Restructure bump_fee into three phases, drop float fee math (B-40)
bump_fee issued one get_transaction per input (up to 15s each) and then a broadcast, all with the caller's DB session held open - exactly the pattern already fixed elsewhere for the same reason (B-18's _trigger_payout, B-31's refresh_user). Also, _prevout_amount computed a prevout's satoshi value via round(value_coins * 100_000_000) on a float the server reported, in a codebase that is otherwise strictly integer-satoshi. bump_fee now takes a session_factory and a pending_id instead of a live session and row, with three phases: read what's needed (the signing key, current fee rate, raw tx) and close the session before any network call; do the chain reads, signing and broadcast with no session open; reopen a session only to persist the outcome. _prevout_amount now asks for the raw (non-verbose) transaction and reads embit's parsed TransactionOutput.value directly - already an exact integer, no float conversion involved at all. A pending_transaction that's no longer "pending" by the time bump_fee actually runs (it confirmed in the meantime, a normal race) is now a quiet no-op returning None, rather than being folded into RbfBumper's error-logging path. Suite grows from 214 to 217 tests. BUGS.md moves B-40 to Previously fixed, and trims its own now-stale claim that bump_fee still depended on verbose=True (B-41) - it no longer does.
This commit is contained in:
1 parent
97545ad91f
commit
08c566d547
3 files changed
+231
-99
No files matched your search
@@ -1,11 +1,11 @@
|
||||
# Known bugs
|
||||
|
||||
A second full-codebase audit on 2026-07-27 found **25 further issues** (4 critical, 6 high,
|
||||
7 medium, 8 low), listed below as B-40 … B-49. B-25 through B-39 are fixed (see "Previously
|
||||
fixed" below) — no Critical-severity finding remains open; the other 10 are Medium/Low.
|
||||
7 medium, 8 low), listed below as B-41 … B-49. B-25 through B-40 are fixed (see "Previously
|
||||
fixed" below) — no Critical-severity finding remains open; the other 9 are Medium/Low.
|
||||
The 139-test suite was green at the time of the audit, so none of these were caught by existing
|
||||
coverage — every fix lands with a regression test (the fifteen fixes so far brought the suite
|
||||
from 139 to 214).
|
||||
coverage — every fix lands with a regression test (the sixteen fixes so far brought the suite
|
||||
from 139 to 217).
|
||||
|
||||
The recurring pattern across the open findings is worth stating once: the code is rigorous
|
||||
about the failure modes that have actually been hit, and silent about the ones that have not.
|
||||
@@ -18,28 +18,15 @@ admin auth, single-process assumptions, no user-facing history, etc.) are docume
|
||||
|
||||
## Medium
|
||||
|
||||
### B-40 — `bump_fee` holds a DB session open across N network calls
|
||||
### B-41 — Confirmation/reconciliation logic depends on `verbose=True`, which is not universally supported
|
||||
|
||||
`tx/broadcast.py:80` issues one `get_transaction` **per input** (up to 15s each) and then a
|
||||
`broadcast`, all with the session open. This is precisely the pattern B-18 removed from
|
||||
`_trigger_payout` via its three-phase structure; it survives here.
|
||||
|
||||
Side note in the same function: `_prevout_amount` does `round(value_coins * 100_000_000)` on a
|
||||
float from the server — acceptable at these magnitudes, but it is floating-point money
|
||||
arithmetic in a codebase that is otherwise strictly integer-satoshi.
|
||||
|
||||
**Proposed fix.** Restructure into the same three phases: read what is needed and close the
|
||||
session, do the chain work, then reopen to persist. For the float: prefer the raw (non-verbose)
|
||||
transaction and parse the output value as an integer with `embit`, which is what
|
||||
`reconcile.py:_release_inputs` already does for inputs.
|
||||
|
||||
### B-41 — All confirmation logic depends on `verbose=True`, which is not universally supported
|
||||
|
||||
`poll_once`, `reconcile._tx_exists_on_chain` and `bump_fee` all call
|
||||
`blockchain.transaction.get(txid, True)`. Several Electrum server implementations and versions
|
||||
reject the verbose flag ("verbose transactions are currently unsupported"). Falling back onto
|
||||
such a server means **no confirmations, no reconciliation, no bumps** — and the code would read
|
||||
that as a transport error and stay silent.
|
||||
`poll_once` and `reconcile._tx_exists_on_chain` call `blockchain.transaction.get(txid, True)`.
|
||||
Several Electrum server implementations and versions reject the verbose flag ("verbose
|
||||
transactions are currently unsupported"). Falling back onto such a server means **no
|
||||
confirmations, no reconciliation** — and the code would read that as a transport error and stay
|
||||
silent. (`bump_fee`'s own `verbose=True` call was removed as part of the B-40 fix — it now reads
|
||||
the raw transaction and parses the output value with `embit` instead, so bumps are unaffected by
|
||||
this finding.)
|
||||
|
||||
Related: `reconcile.py:83` decides whether to **abandon a transaction** by substring-matching
|
||||
the error text (`"missing"`, `"not found"`, `"no such"`, `"unknown"`). It works against
|
||||
@@ -133,9 +120,10 @@ already does.
|
||||
- **B-37** — a withdrawal covered by unconfirmed change answered "insufficient balance" instead of distinguishing it from actually having no funds
|
||||
- **B-38** — the SSE subscriber cap was global, so one client opening enough connections degraded every other user to polling
|
||||
- **B-39** — SQLite ran without WAL or a `busy_timeout`, so a writer could block every reader and a second writer failed immediately instead of waiting
|
||||
- **B-40** — `bump_fee` held a DB session open across N slow network calls, and computed a prevout's value from a server-reported float instead of an exact integer
|
||||
|
||||
See git history for the fix-by-fix breakdown (commits `f13f685`, `50a43ae`, `933760e`, and the
|
||||
B-28/B-29/B-30/B-31/B-32/B-33/B-34/B-35/B-36/B-37/B-38/B-39 fixes). Suite grew from 139 to 214 tests over the fifteen.
|
||||
B-28/B-29/B-30/B-31/B-32/B-33/B-34/B-35/B-36/B-37/B-38/B-39/B-40 fixes). Suite grew from 139 to 217 tests over the sixteen.
|
||||
|
||||
A full-codebase audit on 2026-07-26 (commit `d4e0974`) found 24 bugs across every Python
|
||||
module under `app/`, both static frontends, and the Docker/Caddy deployment — 5 critical,
|
||||
|
||||
Reference in new issue
Block a user