This commit is contained in:
Christopher Jeffrey 2015-12-04 23:16:02 -08:00
parent 87eea1e398
commit c8e04d8552

View File

@ -290,6 +290,7 @@ Wallet.prototype.sign = function sign(tx, type, inputs, off) {
var signature = bcoin.ecdsa.sign(hash, this.key).toDER();
signature = signature.concat(bcoin.protocol.constants.hashType[type]);
// P2PKH and simple tx
if (bcoin.script.isPubkeyhash(s) || bcoin.script.isSimplePubkeyhash(s)) {
input.script = [ signature, pub ];
return true;
@ -299,7 +300,6 @@ Wallet.prototype.sign = function sign(tx, type, inputs, off) {
// empty array == OP_FALSE == OP_0
// raw format: OP_FALSE [sig-1] [sig-2] ...
// p2sh format: OP_FALSE [sig-1] [sig-2] ... [redeem-script]
if (bcoin.script.isMultisig(s) || bcoin.script.isScripthash(s)) {
// XXX Check own?
// || (bcoin.script.isScripthash(s) && utils.isEqual(s[1], this.getP2SHHash())) {
@ -310,6 +310,7 @@ Wallet.prototype.sign = function sign(tx, type, inputs, off) {
}
}
// P2SH requires a redeem script after signatures
if (bcoin.script.isScripthash(s)) {
if (input.script.length - 1 === this.n) {
input.script.push(this.getP2SHRedemption());
@ -325,7 +326,8 @@ Wallet.prototype.sign = function sign(tx, type, inputs, off) {
Wallet.prototype.signEmpty = function sign(tx, type, inputs, off) {
if (!type)
type = 'all';
assert.equal(type, 'all');
// assert.equal(type, 'all');
if (!off)
off = 0;