mirror of https://github.com/BTCPrivate/copay.git
fix callback in sent
This commit is contained in:
parent
342b9bd937
commit
7f20106d71
|
@ -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>
|
||||
|
|
|
@ -9,9 +9,10 @@ angular.module('copay.addresses').controller('AddressesController',
|
|||
var w = $rootScope.wallet;
|
||||
|
||||
var _updateBalance = function () {
|
||||
w.getBalance(function (balance, balanceByAddr) {
|
||||
w.getBalance(function (balance, balanceByAddr, isMain) {
|
||||
if (balanceByAddr && Object.keys(balanceByAddr).length) {
|
||||
$scope.balanceByAddr = balanceByAddr;
|
||||
$scope.isMain = isMain;
|
||||
$scope.addrs = Object.keys(balanceByAddr);
|
||||
$scope.selectedAddr = $scope.addrs[0];
|
||||
$scope.$digest();
|
||||
|
|
|
@ -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});
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue