wallet-core: work around missing timestamp in legacy transaction

This commit is contained in:
Florian Dold 2023-04-13 15:58:38 +02:00
parent b96464fe09
commit b567ba4668
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
3 changed files with 19 additions and 2 deletions

View File

@ -162,6 +162,7 @@ advancedCli
await runTestWithState(testState, runEnv1, "env1", true); await runTestWithState(testState, runEnv1, "env1", true);
}); });
const sandcastleCli = testingCli.subcommand("sandcastleArgs", "sandcastle", { const sandcastleCli = testingCli.subcommand("sandcastleArgs", "sandcastle", {
help: "Subcommands for handling GNU Taler sandcastle deployments.", help: "Subcommands for handling GNU Taler sandcastle deployments.",
}); });

View File

@ -38,6 +38,7 @@ import {
setGlobalLogLevelFromString, setGlobalLogLevelFromString,
summarizeTalerErrorDetail, summarizeTalerErrorDetail,
TalerUriType, TalerUriType,
Transaction,
WalletNotification, WalletNotification,
} from "@gnu-taler/taler-util"; } from "@gnu-taler/taler-util";
import { clk } from "@gnu-taler/taler-util/clk"; import { clk } from "@gnu-taler/taler-util/clk";
@ -1128,6 +1129,16 @@ const advancedCli = walletCli.subcommand("advancedArgs", "advanced", {
help: "Subcommands for advanced operations (only use if you know what you're doing!).", help: "Subcommands for advanced operations (only use if you know what you're doing!).",
}); });
advancedCli
.subcommand("sampleTransactions", "sample-transactions", {
help: "Print sample wallet-core transactions",
})
.action(async (args) => {
let transactions: Transaction[] = [
];
});
advancedCli advancedCli
.subcommand("serve", "serve", { .subcommand("serve", "serve", {
help: "Serve the wallet API via a unix domain socket.", help: "Serve the wallet API via a unix domain socket.",

View File

@ -525,7 +525,8 @@ function buildTransactionForPeerPullCredit(
? ExtendedStatus.Done ? ExtendedStatus.Done
: ExtendedStatus.Pending, : ExtendedStatus.Pending,
pending: !wsr.timestampFinish, pending: !wsr.timestampFinish,
timestamp: pullCredit.mergeTimestamp, // Old transactions don't have it!
timestamp: pullCredit.mergeTimestamp ?? TalerProtocolTimestamp.now(),
info: { info: {
expiration: wsr.wgInfo.contractTerms.purse_expiration, expiration: wsr.wgInfo.contractTerms.purse_expiration,
summary: wsr.wgInfo.contractTerms.summary, summary: wsr.wgInfo.contractTerms.summary,
@ -558,7 +559,8 @@ function buildTransactionForPeerPullCredit(
exchangeBaseUrl: pullCredit.exchangeBaseUrl, exchangeBaseUrl: pullCredit.exchangeBaseUrl,
extendedStatus: ExtendedStatus.Pending, extendedStatus: ExtendedStatus.Pending,
pending: true, pending: true,
timestamp: pullCredit.mergeTimestamp, // Old transactions don't have it!
timestamp: pullCredit.mergeTimestamp ?? TalerProtocolTimestamp.now(),
info: { info: {
expiration: peerContractTerms.purse_expiration, expiration: peerContractTerms.purse_expiration,
summary: peerContractTerms.summary, summary: peerContractTerms.summary,
@ -1387,6 +1389,9 @@ export async function getTransactions(
if (!tx.amountRaw) { if (!tx.amountRaw) {
logger.warn(`missing amountRaw in ${j2s(tx)}`); logger.warn(`missing amountRaw in ${j2s(tx)}`);
} }
if (!tx.timestamp) {
logger.warn(`missing timestamp in ${j2s(tx)}`);
}
} }
const txPending = transactions.filter((x) => x.pending); const txPending = transactions.filter((x) => x.pending);