Skip to content

Accounts and journal entries ​

Each wallet has three accounts (pending, available, held); three system accounts are shared. Every operation is a journal transaction of ≥ 2 lines that sums to 0: positive = debit, negative = credit.

flowchart LR
  subgraph SYS[System accounts]
    FR["sys:funding_receivable<br/>Stripe owes us"]
    BK["sys:bank<br/>USD in the bank"]
    PO["sys:payouts_out<br/>payouts pending settlement"]
  end
  subgraph USR[User wallet]
    P[user:pending]
    A[user:available]
    H[user:held]
  end
  FR -->|1 · deposit initiated| P
  P -->|2 · deposit settled| A
  P -->|3 · deposit returned| FR
  A -->|4 · create hold| H
  H -->|5 · capture| PO
  H -->|6 · release| A
  A -->|7 · transfer| A2[other user:available]

Each arrow is a journal transaction (source debited, destination credited). Settlement also moves funding_receivable → bank.

Every operation's entry ​

#OperationDebit (+)Credit (−)Journal key
1Deposit initiatedsys:funding_receivableuser:pendingdeposit:<id>:initiated
2Deposit settleduser:pending + sys:bankuser:available + sys:funding_receivabledeposit:<id>:settled
3Deposit returneduser:pendingsys:funding_receivabledeposit:<id>:returned
4Create holduser:availableuser:heldhold:<id>:created
5Capture holduser:heldsys:payouts_outhold:<id>:captured
6Release holduser:helduser:availablehold:<id>:released
7TransferuserA:availableuserB:availabletransfer:<Idempotency-Key>
8Reversal of any transactionoriginal creditsoriginal debits<originalKey>:reversal
  • User accounts are credit-normal: money the platform owes the user, so a credit increases them (sign math).
  • Exception: user:<owner>:receivable is debit-normal and never negative: what the user owes the platform. Created lazily by WalletsService.ensureReceivable, never with the wallet (ledger foundation).

Worked example ​

Juan deposits $100 by ACH, it settles, he holds $25 and the payout goes out (cents; bold = changed).

Steppendingavailableheldfunding_rec.bankpayouts_out
Wallet created000000
1 · Deposit initiated (10,000)10,0000010,00000
2 · Deposit settled010,0000010,0000
4 · Hold of 2,50007,5002,500010,0000
5 · Hold captured07,5000010,0002,500

The bank holds 10,000 = 7,500 owed to Juan + 2,500 in the payout. That's why reconciliation sums to 0.

Balance sign math ​

Rule: delta = normal_side == 'debit' ? amount : −amount. Lines keep one sign convention; each balance is reported positive when it holds value. Reconciliation recomputes every balance in SQL with the same rule.

Accountnormal_sideLinedeltaEffect
sys:funding_receivabledebit+10,000 (debit)+10,000Stripe owes us more
user:pendingcredit−10,000 (credit)+10,000money on the way
user:availablecredit+2,500 (debit)−2,500less to spend
user:heldcredit−2,500 (credit)+2,500money reserved
sys:payouts_outcredit−2,500 (credit)+2,500payout in flight

Money is an integer number of cents. Every movement sums to zero.