Browse Source

Fixes for Script.getInType and Script.simpleInPubKey.

hk-custom-address
Stefan Thomas 13 years ago
parent
commit
de21042bb7
  1. 9
      src/script.js

9
src/script.js

@ -99,15 +99,16 @@
Script.prototype.getInType = function () 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. // 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'; return 'Pubkey';
} else if (this.chunks.length == 2 && } else if (this.chunks.length == 2 &&
Bitcoin.Util.isArray(this.chunks[0]) && Bitcoin.Util.isArray(this.chunks[0]) &&
Bitcoin.Util.isArray(this.chunks[1])) { Bitcoin.Util.isArray(this.chunks[1])) {
return 'Address'; return 'Address';
} else { } else {
console.log(this.chunks);
throw new Error("Encountered non-standard scriptSig"); throw new Error("Encountered non-standard scriptSig");
} }
}; };
@ -118,7 +119,9 @@
case 'Address': case 'Address':
return this.chunks[1]; return this.chunks[1];
case 'Pubkey': 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: default:
throw new Error("Encountered non-standard scriptSig"); throw new Error("Encountered non-standard scriptSig");
} }

Loading…
Cancel
Save