1
1
#![ allow( unused) ]
2
- use std:: str:: FromStr ;
3
-
2
+ use bdk_chain:: { BlockId , CheckPoint } ;
4
3
use bdk_wallet:: bitcoin:: bip32:: Xpriv ;
5
4
use bdk_wallet:: bitcoin:: hashes:: Hash ;
6
5
use bdk_wallet:: bitcoin:: key:: Secp256k1 ;
6
+ use std:: str:: FromStr ;
7
7
8
8
use bdk_wallet:: bitcoin:: {
9
9
self , psbt, Address , Network , OutPoint , Psbt , Script , Sequence , Transaction , TxIn , TxOut , Txid ,
@@ -29,6 +29,7 @@ use bitcoin::{absolute, transaction, Amount};
29
29
// 7. Finalize the psbt. At this point, miniscript will check whether the transaction
30
30
// satisfies the descriptor, and will notify you if it doesn't.
31
31
// 8. If desired, extract the transaction from the psbt and broadcast it.
32
+ #[ allow( clippy:: print_stdout) ]
32
33
fn main ( ) {
33
34
// In order to try out descriptors, let's define a Bitcoin vault with two spend paths.
34
35
//
@@ -132,9 +133,11 @@ fn main() {
132
133
let fees = Amount :: from_sat ( 500 ) ;
133
134
134
135
// Calculate the change amount (total balance minus the amount sent in txout1)
135
- let change_amount = emergency_wallet
136
- . balance ( )
137
- . confirmed
136
+ let vault_balance = vault. balance ( ) ;
137
+ println ! ( "vault balance is {vault_balance}" ) ;
138
+
139
+ let change_amount = vault_balance
140
+ . untrusted_pending
138
141
. checked_sub ( txout1. value )
139
142
. expect ( "failed to generate change amount" )
140
143
. checked_sub ( fees)
@@ -323,6 +326,7 @@ fn blank_transaction_with(lock_time: absolute::LockTime) -> bitcoin::Transaction
323
326
}
324
327
325
328
fn deposit_transaction ( wallet : & mut Wallet , tx : Transaction ) -> OutPoint {
329
+ use bdk_chain:: TxUpdate ;
326
330
use bdk_chain:: { ConfirmationBlockTime , TxGraph } ;
327
331
use bdk_wallet:: Update ;
328
332
@@ -332,7 +336,7 @@ fn deposit_transaction(wallet: &mut Wallet, tx: Transaction) -> OutPoint {
332
336
let _ = graph. insert_seen_at ( txid, 42 ) ;
333
337
wallet
334
338
. apply_update ( Update {
335
- graph,
339
+ tx_update : graph. into ( ) ,
336
340
..Default :: default ( )
337
341
} )
338
342
. unwrap ( ) ;
0 commit comments