Commit 81b4b10
authored
Two fixes in utxo_ledger.py:
1. **Broken rollback causes fund destruction**: When apply_transaction()
fails during output creation, the except block returned False but did
NOT restore the already-spent boxes. This permanently destroyed funds.
Fix: restore spent_boxes to _boxes and _by_address, remove from _spent.
2. **BalanceTracker.transfer() uses all UTXOs**: The transfer method
consumed every UTXO box as input, which was inefficient, privacy-leaking,
and created unnecessarily large transactions.
Fix: greedy coin selection (smallest-first) to minimize inputs.
Note: node/utxo_db.py already has correct rollback via SQLite transactions.
This fix brings the in-memory ledger to the same safety standard.
Wallet: RTC9d7caca3039130d3b26d41f7343d8f4ef4592360
1 parent ad8ab92 commit 81b4b10
1 file changed
Lines changed: 33 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
298 | | - | |
299 | | - | |
300 | | - | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
301 | 311 | | |
302 | 312 | | |
303 | 313 | | |
| |||
465 | 475 | | |
466 | 476 | | |
467 | 477 | | |
468 | | - | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
469 | 495 | | |
470 | 496 | | |
471 | | - | |
| 497 | + | |
472 | 498 | | |
473 | 499 | | |
474 | 500 | | |
| |||
483 | 509 | | |
484 | 510 | | |
485 | 511 | | |
486 | | - | |
487 | | - | |
| 512 | + | |
| 513 | + | |
488 | 514 | | |
489 | 515 | | |
490 | 516 | | |
| |||
0 commit comments