add more tests and fix some bugs

This commit is contained in:
Manuel Araoz 2014-06-09 17:28:56 -03:00
commit 697dea673a
6 changed files with 129 additions and 27 deletions

View file

@ -32,6 +32,7 @@ function Wallet(opts) {
this.id = opts.id || Wallet.getRandomId();
this.name = opts.name;
this.netKey = opts.netKey || SecureRandom.getRandomBuffer(8).toString('base64');
this.networkName = opts.networkName;
// Renew token every 24hs
if (opts.tokenTime && new Date().getTime() - opts.tokenTime < 86400000) {
@ -318,7 +319,7 @@ Wallet.prototype.toObj = function() {
opts: optsObj,
publicKeyRing: this.publicKeyRing.toObj(),
txProposals: this.txProposals.toObj(),
privateKey: this.privateKey.toObj()
privateKey: this.privateKey?this.privateKey.toObj():undefined
};
return walletObj;
@ -459,7 +460,6 @@ Wallet.prototype.sign = function(ntxid, cb) {
var txp = self.txProposals.txps[ntxid];
if (!txp || txp.rejectedBy[myId] || txp.signedBy[myId]) {
if (cb) cb(false);
throw new Error('Invalid transaction to sign: '+ntxid);
}
var pkr = self.publicKeyRing;