tests: move inconsistent hashType/redeemScript test
This commit is contained in:
parent
ebbe1278a0
commit
1fde0a401d
2 changed files with 174 additions and 126 deletions
222
test/fixtures/transaction_builder.json
vendored
222
test/fixtures/transaction_builder.json
vendored
|
@ -8,8 +8,10 @@
|
||||||
{
|
{
|
||||||
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
||||||
"vout": 0,
|
"vout": 0,
|
||||||
"privKeys": [
|
"signs": [
|
||||||
"KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn"
|
{
|
||||||
|
"privKey": "KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -28,8 +30,10 @@
|
||||||
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
||||||
"vout": 0,
|
"vout": 0,
|
||||||
"prevTxScript": "0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 OP_CHECKSIG",
|
"prevTxScript": "0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 OP_CHECKSIG",
|
||||||
"privKeys": [
|
"signs": [
|
||||||
"KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn"
|
{
|
||||||
|
"privKey": "KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -47,11 +51,15 @@
|
||||||
{
|
{
|
||||||
"txId": "4971f016798a167331bcbc67248313fbc444c6e92e4416efd06964425588f5cf",
|
"txId": "4971f016798a167331bcbc67248313fbc444c6e92e4416efd06964425588f5cf",
|
||||||
"vout": 0,
|
"vout": 0,
|
||||||
"privKeys": [
|
"signs": [
|
||||||
"91avARGdfge8E4tZfYLoxeJ5sGBdNJQH4kvjJoQFacbgwmaKkrx",
|
{
|
||||||
"91avARGdfge8E4tZfYLoxeJ5sGBdNJQH4kvjJoQFacbgww7vXtT"
|
"privKey": "91avARGdfge8E4tZfYLoxeJ5sGBdNJQH4kvjJoQFacbgwmaKkrx",
|
||||||
],
|
"redeemScript": "OP_2 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a OP_2 OP_CHECKMULTISIG"
|
||||||
"redeemScript": "OP_2 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a OP_2 OP_CHECKMULTISIG"
|
},
|
||||||
|
{
|
||||||
|
"privKey": "91avARGdfge8E4tZfYLoxeJ5sGBdNJQH4kvjJoQFacbgww7vXtT"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outputs": [
|
"outputs": [
|
||||||
|
@ -69,9 +77,13 @@
|
||||||
"txId": "4971f016798a167331bcbc67248313fbc444c6e92e4416efd06964425588f5cf",
|
"txId": "4971f016798a167331bcbc67248313fbc444c6e92e4416efd06964425588f5cf",
|
||||||
"vout": 0,
|
"vout": 0,
|
||||||
"prevTxScript": "OP_2 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a OP_2 OP_CHECKMULTISIG",
|
"prevTxScript": "OP_2 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a OP_2 OP_CHECKMULTISIG",
|
||||||
"privKeys": [
|
"signs": [
|
||||||
"91avARGdfge8E4tZfYLoxeJ5sGBdNJQH4kvjJoQFacbgwmaKkrx",
|
{
|
||||||
"91avARGdfge8E4tZfYLoxeJ5sGBdNJQH4kvjJoQFacbgww7vXtT"
|
"privKey": "91avARGdfge8E4tZfYLoxeJ5sGBdNJQH4kvjJoQFacbgwmaKkrx"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"privKey": "91avARGdfge8E4tZfYLoxeJ5sGBdNJQH4kvjJoQFacbgww7vXtT"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -90,10 +102,12 @@
|
||||||
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
||||||
"vout": 0,
|
"vout": 0,
|
||||||
"prevTxScript": "OP_HASH160 e89677d91455e541630d62c63718bef738b478b1 OP_EQUAL",
|
"prevTxScript": "OP_HASH160 e89677d91455e541630d62c63718bef738b478b1 OP_EQUAL",
|
||||||
"privKeys": [
|
"signs": [
|
||||||
"KxLDMPtVM7sLSu2v5n1LybDibw6P9FFbL4pUwJ51UDm7rp5AmXWW"
|
{
|
||||||
],
|
"privKey": "KxLDMPtVM7sLSu2v5n1LybDibw6P9FFbL4pUwJ51UDm7rp5AmXWW",
|
||||||
"redeemScript": "033e29aea1168a835d5e386c292082db7b7807172a10ec634ad34226f36d79e70f OP_CHECKSIG"
|
"redeemScript": "033e29aea1168a835d5e386c292082db7b7807172a10ec634ad34226f36d79e70f OP_CHECKSIG"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outputs": [
|
"outputs": [
|
||||||
|
@ -110,8 +124,10 @@
|
||||||
{
|
{
|
||||||
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
||||||
"vout": 1,
|
"vout": 1,
|
||||||
"privKeys": [
|
"signs": [
|
||||||
"KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn"
|
{
|
||||||
|
"privKey": "KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -132,8 +148,10 @@
|
||||||
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
||||||
"vout": 2,
|
"vout": 2,
|
||||||
"sequence": 2147001,
|
"sequence": 2147001,
|
||||||
"privKeys": [
|
"signs": [
|
||||||
"KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn"
|
{
|
||||||
|
"privKey": "KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -164,7 +182,7 @@
|
||||||
{
|
{
|
||||||
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
||||||
"vout": 0,
|
"vout": 0,
|
||||||
"privKeys": []
|
"signs": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outputs": []
|
"outputs": []
|
||||||
|
@ -176,7 +194,7 @@
|
||||||
{
|
{
|
||||||
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
||||||
"vout": 0,
|
"vout": 0,
|
||||||
"privKeys": []
|
"signs": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outputs": [
|
"outputs": [
|
||||||
|
@ -194,15 +212,17 @@
|
||||||
{
|
{
|
||||||
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
||||||
"vout": 0,
|
"vout": 0,
|
||||||
"privKeys": [
|
"signs": [
|
||||||
"KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn"
|
{
|
||||||
|
"privKey": "KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
||||||
"vout": 1,
|
"vout": 1,
|
||||||
"prevTxScript": "OP_DUP OP_HASH160 aa4d7985c57e011a8b3dd8e0e5a73aaef41629c5 OP_EQUALVERIFY OP_CHECKSIG",
|
"prevTxScript": "OP_DUP OP_HASH160 aa4d7985c57e011a8b3dd8e0e5a73aaef41629c5 OP_EQUALVERIFY OP_CHECKSIG",
|
||||||
"privKeys": []
|
"signs": []
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outputs": [
|
"outputs": [
|
||||||
|
@ -225,11 +245,15 @@
|
||||||
{
|
{
|
||||||
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
||||||
"vout": 1,
|
"vout": 1,
|
||||||
"privKeys": [
|
"signs": [
|
||||||
"KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn",
|
{
|
||||||
"KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn"
|
"privKey": "KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn"
|
||||||
],
|
},
|
||||||
"throws": 1
|
{
|
||||||
|
"privKey": "KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn",
|
||||||
|
"throws": true
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outputs": [
|
"outputs": [
|
||||||
|
@ -245,11 +269,13 @@
|
||||||
{
|
{
|
||||||
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
||||||
"vout": 1,
|
"vout": 1,
|
||||||
"privKeys": [
|
"signs": [
|
||||||
"KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn"
|
{
|
||||||
],
|
"privKey": "KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn",
|
||||||
"redeemScript": "OP_RETURN 06deadbeef03f895a2ad89fb6d696497af486cb7c644a27aa568c7a18dd06113401115185474",
|
"redeemScript": "OP_RETURN 06deadbeef03f895a2ad89fb6d696497af486cb7c644a27aa568c7a18dd06113401115185474",
|
||||||
"throws": 0
|
"throws": true
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outputs": [
|
"outputs": [
|
||||||
|
@ -266,10 +292,65 @@
|
||||||
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
||||||
"vout": 1,
|
"vout": 1,
|
||||||
"prevTxScript": "OP_HASH160 7f67f0521934a57d3039f77f9f32cf313f3ac74b OP_EQUAL",
|
"prevTxScript": "OP_HASH160 7f67f0521934a57d3039f77f9f32cf313f3ac74b OP_EQUAL",
|
||||||
"privKeys": [
|
"signs": [
|
||||||
"KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn"
|
{
|
||||||
],
|
"privKey": "KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn",
|
||||||
"throws": 0
|
"throws": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"script": "OP_DUP OP_HASH160 aa4d7985c57e011a8b3dd8e0e5a73aaef41629c5 OP_EQUALVERIFY OP_CHECKSIG",
|
||||||
|
"value": 1000
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"exception": "Inconsistent redeemScript",
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
||||||
|
"vout": 0,
|
||||||
|
"signs": [
|
||||||
|
{
|
||||||
|
"redeemScript": "OP_2 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a OP_2 OP_CHECKMULTISIG",
|
||||||
|
"privKey": "KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"redeemScript": "OP_1 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a OP_2 OP_CHECKMULTISIG",
|
||||||
|
"privKey": "KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn",
|
||||||
|
"throws": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"script": "OP_DUP OP_HASH160 aa4d7985c57e011a8b3dd8e0e5a73aaef41629c5 OP_EQUALVERIFY OP_CHECKSIG",
|
||||||
|
"value": 1000
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"exception": "Inconsistent hashType",
|
||||||
|
"inputs": [
|
||||||
|
{
|
||||||
|
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
||||||
|
"vout": 0,
|
||||||
|
"signs": [
|
||||||
|
{
|
||||||
|
"redeemScript": "OP_2 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 04c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee51ae168fea63dc339a3c58419466ceaeef7f632653266d0e1236431a950cfe52a OP_2 OP_CHECKMULTISIG",
|
||||||
|
"privKey": "KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn",
|
||||||
|
"hashType": 4
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"privKey": "KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn",
|
||||||
|
"hashType": 2,
|
||||||
|
"throws": true
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outputs": [
|
"outputs": [
|
||||||
|
@ -285,11 +366,13 @@
|
||||||
{
|
{
|
||||||
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
||||||
"vout": 1,
|
"vout": 1,
|
||||||
"privKeys": [
|
"signs": [
|
||||||
"KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn"
|
{
|
||||||
],
|
"privKey": "KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn",
|
||||||
"redeemScript": "OP_HASH160 7f67f0521934a57d3039f77f9f32cf313f3ac74b OP_EQUAL",
|
"redeemScript": "OP_HASH160 7f67f0521934a57d3039f77f9f32cf313f3ac74b OP_EQUAL",
|
||||||
"throws": 0
|
"throws": true
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outputs": [
|
"outputs": [
|
||||||
|
@ -306,11 +389,13 @@
|
||||||
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
||||||
"vout": 1,
|
"vout": 1,
|
||||||
"prevTxScript": "OP_DUP OP_HASH160 aa4d7985c57e011a8b3dd8e0e5a73aaef41629c5 OP_EQUALVERIFY OP_CHECKSIG",
|
"prevTxScript": "OP_DUP OP_HASH160 aa4d7985c57e011a8b3dd8e0e5a73aaef41629c5 OP_EQUALVERIFY OP_CHECKSIG",
|
||||||
"privKeys": [
|
"signs": [
|
||||||
"KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn"
|
{
|
||||||
],
|
"privKey": "KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn",
|
||||||
"redeemScript": "OP_1 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 OP_1 OP_CHECKMULTISIG",
|
"redeemScript": "OP_1 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 OP_1 OP_CHECKMULTISIG",
|
||||||
"throws": 0
|
"throws": true
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outputs": [
|
"outputs": [
|
||||||
|
@ -326,12 +411,17 @@
|
||||||
{
|
{
|
||||||
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
||||||
"vout": 1,
|
"vout": 1,
|
||||||
"privKeys": [
|
"signs": [
|
||||||
"KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn",
|
{
|
||||||
"KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn"
|
"privKey": "KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn",
|
||||||
],
|
"redeemScript": "OP_1 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 OP_1 OP_CHECKMULTISIG"
|
||||||
"redeemScript": "OP_1 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 OP_1 OP_CHECKMULTISIG",
|
},
|
||||||
"throws": 1
|
{
|
||||||
|
"privKey": "KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn",
|
||||||
|
"redeemScript": "OP_1 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 OP_1 OP_CHECKMULTISIG",
|
||||||
|
"throws": true
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outputs": [
|
"outputs": [
|
||||||
|
@ -348,11 +438,13 @@
|
||||||
{
|
{
|
||||||
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
||||||
"vout": 1,
|
"vout": 1,
|
||||||
"privKeys": [
|
"signs": [
|
||||||
"KzrA86mCVMGWnLGBQu9yzQa32qbxb5dvSK4XhyjjGAWSBKYX4rHx"
|
{
|
||||||
],
|
"privKey": "KzrA86mCVMGWnLGBQu9yzQa32qbxb5dvSK4XhyjjGAWSBKYX4rHx",
|
||||||
"redeemScript": "OP_1 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 OP_1 OP_CHECKMULTISIG",
|
"redeemScript": "OP_1 0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 OP_1 OP_CHECKMULTISIG",
|
||||||
"throws": 0
|
"throws": true
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outputs": [
|
"outputs": [
|
||||||
|
@ -369,10 +461,12 @@
|
||||||
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
"txId": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
||||||
"vout": 0,
|
"vout": 0,
|
||||||
"prevTxScript": "OP_RETURN 06deadbeef03f895a2ad89fb6d696497af486cb7c644a27aa568c7a18dd06113401115185474",
|
"prevTxScript": "OP_RETURN 06deadbeef03f895a2ad89fb6d696497af486cb7c644a27aa568c7a18dd06113401115185474",
|
||||||
"privKeys": [
|
"signs": [
|
||||||
"KwDiBf89QgGbjEhKnhXJuH7LrciVrZi3qYjgd9M7rFU73sVHnoWn"
|
{
|
||||||
],
|
"privKey": "KzrA86mCVMGWnLGBQu9yzQa32qbxb5dvSK4XhyjjGAWSBKYX4rHx",
|
||||||
"throws": 0
|
"throws": true
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outputs": [
|
"outputs": [
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
var assert = require('assert')
|
var assert = require('assert')
|
||||||
var scripts = require('../src/scripts')
|
|
||||||
|
|
||||||
var BigInteger = require('bigi')
|
var BigInteger = require('bigi')
|
||||||
var ECKey = require('../src/eckey')
|
var ECKey = require('../src/eckey')
|
||||||
|
@ -28,16 +27,15 @@ function construct(txb, f, sign) {
|
||||||
|
|
||||||
if (sign === undefined || sign) {
|
if (sign === undefined || sign) {
|
||||||
f.inputs.forEach(function(input, index) {
|
f.inputs.forEach(function(input, index) {
|
||||||
var redeemScript
|
input.signs.forEach(function(sign) {
|
||||||
|
var privKey = ECKey.fromWIF(sign.privKey)
|
||||||
|
var redeemScript
|
||||||
|
|
||||||
if (input.redeemScript) {
|
if (sign.redeemScript) {
|
||||||
redeemScript = Script.fromASM(input.redeemScript)
|
redeemScript = Script.fromASM(sign.redeemScript)
|
||||||
}
|
}
|
||||||
|
|
||||||
input.privKeys.forEach(function(wif) {
|
txb.sign(index, privKey, redeemScript, sign.hashType)
|
||||||
var privKey = ECKey.fromWIF(wif)
|
|
||||||
|
|
||||||
txb.sign(index, privKey, redeemScript)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -128,69 +126,25 @@ describe('TransactionBuilder', function() {
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('sign', function() {
|
describe('sign', function() {
|
||||||
describe('when prevOutScript is undefined', function() {
|
|
||||||
it('assumes pubKeyHash', function() {
|
|
||||||
txb.addInput(prevTxHash, 0)
|
|
||||||
txb.sign(0, privKey)
|
|
||||||
|
|
||||||
assert.equal(txb.inputs[0].scriptType, 'pubkeyhash')
|
|
||||||
assert.equal(txb.inputs[0].redeemScript, undefined)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('when redeemScript is defined', function() {
|
|
||||||
it('assumes scriptHash', function() {
|
|
||||||
txb.addInput(prevTxHash, 0)
|
|
||||||
txb.sign(0, privKey, privScript)
|
|
||||||
|
|
||||||
assert.equal(txb.inputs[0].prevOutType, 'scripthash')
|
|
||||||
assert.equal(txb.inputs[0].redeemScript, privScript)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('throws if hashType is inconsistent', function() {
|
|
||||||
var redeemScript = scripts.multisigOutput(1, [privKey.pub])
|
|
||||||
|
|
||||||
txb.addInput(prevTxHash, 0)
|
|
||||||
txb.sign(0, privKey, redeemScript, 83)
|
|
||||||
|
|
||||||
assert.throws(function() {
|
|
||||||
txb.sign(0, privKey, redeemScript, 82)
|
|
||||||
}, /Inconsistent hashType/)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('throws if redeemScript is inconsistent', function() {
|
|
||||||
var firstScript = scripts.multisigOutput(1, [privKey.pub])
|
|
||||||
var otherScript = scripts.multisigOutput(2, [privKey.pub, privKey.pub])
|
|
||||||
|
|
||||||
txb.addInput(prevTxHash, 0)
|
|
||||||
txb.sign(0, privKey, firstScript)
|
|
||||||
|
|
||||||
assert.throws(function() {
|
|
||||||
txb.sign(0, privKey, otherScript)
|
|
||||||
}, /Inconsistent redeemScript/)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
fixtures.invalid.sign.forEach(function(f) {
|
fixtures.invalid.sign.forEach(function(f) {
|
||||||
it('throws on ' + f.exception + ' (' + f.description + ')', function() {
|
it('throws on ' + f.exception + ' (' + f.description + ')', function() {
|
||||||
construct(txb, f, false)
|
construct(txb, f, false)
|
||||||
|
|
||||||
f.inputs.forEach(function(input, index) {
|
f.inputs.forEach(function(input, index) {
|
||||||
var redeemScript
|
input.signs.forEach(function(sign) {
|
||||||
|
var privKey = ECKey.fromWIF(sign.privKey)
|
||||||
|
var redeemScript
|
||||||
|
|
||||||
if (input.redeemScript) {
|
if (sign.redeemScript) {
|
||||||
redeemScript = Script.fromASM(input.redeemScript)
|
redeemScript = Script.fromASM(sign.redeemScript)
|
||||||
}
|
}
|
||||||
|
|
||||||
input.privKeys.forEach(function(wif, i) {
|
if (!sign.throws) {
|
||||||
var privKey = ECKey.fromWIF(wif)
|
txb.sign(index, privKey, redeemScript, sign.hashType)
|
||||||
|
|
||||||
if (input.throws !== i) {
|
|
||||||
txb.sign(index, privKey, redeemScript)
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
assert.throws(function() {
|
assert.throws(function() {
|
||||||
txb.sign(index, privKey, redeemScript)
|
txb.sign(index, privKey, redeemScript, sign.hashType)
|
||||||
}, new RegExp(f.exception))
|
}, new RegExp(f.exception))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue