Skip to content

Commit 80b18f1

Browse files
committed
f use helper, update err/comment for sp
1 parent 40d2d67 commit 80b18f1

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lightning/src/ln/channel.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -934,11 +934,11 @@ impl<Signer: Sign> Channel<Signer> {
934934
let funders_amount_msat = msg.funding_satoshis * 1000 - msg.push_msat;
935935
let commitment_tx_fee = msg.feerate_per_kw as u64 * (COMMITMENT_TX_BASE_WEIGHT + 4 * COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000;
936936
if funders_amount_msat / 1000 < commitment_tx_fee {
937-
return Err(ChannelError::Close(format!("Funding amount ({}) can't even pay fee for initial commitment transaction fee of {}.", funders_amount_msat / 1000, commitment_tx_fee)));
937+
return Err(ChannelError::Close(format!("Funding amount ({} sats) can't even pay fee for initial commitment transaction fee of {} sats.", funders_amount_msat / 1000, commitment_tx_fee)));
938938
}
939939

940940
let to_remote_satoshis = funders_amount_msat / 1000 - commitment_tx_fee;
941-
// While its reasonable for us to not meet the channel reserve initially (if they don't
941+
// While it's reasonable for us to not meet the channel reserve initially (if they don't
942942
// want to push much to us), our counterparty should always have more than our reserve.
943943
if to_remote_satoshis < holder_selected_channel_reserve_satoshis {
944944
return Err(ChannelError::Close("Insufficient funding amount for initial reserve".to_owned()));

lightning/src/ln/functional_tests.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1400,7 +1400,7 @@ fn test_chan_reserve_violation_outbound_htlc_inbound_chan() {
14001400
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
14011401

14021402
let mut push_amt = 100_000_000;
1403-
push_amt -= feerate_per_kw as u64 * (COMMITMENT_TX_BASE_WEIGHT + 4 * COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000 * 1000;
1403+
push_amt -= commit_tx_fee_msat(feerate_per_kw, 4);
14041404
push_amt -= Channel::<EnforcingSigner>::get_holder_selected_channel_reserve_satoshis(100_000) * 1000;
14051405

14061406
let _ = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100_000, push_amt, InitFeatures::known(), InitFeatures::known());
@@ -1431,7 +1431,7 @@ fn test_chan_reserve_violation_inbound_htlc_outbound_channel() {
14311431
// channel reserve violation (so their balance is channel reserve (1000 sats) + commitment
14321432
// transaction fee with 0 HTLCs (183 sats)).
14331433
let mut push_amt = 100_000_000;
1434-
push_amt -= feerate_per_kw as u64 * (COMMITMENT_TX_BASE_WEIGHT + 4 * COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000 * 1000;
1434+
push_amt -= commit_tx_fee_msat(feerate_per_kw, 4);
14351435
push_amt -= Channel::<EnforcingSigner>::get_holder_selected_channel_reserve_satoshis(100_000) * 1000;
14361436
let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100_000, push_amt, InitFeatures::known(), InitFeatures::known());
14371437

@@ -1485,7 +1485,7 @@ fn test_chan_reserve_dust_inbound_htlcs_outbound_chan() {
14851485
// channel reserve violation (so their balance is channel reserve (1000 sats) + commitment
14861486
// transaction fee with 0 HTLCs (183 sats)).
14871487
let mut push_amt = 100_000_000;
1488-
push_amt -= feerate_per_kw as u64 * (COMMITMENT_TX_BASE_WEIGHT + 4 * COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000 * 1000;
1488+
push_amt -= commit_tx_fee_msat(feerate_per_kw, 4);
14891489
push_amt -= Channel::<EnforcingSigner>::get_holder_selected_channel_reserve_satoshis(100_000) * 1000;
14901490
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, push_amt, InitFeatures::known(), InitFeatures::known());
14911491

0 commit comments

Comments
 (0)