better nonstandard signing.

This commit is contained in:
Christopher Jeffrey 2016-01-19 16:12:30 -08:00
parent 1258cbbbd4
commit 5e00e42903

View File

@ -213,10 +213,17 @@ TX.prototype.scriptInput = function scriptInput(index, pub, redeem) {
input.script[i + 1] = []; input.script[i + 1] = [];
} else { } else {
// Likely a non-standard scripthash multisig // Likely a non-standard scripthash multisig
// input. Just set up the empty array. Also, // input. Determine n value by counting keys.
// only allow nonstandard types for scripthash. // Also, only allow nonstandard types for
if (redeem) // scripthash.
if (redeem) {
input.script = [[]]; input.script = [[]];
// Fill script with `n` signature slots.
for (i = 0; i < s.length; i++) {
if (bcoin.script.isKey(s[i]))
input.script.push([]);
}
}
} }
// P2SH requires the redeem script after signatures // P2SH requires the redeem script after signatures
@ -782,7 +789,7 @@ TX.prototype.isCoinbase = function isCoinbase() {
TX.prototype.maxSize = function maxSize() { TX.prototype.maxSize = function maxSize() {
var copy = this.clone(); var copy = this.clone();
var i, input, total, size, s, m, n; var i, j, input, total, size, s, m, n;
// Create copy with 0-script inputs // Create copy with 0-script inputs
for (i = 0; i < copy.inputs.length; i++) for (i = 0; i < copy.inputs.length; i++)
@ -856,6 +863,12 @@ TX.prototype.maxSize = function maxSize() {
size += 1; size += 1;
// OP_CHECKMULTISIG // OP_CHECKMULTISIG
size += 1; size += 1;
} else {
// OP_PUSHDATA0 [signature]
for (j = 0; j < s.length; j++) {
if (bcoin.script.isKey(s[j]))
size += 1 + 73;
}
} }
// Byte for varint size of input script // Byte for varint size of input script