fix: missing total cost in peer pull payment

This commit is contained in:
Sebastian 2023-01-18 17:31:34 -03:00
parent 20b9e62aa1
commit 4bd9b1ba79
No known key found for this signature in database
GPG Key ID: BE4FF68352439FC1
3 changed files with 16 additions and 1 deletions

View File

@ -1864,6 +1864,12 @@ export interface PeerPullPaymentIncomingRecord {
* Status of the peer push payment incoming initiation. * Status of the peer push payment incoming initiation.
*/ */
status: PeerPullPaymentIncomingStatus; status: PeerPullPaymentIncomingStatus;
/**
* Total cost based on the coin selection.
* Non undefined after status === "Accepted"
*/
totalCost: AmountString | undefined;
} }
/** /**

View File

@ -882,6 +882,11 @@ export async function acceptPeerPullPayment(
const sel = coinSelRes.result; const sel = coinSelRes.result;
const totalAmount = await getTotalPeerPaymentCost(
ws,
coinSelRes.result.coins,
);
await ws.db await ws.db
.mktx((x) => [ .mktx((x) => [
x.exchanges, x.exchanges,
@ -908,6 +913,7 @@ export async function acceptPeerPullPayment(
throw Error(); throw Error();
} }
pi.status = PeerPullPaymentIncomingStatus.Accepted; pi.status = PeerPullPaymentIncomingStatus.Accepted;
pi.totalCost = Amounts.stringify(totalAmount);
await tx.peerPullPaymentIncoming.put(pi); await tx.peerPullPaymentIncoming.put(pi);
}); });
@ -995,6 +1001,7 @@ export async function checkPeerPullPayment(
timestampCreated: TalerProtocolTimestamp.now(), timestampCreated: TalerProtocolTimestamp.now(),
contractTerms: dec.contractTerms, contractTerms: dec.contractTerms,
status: PeerPullPaymentIncomingStatus.Proposed, status: PeerPullPaymentIncomingStatus.Proposed,
totalCost: undefined,
}); });
}); });

View File

@ -380,7 +380,9 @@ function buildTransactionForPullPaymentDebit(
): Transaction { ): Transaction {
return { return {
type: TransactionType.PeerPullDebit, type: TransactionType.PeerPullDebit,
amountEffective: Amounts.stringify(pi.contractTerms.amount), amountEffective: pi.totalCost
? pi.totalCost
: Amounts.stringify(pi.contractTerms.amount),
amountRaw: Amounts.stringify(pi.contractTerms.amount), amountRaw: Amounts.stringify(pi.contractTerms.amount),
exchangeBaseUrl: pi.exchangeBaseUrl, exchangeBaseUrl: pi.exchangeBaseUrl,
frozen: false, frozen: false,