You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Force close with a trusted counterparty is never broadcast: add a function to send it #1219
With the counterparty in AnchorChannelsConfig::trusted_peers_no_reserve, our own force close of an anchor channel is never broadcast. force_close_channel closes the channel and LDK hands the commitment over in BumpTransactionEvent::ChannelClose, but the event handler returns early for trusted counterparties ("Skip bumping channel closes if our counterparty is trusted", src/event.rs, still on main at 79e4d92). The close reaches the chain only if the counterparty broadcasts its own commitment. If it stays offline, the funds stay in the channel.
This is the usual setup for a mobile wallet with an LSP, where the user keeps no on-chain reserve. Our app (Stable Channels) lists its LSP there.
What we saw
Regtest (ldk-node 47dad6d, LDK 090e09f): with the LSP stopped, force_close_channel leaves the mempool empty.
Mainnet (our iOS app, on a fork of ldk-node with the same check): after force_close_channel the node logs Ignoring BumpTransactionEvent::ChannelClose for channel ... due to trusted counterparty ... and broadcasts nothing.
Our workaround
The app stops the node and reads its channel monitors from the store (MonitorUpdatingPersister::read_all_channel_monitors_with_updates). It calls broadcast_latest_holder_commitment_txn on that copy and takes commitment_tx from the ChannelClose event. It broadcasts the commitment with a child that spends only our anchor output, paying to the OP_RETURN <3 zero bytes> output that BumpTransactionEventHandler uses for a single input with no change.
Mainnet: the commitment 7c91f6de65f1242361b178b438fc3bcdb3186ae8ff99644af3ae687c668c230b paid 284 sats (1.02 sat/vB). With the child 8a984928bad2f7377f73b58bbd79a0687b3ea7e06ea57b2709b24343891800f2 the package paid 1.65 sat/vB. Both confirmed in the next block (974384).
Regtest: the same flow, and after the CSV delay the restarted node sweeps to_local to its wallet. On mainnet our output unlocks at block 974528; not checked yet.
This needs no reserve, since the anchor's 330 sats pay for the bump. It only works while that package rate is enough for the mempool.
Ask
A Node function that sends our close for a trusted counterparty, so apps don't have to read the store of a stopped node. For example:
/// Broadcasts the latest holder commitment of a channel we force closed with a counterparty in/// `trusted_peers_no_reserve`, with a child that spends only our anchor output.pubfnbroadcast_force_close(&self,channel_id:&ChannelId,counterparty_node_id:PublicKey,) -> Result<(),Error>
The name and shape are up to you. If you'd rather change the default, broadcasting commitment_tx with an anchor-only bump in the event handler for trusted counterparties would also work for us.
Related: #988 (a read-only accessor for the latest holder commitment) and lightningdevkit/orange-sdk#95 (the same failure seen from orange-sdk). Their author closed both while trying another approach.
Activity