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