fix conflicts

This commit is contained in:
Mario Colque 2014-04-20 17:18:20 -03:00
commit 74f7271310
28 changed files with 653 additions and 761 deletions

View file

@ -10,11 +10,12 @@ angular.module('copay.home').controller('HomeController',
var _updateBalance = function () {
w.getBalance(function (balance, balanceByAddr) {
$rootScope.$apply(function() {
$rootScope.balanceByAddr = balanceByAddr;
if (balanceByAddr && Object.keys(balanceByAddr).length) {
$scope.balanceByAddr = balanceByAddr;
$scope.addrs = Object.keys(balanceByAddr);
$scope.selectedAddr = $scope.addrs[0];
});
$scope.$digest();
}
});
};
@ -30,4 +31,5 @@ angular.module('copay.home').controller('HomeController',
};
_updateBalance();
w.on('refresh',_updateBalance);
});

View file

@ -4,8 +4,35 @@ angular.module('copay.send').controller('SendController',
function($scope, $rootScope, $location) {
$scope.title = 'Send';
$scope.unitIds = ['BTC','mBTC'];
$scope.selectedUnit = $scope.unitIds[0];
$scope.submitForm = function(form) {
if (form.$invalid) {
$rootScope.flashMessage = { message: 'You can not send a proposal transaction. Please, try again', type: 'error'};
return;
}
var address = form.address.$modelValue;
var amount = (form.amount.$modelValue * 100000000).toString(); // satoshi to string
var w = $rootScope.wallet;
w.createTx( address, amount,function() {
$rootScope.$digest();
});
// reset fields
$scope.address = null;
$scope.amount = null;
form.address.$pristine = true;
form.amount.$pristine = true;
// TODO: check if createTx has an error.
$rootScope.flashMessage = { message: 'You send a proposal transaction succefully', type: 'success'};
};
$scope.sendTest = function() {
var w = $rootScope.wallet;
var w = $rootScope.wallet;
w.createTx( 'mimoZNLcP2rrMRgdeX5PSnR7AjCqQveZZ4', '12345',function() {
$rootScope.$digest();
});

View file

@ -34,7 +34,6 @@ angular.module('copay.setup').controller('SetupController',
};
var w = walletFactory.create(opts);
controllerUtils.setupUxHandlers(w);
w.netStart();
};
});

View file

@ -10,23 +10,26 @@ angular.module('copay.signin').controller('SigninController',
$location.path('setup');
};
$scope.open = function(walletId) {
$scope.open = function(walletId, opts) {
$scope.loading = true;
var w = walletFactory.open(walletId);
console.log('[signin.js.23:walletId:]',walletId); //TODO
var w = walletFactory.open(walletId, opts);
controllerUtils.setupUxHandlers(w);
w.netStart();
};
$scope.join = function(peerId) {
$scope.join = function(secret) {
$scope.loading = true;
walletFactory.network.on('openError', function() {
controllerUtils.onError($scope);
$rootScope.$digest();
walletFactory.network.on('joinError', function() {
controllerUtils.onErrorDigest($scope);
});
walletFactory.connectTo(peerId, function(w) {
walletFactory.joinCreateSession(secret, function(w) {
console.log('[signin.js.33] joinCreateSession RETURN', w); //TODO
controllerUtils.setupUxHandlers(w);
w.netStart();
w.setupNetHandlers();
});
};
});

View file

@ -1,4 +1,5 @@
'use strict';
var bitcore = require('bitcore');
angular.module('copay.transactions').controller('TransactionsController',
function($scope, $rootScope, $location) {
@ -9,7 +10,7 @@ angular.module('copay.transactions').controller('TransactionsController',
var _updateTxs = function() {
var w =$rootScope.wallet;
var inT = w.getTxProposals();
var ts = [];
var txs = [];
inT.forEach(function(i){
var b = i.txp.builder;
@ -18,28 +19,49 @@ angular.module('copay.transactions').controller('TransactionsController',
feeSat: b.feeSat,
};
var outs = [];
var bitcore = require('bitcore');
tx.outs.forEach(function(o) {
var s = o.getScript();
var aStr = bitcore.Address.fromScript(s, config.networkName).toString();
if (!w.addressIsOwn(aStr))
var addr = bitcore.Address.fromScriptPubKey(o.getScript(), config.networkName)[0].toString();
if (!w.addressIsOwn(addr)) {
outs.push({
address: aStr,
address: addr,
value: bitcore.util.valueToBigInt(o.getValue())/bitcore.util.COIN,
});
}
});
one.outs = outs;
ts.push(one);
});
$scope.txs = ts;
};
_updateTxs();
// TOD: check missingSignatures === in al inputs?
one.missingSignatures = tx.countInputMissingSignatures(0);
one.signedByUs = i.signedByUs;
one.ntxid = i.ntxid;
one.creator = i.txp.creator,
one.createdTs = i.txp.createdTs;
txs.push(one);
});
$scope.txs = txs;
};
$scope.sign = function (ntxid) {
var w = $rootScope.wallet;
var ret = w.sign(ntxid);
$rootScope.flashMessage = {type:'success', message: 'Transactions SEND! : ' + ret};
_updateTxs();
var p = w.getTxProposal(ntxid);
if (p.txp.builder.isFullySigned()) {
w.sendTx(ntxid, function(txid) {
$rootScope.flashMessage = txid
? {type:'success', message: 'Transactions SENT! txid:' + txid}
: {type:'error', message: 'There was an error sending the Transaction'}
;
});
}
else {
$rootScope.flashMessage = ret
? {type:'success', message: 'Transactions signed'}
: {type:'error', message: 'There was an error signing the Transaction'}
;
}
_updateTxs();
};
});