mirror of https://github.com/BTCPrivate/copay.git
Fix refactory for createTx.
This commit is contained in:
parent
f55d243bed
commit
f5fd03ad3c
|
@ -285,9 +285,9 @@ Wallet.prototype.getTotalBalance = function(cb) {
|
||||||
|
|
||||||
Wallet.prototype.getBalance = function(addrs, cb) {
|
Wallet.prototype.getBalance = function(addrs, cb) {
|
||||||
var balance = 0;
|
var balance = 0;
|
||||||
this.listUnspent(addrs, function(unspent) {
|
this.listUnspent(addrs, function(utxos) {
|
||||||
for(var i=0;i<unspent.length; i++) {
|
for(var i=0;i<utxos.length; i++) {
|
||||||
balance = balance + unspent[i].amount;
|
balance = balance + utxos[i].amount;
|
||||||
}
|
}
|
||||||
if (balance) {
|
if (balance) {
|
||||||
if (balance === parseInt(balance)) {
|
if (balance === parseInt(balance)) {
|
||||||
|
@ -302,11 +302,8 @@ Wallet.prototype.getBalance = function(addrs, cb) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Wallet.prototype.listUnspent = function(addrs, cb) {
|
Wallet.prototype.listUnspent = function(addrs, cb) {
|
||||||
if (!addrs) {
|
this.blockchain.listUnspent(addrs, function(utxos) {
|
||||||
addrs = this.getAddressesStr();
|
return cb(utxos);
|
||||||
}
|
|
||||||
this.blockchain.listUnspent(addrs, function(unspent) {
|
|
||||||
return cb(unspent);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -327,7 +324,7 @@ Wallet.prototype.createTx = function(toAddress, amountSatStr, opts, cb) {
|
||||||
opts.remainderOut={ address: this.publicKeyRing.generateAddress(true).toString()};
|
opts.remainderOut={ address: this.publicKeyRing.generateAddress(true).toString()};
|
||||||
}
|
}
|
||||||
|
|
||||||
self.listUnspent(function(utxos) {
|
self.listUnspent(self.getAddressesStr(), function(utxos) {
|
||||||
// TODO check enough funds, etc.
|
// TODO check enough funds, etc.
|
||||||
self.createTxSync(toAddress, amountSatStr, utxos, opts);
|
self.createTxSync(toAddress, amountSatStr, utxos, opts);
|
||||||
self.store();
|
self.store();
|
||||||
|
|
Loading…
Reference in New Issue