Skip to content

Commit

Permalink
fix bug related with chunks length
Browse files Browse the repository at this point in the history
  • Loading branch information
fanatid committed Oct 12, 2015
1 parent 6e0535f commit ac0a17c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "script2addresses",
"version": "0.1.1",
"version": "0.1.2",
"description": "Transform bitcoin script to bitcoin addresses",
"keywords": [
"bitcoin",
Expand Down
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export default function (script, network, strict) {
network = network || Networks.get(network) || Networks.defaultNetwork

let sChunks = script.chunks
if (sChunks.length === 0) {
return {type: 'unknow'}
}

switch (sChunks[0].opcodenum) {
// pubkeyhash
Expand Down Expand Up @@ -115,7 +118,7 @@ export default function (script, network, strict) {

// multisig
let mOp = sChunks[0].opcodenum
let nOp = sChunks[sChunks.length - 2].opcodenum
let nOp = sChunks[Math.max(sChunks.length - 2, 0)].opcodenum
if (sChunks.length >= 4 &&
sChunks[sChunks.length - 1].opcodenum === Opcode.OP_CHECKMULTISIG &&
mOp >= Opcode.OP_1 &&
Expand Down

0 comments on commit ac0a17c

Please sign in to comment.