Currency refactor - #31
BugBot Review
BugBot Analysis Progress (4m 11s elapsed)
✅ Gathered PR context (1s)
✅ Analyzed code changes (0s)
✅ Completed bug detection — 3 potential bugs found (4m 7s)
✅ Validation and filtering completed (0s)
✅ Posted analysis results — 3 bugs reported (2s)
✅ Analysis completed successfully (0s)
Final Result: BugBot completed review and found 3 potential issues
Request ID: serverGenReqId_70b2ea38-e602-4951-bf5e-59ab4b417c5b
Details
Bug: Undefined Methods Cause Balance Calculation Errors
The total_balance_sat method in WalletState and the sats_value_of_proofs function in Wallet attempt to call undefined melt_exchange_rate and mint_exchange_rate methods, respectively, on Mint objects when processing non-BTC proofs. This causes an AttributeError and prevents accurate balance calculation. Additionally, Mint instances are created in a loop without proper cleanup, leading to resource leaks.
sixty_nuts/types.py#L142-L159
sixty-nuts/sixty_nuts/types.py
Lines 142 to 159 in 3108320
sixty_nuts/wallet.py#L2735-L2737
sixty-nuts/sixty_nuts/wallet.py
Lines 2735 to 2737 in 3108320
Bug: Bitcoin Exchange Rate Method Inverts Values
The melt_exchange_rate method returns inverted exchange rates for Bitcoin units. For "sat", it incorrectly returns 1000 instead of 1. For "msat", it incorrectly returns 1 instead of 0.001. This results in incorrect currency conversions.
sixty_nuts/mint.py#L391-L398
Lines 391 to 398 in 3108320
Bug: Mint Quote Creation Fails Without Currencies
An IndexError occurs in Mint.create_mint_quote and Mint.create_melt_quote methods when the unit parameter is None. This happens because the code attempts to access currencies[0] from the list of available currencies without checking if the list is empty, leading to an error if the mint provides no currencies.
sixty_nuts/mint.py#L433-L434
Lines 433 to 434 in 3108320
sixty_nuts/mint.py#L490-L491
Lines 490 to 491 in 3108320
Was this report helpful? Give feedback by reacting with 👍 or 👎