rename sendTx -> publishTx

This commit is contained in:
Ivan Socolsky 2015-12-08 12:01:49 -03:00
parent 3f35d8f141
commit 89b2a08f9f
3 changed files with 20 additions and 20 deletions

View File

@ -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) { getServerWithAuth(req, res, function(server) {
req.body.txProposalId = req.params['id']; 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); if (err) return returnError(err, res, req);
res.json(txp); res.json(txp);
res.end(); res.end();

View File

@ -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 {Object} opts
* @param {string} opts.txProposalId - The tx id. * @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.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.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. * @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; var self = this;
function utxoKey(utxo) { function utxoKey(utxo) {

View File

@ -2385,8 +2385,8 @@ describe('Wallet service', function() {
server.createTx(txOpts, function(err, txp) { server.createTx(txOpts, function(err, txp) {
should.not.exist(err); should.not.exist(err);
should.exist(txp); should.exist(txp);
var sendOpts = helpers.getProposalSignatureOpts(txp, TestData.copayers[0].privKey_1H_0); var publishOpts = helpers.getProposalSignatureOpts(txp, TestData.copayers[0].privKey_1H_0);
server.sendTx(sendOpts, function(err) { server.publishTx(publishOpts, function(err) {
should.not.exist(err); should.not.exist(err);
server.getPendingTxs({}, function(err, txs) { server.getPendingTxs({}, function(err, txs) {
should.not.exist(err); should.not.exist(err);
@ -2399,7 +2399,7 @@ describe('Wallet service', function() {
}); });
it('should fail to send non-existent tx proposal', function(done) { it('should fail to send non-existent tx proposal', function(done) {
server.sendTx({ server.publishTx({
txProposalId: 'wrong-id', txProposalId: 'wrong-id',
proposalSignature: 'dummy', proposalSignature: 'dummy',
}, function(err) { }, function(err) {
@ -2423,7 +2423,7 @@ describe('Wallet service', function() {
server.createTx(txOpts, function(err, txp) { server.createTx(txOpts, function(err, txp) {
should.not.exist(err); should.not.exist(err);
should.exist(txp); should.exist(txp);
server.sendTx({ server.publishTx({
txProposalId: txp.id, txProposalId: txp.id,
proposalSignature: 'dummy' proposalSignature: 'dummy'
}, function(err) { }, function(err) {
@ -2452,14 +2452,14 @@ describe('Wallet service', function() {
var pubKey = new Bitcore.PrivateKey(TestData.copayers[0].privKey_1H_0).toPublicKey().toString(); 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 pubKeySig = helpers.signMessage(pubKey, TestData.copayers[1].privKey_1H_0);
var sendOpts = { var publishOpts = {
txProposalId: txp.id, txProposalId: txp.id,
proposalSignature: proposalSignature, proposalSignature: proposalSignature,
proposalSignaturePubKey: pubKey, proposalSignaturePubKey: pubKey,
proposalSignaturePubKeySig: pubKeySig, proposalSignaturePubKeySig: pubKeySig,
} }
server.sendTx(sendOpts, function(err) { server.publishTx(publishOpts, function(err) {
should.exist(err); should.exist(err);
err.message.should.contain('Invalid proposal signing key'); err.message.should.contain('Invalid proposal signing key');
done(); done();
@ -2495,14 +2495,14 @@ describe('Wallet service', function() {
should.not.exist(err); should.not.exist(err);
should.exist(txp); should.exist(txp);
var sendOpts = { var publishOpts = {
txProposalId: txp.id, txProposalId: txp.id,
proposalSignature: helpers.signMessage(txp.getRawTx(), reqPrivKey), proposalSignature: helpers.signMessage(txp.getRawTx(), reqPrivKey),
proposalSignaturePubKey: reqPubKey, proposalSignaturePubKey: reqPubKey,
proposalSignaturePubKeySig: sig, proposalSignaturePubKeySig: sig,
} }
server.sendTx(sendOpts, function(err) { server.publishTx(publishOpts, function(err) {
should.exist(err); should.exist(err);
err.message.should.contain('Invalid proposal signing key'); err.message.should.contain('Invalid proposal signing key');
done(); done();
@ -2539,12 +2539,12 @@ describe('Wallet service', function() {
txp2 = txp; txp2 = txp;
should.exist(txp1); should.exist(txp1);
should.exist(txp2); should.exist(txp2);
var sendOpts = helpers.getProposalSignatureOpts(txp1, TestData.copayers[0].privKey_1H_0); var publishOpts = helpers.getProposalSignatureOpts(txp1, TestData.copayers[0].privKey_1H_0);
server.sendTx(sendOpts, next); server.publishTx(publishOpts, next);
}, },
function(next) { function(next) {
var sendOpts = helpers.getProposalSignatureOpts(txp2, TestData.copayers[0].privKey_1H_0); var publishOpts = helpers.getProposalSignatureOpts(txp2, TestData.copayers[0].privKey_1H_0);
server.sendTx(sendOpts, function(err) { server.publishTx(publishOpts, function(err) {
should.exist(err); should.exist(err);
err.code.should.equal('UNAVAILABLE_UTXOS'); err.code.should.equal('UNAVAILABLE_UTXOS');
next(); next();
@ -2563,8 +2563,8 @@ describe('Wallet service', function() {
}, },
function(txp3, next) { function(txp3, next) {
should.exist(txp3); should.exist(txp3);
var sendOpts = helpers.getProposalSignatureOpts(txp3, TestData.copayers[0].privKey_1H_0); var publishOpts = helpers.getProposalSignatureOpts(txp3, TestData.copayers[0].privKey_1H_0);
server.sendTx(sendOpts, next); server.publishTx(publishOpts, next);
}, },
function(next) { function(next) {
server.getPendingTxs({}, function(err, txs) { server.getPendingTxs({}, function(err, txs) {
@ -2591,8 +2591,8 @@ describe('Wallet service', function() {
server.createTx(txOpts, function(err, txp) { server.createTx(txOpts, function(err, txp) {
should.not.exist(err); should.not.exist(err);
should.exist(txp); should.exist(txp);
var sendOpts = helpers.getProposalSignatureOpts(txp, TestData.copayers[0].privKey_1H_0); var publishOpts = helpers.getProposalSignatureOpts(txp, TestData.copayers[0].privKey_1H_0);
server.sendTx(sendOpts, function(err) { server.publishTx(publishOpts, function(err) {
should.not.exist(err); should.not.exist(err);
server.getPendingTxs({}, function(err, txs) { server.getPendingTxs({}, function(err, txs) {
should.not.exist(err); should.not.exist(err);