scriptOutput: move "p2shify".
This commit is contained in:
parent
37e1c8a2ef
commit
a1fea2bd65
@ -301,16 +301,6 @@ TX.prototype.scriptOutput = function(options) {
|
|||||||
assert(n >= 1 && n <= 3);
|
assert(n >= 1 && n <= 3);
|
||||||
|
|
||||||
script = bcoin.script.multisig(keys, m, n);
|
script = bcoin.script.multisig(keys, m, n);
|
||||||
|
|
||||||
// make it p2sh
|
|
||||||
if (options.hash) {
|
|
||||||
var hash = utils.ripesha(bcoin.script.encode(script));
|
|
||||||
script = [
|
|
||||||
'hash160',
|
|
||||||
hash,
|
|
||||||
'eq'
|
|
||||||
];
|
|
||||||
}
|
|
||||||
} else if (bcoin.wallet.validateAddress(options.address, 'p2sh')) {
|
} else if (bcoin.wallet.validateAddress(options.address, 'p2sh')) {
|
||||||
// p2sh transaction
|
// p2sh transaction
|
||||||
// https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki
|
// https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki
|
||||||
@ -332,6 +322,18 @@ TX.prototype.scriptOutput = function(options) {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make it p2sh
|
||||||
|
if (options.hash) {
|
||||||
|
var redeem = script;
|
||||||
|
var hash = utils.ripesha(bcoin.script.encode(redeem));
|
||||||
|
script = [
|
||||||
|
'hash160',
|
||||||
|
hash,
|
||||||
|
'eq'
|
||||||
|
];
|
||||||
|
script.redeem = redeem;
|
||||||
|
}
|
||||||
|
|
||||||
return script;
|
return script;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user