@@ -383,9 +383,19 @@ fn onchain_send_receive() {
383
383
) ;
384
384
385
385
let amount_to_send_sats = 54321 ;
386
+ let fee_estimate = node_a
387
+ . onchain_payment ( )
388
+ . estimate_send_to_address ( & addr_a, amount_to_send_sats, None )
389
+ . unwrap ( ) ;
386
390
let txid =
387
391
node_b. onchain_payment ( ) . send_to_address ( & addr_a, amount_to_send_sats, None ) . unwrap ( ) ;
388
392
wait_for_tx ( & electrsd. client , txid) ;
393
+
394
+ // verify we estimated the fee correctly
395
+ let entry = bitcoind. client . get_mempool_entry ( txid) . unwrap ( ) ;
396
+ let actual_fee = Amount :: from_btc ( entry. 0 . fees . base ) . unwrap ( ) ;
397
+ assert_eq ! ( fee_estimate, actual_fee) ;
398
+
389
399
node_a. sync_wallets ( ) . unwrap ( ) ;
390
400
node_b. sync_wallets ( ) . unwrap ( ) ;
391
401
@@ -449,10 +459,19 @@ fn onchain_send_receive() {
449
459
}
450
460
451
461
let addr_b = node_b. onchain_payment ( ) . new_address ( ) . unwrap ( ) ;
462
+ let fee_estimate =
463
+ node_a. onchain_payment ( ) . estimate_send_all_to_address ( & addr_b, true , None ) . unwrap ( ) ;
452
464
let txid = node_a. onchain_payment ( ) . send_all_to_address ( & addr_b, true , None ) . unwrap ( ) ;
453
- generate_blocks_and_wait ( & bitcoind . client , & electrsd . client , 6 ) ;
465
+
454
466
wait_for_tx ( & electrsd. client , txid) ;
455
467
468
+ // verify we estimated the fee correctly
469
+ let entry = bitcoind. client . get_mempool_entry ( txid) . unwrap ( ) ;
470
+ let actual_fee = Amount :: from_btc ( entry. 0 . fees . base ) . unwrap ( ) ;
471
+ assert_eq ! ( fee_estimate, actual_fee) ;
472
+
473
+ generate_blocks_and_wait ( & bitcoind. client , & electrsd. client , 6 ) ;
474
+
456
475
node_a. sync_wallets ( ) . unwrap ( ) ;
457
476
node_b. sync_wallets ( ) . unwrap ( ) ;
458
477
@@ -522,9 +541,17 @@ fn onchain_send_all_retains_reserve() {
522
541
assert_eq ! ( node_b. list_balances( ) . spendable_onchain_balance_sats, premine_amount_sat) ;
523
542
524
543
// Send all over, with 0 reserve as we don't have any channels open.
544
+ let fee_estimate =
545
+ node_a. onchain_payment ( ) . estimate_send_all_to_address ( & addr_b, true , None ) . unwrap ( ) ;
525
546
let txid = node_a. onchain_payment ( ) . send_all_to_address ( & addr_b, true , None ) . unwrap ( ) ;
526
547
527
548
wait_for_tx ( & electrsd. client , txid) ;
549
+
550
+ // verify we estimated the fee correctly
551
+ let entry = bitcoind. client . get_mempool_entry ( txid) . unwrap ( ) ;
552
+ let actual_fee = Amount :: from_btc ( entry. 0 . fees . base ) . unwrap ( ) ;
553
+ assert_eq ! ( fee_estimate, actual_fee) ;
554
+
528
555
generate_blocks_and_wait ( & bitcoind. client , & electrsd. client , 6 ) ;
529
556
530
557
node_a. sync_wallets ( ) . unwrap ( ) ;
@@ -563,9 +590,17 @@ fn onchain_send_all_retains_reserve() {
563
590
. contains( & node_b. list_balances( ) . spendable_onchain_balance_sats) ) ;
564
591
565
592
// Send all over again, this time ensuring the reserve is accounted for
593
+ let fee_estimate =
594
+ node_b. onchain_payment ( ) . estimate_send_all_to_address ( & addr_a, true , None ) . unwrap ( ) ;
566
595
let txid = node_b. onchain_payment ( ) . send_all_to_address ( & addr_a, true , None ) . unwrap ( ) ;
567
596
568
597
wait_for_tx ( & electrsd. client , txid) ;
598
+
599
+ // verify we estimated the fee correctly
600
+ let entry = bitcoind. client . get_mempool_entry ( txid) . unwrap ( ) ;
601
+ let actual_fee = Amount :: from_btc ( entry. 0 . fees . base ) . unwrap ( ) ;
602
+ assert_eq ! ( fee_estimate, actual_fee) ;
603
+
569
604
generate_blocks_and_wait ( & bitcoind. client , & electrsd. client , 6 ) ;
570
605
571
606
node_a. sync_wallets ( ) . unwrap ( ) ;
0 commit comments