Skip to content

Commit

Permalink
common: is_provably_segwit: improve doc
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoComandini committed Oct 17, 2024
1 parent 8c6f8fd commit 4000669
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lwk_common/src/segwit.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use elements_miniscript::elements::Script;

/// Determine if a transaction input is provably segwit
pub fn is_provably_segwit(prevout_scriptpubkey: &Script, redeem_script: &Option<Script>) -> bool {
if prevout_scriptpubkey.is_witness_program() {
/// Whether a script pubkey is provably segwit
///
/// The redeem script is necessary for P2SH wrapped scripts.
pub fn is_provably_segwit(scriptpubkey: &Script, redeem_script: &Option<Script>) -> bool {
if scriptpubkey.is_witness_program() {
// Native Segwit
return true;
}
if prevout_scriptpubkey.is_p2sh() {
if scriptpubkey.is_p2sh() {
if let Some(redeem_script) = redeem_script {
if redeem_script.is_witness_program()
&& &redeem_script.to_p2sh() == prevout_scriptpubkey
{
if redeem_script.is_witness_program() && &redeem_script.to_p2sh() == scriptpubkey {
// Segwit Wrapped
return true;
}
Expand Down

0 comments on commit 4000669

Please sign in to comment.