Browse Source

Scripts: adds assertion for enforcing a Script input

hk-custom-address
Daniel Cousens 11 years ago
parent
commit
9d5d18b2d8
  1. 4
      src/scripts.js

4
src/scripts.js

@ -3,6 +3,8 @@ var opcodes = require('./opcodes')
var Script = require('./script') var Script = require('./script')
function classifyOutput(script) { function classifyOutput(script) {
assert(script instanceof Script, 'Expected Script, got ', script)
if (isPubkeyhash.call(script)) { if (isPubkeyhash.call(script)) {
return 'pubkeyhash' return 'pubkeyhash'
} else if (isPubkey.call(script)) { } else if (isPubkey.call(script)) {
@ -19,6 +21,8 @@ function classifyOutput(script) {
} }
function classifyInput(script) { function classifyInput(script) {
assert(script instanceof Script, 'Expected Script, got ', script)
if (script.chunks.length == 1 && Buffer.isBuffer(script.chunks[0])) { if (script.chunks.length == 1 && Buffer.isBuffer(script.chunks[0])) {
return 'pubkey' return 'pubkey'
} else if (script.chunks.length == 2 && Buffer.isBuffer(script.chunks[0]) && Buffer.isBuffer(script.chunks[1])) { } else if (script.chunks.length == 2 && Buffer.isBuffer(script.chunks[0]) && Buffer.isBuffer(script.chunks[1])) {

Loading…
Cancel
Save