@@ -397,10 +397,10 @@ fn do_test_claim_value_force_close(anchors: bool, prev_commitment_tx: bool) {
397
397
assert_eq ! ( ChannelId :: v1_from_funding_outpoint( funding_outpoint) , chan_id) ;
398
398
399
399
// This HTLC is immediately claimed, giving node B the preimage
400
- let ( payment_preimage, payment_hash, ..) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 3_000_000 ) ;
400
+ let ( payment_preimage, payment_hash, ..) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 3_000_100 ) ;
401
401
// This HTLC is allowed to time out, letting A claim it. However, in order to test claimable
402
402
// balances more fully we also give B the preimage for this HTLC.
403
- let ( timeout_payment_preimage, timeout_payment_hash, ..) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 4_000_000 ) ;
403
+ let ( timeout_payment_preimage, timeout_payment_hash, ..) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 4_000_200 ) ;
404
404
// This HTLC will be dust, and not be claimable at all:
405
405
let ( dust_payment_preimage, dust_payment_hash, ..) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 3_000 ) ;
406
406
@@ -451,9 +451,9 @@ fn do_test_claim_value_force_close(anchors: bool, prev_commitment_tx: bool) {
451
451
( chan_utils:: commitment_tx_base_weight ( & channel_type_features) + 2 * chan_utils:: COMMITMENT_TX_WEIGHT_PER_HTLC ) / 1000 ;
452
452
let anchor_outputs_value = if anchors { 2 * channel:: ANCHOR_OUTPUT_VALUE_SATOSHI } else { 0 } ;
453
453
assert_eq ! ( sorted_vec( vec![ Balance :: ClaimableOnChannelClose {
454
- amount_satoshis: 1_000_000 - 3_000 - 4_000 - 1_000 - 3 - commitment_tx_fee - anchor_outputs_value,
454
+ amount_satoshis: 1_000_000 - 3_000 - 4_000 - 1_000 - 3 - commitment_tx_fee - anchor_outputs_value - 1 /* msat amount that is burned to fees */ ,
455
455
transaction_fee_satoshis: commitment_tx_fee,
456
- outbound_payment_htlc_rounded_msat: 3000 ,
456
+ outbound_payment_htlc_rounded_msat: 3300 ,
457
457
outbound_forwarded_htlc_rounded_msat: 0 ,
458
458
inbound_claiming_htlc_rounded_msat: 0 ,
459
459
inbound_htlc_rounded_msat: 0 ,
@@ -465,13 +465,13 @@ fn do_test_claim_value_force_close(anchors: bool, prev_commitment_tx: bool) {
465
465
outbound_payment_htlc_rounded_msat: 0 ,
466
466
outbound_forwarded_htlc_rounded_msat: 0 ,
467
467
inbound_claiming_htlc_rounded_msat: 0 ,
468
- inbound_htlc_rounded_msat: 3000 ,
468
+ inbound_htlc_rounded_msat: 3300 ,
469
469
} , received_htlc_balance. clone( ) , received_htlc_timeout_balance. clone( ) ] ) ,
470
470
sorted_vec( nodes[ 1 ] . chain_monitor. chain_monitor. get_monitor( funding_outpoint) . unwrap( ) . get_claimable_balances( ) ) ) ;
471
471
472
472
nodes[ 1 ] . node . claim_funds ( payment_preimage) ;
473
473
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
474
- expect_payment_claimed ! ( nodes[ 1 ] , payment_hash, 3_000_000 ) ;
474
+ expect_payment_claimed ! ( nodes[ 1 ] , payment_hash, 3_000_100 ) ;
475
475
476
476
let b_htlc_msgs = get_htlc_update_msgs ! ( & nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ;
477
477
// We claim the dust payment here as well, but it won't impact our claimable balances as its
@@ -482,7 +482,7 @@ fn do_test_claim_value_force_close(anchors: bool, prev_commitment_tx: bool) {
482
482
483
483
nodes[ 1 ] . node . claim_funds ( timeout_payment_preimage) ;
484
484
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
485
- expect_payment_claimed ! ( nodes[ 1 ] , timeout_payment_hash, 4_000_000 ) ;
485
+ expect_payment_claimed ! ( nodes[ 1 ] , timeout_payment_hash, 4_000_200 ) ;
486
486
487
487
if prev_commitment_tx {
488
488
// To build a previous commitment transaction, deliver one round of commitment messages.
@@ -511,9 +511,11 @@ fn do_test_claim_value_force_close(anchors: bool, prev_commitment_tx: bool) {
511
511
1_000 - // The push_msat value in satoshis
512
512
3 - // The dust HTLC value in satoshis
513
513
commitment_tx_fee - // The commitment transaction fee with two HTLC outputs
514
- anchor_outputs_value, // The anchor outputs value in satoshis
514
+ anchor_outputs_value - // The anchor outputs value in satoshis
515
+ 1 , // The rounded up msat part of the one HTLC
515
516
transaction_fee_satoshis: commitment_tx_fee,
516
- outbound_payment_htlc_rounded_msat: 3000 ,
517
+ outbound_payment_htlc_rounded_msat: 3000 + if prev_commitment_tx {
518
+ 200 /* 1 to-be-failed HTLC */ } else { 300 /* 2 HTLCs */ } ,
517
519
outbound_forwarded_htlc_rounded_msat: 0 ,
518
520
inbound_claiming_htlc_rounded_msat: 0 ,
519
521
inbound_htlc_rounded_msat: 0 ,
@@ -528,7 +530,8 @@ fn do_test_claim_value_force_close(anchors: bool, prev_commitment_tx: bool) {
528
530
transaction_fee_satoshis: 0 ,
529
531
outbound_payment_htlc_rounded_msat: 0 ,
530
532
outbound_forwarded_htlc_rounded_msat: 0 ,
531
- inbound_claiming_htlc_rounded_msat: 3000 ,
533
+ inbound_claiming_htlc_rounded_msat: 3000 + if prev_commitment_tx {
534
+ 200 /* 1 HTLC */ } else { 300 /* 2 HTLCs */ } ,
532
535
inbound_htlc_rounded_msat: 0 ,
533
536
} ] ,
534
537
nodes[ 1 ] . chain_monitor. chain_monitor. get_monitor( funding_outpoint) . unwrap( ) . get_claimable_balances( ) ) ;
@@ -593,7 +596,14 @@ fn do_test_claim_value_force_close(anchors: bool, prev_commitment_tx: bool) {
593
596
let commitment_tx_fee = chan_feerate as u64 *
594
597
( chan_utils:: commitment_tx_base_weight ( & channel_type_features) + 2 * chan_utils:: COMMITMENT_TX_WEIGHT_PER_HTLC ) / 1000 ;
595
598
assert_eq ! ( sorted_vec( vec![ Balance :: ClaimableAwaitingConfirmations {
596
- amount_satoshis: 1_000_000 - 3_000 - 4_000 - 1_000 - 3 - commitment_tx_fee - anchor_outputs_value,
599
+ amount_satoshis: 1_000_000 - // Channel funding value in satoshis
600
+ 4_000 - // The to-be-failed HTLC value in satoshis
601
+ 3_000 - // The claimed HTLC value in satoshis
602
+ 1_000 - // The push_msat value in satoshis
603
+ 3 - // The dust HTLC value in satoshis
604
+ commitment_tx_fee - // The commitment transaction fee with two HTLC outputs
605
+ anchor_outputs_value - // The anchor outputs value in satoshis
606
+ 1 , // The rounded up msat parts of HTLCs
597
607
confirmation_height: nodes[ 0 ] . best_block_info( ) . 1 + ANTI_REORG_DELAY - 1 ,
598
608
} , sent_htlc_balance. clone( ) , sent_htlc_timeout_balance. clone( ) ] ) ,
599
609
sorted_vec( nodes[ 0 ] . chain_monitor. chain_monitor. get_monitor( funding_outpoint) . unwrap( ) . get_claimable_balances( ) ) ) ;
@@ -1240,8 +1250,8 @@ fn do_test_revoked_counterparty_commitment_balances(anchors: bool, confirm_htlc_
1240
1250
// are all currently claimed in separate transactions, which helps us test as we can claim
1241
1251
// HTLCs individually.
1242
1252
1243
- let ( claimed_payment_preimage, claimed_payment_hash, ..) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 3_000_000 ) ;
1244
- let timeout_payment_hash = route_payment ( & nodes[ 1 ] , & [ & nodes[ 0 ] ] , 4_000_000 ) . 1 ;
1253
+ let ( claimed_payment_preimage, claimed_payment_hash, ..) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 3_000_100 ) ;
1254
+ let timeout_payment_hash = route_payment ( & nodes[ 1 ] , & [ & nodes[ 0 ] ] , 4_000_200 ) . 1 ;
1245
1255
let dust_payment_hash = route_payment ( & nodes[ 1 ] , & [ & nodes[ 0 ] ] , 3_000 ) . 1 ;
1246
1256
1247
1257
let htlc_cltv_timeout = nodes[ 0 ] . best_block_info ( ) . 1 + TEST_FINAL_CLTV + 1 ; // Note ChannelManager adds one to CLTV timeouts for safety
@@ -1262,7 +1272,7 @@ fn do_test_revoked_counterparty_commitment_balances(anchors: bool, confirm_htlc_
1262
1272
let missing_htlc_payment_hash = route_payment ( & nodes[ 1 ] , & [ & nodes[ 0 ] ] , 2_000_000 ) . 1 ;
1263
1273
1264
1274
nodes[ 1 ] . node . claim_funds ( claimed_payment_preimage) ;
1265
- expect_payment_claimed ! ( nodes[ 1 ] , claimed_payment_hash, 3_000_000 ) ;
1275
+ expect_payment_claimed ! ( nodes[ 1 ] , claimed_payment_hash, 3_000_100 ) ;
1266
1276
check_added_monitors ! ( nodes[ 1 ] , 1 ) ;
1267
1277
let _b_htlc_msgs = get_htlc_update_msgs ! ( & nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ;
1268
1278
@@ -1304,11 +1314,11 @@ fn do_test_revoked_counterparty_commitment_balances(anchors: bool, confirm_htlc_
1304
1314
// Prior to channel closure, B considers the preimage HTLC as its own, and otherwise only
1305
1315
// lists the two on-chain timeout-able HTLCs as claimable balances.
1306
1316
assert_eq ! ( sorted_vec( vec![ Balance :: ClaimableOnChannelClose {
1307
- amount_satoshis: 100_000 - 5_000 - 4_000 - 3 - 2_000 + 3_000 ,
1317
+ amount_satoshis: 100_000 - 5_000 - 4_000 - 3 - 2_000 + 3_000 - 1 /* rounded up msat parts of HTLCs */ ,
1308
1318
transaction_fee_satoshis: 0 ,
1309
- outbound_payment_htlc_rounded_msat: 3000 ,
1319
+ outbound_payment_htlc_rounded_msat: 3200 ,
1310
1320
outbound_forwarded_htlc_rounded_msat: 0 ,
1311
- inbound_claiming_htlc_rounded_msat: 0 ,
1321
+ inbound_claiming_htlc_rounded_msat: 100 ,
1312
1322
inbound_htlc_rounded_msat: 0 ,
1313
1323
} , Balance :: MaybeTimeoutClaimableHTLC {
1314
1324
amount_satoshis: 2_000 ,
@@ -1358,7 +1368,7 @@ fn do_test_revoked_counterparty_commitment_balances(anchors: bool, confirm_htlc_
1358
1368
// claim balances separated out.
1359
1369
let expected_balance = vec ! [ Balance :: ClaimableAwaitingConfirmations {
1360
1370
// to_remote output in A's revoked commitment
1361
- amount_satoshis: 100_000 - 5_000 - 4_000 - 3 ,
1371
+ amount_satoshis: 100_000 - 5_000 - 4_000 - 3 - 1 /* rounded up msat parts of HTLCs */ ,
1362
1372
confirmation_height: nodes[ 1 ] . best_block_info( ) . 1 + 5 ,
1363
1373
} , Balance :: CounterpartyRevokedOutputClaimable {
1364
1374
amount_satoshis: 3_000 ,
@@ -1367,7 +1377,7 @@ fn do_test_revoked_counterparty_commitment_balances(anchors: bool, confirm_htlc_
1367
1377
} ] ;
1368
1378
1369
1379
let to_self_unclaimed_balance = Balance :: CounterpartyRevokedOutputClaimable {
1370
- amount_satoshis : 1_000_000 - 100_000 - 3_000 - commitment_tx_fee - anchor_outputs_value,
1380
+ amount_satoshis : 1_000_000 - 100_000 - 3_000 - commitment_tx_fee - anchor_outputs_value - 1 /* rounded up msat parts of HTLCs */ ,
1371
1381
} ;
1372
1382
let to_self_claimed_avail_height;
1373
1383
let largest_htlc_unclaimed_balance = Balance :: CounterpartyRevokedOutputClaimable {
@@ -1396,7 +1406,7 @@ fn do_test_revoked_counterparty_commitment_balances(anchors: bool, confirm_htlc_
1396
1406
confirmation_height : largest_htlc_claimed_avail_height,
1397
1407
} ;
1398
1408
let to_self_claimed_balance = Balance :: ClaimableAwaitingConfirmations {
1399
- amount_satoshis : 1_000_000 - 100_000 - 3_000 - commitment_tx_fee - anchor_outputs_value - to_self_claim_fee,
1409
+ amount_satoshis : 1_000_000 - 100_000 - 3_000 - commitment_tx_fee - anchor_outputs_value - to_self_claim_fee - 1 /* rounded up msat parts of HTLCs */ ,
1400
1410
confirmation_height : to_self_claimed_avail_height,
1401
1411
} ;
1402
1412
@@ -1423,10 +1433,10 @@ fn do_test_revoked_counterparty_commitment_balances(anchors: bool, confirm_htlc_
1423
1433
1424
1434
assert_eq ! ( sorted_vec( vec![ Balance :: ClaimableAwaitingConfirmations {
1425
1435
// to_remote output in A's revoked commitment
1426
- amount_satoshis: 100_000 - 5_000 - 4_000 - 3 ,
1436
+ amount_satoshis: 100_000 - 5_000 - 4_000 - 3 - 1 /* rounded up msat parts of HTLCs */ ,
1427
1437
confirmation_height: nodes[ 1 ] . best_block_info( ) . 1 + 1 ,
1428
1438
} , Balance :: ClaimableAwaitingConfirmations {
1429
- amount_satoshis: 1_000_000 - 100_000 - 3_000 - commitment_tx_fee - anchor_outputs_value - to_self_claim_fee,
1439
+ amount_satoshis: 1_000_000 - 100_000 - 3_000 - commitment_tx_fee - anchor_outputs_value - to_self_claim_fee - 1 /* rounded up msat parts of HTLCs */ ,
1430
1440
confirmation_height: to_self_claimed_avail_height,
1431
1441
} , Balance :: ClaimableAwaitingConfirmations {
1432
1442
amount_satoshis: 3_000 - outbound_htlc_claim_fee,
@@ -1517,7 +1527,7 @@ fn do_test_revoked_counterparty_htlc_tx_balances(anchors: bool) {
1517
1527
let funding_outpoint = OutPoint { txid : funding_tx. txid ( ) , index : 0 } ;
1518
1528
assert_eq ! ( ChannelId :: v1_from_funding_outpoint( funding_outpoint) , chan_id) ;
1519
1529
1520
- let payment_preimage = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 3_000_000 ) . 0 ;
1530
+ let payment_preimage = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 3_000_100 ) . 0 ;
1521
1531
let failed_payment_hash = route_payment ( & nodes[ 1 ] , & [ & nodes[ 0 ] ] , 1_000_000 ) . 1 ;
1522
1532
let revoked_local_txn = get_local_commitment_txn ! ( nodes[ 1 ] , chan_id) ;
1523
1533
assert_eq ! ( revoked_local_txn[ 0 ] . input. len( ) , 1 ) ;
@@ -1612,7 +1622,7 @@ fn do_test_revoked_counterparty_htlc_tx_balances(anchors: bool) {
1612
1622
let anchor_outputs_value = if anchors { channel:: ANCHOR_OUTPUT_VALUE_SATOSHI * 2 } else { 0 } ;
1613
1623
let as_balances = sorted_vec ( vec ! [ Balance :: ClaimableAwaitingConfirmations {
1614
1624
// to_remote output in B's revoked commitment
1615
- amount_satoshis: 1_000_000 - 12_000 - 3_000 - commitment_tx_fee - anchor_outputs_value,
1625
+ amount_satoshis: 1_000_000 - 12_000 - 3_000 - commitment_tx_fee - anchor_outputs_value - 1 /* The rounded up msat part of the one HTLC */ ,
1616
1626
confirmation_height: to_remote_conf_height,
1617
1627
} , Balance :: CounterpartyRevokedOutputClaimable {
1618
1628
// to_self output in B's revoked commitment
@@ -1657,7 +1667,7 @@ fn do_test_revoked_counterparty_htlc_tx_balances(anchors: bool) {
1657
1667
mine_transaction ( & nodes[ 0 ] , & as_htlc_claim_tx[ 0 ] ) ;
1658
1668
assert_eq ! ( sorted_vec( vec![ Balance :: ClaimableAwaitingConfirmations {
1659
1669
// to_remote output in B's revoked commitment
1660
- amount_satoshis: 1_000_000 - 12_000 - 3_000 - commitment_tx_fee - anchor_outputs_value,
1670
+ amount_satoshis: 1_000_000 - 12_000 - 3_000 - commitment_tx_fee - anchor_outputs_value - 1 /* rounded up msat parts of HTLCs */ ,
1661
1671
confirmation_height: to_remote_conf_height,
1662
1672
} , Balance :: CounterpartyRevokedOutputClaimable {
1663
1673
// to_self output in B's revoked commitment
@@ -1823,7 +1833,7 @@ fn do_test_revoked_counterparty_aggregated_claims(anchors: bool) {
1823
1833
// transaction, and one which we will not, allowing B to claim the HTLC output in an aggregated
1824
1834
// revocation-claim transaction.
1825
1835
1826
- let ( claimed_payment_preimage, claimed_payment_hash, ..) = route_payment ( & nodes[ 1 ] , & [ & nodes[ 0 ] ] , 3_000_000 ) ;
1836
+ let ( claimed_payment_preimage, claimed_payment_hash, ..) = route_payment ( & nodes[ 1 ] , & [ & nodes[ 0 ] ] , 3_000_100 ) ;
1827
1837
let revoked_payment_hash = route_payment ( & nodes[ 1 ] , & [ & nodes[ 0 ] ] , 4_000_000 ) . 1 ;
1828
1838
1829
1839
let htlc_cltv_timeout = nodes[ 1 ] . best_block_info ( ) . 1 + TEST_FINAL_CLTV + 1 ; // Note ChannelManager adds one to CLTV timeouts for safety
@@ -1857,14 +1867,14 @@ fn do_test_revoked_counterparty_aggregated_claims(anchors: bool) {
1857
1867
commitment_signed_dance ! ( nodes[ 1 ] , nodes[ 0 ] , fee_update. commitment_signed, false ) ;
1858
1868
1859
1869
nodes[ 0 ] . node . claim_funds ( claimed_payment_preimage) ;
1860
- expect_payment_claimed ! ( nodes[ 0 ] , claimed_payment_hash, 3_000_000 ) ;
1870
+ expect_payment_claimed ! ( nodes[ 0 ] , claimed_payment_hash, 3_000_100 ) ;
1861
1871
check_added_monitors ! ( nodes[ 0 ] , 1 ) ;
1862
1872
let _a_htlc_msgs = get_htlc_update_msgs ! ( & nodes[ 0 ] , nodes[ 1 ] . node. get_our_node_id( ) ) ;
1863
1873
1864
1874
assert_eq ! ( sorted_vec( vec![ Balance :: ClaimableOnChannelClose {
1865
- amount_satoshis: 100_000 - 4_000 - 3_000 ,
1875
+ amount_satoshis: 100_000 - 4_000 - 3_000 - 1 /* rounded up msat parts of HTLCs */ ,
1866
1876
transaction_fee_satoshis: 0 ,
1867
- outbound_payment_htlc_rounded_msat: 0 ,
1877
+ outbound_payment_htlc_rounded_msat: 100 ,
1868
1878
outbound_forwarded_htlc_rounded_msat: 0 ,
1869
1879
inbound_claiming_htlc_rounded_msat: 0 ,
1870
1880
inbound_htlc_rounded_msat: 0 ,
@@ -1913,7 +1923,7 @@ fn do_test_revoked_counterparty_aggregated_claims(anchors: bool) {
1913
1923
let anchor_outputs_value = if anchors { channel:: ANCHOR_OUTPUT_VALUE_SATOSHI * 2 } else { 0 } ;
1914
1924
assert_eq ! ( sorted_vec( vec![ Balance :: ClaimableAwaitingConfirmations {
1915
1925
// to_remote output in A's revoked commitment
1916
- amount_satoshis: 100_000 - 4_000 - 3_000 ,
1926
+ amount_satoshis: 100_000 - 4_000 - 3_000 - 1 /* rounded up msat parts of HTLCs */ ,
1917
1927
confirmation_height: to_remote_maturity,
1918
1928
} , Balance :: CounterpartyRevokedOutputClaimable {
1919
1929
// to_self output in A's revoked commitment
@@ -1968,7 +1978,7 @@ fn do_test_revoked_counterparty_aggregated_claims(anchors: bool) {
1968
1978
1969
1979
assert_eq ! ( sorted_vec( vec![ Balance :: ClaimableAwaitingConfirmations {
1970
1980
// to_remote output in A's revoked commitment
1971
- amount_satoshis: 100_000 - 4_000 - 3_000 ,
1981
+ amount_satoshis: 100_000 - 4_000 - 3_000 - 1 /* rounded up msat parts of HTLCs */ ,
1972
1982
confirmation_height: to_remote_maturity,
1973
1983
} , Balance :: CounterpartyRevokedOutputClaimable {
1974
1984
// to_self output in A's revoked commitment
0 commit comments