[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-wallet-core] branch master updated: fix bug in withdrawal operati
From: |
gnunet |
Subject: |
[taler-wallet-core] branch master updated: fix bug in withdrawal operation state machine, allow manual reserve update from CLI |
Date: |
Mon, 16 Mar 2020 12:48:51 +0100 |
This is an automated email from the git hooks/post-receive script.
dold pushed a commit to branch master
in repository wallet-core.
The following commit(s) were added to refs/heads/master by this push:
new 9e2be07c fix bug in withdrawal operation state machine, allow manual
reserve update from CLI
9e2be07c is described below
commit 9e2be07cfc2267f817c22105ad2a147bc7f8c33e
Author: Florian Dold <address@hidden>
AuthorDate: Mon Mar 16 17:18:46 2020 +0530
fix bug in withdrawal operation state machine, allow manual reserve update
from CLI
---
src/headless/taler-wallet-cli.ts | 12 ++++++++++++
src/operations/reserves.ts | 10 +++++++---
src/wallet.ts | 6 ++++++
3 files changed, 25 insertions(+), 3 deletions(-)
diff --git a/src/headless/taler-wallet-cli.ts b/src/headless/taler-wallet-cli.ts
index 28618bcc..2a104063 100644
--- a/src/headless/taler-wallet-cli.ts
+++ b/src/headless/taler-wallet-cli.ts
@@ -374,6 +374,18 @@ advancedCli
});
});
+ advancedCli
+ .subcommand("updateReserve", "update-reserve", {
+ help: "Update reserve status.",
+ })
+ .requiredArgument("reservePub", clk.STRING)
+ .action(async args => {
+ await withWallet(args, async wallet => {
+ const r = await wallet.updateReserve(args.updateReserve.reservePub);
+ console.log("updated reserve:", JSON.stringify(r, undefined, 2));
+ });
+ });
+
const testCli = walletCli.subcommand("testingArgs", "testing", {
help: "Subcommands for testing GNU Taler deployments.",
});
diff --git a/src/operations/reserves.ts b/src/operations/reserves.ts
index efca08a4..d19d069a 100644
--- a/src/operations/reserves.ts
+++ b/src/operations/reserves.ts
@@ -228,7 +228,7 @@ export async function forceQueryReserve(
await tx.put(Stores.reserves, reserve);
});
- await processReserve(ws, reservePub);
+ await processReserve(ws, reservePub, true);
}
/**
@@ -490,6 +490,7 @@ async function updateReserve(
reserveUpdateId,
};
await tx.put(Stores.reserveUpdatedEvents, reserveUpdate);
+ r.reserveStatus = ReserveRecordStatus.WITHDRAWING;
} else {
const expectedBalance = Amounts.sub(
r.amountWithdrawAllocated,
@@ -497,7 +498,8 @@ async function updateReserve(
);
const cmp = Amounts.cmp(balance, expectedBalance.amount);
if (cmp == 0) {
- // Nothing changed.
+ // Nothing changed, go back to sleep!
+ r.reserveStatus = ReserveRecordStatus.DORMANT;
return;
}
if (cmp > 0) {
@@ -506,8 +508,10 @@ async function updateReserve(
r.amountWithdrawRemaining,
extra,
).amount;
+ r.reserveStatus = ReserveRecordStatus.WITHDRAWING;
} else {
// We're missing some money.
+ r.reserveStatus = ReserveRecordStatus.DORMANT;
}
const reserveUpdate: ReserveUpdatedEventRecord = {
reservePub: r.reservePub,
@@ -520,12 +524,12 @@ async function updateReserve(
await tx.put(Stores.reserveUpdatedEvents, reserveUpdate);
}
r.lastSuccessfulStatusQuery = getTimestampNow();
- r.reserveStatus = ReserveRecordStatus.WITHDRAWING;
r.retryInfo = initRetryInfo();
r.reserveTransactions = reserveInfo.history;
await tx.put(Stores.reserves, r);
},
);
+ console.log("updated reserve");
ws.notify({ type: NotificationType.ReserveUpdated });
}
diff --git a/src/wallet.ts b/src/wallet.ts
index 9cba1360..29114376 100644
--- a/src/wallet.ts
+++ b/src/wallet.ts
@@ -85,6 +85,7 @@ import {
import {
processReserve,
createTalerWithdrawReserve,
+ forceQueryReserve,
} from "./operations/reserves";
import { InternalWalletState } from "./operations/state";
@@ -714,6 +715,11 @@ export class Wallet {
}
}
+ async updateReserve(reservePub: string): Promise<ReserveRecord | undefined> {
+ await forceQueryReserve(this.ws, reservePub);
+ return await this.ws.db.get(Stores.reserves, reservePub);
+ }
+
async refuseProposal(proposalId: string): Promise<void> {
return refuseProposal(this.ws, proposalId);
}
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-wallet-core] branch master updated: fix bug in withdrawal operation state machine, allow manual reserve update from CLI,
gnunet <=