@@ -383,9 +383,17 @@ fn onchain_send_receive() {
383
383
) ;
384
384
385
385
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 ( ) ;
386
388
let txid =
387
389
node_b. onchain_payment ( ) . send_to_address ( & addr_a, amount_to_send_sats, None ) . unwrap ( ) ;
388
390
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
+
389
397
node_a. sync_wallets ( ) . unwrap ( ) ;
390
398
node_b. sync_wallets ( ) . unwrap ( ) ;
391
399
@@ -449,10 +457,19 @@ fn onchain_send_receive() {
449
457
}
450
458
451
459
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 ( ) ;
452
462
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
+
454
464
wait_for_tx ( & electrsd. client , txid) ;
455
465
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
+
456
473
node_a. sync_wallets ( ) . unwrap ( ) ;
457
474
node_b. sync_wallets ( ) . unwrap ( ) ;
458
475
@@ -522,9 +539,17 @@ fn onchain_send_all_retains_reserve() {
522
539
assert_eq ! ( node_b. list_balances( ) . spendable_onchain_balance_sats, premine_amount_sat) ;
523
540
524
541
// 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 ( ) ;
525
544
let txid = node_a. onchain_payment ( ) . send_all_to_address ( & addr_b, true , None ) . unwrap ( ) ;
526
545
527
546
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
+
528
553
generate_blocks_and_wait ( & bitcoind. client , & electrsd. client , 6 ) ;
529
554
530
555
node_a. sync_wallets ( ) . unwrap ( ) ;
@@ -563,9 +588,17 @@ fn onchain_send_all_retains_reserve() {
563
588
. contains( & node_b. list_balances( ) . spendable_onchain_balance_sats) ) ;
564
589
565
590
// 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 ( ) ;
566
593
let txid = node_b. onchain_payment ( ) . send_all_to_address ( & addr_a, true , None ) . unwrap ( ) ;
567
594
568
595
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
+
569
602
generate_blocks_and_wait ( & bitcoind. client , & electrsd. client , 6 ) ;
570
603
571
604
node_a. sync_wallets ( ) . unwrap ( ) ;
0 commit comments