///
/// [`Wallet`]: crate::Wallet
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash)]
-pub struct LocalUtxo {
+pub struct LocalOutput {
/// Reference to a transaction output
pub outpoint: OutPoint,
/// Transaction output
/// An unspent transaction output (UTXO).
pub enum Utxo {
/// A UTXO owned by the local wallet.
- Local(LocalUtxo),
+ Local(LocalOutput),
/// A UTXO owned by another wallet.
Foreign {
/// The location of the output.
.unwrap();
WeightedUtxo {
satisfaction_weight: P2WPKH_SATISFACTION_SIZE,
- utxo: Utxo::Local(LocalUtxo {
+ utxo: Utxo::Local(LocalOutput {
outpoint,
txout: TxOut {
value,
for _ in 0..utxos_number {
res.push(WeightedUtxo {
satisfaction_weight: P2WPKH_SATISFACTION_SIZE,
- utxo: Utxo::Local(LocalUtxo {
+ utxo: Utxo::Local(LocalOutput {
outpoint: OutPoint::from_str(
"ebd9813ecebc57ff8f30797de7c205e3c7498ca950ea4341ee51a685ff2fa30a:0",
)
fn generate_same_value_utxos(utxos_value: u64, utxos_number: usize) -> Vec<WeightedUtxo> {
let utxo = WeightedUtxo {
satisfaction_weight: P2WPKH_SATISFACTION_SIZE,
- utxo: Utxo::Local(LocalUtxo {
+ utxo: Utxo::Local(LocalOutput {
outpoint: OutPoint::from_str(
"ebd9813ecebc57ff8f30797de7c205e3c7498ca950ea4341ee51a685ff2fa30a:0",
)
}
/// Return the list of unspent outputs of this wallet
- pub fn list_unspent(&self) -> impl Iterator<Item = LocalUtxo> + '_ {
+ pub fn list_unspent(&self) -> impl Iterator<Item = LocalOutput> + '_ {
self.indexed_graph
.graph()
.filter_chain_unspents(
/// Returns the utxo owned by this wallet corresponding to `outpoint` if it exists in the
/// wallet's database.
- pub fn get_utxo(&self, op: OutPoint) -> Option<LocalUtxo> {
+ pub fn get_utxo(&self, op: OutPoint) -> Option<LocalOutput> {
let (&spk_i, _) = self.indexed_graph.index.txout(op)?;
self.indexed_graph
.graph()
.max_satisfaction_weight()
.unwrap();
WeightedUtxo {
- utxo: Utxo::Local(LocalUtxo {
+ utxo: Utxo::Local(LocalOutput {
outpoint: txin.previous_output,
txout: txout.clone(),
keychain,
descriptor.at_derivation_index(child).ok()
}
- fn get_available_utxos(&self) -> Vec<(LocalUtxo, usize)> {
+ fn get_available_utxos(&self) -> Vec<(LocalOutput, usize)> {
self.list_unspent()
.map(|utxo| {
let keychain = utxo.keychain;
/// get the corresponding PSBT Input for a LocalUtxo
pub fn get_psbt_input(
&self,
- utxo: LocalUtxo,
+ utxo: LocalOutput,
sighash_type: Option<psbt::PsbtSighashType>,
only_witness_utxo: bool,
) -> Result<psbt::Input, CreateTxError<D::WriteError>>
keychain: KeychainKind,
derivation_index: u32,
full_txo: FullTxOut<ConfirmationTimeHeightAnchor>,
-) -> LocalUtxo {
- LocalUtxo {
+) -> LocalOutput {
+ LocalOutput {
outpoint: full_txo.outpoint,
txout: full_txo.txout,
is_spent: full_txo.spent_by.is_some(),
use super::coin_selection::{CoinSelectionAlgorithm, DefaultCoinSelectionAlgorithm};
use super::ChangeSet;
-use crate::types::{FeeRate, KeychainKind, LocalUtxo, WeightedUtxo};
+use crate::types::{FeeRate, KeychainKind, LocalOutput, WeightedUtxo};
use crate::wallet::CreateTxError;
use crate::{Utxo, Wallet};
}
impl ChangeSpendPolicy {
- pub(crate) fn is_satisfied_by(&self, utxo: &LocalUtxo) -> bool {
+ pub(crate) fn is_satisfied_by(&self, utxo: &LocalOutput) -> bool {
match self {
ChangeSpendPolicy::ChangeAllowed => true,
ChangeSpendPolicy::OnlyChange => utxo.keychain == KeychainKind::Internal,
);
}
- fn get_test_utxos() -> Vec<LocalUtxo> {
+ fn get_test_utxos() -> Vec<LocalOutput> {
use bitcoin::hashes::Hash;
vec![
- LocalUtxo {
+ LocalOutput {
outpoint: OutPoint {
txid: bitcoin::Txid::from_slice(&[0; 32]).unwrap(),
vout: 0,
confirmation_time: ConfirmationTime::Unconfirmed { last_seen: 0 },
derivation_index: 0,
},
- LocalUtxo {
+ LocalOutput {
outpoint: OutPoint {
txid: bitcoin::Txid::from_slice(&[0; 32]).unwrap(),
vout: 1,
#![allow(unused)]
-use bdk::{wallet::AddressIndex, KeychainKind, LocalUtxo, Wallet};
+use bdk::{wallet::AddressIndex, KeychainKind, LocalOutput, Wallet};
use bdk_chain::indexed_tx_graph::Indexer;
use bdk_chain::{BlockId, ConfirmationTime};
use bitcoin::hashes::Hash;