Script: fixes pubKeyInput and adds a test
This commit is contained in:
parent
9d5d18b2d8
commit
b68b1d5da4
3 changed files with 27 additions and 6 deletions
|
@ -139,7 +139,7 @@ function multisigOutput(m, pubKeys) {
|
|||
function pubKeyInput(signature) {
|
||||
assert(Buffer.isBuffer(signature), 'Expected Buffer, got ' + signature)
|
||||
|
||||
return Script.fromChunks(signature)
|
||||
return Script.fromChunks([signature])
|
||||
}
|
||||
|
||||
// {signature} {pubKey}
|
||||
|
|
9
test/fixtures/script.json
vendored
9
test/fixtures/script.json
vendored
|
@ -33,6 +33,15 @@
|
|||
"asm": "72 304502206becda98cecf7a545d1a640221438ff8912d9b505ede67e0138485111099f696022100ccd616072501310acba10feb97cecc918e21c8e92760cd35144efec7622938f301 65 040cd2d2ce17a1e9b2b3b2cb294d40eecf305a25b7e7bfdafae6bb2639f4ee399b3637706c3d377ec4ab781355add443ae864b134c5e523001c442186ea60f0eb8",
|
||||
"scriptPubKey": false
|
||||
},
|
||||
{
|
||||
"description": "pubKey scriptSig",
|
||||
"hex": "48304502206becda98cecf7a545d1a640221438ff8912d9b505ede67e0138485111099f696022100ccd616072501310acba10feb97cecc918e21c8e92760cd35144efec7622938f301",
|
||||
"type": "pubkey",
|
||||
"hash": "44d9982c3e79452e02ef5816976a0e20a0ec1cba",
|
||||
"signature": "304502206becda98cecf7a545d1a640221438ff8912d9b505ede67e0138485111099f696022100ccd616072501310acba10feb97cecc918e21c8e92760cd35144efec7622938f301",
|
||||
"asm": "72 304502206becda98cecf7a545d1a640221438ff8912d9b505ede67e0138485111099f696022100ccd616072501310acba10feb97cecc918e21c8e92760cd35144efec7622938f301",
|
||||
"scriptPubKey": false
|
||||
},
|
||||
{
|
||||
"description": "Valid multisig script",
|
||||
"hex": "5121032487c2a32f7c8d57d2a93906a6457afd00697925b0e6e145d89af6d3bca330162102308673d16987eaa010e540901cc6fe3695e758c19f46ce604e174dac315e685a52ae",
|
||||
|
|
|
@ -52,12 +52,24 @@ describe('Scripts', function() {
|
|||
|
||||
// FIXME: bad
|
||||
describe('pay-to-pubkey', function() {
|
||||
it('matches the test data', function() {
|
||||
var f = fixtures.valid[0]
|
||||
var pubKey = ECPubKey.fromHex(f.pubKey)
|
||||
var script = scripts.pubKeyOutput(pubKey)
|
||||
describe('input', function() {
|
||||
it('matches the test data', function() {
|
||||
var f = fixtures.valid[4]
|
||||
var signature = new Buffer(f.signature, 'hex')
|
||||
var script = scripts.pubKeyInput(signature)
|
||||
|
||||
assert.equal(script.toHex(), f.hex)
|
||||
assert.equal(script.toHex(), f.hex)
|
||||
})
|
||||
})
|
||||
|
||||
describe('output', function() {
|
||||
it('matches the test data', function() {
|
||||
var f = fixtures.valid[0]
|
||||
var pubKey = ECPubKey.fromHex(f.pubKey)
|
||||
var script = scripts.pubKeyOutput(pubKey)
|
||||
|
||||
assert.equal(script.toHex(), f.hex)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue