@@ -69,8 +69,8 @@ fn do_channel_full_cycle<K: KVStore + Sync + Send>(
69
69
) ;
70
70
node_a. sync_wallets ( ) . unwrap ( ) ;
71
71
node_b. sync_wallets ( ) . unwrap ( ) ;
72
- assert_eq ! ( node_a. onchain_balance ( ) . unwrap( ) . get_spendable ( ) , premine_amount_sat) ;
73
- assert_eq ! ( node_b. onchain_balance ( ) . unwrap( ) . get_spendable ( ) , premine_amount_sat) ;
72
+ assert_eq ! ( node_a. spendable_onchain_balance_sats ( ) . unwrap( ) , premine_amount_sat) ;
73
+ assert_eq ! ( node_b. spendable_onchain_balance_sats ( ) . unwrap( ) , premine_amount_sat) ;
74
74
75
75
// Check we haven't got any events yet
76
76
assert_eq ! ( node_a. next_event( ) , None ) ;
@@ -116,12 +116,11 @@ fn do_channel_full_cycle<K: KVStore + Sync + Send>(
116
116
node_b. sync_wallets ( ) . unwrap ( ) ;
117
117
118
118
let onchain_fee_buffer_sat = 1500 ;
119
- let node_a_balance = node_a. onchain_balance ( ) . unwrap ( ) ;
120
119
let node_a_upper_bound_sat = premine_amount_sat - funding_amount_sat;
121
120
let node_a_lower_bound_sat = premine_amount_sat - funding_amount_sat - onchain_fee_buffer_sat;
122
- assert ! ( node_a_balance . get_spendable ( ) < node_a_upper_bound_sat) ;
123
- assert ! ( node_a_balance . get_spendable ( ) > node_a_lower_bound_sat) ;
124
- assert_eq ! ( node_b. onchain_balance ( ) . unwrap( ) . get_spendable ( ) , premine_amount_sat) ;
121
+ assert ! ( node_a . spendable_onchain_balance_sats ( ) . unwrap ( ) < node_a_upper_bound_sat) ;
122
+ assert ! ( node_a . spendable_onchain_balance_sats ( ) . unwrap ( ) > node_a_lower_bound_sat) ;
123
+ assert_eq ! ( node_b. spendable_onchain_balance_sats ( ) . unwrap( ) , premine_amount_sat) ;
125
124
126
125
expect_event ! ( node_a, ChannelReady ) ;
127
126
@@ -254,10 +253,10 @@ fn do_channel_full_cycle<K: KVStore + Sync + Send>(
254
253
let node_a_upper_bound_sat =
255
254
( premine_amount_sat - funding_amount_sat) + ( funding_amount_sat - sum_of_all_payments_sat) ;
256
255
let node_a_lower_bound_sat = node_a_upper_bound_sat - onchain_fee_buffer_sat;
257
- assert ! ( node_a. onchain_balance ( ) . unwrap( ) . get_spendable ( ) > node_a_lower_bound_sat) ;
258
- assert ! ( node_a. onchain_balance ( ) . unwrap( ) . get_spendable ( ) < node_a_upper_bound_sat) ;
256
+ assert ! ( node_a. spendable_onchain_balance_sats ( ) . unwrap( ) > node_a_lower_bound_sat) ;
257
+ assert ! ( node_a. spendable_onchain_balance_sats ( ) . unwrap( ) < node_a_upper_bound_sat) ;
259
258
let expected_final_amount_node_b_sat = premine_amount_sat + sum_of_all_payments_sat;
260
- assert_eq ! ( node_b. onchain_balance ( ) . unwrap( ) . get_spendable ( ) , expected_final_amount_node_b_sat) ;
259
+ assert_eq ! ( node_b. spendable_onchain_balance_sats ( ) . unwrap( ) , expected_final_amount_node_b_sat) ;
261
260
262
261
// Check we handled all events
263
262
assert_eq ! ( node_a. next_event( ) , None ) ;
@@ -299,8 +298,8 @@ fn channel_open_fails_when_funds_insufficient() {
299
298
) ;
300
299
node_a. sync_wallets ( ) . unwrap ( ) ;
301
300
node_b. sync_wallets ( ) . unwrap ( ) ;
302
- assert_eq ! ( node_a. onchain_balance ( ) . unwrap( ) . get_spendable ( ) , premine_amount_sat) ;
303
- assert_eq ! ( node_b. onchain_balance ( ) . unwrap( ) . get_spendable ( ) , premine_amount_sat) ;
301
+ assert_eq ! ( node_a. spendable_onchain_balance_sats ( ) . unwrap( ) , premine_amount_sat) ;
302
+ assert_eq ! ( node_b. spendable_onchain_balance_sats ( ) . unwrap( ) , premine_amount_sat) ;
304
303
305
304
println ! ( "\n A -- connect_open_channel -> B" ) ;
306
305
assert_eq ! (
@@ -342,13 +341,13 @@ fn start_stop_reinit() {
342
341
let expected_amount = Amount :: from_sat ( 100000 ) ;
343
342
344
343
premine_and_distribute_funds ( & bitcoind, & electrsd, vec ! [ funding_address] , expected_amount) ;
345
- assert_eq ! ( node. onchain_balance ( ) . unwrap( ) . get_total ( ) , 0 ) ;
344
+ assert_eq ! ( node. total_onchain_balance_sats ( ) . unwrap( ) , 0 ) ;
346
345
347
346
node. start ( ) . unwrap ( ) ;
348
347
assert_eq ! ( node. start( ) , Err ( Error :: AlreadyRunning ) ) ;
349
348
350
349
node. sync_wallets ( ) . unwrap ( ) ;
351
- assert_eq ! ( node. onchain_balance ( ) . unwrap( ) . get_spendable ( ) , expected_amount. to_sat( ) ) ;
350
+ assert_eq ! ( node. spendable_onchain_balance_sats ( ) . unwrap( ) , expected_amount. to_sat( ) ) ;
352
351
353
352
let log_file_symlink = format ! ( "{}/logs/ldk_node_latest.log" , config. storage_dir_path) ;
354
353
assert ! ( std:: path:: Path :: new( & log_file_symlink) . is_symlink( ) ) ;
@@ -371,13 +370,13 @@ fn start_stop_reinit() {
371
370
reinitialized_node. start ( ) . unwrap ( ) ;
372
371
373
372
assert_eq ! (
374
- reinitialized_node. onchain_balance ( ) . unwrap( ) . get_spendable ( ) ,
373
+ reinitialized_node. spendable_onchain_balance_sats ( ) . unwrap( ) ,
375
374
expected_amount. to_sat( )
376
375
) ;
377
376
378
377
reinitialized_node. sync_wallets ( ) . unwrap ( ) ;
379
378
assert_eq ! (
380
- reinitialized_node. onchain_balance ( ) . unwrap( ) . get_spendable ( ) ,
379
+ reinitialized_node. spendable_onchain_balance_sats ( ) . unwrap( ) ,
381
380
expected_amount. to_sat( )
382
381
) ;
383
382
@@ -398,13 +397,13 @@ fn start_stop_reinit_fs_store() {
398
397
let expected_amount = Amount :: from_sat ( 100000 ) ;
399
398
400
399
premine_and_distribute_funds ( & bitcoind, & electrsd, vec ! [ funding_address] , expected_amount) ;
401
- assert_eq ! ( node. onchain_balance ( ) . unwrap( ) . get_total ( ) , 0 ) ;
400
+ assert_eq ! ( node. total_onchain_balance_sats ( ) . unwrap( ) , 0 ) ;
402
401
403
402
node. start ( ) . unwrap ( ) ;
404
403
assert_eq ! ( node. start( ) , Err ( Error :: AlreadyRunning ) ) ;
405
404
406
405
node. sync_wallets ( ) . unwrap ( ) ;
407
- assert_eq ! ( node. onchain_balance ( ) . unwrap( ) . get_spendable ( ) , expected_amount. to_sat( ) ) ;
406
+ assert_eq ! ( node. spendable_onchain_balance_sats ( ) . unwrap( ) , expected_amount. to_sat( ) ) ;
408
407
409
408
node. stop ( ) . unwrap ( ) ;
410
409
assert_eq ! ( node. stop( ) , Err ( Error :: NotRunning ) ) ;
@@ -424,13 +423,13 @@ fn start_stop_reinit_fs_store() {
424
423
reinitialized_node. start ( ) . unwrap ( ) ;
425
424
426
425
assert_eq ! (
427
- reinitialized_node. onchain_balance ( ) . unwrap( ) . get_spendable ( ) ,
426
+ reinitialized_node. spendable_onchain_balance_sats ( ) . unwrap( ) ,
428
427
expected_amount. to_sat( )
429
428
) ;
430
429
431
430
reinitialized_node. sync_wallets ( ) . unwrap ( ) ;
432
431
assert_eq ! (
433
- reinitialized_node. onchain_balance ( ) . unwrap( ) . get_spendable ( ) ,
432
+ reinitialized_node. spendable_onchain_balance_sats ( ) . unwrap( ) ,
434
433
expected_amount. to_sat( )
435
434
) ;
436
435
@@ -465,7 +464,7 @@ fn onchain_spend_receive() {
465
464
466
465
node_a. sync_wallets ( ) . unwrap ( ) ;
467
466
node_b. sync_wallets ( ) . unwrap ( ) ;
468
- assert_eq ! ( node_b. onchain_balance ( ) . unwrap( ) . get_spendable ( ) , 100000 ) ;
467
+ assert_eq ! ( node_b. spendable_onchain_balance_sats ( ) . unwrap( ) , 100000 ) ;
469
468
470
469
assert_eq ! ( Err ( Error :: InsufficientFunds ) , node_a. send_to_onchain_address( & addr_b, 1000 ) ) ;
471
470
@@ -476,9 +475,9 @@ fn onchain_spend_receive() {
476
475
node_a. sync_wallets ( ) . unwrap ( ) ;
477
476
node_b. sync_wallets ( ) . unwrap ( ) ;
478
477
479
- assert_eq ! ( node_a. onchain_balance ( ) . unwrap( ) . get_spendable ( ) , 1000 ) ;
480
- assert ! ( node_b. onchain_balance ( ) . unwrap( ) . get_spendable ( ) > 98000 ) ;
481
- assert ! ( node_b. onchain_balance ( ) . unwrap( ) . get_spendable ( ) < 100000 ) ;
478
+ assert_eq ! ( node_a. spendable_onchain_balance_sats ( ) . unwrap( ) , 1000 ) ;
479
+ assert ! ( node_b. spendable_onchain_balance_sats ( ) . unwrap( ) > 98000 ) ;
480
+ assert ! ( node_b. spendable_onchain_balance_sats ( ) . unwrap( ) < 100000 ) ;
482
481
483
482
let addr_b = node_b. new_funding_address ( ) . unwrap ( ) ;
484
483
let txid = node_a. send_all_to_onchain_address ( & addr_b) . unwrap ( ) ;
@@ -488,9 +487,9 @@ fn onchain_spend_receive() {
488
487
node_a. sync_wallets ( ) . unwrap ( ) ;
489
488
node_b. sync_wallets ( ) . unwrap ( ) ;
490
489
491
- assert_eq ! ( node_a. onchain_balance ( ) . unwrap( ) . get_total ( ) , 0 ) ;
492
- assert ! ( node_b. onchain_balance ( ) . unwrap( ) . get_spendable ( ) > 99000 ) ;
493
- assert ! ( node_b. onchain_balance ( ) . unwrap( ) . get_spendable ( ) < 100000 ) ;
490
+ assert_eq ! ( node_a. total_onchain_balance_sats ( ) . unwrap( ) , 0 ) ;
491
+ assert ! ( node_b. spendable_onchain_balance_sats ( ) . unwrap( ) > 99000 ) ;
492
+ assert ! ( node_b. spendable_onchain_balance_sats ( ) . unwrap( ) < 100000 ) ;
494
493
}
495
494
496
495
#[ test]
0 commit comments