This commit is contained in:
Matias Alejo Garcia 2015-02-13 18:53:49 -03:00
parent edce55b6cc
commit 0af48ff27b
5 changed files with 39 additions and 22 deletions

6
app.js
View File

@ -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();

View File

@ -41,5 +41,12 @@ cli.txProposals({}, function(err, x) {
}).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.');
});
});

View File

@ -29,10 +29,17 @@ cli.status(function(err, res) {
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);
});
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
});
}
});

View File

@ -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;
};

View File

@ -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);
})
};