From 89b2a08f9f6756d856ba818687bef12fe7050b4d Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Tue, 8 Dec 2015 12:01:49 -0300 Subject: [PATCH] rename sendTx -> publishTx --- lib/expressapp.js | 4 ++-- lib/server.js | 4 ++-- test/integration/server.js | 32 ++++++++++++++++---------------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/expressapp.js b/lib/expressapp.js index 17feccc..9ad17ef 100644 --- a/lib/expressapp.js +++ b/lib/expressapp.js @@ -369,10 +369,10 @@ ExpressApp.prototype.start = function(opts, cb) { }); }); - router.post('/v1/txproposals/:id/send/', function(req, res) { + router.post('/v1/txproposals/:id/publish/', function(req, res) { getServerWithAuth(req, res, function(server) { req.body.txProposalId = req.params['id']; - server.sendTx(req.body, function(err, txp) { + server.publishTx(req.body, function(err, txp) { if (err) return returnError(err, res, req); res.json(txp); res.end(); diff --git a/lib/server.js b/lib/server.js index b27a29f..4ed2f12 100644 --- a/lib/server.js +++ b/lib/server.js @@ -1446,14 +1446,14 @@ WalletService.prototype._verifyRequestPubKey = function(requestPubKey, signature }; /** - * Send an already created tx proposal to other copayers in the wallet. + * Publish an already created tx proposal so inputs are locked and other copayers in the wallet can see it. * @param {Object} opts * @param {string} opts.txProposalId - The tx id. * @param {string} opts.proposalSignature - S(raw tx). Used by other copayers to verify the proposal. * @param {string} opts.proposalSignaturePubKey - (Optional) An alternative public key used to verify the proposal signature. * @param {string} opts.proposalSignaturePubKeySig - (Optional) A signature used to validate the opts.proposalSignaturePubKey. */ -WalletService.prototype.sendTx = function(opts, cb) { +WalletService.prototype.publishTx = function(opts, cb) { var self = this; function utxoKey(utxo) { diff --git a/test/integration/server.js b/test/integration/server.js index 946210e..910ffca 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -2385,8 +2385,8 @@ describe('Wallet service', function() { server.createTx(txOpts, function(err, txp) { should.not.exist(err); should.exist(txp); - var sendOpts = helpers.getProposalSignatureOpts(txp, TestData.copayers[0].privKey_1H_0); - server.sendTx(sendOpts, function(err) { + var publishOpts = helpers.getProposalSignatureOpts(txp, TestData.copayers[0].privKey_1H_0); + server.publishTx(publishOpts, function(err) { should.not.exist(err); server.getPendingTxs({}, function(err, txs) { should.not.exist(err); @@ -2399,7 +2399,7 @@ describe('Wallet service', function() { }); it('should fail to send non-existent tx proposal', function(done) { - server.sendTx({ + server.publishTx({ txProposalId: 'wrong-id', proposalSignature: 'dummy', }, function(err) { @@ -2423,7 +2423,7 @@ describe('Wallet service', function() { server.createTx(txOpts, function(err, txp) { should.not.exist(err); should.exist(txp); - server.sendTx({ + server.publishTx({ txProposalId: txp.id, proposalSignature: 'dummy' }, function(err) { @@ -2452,14 +2452,14 @@ describe('Wallet service', function() { var pubKey = new Bitcore.PrivateKey(TestData.copayers[0].privKey_1H_0).toPublicKey().toString(); var pubKeySig = helpers.signMessage(pubKey, TestData.copayers[1].privKey_1H_0); - var sendOpts = { + var publishOpts = { txProposalId: txp.id, proposalSignature: proposalSignature, proposalSignaturePubKey: pubKey, proposalSignaturePubKeySig: pubKeySig, } - server.sendTx(sendOpts, function(err) { + server.publishTx(publishOpts, function(err) { should.exist(err); err.message.should.contain('Invalid proposal signing key'); done(); @@ -2495,14 +2495,14 @@ describe('Wallet service', function() { should.not.exist(err); should.exist(txp); - var sendOpts = { + var publishOpts = { txProposalId: txp.id, proposalSignature: helpers.signMessage(txp.getRawTx(), reqPrivKey), proposalSignaturePubKey: reqPubKey, proposalSignaturePubKeySig: sig, } - server.sendTx(sendOpts, function(err) { + server.publishTx(publishOpts, function(err) { should.exist(err); err.message.should.contain('Invalid proposal signing key'); done(); @@ -2539,12 +2539,12 @@ describe('Wallet service', function() { txp2 = txp; should.exist(txp1); should.exist(txp2); - var sendOpts = helpers.getProposalSignatureOpts(txp1, TestData.copayers[0].privKey_1H_0); - server.sendTx(sendOpts, next); + var publishOpts = helpers.getProposalSignatureOpts(txp1, TestData.copayers[0].privKey_1H_0); + server.publishTx(publishOpts, next); }, function(next) { - var sendOpts = helpers.getProposalSignatureOpts(txp2, TestData.copayers[0].privKey_1H_0); - server.sendTx(sendOpts, function(err) { + var publishOpts = helpers.getProposalSignatureOpts(txp2, TestData.copayers[0].privKey_1H_0); + server.publishTx(publishOpts, function(err) { should.exist(err); err.code.should.equal('UNAVAILABLE_UTXOS'); next(); @@ -2563,8 +2563,8 @@ describe('Wallet service', function() { }, function(txp3, next) { should.exist(txp3); - var sendOpts = helpers.getProposalSignatureOpts(txp3, TestData.copayers[0].privKey_1H_0); - server.sendTx(sendOpts, next); + var publishOpts = helpers.getProposalSignatureOpts(txp3, TestData.copayers[0].privKey_1H_0); + server.publishTx(publishOpts, next); }, function(next) { server.getPendingTxs({}, function(err, txs) { @@ -2591,8 +2591,8 @@ describe('Wallet service', function() { server.createTx(txOpts, function(err, txp) { should.not.exist(err); should.exist(txp); - var sendOpts = helpers.getProposalSignatureOpts(txp, TestData.copayers[0].privKey_1H_0); - server.sendTx(sendOpts, function(err) { + var publishOpts = helpers.getProposalSignatureOpts(txp, TestData.copayers[0].privKey_1H_0); + server.publishTx(publishOpts, function(err) { should.not.exist(err); server.getPendingTxs({}, function(err, txs) { should.not.exist(err);