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() {};