Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
oleonardolima committed Dec 12, 2024
1 parent 606a2b0 commit 1d5aab9
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ members = [
"example-crates/example_wallet_esplora_blocking",
"example-crates/example_wallet_esplora_async",
"example-crates/example_wallet_rpc",
"example-crates/example_double_spending",
]

[workspace.package]
Expand Down
12 changes: 12 additions & 0 deletions example-crates/example_double_spending/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "example_double_spending"
version = "0.1.0"
edition = "2021"
publish = false

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
bdk_wallet = { path = "../../crates/wallet", features = ["file_store"] }
bdk_esplora = { path = "../../crates/esplora", features = ["blocking"] }
anyhow = "1"
147 changes: 147 additions & 0 deletions example-crates/example_double_spending/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
use std::str::FromStr;

Check failure on line 1 in example-crates/example_double_spending/src/main.rs

View workflow job for this annotation

GitHub Actions / Clippy Results

unused import: `std::str::FromStr`

error: unused import: `std::str::FromStr` --> example-crates/example_double_spending/src/main.rs:1:5 | 1 | use std::str::FromStr; | ^^^^^^^^^^^^^^^^^ | = note: `-D unused-imports` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(unused_imports)]`

use bdk_esplora::EsploraExt;
use bdk_wallet::{
bitcoin::{Address, Amount, FeeRate, TxIn},

Check failure on line 5 in example-crates/example_double_spending/src/main.rs

View workflow job for this annotation

GitHub Actions / Clippy Results

unused imports: `Address` and `TxIn`

error: unused imports: `Address` and `TxIn` --> example-crates/example_double_spending/src/main.rs:5:15 | 5 | bitcoin::{Address, Amount, FeeRate, TxIn}, | ^^^^^^^ ^^^^
rusqlite::Connection,
KeychainKind, SignOptions, TxOrdering, Wallet,
};

fn main() {
const ESPLORA_API: &str = "https://mempool.space/testnet4/api";
const PARALLEL_REQUESTS: usize = 5;

// Initialize the DB connections for both wallets A and B.
let wallet_a = "WALLET_A";
let wallet_b = "WALLET_B";

let mut conn_a = Connection::open(format!("./{}.sqlite", wallet_a).as_str()).unwrap();
let mut conn_b = Connection::open(format!("./{}.sqlite", wallet_b).as_str()).unwrap();

// Initialize & Load wallets A and B.
let mut wallet_a = Wallet::load()
.descriptor(KeychainKind::External, Some("tr()#h305zpuu"))
.extract_keys()
.load_wallet(&mut conn_a)
.unwrap()
.unwrap();

let mut wallet_b = Wallet::load()
.descriptor(KeychainKind::External, Some("tr()#dyn6d6zd"))
.extract_keys()
.load_wallet(&mut conn_b)
.unwrap();

let esplora_client = bdk_esplora::esplora_client::Builder::new(ESPLORA_API).build_blocking();

// Sync Wallet A

let sync_req = wallet_a.start_sync_with_revealed_spks().build();
let sync_res = esplora_client.sync(sync_req, PARALLEL_REQUESTS).unwrap();
let _ = wallet_a.apply_update(sync_res).unwrap();

// Persist Wallet B
wallet_a.persist(&mut conn_b).unwrap();

// Sync Wallet B
let sync_req = wallet_b.start_sync_with_revealed_spks().build();

Check failure on line 47 in example-crates/example_double_spending/src/main.rs

View workflow job for this annotation

GitHub Actions / Clippy Results

no method named `start_sync_with_revealed_spks` found for enum `std::option::Option` in the current scope

error[E0599]: no method named `start_sync_with_revealed_spks` found for enum `std::option::Option` in the current scope --> example-crates/example_double_spending/src/main.rs:47:29 | 47 | let sync_req = wallet_b.start_sync_with_revealed_spks().build(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method not found in `Option<PersistedWallet<Connection>>` | note: the method `start_sync_with_revealed_spks` exists on the type `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` --> /home/runner/work/bdk/bdk/crates/wallet/src/wallet/mod.rs:2448:5 | 2448 | pub fn start_sync_with_revealed_spks(&self) -> SyncRequestBuilder<(KeychainKind, u32)> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `Option::expect` to unwrap the `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` value, panicking if the value is an `Option::None` | 47 | let sync_req = wallet_b.expect("REASON").start_sync_with_revealed_spks().build(); | +++++++++++++++++
let sync_res = esplora_client.sync(sync_req, PARALLEL_REQUESTS).unwrap();
let _ = wallet_b.apply_update(sync_res).unwrap();

Check failure on line 49 in example-crates/example_double_spending/src/main.rs

View workflow job for this annotation

GitHub Actions / Clippy Results

no method named `apply_update` found for enum `std::option::Option` in the current scope

error[E0599]: no method named `apply_update` found for enum `std::option::Option` in the current scope --> example-crates/example_double_spending/src/main.rs:49:22 | 49 | let _ = wallet_b.apply_update(sync_res).unwrap(); | ^^^^^^^^^^^^ method not found in `Option<PersistedWallet<Connection>>` | note: the method `apply_update` exists on the type `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` --> /home/runner/work/bdk/bdk/crates/wallet/src/wallet/mod.rs:2267:5 | 2267 | pub fn apply_update(&mut self, update: impl Into<Update>) -> Result<(), CannotConnectError> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `Option::expect` to unwrap the `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` value, panicking if the value is an `Option::None` | 49 | let _ = wallet_b.expect("REASON").apply_update(sync_res).unwrap(); | +++++++++++++++++

// Persist Wallet B
wallet_b.persist(&mut conn_b).unwrap();

Check failure on line 52 in example-crates/example_double_spending/src/main.rs

View workflow job for this annotation

GitHub Actions / Clippy Results

no method named `persist` found for enum `std::option::Option` in the current scope

error[E0599]: no method named `persist` found for enum `std::option::Option` in the current scope --> example-crates/example_double_spending/src/main.rs:52:14 | 52 | wallet_b.persist(&mut conn_b).unwrap(); | ^^^^^^^ method not found in `Option<PersistedWallet<Connection>>` | note: the method `persist` exists on the type `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` --> /home/runner/work/bdk/bdk/crates/wallet/src/wallet/persisted.rs:183:5 | 183 | pub fn persist(&mut self, persister: &mut P) -> Result<bool, P::Error> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `Option::expect` to unwrap the `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` value, panicking if the value is an `Option::None` | 52 | wallet_b.expect("REASON").persist(&mut conn_b).unwrap(); | +++++++++++++++++

for tx in wallet_a.transactions() {
println!("wallet: {:?} tx: {:?}", wallet_a, tx);
}

for tx in wallet_b.transactions() {

Check failure on line 58 in example-crates/example_double_spending/src/main.rs

View workflow job for this annotation

GitHub Actions / Clippy Results

no method named `transactions` found for enum `std::option::Option` in the current scope

error[E0599]: no method named `transactions` found for enum `std::option::Option` in the current scope --> example-crates/example_double_spending/src/main.rs:58:24 | 58 | for tx in wallet_b.transactions() { | ^^^^^^^^^^^^ method not found in `Option<PersistedWallet<Connection>>` | note: the method `transactions` exists on the type `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` --> /home/runner/work/bdk/bdk/crates/wallet/src/wallet/mod.rs:1066:5 | 1066 | pub fn transactions(&self) -> impl Iterator<Item = WalletTx> + '_ { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `Option::expect` to unwrap the `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` value, panicking if the value is an `Option::None` | 58 | for tx in wallet_b.expect("REASON").transactions() { | +++++++++++++++++
println!("wallet: {:?} tx: {:?}", wallet_b, tx);
}

// Build Initial TxA: WalletA -> WalletB

let wa_change_addr = wallet_a.peek_address(KeychainKind::Internal, 0).address;
let wb_recv_addr = wallet_b.peek_address(KeychainKind::External, 0).address;

Check failure on line 65 in example-crates/example_double_spending/src/main.rs

View workflow job for this annotation

GitHub Actions / Clippy Results

no method named `peek_address` found for enum `std::option::Option` in the current scope

error[E0599]: no method named `peek_address` found for enum `std::option::Option` in the current scope --> example-crates/example_double_spending/src/main.rs:65:33 | 65 | let wb_recv_addr = wallet_b.peek_address(KeychainKind::External, 0).address; | ^^^^^^^^^^^^ method not found in `Option<PersistedWallet<Connection>>` | note: the method `peek_address` exists on the type `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` --> /home/runner/work/bdk/bdk/crates/wallet/src/wallet/mod.rs:639:5 | 639 | pub fn peek_address(&self, keychain: KeychainKind, mut index: u32) -> AddressInfo { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `Option::expect` to unwrap the `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` value, panicking if the value is an `Option::None` | 65 | let wb_recv_addr = wallet_b.expect("REASON").peek_address(KeychainKind::External, 0).address; | +++++++++++++++++

let mut tx1_builder = wallet_a.build_tx();
tx1_builder
.ordering(TxOrdering::Untouched)
.add_recipient(wb_recv_addr.script_pubkey(), Amount::from_sat(1000))
.fee_rate(FeeRate::from_sat_per_vb(1).unwrap())
.drain_to(wa_change_addr.script_pubkey());

let mut tx1_psbt = tx1_builder.finish().unwrap();

let _sign_outcome = wallet_a
.sign(&mut tx1_psbt, SignOptions::default())
.unwrap();

let tx1 = tx1_psbt.extract_tx().unwrap();
println!("tx1: {:?}", tx1.compute_txid());

esplora_client.broadcast(&tx1).unwrap();

// Sync Wallet B
let sync_req = wallet_b.start_sync_with_revealed_spks().build();

Check failure on line 86 in example-crates/example_double_spending/src/main.rs

View workflow job for this annotation

GitHub Actions / Clippy Results

no method named `start_sync_with_revealed_spks` found for enum `std::option::Option` in the current scope

error[E0599]: no method named `start_sync_with_revealed_spks` found for enum `std::option::Option` in the current scope --> example-crates/example_double_spending/src/main.rs:86:29 | 86 | let sync_req = wallet_b.start_sync_with_revealed_spks().build(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method not found in `Option<PersistedWallet<Connection>>` | note: the method `start_sync_with_revealed_spks` exists on the type `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` --> /home/runner/work/bdk/bdk/crates/wallet/src/wallet/mod.rs:2448:5 | 2448 | pub fn start_sync_with_revealed_spks(&self) -> SyncRequestBuilder<(KeychainKind, u32)> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `Option::expect` to unwrap the `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` value, panicking if the value is an `Option::None` | 86 | let sync_req = wallet_b.expect("REASON").start_sync_with_revealed_spks().build(); | +++++++++++++++++
let sync_res = esplora_client.sync(sync_req, PARALLEL_REQUESTS).unwrap();
let _ = wallet_b.apply_update(sync_res).unwrap();

Check failure on line 88 in example-crates/example_double_spending/src/main.rs

View workflow job for this annotation

GitHub Actions / Clippy Results

no method named `apply_update` found for enum `std::option::Option` in the current scope

error[E0599]: no method named `apply_update` found for enum `std::option::Option` in the current scope --> example-crates/example_double_spending/src/main.rs:88:22 | 88 | let _ = wallet_b.apply_update(sync_res).unwrap(); | ^^^^^^^^^^^^ method not found in `Option<PersistedWallet<Connection>>` | note: the method `apply_update` exists on the type `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` --> /home/runner/work/bdk/bdk/crates/wallet/src/wallet/mod.rs:2267:5 | 2267 | pub fn apply_update(&mut self, update: impl Into<Update>) -> Result<(), CannotConnectError> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `Option::expect` to unwrap the `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` value, panicking if the value is an `Option::None` | 88 | let _ = wallet_b.expect("REASON").apply_update(sync_res).unwrap(); | +++++++++++++++++

// Persist Wallet B
wallet_b.persist(&mut conn_b).unwrap();

Check failure on line 91 in example-crates/example_double_spending/src/main.rs

View workflow job for this annotation

GitHub Actions / Clippy Results

no method named `persist` found for enum `std::option::Option` in the current scope

error[E0599]: no method named `persist` found for enum `std::option::Option` in the current scope --> example-crates/example_double_spending/src/main.rs:91:14 | 91 | wallet_b.persist(&mut conn_b).unwrap(); | ^^^^^^^ method not found in `Option<PersistedWallet<Connection>>` | note: the method `persist` exists on the type `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` --> /home/runner/work/bdk/bdk/crates/wallet/src/wallet/persisted.rs:183:5 | 183 | pub fn persist(&mut self, persister: &mut P) -> Result<bool, P::Error> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `Option::expect` to unwrap the `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` value, panicking if the value is an `Option::None` | 91 | wallet_b.expect("REASON").persist(&mut conn_b).unwrap(); | +++++++++++++++++

for tx in wallet_b.transactions() {

Check failure on line 93 in example-crates/example_double_spending/src/main.rs

View workflow job for this annotation

GitHub Actions / Clippy Results

no method named `transactions` found for enum `std::option::Option` in the current scope

error[E0599]: no method named `transactions` found for enum `std::option::Option` in the current scope --> example-crates/example_double_spending/src/main.rs:93:24 | 93 | for tx in wallet_b.transactions() { | ^^^^^^^^^^^^ method not found in `Option<PersistedWallet<Connection>>` | note: the method `transactions` exists on the type `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` --> /home/runner/work/bdk/bdk/crates/wallet/src/wallet/mod.rs:1066:5 | 1066 | pub fn transactions(&self) -> impl Iterator<Item = WalletTx> + '_ { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `Option::expect` to unwrap the `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` value, panicking if the value is an `Option::None` | 93 | for tx in wallet_b.expect("REASON").transactions() { | +++++++++++++++++
println!("wallet: {:?} tx: {:?}", wallet_b, tx.tx_node.txid);
}

// RBF Tx1 (Double Spend)
let wa_recv_addr = wallet_a.peek_address(KeychainKind::External, 0).address;

let mut tx2_builder = wallet_a.build_fee_bump(tx1.compute_txid()).unwrap();

tx2_builder
.fee_rate(FeeRate::from_sat_per_vb_unchecked(15))
.set_recipients(vec![(wa_recv_addr.script_pubkey(), Amount::from_sat(1000))])
.drain_to(wa_change_addr.script_pubkey())
.drain_wallet();

let mut tx2_psbt = tx2_builder.finish().unwrap();

let _sign_outcome = wallet_a
.sign(&mut tx2_psbt, SignOptions::default())
.unwrap();

let tx2 = tx2_psbt.extract_tx().unwrap();
println!("tx2: {:?}", tx2.compute_txid());

esplora_client.broadcast(&tx2).unwrap();

// Check that both Tx1 and Tx2 (RBF) have different TxIds.
assert_ne!(tx1.compute_txid(), tx2.compute_txid());

// Check that Wallet B transactions contains Tx2, but not Tx1.
assert!(wallet_b
.transactions()

Check failure on line 124 in example-crates/example_double_spending/src/main.rs

View workflow job for this annotation

GitHub Actions / Clippy Results

no method named `transactions` found for enum `std::option::Option` in the current scope

error[E0599]: no method named `transactions` found for enum `std::option::Option` in the current scope --> example-crates/example_double_spending/src/main.rs:124:10 | 123 | assert!(wallet_b | _____________- 124 | | .transactions() | | -^^^^^^^^^^^^ method not found in `Option<PersistedWallet<Connection>>` | |_________| | | note: the method `transactions` exists on the type `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` --> /home/runner/work/bdk/bdk/crates/wallet/src/wallet/mod.rs:1066:5 | 1066 | pub fn transactions(&self) -> impl Iterator<Item = WalletTx> + '_ { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `Option::expect` to unwrap the `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` value, panicking if the value is an `Option::None` | 123 | assert!(wallet_b.expect("REASON") | +++++++++++++++++
.find(|tx| tx.tx_node.txid == tx2.compute_txid())
.is_some());
assert!(wallet_b
.transactions()

Check failure on line 128 in example-crates/example_double_spending/src/main.rs

View workflow job for this annotation

GitHub Actions / Clippy Results

no method named `transactions` found for enum `std::option::Option` in the current scope

error[E0599]: no method named `transactions` found for enum `std::option::Option` in the current scope --> example-crates/example_double_spending/src/main.rs:128:10 | 127 | assert!(wallet_b | _____________- 128 | | .transactions() | | -^^^^^^^^^^^^ method not found in `Option<PersistedWallet<Connection>>` | |_________| | | note: the method `transactions` exists on the type `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` --> /home/runner/work/bdk/bdk/crates/wallet/src/wallet/mod.rs:1066:5 | 1066 | pub fn transactions(&self) -> impl Iterator<Item = WalletTx> + '_ { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `Option::expect` to unwrap the `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` value, panicking if the value is an `Option::None` | 127 | assert!(wallet_b.expect("REASON") | +++++++++++++++++
.find(|tx| tx.tx_node.txid == tx1.compute_txid())
.is_none());

// Sync Wallet B
let sync_req = wallet_b.start_sync_with_revealed_spks().build();

Check failure on line 133 in example-crates/example_double_spending/src/main.rs

View workflow job for this annotation

GitHub Actions / Clippy Results

no method named `start_sync_with_revealed_spks` found for enum `std::option::Option` in the current scope

error[E0599]: no method named `start_sync_with_revealed_spks` found for enum `std::option::Option` in the current scope --> example-crates/example_double_spending/src/main.rs:133:29 | 133 | let sync_req = wallet_b.start_sync_with_revealed_spks().build(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method not found in `Option<PersistedWallet<Connection>>` | note: the method `start_sync_with_revealed_spks` exists on the type `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` --> /home/runner/work/bdk/bdk/crates/wallet/src/wallet/mod.rs:2448:5 | 2448 | pub fn start_sync_with_revealed_spks(&self) -> SyncRequestBuilder<(KeychainKind, u32)> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `Option::expect` to unwrap the `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` value, panicking if the value is an `Option::None` | 133 | let sync_req = wallet_b.expect("REASON").start_sync_with_revealed_spks().build(); | +++++++++++++++++
let sync_res = esplora_client.sync(sync_req, PARALLEL_REQUESTS).unwrap();
let _ = wallet_b.apply_update(sync_res).unwrap();

Check failure on line 135 in example-crates/example_double_spending/src/main.rs

View workflow job for this annotation

GitHub Actions / Clippy Results

no method named `apply_update` found for enum `std::option::Option` in the current scope

error[E0599]: no method named `apply_update` found for enum `std::option::Option` in the current scope --> example-crates/example_double_spending/src/main.rs:135:22 | 135 | let _ = wallet_b.apply_update(sync_res).unwrap(); | ^^^^^^^^^^^^ method not found in `Option<PersistedWallet<Connection>>` | note: the method `apply_update` exists on the type `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` --> /home/runner/work/bdk/bdk/crates/wallet/src/wallet/mod.rs:2267:5 | 2267 | pub fn apply_update(&mut self, update: impl Into<Update>) -> Result<(), CannotConnectError> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `Option::expect` to unwrap the `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` value, panicking if the value is an `Option::None` | 135 | let _ = wallet_b.expect("REASON").apply_update(sync_res).unwrap(); | +++++++++++++++++

wallet_a.persist(&mut conn_a).unwrap();
wallet_b.persist(&mut conn_b).unwrap();

Check failure on line 138 in example-crates/example_double_spending/src/main.rs

View workflow job for this annotation

GitHub Actions / Clippy Results

no method named `persist` found for enum `std::option::Option` in the current scope

error[E0599]: no method named `persist` found for enum `std::option::Option` in the current scope --> example-crates/example_double_spending/src/main.rs:138:14 | 138 | wallet_b.persist(&mut conn_b).unwrap(); | ^^^^^^^ method not found in `Option<PersistedWallet<Connection>>` | note: the method `persist` exists on the type `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` --> /home/runner/work/bdk/bdk/crates/wallet/src/wallet/persisted.rs:183:5 | 183 | pub fn persist(&mut self, persister: &mut P) -> Result<bool, P::Error> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `Option::expect` to unwrap the `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` value, panicking if the value is an `Option::None` | 138 | wallet_b.expect("REASON").persist(&mut conn_b).unwrap(); | +++++++++++++++++

for tx in wallet_b.transactions() {

Check failure on line 140 in example-crates/example_double_spending/src/main.rs

View workflow job for this annotation

GitHub Actions / Clippy Results

no method named `transactions` found for enum `std::option::Option` in the current scope

error[E0599]: no method named `transactions` found for enum `std::option::Option` in the current scope --> example-crates/example_double_spending/src/main.rs:140:24 | 140 | for tx in wallet_b.transactions() { | ^^^^^^^^^^^^ method not found in `Option<PersistedWallet<Connection>>` | note: the method `transactions` exists on the type `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` --> /home/runner/work/bdk/bdk/crates/wallet/src/wallet/mod.rs:1066:5 | 1066 | pub fn transactions(&self) -> impl Iterator<Item = WalletTx> + '_ { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `Option::expect` to unwrap the `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` value, panicking if the value is an `Option::None` | 140 | for tx in wallet_b.expect("REASON").transactions() { | +++++++++++++++++
println!("wallet: {:?} tx: {:?}", wallet_b, tx);
}

for tx in wallet_b.transactions() {

Check failure on line 144 in example-crates/example_double_spending/src/main.rs

View workflow job for this annotation

GitHub Actions / Clippy Results

no method named `transactions` found for enum `std::option::Option` in the current scope

error[E0599]: no method named `transactions` found for enum `std::option::Option` in the current scope --> example-crates/example_double_spending/src/main.rs:144:24 | 144 | for tx in wallet_b.transactions() { | ^^^^^^^^^^^^ method not found in `Option<PersistedWallet<Connection>>` | note: the method `transactions` exists on the type `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` --> /home/runner/work/bdk/bdk/crates/wallet/src/wallet/mod.rs:1066:5 | 1066 | pub fn transactions(&self) -> impl Iterator<Item = WalletTx> + '_ { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `Option::expect` to unwrap the `bdk_wallet::PersistedWallet<bdk_wallet::rusqlite::Connection>` value, panicking if the value is an `Option::None` | 144 | for tx in wallet_b.expect("REASON").transactions() { | +++++++++++++++++
println!("wallet: {:?} tx: {:?}", wallet_b, tx);
}
}

0 comments on commit 1d5aab9

Please sign in to comment.