fix coin selection issue
This commit is contained in:
parent
834b89547b
commit
8db3e73606
@ -4,8 +4,8 @@
|
|||||||
"name": "GNU Taler Wallet (git)",
|
"name": "GNU Taler Wallet (git)",
|
||||||
"description": "Privacy preserving and transparent payments",
|
"description": "Privacy preserving and transparent payments",
|
||||||
"author": "GNU Taler Developers",
|
"author": "GNU Taler Developers",
|
||||||
"version": "0.6.29",
|
"version": "0.6.30",
|
||||||
"version_name": "0.1.5",
|
"version_name": "0.1.6",
|
||||||
|
|
||||||
"minimum_chrome_version": "49",
|
"minimum_chrome_version": "49",
|
||||||
"minimum_opera_version": "36",
|
"minimum_opera_version": "36",
|
||||||
|
@ -246,10 +246,16 @@ export function selectCoins(cds: CoinWithDenom[], paymentAmount: AmountJson,
|
|||||||
let coversAmountWithFee = false;
|
let coversAmountWithFee = false;
|
||||||
for (let i = 0; i < cds.length; i++) {
|
for (let i = 0; i < cds.length; i++) {
|
||||||
let {coin, denom} = cds[i];
|
let {coin, denom} = cds[i];
|
||||||
cdsResult.push(cds[i]);
|
if (coin.suspended) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (coin.dirty) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (Amounts.cmp(denom.feeDeposit, coin.currentAmount) >= 0) {
|
if (Amounts.cmp(denom.feeDeposit, coin.currentAmount) >= 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
cdsResult.push(cds[i]);
|
||||||
accFee = Amounts.add(denom.feeDeposit, accFee).amount;
|
accFee = Amounts.add(denom.feeDeposit, accFee).amount;
|
||||||
accAmount = Amounts.add(coin.currentAmount, accAmount).amount;
|
accAmount = Amounts.add(coin.currentAmount, accAmount).amount;
|
||||||
coversAmount = Amounts.cmp(accAmount, paymentAmount) >= 0;
|
coversAmount = Amounts.cmp(accAmount, paymentAmount) >= 0;
|
||||||
@ -518,6 +524,12 @@ export class Wallet {
|
|||||||
if (coin.suspended) {
|
if (coin.suspended) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (coin.dirty) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (coin.transactionPending) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
cds.push({coin, denom});
|
cds.push({coin, denom});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -933,6 +945,7 @@ export class Wallet {
|
|||||||
*/
|
*/
|
||||||
private async depleteReserve(reserve: ReserveRecord,
|
private async depleteReserve(reserve: ReserveRecord,
|
||||||
exchange: ExchangeRecord): Promise<number> {
|
exchange: ExchangeRecord): Promise<number> {
|
||||||
|
console.log("depleting reserve");
|
||||||
if (!reserve.current_amount) {
|
if (!reserve.current_amount) {
|
||||||
throw Error("can't withdraw when amount is unknown");
|
throw Error("can't withdraw when amount is unknown");
|
||||||
}
|
}
|
||||||
@ -943,6 +956,8 @@ export class Wallet {
|
|||||||
let denomsForWithdraw = await this.getVerifiedWithdrawDenomList(exchange.baseUrl,
|
let denomsForWithdraw = await this.getVerifiedWithdrawDenomList(exchange.baseUrl,
|
||||||
currentAmount);
|
currentAmount);
|
||||||
|
|
||||||
|
console.log(`withdrawing ${denomsForWithdraw.length} coins`);
|
||||||
|
|
||||||
let ps = denomsForWithdraw.map(async(denom) => {
|
let ps = denomsForWithdraw.map(async(denom) => {
|
||||||
function mutateReserve(r: ReserveRecord): ReserveRecord {
|
function mutateReserve(r: ReserveRecord): ReserveRecord {
|
||||||
let currentAmount = r.current_amount;
|
let currentAmount = r.current_amount;
|
||||||
@ -1343,8 +1358,6 @@ export class Wallet {
|
|||||||
(x) => x.baseUrl)
|
(x) => x.baseUrl)
|
||||||
.reduce(collectSmallestWithdraw, {}));
|
.reduce(collectSmallestWithdraw, {}));
|
||||||
|
|
||||||
console.log("smallest withdraws", smallestWithdraw);
|
|
||||||
|
|
||||||
let tx = this.q();
|
let tx = this.q();
|
||||||
tx.iter(Stores.coins)
|
tx.iter(Stores.coins)
|
||||||
.reduce(collectBalances, balance);
|
.reduce(collectBalances, balance);
|
||||||
|
Loading…
Reference in New Issue
Block a user