-
Notifications
You must be signed in to change notification settings - Fork 4
Store the transactions inputs and outputs to the DB #1110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+170
−24
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
prisma-local/migrations/20260223120000_add_transaction_inputs_outputs/migration.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| -- CreateTable | ||
| CREATE TABLE `TransactionInput` ( | ||
| `id` VARCHAR(191) NOT NULL DEFAULT (uuid()), | ||
| `transactionId` VARCHAR(191) NOT NULL, | ||
| `addressId` VARCHAR(191) NOT NULL, | ||
| `index` INTEGER NOT NULL, | ||
| `amount` DECIMAL(24, 8) NOT NULL, | ||
|
|
||
| INDEX `TransactionInput_transactionId_idx`(`transactionId`), | ||
| INDEX `TransactionInput_addressId_idx`(`addressId`), | ||
| PRIMARY KEY (`id`) | ||
| ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
|
|
||
| -- CreateTable | ||
| CREATE TABLE `TransactionOutput` ( | ||
| `id` VARCHAR(191) NOT NULL DEFAULT (uuid()), | ||
| `transactionId` VARCHAR(191) NOT NULL, | ||
| `addressId` VARCHAR(191) NOT NULL, | ||
| `index` INTEGER NOT NULL, | ||
| `amount` DECIMAL(24, 8) NOT NULL, | ||
|
|
||
| INDEX `TransactionOutput_transactionId_idx`(`transactionId`), | ||
| INDEX `TransactionOutput_addressId_idx`(`addressId`), | ||
| PRIMARY KEY (`id`) | ||
| ) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE `TransactionInput` ADD CONSTRAINT `TransactionInput_transactionId_fkey` FOREIGN KEY (`transactionId`) REFERENCES `Transaction`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE `TransactionInput` ADD CONSTRAINT `TransactionInput_addressId_fkey` FOREIGN KEY (`addressId`) REFERENCES `Address`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE `TransactionOutput` ADD CONSTRAINT `TransactionOutput_transactionId_fkey` FOREIGN KEY (`transactionId`) REFERENCES `Transaction`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; | ||
|
|
||
| -- AddForeignKey | ||
| ALTER TABLE `TransactionOutput` ADD CONSTRAINT `TransactionOutput_addressId_fkey` FOREIGN KEY (`addressId`) REFERENCES `Address`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
rg -n "fetchAllAddressesForNetworkId" --type=ts -A 30Repository: PayButton/paybutton-server
Length of output: 13076
🏁 Script executed:
Repository: PayButton/paybutton-server
Length of output: 238
🏁 Script executed:
Repository: PayButton/paybutton-server
Length of output: 52
fetchAllAddressesForNetworkIdreturns ALL addresses — including participant records created byupsertAddress.The implementation at
services/addressService.ts:181–187filters only bynetworkIdwith no user association check:When
upsertAddresscreates Address records for participant addresses (lines 291–306), they persist in the database without user association. On the next server restart:subscribeInitialAddresses()(line 978) will subscribe to ALL addresses including these participant records.syncMissedTransactions()(line 960) will sync transactions for all participant addresses.This is a fundamental behavioral change: the Address table now tracks all transaction participants, not just user-registered addresses, and the system automatically enrolls them for syncing at restart.
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue here is not the change but the lack of filtering on the subscription. This should be fixed separately
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Fabcien, understood! You're right that the subscription and sync logic infetchAllAddressesForNetworkId(and related functions likesubscribeInitialAddresses()andsyncMissedTransactions()) should filter to only user-registered addresses rather than all participant addresses that get upserted.Keeping the current change in
getTransactionFromChronikTransactionto store inputs/outputs makes sense as a separate concern from how we manage subscriptions on server restart.Would you like me to create a follow-up issue to track the work needed to add filtering logic to prevent subscribing/syncing participant-only addresses?
✏️ Learnings added