Skip to main content

check_inbound_registration

Function check_inbound_registration 

Source
fn check_inbound_registration(
    outbound_lock_acquired: bool,
    existing_direction: Option<PaymentDirection>,
) -> Result<(), InboundRegistrationRefusal>
Expand description

Decides whether an invoice may be registered for a payment hash the node may already know as one of our outbound payments.

ldk-node keys BOLT11 payments by PaymentId(payment_hash) in both directions, and registering an invoice overwrites whatever record shares the key. Registering one for a hash we pay would erase the outbound record pay() reads its result from, so a settled payment would be reported as failed and the outgoing contract forfeited while the payee keeps the funds.

outbound_lock_acquired is whether the caller took the per-hash lock pay() holds for the whole life of a payment, and existing_direction is the direction of the node’s record for the hash, if any. A terminal outbound record is refused as well: a restarted state machine re-runs pay() and needs that record to recover the payment’s result instead of re-dispatching. An existing inbound record is left to the caller, whose own reservation already rejects duplicate registrations.