From f7e60084f24cfa203f25f1efe8181d0ebb9b989e Mon Sep 17 00:00:00 2001 From: Ivan Socolsky Date: Wed, 4 Feb 2015 15:45:08 -0300 Subject: [PATCH] add #getTx --- lib/server.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/server.js b/lib/server.js index edf7834..b1aaada 100644 --- a/lib/server.js +++ b/lib/server.js @@ -433,6 +433,23 @@ CopayServer.prototype.createTx = function(opts, cb) { }); }; +/** + * Retrieves a tx from storage. + * @param {Object} opts + * @param {string} opts.walletId - The wallet id. + * @param {string} opts.id - The tx id. + * @returns {Object} txProposal + */ +CopayServer.prototype.getTx = function(opts, cb) { + var self = this; + + self.storage.fetchTx(opts.walletId, opts.id, function(err, txp) { + if (err) return cb(err); + if (!txp) return cb(new ClientError('Transaction proposal not found')); + return cb(null, txp); + }); +}; + CopayServer.prototype._broadcastTx = function(rawTx, cb) { // TODO: this should attempt to broadcast _all_ accepted and not-yet broadcasted (status=='accepted') txps? cb = cb || function() {};