diff options
Diffstat (limited to 'packages/taler-wallet-core/src/operations/pay-peer.ts')
-rw-r--r-- | packages/taler-wallet-core/src/operations/pay-peer.ts | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/packages/taler-wallet-core/src/operations/pay-peer.ts b/packages/taler-wallet-core/src/operations/pay-peer.ts index ef2c19c33..6e5f1b89b 100644 --- a/packages/taler-wallet-core/src/operations/pay-peer.ts +++ b/packages/taler-wallet-core/src/operations/pay-peer.ts @@ -31,7 +31,7 @@ import { PreparePeerPullDebitRequest, PreparePeerPullDebitResponse, PreparePeerPushCredit, - CheckPeerPushPaymentResponse, + PreparePeerPushCreditResponse, Codec, codecForAmountString, codecForAny, @@ -100,7 +100,10 @@ import { import { getPeerPaymentBalanceDetailsInTx } from "./balance.js"; import { updateExchangeFromUrl } from "./exchanges.js"; import { getTotalRefreshCost } from "./refresh.js"; -import { internalCreateWithdrawalGroup } from "./withdraw.js"; +import { + getExchangeWithdrawalInfo, + internalCreateWithdrawalGroup, +} from "./withdraw.js"; const logger = new Logger("operations/peer-to-peer.ts"); @@ -623,7 +626,7 @@ export const codecForExchangePurseStatus = (): Codec<ExchangePurseStatus> => export async function preparePeerPushCredit( ws: InternalWalletState, req: PreparePeerPushCredit, -): Promise<CheckPeerPushPaymentResponse> { +): Promise<PreparePeerPushCreditResponse> { const uri = parsePayPushUri(req.talerUri); if (!uri) { @@ -658,6 +661,8 @@ export async function preparePeerPushCredit( if (existing) { return { amount: existing.existingContractTerms.amount, + amountEffective: existing.existingPushInc.estimatedAmountEffective, + amountRaw: existing.existingContractTerms.amount, contractTerms: existing.existingContractTerms, peerPushPaymentIncomingId: existing.existingPushInc.peerPushPaymentIncomingId, @@ -705,6 +710,13 @@ export async function preparePeerPushCredit( const withdrawalGroupId = encodeCrock(getRandomBytes(32)); + const wi = await getExchangeWithdrawalInfo( + ws, + exchangeBaseUrl, + Amounts.parseOrThrow(purseStatus.balance), + undefined, + ); + await ws.db .mktx((x) => [x.contractTerms, x.peerPushPaymentIncoming]) .runReadWrite(async (tx) => { @@ -718,6 +730,10 @@ export async function preparePeerPushCredit( contractTermsHash, status: PeerPushPaymentIncomingStatus.Proposed, withdrawalGroupId, + currency: Amounts.currencyOf(purseStatus.balance), + estimatedAmountEffective: Amounts.stringify( + wi.withdrawalAmountEffective, + ), }); await tx.contractTerms.put({ @@ -728,6 +744,8 @@ export async function preparePeerPushCredit( return { amount: purseStatus.balance, + amountEffective: wi.withdrawalAmountEffective, + amountRaw: purseStatus.balance, contractTerms: dec.contractTerms, peerPushPaymentIncomingId, }; |