add reservePub to the withdrawal transaction info
This commit is contained in:
parent
4941546886
commit
60cfb0e78f
@ -130,6 +130,9 @@ interface WithdrawalDetailsForManualTransfer {
|
||||
* Already contains the amount and message.
|
||||
*/
|
||||
exchangePaytoUris: string[];
|
||||
|
||||
// Public key of the reserve
|
||||
reservePub: string;
|
||||
}
|
||||
|
||||
interface WithdrawalDetailsForTalerBankIntegrationApi {
|
||||
@ -147,6 +150,9 @@ interface WithdrawalDetailsForTalerBankIntegrationApi {
|
||||
* initiated confirmation.
|
||||
*/
|
||||
bankConfirmationUrl?: string;
|
||||
|
||||
// Public key of the reserve
|
||||
reservePub: string;
|
||||
}
|
||||
|
||||
// This should only be used for actual withdrawals
|
||||
|
@ -15,62 +15,36 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
CreateReserveRequest,
|
||||
CreateReserveResponse,
|
||||
TalerErrorDetails,
|
||||
AcceptWithdrawalResponse,
|
||||
Amounts,
|
||||
codecForBankWithdrawalOperationPostResponse,
|
||||
AcceptWithdrawalResponse, addPaytoQueryParams, Amounts, canonicalizeBaseUrl, codecForBankWithdrawalOperationPostResponse,
|
||||
codecForReserveStatus,
|
||||
codecForWithdrawOperationStatusResponse,
|
||||
Duration,
|
||||
codecForWithdrawOperationStatusResponse, CreateReserveRequest,
|
||||
CreateReserveResponse, Duration,
|
||||
durationMax,
|
||||
durationMin,
|
||||
getTimestampNow,
|
||||
NotificationType,
|
||||
ReserveTransactionType,
|
||||
TalerErrorCode,
|
||||
addPaytoQueryParams,
|
||||
durationMin, encodeCrock, getRandomBytes, getTimestampNow, Logger, NotificationType, randomBytes, ReserveTransactionType,
|
||||
TalerErrorCode, TalerErrorDetails, URL
|
||||
} from "@gnu-taler/taler-util";
|
||||
import { randomBytes } from "@gnu-taler/taler-util";
|
||||
import {
|
||||
ReserveRecordStatus,
|
||||
ReserveBankInfo,
|
||||
ReserveRecord,
|
||||
WithdrawalGroupRecord,
|
||||
WalletStoresV1,
|
||||
} from "../db.js";
|
||||
import { assertUnreachable } from "../util/assertUnreachable.js";
|
||||
import { canonicalizeBaseUrl } from "@gnu-taler/taler-util";
|
||||
import {
|
||||
initRetryInfo,
|
||||
getRetryDuration,
|
||||
updateRetryInfoTimeout,
|
||||
} from "../util/retries.js";
|
||||
import { guardOperationException, OperationFailedError } from "../errors.js";
|
||||
import {
|
||||
updateExchangeFromUrl,
|
||||
getExchangePaytoUri,
|
||||
getExchangeDetails,
|
||||
getExchangeTrust,
|
||||
} from "./exchanges.js";
|
||||
import { InternalWalletState } from "../common.js";
|
||||
import {
|
||||
updateWithdrawalDenoms,
|
||||
getCandidateWithdrawalDenoms,
|
||||
selectWithdrawalDenominations,
|
||||
denomSelectionInfoToState,
|
||||
processWithdrawGroup,
|
||||
getBankWithdrawalInfo,
|
||||
} from "./withdraw.js";
|
||||
import { encodeCrock, getRandomBytes } from "@gnu-taler/taler-util";
|
||||
import { Logger, URL } from "@gnu-taler/taler-util";
|
||||
ReserveBankInfo,
|
||||
ReserveRecord, ReserveRecordStatus, WalletStoresV1, WithdrawalGroupRecord
|
||||
} from "../db.js";
|
||||
import { guardOperationException, OperationFailedError } from "../errors.js";
|
||||
import { assertUnreachable } from "../util/assertUnreachable.js";
|
||||
import {
|
||||
readSuccessResponseJsonOrErrorCode,
|
||||
readSuccessResponseJsonOrThrow,
|
||||
throwUnexpectedRequestError,
|
||||
throwUnexpectedRequestError
|
||||
} from "../util/http.js";
|
||||
import { GetReadOnlyAccess } from "../util/query.js";
|
||||
import {
|
||||
getRetryDuration, initRetryInfo, updateRetryInfoTimeout
|
||||
} from "../util/retries.js";
|
||||
import {
|
||||
getExchangeDetails, getExchangePaytoUri, getExchangeTrust, updateExchangeFromUrl
|
||||
} from "./exchanges.js";
|
||||
import {
|
||||
denomSelectionInfoToState, getBankWithdrawalInfo, getCandidateWithdrawalDenoms, processWithdrawGroup, selectWithdrawalDenominations, updateWithdrawalDenoms
|
||||
} from "./withdraw.js";
|
||||
|
||||
const logger = new Logger("reserves.ts");
|
||||
|
||||
@ -540,7 +514,7 @@ async function updateReserve(
|
||||
if (
|
||||
resp.status === 404 &&
|
||||
result.talerErrorResponse.code ===
|
||||
TalerErrorCode.EXCHANGE_RESERVES_GET_STATUS_UNKNOWN
|
||||
TalerErrorCode.EXCHANGE_RESERVES_GET_STATUS_UNKNOWN
|
||||
) {
|
||||
ws.notify({
|
||||
type: NotificationType.ReserveNotYetFound,
|
||||
@ -643,8 +617,7 @@ async function updateReserve(
|
||||
logger.trace(
|
||||
`Remaining unclaimed amount in reseve is ${Amounts.stringify(
|
||||
remainingAmount,
|
||||
)} and can be withdrawn with ${
|
||||
denomSelInfo.selectedDenoms.length
|
||||
)} and can be withdrawn with ${denomSelInfo.selectedDenoms.length
|
||||
} coins`,
|
||||
);
|
||||
|
||||
@ -731,7 +704,7 @@ async function processReserveImpl(
|
||||
case ReserveRecordStatus.REGISTERING_BANK:
|
||||
await processReserveBankStatus(ws, reservePub);
|
||||
return await processReserveImpl(ws, reservePub, true);
|
||||
case ReserveRecordStatus.QUERYING_STATUS:
|
||||
case ReserveRecordStatus.QUERYING_STATUS:
|
||||
const res = await updateReserve(ws, reservePub);
|
||||
if (res.ready) {
|
||||
return await processReserveImpl(ws, reservePub, true);
|
||||
|
@ -17,32 +17,22 @@
|
||||
/**
|
||||
* Imports.
|
||||
*/
|
||||
import {
|
||||
AmountJson,
|
||||
Amounts, OrderShortInfo, PaymentStatus, timestampCmp, Transaction, TransactionsRequest,
|
||||
TransactionsResponse, TransactionType, WithdrawalDetails, WithdrawalType
|
||||
} from "@gnu-taler/taler-util";
|
||||
import { InternalWalletState } from "../common.js";
|
||||
import {
|
||||
WalletRefundItem,
|
||||
RefundState,
|
||||
ReserveRecordStatus,
|
||||
AbortStatus,
|
||||
ReserveRecord,
|
||||
AbortStatus, RefundState, ReserveRecord, ReserveRecordStatus, WalletRefundItem
|
||||
} from "../db.js";
|
||||
import { AmountJson, Amounts, timestampCmp } from "@gnu-taler/taler-util";
|
||||
import {
|
||||
TransactionsRequest,
|
||||
TransactionsResponse,
|
||||
Transaction,
|
||||
TransactionType,
|
||||
PaymentStatus,
|
||||
WithdrawalType,
|
||||
WithdrawalDetails,
|
||||
OrderShortInfo,
|
||||
} from "@gnu-taler/taler-util";
|
||||
import { getFundingPaytoUris } from "./reserves.js";
|
||||
import { getExchangeDetails } from "./exchanges.js";
|
||||
import { processWithdrawGroup } from "./withdraw.js";
|
||||
import { processPurchasePay } from "./pay.js";
|
||||
import { processDepositGroup } from "./deposits.js";
|
||||
import { processTip } from "./tip.js";
|
||||
import { getExchangeDetails } from "./exchanges.js";
|
||||
import { processPurchasePay } from "./pay.js";
|
||||
import { processRefreshGroup } from "./refresh.js";
|
||||
import { getFundingPaytoUris } from "./reserves.js";
|
||||
import { processTip } from "./tip.js";
|
||||
import { processWithdrawGroup } from "./withdraw.js";
|
||||
|
||||
/**
|
||||
* Create an event ID from the type and the primary key for the event.
|
||||
@ -138,6 +128,7 @@ export async function getTransactions(
|
||||
withdrawalDetails = {
|
||||
type: WithdrawalType.TalerBankIntegrationApi,
|
||||
confirmed: true,
|
||||
reservePub: wsr.reservePub,
|
||||
bankConfirmationUrl: r.bankInfo.confirmUrl,
|
||||
};
|
||||
} else {
|
||||
@ -151,11 +142,13 @@ export async function getTransactions(
|
||||
}
|
||||
withdrawalDetails = {
|
||||
type: WithdrawalType.ManualTransfer,
|
||||
reservePub: wsr.reservePub,
|
||||
exchangePaytoUris:
|
||||
exchangeDetails.wireInfo?.accounts.map((x) => x.payto_uri) ??
|
||||
[],
|
||||
};
|
||||
}
|
||||
|
||||
transactions.push({
|
||||
type: TransactionType.Withdrawal,
|
||||
amountEffective: Amounts.stringify(wsr.denomsSel.totalCoinValue),
|
||||
@ -194,11 +187,13 @@ export async function getTransactions(
|
||||
withdrawalDetails = {
|
||||
type: WithdrawalType.TalerBankIntegrationApi,
|
||||
confirmed: false,
|
||||
reservePub: r.reservePub,
|
||||
bankConfirmationUrl: r.bankInfo.confirmUrl,
|
||||
};
|
||||
} else {
|
||||
withdrawalDetails = {
|
||||
type: WithdrawalType.ManualTransfer,
|
||||
reservePub: r.reservePub,
|
||||
exchangePaytoUris: await getFundingPaytoUris(tx, r.reservePub),
|
||||
};
|
||||
}
|
||||
@ -439,7 +434,7 @@ export async function retryTransaction(
|
||||
const proposalId = rest[0];
|
||||
await processPurchasePay(ws, proposalId, true);
|
||||
break;
|
||||
case TransactionType.Tip:
|
||||
case TransactionType.Tip:
|
||||
const walletTipId = rest[0];
|
||||
await processTip(ws, walletTipId, true);
|
||||
break;
|
||||
@ -483,8 +478,8 @@ export async function deleteTransaction(
|
||||
const reserveRecord:
|
||||
| ReserveRecord
|
||||
| undefined = await tx.reserves.indexes.byInitialWithdrawalGroupId.get(
|
||||
withdrawalGroupId,
|
||||
);
|
||||
withdrawalGroupId,
|
||||
);
|
||||
if (reserveRecord && !reserveRecord.initialWithdrawalStarted) {
|
||||
const reservePub = reserveRecord.reservePub;
|
||||
await tx.reserves.delete(reservePub);
|
||||
|
Loading…
Reference in New Issue
Block a user