diff options
Diffstat (limited to 'packages/taler-wallet-core/src/operations/withdraw.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/withdraw.ts | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/packages/taler-wallet-core/src/operations/withdraw.ts b/packages/taler-wallet-core/src/operations/withdraw.ts index 47252a7e4..f2152ccbc 100644 --- a/packages/taler-wallet-core/src/operations/withdraw.ts +++ b/packages/taler-wallet-core/src/operations/withdraw.ts @@ -50,6 +50,7 @@ import { TalerErrorCode, TalerErrorDetail, TalerProtocolTimestamp, + TransactionType, UnblindedSignature, URL, VersionMatchResult, @@ -104,6 +105,7 @@ import { getExchangeTrust, updateExchangeFromUrl, } from "./exchanges.js"; +import { makeEventId } from "./transactions.js"; /** * Logger for this file. @@ -256,7 +258,7 @@ export function selectWithdrawalDenominations( DenominationRecord.getValue(d), d.fees.feeWithdraw, ).amount; - for (;;) { + for (; ;) { if (Amounts.cmp(remaining, cost) < 0) { break; } @@ -890,8 +892,7 @@ export async function updateWithdrawalDenoms( denom.verificationStatus === DenominationVerificationStatus.Unverified ) { logger.trace( - `Validating denomination (${current + 1}/${ - denominations.length + `Validating denomination (${current + 1}/${denominations.length }) signature of ${denom.denomPubHash}`, ); let valid = false; @@ -974,7 +975,7 @@ async function queryReserve( if ( resp.status === 404 && result.talerErrorResponse.code === - TalerErrorCode.EXCHANGE_RESERVES_STATUS_UNKNOWN + TalerErrorCode.EXCHANGE_RESERVES_STATUS_UNKNOWN ) { ws.notify({ type: NotificationType.ReserveNotYetFound, @@ -1003,10 +1004,16 @@ async function queryReserve( return { ready: true }; } +enum BankStatusResultCode { + Done = "done", + Waiting = "waiting", + Aborted = "aborted", +} + export async function processWithdrawalGroup( ws: InternalWalletState, withdrawalGroupId: string, - options: {} = {}, + options: object = {}, ): Promise<OperationAttemptResult> { logger.trace("processing withdrawal group", withdrawalGroupId); const withdrawalGroup = await ws.db @@ -1053,13 +1060,15 @@ export async function processWithdrawalGroup( }; } } + break; } - case ReserveRecordStatus.BankAborted: + case ReserveRecordStatus.BankAborted: { // FIXME return { type: OperationAttemptResultType.Pending, result: undefined, }; + } case ReserveRecordStatus.Dormant: // We can try to withdraw, nothing needs to be done with the reserve. break; @@ -1288,7 +1297,7 @@ export async function getExchangeWithdrawalInfo( ) { logger.warn( `wallet's support for exchange protocol version ${WALLET_EXCHANGE_PROTOCOL_VERSION} might be outdated ` + - `(exchange has ${exchangeDetails.protocolVersion}), checking for updates`, + `(exchange has ${exchangeDetails.protocolVersion}), checking for updates`, ); } } @@ -1540,12 +1549,6 @@ async function registerReserveWithBank( ws.notify({ type: NotificationType.ReserveRegisteredWithBank }); } -enum BankStatusResultCode { - Done = "done", - Waiting = "waiting", - Aborted = "aborted", -} - interface BankStatusResult { status: BankStatusResultCode; } @@ -1790,6 +1793,10 @@ export async function acceptWithdrawalFromUri( return { reservePub: existingWithdrawalGroup.reservePub, confirmTransferUrl: url, + transactionId: makeEventId( + TransactionType.Withdrawal, + existingWithdrawalGroup.withdrawalGroupId, + ) }; } @@ -1847,6 +1854,10 @@ export async function acceptWithdrawalFromUri( return { reservePub: withdrawalGroup.reservePub, confirmTransferUrl: withdrawInfo.confirmTransferUrl, + transactionId: makeEventId( + TransactionType.Withdrawal, + withdrawalGroupId, + ) }; } @@ -1901,5 +1912,9 @@ export async function createManualWithdrawal( return { reservePub: withdrawalGroup.reservePub, exchangePaytoUris: exchangePaytoUris, + transactionId: makeEventId( + TransactionType.Withdrawal, + withdrawalGroupId, + ) }; } |