let weighted_utxo = match txout_index.index_of_spk(&txout.script_pubkey) {
Some(&(keychain, derivation_index)) => {
let satisfaction_weight = self
- .get_descriptor_for_keychain(keychain)
+ .public_descriptor(keychain)
.max_weight_to_satisfy()
.unwrap();
WeightedUtxo {
)
}
- /// Return the "public" version of the wallet's descriptor, meaning a new descriptor that has
- /// the same structure but with every secret key removed
+ /// Returns the descriptor used to create addresses for a particular `keychain`.
+ /// It's the "public" version of the wallet's descriptor, meaning a new descriptor that has
+ /// the same structure but with the all secret keys replaced by their corresponding public key.
///
- /// This can be used to build a watch-only version of a wallet
+ /// This can be used to build a watch-only version of a wallet.
pub fn public_descriptor(&self, keychain: KeychainKind) -> &ExtendedDescriptor {
self.indexed_graph
.index
- .keychains()
- .find(|(k, _)| *k == &keychain)
- .map(|(_, d)| d)
+ .get_descriptor(&keychain)
.expect("keychain must exist")
}
&self.secp
}
- /// Returns the descriptor used to create addresses for a particular `keychain`.
- pub fn get_descriptor_for_keychain(&self, keychain: KeychainKind) -> &ExtendedDescriptor {
- self.public_descriptor(keychain)
- }
-
/// The derivation index of this wallet. It will return `None` if it has not derived any addresses.
/// Otherwise, it will return the index of the highest address it has derived.
pub fn derivation_index(&self, keychain: KeychainKind) -> Option<u32> {
.indexed_graph
.index
.index_of_spk(&txout.script_pubkey)?;
- let descriptor = self.get_descriptor_for_keychain(keychain);
+ let descriptor = self.public_descriptor(keychain);
descriptor.at_derivation_index(child).ok()
}
.map(|utxo| {
let keychain = utxo.keychain;
(utxo, {
- self.get_descriptor_for_keychain(keychain)
+ self.public_descriptor(keychain)
.max_weight_to_satisfy()
.unwrap()
})
..psbt::Input::default()
};
- let desc = self.get_descriptor_for_keychain(keychain);
+ let desc = self.public_descriptor(keychain);
let derived_descriptor = desc
.at_derivation_index(child)
.expect("child can't be hardened");
if let Some(&(keychain, child)) =
self.indexed_graph.index.index_of_spk(&out.script_pubkey)
{
- let desc = self.get_descriptor_for_keychain(keychain);
+ let desc = self.public_descriptor(keychain);
let desc = desc
.at_derivation_index(child)
.expect("child can't be hardened");
/// Return the checksum of the public descriptor associated to `keychain`
///
- /// Internally calls [`Self::get_descriptor_for_keychain`] to fetch the right descriptor
+ /// Internally calls [`Self::public_descriptor`] to fetch the right descriptor
pub fn descriptor_checksum(&self, keychain: KeychainKind) -> String {
- self.get_descriptor_for_keychain(keychain)
+ self.public_descriptor(keychain)
.to_string()
.split_once('#')
.unwrap()
);
let secp = Secp256k1::new();
assert_eq!(
- *wallet.get_descriptor_for_keychain(KeychainKind::External),
+ *wallet.public_descriptor(KeychainKind::External),
desc.into_wallet_descriptor(&secp, wallet.network())
.unwrap()
.0
.assume_checked();
let utxo = wallet2.list_unspent().next().expect("must take!");
let foreign_utxo_satisfaction = wallet2
- .get_descriptor_for_keychain(KeychainKind::External)
+ .public_descriptor(KeychainKind::External)
.max_weight_to_satisfy()
.unwrap();
.assume_checked();
let utxo = wallet2.list_unspent().next().expect("must take!");
let foreign_utxo_satisfaction = wallet2
- .get_descriptor_for_keychain(KeychainKind::External)
+ .public_descriptor(KeychainKind::External)
.max_weight_to_satisfy()
.unwrap();
let (mut wallet, _) = get_funded_wallet_wpkh();
let outpoint = wallet.list_unspent().next().expect("must exist").outpoint;
let foreign_utxo_satisfaction = wallet
- .get_descriptor_for_keychain(KeychainKind::External)
+ .public_descriptor(KeychainKind::External)
.max_weight_to_satisfy()
.unwrap();
let tx2 = wallet2.get_tx(txid2).unwrap().tx_node.tx.clone();
let satisfaction_weight = wallet2
- .get_descriptor_for_keychain(KeychainKind::External)
+ .public_descriptor(KeychainKind::External)
.max_weight_to_satisfy()
.unwrap();
let utxo2 = wallet2.list_unspent().next().unwrap();
let satisfaction_weight = wallet2
- .get_descriptor_for_keychain(KeychainKind::External)
+ .public_descriptor(KeychainKind::External)
.max_weight_to_satisfy()
.unwrap();
let utxo = wallet2.list_unspent().next().unwrap();
let psbt_input = wallet2.get_psbt_input(utxo.clone(), None, false).unwrap();
let foreign_utxo_satisfaction = wallet2
- .get_descriptor_for_keychain(KeychainKind::External)
+ .public_descriptor(KeychainKind::External)
.max_weight_to_satisfy()
.unwrap();