@@ -69,8 +69,8 @@ fn do_channel_full_cycle<K: KVStore + Sync + Send>(
6969 ) ;
7070 node_a. sync_wallets ( ) . unwrap ( ) ;
7171 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) ;
7474
7575 // Check we haven't got any events yet
7676 assert_eq ! ( node_a. next_event( ) , None ) ;
@@ -115,12 +115,11 @@ fn do_channel_full_cycle<K: KVStore + Sync + Send>(
115115 node_b. sync_wallets ( ) . unwrap ( ) ;
116116
117117 let onchain_fee_buffer_sat = 1500 ;
118- let node_a_balance = node_a. onchain_balance ( ) . unwrap ( ) ;
119118 let node_a_upper_bound_sat = premine_amount_sat - funding_amount_sat;
120119 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) ;
124123
125124 expect_event ! ( node_a, ChannelReady ) ;
126125
@@ -253,10 +252,10 @@ fn do_channel_full_cycle<K: KVStore + Sync + Send>(
253252 let node_a_upper_bound_sat =
254253 ( premine_amount_sat - funding_amount_sat) + ( funding_amount_sat - sum_of_all_payments_sat) ;
255254 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) ;
258257 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) ;
260259
261260 // Check we handled all events
262261 assert_eq ! ( node_a. next_event( ) , None ) ;
@@ -298,8 +297,8 @@ fn channel_open_fails_when_funds_insufficient() {
298297 ) ;
299298 node_a. sync_wallets ( ) . unwrap ( ) ;
300299 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) ;
303302
304303 println ! ( "\n A -- connect_open_channel -> B" ) ;
305304 assert_eq ! (
@@ -340,13 +339,13 @@ fn start_stop_reinit() {
340339 let expected_amount = Amount :: from_sat ( 100000 ) ;
341340
342341 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 ) ;
344343
345344 node. start ( ) . unwrap ( ) ;
346345 assert_eq ! ( node. start( ) , Err ( Error :: AlreadyRunning ) ) ;
347346
348347 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( ) ) ;
350349
351350 let log_file_symlink = format ! ( "{}/logs/ldk_node_latest.log" , config. storage_dir_path) ;
352351 assert ! ( std:: path:: Path :: new( & log_file_symlink) . is_symlink( ) ) ;
@@ -369,13 +368,13 @@ fn start_stop_reinit() {
369368 reinitialized_node. start ( ) . unwrap ( ) ;
370369
371370 assert_eq ! (
372- reinitialized_node. onchain_balance ( ) . unwrap( ) . get_spendable ( ) ,
371+ reinitialized_node. spendable_onchain_balance_sats ( ) . unwrap( ) ,
373372 expected_amount. to_sat( )
374373 ) ;
375374
376375 reinitialized_node. sync_wallets ( ) . unwrap ( ) ;
377376 assert_eq ! (
378- reinitialized_node. onchain_balance ( ) . unwrap( ) . get_spendable ( ) ,
377+ reinitialized_node. spendable_onchain_balance_sats ( ) . unwrap( ) ,
379378 expected_amount. to_sat( )
380379 ) ;
381380
@@ -396,13 +395,13 @@ fn start_stop_reinit_fs_store() {
396395 let expected_amount = Amount :: from_sat ( 100000 ) ;
397396
398397 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 ) ;
400399
401400 node. start ( ) . unwrap ( ) ;
402401 assert_eq ! ( node. start( ) , Err ( Error :: AlreadyRunning ) ) ;
403402
404403 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( ) ) ;
406405
407406 node. stop ( ) . unwrap ( ) ;
408407 assert_eq ! ( node. stop( ) , Err ( Error :: NotRunning ) ) ;
@@ -422,13 +421,13 @@ fn start_stop_reinit_fs_store() {
422421 reinitialized_node. start ( ) . unwrap ( ) ;
423422
424423 assert_eq ! (
425- reinitialized_node. onchain_balance ( ) . unwrap( ) . get_spendable ( ) ,
424+ reinitialized_node. spendable_onchain_balance_sats ( ) . unwrap( ) ,
426425 expected_amount. to_sat( )
427426 ) ;
428427
429428 reinitialized_node. sync_wallets ( ) . unwrap ( ) ;
430429 assert_eq ! (
431- reinitialized_node. onchain_balance ( ) . unwrap( ) . get_spendable ( ) ,
430+ reinitialized_node. spendable_onchain_balance_sats ( ) . unwrap( ) ,
432431 expected_amount. to_sat( )
433432 ) ;
434433
@@ -463,7 +462,7 @@ fn onchain_spend_receive() {
463462
464463 node_a. sync_wallets ( ) . unwrap ( ) ;
465464 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 ) ;
467466
468467 assert_eq ! ( Err ( Error :: InsufficientFunds ) , node_a. send_to_onchain_address( & addr_b, 1000 ) ) ;
469468
@@ -474,9 +473,9 @@ fn onchain_spend_receive() {
474473 node_a. sync_wallets ( ) . unwrap ( ) ;
475474 node_b. sync_wallets ( ) . unwrap ( ) ;
476475
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 ) ;
480479
481480 let addr_b = node_b. new_funding_address ( ) . unwrap ( ) ;
482481 let txid = node_a. send_all_to_onchain_address ( & addr_b) . unwrap ( ) ;
@@ -486,9 +485,9 @@ fn onchain_spend_receive() {
486485 node_a. sync_wallets ( ) . unwrap ( ) ;
487486 node_b. sync_wallets ( ) . unwrap ( ) ;
488487
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 ) ;
492491}
493492
494493#[ test]
0 commit comments