Skip to content

Comments

ipc: Serialize null CTransactionRef as empty Data#242

Open
Sjors wants to merge 2 commits intobitcoin-core:masterfrom
Sjors:2026/02/serialize-null
Open

ipc: Serialize null CTransactionRef as empty Data#242
Sjors wants to merge 2 commits intobitcoin-core:masterfrom
Sjors:2026/02/serialize-null

Conversation

@Sjors
Copy link
Member

@Sjors Sjors commented Feb 20, 2026

Taken from: bitcoin/bitcoin#34020 (comment)

Empty Data can be a valid representation for some types, so this behavior should not be generalized.

In List(Data) contexts, Cap'n Proto's current C++ API does not let us distinguish null vs empty Data.

Given those constraints, this commit is narrowly scoped: interpret empty Data as null only for CTransactionRef-like pointer paths where empty serialization is known to be safe. The implementation avoids making generic pointer-type assumptions and introduces a targeted has-field customization path.

@DrahtBot
Copy link

DrahtBot commented Feb 20, 2026

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Reviews

See the guideline for information on the review process.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #243 (mpgen: support primitive std::optional struct fields by ryanofsky)

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.

@Sjors
Copy link
Member Author

Sjors commented Feb 20, 2026

So far I just took bitcoin/bitcoin@b147783 verbatim, minus the IPC tests which go into Bitcoin Core. Let me know if you need more adjustments. Looks like the LLM found some typos.

@Sjors Sjors force-pushed the 2026/02/serialize-null branch from fb2622f to e8bcca3 Compare February 20, 2026 09:48
@Sjors
Copy link
Member Author

Sjors commented Feb 20, 2026

Whipped up a test inspired by the one in bitcoin/bitcoin@b147783 on the Bitcoin Core side.

I fixed the typos and also added a commit to fix two missing includes, that would otherwise need to be added in the test.

@Sjors Sjors force-pushed the 2026/02/serialize-null branch from e8bcca3 to 423a789 Compare February 20, 2026 10:06
@Sjors
Copy link
Member Author

Sjors commented Feb 20, 2026

Added missing #include <vector> to mp/gen.cpp.

Sjors and others added 2 commits February 21, 2026 08:55
Reference and rationale:
bitcoin/bitcoin#34020 (comment)

Empty `Data` can be a valid representation for some types, so this behavior
should not be generalized.

In `List(Data)` contexts, Cap'n Proto's current C++ API does not let us
distinguish null vs empty `Data`.

Given those constraints, this commit is narrowly scoped: interpret empty `Data`
as null only for `CTransactionRef`-like pointer paths where empty serialization
is known to be safe. The implementation avoids making generic pointer-type
assumptions and introduces a targeted has-field customization path.

Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants