diff --git a/lib/model/txproposal.js b/lib/model/txproposal.js index 3c2f51e..46a21fd 100644 --- a/lib/model/txproposal.js +++ b/lib/model/txproposal.js @@ -2,6 +2,7 @@ var _ = require('lodash'); var Guid = require('guid'); +var Bitcore = require('bitcore'); var TxProposalAction = require('./txproposalaction'); @@ -38,7 +39,6 @@ TxProposal.fromObj = function (obj) { x.message = obj.message; x.changeAddress = obj.changeAddress; x.inputs = obj.inputs; - x.rawTx = obj.rawTx; x.requiredSignatures = obj.requiredSignatures; x.maxRejections = obj.maxRejections; x.status = obj.status; @@ -51,6 +51,7 @@ TxProposal.fromObj = function (obj) { return x; }; + TxProposal.prototype._updateStatus = function () { if (this.status != 'pending') return; @@ -61,6 +62,16 @@ TxProposal.prototype._updateStatus = function () { } }; + +TxProposal.prototype._getBitcoreTx = function () { + return new Bitcore.Transaction() + .from(this.inputs) + .to(this.toAddress, this.amount) + .change(this.changeAddress); + +}; + + TxProposal.prototype.addAction = function (copayerId, type, signature) { var action = new TxProposalAction({ copayerId: copayerId, @@ -71,7 +82,15 @@ TxProposal.prototype.addAction = function (copayerId, type, signature) { this._updateStatus(); }; -TxProposal.prototype.sign = function (copayerId, signature) { + +TxProposal.prototype._checkSignature = function (signatures) { + var t = this._getBitcoreTx(); + t.applyS + +}; + +TxProposal.prototype.sign = function (copayerId, signatures) { + this._checkSignature(signature); this.addAction(copayerId, 'accept', signature); }; diff --git a/lib/server.js b/lib/server.js index 4bf9320..bfa3f29 100644 --- a/lib/server.js +++ b/lib/server.js @@ -347,19 +347,6 @@ CopayServer.prototype.getBalance = function(opts, cb) { }; -CopayServer.prototype._createRawTx = function(txp) { - console.log('[server.js.320:txp:]', txp.inputs, txp.toAddress, txp.amount, txp.changeAddress); //TODO - - - var rawTx = new Bitcore.Transaction() - .from(txp.inputs) - .to(txp.toAddress, txp.amount) - .change(txp.changeAddress); - - console.log('[server.js.324:rawTx:]', rawTx); //TODO - return rawTx; -}; - CopayServer.prototype._inputSatoshis = function(i) { return i.amount ? Utils.strip(i.amount * 1e8) : i.satoshis; diff --git a/test/integration.js b/test/integration.js index c849e96..353dcc0 100644 --- a/test/integration.js +++ b/test/integration.js @@ -134,7 +134,7 @@ helpers.createUtxos = function(server, wallet, amounts, cb) { vout: Math.floor((Math.random() * 10) + 1), satoshis: amount, scriptPubKey: addresses[i].getScriptPubKey(wallet.m).toBuffer().toString('hex'), - address: addresses[i].address, + address: addresses[i++].address, }; }); @@ -154,9 +154,9 @@ helpers.clientSign = function(tx, xpriv, n) { _.each(tx.inputs, function(i) { if (!derived[i.path]) { - privs.push(xpriv.derive(i.path).privateKey); - derived[i.path] = true; - } + derived[i.path] = xpriv.derive(i.path).privateKey; + } + privs.push(derived[i.path]); }); var t = new Bitcore.Transaction(); @@ -986,9 +986,11 @@ describe('Copay server', function() { }, function(err, txs) { var tx = txs[0]; tx.id.should.equal(txid); +console.log('[integration.js.988:tx:]',tx); //TODO // var signatures = helpers.clientSign(tx, someXPrivKey[0], wallet.n); +console.log('[integration.js.992:signatures:]',signatures); //TODO server.signTx({ walletId: '123', copayerId: '1',