Compare commits

..

No commits in common. "56ac4a69e9239ed3c7b6c6d63e018f5fee9dc5b9" and "490605333c1a5d21ea19de50b4a785813b774de4" have entirely different histories.

View file

@ -130,11 +130,7 @@ async def _handle_payment(payment: Payment) -> None:
data = parse_settlement( data = parse_settlement(
machine=machine, machine=machine,
payment_hash=payment.payment_hash, payment_hash=payment.payment_hash,
# `payment.sat` is signed by protocol direction (negative for an wire_sats=payment.sat,
# outbound cash-in payout, positive for an inbound cash-out
# receipt). The settlement's `wire_sats` is a magnitude — direction
# is carried separately by `tx_type` — so pass the absolute value.
wire_sats=abs(payment.sat),
extra=extra, extra=extra,
super_config=super_config, super_config=super_config,
) )
@ -209,8 +205,7 @@ async def _record_rejected(payment: Payment, machine: Machine, exc: Exception) -
data = CreateDcaSettlementData( data = CreateDcaSettlementData(
machine_id=machine.id, machine_id=machine.id,
payment_hash=payment.payment_hash, payment_hash=payment.payment_hash,
# Magnitude, not the signed `payment.sat` (negative for outbound). wire_sats=payment.sat,
wire_sats=abs(payment.sat),
fiat_amount=0.0, fiat_amount=0.0,
fiat_code=machine.fiat_code, fiat_code=machine.fiat_code,
exchange_rate=0.0, exchange_rate=0.0,
@ -218,11 +213,11 @@ async def _record_rejected(payment: Payment, machine: Machine, exc: Exception) -
fee_sats=0, fee_sats=0,
platform_fee_sats=0, platform_fee_sats=0,
operator_fee_sats=0, operator_fee_sats=0,
# The parsed tx_type is unavailable on the rejection path, but the # tx_type is unknown for rejection paths; default to cash_out
# authenticated protocol direction is: an outbound payment is a # (the only direction currently wired). When S8 lands the
# cash-in, an inbound one a cash-out. Use that so a rejected row shows # listener will branch on tx_type from extra, and this default
# the right direction instead of always reading "cash-out". # gets revisited.
tx_type="cash_in" if not payment.is_in else "cash_out", tx_type="cash_out",
) )
rejected = await create_settlement_idempotent( rejected = await create_settlement_idempotent(
data, initial_status="rejected", error_message=str(exc) data, initial_status="rejected", error_message=str(exc)