diff --git a/src/script.js b/src/script.js index 317dc18..b06fc1a 100644 --- a/src/script.js +++ b/src/script.js @@ -99,15 +99,16 @@ Script.prototype.getInType = function () { - if (this.chunks.length == 1) { + if (this.chunks.length == 1 && + Bitcoin.Util.isArray(this.chunks[0])) { // Direct IP to IP transactions only have the public key in their scriptSig. + // TODO: We could also check that the length of the data is 65 or 33. return 'Pubkey'; } else if (this.chunks.length == 2 && Bitcoin.Util.isArray(this.chunks[0]) && Bitcoin.Util.isArray(this.chunks[1])) { return 'Address'; } else { - console.log(this.chunks); throw new Error("Encountered non-standard scriptSig"); } }; @@ -118,7 +119,9 @@ case 'Address': return this.chunks[1]; case 'Pubkey': - return this.chunks[0]; + // TODO: Theoretically, we could recover the pubkey from the sig here. + // See https://bitcointalk.org/?topic=6430.0 + throw new Error("Script does not contain pubkey."); default: throw new Error("Encountered non-standard scriptSig"); }