[Low] CLI/SDK ignore spendable — balance display, send gating, and provider stake checks use unfinalized totals
Report
Summary
The API already returns spendable and final_height alongside balances, but the Go SDK's GetBalances decodes only balances — so the CLI balance display, the CLI send sufficiency check, and the provider stake check all operate on unfinalized totals. CLI users cannot distinguish confirmed from unconfirmed funds, and sends built on unfinalized funds are accepted then reorgable. The web wallet, against the same API, does it right.
Root Cause
- Server
handleGetBalance(api/handler.go:453-478) returnsbalances+spendable+final_height. - SDK
GetBalances(client/client.go:61-77) decodes onlybalances(struct:69-71) —spendableandfinal_heightare silently dropped. cmdWalletBalance(cmd/xe/main.go:642-663) therefore prints totals only;cmdSend's sufficiency check (:700-702,bals[asset] < amount) passes against funds that may be unwound in a fork;pickProvider's stake check (:1732-1733,bals["XCU"] >= stake) passes a provider whose stake funds may be locked/unspendable.- Contrast — the web wallet, same API: loads spendable (
web/assets/wallet.js:699), displays a spendable column (:737), shows spendable in the asset dropdown (:799), and blocks sends above spendable (:827-829).
Verification
Executed PoC against the real api.Handler (httptest + fake backend):
GetBalances raw server body: {"balances":{"XCU":500,"XE":1000},"spendable":{"XCU":50,"XE":100},"final_height":2}
SDK returned: map[XCU:500 XE:1000] (spendable + final_height dropped)
Note on related reports
Searched "spendable" — #382 is server-side (API serving spendable from an unconfirmed frontier during sync lag), a different component and root cause; cite as related, not a dup.
Suggested fix
Decode spendable and final_height in GetBalances (new return type or accessor), have the CLI display spendable alongside totals, and gate cmdSend and pickProvider on spendable.
Thread
Thanks. This is the same finding as an earlier report that is not public, which was filed first; the programme pays the first verifiable submission, so this one closes as a duplicate. If you believe it is a different bug, file a new report that links https://bounty.xe.network/XE-16975 and says what differs; it is read like any other.