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