Merge pull request #673 from yemel/feature/proposal-comments

Add user comment to transaction propossal
This commit is contained in:
Manuel Aráoz 2014-06-13 11:30:12 -03:00
commit 8d3ebcc0e2
8 changed files with 93 additions and 15 deletions

View file

@ -107,7 +107,7 @@ PublicKeyRing.prototype.nicknameForIndex = function(index) {
};
PublicKeyRing.prototype.nicknameForCopayer = function(copayerId) {
return this.nicknameFor[copayerId];
return this.nicknameFor[copayerId] || 'NN';
};
PublicKeyRing.prototype.addCopayer = function(newEpk, nickname) {

View file

@ -20,6 +20,7 @@ function TxProposal(opts) {
this.sentTs = opts.sentTs || null;
this.sentTxid = opts.sentTxid || null;
this.inputChainPaths = opts.inputChainPaths || [];
this.comment = opts.comment || null;
}
TxProposal.prototype.toObj = function() {

View file

@ -620,7 +620,7 @@ Wallet.prototype.getUnspent = function(cb) {
};
Wallet.prototype.createTx = function(toAddress, amountSatStr, opts, cb) {
Wallet.prototype.createTx = function(toAddress, amountSatStr, comment, opts, cb) {
var self = this;
if (typeof opts === 'function') {
cb = opts;
@ -633,7 +633,7 @@ Wallet.prototype.createTx = function(toAddress, amountSatStr, opts, cb) {
}
this.getUnspent(function(err, safeUnspent) {
var ntxid = self.createTxSync(toAddress, amountSatStr, safeUnspent, opts);
var ntxid = self.createTxSync(toAddress, amountSatStr, comment, safeUnspent, opts);
if (ntxid) {
self.sendIndexes();
self.sendTxProposals(null, ntxid);
@ -644,7 +644,7 @@ Wallet.prototype.createTx = function(toAddress, amountSatStr, opts, cb) {
});
};
Wallet.prototype.createTxSync = function(toAddress, amountSatStr, utxos, opts) {
Wallet.prototype.createTxSync = function(toAddress, amountSatStr, comment, utxos, opts) {
var pkr = this.publicKeyRing;
var priv = this.privateKey;
opts = opts || {};
@ -655,6 +655,10 @@ Wallet.prototype.createTxSync = function(toAddress, amountSatStr, utxos, opts) {
throw new Error('publicKeyRing is not complete');
}
if (comment && comment.length > 100) {
throw new Error("comment can't be longer that 100 characters");
}
if (!opts.remainderOut) {
opts.remainderOut = {
address: this._doGenerateAddress(true).toString()
@ -695,6 +699,7 @@ Wallet.prototype.createTxSync = function(toAddress, amountSatStr, utxos, opts) {
creator: myId,
createdTs: now,
builder: b,
comment: comment
};
var ntxid = this.txProposals.add(data);