[GEN-1599] Withdrawals to support the new Database model (single output backwards-compatible)#414
Conversation
- Implemented migration to transfer existing data from WalletWithdrawalRequests to WalletWithdrawalRequestDestinations. - Added verification step to ensure data integrity during migration.
…ate migration files
… amount in a list of withdrawal request destinations
…lRequestDestinations
…s for improved structure
…set and log errors for missing addresses
…ods for comprehensive request data
…TotalAmount for consistency
| var balanceResponse = await _nbXplorerService.GetBalanceAsync(derivationStrategy); | ||
|
|
||
| walletWithdrawalRequest.Amount = ((Money)balanceResponse.Confirmed).ToUnit(MoneyUnit.BTC); | ||
| var firstDestination = walletWithdrawalRequest.WalletWithdrawalRequestDestinations?.FirstOrDefault(); |
There was a problem hiding this comment.
This is just for this version incoming versions will support multiple outputs.
…mprove data binding and validation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors withdrawal-related functionality for a new Database model by removing legacy properties and updating tests, UI elements, and service/repository logic to work with a single-output withdrawal approach. Key changes include replacing Amount/DestinationAddress with WalletWithdrawalRequestDestinations, updating data migrations to handle legacy data, and modifying UI and service logic to use the new destination model.
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/NodeGuard.Tests/Services/BitcoinServiceTests.cs | Updated tests to verify new destination list usage |
| test/NodeGuard.Tests/Data/Repositories/FUTXORepositoryTests.cs | Refactored tests to use the new destination property |
| src/Shared/PSBTSign.razor | Changed to display TotalAmount instead of Amount |
| src/Services/BitcoinService.cs | Refactored amount assignment and destination tracking logic |
| src/Rpc/NodeGuardService.cs | Updated withdrawal request creation using new array initializer syntax for destinations |
| src/Pages/Withdrawals.razor, src/Pages/Wallets.razor | Modified UI components to support the destination list and TotalAmount changes |
| src/Migrations/* | Added migrations for dropping obsolete fields and migrating legacy data |
| src/Data/* | Updated models, repositories and DbInitializer to reflect the new withdrawal model |
Comments suppressed due to low confidence (2)
src/Rpc/NodeGuardService.cs:225
- [nitpick] Consider adding an inline comment explaining the new array initializer syntax for WalletWithdrawalRequestDestinations to aid maintainability for team members less familiar with C# 12 features.
WalletWithdrawalRequestDestinations = [
src/Migrations/20250611142943_MigrateLegacyWithdrawalData.cs:29
- [nitpick] Verify that the use of a raw SQL transaction block with DO $$ in this migration is compatible with all target database systems and add a comment explaining its purpose for clarity.
DO $$
Co-authored-by: Rodrigo <39995243+RodriFS@users.noreply.github.com>
The goal of this PR is to
safelyScreen.Recording.2025-06-12.at.14.13.01.mov