Skip to content

Commit

Permalink
Fixed deposit_transaction so we're compiling again after upstream merge
Browse files Browse the repository at this point in the history
  • Loading branch information
futurechimp committed Oct 10, 2024
1 parent 2209462 commit 633e96a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions crates/wallet/examples/descriptor_with_plan.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#![allow(unused)]
use std::str::FromStr;

use bdk_chain::{BlockId, CheckPoint};
use bdk_wallet::bitcoin::bip32::Xpriv;
use bdk_wallet::bitcoin::hashes::Hash;
use bdk_wallet::bitcoin::key::Secp256k1;
use std::str::FromStr;

use bdk_wallet::bitcoin::{
self, psbt, Address, Network, OutPoint, Psbt, Script, Sequence, Transaction, TxIn, TxOut, Txid,
Expand All @@ -29,6 +29,7 @@ use bitcoin::{absolute, transaction, Amount};
// 7. Finalize the psbt. At this point, miniscript will check whether the transaction
// satisfies the descriptor, and will notify you if it doesn't.
// 8. If desired, extract the transaction from the psbt and broadcast it.
#[allow(clippy::print_stdout)]
fn main() {
// In order to try out descriptors, let's define a Bitcoin vault with two spend paths.
//
Expand Down Expand Up @@ -132,9 +133,11 @@ fn main() {
let fees = Amount::from_sat(500);

// Calculate the change amount (total balance minus the amount sent in txout1)
let change_amount = emergency_wallet
.balance()
.confirmed
let vault_balance = vault.balance();
println!("vault balance is {vault_balance}");

let change_amount = vault_balance
.untrusted_pending
.checked_sub(txout1.value)
.expect("failed to generate change amount")
.checked_sub(fees)
Expand Down Expand Up @@ -323,6 +326,7 @@ fn blank_transaction_with(lock_time: absolute::LockTime) -> bitcoin::Transaction
}

fn deposit_transaction(wallet: &mut Wallet, tx: Transaction) -> OutPoint {
use bdk_chain::TxUpdate;
use bdk_chain::{ConfirmationBlockTime, TxGraph};
use bdk_wallet::Update;

Expand All @@ -332,7 +336,7 @@ fn deposit_transaction(wallet: &mut Wallet, tx: Transaction) -> OutPoint {
let _ = graph.insert_seen_at(txid, 42);
wallet
.apply_update(Update {
graph,
tx_update: graph.into(),
..Default::default()
})
.unwrap();
Expand Down

0 comments on commit 633e96a

Please sign in to comment.