Skip to content

Commit

Permalink
Add support for anchor output type
Browse files Browse the repository at this point in the history
  • Loading branch information
mononaut committed Aug 30, 2024
1 parent bffba5a commit 570071a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/rest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ impl TxOutValue {
"v0_p2wsh"
} else if is_v1_p2tr(script) {
"v1_p2tr"
} else if is_anchor(script) {
"anchor"
} else if script.is_provably_unspendable() {
"provably_unspendable"
} else if is_bare_multisig(script) {
Expand Down Expand Up @@ -405,6 +407,15 @@ fn is_bare_multisig(script: &Script) -> bool {
&& script[0] <= script[len - 2]
}

fn is_anchor(script: &Script) -> bool {
let len = script.len();
len == 4
&& script[0] == opcodes::all::OP_PUSHNUM_1.into_u8()
&& script[1] == opcodes::all::OP_PUSHBYTES_2.into_u8()
&& script[2] == 0x4e
&& script[3] == 0x73
}

#[derive(Serialize)]
struct UtxoValue {
txid: Txid,
Expand Down

0 comments on commit 570071a

Please sign in to comment.