|
|
@ -7,7 +7,10 @@ var log = require('npmlog'); |
|
|
|
log.debug = log.verbose; |
|
|
|
log.disableColor(); |
|
|
|
|
|
|
|
var Bitcore = require('bitcore-lib'); |
|
|
|
var Bitcore = { |
|
|
|
'btc': require('bitcore-lib'), |
|
|
|
'bch': require('bitcore-lib-cash'), |
|
|
|
}; |
|
|
|
|
|
|
|
var Common = require('../common'); |
|
|
|
var Constants = Common.Constants, |
|
|
@ -139,7 +142,7 @@ TxProposal.prototype._updateStatus = function() { |
|
|
|
TxProposal.prototype._buildTx = function() { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
var t = new Bitcore.Transaction(); |
|
|
|
var t = new Bitcore[self.coin].Transaction(); |
|
|
|
|
|
|
|
$.checkState(Utils.checkValueInCollection(self.addressType, Constants.SCRIPT_TYPES)); |
|
|
|
|
|
|
@ -158,7 +161,7 @@ TxProposal.prototype._buildTx = function() { |
|
|
|
_.each(self.outputs, function(o) { |
|
|
|
$.checkState(o.script || o.toAddress, 'Output should have either toAddress or script specified'); |
|
|
|
if (o.script) { |
|
|
|
t.addOutput(new Bitcore.Transaction.Output({ |
|
|
|
t.addOutput(new Bitcore[self.coin].Transaction.Output({ |
|
|
|
script: o.script, |
|
|
|
satoshis: o.amount |
|
|
|
})); |
|
|
@ -322,21 +325,23 @@ TxProposal.prototype.addAction = function(copayerId, type, comment, signatures, |
|
|
|
TxProposal.prototype._addSignaturesToBitcoreTx = function(tx, signatures, xpub) { |
|
|
|
var self = this; |
|
|
|
|
|
|
|
var bitcore = Bitcore[self.coin]; |
|
|
|
|
|
|
|
if (signatures.length != this.inputs.length) |
|
|
|
throw new Error('Number of signatures does not match number of inputs'); |
|
|
|
|
|
|
|
var i = 0, |
|
|
|
x = new Bitcore.HDPublicKey(xpub); |
|
|
|
x = new bitcore.HDPublicKey(xpub); |
|
|
|
|
|
|
|
_.each(signatures, function(signatureHex) { |
|
|
|
var input = self.inputs[i]; |
|
|
|
try { |
|
|
|
var signature = Bitcore.crypto.Signature.fromString(signatureHex); |
|
|
|
var signature = bitcore.crypto.Signature.fromString(signatureHex); |
|
|
|
var pub = x.deriveChild(self.inputPaths[i]).publicKey; |
|
|
|
var s = { |
|
|
|
inputIndex: i, |
|
|
|
signature: signature, |
|
|
|
sigtype: Bitcore.crypto.Signature.SIGHASH_ALL, |
|
|
|
sigtype: bitcore.crypto.Signature.SIGHASH_ALL, |
|
|
|
publicKey: pub, |
|
|
|
}; |
|
|
|
tx.inputs[i].addSignature(tx, s); |
|
|
|