Update bdk_chain to bitcoin 0.30.0
This commit is contained in:
		
							parent
							
								
									d73669e8fa
								
							
						
					
					
						commit
						853d361751
					
				| @ -14,13 +14,13 @@ readme = "README.md" | |||||||
| 
 | 
 | ||||||
| [dependencies] | [dependencies] | ||||||
| # For no-std, remember to enable the bitcoin/no-std feature | # For no-std, remember to enable the bitcoin/no-std feature | ||||||
| bitcoin = { version = "0.29", default-features = false } | bitcoin = { version = "0.30.0", default-features = false } | ||||||
| serde_crate = { package = "serde", version = "1", optional = true, features = ["derive"] } | serde_crate = { package = "serde", version = "1", optional = true, features = ["derive"] } | ||||||
| 
 | 
 | ||||||
| # Use hashbrown as a feature flag to have HashSet and HashMap from it. | # Use hashbrown as a feature flag to have HashSet and HashMap from it. | ||||||
| # note version 0.13 breaks outs MSRV. | # note version 0.13 breaks outs MSRV. | ||||||
| hashbrown = { version = "0.11", optional = true, features = ["serde"] } | hashbrown = { version = "0.11", optional = true, features = ["serde"] } | ||||||
| miniscript = { version = "9.0.0", optional = true, default-features = false } | miniscript = { version = "10.0.0", optional = true, default-features = false } | ||||||
| 
 | 
 | ||||||
| [dev-dependencies] | [dev-dependencies] | ||||||
| rand = "0.8" | rand = "0.8" | ||||||
|  | |||||||
| @ -104,7 +104,7 @@ impl Default for BlockId { | |||||||
|     fn default() -> Self { |     fn default() -> Self { | ||||||
|         Self { |         Self { | ||||||
|             height: Default::default(), |             height: Default::default(), | ||||||
|             hash: BlockHash::from_inner([0u8; 32]), |             hash: BlockHash::all_zeros(), | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
| @ -3,12 +3,14 @@ use crate::miniscript::{Descriptor, DescriptorPublicKey}; | |||||||
| /// A trait to extend the functionality of a miniscript descriptor.
 | /// A trait to extend the functionality of a miniscript descriptor.
 | ||||||
| pub trait DescriptorExt { | pub trait DescriptorExt { | ||||||
|     /// Returns the minimum value (in satoshis) at which an output is broadcastable.
 |     /// Returns the minimum value (in satoshis) at which an output is broadcastable.
 | ||||||
|  |     /// Panics if the descriptor wildcard is hardened.
 | ||||||
|     fn dust_value(&self) -> u64; |     fn dust_value(&self) -> u64; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| impl DescriptorExt for Descriptor<DescriptorPublicKey> { | impl DescriptorExt for Descriptor<DescriptorPublicKey> { | ||||||
|     fn dust_value(&self) -> u64 { |     fn dust_value(&self) -> u64 { | ||||||
|         self.at_derivation_index(0) |         self.at_derivation_index(0) | ||||||
|  |             .expect("descriptor can't have hardened derivation") | ||||||
|             .script_pubkey() |             .script_pubkey() | ||||||
|             .dust_value() |             .dust_value() | ||||||
|             .to_sat() |             .to_sat() | ||||||
|  | |||||||
| @ -313,7 +313,7 @@ impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> { | |||||||
|         self.inner |         self.inner | ||||||
|             .all_spks() |             .all_spks() | ||||||
|             .range((keychain.clone(), u32::MIN)..(keychain.clone(), next_index)) |             .range((keychain.clone(), u32::MIN)..(keychain.clone(), next_index)) | ||||||
|             .map(|((_, derivation_index), spk)| (*derivation_index, spk)) |             .map(|((_, derivation_index), spk)| (*derivation_index, spk.as_script())) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /// Get the next derivation index for `keychain`. The next index is the index after the last revealed
 |     /// Get the next derivation index for `keychain`. The next index is the index after the last revealed
 | ||||||
|  | |||||||
| @ -1,5 +1,5 @@ | |||||||
| use crate::{ | use crate::{ | ||||||
|     bitcoin::{secp256k1::Secp256k1, Script}, |     bitcoin::{secp256k1::Secp256k1, ScriptBuf}, | ||||||
|     miniscript::{Descriptor, DescriptorPublicKey}, |     miniscript::{Descriptor, DescriptorPublicKey}, | ||||||
| }; | }; | ||||||
| use core::{borrow::Borrow, ops::Bound, ops::RangeBounds}; | use core::{borrow::Borrow, ops::Bound, ops::RangeBounds}; | ||||||
| @ -22,9 +22,9 @@ pub const BIP32_MAX_INDEX: u32 = (1 << 31) - 1; | |||||||
| /// # use std::str::FromStr;
 | /// # use std::str::FromStr;
 | ||||||
| /// # let secp = bitcoin::secp256k1::Secp256k1::signing_only();
 | /// # let secp = bitcoin::secp256k1::Secp256k1::signing_only();
 | ||||||
| /// # let (descriptor, _) = Descriptor::<DescriptorPublicKey>::parse_descriptor(&secp, "wpkh([73c5da0a/86'/0'/0']xprv9xgqHN7yz9MwCkxsBPN5qetuNdQSUttZNKw1dcYTV4mkaAFiBVGQziHs3NRSWMkCzvgjEe3n9xV8oYywvM8at9yRqyaZVz6TYYhX98VjsUk/1/0)").unwrap();
 | /// # let (descriptor, _) = Descriptor::<DescriptorPublicKey>::parse_descriptor(&secp, "wpkh([73c5da0a/86'/0'/0']xprv9xgqHN7yz9MwCkxsBPN5qetuNdQSUttZNKw1dcYTV4mkaAFiBVGQziHs3NRSWMkCzvgjEe3n9xV8oYywvM8at9yRqyaZVz6TYYhX98VjsUk/1/0)").unwrap();
 | ||||||
| /// # let external_spk_0 = descriptor.at_derivation_index(0).script_pubkey();
 | /// # let external_spk_0 = descriptor.at_derivation_index(0).unwrap().script_pubkey();
 | ||||||
| /// # let external_spk_3 = descriptor.at_derivation_index(3).script_pubkey();
 | /// # let external_spk_3 = descriptor.at_derivation_index(3).unwrap().script_pubkey();
 | ||||||
| /// # let external_spk_4 = descriptor.at_derivation_index(4).script_pubkey();
 | /// # let external_spk_4 = descriptor.at_derivation_index(4).unwrap().script_pubkey();
 | ||||||
| ///
 | ///
 | ||||||
| /// // Creates a new script pubkey iterator starting at 0 from a descriptor.
 | /// // Creates a new script pubkey iterator starting at 0 from a descriptor.
 | ||||||
| /// let mut spk_iter = SpkIterator::new(&descriptor);
 | /// let mut spk_iter = SpkIterator::new(&descriptor);
 | ||||||
| @ -84,7 +84,7 @@ impl<D> Iterator for SpkIterator<D> | |||||||
| where | where | ||||||
|     D: Borrow<Descriptor<DescriptorPublicKey>>, |     D: Borrow<Descriptor<DescriptorPublicKey>>, | ||||||
| { | { | ||||||
|     type Item = (u32, Script); |     type Item = (u32, ScriptBuf); | ||||||
| 
 | 
 | ||||||
|     fn next(&mut self) -> Option<Self::Item> { |     fn next(&mut self) -> Option<Self::Item> { | ||||||
|         // For non-wildcard descriptors, we expect the first element to be Some((0, spk)), then None after.
 |         // For non-wildcard descriptors, we expect the first element to be Some((0, spk)), then None after.
 | ||||||
| @ -96,8 +96,7 @@ where | |||||||
|         let script = self |         let script = self | ||||||
|             .descriptor |             .descriptor | ||||||
|             .borrow() |             .borrow() | ||||||
|             .at_derivation_index(self.next_index) |             .derived_descriptor(&self.secp, self.next_index) | ||||||
|             .derived_descriptor(&self.secp) |  | ||||||
|             .expect("the descriptor cannot need hardened derivation") |             .expect("the descriptor cannot need hardened derivation") | ||||||
|             .script_pubkey(); |             .script_pubkey(); | ||||||
|         let output = (self.next_index, script); |         let output = (self.next_index, script); | ||||||
| @ -149,15 +148,14 @@ mod test { | |||||||
| 
 | 
 | ||||||
|     #[test] |     #[test] | ||||||
|     #[allow(clippy::iter_nth_zero)] |     #[allow(clippy::iter_nth_zero)] | ||||||
|  |     #[rustfmt::skip] | ||||||
|     fn test_spkiterator_wildcard() { |     fn test_spkiterator_wildcard() { | ||||||
|         let (_, external_desc, _) = init_txout_index(); |         let (_, external_desc, _) = init_txout_index(); | ||||||
|         let external_spk_0 = external_desc.at_derivation_index(0).script_pubkey(); |         let external_spk_0 = external_desc.at_derivation_index(0).unwrap().script_pubkey(); | ||||||
|         let external_spk_16 = external_desc.at_derivation_index(16).script_pubkey(); |         let external_spk_16 = external_desc.at_derivation_index(16).unwrap().script_pubkey(); | ||||||
|         let external_spk_20 = external_desc.at_derivation_index(20).script_pubkey(); |         let external_spk_20 = external_desc.at_derivation_index(20).unwrap().script_pubkey(); | ||||||
|         let external_spk_21 = external_desc.at_derivation_index(21).script_pubkey(); |         let external_spk_21 = external_desc.at_derivation_index(21).unwrap().script_pubkey(); | ||||||
|         let external_spk_max = external_desc |         let external_spk_max = external_desc.at_derivation_index(BIP32_MAX_INDEX).unwrap().script_pubkey(); | ||||||
|             .at_derivation_index(BIP32_MAX_INDEX) |  | ||||||
|             .script_pubkey(); |  | ||||||
| 
 | 
 | ||||||
|         let mut external_spk = SpkIterator::new(&external_desc); |         let mut external_spk = SpkIterator::new(&external_desc); | ||||||
|         let max_index = BIP32_MAX_INDEX - 22; |         let max_index = BIP32_MAX_INDEX - 22; | ||||||
| @ -187,6 +185,7 @@ mod test { | |||||||
|         let (no_wildcard_descriptor, _) = Descriptor::<DescriptorPublicKey>::parse_descriptor(&secp, "wpkh([73c5da0a/86'/0'/0']xprv9xgqHN7yz9MwCkxsBPN5qetuNdQSUttZNKw1dcYTV4mkaAFiBVGQziHs3NRSWMkCzvgjEe3n9xV8oYywvM8at9yRqyaZVz6TYYhX98VjsUk/1/0)").unwrap(); |         let (no_wildcard_descriptor, _) = Descriptor::<DescriptorPublicKey>::parse_descriptor(&secp, "wpkh([73c5da0a/86'/0'/0']xprv9xgqHN7yz9MwCkxsBPN5qetuNdQSUttZNKw1dcYTV4mkaAFiBVGQziHs3NRSWMkCzvgjEe3n9xV8oYywvM8at9yRqyaZVz6TYYhX98VjsUk/1/0)").unwrap(); | ||||||
|         let external_spk_0 = no_wildcard_descriptor |         let external_spk_0 = no_wildcard_descriptor | ||||||
|             .at_derivation_index(0) |             .at_derivation_index(0) | ||||||
|  |             .unwrap() | ||||||
|             .script_pubkey(); |             .script_pubkey(); | ||||||
| 
 | 
 | ||||||
|         let mut external_spk = SpkIterator::new(&no_wildcard_descriptor); |         let mut external_spk = SpkIterator::new(&no_wildcard_descriptor); | ||||||
|  | |||||||
| @ -5,7 +5,7 @@ use crate::{ | |||||||
|     indexed_tx_graph::Indexer, |     indexed_tx_graph::Indexer, | ||||||
|     ForEachTxOut, |     ForEachTxOut, | ||||||
| }; | }; | ||||||
| use bitcoin::{self, OutPoint, Script, Transaction, TxOut, Txid}; | use bitcoin::{self, OutPoint, Script, ScriptBuf, Transaction, TxOut, Txid}; | ||||||
| 
 | 
 | ||||||
| /// An index storing [`TxOut`]s that have a script pubkey that matches those in a list.
 | /// An index storing [`TxOut`]s that have a script pubkey that matches those in a list.
 | ||||||
| ///
 | ///
 | ||||||
| @ -30,9 +30,9 @@ use bitcoin::{self, OutPoint, Script, Transaction, TxOut, Txid}; | |||||||
| #[derive(Clone, Debug)] | #[derive(Clone, Debug)] | ||||||
| pub struct SpkTxOutIndex<I> { | pub struct SpkTxOutIndex<I> { | ||||||
|     /// script pubkeys ordered by index
 |     /// script pubkeys ordered by index
 | ||||||
|     spks: BTreeMap<I, Script>, |     spks: BTreeMap<I, ScriptBuf>, | ||||||
|     /// A reverse lookup from spk to spk index
 |     /// A reverse lookup from spk to spk index
 | ||||||
|     spk_indices: HashMap<Script, I>, |     spk_indices: HashMap<ScriptBuf, I>, | ||||||
|     /// The set of unused indexes.
 |     /// The set of unused indexes.
 | ||||||
|     unused: BTreeSet<I>, |     unused: BTreeSet<I>, | ||||||
|     /// Lookup index and txout by outpoint.
 |     /// Lookup index and txout by outpoint.
 | ||||||
| @ -152,11 +152,11 @@ impl<I: Clone + Ord> SpkTxOutIndex<I> { | |||||||
|         use bitcoin::hashes::Hash; |         use bitcoin::hashes::Hash; | ||||||
|         use core::ops::Bound::*; |         use core::ops::Bound::*; | ||||||
|         let min_op = OutPoint { |         let min_op = OutPoint { | ||||||
|             txid: Txid::from_inner([0x00; 32]), |             txid: Txid::all_zeros(), | ||||||
|             vout: u32::MIN, |             vout: u32::MIN, | ||||||
|         }; |         }; | ||||||
|         let max_op = OutPoint { |         let max_op = OutPoint { | ||||||
|             txid: Txid::from_inner([0xff; 32]), |             txid: Txid::from_byte_array([0xff; Txid::LEN]), | ||||||
|             vout: u32::MAX, |             vout: u32::MAX, | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
| @ -188,18 +188,18 @@ impl<I: Clone + Ord> SpkTxOutIndex<I> { | |||||||
|     ///
 |     ///
 | ||||||
|     /// If that index hasn't been inserted yet, it will return `None`.
 |     /// If that index hasn't been inserted yet, it will return `None`.
 | ||||||
|     pub fn spk_at_index(&self, index: &I) -> Option<&Script> { |     pub fn spk_at_index(&self, index: &I) -> Option<&Script> { | ||||||
|         self.spks.get(index) |         self.spks.get(index).map(|s| s.as_script()) | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /// The script pubkeys that are being tracked by the index.
 |     /// The script pubkeys that are being tracked by the index.
 | ||||||
|     pub fn all_spks(&self) -> &BTreeMap<I, Script> { |     pub fn all_spks(&self) -> &BTreeMap<I, ScriptBuf> { | ||||||
|         &self.spks |         &self.spks | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /// Adds a script pubkey to scan for. Returns `false` and does nothing if spk already exists in the map
 |     /// Adds a script pubkey to scan for. Returns `false` and does nothing if spk already exists in the map
 | ||||||
|     ///
 |     ///
 | ||||||
|     /// the index will look for outputs spending to this spk whenever it scans new data.
 |     /// the index will look for outputs spending to this spk whenever it scans new data.
 | ||||||
|     pub fn insert_spk(&mut self, index: I, spk: Script) -> bool { |     pub fn insert_spk(&mut self, index: I, spk: ScriptBuf) -> bool { | ||||||
|         match self.spk_indices.entry(spk.clone()) { |         match self.spk_indices.entry(spk.clone()) { | ||||||
|             Entry::Vacant(value) => { |             Entry::Vacant(value) => { | ||||||
|                 value.insert(index.clone()); |                 value.insert(index.clone()); | ||||||
|  | |||||||
| @ -56,7 +56,7 @@ macro_rules! changeset { | |||||||
| pub fn new_tx(lt: u32) -> bitcoin::Transaction { | pub fn new_tx(lt: u32) -> bitcoin::Transaction { | ||||||
|     bitcoin::Transaction { |     bitcoin::Transaction { | ||||||
|         version: 0x00, |         version: 0x00, | ||||||
|         lock_time: bitcoin::PackedLockTime(lt), |         lock_time: bitcoin::absolute::LockTime::from_consensus(lt), | ||||||
|         input: vec![], |         input: vec![], | ||||||
|         output: vec![], |         output: vec![], | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -10,7 +10,9 @@ use bdk_chain::{ | |||||||
|     tx_graph::Additions, |     tx_graph::Additions, | ||||||
|     BlockId, ChainPosition, ConfirmationHeightAnchor, |     BlockId, ChainPosition, ConfirmationHeightAnchor, | ||||||
| }; | }; | ||||||
| use bitcoin::{secp256k1::Secp256k1, BlockHash, OutPoint, Script, Transaction, TxIn, TxOut}; | use bitcoin::{ | ||||||
|  |     secp256k1::Secp256k1, BlockHash, OutPoint, Script, ScriptBuf, Transaction, TxIn, TxOut, | ||||||
|  | }; | ||||||
| use miniscript::Descriptor; | use miniscript::Descriptor; | ||||||
| 
 | 
 | ||||||
| /// Ensure [`IndexedTxGraph::insert_relevant_txs`] can successfully index transactions NOT presented
 | /// Ensure [`IndexedTxGraph::insert_relevant_txs`] can successfully index transactions NOT presented
 | ||||||
| @ -25,8 +27,8 @@ fn insert_relevant_txs() { | |||||||
|     const DESCRIPTOR: &str = "tr([73c5da0a/86'/0'/0']xprv9xgqHN7yz9MwCkxsBPN5qetuNdQSUttZNKw1dcYTV4mkaAFiBVGQziHs3NRSWMkCzvgjEe3n9xV8oYywvM8at9yRqyaZVz6TYYhX98VjsUk/0/*)"; |     const DESCRIPTOR: &str = "tr([73c5da0a/86'/0'/0']xprv9xgqHN7yz9MwCkxsBPN5qetuNdQSUttZNKw1dcYTV4mkaAFiBVGQziHs3NRSWMkCzvgjEe3n9xV8oYywvM8at9yRqyaZVz6TYYhX98VjsUk/0/*)"; | ||||||
|     let (descriptor, _) = Descriptor::parse_descriptor(&Secp256k1::signing_only(), DESCRIPTOR) |     let (descriptor, _) = Descriptor::parse_descriptor(&Secp256k1::signing_only(), DESCRIPTOR) | ||||||
|         .expect("must be valid"); |         .expect("must be valid"); | ||||||
|     let spk_0 = descriptor.at_derivation_index(0).script_pubkey(); |     let spk_0 = descriptor.at_derivation_index(0).unwrap().script_pubkey(); | ||||||
|     let spk_1 = descriptor.at_derivation_index(9).script_pubkey(); |     let spk_1 = descriptor.at_derivation_index(9).unwrap().script_pubkey(); | ||||||
| 
 | 
 | ||||||
|     let mut graph = IndexedTxGraph::<ConfirmationHeightAnchor, KeychainTxOutIndex<()>>::default(); |     let mut graph = IndexedTxGraph::<ConfirmationHeightAnchor, KeychainTxOutIndex<()>>::default(); | ||||||
|     graph.index.add_keychain((), descriptor); |     graph.index.add_keychain((), descriptor); | ||||||
| @ -127,21 +129,21 @@ fn test_list_owned_txouts() { | |||||||
| 
 | 
 | ||||||
|     // Get trusted and untrusted addresses
 |     // Get trusted and untrusted addresses
 | ||||||
| 
 | 
 | ||||||
|     let mut trusted_spks = Vec::new(); |     let mut trusted_spks: Vec<ScriptBuf> = Vec::new(); | ||||||
|     let mut untrusted_spks = Vec::new(); |     let mut untrusted_spks: Vec<ScriptBuf> = Vec::new(); | ||||||
| 
 | 
 | ||||||
|     { |     { | ||||||
|         // we need to scope here to take immutanble reference of the graph
 |         // we need to scope here to take immutanble reference of the graph
 | ||||||
|         for _ in 0..10 { |         for _ in 0..10 { | ||||||
|             let ((_, script), _) = graph.index.reveal_next_spk(&"keychain_1".to_string()); |             let ((_, script), _) = graph.index.reveal_next_spk(&"keychain_1".to_string()); | ||||||
|             // TODO Assert indexes
 |             // TODO Assert indexes
 | ||||||
|             trusted_spks.push(script.clone()); |             trusted_spks.push(script.to_owned()); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     { |     { | ||||||
|         for _ in 0..10 { |         for _ in 0..10 { | ||||||
|             let ((_, script), _) = graph.index.reveal_next_spk(&"keychain_2".to_string()); |             let ((_, script), _) = graph.index.reveal_next_spk(&"keychain_2".to_string()); | ||||||
|             untrusted_spks.push(script.clone()); |             untrusted_spks.push(script.to_owned()); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -155,7 +157,7 @@ fn test_list_owned_txouts() { | |||||||
|         }], |         }], | ||||||
|         output: vec![TxOut { |         output: vec![TxOut { | ||||||
|             value: 70000, |             value: 70000, | ||||||
|             script_pubkey: trusted_spks[0].clone(), |             script_pubkey: trusted_spks[0].to_owned(), | ||||||
|         }], |         }], | ||||||
|         ..common::new_tx(0) |         ..common::new_tx(0) | ||||||
|     }; |     }; | ||||||
| @ -164,7 +166,7 @@ fn test_list_owned_txouts() { | |||||||
|     let tx2 = Transaction { |     let tx2 = Transaction { | ||||||
|         output: vec![TxOut { |         output: vec![TxOut { | ||||||
|             value: 30000, |             value: 30000, | ||||||
|             script_pubkey: untrusted_spks[0].clone(), |             script_pubkey: untrusted_spks[0].to_owned(), | ||||||
|         }], |         }], | ||||||
|         ..common::new_tx(0) |         ..common::new_tx(0) | ||||||
|     }; |     }; | ||||||
| @ -177,7 +179,7 @@ fn test_list_owned_txouts() { | |||||||
|         }], |         }], | ||||||
|         output: vec![TxOut { |         output: vec![TxOut { | ||||||
|             value: 10000, |             value: 10000, | ||||||
|             script_pubkey: trusted_spks[1].clone(), |             script_pubkey: trusted_spks[1].to_owned(), | ||||||
|         }], |         }], | ||||||
|         ..common::new_tx(0) |         ..common::new_tx(0) | ||||||
|     }; |     }; | ||||||
| @ -186,7 +188,7 @@ fn test_list_owned_txouts() { | |||||||
|     let tx4 = Transaction { |     let tx4 = Transaction { | ||||||
|         output: vec![TxOut { |         output: vec![TxOut { | ||||||
|             value: 20000, |             value: 20000, | ||||||
|             script_pubkey: untrusted_spks[1].clone(), |             script_pubkey: untrusted_spks[1].to_owned(), | ||||||
|         }], |         }], | ||||||
|         ..common::new_tx(0) |         ..common::new_tx(0) | ||||||
|     }; |     }; | ||||||
| @ -195,7 +197,7 @@ fn test_list_owned_txouts() { | |||||||
|     let tx5 = Transaction { |     let tx5 = Transaction { | ||||||
|         output: vec![TxOut { |         output: vec![TxOut { | ||||||
|             value: 15000, |             value: 15000, | ||||||
|             script_pubkey: trusted_spks[2].clone(), |             script_pubkey: trusted_spks[2].to_owned(), | ||||||
|         }], |         }], | ||||||
|         ..common::new_tx(0) |         ..common::new_tx(0) | ||||||
|     }; |     }; | ||||||
| @ -258,7 +260,7 @@ fn test_list_owned_txouts() { | |||||||
|                 &local_chain, |                 &local_chain, | ||||||
|                 chain_tip, |                 chain_tip, | ||||||
|                 graph.index.outpoints().iter().cloned(), |                 graph.index.outpoints().iter().cloned(), | ||||||
|                 |_, spk: &Script| trusted_spks.contains(spk), |                 |_, spk: &Script| trusted_spks.contains(&spk.to_owned()), | ||||||
|             ); |             ); | ||||||
| 
 | 
 | ||||||
|             assert_eq!(txouts.len(), 5); |             assert_eq!(txouts.len(), 5); | ||||||
|  | |||||||
| @ -8,7 +8,7 @@ use bdk_chain::{ | |||||||
|     Append, |     Append, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| use bitcoin::{secp256k1::Secp256k1, OutPoint, Script, Transaction, TxOut}; | use bitcoin::{secp256k1::Secp256k1, OutPoint, ScriptBuf, Transaction, TxOut}; | ||||||
| use miniscript::{Descriptor, DescriptorPublicKey}; | use miniscript::{Descriptor, DescriptorPublicKey}; | ||||||
| 
 | 
 | ||||||
| #[derive(Clone, Debug, PartialEq, Eq, Ord, PartialOrd)] | #[derive(Clone, Debug, PartialEq, Eq, Ord, PartialOrd)] | ||||||
| @ -34,7 +34,7 @@ fn init_txout_index() -> ( | |||||||
|     (txout_index, external_descriptor, internal_descriptor) |     (txout_index, external_descriptor, internal_descriptor) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| fn spk_at_index(descriptor: &Descriptor<DescriptorPublicKey>, index: u32) -> Script { | fn spk_at_index(descriptor: &Descriptor<DescriptorPublicKey>, index: u32) -> ScriptBuf { | ||||||
|     descriptor |     descriptor | ||||||
|         .derived_descriptor(&Secp256k1::verification_only(), index) |         .derived_descriptor(&Secp256k1::verification_only(), index) | ||||||
|         .expect("must derive") |         .expect("must derive") | ||||||
| @ -177,12 +177,14 @@ fn test_lookahead() { | |||||||
|                 TxOut { |                 TxOut { | ||||||
|                     script_pubkey: external_desc |                     script_pubkey: external_desc | ||||||
|                         .at_derivation_index(external_index) |                         .at_derivation_index(external_index) | ||||||
|  |                         .unwrap() | ||||||
|                         .script_pubkey(), |                         .script_pubkey(), | ||||||
|                     value: 10_000, |                     value: 10_000, | ||||||
|                 }, |                 }, | ||||||
|                 TxOut { |                 TxOut { | ||||||
|                     script_pubkey: internal_desc |                     script_pubkey: internal_desc | ||||||
|                         .at_derivation_index(internal_index) |                         .at_derivation_index(internal_index) | ||||||
|  |                         .unwrap() | ||||||
|                         .script_pubkey(), |                         .script_pubkey(), | ||||||
|                     value: 10_000, |                     value: 10_000, | ||||||
|                 }, |                 }, | ||||||
| @ -223,9 +225,17 @@ fn test_scan_with_lookahead() { | |||||||
|     let (mut txout_index, external_desc, _) = init_txout_index(); |     let (mut txout_index, external_desc, _) = init_txout_index(); | ||||||
|     txout_index.set_lookahead_for_all(10); |     txout_index.set_lookahead_for_all(10); | ||||||
| 
 | 
 | ||||||
|     let spks: BTreeMap<u32, Script> = [0, 10, 20, 30] |     let spks: BTreeMap<u32, ScriptBuf> = [0, 10, 20, 30] | ||||||
|         .into_iter() |         .into_iter() | ||||||
|         .map(|i| (i, external_desc.at_derivation_index(i).script_pubkey())) |         .map(|i| { | ||||||
|  |             ( | ||||||
|  |                 i, | ||||||
|  |                 external_desc | ||||||
|  |                     .at_derivation_index(i) | ||||||
|  |                     .unwrap() | ||||||
|  |                     .script_pubkey(), | ||||||
|  |             ) | ||||||
|  |         }) | ||||||
|         .collect(); |         .collect(); | ||||||
| 
 | 
 | ||||||
|     for (&spk_i, spk) in &spks { |     for (&spk_i, spk) in &spks { | ||||||
| @ -251,7 +261,10 @@ fn test_scan_with_lookahead() { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     // now try with index 41 (lookahead surpassed), we expect that the txout to not be indexed
 |     // now try with index 41 (lookahead surpassed), we expect that the txout to not be indexed
 | ||||||
|     let spk_41 = external_desc.at_derivation_index(41).script_pubkey(); |     let spk_41 = external_desc | ||||||
|  |         .at_derivation_index(41) | ||||||
|  |         .unwrap() | ||||||
|  |         .script_pubkey(); | ||||||
|     let op = OutPoint::new(h!("fake tx"), 41); |     let op = OutPoint::new(h!("fake tx"), 41); | ||||||
|     let txout = TxOut { |     let txout = TxOut { | ||||||
|         script_pubkey: spk_41, |         script_pubkey: spk_41, | ||||||
| @ -262,12 +275,13 @@ fn test_scan_with_lookahead() { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| #[test] | #[test] | ||||||
|  | #[rustfmt::skip] | ||||||
| fn test_wildcard_derivations() { | fn test_wildcard_derivations() { | ||||||
|     let (mut txout_index, external_desc, _) = init_txout_index(); |     let (mut txout_index, external_desc, _) = init_txout_index(); | ||||||
|     let external_spk_0 = external_desc.at_derivation_index(0).script_pubkey(); |     let external_spk_0 = external_desc.at_derivation_index(0).unwrap().script_pubkey(); | ||||||
|     let external_spk_16 = external_desc.at_derivation_index(16).script_pubkey(); |     let external_spk_16 = external_desc.at_derivation_index(16).unwrap().script_pubkey(); | ||||||
|     let external_spk_26 = external_desc.at_derivation_index(26).script_pubkey(); |     let external_spk_26 = external_desc.at_derivation_index(26).unwrap().script_pubkey(); | ||||||
|     let external_spk_27 = external_desc.at_derivation_index(27).script_pubkey(); |     let external_spk_27 = external_desc.at_derivation_index(27).unwrap().script_pubkey(); | ||||||
| 
 | 
 | ||||||
|     // - nothing is derived
 |     // - nothing is derived
 | ||||||
|     // - unused list is also empty
 |     // - unused list is also empty
 | ||||||
| @ -277,10 +291,10 @@ fn test_wildcard_derivations() { | |||||||
|     // - next_unused() == ((0, <spk>), DerivationAdditions:is_empty())
 |     // - next_unused() == ((0, <spk>), DerivationAdditions:is_empty())
 | ||||||
|     assert_eq!(txout_index.next_index(&TestKeychain::External), (0, true)); |     assert_eq!(txout_index.next_index(&TestKeychain::External), (0, true)); | ||||||
|     let (spk, changeset) = txout_index.reveal_next_spk(&TestKeychain::External); |     let (spk, changeset) = txout_index.reveal_next_spk(&TestKeychain::External); | ||||||
|     assert_eq!(spk, (0_u32, &external_spk_0)); |     assert_eq!(spk, (0_u32, external_spk_0.as_script())); | ||||||
|     assert_eq!(changeset.as_inner(), &[(TestKeychain::External, 0)].into()); |     assert_eq!(changeset.as_inner(), &[(TestKeychain::External, 0)].into()); | ||||||
|     let (spk, changeset) = txout_index.next_unused_spk(&TestKeychain::External); |     let (spk, changeset) = txout_index.next_unused_spk(&TestKeychain::External); | ||||||
|     assert_eq!(spk, (0_u32, &external_spk_0)); |     assert_eq!(spk, (0_u32, external_spk_0.as_script())); | ||||||
|     assert_eq!(changeset.as_inner(), &[].into()); |     assert_eq!(changeset.as_inner(), &[].into()); | ||||||
| 
 | 
 | ||||||
|     // - derived till 25
 |     // - derived till 25
 | ||||||
| @ -300,12 +314,12 @@ fn test_wildcard_derivations() { | |||||||
|     assert_eq!(txout_index.next_index(&TestKeychain::External), (26, true)); |     assert_eq!(txout_index.next_index(&TestKeychain::External), (26, true)); | ||||||
| 
 | 
 | ||||||
|     let (spk, changeset) = txout_index.reveal_next_spk(&TestKeychain::External); |     let (spk, changeset) = txout_index.reveal_next_spk(&TestKeychain::External); | ||||||
|     assert_eq!(spk, (26, &external_spk_26)); |     assert_eq!(spk, (26, external_spk_26.as_script())); | ||||||
| 
 | 
 | ||||||
|     assert_eq!(changeset.as_inner(), &[(TestKeychain::External, 26)].into()); |     assert_eq!(changeset.as_inner(), &[(TestKeychain::External, 26)].into()); | ||||||
| 
 | 
 | ||||||
|     let (spk, changeset) = txout_index.next_unused_spk(&TestKeychain::External); |     let (spk, changeset) = txout_index.next_unused_spk(&TestKeychain::External); | ||||||
|     assert_eq!(spk, (16, &external_spk_16)); |     assert_eq!(spk, (16, external_spk_16.as_script())); | ||||||
|     assert_eq!(changeset.as_inner(), &[].into()); |     assert_eq!(changeset.as_inner(), &[].into()); | ||||||
| 
 | 
 | ||||||
|     // - Use all the derived till 26.
 |     // - Use all the derived till 26.
 | ||||||
| @ -315,7 +329,7 @@ fn test_wildcard_derivations() { | |||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     let (spk, changeset) = txout_index.next_unused_spk(&TestKeychain::External); |     let (spk, changeset) = txout_index.next_unused_spk(&TestKeychain::External); | ||||||
|     assert_eq!(spk, (27, &external_spk_27)); |     assert_eq!(spk, (27, external_spk_27.as_script())); | ||||||
|     assert_eq!(changeset.as_inner(), &[(TestKeychain::External, 27)].into()); |     assert_eq!(changeset.as_inner(), &[(TestKeychain::External, 27)].into()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -327,6 +341,7 @@ fn test_non_wildcard_derivations() { | |||||||
|     let (no_wildcard_descriptor, _) = Descriptor::<DescriptorPublicKey>::parse_descriptor(&secp, "wpkh([73c5da0a/86'/0'/0']xprv9xgqHN7yz9MwCkxsBPN5qetuNdQSUttZNKw1dcYTV4mkaAFiBVGQziHs3NRSWMkCzvgjEe3n9xV8oYywvM8at9yRqyaZVz6TYYhX98VjsUk/1/0)").unwrap(); |     let (no_wildcard_descriptor, _) = Descriptor::<DescriptorPublicKey>::parse_descriptor(&secp, "wpkh([73c5da0a/86'/0'/0']xprv9xgqHN7yz9MwCkxsBPN5qetuNdQSUttZNKw1dcYTV4mkaAFiBVGQziHs3NRSWMkCzvgjEe3n9xV8oYywvM8at9yRqyaZVz6TYYhX98VjsUk/1/0)").unwrap(); | ||||||
|     let external_spk = no_wildcard_descriptor |     let external_spk = no_wildcard_descriptor | ||||||
|         .at_derivation_index(0) |         .at_derivation_index(0) | ||||||
|  |         .unwrap() | ||||||
|         .script_pubkey(); |         .script_pubkey(); | ||||||
| 
 | 
 | ||||||
|     txout_index.add_keychain(TestKeychain::External, no_wildcard_descriptor); |     txout_index.add_keychain(TestKeychain::External, no_wildcard_descriptor); | ||||||
| @ -339,11 +354,11 @@ fn test_non_wildcard_derivations() { | |||||||
|     // - when we get the next unused script, script @ index 0
 |     // - when we get the next unused script, script @ index 0
 | ||||||
|     assert_eq!(txout_index.next_index(&TestKeychain::External), (0, true)); |     assert_eq!(txout_index.next_index(&TestKeychain::External), (0, true)); | ||||||
|     let (spk, changeset) = txout_index.reveal_next_spk(&TestKeychain::External); |     let (spk, changeset) = txout_index.reveal_next_spk(&TestKeychain::External); | ||||||
|     assert_eq!(spk, (0, &external_spk)); |     assert_eq!(spk, (0, external_spk.as_script())); | ||||||
|     assert_eq!(changeset.as_inner(), &[(TestKeychain::External, 0)].into()); |     assert_eq!(changeset.as_inner(), &[(TestKeychain::External, 0)].into()); | ||||||
| 
 | 
 | ||||||
|     let (spk, changeset) = txout_index.next_unused_spk(&TestKeychain::External); |     let (spk, changeset) = txout_index.next_unused_spk(&TestKeychain::External); | ||||||
|     assert_eq!(spk, (0, &external_spk)); |     assert_eq!(spk, (0, external_spk.as_script())); | ||||||
|     assert_eq!(changeset.as_inner(), &[].into()); |     assert_eq!(changeset.as_inner(), &[].into()); | ||||||
| 
 | 
 | ||||||
|     // given:
 |     // given:
 | ||||||
| @ -356,11 +371,11 @@ fn test_non_wildcard_derivations() { | |||||||
|     txout_index.mark_used(&TestKeychain::External, 0); |     txout_index.mark_used(&TestKeychain::External, 0); | ||||||
| 
 | 
 | ||||||
|     let (spk, changeset) = txout_index.reveal_next_spk(&TestKeychain::External); |     let (spk, changeset) = txout_index.reveal_next_spk(&TestKeychain::External); | ||||||
|     assert_eq!(spk, (0, &external_spk)); |     assert_eq!(spk, (0, external_spk.as_script())); | ||||||
|     assert_eq!(changeset.as_inner(), &[].into()); |     assert_eq!(changeset.as_inner(), &[].into()); | ||||||
| 
 | 
 | ||||||
|     let (spk, changeset) = txout_index.next_unused_spk(&TestKeychain::External); |     let (spk, changeset) = txout_index.next_unused_spk(&TestKeychain::External); | ||||||
|     assert_eq!(spk, (0, &external_spk)); |     assert_eq!(spk, (0, external_spk.as_script())); | ||||||
|     assert_eq!(changeset.as_inner(), &[].into()); |     assert_eq!(changeset.as_inner(), &[].into()); | ||||||
|     let (revealed_spks, revealed_additions) = |     let (revealed_spks, revealed_additions) = | ||||||
|         txout_index.reveal_to_target(&TestKeychain::External, 200); |         txout_index.reveal_to_target(&TestKeychain::External, 200); | ||||||
|  | |||||||
| @ -1,10 +1,10 @@ | |||||||
| use bdk_chain::SpkTxOutIndex; | use bdk_chain::SpkTxOutIndex; | ||||||
| use bitcoin::{hashes::hex::FromHex, OutPoint, PackedLockTime, Script, Transaction, TxIn, TxOut}; | use bitcoin::{absolute, OutPoint, ScriptBuf, Transaction, TxIn, TxOut}; | ||||||
| 
 | 
 | ||||||
| #[test] | #[test] | ||||||
| fn spk_txout_sent_and_received() { | fn spk_txout_sent_and_received() { | ||||||
|     let spk1 = Script::from_hex("001404f1e52ce2bab3423c6a8c63b7cd730d8f12542c").unwrap(); |     let spk1 = ScriptBuf::from_hex("001404f1e52ce2bab3423c6a8c63b7cd730d8f12542c").unwrap(); | ||||||
|     let spk2 = Script::from_hex("00142b57404ae14f08c3a0c903feb2af7830605eb00f").unwrap(); |     let spk2 = ScriptBuf::from_hex("00142b57404ae14f08c3a0c903feb2af7830605eb00f").unwrap(); | ||||||
| 
 | 
 | ||||||
|     let mut index = SpkTxOutIndex::default(); |     let mut index = SpkTxOutIndex::default(); | ||||||
|     index.insert_spk(0, spk1.clone()); |     index.insert_spk(0, spk1.clone()); | ||||||
| @ -12,7 +12,7 @@ fn spk_txout_sent_and_received() { | |||||||
| 
 | 
 | ||||||
|     let tx1 = Transaction { |     let tx1 = Transaction { | ||||||
|         version: 0x02, |         version: 0x02, | ||||||
|         lock_time: PackedLockTime(0), |         lock_time: absolute::LockTime::ZERO, | ||||||
|         input: vec![], |         input: vec![], | ||||||
|         output: vec![TxOut { |         output: vec![TxOut { | ||||||
|             value: 42_000, |             value: 42_000, | ||||||
| @ -31,7 +31,7 @@ fn spk_txout_sent_and_received() { | |||||||
| 
 | 
 | ||||||
|     let tx2 = Transaction { |     let tx2 = Transaction { | ||||||
|         version: 0x1, |         version: 0x1, | ||||||
|         lock_time: PackedLockTime(0), |         lock_time: absolute::LockTime::ZERO, | ||||||
|         input: vec![TxIn { |         input: vec![TxIn { | ||||||
|             previous_output: OutPoint { |             previous_output: OutPoint { | ||||||
|                 txid: tx1.txid(), |                 txid: tx1.txid(), | ||||||
| @ -57,8 +57,8 @@ fn spk_txout_sent_and_received() { | |||||||
| 
 | 
 | ||||||
| #[test] | #[test] | ||||||
| fn mark_used() { | fn mark_used() { | ||||||
|     let spk1 = Script::from_hex("001404f1e52ce2bab3423c6a8c63b7cd730d8f12542c").unwrap(); |     let spk1 = ScriptBuf::from_hex("001404f1e52ce2bab3423c6a8c63b7cd730d8f12542c").unwrap(); | ||||||
|     let spk2 = Script::from_hex("00142b57404ae14f08c3a0c903feb2af7830605eb00f").unwrap(); |     let spk2 = ScriptBuf::from_hex("00142b57404ae14f08c3a0c903feb2af7830605eb00f").unwrap(); | ||||||
| 
 | 
 | ||||||
|     let mut spk_index = SpkTxOutIndex::default(); |     let mut spk_index = SpkTxOutIndex::default(); | ||||||
|     spk_index.insert_spk(1, spk1.clone()); |     spk_index.insert_spk(1, spk1.clone()); | ||||||
| @ -74,7 +74,7 @@ fn mark_used() { | |||||||
| 
 | 
 | ||||||
|     let tx1 = Transaction { |     let tx1 = Transaction { | ||||||
|         version: 0x02, |         version: 0x02, | ||||||
|         lock_time: PackedLockTime(0), |         lock_time: absolute::LockTime::ZERO, | ||||||
|         input: vec![], |         input: vec![], | ||||||
|         output: vec![TxOut { |         output: vec![TxOut { | ||||||
|             value: 42_000, |             value: 42_000, | ||||||
|  | |||||||
| @ -7,7 +7,7 @@ use bdk_chain::{ | |||||||
|     Anchor, Append, BlockId, ChainPosition, ConfirmationHeightAnchor, |     Anchor, Append, BlockId, ChainPosition, ConfirmationHeightAnchor, | ||||||
| }; | }; | ||||||
| use bitcoin::{ | use bitcoin::{ | ||||||
|     hashes::Hash, BlockHash, OutPoint, PackedLockTime, Script, Transaction, TxIn, TxOut, Txid, |     absolute, hashes::Hash, BlockHash, OutPoint, ScriptBuf, Transaction, TxIn, TxOut, Txid, | ||||||
| }; | }; | ||||||
| use core::iter; | use core::iter; | ||||||
| use std::vec; | use std::vec; | ||||||
| @ -20,14 +20,14 @@ fn insert_txouts() { | |||||||
|             OutPoint::new(h!("tx1"), 1), |             OutPoint::new(h!("tx1"), 1), | ||||||
|             TxOut { |             TxOut { | ||||||
|                 value: 10_000, |                 value: 10_000, | ||||||
|                 script_pubkey: Script::new(), |                 script_pubkey: ScriptBuf::new(), | ||||||
|             }, |             }, | ||||||
|         ), |         ), | ||||||
|         ( |         ( | ||||||
|             OutPoint::new(h!("tx1"), 2), |             OutPoint::new(h!("tx1"), 2), | ||||||
|             TxOut { |             TxOut { | ||||||
|                 value: 20_000, |                 value: 20_000, | ||||||
|                 script_pubkey: Script::new(), |                 script_pubkey: ScriptBuf::new(), | ||||||
|             }, |             }, | ||||||
|         ), |         ), | ||||||
|     ]; |     ]; | ||||||
| @ -37,21 +37,21 @@ fn insert_txouts() { | |||||||
|         OutPoint::new(h!("tx2"), 0), |         OutPoint::new(h!("tx2"), 0), | ||||||
|         TxOut { |         TxOut { | ||||||
|             value: 20_000, |             value: 20_000, | ||||||
|             script_pubkey: Script::new(), |             script_pubkey: ScriptBuf::new(), | ||||||
|         }, |         }, | ||||||
|     )]; |     )]; | ||||||
| 
 | 
 | ||||||
|     // One full transaction to be included in the update
 |     // One full transaction to be included in the update
 | ||||||
|     let update_txs = Transaction { |     let update_txs = Transaction { | ||||||
|         version: 0x01, |         version: 0x01, | ||||||
|         lock_time: PackedLockTime(0), |         lock_time: absolute::LockTime::ZERO, | ||||||
|         input: vec![TxIn { |         input: vec![TxIn { | ||||||
|             previous_output: OutPoint::null(), |             previous_output: OutPoint::null(), | ||||||
|             ..Default::default() |             ..Default::default() | ||||||
|         }], |         }], | ||||||
|         output: vec![TxOut { |         output: vec![TxOut { | ||||||
|             value: 30_000, |             value: 30_000, | ||||||
|             script_pubkey: Script::new(), |             script_pubkey: ScriptBuf::new(), | ||||||
|         }], |         }], | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
| @ -161,14 +161,14 @@ fn insert_txouts() { | |||||||
|                 1u32, |                 1u32, | ||||||
|                 &TxOut { |                 &TxOut { | ||||||
|                     value: 10_000, |                     value: 10_000, | ||||||
|                     script_pubkey: Script::new(), |                     script_pubkey: ScriptBuf::new(), | ||||||
|                 } |                 } | ||||||
|             ), |             ), | ||||||
|             ( |             ( | ||||||
|                 2u32, |                 2u32, | ||||||
|                 &TxOut { |                 &TxOut { | ||||||
|                     value: 20_000, |                     value: 20_000, | ||||||
|                     script_pubkey: Script::new(), |                     script_pubkey: ScriptBuf::new(), | ||||||
|                 } |                 } | ||||||
|             ) |             ) | ||||||
|         ] |         ] | ||||||
| @ -181,7 +181,7 @@ fn insert_txouts() { | |||||||
|             0u32, |             0u32, | ||||||
|             &TxOut { |             &TxOut { | ||||||
|                 value: 30_000, |                 value: 30_000, | ||||||
|                 script_pubkey: Script::new() |                 script_pubkey: ScriptBuf::new() | ||||||
|             } |             } | ||||||
|         )] |         )] | ||||||
|         .into() |         .into() | ||||||
| @ -192,7 +192,7 @@ fn insert_txouts() { | |||||||
| fn insert_tx_graph_doesnt_count_coinbase_as_spent() { | fn insert_tx_graph_doesnt_count_coinbase_as_spent() { | ||||||
|     let tx = Transaction { |     let tx = Transaction { | ||||||
|         version: 0x01, |         version: 0x01, | ||||||
|         lock_time: PackedLockTime(0), |         lock_time: absolute::LockTime::ZERO, | ||||||
|         input: vec![TxIn { |         input: vec![TxIn { | ||||||
|             previous_output: OutPoint::null(), |             previous_output: OutPoint::null(), | ||||||
|             ..Default::default() |             ..Default::default() | ||||||
| @ -210,7 +210,7 @@ fn insert_tx_graph_doesnt_count_coinbase_as_spent() { | |||||||
| fn insert_tx_graph_keeps_track_of_spend() { | fn insert_tx_graph_keeps_track_of_spend() { | ||||||
|     let tx1 = Transaction { |     let tx1 = Transaction { | ||||||
|         version: 0x01, |         version: 0x01, | ||||||
|         lock_time: PackedLockTime(0), |         lock_time: absolute::LockTime::ZERO, | ||||||
|         input: vec![], |         input: vec![], | ||||||
|         output: vec![TxOut::default()], |         output: vec![TxOut::default()], | ||||||
|     }; |     }; | ||||||
| @ -222,7 +222,7 @@ fn insert_tx_graph_keeps_track_of_spend() { | |||||||
| 
 | 
 | ||||||
|     let tx2 = Transaction { |     let tx2 = Transaction { | ||||||
|         version: 0x01, |         version: 0x01, | ||||||
|         lock_time: PackedLockTime(0), |         lock_time: absolute::LockTime::ZERO, | ||||||
|         input: vec![TxIn { |         input: vec![TxIn { | ||||||
|             previous_output: op, |             previous_output: op, | ||||||
|             ..Default::default() |             ..Default::default() | ||||||
| @ -251,7 +251,7 @@ fn insert_tx_graph_keeps_track_of_spend() { | |||||||
| fn insert_tx_can_retrieve_full_tx_from_graph() { | fn insert_tx_can_retrieve_full_tx_from_graph() { | ||||||
|     let tx = Transaction { |     let tx = Transaction { | ||||||
|         version: 0x01, |         version: 0x01, | ||||||
|         lock_time: PackedLockTime(0), |         lock_time: absolute::LockTime::ZERO, | ||||||
|         input: vec![TxIn { |         input: vec![TxIn { | ||||||
|             previous_output: OutPoint::null(), |             previous_output: OutPoint::null(), | ||||||
|             ..Default::default() |             ..Default::default() | ||||||
| @ -269,11 +269,11 @@ fn insert_tx_displaces_txouts() { | |||||||
|     let mut tx_graph = TxGraph::<()>::default(); |     let mut tx_graph = TxGraph::<()>::default(); | ||||||
|     let tx = Transaction { |     let tx = Transaction { | ||||||
|         version: 0x01, |         version: 0x01, | ||||||
|         lock_time: PackedLockTime(0), |         lock_time: absolute::LockTime::ZERO, | ||||||
|         input: vec![], |         input: vec![], | ||||||
|         output: vec![TxOut { |         output: vec![TxOut { | ||||||
|             value: 42_000, |             value: 42_000, | ||||||
|             script_pubkey: Script::default(), |             script_pubkey: ScriptBuf::default(), | ||||||
|         }], |         }], | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
| @ -284,7 +284,7 @@ fn insert_tx_displaces_txouts() { | |||||||
|         }, |         }, | ||||||
|         TxOut { |         TxOut { | ||||||
|             value: 1_337_000, |             value: 1_337_000, | ||||||
|             script_pubkey: Script::default(), |             script_pubkey: ScriptBuf::default(), | ||||||
|         }, |         }, | ||||||
|     ); |     ); | ||||||
| 
 | 
 | ||||||
| @ -295,7 +295,7 @@ fn insert_tx_displaces_txouts() { | |||||||
|         }, |         }, | ||||||
|         TxOut { |         TxOut { | ||||||
|             value: 1_000_000_000, |             value: 1_000_000_000, | ||||||
|             script_pubkey: Script::default(), |             script_pubkey: ScriptBuf::default(), | ||||||
|         }, |         }, | ||||||
|     ); |     ); | ||||||
| 
 | 
 | ||||||
| @ -325,11 +325,11 @@ fn insert_txout_does_not_displace_tx() { | |||||||
|     let mut tx_graph = TxGraph::<()>::default(); |     let mut tx_graph = TxGraph::<()>::default(); | ||||||
|     let tx = Transaction { |     let tx = Transaction { | ||||||
|         version: 0x01, |         version: 0x01, | ||||||
|         lock_time: PackedLockTime(0), |         lock_time: absolute::LockTime::ZERO, | ||||||
|         input: vec![], |         input: vec![], | ||||||
|         output: vec![TxOut { |         output: vec![TxOut { | ||||||
|             value: 42_000, |             value: 42_000, | ||||||
|             script_pubkey: Script::default(), |             script_pubkey: ScriptBuf::default(), | ||||||
|         }], |         }], | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
| @ -342,7 +342,7 @@ fn insert_txout_does_not_displace_tx() { | |||||||
|         }, |         }, | ||||||
|         TxOut { |         TxOut { | ||||||
|             value: 1_337_000, |             value: 1_337_000, | ||||||
|             script_pubkey: Script::default(), |             script_pubkey: ScriptBuf::default(), | ||||||
|         }, |         }, | ||||||
|     ); |     ); | ||||||
| 
 | 
 | ||||||
| @ -353,7 +353,7 @@ fn insert_txout_does_not_displace_tx() { | |||||||
|         }, |         }, | ||||||
|         TxOut { |         TxOut { | ||||||
|             value: 1_000_000_000, |             value: 1_000_000_000, | ||||||
|             script_pubkey: Script::default(), |             script_pubkey: ScriptBuf::default(), | ||||||
|         }, |         }, | ||||||
|     ); |     ); | ||||||
| 
 | 
 | ||||||
| @ -381,7 +381,7 @@ fn test_calculate_fee() { | |||||||
|     let mut graph = TxGraph::<()>::default(); |     let mut graph = TxGraph::<()>::default(); | ||||||
|     let intx1 = Transaction { |     let intx1 = Transaction { | ||||||
|         version: 0x01, |         version: 0x01, | ||||||
|         lock_time: PackedLockTime(0), |         lock_time: absolute::LockTime::ZERO, | ||||||
|         input: vec![], |         input: vec![], | ||||||
|         output: vec![TxOut { |         output: vec![TxOut { | ||||||
|             value: 100, |             value: 100, | ||||||
| @ -390,7 +390,7 @@ fn test_calculate_fee() { | |||||||
|     }; |     }; | ||||||
|     let intx2 = Transaction { |     let intx2 = Transaction { | ||||||
|         version: 0x02, |         version: 0x02, | ||||||
|         lock_time: PackedLockTime(0), |         lock_time: absolute::LockTime::ZERO, | ||||||
|         input: vec![], |         input: vec![], | ||||||
|         output: vec![TxOut { |         output: vec![TxOut { | ||||||
|             value: 200, |             value: 200, | ||||||
| @ -415,7 +415,7 @@ fn test_calculate_fee() { | |||||||
| 
 | 
 | ||||||
|     let mut tx = Transaction { |     let mut tx = Transaction { | ||||||
|         version: 0x01, |         version: 0x01, | ||||||
|         lock_time: PackedLockTime(0), |         lock_time: absolute::LockTime::ZERO, | ||||||
|         input: vec![ |         input: vec![ | ||||||
|             TxIn { |             TxIn { | ||||||
|                 previous_output: OutPoint { |                 previous_output: OutPoint { | ||||||
| @ -464,7 +464,7 @@ fn test_calculate_fee() { | |||||||
| fn test_calculate_fee_on_coinbase() { | fn test_calculate_fee_on_coinbase() { | ||||||
|     let tx = Transaction { |     let tx = Transaction { | ||||||
|         version: 0x01, |         version: 0x01, | ||||||
|         lock_time: PackedLockTime(0), |         lock_time: absolute::LockTime::ZERO, | ||||||
|         input: vec![TxIn { |         input: vec![TxIn { | ||||||
|             previous_output: OutPoint::null(), |             previous_output: OutPoint::null(), | ||||||
|             ..Default::default() |             ..Default::default() | ||||||
| @ -636,11 +636,11 @@ fn test_chain_spends() { | |||||||
|         output: vec![ |         output: vec![ | ||||||
|             TxOut { |             TxOut { | ||||||
|                 value: 10_000, |                 value: 10_000, | ||||||
|                 script_pubkey: Script::new(), |                 script_pubkey: ScriptBuf::new(), | ||||||
|             }, |             }, | ||||||
|             TxOut { |             TxOut { | ||||||
|                 value: 20_000, |                 value: 20_000, | ||||||
|                 script_pubkey: Script::new(), |                 script_pubkey: ScriptBuf::new(), | ||||||
|             }, |             }, | ||||||
|         ], |         ], | ||||||
|         ..common::new_tx(0) |         ..common::new_tx(0) | ||||||
| @ -655,11 +655,11 @@ fn test_chain_spends() { | |||||||
|         output: vec![ |         output: vec![ | ||||||
|             TxOut { |             TxOut { | ||||||
|                 value: 5_000, |                 value: 5_000, | ||||||
|                 script_pubkey: Script::new(), |                 script_pubkey: ScriptBuf::new(), | ||||||
|             }, |             }, | ||||||
|             TxOut { |             TxOut { | ||||||
|                 value: 5_000, |                 value: 5_000, | ||||||
|                 script_pubkey: Script::new(), |                 script_pubkey: ScriptBuf::new(), | ||||||
|             }, |             }, | ||||||
|         ], |         ], | ||||||
|         ..common::new_tx(0) |         ..common::new_tx(0) | ||||||
| @ -674,11 +674,11 @@ fn test_chain_spends() { | |||||||
|         output: vec![ |         output: vec![ | ||||||
|             TxOut { |             TxOut { | ||||||
|                 value: 10_000, |                 value: 10_000, | ||||||
|                 script_pubkey: Script::new(), |                 script_pubkey: ScriptBuf::new(), | ||||||
|             }, |             }, | ||||||
|             TxOut { |             TxOut { | ||||||
|                 value: 10_000, |                 value: 10_000, | ||||||
|                 script_pubkey: Script::new(), |                 script_pubkey: ScriptBuf::new(), | ||||||
|             }, |             }, | ||||||
|         ], |         ], | ||||||
|         ..common::new_tx(0) |         ..common::new_tx(0) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user