@@ -383,9 +383,17 @@ fn onchain_send_receive() {
383383 ) ;
384384
385385 let amount_to_send_sats = 54321 ;
386+ let fee_estimate =
387+ node_a. onchain_payment ( ) . estimate_send_to_address ( & addr_a, amount_to_send_sats, None ) . unwrap ( ) ;
386388 let txid =
387389 node_b. onchain_payment ( ) . send_to_address ( & addr_a, amount_to_send_sats, None ) . unwrap ( ) ;
388390 wait_for_tx ( & electrsd. client , txid) ;
391+
392+ // verify we estimated the fee correctly
393+ let entry = bitcoind. client . get_mempool_entry ( txid) . unwrap ( ) ;
394+ let actual_fee = Amount :: from_btc ( entry. 0 . fees . base ) . unwrap ( ) ;
395+ assert_eq ! ( fee_estimate, actual_fee) ;
396+
389397 node_a. sync_wallets ( ) . unwrap ( ) ;
390398 node_b. sync_wallets ( ) . unwrap ( ) ;
391399
@@ -449,10 +457,19 @@ fn onchain_send_receive() {
449457 }
450458
451459 let addr_b = node_b. onchain_payment ( ) . new_address ( ) . unwrap ( ) ;
460+ let fee_estimate =
461+ node_a. onchain_payment ( ) . estimate_send_all_to_address ( & addr_b, true , None ) . unwrap ( ) ;
452462 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 ) ;
463+
454464 wait_for_tx ( & electrsd. client , txid) ;
455465
466+ // verify we estimated the fee correctly
467+ let entry = bitcoind. client . get_mempool_entry ( txid) . unwrap ( ) ;
468+ let actual_fee = Amount :: from_btc ( entry. 0 . fees . base ) . unwrap ( ) ;
469+ assert_eq ! ( fee_estimate, actual_fee) ;
470+
471+ generate_blocks_and_wait ( & bitcoind. client , & electrsd. client , 6 ) ;
472+
456473 node_a. sync_wallets ( ) . unwrap ( ) ;
457474 node_b. sync_wallets ( ) . unwrap ( ) ;
458475
@@ -522,9 +539,17 @@ fn onchain_send_all_retains_reserve() {
522539 assert_eq ! ( node_b. list_balances( ) . spendable_onchain_balance_sats, premine_amount_sat) ;
523540
524541 // Send all over, with 0 reserve as we don't have any channels open.
542+ let fee_estimate =
543+ node_a. onchain_payment ( ) . estimate_send_all_to_address ( & addr_b, true , None ) . unwrap ( ) ;
525544 let txid = node_a. onchain_payment ( ) . send_all_to_address ( & addr_b, true , None ) . unwrap ( ) ;
526545
527546 wait_for_tx ( & electrsd. client , txid) ;
547+
548+ // verify we estimated the fee correctly
549+ let entry = bitcoind. client . get_mempool_entry ( txid) . unwrap ( ) ;
550+ let actual_fee = Amount :: from_btc ( entry. 0 . fees . base ) . unwrap ( ) ;
551+ assert_eq ! ( fee_estimate, actual_fee) ;
552+
528553 generate_blocks_and_wait ( & bitcoind. client , & electrsd. client , 6 ) ;
529554
530555 node_a. sync_wallets ( ) . unwrap ( ) ;
@@ -563,9 +588,17 @@ fn onchain_send_all_retains_reserve() {
563588 . contains( & node_b. list_balances( ) . spendable_onchain_balance_sats) ) ;
564589
565590 // Send all over again, this time ensuring the reserve is accounted for
591+ let fee_estimate =
592+ node_b. onchain_payment ( ) . estimate_send_all_to_address ( & addr_a, true , None ) . unwrap ( ) ;
566593 let txid = node_b. onchain_payment ( ) . send_all_to_address ( & addr_a, true , None ) . unwrap ( ) ;
567594
568595 wait_for_tx ( & electrsd. client , txid) ;
596+
597+ // verify we estimated the fee correctly
598+ let entry = bitcoind. client . get_mempool_entry ( txid) . unwrap ( ) ;
599+ let actual_fee = Amount :: from_btc ( entry. 0 . fees . base ) . unwrap ( ) ;
600+ assert_eq ! ( fee_estimate, actual_fee) ;
601+
569602 generate_blocks_and_wait ( & bitcoind. client , & electrsd. client , 6 ) ;
570603
571604 node_a. sync_wallets ( ) . unwrap ( ) ;
0 commit comments