wallet-core: show instructed amount as raw amount for withdrawal

This commit is contained in:
Florian Dold 2022-10-16 22:18:24 +02:00
parent 8d4a7d6103
commit b52b074a8d
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
7 changed files with 39 additions and 9 deletions

View File

@ -333,6 +333,8 @@ export interface BackupWithdrawalGroup {
*/ */
raw_withdrawal_amount: BackupAmountString; raw_withdrawal_amount: BackupAmountString;
effective_withdrawal_amount: BackupAmountString;
/** /**
* Restrict withdrawals from this reserve to this age. * Restrict withdrawals from this reserve to this age.
*/ */

View File

@ -1972,6 +1972,7 @@ export class WalletCli {
...this.timetravelArgArr, ...this.timetravelArgArr,
"--wallet-db", "--wallet-db",
this.dbfile, this.dbfile,
"advanced",
"run-pending", "run-pending",
], ],
); );

View File

@ -1356,11 +1356,6 @@ export interface WithdrawalGroupRecord {
*/ */
status: WithdrawalGroupStatus; status: WithdrawalGroupStatus;
/**
* Amount that was sent by the user to fund the reserve.
*/
instructedAmount: AmountJson;
/** /**
* Wire information (as payto URI) for the bank account that * Wire information (as payto URI) for the bank account that
* transferred funds for this reserve. * transferred funds for this reserve.
@ -1374,12 +1369,36 @@ export interface WithdrawalGroupRecord {
*/ */
restrictAge?: number; restrictAge?: number;
/**
* Amount that was sent by the user to fund the reserve.
*/
instructedAmount: AmountJson;
/**
* Amount that was observed when querying the reserve that
* we are withdrawing from.
*
* Useful for diagnostics.
*/
reserveBalanceAmount?: AmountJson;
/** /**
* Amount including fees (i.e. the amount subtracted from the * Amount including fees (i.e. the amount subtracted from the
* reserve to withdraw all coins in this withdrawal session). * reserve to withdraw all coins in this withdrawal session).
*
* (Initial amount confirmed by the user, might differ with denomSel
* on reselection.)
*/ */
rawWithdrawalAmount: AmountJson; rawWithdrawalAmount: AmountJson;
/**
* Amount that will be added to the balance when the withdrawal succeeds.
*
* (Initial amount confirmed by the user, might differ with denomSel
* on reselection.)
*/
effectiveWithdrawalAmount: AmountJson;
/** /**
* Denominations selected for withdrawal. * Denominations selected for withdrawal.
*/ */

View File

@ -166,6 +166,9 @@ export async function exportBackup(
secret_seed: wg.secretSeed, secret_seed: wg.secretSeed,
exchange_base_url: wg.exchangeBaseUrl, exchange_base_url: wg.exchangeBaseUrl,
instructed_amount: Amounts.stringify(wg.instructedAmount), instructed_amount: Amounts.stringify(wg.instructedAmount),
effective_withdrawal_amount: Amounts.stringify(
wg.effectiveWithdrawalAmount,
),
reserve_priv: wg.reservePriv, reserve_priv: wg.reservePriv,
restrict_age: wg.restrictAge, restrict_age: wg.restrictAge,
// FIXME: proper status conversion! // FIXME: proper status conversion!

View File

@ -556,6 +556,9 @@ export async function importBackup(
rawWithdrawalAmount: Amounts.parseOrThrow( rawWithdrawalAmount: Amounts.parseOrThrow(
backupWg.raw_withdrawal_amount, backupWg.raw_withdrawal_amount,
), ),
effectiveWithdrawalAmount: Amounts.parseOrThrow(
backupWg.effective_withdrawal_amount,
),
reservePriv: backupWg.reserve_priv, reservePriv: backupWg.reserve_priv,
reservePub, reservePub,
status: backupWg.timestamp_finish status: backupWg.timestamp_finish

View File

@ -379,7 +379,7 @@ function buildTransactionForPullPaymentCredit(
return { return {
type: TransactionType.PeerPullCredit, type: TransactionType.PeerPullCredit,
amountEffective: Amounts.stringify(wsr.denomsSel.totalCoinValue), amountEffective: Amounts.stringify(wsr.denomsSel.totalCoinValue),
amountRaw: Amounts.stringify(wsr.rawWithdrawalAmount), amountRaw: Amounts.stringify(wsr.instructedAmount),
exchangeBaseUrl: wsr.exchangeBaseUrl, exchangeBaseUrl: wsr.exchangeBaseUrl,
pending: !wsr.timestampFinish, pending: !wsr.timestampFinish,
timestamp: wsr.timestampStart, timestamp: wsr.timestampStart,
@ -409,7 +409,7 @@ function buildTransactionForPushPaymentCredit(
return { return {
type: TransactionType.PeerPushCredit, type: TransactionType.PeerPushCredit,
amountEffective: Amounts.stringify(wsr.denomsSel.totalCoinValue), amountEffective: Amounts.stringify(wsr.denomsSel.totalCoinValue),
amountRaw: Amounts.stringify(wsr.rawWithdrawalAmount), amountRaw: Amounts.stringify(wsr.instructedAmount),
exchangeBaseUrl: wsr.exchangeBaseUrl, exchangeBaseUrl: wsr.exchangeBaseUrl,
info: { info: {
expiration: wsr.wgInfo.contractTerms.purse_expiration, expiration: wsr.wgInfo.contractTerms.purse_expiration,
@ -436,7 +436,7 @@ function buildTransactionForBankIntegratedWithdraw(
return { return {
type: TransactionType.Withdrawal, type: TransactionType.Withdrawal,
amountEffective: Amounts.stringify(wsr.denomsSel.totalCoinValue), amountEffective: Amounts.stringify(wsr.denomsSel.totalCoinValue),
amountRaw: Amounts.stringify(wsr.rawWithdrawalAmount), amountRaw: Amounts.stringify(wsr.instructedAmount),
withdrawalDetails: { withdrawalDetails: {
type: WithdrawalType.TalerBankIntegrationApi, type: WithdrawalType.TalerBankIntegrationApi,
confirmed: wsr.wgInfo.bankInfo.timestampBankConfirmed ? true : false, confirmed: wsr.wgInfo.bankInfo.timestampBankConfirmed ? true : false,
@ -477,7 +477,7 @@ function buildTransactionForManualWithdraw(
amountEffective: Amounts.stringify( amountEffective: Amounts.stringify(
withdrawalGroup.denomsSel.totalCoinValue, withdrawalGroup.denomsSel.totalCoinValue,
), ),
amountRaw: Amounts.stringify(withdrawalGroup.rawWithdrawalAmount), amountRaw: Amounts.stringify(withdrawalGroup.instructedAmount),
withdrawalDetails: { withdrawalDetails: {
type: WithdrawalType.ManualTransfer, type: WithdrawalType.ManualTransfer,
reservePub: withdrawalGroup.reservePub, reservePub: withdrawalGroup.reservePub,

View File

@ -932,6 +932,7 @@ async function queryReserve(
return; return;
} }
wg.status = WithdrawalGroupStatus.Ready; wg.status = WithdrawalGroupStatus.Ready;
wg.reserveBalanceAmount = Amounts.parse(result.response.balance);
await tx.withdrawalGroups.put(wg); await tx.withdrawalGroups.put(wg);
}); });
@ -1700,6 +1701,7 @@ export async function internalCreateWithdrawalGroup(
instructedAmount: amount, instructedAmount: amount,
timestampStart: now, timestampStart: now,
rawWithdrawalAmount: initialDenomSel.totalWithdrawCost, rawWithdrawalAmount: initialDenomSel.totalWithdrawCost,
effectiveWithdrawalAmount: initialDenomSel.totalCoinValue,
secretSeed, secretSeed,
reservePriv: reserveKeyPair.priv, reservePriv: reserveKeyPair.priv,
reservePub: reserveKeyPair.pub, reservePub: reserveKeyPair.pub,