fix getRawTx

This commit is contained in:
Matias Alejo Garcia 2015-02-13 21:16:18 -03:00
parent a04cded8b9
commit 5953dc8f1d
3 changed files with 18 additions and 3 deletions

View File

@ -70,10 +70,14 @@ TxProposal.prototype._updateStatus = function() {
TxProposal.prototype._getCurrentSignatures = function() {
return _.map(_.some(this.actions, 'xpub'), function(x) {
var acceptedActions = _.filter(this.actions, function(x) {
return x && x.type == 'accept';
});
return _.map(acceptedActions, function(x) {
return {
signatures: x.signatures,
xpub: xpub,
xpub: x.xpub,
};
});
};
@ -94,7 +98,7 @@ TxProposal.prototype._getBitcoreTx = function() {
var sigs = this._getCurrentSignatures();
_.each(sigs, function(x) {
this._addSignaturesToBitcoreTx(t, x.signatures, x.xpub);
self._addSignaturesToBitcoreTx(t, x.signatures, x.xpub);
});
return t;

View File

@ -584,6 +584,7 @@ CopayServer.prototype.removePendingTx = function(opts, cb) {
CopayServer.prototype._broadcastTx = function(txp, cb) {
var raw = txp.getRawTx();
console.log('[server.js.586:raw:]',raw); //TODO
var bc = this._getBlockExplorer('insight', txp.getNetworkName());
bc.broadcast(raw, function(err, txid) {
return cb(err, txid);

View File

@ -37,6 +37,16 @@ describe('TXProposal', function() {
});
});
describe('#getRawTx', function() {
it('should generate correct raw transaction for signed 2-2', function() {
var txp = TXP.fromObj(aTXP());
txp.sign('1', theSignatures, theXPub);
txp.getRawTx().should.equal('0100000001ab069f7073be9b491bb1ad4233a45d2e383082ccc7206df905662d6d8499e66e080000009200483045022100896aeb8db75fec22fddb5facf791927a996eb3aee23ee6deaa15471ea46047de02204c0c33f42a9d3ff93d62738712a8c8a5ecd21b45393fdd144e7b01b5a186f1f9014752210319008ffe1b3e208f5ebed8f46495c056763f87b07930a7027a92ee477fb0cb0f2103b5f035af8be40d0db5abb306b7754949ab39032cf99ad177691753b37d10130152aeffffffff0280f0fa02000000001976a91451224bca38efcaa31d5340917c3f3f713b8b20e488ac70c9fa020000000017a914778192003f0e9e1d865c082179cc3dae5464b03d8700000000');
});
});
describe('#reject', function() {
it('should reject 2-2', function() {
var txp = TXP.fromObj(aTXP());