wallet-core: Add 'deposited' field to deposit transaction

This field indicates whether the POST requests to deposit coins went
through with the exchange.

We also don't consider a deposit transaction as having lifeness when it
is already deposited and we're just querying for informational deposit
tracking information.
This commit is contained in:
Florian Dold 2023-01-18 19:30:48 +01:00
parent 5e129abe9e
commit 598de5b0d5
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
5 changed files with 25 additions and 4 deletions

View File

@ -54,11 +54,10 @@ export async function runDepositTest(t: GlobalTestState) {
WalletApiOperation.GetTransactions, WalletApiOperation.GetTransactions,
{}, {},
); );
console.log("transactions", JSON.stringify(transactions, undefined, 2)); console.log("transactions", JSON.stringify(transactions, undefined, 2));
t.assertDeepEqual(transactions.transactions[0].type, "withdrawal"); t.assertDeepEqual(transactions.transactions[0].type, "withdrawal");
t.assertTrue(!transactions.transactions[0].pending);
t.assertDeepEqual(transactions.transactions[1].type, "deposit"); t.assertDeepEqual(transactions.transactions[1].type, "deposit");
t.assertTrue(!transactions.transactions[1].pending);
// The raw amount is what ends up on the bank account, which includes // The raw amount is what ends up on the bank account, which includes
// deposit and wire fees. // deposit and wire fees.
t.assertDeepEqual(transactions.transactions[1].amountRaw, "TESTKUDOS:9.79"); t.assertDeepEqual(transactions.transactions[1].amountRaw, "TESTKUDOS:9.79");

View File

@ -550,6 +550,11 @@ export interface TransactionDeposit extends TransactionCommon {
wireTransferDeadline: TalerProtocolTimestamp; wireTransferDeadline: TalerProtocolTimestamp;
wireTransferProgress: number; wireTransferProgress: number;
/**
* Did all the deposit requests succeed?
*/
deposited: boolean;
} }
export interface TransactionByIdRequest { export interface TransactionByIdRequest {

View File

@ -21,7 +21,6 @@ import {
AbsoluteTime, AbsoluteTime,
AmountJson, AmountJson,
Amounts, Amounts,
bytesToString,
CancellationToken, CancellationToken,
canonicalJson, canonicalJson,
codecForDepositSuccess, codecForDepositSuccess,
@ -457,6 +456,8 @@ export async function prepareDepositGroup(
effectiveDepositAmount: Amounts.stringify(effectiveDepositAmount), effectiveDepositAmount: Amounts.stringify(effectiveDepositAmount),
}; };
} }
export async function createDepositGroup( export async function createDepositGroup(
ws: InternalWalletState, ws: InternalWalletState,
req: CreateDepositGroupRequest, req: CreateDepositGroupRequest,

View File

@ -200,13 +200,22 @@ async function gatherDepositPending(
if (dg.timestampFinished) { if (dg.timestampFinished) {
return; return;
} }
let deposited = true;
for (const d of dg.depositedPerCoin) {
if (!d) {
deposited = false;
}
}
const opId = RetryTags.forDeposit(dg); const opId = RetryTags.forDeposit(dg);
const retryRecord = await tx.operationRetries.get(opId); const retryRecord = await tx.operationRetries.get(opId);
const timestampDue = retryRecord?.retryInfo.nextRetry ?? AbsoluteTime.now(); const timestampDue = retryRecord?.retryInfo.nextRetry ?? AbsoluteTime.now();
resp.pendingOperations.push({ resp.pendingOperations.push({
type: PendingTaskType.Deposit, type: PendingTaskType.Deposit,
...getPendingCommon(ws, opId, timestampDue), ...getPendingCommon(ws, opId, timestampDue),
givesLifeness: true, // Fully deposited operations don't give lifeness,
// because there is no reason to wait on the
// deposit tracking status.
givesLifeness: !deposited,
depositGroupId: dg.depositGroupId, depositGroupId: dg.depositGroupId,
lastError: retryRecord?.lastError, lastError: retryRecord?.lastError,
retryInfo: retryRecord?.retryInfo, retryInfo: retryRecord?.retryInfo,

View File

@ -557,6 +557,12 @@ function buildTransactionForDeposit(
dg: DepositGroupRecord, dg: DepositGroupRecord,
ort?: OperationRetryRecord, ort?: OperationRetryRecord,
): Transaction { ): Transaction {
let deposited = true;
for (const d of dg.depositedPerCoin) {
if (!d) {
deposited = false;
}
}
return { return {
type: TransactionType.Deposit, type: TransactionType.Deposit,
amountRaw: Amounts.stringify(dg.effectiveDepositAmount), amountRaw: Amounts.stringify(dg.effectiveDepositAmount),
@ -581,6 +587,7 @@ function buildTransactionForDeposit(
)) / )) /
dg.transactionPerCoin.length, dg.transactionPerCoin.length,
depositGroupId: dg.depositGroupId, depositGroupId: dg.depositGroupId,
deposited,
...(ort?.lastError ? { error: ort.lastError } : {}), ...(ort?.lastError ? { error: ort.lastError } : {}),
}; };
} }