The flowchart's WITHDRAW node (E1) stated that a withdrawal cannot happen together with a bet in progress. The code only serializes the two *builds* through the per-user lock: a withdrawal is accepted while a bet is still unconfirmed, as long as confirmed, unspent UTXOs cover it. CLAUDE.md makes every node of the diagrams binding, so one of the two had to move, and it is the diagram. The hazard the node was reaching for is the two transactions picking the same UTXO, and that is already excluded twice: app/tx/locks.py keeps the builds from overlapping, and select_utxos skips anything already marked spent_txid. What the node forbade on top of that is spending untouched, confirmed money — so implementing it as written would freeze a user's whole balance for a block after every bet and protect nothing. E1 now describes the real rule, and CLAUDE.md's per-user-lock paragraph states it is the only exclusion between the two. Regenerated the A4/A3 PDFs (gitignored, so not in this commit). The regression test is behavioural, not a wording check: it funds a user with two confirmed UTXOs, bets (taking the larger), and asserts the withdrawal goes through on the other one with the bet still unconfirmed and neither transaction spending the other's input. A second test keeps the diagram from drifting back. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
52 lines
2.8 KiB
Plaintext
52 lines
2.8 KiB
Plaintext
flowchart LR
|
|
|
|
subgraph REG["FASE 1 - Registrazione"]
|
|
direction TB
|
|
A1["L'utente si registra\n(username + password)"] --> A2["Il server genera un indirizzo\ndedicato e permanente per l'utente\n(chiave segreta cifrata,\ncustodita dal server)"]
|
|
A2 --> A3["L'indirizzo viene collegato\nal profilo utente\n(sara' sia l'indirizzo di deposito\nche quello che ricevera' vincite\ne prelievi)"]
|
|
end
|
|
|
|
subgraph DEP["FASE 2 - Deposito"]
|
|
direction TB
|
|
B1["L'utente invia PLM\nal proprio indirizzo dedicato"] --> B2["Il sistema monitora\nl'indirizzo sulla blockchain"]
|
|
B2 --> B3{"Transazione\nconfermata?"}
|
|
B3 -- "No" --> B2
|
|
B3 -- "Si'" --> B4["Saldo dell'utente\naccreditato nel sistema"]
|
|
end
|
|
|
|
subgraph PLAY["FASE 3 - Scommessa"]
|
|
direction TB
|
|
C1{"L'utente vuole\nscommettere?\n(costo fisso, es. 10 PLM;\nal massimo una scommessa\nattiva alla volta)"}
|
|
C1 -- "Si', saldo sufficiente" --> C2["Si prepara la transazione:\ndal suo indirizzo verso\nil conto comune del montepremi\n(con resto che torna a lui)"]
|
|
C2 --> C3["Transazione firmata\ne inviata alla rete"]
|
|
C3 --> C4{"Confermata?"}
|
|
C4 -- "No, troppo tempo" --> C5["Si aumenta la commissione\ne si reinvia"]
|
|
C5 --> C3
|
|
C4 -- "Si'" --> C6["L'utente e' ufficialmente\npartecipante al round in corso"]
|
|
end
|
|
|
|
subgraph DRAW["FASE 4 - Round ed estrazione"]
|
|
direction TB
|
|
D0["(dettaglio completo in\nround-lifecycle.mmd)"] -.-> D1["Il round ha un tempo limite\nper accettare scommesse"]
|
|
D1 --> D2["Allo scadere, si aspettano\nle scommesse gia' in corso\ne poi il round si chiude"]
|
|
D2 --> D3["Si estrae un vincitore\nin modo casuale e verificabile\n(hash del primo blocco\ndopo la chiusura)"]
|
|
D3 --> D4["Il montepremi viene diviso:\n70% al vincitore\n30% alla piattaforma"]
|
|
D4 --> D5["Pagamento inviato e confermato\nsulla rete\n(stesso schema di riprova\ncon commissione aumentata\nin caso di ritardo)"]
|
|
end
|
|
|
|
subgraph WITHDRAW["FASE 5 - Prelievo"]
|
|
direction TB
|
|
E1["L'utente richiede un prelievo:\nindirizzo esterno + importo\n(spende solo saldo confermato\ne non ancora impegnato: una scommessa\nin attesa di conferma non lo blocca,\nma le due operazioni non vengono\nmai preparate nello stesso momento)"] --> E2["Si prepara e firma la transazione:\ndal suo indirizzo verso\nl'indirizzo esterno indicato\n(con resto che torna a lui)"]
|
|
E2 --> E3["Transazione inviata\nalla rete"]
|
|
E3 --> E4{"Confermata?"}
|
|
E4 -- "No, troppo tempo" --> E5["Si aumenta la commissione\ne si reinvia"]
|
|
E5 --> E3
|
|
E4 -- "Si'" --> E6["Saldo dell'utente aggiornato"]
|
|
end
|
|
|
|
A3 --> B1
|
|
B4 --> C1
|
|
B4 --> E1
|
|
C6 --> D1
|
|
D5 -.->|"round successivo"| C1
|