addressbook \& tx working again

This commit is contained in:
Matias Alejo Garcia 2014-11-23 16:31:08 -03:00
commit f3f9ca3e33
5 changed files with 14 additions and 27 deletions

View file

@ -258,8 +258,6 @@ angular.module('copayApp.controllers').controller('SendController',
$scope.openScanner = function() {
if (window.cordova) return $scope.scannerIntent();
console.log('[send.js.260] OPENN'); //TODO
$scope.showScanner = true;
// Wait a moment until the canvas shows

View file

@ -208,9 +208,6 @@ Network.prototype._onMessage = function(enc) {
return;
}
log.info('Network message: ', payload.type);
log.debug('Message payload:', payload);
var self = this;
switch (payload.type) {
case 'hello':

View file

@ -44,7 +44,8 @@ function TxProposal(opts) {
var me = {};
me[opts.creator] = now;
this.signedBy = this.seenBy = me;
this.signedBy = me;
this.signedBy = _.clone(me);
this.creator = opts.creator;
this.createdTs = now;
}
@ -84,18 +85,18 @@ TxProposal.prototype._checkPayPro = function() {
TxProposal.prototype.isFullySigned = function() {
return txp.builder && txp.builder.isFullySigned();
return this.builder && this.builder.isFullySigned();
};
TxProposal.prototype.sign = function(keys, signerId) {
var before = txp.countSignatures();
txp.builder.sign(keys);
var before = this.countSignatures();
this.builder.sign(keys);
var signaturesAdded = txp.countSignatures() > before;
var signaturesAdded = this.countSignatures() > before;
if (signaturesAdded){
txp.signedBy[signerId] = Date.now();
this.signedBy[signerId] = Date.now();
}
return signturesAdded;
return signaturesAdded;
};

View file

@ -178,16 +178,6 @@ TxProposals.prototype.getTxProposal = function(ntxid, copayers) {
};
TxProposals.prototype.reject = function(ntxid, copayerId) {
var txp = this.get(ntxid);
txp.setRejected(copayerId);
};
TxProposals.prototype.seen = function(ntxid, copayerId) {
var txp = this.get(ntxid);
txp.setSeen(copayerId);
};
//returns the unspent txid-vout used in PENDING Txs
TxProposals.prototype.getUsedUnspent = function(maxRejectCount) {
var ret = {};

View file

@ -614,11 +614,10 @@ Wallet.prototype._onSeen = function(senderId, data) {
* @emits txProposalEvent
*/
Wallet.prototype._onAddressBook = function(senderId, data) {
if (!data.addressBook || !_.isArray(data.addressBook))
if (!data.addressBook || !_.isObject(data.addressBook))
return;
var self = this, hasChange;
_.each(data.addressBook, function(value, key) {
if (!self.addressBook[key] && Address.validate(key)) {
@ -630,6 +629,7 @@ Wallet.prototype._onAddressBook = function(senderId, data) {
hasChange = true;
}
});
console.log('[Wallet.js.635:hasChange:]',hasChange); //TODO
if (hasChange) {
this.emitAndKeepAlive('addressBookUpdated');
@ -1447,7 +1447,8 @@ Wallet.prototype.purgeTxProposals = function(deleteAll) {
* @emits txProposalsUpdated
*/
Wallet.prototype.reject = function(ntxid) {
var txp = this.txProposals.reject(ntxid, this.getMyCopayerId());
var txp = this.txProposals.get(ntxid);
txp.setRejected(this.getMyCopayerId());
this.sendReject(ntxid);
this.emitAndKeepAlive('txProposalsUpdated');
};
@ -1467,7 +1468,7 @@ Wallet.prototype.sign = function(ntxid) {
var keys = this.privateKey.getForPaths(txp.inputChainPaths);
var signaturesAdded = txp.sign(keys, this.getMyCopayerId());
if (!signturesAdded)
if (!signaturesAdded)
return false;
this.emitAndKeepAlive('txProposalsUpdated');
@ -1477,7 +1478,7 @@ Wallet.prototype.sign = function(ntxid) {
Wallet.prototype.signAndSend = function(ntxid, cb) {
if (this.sign(ntxid)) {
var txp = w.txProposals.get(ntxid);
var txp = this.txProposals.get(ntxid);
if (txp.isFullySigned()) {
return this.broadcastTx(ntxid, cb);
} else {