Browse Source

sign 3

activeAddress
Matias Alejo Garcia 10 years ago
parent
commit
0af48ff27b
  1. 6
      app.js
  2. 13
      bit-wallet/bit-sign
  3. 19
      bit-wallet/bit-status
  4. 18
      lib/clientlib.js
  5. 3
      lib/server.js

6
app.js

@ -194,9 +194,9 @@ router.get('/v1/balance/', function(req, res) {
}); });
}); });
router.post('/v1/txproposals/:id/signatures', function(req, res) { router.post('/v1/txproposals/:id/signatures/', function(req, res) {
req.body.txProposalId = req.params['id'];
getServerWithAuth(req, res, function(server) { getServerWithAuth(req, res, function(server) {
req.body.txProposalId = req.params['id'];
server.signTx(req.body, function(err, txp) { server.signTx(req.body, function(err, txp) {
if (err) return returnError(err, res, req); if (err) return returnError(err, res, req);
res.end(); res.end();
@ -205,8 +205,8 @@ router.post('/v1/txproposals/:id/signatures', function(req, res) {
}); });
router.post('/v1/txproposals/:id/rejections', function(req, res) { router.post('/v1/txproposals/:id/rejections', function(req, res) {
req.body.txProposalId = req.params['id'];
getServerWithAuth(req, res, function(server) { getServerWithAuth(req, res, function(server) {
req.body.txProposalId = req.params['id'];
server.signTx(req.body, function(err, txp) { server.signTx(req.body, function(err, txp) {
if (err) return returnError(err, res, req); if (err) return returnError(err, res, req);
res.end(); res.end();

13
bit-wallet/bit-sign

@ -33,13 +33,20 @@ cli.txProposals({}, function(err, x) {
}); });
if (!txps.length) if (!txps.length)
common.die('Could not find TX Proposal:' + txpid); common.die('Could not find TX Proposal:' + txpid);
if (txps.length > 1) 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; return x.id;
}).join(' '));; }).join(' '));;
var txp = txps[0]; 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.');
});
}); });

19
bit-wallet/bit-status

@ -26,13 +26,20 @@ cli.status(function(err, res) {
var x = res.balance; var x = res.balance;
console.log('* Balance %d (Locked: %d)', x.totalAmount, x.lockedAmount); console.log('* Balance %d (Locked: %d)', x.totalAmount, x.lockedAmount);
if (! _.isEmpty(res.pendingTxps)) { if (!_.isEmpty(res.pendingTxps)) {
console.log("* TX Proposals:") console.log("* TX Proposals:")
_.each(res.pendingTxps, function(x){ _.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
}); });
} }
if (program.verbose)
console.log('* Raw Server Response:\n', res); //TODO
}); });

18
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; var self = this;
data = data || {}; data = data || {};
@ -143,7 +143,7 @@ ClientLib.prototype._joinWallet = function(data, secret, copayerName, cb) {
var walletPrivKey = Bitcore.PrivateKey.fromString(secretSplit[1]); var walletPrivKey = Bitcore.PrivateKey.fromString(secretSplit[1]);
var network = secretSplit[2] == 'T' ? 'testnet' : 'livenet'; var network = secretSplit[2] == 'T' ? 'testnet' : 'livenet';
data.xPrivKey = _createXPrivKey(network); data.xPrivKey = _createXPrivKey(network);
var xPubKey = new Bitcore.HDPublicKey(data.xPrivKey); var xPubKey = new Bitcore.HDPublicKey(data.xPrivKey);
var xPubKeySignature = SignUtils.sign(xPubKey.toString(), walletPrivKey); var xPubKeySignature = SignUtils.sign(xPubKey.toString(), walletPrivKey);
@ -434,12 +434,17 @@ ClientLib.prototype.sign = function(txp, cb) {
signatures.push(s); signatures.push(s);
}); });
var url = '/v1//'; var url = '/v1/txproposals/' + txp.id + '/signatures/';
var signature = _signRequest(url, args, data.signingPrivKey); var args = {
signatures: signatures
};
var reqSignature = _signRequest(url, args, data.signingPrivKey);
console.log('[clientlib.js.441:reqSignature:]',url, args, reqSignature); //TODO
request({ request({
headers: { headers: {
'x-identity': data.copayerId, 'x-identity': data.copayerId,
'x-signature': signature, 'x-signature': reqSignature,
}, },
method: 'post', method: 'post',
url: _getUrl(url), url: _getUrl(url),
@ -453,9 +458,6 @@ ClientLib.prototype.sign = function(txp, cb) {
} }
return cb(null, body); return cb(null, body);
}); });
return signatures;
}; };

3
lib/server.js

@ -374,7 +374,6 @@ CopayServer.prototype._getUtxos = function(cb) {
utxo.path = addressToPath[utxo.address].path; utxo.path = addressToPath[utxo.address].path;
utxo.publicKeys = addressToPath[utxo.address].publicKeys; utxo.publicKeys = addressToPath[utxo.address].publicKeys;
}); });
console.log('[server.js.375:utxos:]', utxos); //TODO
return cb(null, utxos); return cb(null, utxos);
}); });
@ -586,7 +585,9 @@ CopayServer.prototype.removePendingTx = function(opts, cb) {
CopayServer.prototype._broadcastTx = function(txp, cb) { CopayServer.prototype._broadcastTx = function(txp, cb) {
var raw = txp.getRawTx(); var raw = txp.getRawTx();
var bc = this._getBlockExplorer('insight', txp.getNetworkName()); var bc = this._getBlockExplorer('insight', txp.getNetworkName());
console.log('[server.js.588:raw:]',raw); //TODO
bc.broadcast(raw, function(err, txid) { bc.broadcast(raw, function(err, txid) {
console.log('[server.js.589:err:]',err, txid); //TODO
return cb(err, txid); return cb(err, txid);
}) })
}; };

Loading…
Cancel
Save