Skip to content

wallet: expose pocx_type field in transaction RPC responses#5

Open
JohnnyFFM wants to merge 1 commit into
pocx-nightlyfrom
feat/wallet-rpc-pocx-type
Open

wallet: expose pocx_type field in transaction RPC responses#5
JohnnyFFM wants to merge 1 commit into
pocx-nightlyfrom
feat/wallet-rpc-pocx-type

Conversation

@JohnnyFFM
Copy link
Copy Markdown
Collaborator

Summary

Adds an optional pocx_type field to listtransactions, gettransaction, and listsinceblock, set to "assignment" or "revocation" when the transaction carries the corresponding PoCX OP_RETURN marker, and absent otherwise.

  • Implemented inside WalletTxToJSON — the shared helper reached by all three RPCs (directly by gettransaction, via ListTransactions with fLong=true for the other two).
  • pocx_type is declared once in TransactionDescriptionString so the RPCResult documentation flows to every affected RPC.
  • Marker detection short-circuits on the first hit; the existing pocx::assignments::IsAssignmentOpReturn / IsRevocationOpReturn parsers are reused.
  • Both the include and the field are guarded with #ifdef ENABLE_POCX, matching the convention used elsewhere in src/wallet/.

Closes PoC-Consortium/bitcoin-pocx#6.

Backwards compatibility

100% additive. No existing field is renamed, removed, or has its meaning changed — assignment txs still appear as category="send", money-flow accounting and the documented category enum are untouched. The field is absent (not null/"") when no marker is present, so for any non-PoCX tx the JSON output is byte-for-byte identical to before. No on-disk / wallet-format change; downgrading the binary just stops emitting the field.

Test plan

Manual regtest exercise via the new script in the outer bitcoin-pocx repo (scripts/assignments/test-wallet-rpc-pocx-type-v2.sh):

  • Ordinary send → pocx_type absent on gettransaction, listtransactions, listsinceblock
  • create_assignment tx → pocx_type="assignment" on all three RPCs
  • revoke_assignment tx → pocx_type="revocation" on all three RPCs
  • Re-check ordinary tx after assignment + revocation → field still absent (no bleed)
  • bitcoin_wallet and bitcoind build clean

Tests passed: 18 / 18.

Add an optional pocx_type field to listtransactions, gettransaction, and
listsinceblock that is set to "assignment" or "revocation" when the
transaction carries the corresponding PoCX OP_RETURN marker, and is
absent otherwise.

The field is pushed inside WalletTxToJSON — the shared helper reached by
all three RPCs (directly by gettransaction, and via ListTransactions
with fLong=true for the other two) — and declared once in
TransactionDescriptionString so the RPCResult documentation flows to
every affected RPC. Marker detection short-circuits on the first hit;
the assignment / revocation OP_RETURN parsers in
pocx/assignments/opcodes.h are reused as-is.

Both the include and the field are guarded with #ifdef ENABLE_POCX,
matching the convention used elsewhere in src/wallet/.

Closes PoC-Consortium/bitcoin-pocx#6.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant