Skip to content

Commit

Permalink
and_n syntactic sugar was not being properly parsed
Browse files Browse the repository at this point in the history
  • Loading branch information
landabaso committed Feb 1, 2023
1 parent a12cdc8 commit 421e618
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"descriptors"
],
"homepage": "https://bitcoinerlab.com/modules/miniscript",
"version": "1.1.0",
"version": "1.1.1",
"description": "Bitcoin Miniscript, a high-level language for describing Bitcoin spending conditions. It includes a Policy and Miniscript compiler, as well as a novel Satisfier for generating expressive witness scripts.",
"main": "dist/index.js",
"types": "types/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/satisfier/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ const evaluate = miniscript => {
.replace(/^pk\(/, 'c:pk_k(')
.replace(/^pkh\(/, 'c:pk_h(')
.replace(/^and_n\(.*\)/, match =>
match.replace('and_n', 'andor').replace(')', ',0)')
match.replace('and_n', 'andor').replace(/\)$/, ',0)')
)
.replace(/^t:(.*)/, match => match.replace('t:', 'and_v(') + ',1)')
.replace(/^l:(.*)/, match => match.replace('l:', 'or_i(0,') + ')')
Expand Down
13 changes: 12 additions & 1 deletion test/fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -825,5 +825,16 @@ export const other = {
}
],
malleableSats: []
}
},
'thresh(1,pkh(@0),a:and_n(multi(1,@1,@2),n:older(2)))': {
miniscript: 'thresh(1,pkh(@0),a:and_n(multi(1,@1,@2),n:older(2)))',
script:
'OP_DUP OP_HASH160 <HASH160(@0)> OP_EQUALVERIFY OP_CHECKSIG OP_TOALTSTACK 1 <@1> <@2> 2 OP_CHECKMULTISIG OP_NOTIF 0 OP_ELSE 2 OP_CHECKSEQUENCEVERIFY OP_0NOTEQUAL OP_ENDIF OP_FROMALTSTACK OP_ADD 1 OP_EQUAL',
nonMalleableSats: [
{ asm: '0 0 <sig(@0)> <@0>' },
{ asm: '0 <sig(@1)> 0 <@0>', nSequence: 2 },
{ asm: '0 <sig(@2)> 0 <@0>', nSequence: 2 }
],
malleableSats: []
}
};

0 comments on commit 421e618

Please sign in to comment.