refactor(chain)!: update KeychainTxOutIndex methods to use owned ScriptBuf

This commit is contained in:
Steve Myers
2024-07-09 16:51:12 -05:00
parent 7c07b9de02
commit 79262185d5
9 changed files with 55 additions and 53 deletions

View File

@@ -119,7 +119,7 @@ pub fn init_graph<'a, A: Anchor + Clone + 'a>(
},
Some(index) => TxOut {
value: Amount::from_sat(output.value),
script_pubkey: spk_index.spk_at_index(index).unwrap().to_owned(),
script_pubkey: spk_index.spk_at_index(index).unwrap(),
},
})
.collect(),

View File

@@ -12,9 +12,7 @@ use bdk_chain::{
local_chain::LocalChain,
tx_graph, Balance, ChainPosition, ConfirmationBlockTime, DescriptorExt,
};
use bitcoin::{
secp256k1::Secp256k1, Amount, OutPoint, Script, ScriptBuf, Transaction, TxIn, TxOut,
};
use bitcoin::{secp256k1::Secp256k1, Amount, OutPoint, ScriptBuf, Transaction, TxIn, TxOut};
use miniscript::Descriptor;
/// Ensure [`IndexedTxGraph::insert_relevant_txs`] can successfully index transactions NOT presented
@@ -284,7 +282,7 @@ fn test_list_owned_txouts() {
&local_chain,
chain_tip,
graph.index.outpoints().iter().cloned(),
|_, spk: &Script| trusted_spks.contains(&spk.to_owned()),
|_, spk: ScriptBuf| trusted_spks.contains(&spk),
);
let confirmed_txouts_txid = txouts

View File

@@ -6,7 +6,7 @@ mod common;
use std::collections::{BTreeSet, HashSet};
use bdk_chain::{Balance, BlockId};
use bitcoin::{Amount, OutPoint, Script};
use bitcoin::{Amount, OutPoint, ScriptBuf};
use common::*;
#[allow(dead_code)]
@@ -659,7 +659,7 @@ fn test_tx_conflict_handling() {
&local_chain,
chain_tip,
spk_index.outpoints().iter().cloned(),
|_, spk: &Script| spk_index.index_of_spk(spk).is_some(),
|_, spk: ScriptBuf| spk_index.index_of_spk(spk).is_some(),
);
assert_eq!(
balance, scenario.exp_balance,