Build a Conditional Payment with a Hold Invoice
Pause an Invoice payment at the receiver, inspect its pending state, then explicitly settle or cancel it.
Create an Invoice that cannot settle automatically
Node C generates the preimage locally, publishes only its SHA-256 hash in the Invoice, and keeps the preimage outside the node until a business condition is satisfied. The Invoice explicitly sets hash_algorithm: 'sha256' so settlement validates the preimage with the same algorithm.
Prepare liquidity and supply the final hop
A newly funded receiver channel starts with its balance on Receiver C's side. Receiver C first sends a small Testnet payment to Bottle, moving 5 CKB to the remote side. Payer A then submits the Invoice with a private last-hop hint for Bottle → C.
The Live Demo checks both channel liquidity and peer connections. Its last-hop hint removes the need to wait for the receiver channel to propagate through public gossip.
Poll both sides without blocking the UI
Node C progresses from Open to Received, while Node A stays Inflight. This is the decision window.
Settle with the preimage or cancel
Settle releases the secret and completes the payment atomically. Cancel rejects the held Invoice and releases its pending liquidity.
lib/hold-invoice.ts · lines 19–25Expose the pending state as an explicit action
The interface enables Settle and Cancel only after the receiver reports Received, preventing an accidental early decision.