Skip to content

Commit 22ebcfe

Browse files
committed
refactor: Rename InputStatus to TxStatus
1 parent 0e4a4a6 commit 22ebcfe

File tree

3 files changed

+14
-18
lines changed

3 files changed

+14
-18
lines changed

examples/common.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::sync::Arc;
33
use bdk_bitcoind_rpc::Emitter;
44
use bdk_chain::{bdk_core, Anchor, Balance, ChainPosition, ConfirmationBlockTime};
55
use bdk_testenv::{bitcoincore_rpc::RpcApi, TestEnv};
6-
use bdk_tx::{CanonicalUnspents, Input, InputCandidates, InputStatus, RbfParams, TxWithStatus};
6+
use bdk_tx::{CanonicalUnspents, Input, InputCandidates, RbfParams, TxStatus, TxWithStatus};
77
use bitcoin::{absolute, Address, BlockHash, OutPoint, Transaction, Txid};
88
use miniscript::{
99
plan::{Assets, Plan},
@@ -106,11 +106,9 @@ impl Wallet {
106106
}
107107

108108
pub fn canonical_txs(&self) -> impl Iterator<Item = TxWithStatus<Arc<Transaction>>> + '_ {
109-
pub fn status_from_position(
110-
pos: ChainPosition<ConfirmationBlockTime>,
111-
) -> Option<InputStatus> {
109+
pub fn status_from_position(pos: ChainPosition<ConfirmationBlockTime>) -> Option<TxStatus> {
112110
match pos {
113-
bdk_chain::ChainPosition::Confirmed { anchor, .. } => Some(InputStatus {
111+
bdk_chain::ChainPosition::Confirmed { anchor, .. } => Some(TxStatus {
114112
height: absolute::Height::from_consensus(
115113
anchor.confirmation_height_upper_bound(),
116114
)
@@ -151,8 +149,6 @@ impl Wallet {
151149

152150
// Exclude txs that reside-in `rbf_set`.
153151
let rbf_set = canon_utxos.extract_replacements(replace)?;
154-
// TODO: We should really be returning an error if we fail to select an input of a tx we
155-
// are intending to replace.
156152
let must_select = rbf_set
157153
.must_select_largest_input_of_each_original_tx(&canon_utxos)?
158154
.into_iter()

src/canonical_unspents.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ use bitcoin::{psbt, OutPoint, Sequence, Transaction, TxOut, Txid};
66
use miniscript::{bitcoin, plan::Plan};
77

88
use crate::{
9-
collections::HashMap, input::CoinbaseMismatch, FromPsbtInputError, Input, InputStatus, RbfSet,
9+
collections::HashMap, input::CoinbaseMismatch, FromPsbtInputError, Input, RbfSet, TxStatus,
1010
};
1111

1212
/// Tx with confirmation status.
13-
pub type TxWithStatus<T> = (T, Option<InputStatus>);
13+
pub type TxWithStatus<T> = (T, Option<TxStatus>);
1414

1515
/// Our canonical view of unspent outputs.
1616
#[derive(Debug, Clone)]
1717
pub struct CanonicalUnspents {
1818
txs: HashMap<Txid, Arc<Transaction>>,
19-
statuses: HashMap<Txid, InputStatus>,
19+
statuses: HashMap<Txid, TxStatus>,
2020
spends: HashMap<OutPoint, Txid>,
2121
}
2222

src/input.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ use miniscript::bitcoin;
99
use miniscript::bitcoin::{OutPoint, Transaction, TxOut};
1010
use miniscript::plan::Plan;
1111

12-
/// Confirmation status of a tx input.
12+
/// Confirmation status of a tx data.
1313
#[derive(Debug, Clone, Copy)]
14-
pub struct InputStatus {
14+
pub struct TxStatus {
1515
/// Confirmation block height.
1616
pub height: absolute::Height,
1717
/// Confirmation block median time past.
@@ -21,7 +21,7 @@ pub struct InputStatus {
2121
pub time: absolute::Time,
2222
}
2323

24-
impl InputStatus {
24+
impl TxStatus {
2525
/// From consensus `height` and `time`.
2626
pub fn new(height: u32, time: u64) -> Result<Self, absolute::ConversionError> {
2727
Ok(Self {
@@ -190,7 +190,7 @@ pub struct Input {
190190
prev_txout: TxOut,
191191
prev_tx: Option<Arc<Transaction>>,
192192
plan: PlanOrPsbtInput,
193-
status: Option<InputStatus>,
193+
status: Option<TxStatus>,
194194
is_coinbase: bool,
195195
}
196196

@@ -205,7 +205,7 @@ impl Input {
205205
plan: Plan,
206206
prev_tx: T,
207207
output_index: usize,
208-
status: Option<InputStatus>,
208+
status: Option<TxStatus>,
209209
) -> Result<Self, OutputsIndexError>
210210
where
211211
T: Into<Arc<Transaction>>,
@@ -227,7 +227,7 @@ impl Input {
227227
plan: Plan,
228228
prev_outpoint: OutPoint,
229229
prev_txout: TxOut,
230-
status: Option<InputStatus>,
230+
status: Option<TxStatus>,
231231
is_coinbase: bool,
232232
) -> Self {
233233
Self {
@@ -253,7 +253,7 @@ impl Input {
253253
sequence: Sequence,
254254
psbt_input: psbt::Input,
255255
satisfaction_weight: usize,
256-
status: Option<InputStatus>,
256+
status: Option<TxStatus>,
257257
is_coinbase: bool,
258258
) -> Result<Self, FromPsbtInputError> {
259259
let outpoint = prev_outpoint;
@@ -331,7 +331,7 @@ impl Input {
331331
}
332332

333333
/// Confirmation status.
334-
pub fn status(&self) -> Option<InputStatus> {
334+
pub fn status(&self) -> Option<TxStatus> {
335335
self.status
336336
}
337337

0 commit comments

Comments
 (0)