diff --git a/app.js b/app.js index e6d1abd..7eb3f00 100644 --- a/app.js +++ b/app.js @@ -194,9 +194,9 @@ router.get('/v1/balance/', function(req, res) { }); }); -router.post('/v1/txproposals/:id/signatures', function(req, res) { - req.body.txProposalId = req.params['id']; +router.post('/v1/txproposals/:id/signatures/', function(req, res) { getServerWithAuth(req, res, function(server) { + req.body.txProposalId = req.params['id']; server.signTx(req.body, function(err, txp) { if (err) return returnError(err, res, req); res.end(); @@ -205,8 +205,8 @@ router.post('/v1/txproposals/:id/signatures', function(req, res) { }); router.post('/v1/txproposals/:id/rejections', function(req, res) { - req.body.txProposalId = req.params['id']; getServerWithAuth(req, res, function(server) { + req.body.txProposalId = req.params['id']; server.signTx(req.body, function(err, txp) { if (err) return returnError(err, res, req); res.end(); diff --git a/bit-wallet/bit-sign b/bit-wallet/bit-sign index 0361b12..bad5658 100755 --- a/bit-wallet/bit-sign +++ b/bit-wallet/bit-sign @@ -33,13 +33,20 @@ cli.txProposals({}, function(err, x) { }); if (!txps.length) - common.die('Could not find TX Proposal:' + txpid); + common.die('Could not find TX Proposal:' + txpid); if (txps.length > 1) - common.die('More that one TX Proposals match:' + txpid + ' : ' + _.map(txps, function(x) { + common.die('More that one TX Proposals match:' + txpid + ' : ' + _.map(txps, function(x) { return x.id; }).join(' '));; var txp = txps[0]; - cli.sign(txp); + cli.sign(txp, function(err, x) { + common.die(err); + + if (program.verbose) + console.log('* Raw Server Response:\n', x); //TODO + + console.log('Transaction signed.'); + }); }); diff --git a/bit-wallet/bit-status b/bit-wallet/bit-status index 040ae99..8fe542d 100755 --- a/bit-wallet/bit-status +++ b/bit-wallet/bit-status @@ -26,13 +26,20 @@ cli.status(function(err, res) { var x = res.balance; console.log('* Balance %d (Locked: %d)', x.totalAmount, x.lockedAmount); - if (! _.isEmpty(res.pendingTxps)) { + if (!_.isEmpty(res.pendingTxps)) { console.log("* TX Proposals:") - _.each(res.pendingTxps, function(x){ - console.log("\t[%s] %d => %s", common.shortID(x.id),x.amount, x.toAddress); + _.each(res.pendingTxps, function(x) { + console.log("\t%s [%s by %s] %dSAT => %s", common.shortID(x.id), x.message, x.creatorName, x.amount, x.toAddress); + + if (!_.isEmpty(x.actions)) { + console.log('\t\t * Actions'); + console.log('\t\t', _.map(x.actions, function(a) { + return a.copayerName + ': ' + a.type + '' + }).join('. ')); + } + + if (program.verbose) + console.log('* Raw Server Response:\n', res); //TODO }); } - - if (program.verbose) - console.log('* Raw Server Response:\n', res); //TODO }); diff --git a/lib/clientlib.js b/lib/clientlib.js index 4db393a..e5ba809 100644 --- a/lib/clientlib.js +++ b/lib/clientlib.js @@ -134,7 +134,7 @@ ClientLib.prototype.createWallet = function(walletName, copayerName, m, n, netwo }); }; -ClientLib.prototype._joinWallet = function(data, secret, copayerName, cb) { +ClientLib.prototype._joinWallet = function(data, secret, copayerName, cb) { var self = this; data = data || {}; @@ -143,7 +143,7 @@ ClientLib.prototype._joinWallet = function(data, secret, copayerName, cb) { var walletPrivKey = Bitcore.PrivateKey.fromString(secretSplit[1]); var network = secretSplit[2] == 'T' ? 'testnet' : 'livenet'; - data.xPrivKey = _createXPrivKey(network); + data.xPrivKey = _createXPrivKey(network); var xPubKey = new Bitcore.HDPublicKey(data.xPrivKey); var xPubKeySignature = SignUtils.sign(xPubKey.toString(), walletPrivKey); @@ -408,7 +408,7 @@ ClientLib.prototype.sign = function(txp, cb) { //Derive proper key to sign, for each input var privs = [], derived = {}; - + var network = new Bitcore.Address(txp.toAddress).network.name; var xpriv = new Bitcore.HDPrivateKey(data.xPrivKey, network); @@ -434,12 +434,17 @@ ClientLib.prototype.sign = function(txp, cb) { signatures.push(s); }); - var url = '/v1//'; - var signature = _signRequest(url, args, data.signingPrivKey); + var url = '/v1/txproposals/' + txp.id + '/signatures/'; + var args = { + signatures: signatures + }; + var reqSignature = _signRequest(url, args, data.signingPrivKey); +console.log('[clientlib.js.441:reqSignature:]',url, args, reqSignature); //TODO + request({ headers: { 'x-identity': data.copayerId, - 'x-signature': signature, + 'x-signature': reqSignature, }, method: 'post', url: _getUrl(url), @@ -453,9 +458,6 @@ ClientLib.prototype.sign = function(txp, cb) { } return cb(null, body); }); - - - return signatures; }; diff --git a/lib/server.js b/lib/server.js index 71cd3ca..7aff2fc 100644 --- a/lib/server.js +++ b/lib/server.js @@ -374,7 +374,6 @@ CopayServer.prototype._getUtxos = function(cb) { utxo.path = addressToPath[utxo.address].path; utxo.publicKeys = addressToPath[utxo.address].publicKeys; }); - console.log('[server.js.375:utxos:]', utxos); //TODO return cb(null, utxos); }); @@ -586,7 +585,9 @@ CopayServer.prototype.removePendingTx = function(opts, cb) { CopayServer.prototype._broadcastTx = function(txp, cb) { var raw = txp.getRawTx(); var bc = this._getBlockExplorer('insight', txp.getNetworkName()); +console.log('[server.js.588:raw:]',raw); //TODO bc.broadcast(raw, function(err, txid) { +console.log('[server.js.589:err:]',err, txid); //TODO return cb(err, txid); }) };