Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/synopsis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ fn main() -> anyhow::Result<()> {
// For waste optimization when deciding change.
change_longterm_feerate: Some(longterm_feerate),
change_min_value: None,
change_dust_relay_feerate: None,
dust_relay_feerate: None,
// This ensures that we satisfy mempool-replacement policy rules 4 and 6.
replace: Some(rbf_params),
},
Expand Down
21 changes: 21 additions & 0 deletions src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,27 @@ impl Input {
pub fn is_segwit(&self) -> bool {
self.plan.is_segwit()
}

/// Returns the number of witness stack items, if witness data is present.
///
/// Returns `None` if this input has no witness data yet (e.g. an unsigned plan-based input).
pub fn witness_item_count(&self) -> Option<usize> {
// Finalized
if let Some(psbt_input) = self.psbt_input() {
if let Some(witness) = &psbt_input.final_script_witness {
return Some(witness.len());
}
}

// Unfinalized
if let Some(plan) = self.plan() {
if plan.witness_version().is_some() {
return Some(plan.witness_template().len());
}
}

None
}
}

/// Input group. Cannot be empty.
Expand Down
4 changes: 4 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ mod finalizer;
mod input;
mod input_candidates;
mod output;
mod policy;
mod rbf;
mod selection;
mod selector;
mod signer;
#[cfg(test)]
pub(crate) mod test_utils;
mod utils;

pub use canonical_unspents::*;
Expand All @@ -27,6 +30,7 @@ pub use miniscript;
pub use miniscript::bitcoin;
use miniscript::{DefiniteDescriptorKey, Descriptor};
pub use output::*;
pub use policy::*;
pub use rbf::*;
pub use selection::*;
pub use selector::*;
Expand Down
Loading