@@ -383,9 +383,19 @@ fn onchain_send_receive() {
383383 ) ;
384384
385385 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 ( ) ;
386390 let txid =
387391 node_b. onchain_payment ( ) . send_to_address ( & addr_a, amount_to_send_sats, None ) . unwrap ( ) ;
388392 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+
389399 node_a. sync_wallets ( ) . unwrap ( ) ;
390400 node_b. sync_wallets ( ) . unwrap ( ) ;
391401
@@ -449,10 +459,19 @@ fn onchain_send_receive() {
449459 }
450460
451461 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 ( ) ;
452464 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+
454466 wait_for_tx ( & electrsd. client , txid) ;
455467
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+
456475 node_a. sync_wallets ( ) . unwrap ( ) ;
457476 node_b. sync_wallets ( ) . unwrap ( ) ;
458477
@@ -522,9 +541,17 @@ fn onchain_send_all_retains_reserve() {
522541 assert_eq ! ( node_b. list_balances( ) . spendable_onchain_balance_sats, premine_amount_sat) ;
523542
524543 // 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 ( ) ;
525546 let txid = node_a. onchain_payment ( ) . send_all_to_address ( & addr_b, true , None ) . unwrap ( ) ;
526547
527548 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+
528555 generate_blocks_and_wait ( & bitcoind. client , & electrsd. client , 6 ) ;
529556
530557 node_a. sync_wallets ( ) . unwrap ( ) ;
@@ -563,9 +590,17 @@ fn onchain_send_all_retains_reserve() {
563590 . contains( & node_b. list_balances( ) . spendable_onchain_balance_sats) ) ;
564591
565592 // 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 ( ) ;
566595 let txid = node_b. onchain_payment ( ) . send_all_to_address ( & addr_a, true , None ) . unwrap ( ) ;
567596
568597 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+
569604 generate_blocks_and_wait ( & bitcoind. client , & electrsd. client , 6 ) ;
570605
571606 node_a. sync_wallets ( ) . unwrap ( ) ;
0 commit comments