interfaces: typed receive-request APIs#34838
Open
MkDev11 wants to merge 1 commit intobitcoin:masterfrom
Open
Conversation
Replace getAddressReceiveRequests() and setAddressReceiveRequest() with three typed methods: getReceiveRequests(), addReceiveRequest(), and eraseReceiveRequest(). This moves serialization responsibility from the GUI to the wallet interface layer, decoupling Qt code from the wallet storage format. Add WalletReceiveRequest struct to interfaces/wallet.h carrying typed fields (id, time, address, label, message, amount) instead of opaque serialized blobs. The wallet now: - Assigns request IDs (previously done by GUI) - Assigns timestamps - Handles serialization/deserialization with graceful error recovery (malformed entries are logged and skipped instead of crashing the GUI) - Uses separate add/erase methods instead of overloading a single setter DB format is unchanged for full backward/forward compatibility. Local serialization-compatible structs (RecipientData, RequestEntryData) in wallet/interfaces.cpp mirror the Qt-side format without Qt dependencies. Closes bitcoin#34629
Contributor
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
Author
Member
This was referenced Mar 18, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
The
interfaces::Walletreceive-request API uses raw serialized strings, coupling GUI code to the wallet's internal storage format. The GUI serializes/deserializesRecentRequestEntryobjects itself, and crashes if deserialization fails on malformed data. The GUI also owns ID assignment, which should be the wallet's responsibility.Root Cause
getAddressReceiveRequests()returnsvector<string>of opaque serialized blobs, andsetAddressReceiveRequest()accepts the same — forcing the GUI to own the serialization format (RecentRequestEntry+SendCoinsRecipientSERIALIZE_METHODS in Qt code). TheSpanReaderdeserialization inRecentRequestsTableModel::addNewRequest(const std::string&)throws on malformed data with no error handling.Solution
Replace the two raw-string methods with three typed methods on
interfaces::Wallet:getReceiveRequests()→ returnsvector<WalletReceiveRequest>with typed fieldsaddReceiveRequest()→ wallet assigns ID + timestamp, serializes internally, returns assigned IDeraseReceiveRequest()→ deletes by destination + IDSerialization moves to
wallet/interfaces.cppusing localRecipientData/RequestEntryDatastructs that are byte-identical to the Qt-sideSendCoinsRecipient/RecentRequestEntryformat, but have no Qt dependency. Malformed entries are logged and skipped instead of crashing. DB format is unchanged for full backward/forward compatibility.Testing
src/qt/test/wallettests.cpp) to verify the new typed API:getReceiveRequests()returns correct typed fieldsgetReceiveRequests()returns emptyLoadReceiveRequestsinwallet_tests.cpp) unchanged — CWallet internals not modifiedcmake --build build && build/bin/test_bitcoin-qtBefore / After
SpanReaderthrows on malformed data → GUI crash. GUI owns ID assignment. Single methodsetAddressReceiveRequestoverloaded for both save (non-empty value) and delete (empty value).WalletReceiveRequeststructs. Malformed entries are logged and skipped. Wallet assigns IDs and timestamps. SeparateaddReceiveRequest/eraseReceiveRequestmethods.Edge Cases Handled
LogWarning, skippednulloptLOCK(m_wallet->cs_wallet)sPaymentRequest,authenticatedMerchant): preserved in serialization format for DB compatibilityCloses #34629