Skip to content

fix: close payout double-pay gaps in 5 non-Bitcoin payout handlers - #11

Merged
colneech-dev merged 1 commit into
mainfrom
fix/payout-batch-idempotency-5-chains
Nov 24, 2026
Merged

colneech-dev merged 1 commit into
mainfrom
fix/payout-batch-idempotency-5-chains

Conversation

@colneech-dev

Copy link
Copy Markdown
Owner

Summary

  • Ethereum, Kaspa, Cryptonote, Conceal and Zano payout handlers sent funds, then called PersistPaymentsAsync directly with no durable record in between a send and a debit.
  • A crash or RPC/gRPC timeout between broadcast and persistence left the balance un-debited, so the same amount could be paid again next run.
  • These 5 handlers now use the same BeginPayoutBatchAsync / CompletePayoutBatchAsync / MarkPayoutBatchFailedAsync idempotency infrastructure in PayoutHandlerBase that Bitcoin/Equihash/Handshake already use.
  • Ambiguous outcomes (transport failures, timeouts) now leave the batch pending and halt payouts for that pool until an operator resolves it via the admin API, instead of silently assuming nothing was sent.

Scope note

The same gap still exists in Ergo, Alephium, Beam, Warthog and Xelis. Not addressed here — each needs its own careful read of its wallet RPC semantics before applying the same pattern.

Test plan

  • dotnet build (Release, SkipNativeLibBuild=true) — 0 errors, only pre-existing warnings
  • Not yet deployed or exercised against a live wallet for any of the 5 chains

🤖 Generated with Claude Code

Ethereum, Kaspa, Cryptonote, Conceal and Zano sent funds and then called
PersistPaymentsAsync directly with no durable record in between. If the
process crashed or the RPC/gRPC call timed out between broadcast and
persistence, the balance was never debited and the same amount could be
paid again on the next payout run from fresh inputs/nonce - unlike
Bitcoin, Equihash and Handshake, which already use the payoutbatches
idempotency infrastructure in PayoutHandlerBase (BeginPayoutBatchAsync /
CompletePayoutBatchAsync / MarkPayoutBatchFailedAsync).

Each handler now:
- records the payout intent (BeginPayoutBatchAsync) before the wallet is
  asked to send anything
- on success, marks the batch sent and persists payments atomically
  (CompletePayoutBatchAsync) instead of a bare PersistPaymentsAsync
- on a transport failure or ambiguous error (IsOutcomeUnknown), leaves
  the batch pending and halts payouts for that pool until an operator
  resolves it, rather than silently treating it as "nothing sent"
- on a definite daemon-reported rejection, marks the batch failed
  (MarkPayoutBatchFailedAsync) so the balance is retried cleanly next run

Ethereum: PayoutAsync(balance) now begins/completes a batch around
eth_sendTransaction.

Kaspa: the broadcast step (the only step that actually moves funds) is
wrapped per-transfer; CreateUnsignedTransactions/Sign are unaffected.
Removed the now-redundant PersistPaymentsAsync(successBalances) at the
end of PayoutAsync since persistence already happened per-transfer.

Cryptonote/Zano: both HandleTransferResponseAsync overloads (transfer
and transfer_split) now take the tracking batch; both call sites
(whole-batch PayoutBatch and single-address PayoutToPaymentId) begin a
batch before sending, including the -4 "retry with transfer_split"
path, which now reuses the original batch instead of leaving it
orphaned.

Conceal: same shape as Cryptonote/Zano via HandleSendTransactionResponseAsync.

Scope note: the same gap exists in Ergo, Alephium, Beam, Warthog and
Xelis payout handlers but was not addressed in this change; each needs
its own careful read of its wallet RPC semantics before applying the
same pattern.

Build-verified: dotnet build (Release, SkipNativeLibBuild=true), 0 errors.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@colneech-dev
colneech-dev merged commit 40156c0 into main Nov 24, 2026
1 check passed
@colneech-dev
colneech-dev deleted the fix/payout-batch-idempotency-5-chains branch November 24, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant