Skip to content

Commit 8263289

Browse files
committed
refactor(bdk)!: rename LocalUtxo to LocalOutput
1 parent 46d39be commit 8263289

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

crates/bdk/src/types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl Vbytes for usize {
161161
///
162162
/// [`Wallet`]: crate::Wallet
163163
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash)]
164-
pub struct LocalUtxo {
164+
pub struct LocalOutput {
165165
/// Reference to a transaction output
166166
pub outpoint: OutPoint,
167167
/// Transaction output
@@ -192,7 +192,7 @@ pub struct WeightedUtxo {
192192
/// An unspent transaction output (UTXO).
193193
pub enum Utxo {
194194
/// A UTXO owned by the local wallet.
195-
Local(LocalUtxo),
195+
Local(LocalOutput),
196196
/// A UTXO owned by another wallet.
197197
Foreign {
198198
/// The location of the output.

crates/bdk/src/wallet/coin_selection.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ mod test {
755755
.unwrap();
756756
WeightedUtxo {
757757
satisfaction_weight: P2WPKH_SATISFACTION_SIZE,
758-
utxo: Utxo::Local(LocalUtxo {
758+
utxo: Utxo::Local(LocalOutput {
759759
outpoint,
760760
txout: TxOut {
761761
value,
@@ -815,7 +815,7 @@ mod test {
815815
for _ in 0..utxos_number {
816816
res.push(WeightedUtxo {
817817
satisfaction_weight: P2WPKH_SATISFACTION_SIZE,
818-
utxo: Utxo::Local(LocalUtxo {
818+
utxo: Utxo::Local(LocalOutput {
819819
outpoint: OutPoint::from_str(
820820
"ebd9813ecebc57ff8f30797de7c205e3c7498ca950ea4341ee51a685ff2fa30a:0",
821821
)
@@ -844,7 +844,7 @@ mod test {
844844
fn generate_same_value_utxos(utxos_value: u64, utxos_number: usize) -> Vec<WeightedUtxo> {
845845
let utxo = WeightedUtxo {
846846
satisfaction_weight: P2WPKH_SATISFACTION_SIZE,
847-
utxo: Utxo::Local(LocalUtxo {
847+
utxo: Utxo::Local(LocalOutput {
848848
outpoint: OutPoint::from_str(
849849
"ebd9813ecebc57ff8f30797de7c205e3c7498ca950ea4341ee51a685ff2fa30a:0",
850850
)

crates/bdk/src/wallet/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ impl<D> Wallet<D> {
737737
}
738738

739739
/// Return the list of unspent outputs of this wallet
740-
pub fn list_unspent(&self) -> impl Iterator<Item = LocalUtxo> + '_ {
740+
pub fn list_unspent(&self) -> impl Iterator<Item = LocalOutput> + '_ {
741741
self.indexed_graph
742742
.graph()
743743
.filter_chain_unspents(
@@ -786,7 +786,7 @@ impl<D> Wallet<D> {
786786

787787
/// Returns the utxo owned by this wallet corresponding to `outpoint` if it exists in the
788788
/// wallet's database.
789-
pub fn get_utxo(&self, op: OutPoint) -> Option<LocalUtxo> {
789+
pub fn get_utxo(&self, op: OutPoint) -> Option<LocalOutput> {
790790
let (&spk_i, _) = self.indexed_graph.index.txout(op)?;
791791
self.indexed_graph
792792
.graph()
@@ -1617,7 +1617,7 @@ impl<D> Wallet<D> {
16171617
.max_satisfaction_weight()
16181618
.unwrap();
16191619
WeightedUtxo {
1620-
utxo: Utxo::Local(LocalUtxo {
1620+
utxo: Utxo::Local(LocalOutput {
16211621
outpoint: txin.previous_output,
16221622
txout: txout.clone(),
16231623
keychain,
@@ -1944,7 +1944,7 @@ impl<D> Wallet<D> {
19441944
descriptor.at_derivation_index(child).ok()
19451945
}
19461946

1947-
fn get_available_utxos(&self) -> Vec<(LocalUtxo, usize)> {
1947+
fn get_available_utxos(&self) -> Vec<(LocalOutput, usize)> {
19481948
self.list_unspent()
19491949
.map(|utxo| {
19501950
let keychain = utxo.keychain;
@@ -2141,7 +2141,7 @@ impl<D> Wallet<D> {
21412141
/// get the corresponding PSBT Input for a LocalUtxo
21422142
pub fn get_psbt_input(
21432143
&self,
2144-
utxo: LocalUtxo,
2144+
utxo: LocalOutput,
21452145
sighash_type: Option<psbt::PsbtSighashType>,
21462146
only_witness_utxo: bool,
21472147
) -> Result<psbt::Input, CreateTxError<D::WriteError>>
@@ -2352,8 +2352,8 @@ fn new_local_utxo(
23522352
keychain: KeychainKind,
23532353
derivation_index: u32,
23542354
full_txo: FullTxOut<ConfirmationTimeHeightAnchor>,
2355-
) -> LocalUtxo {
2356-
LocalUtxo {
2355+
) -> LocalOutput {
2356+
LocalOutput {
23572357
outpoint: full_txo.outpoint,
23582358
txout: full_txo.txout,
23592359
is_spent: full_txo.spent_by.is_some(),

crates/bdk/src/wallet/tx_builder.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ use bitcoin::{absolute, script::PushBytes, OutPoint, ScriptBuf, Sequence, Transa
5353

5454
use super::coin_selection::{CoinSelectionAlgorithm, DefaultCoinSelectionAlgorithm};
5555
use super::ChangeSet;
56-
use crate::types::{FeeRate, KeychainKind, LocalUtxo, WeightedUtxo};
56+
use crate::types::{FeeRate, KeychainKind, LocalOutput, WeightedUtxo};
5757
use crate::wallet::CreateTxError;
5858
use crate::{Utxo, Wallet};
5959

@@ -889,7 +889,7 @@ impl Default for ChangeSpendPolicy {
889889
}
890890

891891
impl ChangeSpendPolicy {
892-
pub(crate) fn is_satisfied_by(&self, utxo: &LocalUtxo) -> bool {
892+
pub(crate) fn is_satisfied_by(&self, utxo: &LocalOutput) -> bool {
893893
match self {
894894
ChangeSpendPolicy::ChangeAllowed => true,
895895
ChangeSpendPolicy::OnlyChange => utxo.keychain == KeychainKind::Internal,
@@ -994,11 +994,11 @@ mod test {
994994
);
995995
}
996996

997-
fn get_test_utxos() -> Vec<LocalUtxo> {
997+
fn get_test_utxos() -> Vec<LocalOutput> {
998998
use bitcoin::hashes::Hash;
999999

10001000
vec![
1001-
LocalUtxo {
1001+
LocalOutput {
10021002
outpoint: OutPoint {
10031003
txid: bitcoin::Txid::from_slice(&[0; 32]).unwrap(),
10041004
vout: 0,
@@ -1009,7 +1009,7 @@ mod test {
10091009
confirmation_time: ConfirmationTime::Unconfirmed { last_seen: 0 },
10101010
derivation_index: 0,
10111011
},
1012-
LocalUtxo {
1012+
LocalOutput {
10131013
outpoint: OutPoint {
10141014
txid: bitcoin::Txid::from_slice(&[0; 32]).unwrap(),
10151015
vout: 1,

crates/bdk/tests/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![allow(unused)]
22

3-
use bdk::{wallet::AddressIndex, KeychainKind, LocalUtxo, Wallet};
3+
use bdk::{wallet::AddressIndex, KeychainKind, LocalOutput, Wallet};
44
use bdk_chain::indexed_tx_graph::Indexer;
55
use bdk_chain::{BlockId, ConfirmationTime};
66
use bitcoin::hashes::Hash;

0 commit comments

Comments
 (0)