Skip to content

Fix reachable unwrap of outbound_htlc_minimum_msat - #211

Merged
tnull merged 1 commit into
lightningdevkit:mainfrom
tnull:2023-11-fix-reachable-chandetails-unwrap
Nov 27, 2023
Merged

tnull merged 1 commit into
lightningdevkit:mainfrom
tnull:2023-11-fix-reachable-chandetails-unwrap

Conversation

@tnull

@tnull tnull commented Nov 27, 2023

Copy link
Copy Markdown
Collaborator

Fixes #208.

As the unwrap previously was reachable we now expose the field as an Option. Additionally, we document the unwrap safety of the other ChannelDetails fields where applicable.

As the `unwrap` previously was reachable we now expose the field as an
`Option`. Additionally, we document the unwrap safety of the other
`ChannelDetails` fields where applicable.
@tnull
tnull force-pushed the 2023-11-fix-reachable-chandetails-unwrap branch from 492762e to d09c572 Compare November 27, 2023 13:01
@tnull
tnull merged commit f42d604 into lightningdevkit:main Nov 27, 2023
jbesraa added a commit to blocknil/ldk-node that referenced this pull request Nov 28, 2026
…nfirmed_unlocked_amount_sats

Follow-up to the previous commit, the same patch. The wallet's sum becomes upstream's
Wallet::get_confirmed_unlocked_amount_sats (ldk-node lightningdevkit#1223, 6fb3d52) word for word, taken alone
with its unit test, so that the Blocknil part is the public wrapper
(Node::confirmed_spendable_onchain_balance_sats, less the anchor reserve) and moving to upstream
drops the copy. Upstream's sum leaves out what ours also skipped (immature coinbase outputs, a
coin whose transaction is too large for tx_add_input); neither is on a provider's wallet, and
either would only make the figure higher than coin selection can use, as before lightningdevkit#211's fix.
The rest of lightningdevkit#1223 (the splice anchor-reserve checks) isn't taken: it conflicts with our
change-keeping splice_in in splice_channel.

Tests: confirmed_unlocked_amount_does_not_depend_on_seeing_a_splice (upstream's; the splice is
signed here for bdk_wallet 3.2.1, ldk3-bdk-3.2.1). The integration test drops its "in a block
but not synced" assertion: the node's background sync can run first, so it raced (failed once).
jbesraa added a commit to blocknil/ldk-node that referenced this pull request Nov 28, 2026
…nd a reserve refusal in splice_in_with_change as InsufficientFunds

From the review of r11, for the provider's splice on arrival (bitcoin-wallet lightningdevkit#211).

- Node::confirmed_spendable_utxo_values: the value of each coin confirmed_spendable_onchain_balance_sats
  counts (Wallet::get_confirmed_unlocked_utxo_values, the filter of upstream's
  get_confirmed_unlocked_amount_sats). The provider sized a splice's fee for a flat 300 vB, so a
  wallet of many small coins was quoted, then refused after the customer's yes; with the values it
  can size the fee for the coins selection would use, largest first.
- In splice_in_inner's Exact arm, when keep_change (splice_in_with_change), the anchor-reserve check
  after coin selection (upstream lightningdevkit#1223) fails with InsufficientFunds, as that method does when no
  coins leave change. It returned ChannelSplicingFailed, which a caller can't tell from a splice that
  can't start. Upstream's splice_in keeps ChannelSplicingFailed.

Tests: splice_in_with_change_reports_a_fee_into_the_anchor_reserve_as_insufficient_funds (fails with
ChannelSplicingFailed without the mapping, checked) and confirmed_spendable_balance_leaves_out_unconfirmed_change,
which now also checks the values at each step.
jbesraa added a commit to blocknil/ldk-node that referenced this pull request Nov 28, 2026
…nnounce in tx_add_input

Coin selection for a splice marks unspendable a coin whose previous
transaction is too large to carry in a tx_add_input (fits_tx_add_input).
get_confirmed_unlocked_utxo_values listed it anyway, and so did the balance
the provider checks, so a provider funded by a large batch payment could
quote a splice on that coin and have it refused after the customer's yes.
The values now use the same filter, and confirmed_spendable_onchain_balance_sats
is their sum (less the anchor reserve), so the provider's two figures agree.
Upstream's get_confirmed_unlocked_amount_sats, which its own splice checks use,
is unchanged. The docs say smallest first, as the provider sizes it.

Test: confirmed_unlocked_utxo_values_leave_out_coins_too_large_to_announce
fails without the filter (both coins listed).

Review of r11 (bitcoin-wallet lightningdevkit#211).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix reachable unwrap when creating ChannelDetails

1 participant