fix conflict

This commit is contained in:
Mario Colque 2014-04-21 11:41:49 -03:00
commit ded325af46
6 changed files with 27 additions and 18 deletions

View File

@ -215,7 +215,11 @@
<h3>Address</h3>
<div class="row">
<div class="large-6 columns">
<a class="panel db" ng-repeat="addr in addrs" ng-click="selectAddr(addr)">{{addr}} <span class="right">{{balanceByAddr[addr] || 0}} <i class="fi-bitcoin"></i></span></a>
<a class="panel db" ng-repeat="addr in addrs" ng-click="selectAddr(addr)">{{addr}}
<span ng-if="!isMain[addr]">(change)</span>
<span class="right">{{balanceByAddr[addr] || 0}} <i class="fi-bitcoin"></i></span></a>
</div>
<div class="large-3 columns line-dashed-v text-center">
<qrcode size="160" data="{{selectedAddr}}"></qrcode>

View File

@ -11,9 +11,10 @@ angular.module('copay.addresses').controller('AddressesController',
var _updateBalance = function () {
controllerUtils.setSocketHandlers();
w.getBalance(function (balance, balanceByAddr) {
w.getBalance(function (balance, balanceByAddr, isMain) {
if (balanceByAddr && Object.keys(balanceByAddr).length) {
$rootScope.balanceByAddr = balanceByAddr;
$scope.isMain = isMain;
$scope.addrs = Object.keys(balanceByAddr);
$scope.selectedAddr = $scope.addrs[0];
$rootScope.$digest();

View File

@ -100,15 +100,9 @@ Insight.prototype._request = function(options, callback) {
if (request.readyState === 4) {
console.log('[Insight.js.102]', request); //TODO
if (request.status === 200) {
try {
return callback(null, JSON.parse(request.responseText));
} catch (e) {
console.log('[Insight.js.106]'); //TODO
return callback({message: 'Wrong response from insight'});
}
} else {
else {
console.log('[Insight.js.111]'); //TODO
return callback({message: 'Error ' + request.status});
}

View File

@ -212,6 +212,7 @@ PublicKeyRing.prototype.getAddresses = function(onlyMain) {
PublicKeyRing.prototype.getRedeemScriptMap = function () {
var ret = {};
console.log('[PublicKeyRing.js.216]', this.changeAddressIndex, this.addressIndex); //TODO
for (var i=0; i<this.changeAddressIndex; i++) {
ret[this.getAddress(i,true)] = this.getRedeemScript(i,true).getBuffer().toString('hex');

View File

@ -32,8 +32,8 @@ TxProposal.prototype.toObj = function() {
TxProposal.prototype.setSent = function(sentTxid) {
this.sentTxid = txid;
this.sentTs = Date.now();;
this.sentTxid = sentTxid;
this.sentTs = Date.now();
};
TxProposal.fromObj = function(o) {

View File

@ -277,8 +277,9 @@ Wallet.prototype.sendPublicKeyRing = function(recipients) {
};
Wallet.prototype.generateAddress = function() {
var addr = this.publicKeyRing.generateAddress();
Wallet.prototype.generateAddress = function(isChange) {
var addr = this.publicKeyRing.generateAddress(isChange);
console.log('[Wallet.js.281:addr:]',addr, this.publicKeyRing.toObj(), this.getAddresses()); //TODO
this.sendPublicKeyRing();
this.store(true);
return addr;
@ -327,6 +328,7 @@ Wallet.prototype.sign = function(ntxid) {
var pkr = self.publicKeyRing;
var keys = self.privateKey.getAll(pkr.addressIndex, pkr.changeAddressIndex);
console.log('[Wallet.js.329:keys:]',keys); //TODO
var b = txp.builder;
var before = b.signaturesAdded;
@ -354,6 +356,7 @@ Wallet.prototype.sendTx = function(ntxid, cb) {
this.log('[Wallet.js.261:txHex:]',txHex); //TODO
var self = this;
this.blockchain.sendRawTransaction(txHex, function(txid) {
self.log('BITCOND txid:',txid); //TODO
if (txid) {
@ -410,6 +413,7 @@ Wallet.prototype.addressIsOwn = function(addrStr) {
Wallet.prototype.getBalance = function(cb) {
var balance = 0;
var balanceByAddr = {};
var isMain = {};
var COIN = bitcore.util.COIN;
var addresses = this.getAddressesStr(true);
@ -418,6 +422,7 @@ Wallet.prototype.getBalance = function(cb) {
// Prefill balanceByAddr with main address
addresses.forEach(function(a){
balanceByAddr[a]=0;
isMain[a]=1;
});
this.getUnspent(function(utxos) {
for(var i=0;i<utxos.length; i++) {
@ -429,7 +434,7 @@ Wallet.prototype.getBalance = function(cb) {
for(var a in balanceByAddr){
balanceByAddr[a] = balanceByAddr[a]/COIN;
};
return cb(balance / COIN, balanceByAddr);
return cb(balance / COIN, balanceByAddr, isMain);
});
};
@ -440,6 +445,7 @@ Wallet.prototype.getUnspent = function(cb) {
};
Wallet.prototype.createTx = function(toAddress, amountSatStr, opts, cb) {
console.log('[Wallet.js.447:createTx:]'); //TODO
var self = this;
if (typeof opts === 'function') {
cb = opts;
@ -472,8 +478,9 @@ Wallet.prototype.createTxSync = function(toAddress, amountSatStr, utxos, opts) {
}
if (!opts.remainderOut) {
opts.remainderOut ={ address: pkr.generateAddress(true).toString() };
};
opts.remainderOut ={ address: this.generateAddress(true).toString() };
}
console.log('[Wallet.js.480:opts: CREATETXSYNC]',opts); //TODO
var b = new Builder(opts)
.setUnspent(utxos)
@ -483,8 +490,10 @@ Wallet.prototype.createTxSync = function(toAddress, amountSatStr, utxos, opts) {
var signRet;
if (priv) {
console.log('[Wallet.js.486] aLL Priv', priv.getAll(pkr.addressIndex, pkr.changeAddressIndex)); //TODO
b.sign( priv.getAll(pkr.addressIndex, pkr.changeAddressIndex) );
}
console.log('[Wallet.js.494]', b, b.build().serialize().toString('hex')); //TODO
var me = {};
var myId = this.getMyPeerId();
var now = Date.now();