add option for colored coin output creation.
This commit is contained in:
parent
efe1181bc1
commit
5b68ec0b3e
@ -407,6 +407,16 @@ TX.prototype.scriptOutput = function scriptOutput(output, options) {
|
||||
assert(n >= 1 && n <= 3);
|
||||
|
||||
script = bcoin.script.multisig(keys, m, n);
|
||||
|
||||
// make it p2sh
|
||||
if (options.scripthash) {
|
||||
var hash = utils.ripesha(bcoin.script.encode(script));
|
||||
script = [
|
||||
'hash160',
|
||||
hash,
|
||||
'eq'
|
||||
];
|
||||
}
|
||||
} else if (bcoin.wallet.validateAddress(options.address, 'scripthash')) {
|
||||
// p2sh transaction
|
||||
// https://github.com/bitcoin/bips/blob/master/bip-0016.mediawiki
|
||||
@ -426,18 +436,15 @@ TX.prototype.scriptOutput = function scriptOutput(output, options) {
|
||||
'eqverify',
|
||||
'checksig'
|
||||
];
|
||||
}
|
||||
|
||||
// make it p2sh
|
||||
if (options.hash) {
|
||||
var redeem = script;
|
||||
var hash = utils.ripesha(bcoin.script.encode(redeem));
|
||||
} else if (options.color) {
|
||||
var color = options.color;
|
||||
if (typeof color === 'string')
|
||||
color = utils.ascii2array(color);
|
||||
assert(color.length <= 40);
|
||||
script = [
|
||||
'hash160',
|
||||
hash,
|
||||
'eq'
|
||||
'ret',
|
||||
color
|
||||
];
|
||||
script.redeem = redeem;
|
||||
}
|
||||
|
||||
output.script = script;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user