avoid special code path, add explicit fixture overwrite
This commit is contained in:
parent
f84a5d18a3
commit
d06c149ec3
2 changed files with 9 additions and 24 deletions
7
test/fixtures/transaction_builder.json
vendored
7
test/fixtures/transaction_builder.json
vendored
|
@ -1491,7 +1491,7 @@
|
||||||
],
|
],
|
||||||
"fromTransaction": [
|
"fromTransaction": [
|
||||||
{
|
{
|
||||||
"description": "Transaction w/ P2SH(P2MS 2/2) -> OP_RETURN | 1 OP_0, no signatures",
|
"description": "Transaction w/ P2SH(P2MS 2/2) -> OP_RETURN | 1 OP_0 fixes to 2 OP_0, no signatures",
|
||||||
"network": "testnet",
|
"network": "testnet",
|
||||||
"incomplete": true,
|
"incomplete": true,
|
||||||
"inputs": [
|
"inputs": [
|
||||||
|
@ -1785,11 +1785,10 @@
|
||||||
"scriptSig": "OP_0 OP_0 OP_0 3045022100a346c61738304eac5e7702188764d19cdf68f4466196729db096d6c87ce18cdd022018c0e8ad03054b0e7e235cda6bedecf35881d7aa7d94ff425a8ace7220f38af001 52410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b84104c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a4104f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e67253ae"
|
"scriptSig": "OP_0 OP_0 OP_0 3045022100a346c61738304eac5e7702188764d19cdf68f4466196729db096d6c87ce18cdd022018c0e8ad03054b0e7e235cda6bedecf35881d7aa7d94ff425a8ace7220f38af001 52410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b84104c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a4104f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e67253ae"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"filterOP_0": true,
|
|
||||||
"pubKeyIndex": 0,
|
"pubKeyIndex": 0,
|
||||||
"keyPair": "91avARGdfge8E4tZfYLoxeJ5sGBdNJQH4kvjJoQFacbgwmaKkrx",
|
"keyPair": "91avARGdfge8E4tZfYLoxeJ5sGBdNJQH4kvjJoQFacbgwmaKkrx",
|
||||||
"scriptSig": "OP_0 3045022100daf0f4f3339d9fbab42b098045c1e4958ee3b308f4ae17be80b63808558d0adb02202f07e3d1f79dc8da285ae0d7f68083d769c11f5621ebd9691d6b48c0d4283d7d01 OP_0 3045022100a346c61738304eac5e7702188764d19cdf68f4466196729db096d6c87ce18cdd022018c0e8ad03054b0e7e235cda6bedecf35881d7aa7d94ff425a8ace7220f38af001 52410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b84104c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a4104f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e67253ae",
|
"scriptSigBefore": "OP_0 3045022100a346c61738304eac5e7702188764d19cdf68f4466196729db096d6c87ce18cdd022018c0e8ad03054b0e7e235cda6bedecf35881d7aa7d94ff425a8ace7220f38af001 52410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b84104c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a4104f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e67253ae",
|
||||||
"scriptSigFiltered": "OP_0 3045022100a346c61738304eac5e7702188764d19cdf68f4466196729db096d6c87ce18cdd022018c0e8ad03054b0e7e235cda6bedecf35881d7aa7d94ff425a8ace7220f38af001 52410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b84104c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a4104f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e67253ae"
|
"scriptSig": "OP_0 3045022100daf0f4f3339d9fbab42b098045c1e4958ee3b308f4ae17be80b63808558d0adb02202f07e3d1f79dc8da285ae0d7f68083d769c11f5621ebd9691d6b48c0d4283d7d01 OP_0 3045022100a346c61738304eac5e7702188764d19cdf68f4466196729db096d6c87ce18cdd022018c0e8ad03054b0e7e235cda6bedecf35881d7aa7d94ff425a8ace7220f38af001 52410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b84104c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a4104f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e67253ae"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -463,27 +463,12 @@ describe('TransactionBuilder', function () {
|
||||||
input.signs.forEach(function (sign) {
|
input.signs.forEach(function (sign) {
|
||||||
// rebuild the transaction each-time after the first
|
// rebuild the transaction each-time after the first
|
||||||
if (tx) {
|
if (tx) {
|
||||||
// do we filter OP_0's beforehand?
|
// manually override the scriptSig?
|
||||||
if (sign.filterOP_0) {
|
if (sign.scriptSigBefore) {
|
||||||
const scriptSig = tx.ins[i].script
|
tx.ins[i].script = bscript.fromASM(sign.scriptSigBefore)
|
||||||
|
|
||||||
// ignore OP_0 on the front, ignore redeemScript
|
|
||||||
const signatures = bscript.decompile(scriptSig)
|
|
||||||
.slice(1, -1)
|
|
||||||
.filter(x => x !== ops.OP_0)
|
|
||||||
|
|
||||||
// rebuild/replace the scriptSig without them
|
|
||||||
const replacement = payments.p2sh({
|
|
||||||
redeem: payments.p2ms({
|
|
||||||
output: redeemScript,
|
|
||||||
signatures
|
|
||||||
}, { allowIncomplete: true, validate: false })
|
|
||||||
}).input
|
|
||||||
assert.strictEqual(bscript.toASM(replacement), sign.scriptSigFiltered)
|
|
||||||
|
|
||||||
tx.ins[i].script = replacement
|
|
||||||
}
|
}
|
||||||
// now import it
|
|
||||||
|
// rebuild
|
||||||
txb = TransactionBuilder.fromTransaction(tx, network)
|
txb = TransactionBuilder.fromTransaction(tx, network)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -492,6 +477,7 @@ describe('TransactionBuilder', function () {
|
||||||
|
|
||||||
// update the tx
|
// update the tx
|
||||||
tx = txb.buildIncomplete()
|
tx = txb.buildIncomplete()
|
||||||
|
|
||||||
// now verify the serialized scriptSig is as expected
|
// now verify the serialized scriptSig is as expected
|
||||||
assert.strictEqual(bscript.toASM(tx.ins[i].script), sign.scriptSig)
|
assert.strictEqual(bscript.toASM(tx.ins[i].script), sign.scriptSig)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Reference in a new issue