Skip to content

pset: mask pegin/issuance flags out of the input outpoint - #293

Merged
apoelstra merged 1 commit into
ElementsProject:masterfrom
delta1:issues/292
Aug 4, 2026
Merged

pset: mask pegin/issuance flags out of the input outpoint#293
apoelstra merged 1 commit into
ElementsProject:masterfrom
delta1:issues/292

Conversation

@delta1

@delta1 delta1 commented Jul 31, 2026

Copy link
Copy Markdown
Member

The pegin and issuance flags are stored in the high bits of the PSET previous_output_index, but they are not part of the outpoint itself: Elements Core keeps them separate in memory and only re-adds them when serializing. Input::issuance_ids was computing the asset entropy over the flagged index, so any new issuance round-tripped through a PSET derived different asset and token IDs than Elements does.

extract_tx already masked the flags, but did so inline. Add Input::previous_outpoint, which strips them (leaving the all-1's coinbase index alone, as it carries no flags), and use it from both places so the two cannot drift apart again. Also replace the bare 1 << 30 / 1 << 31 literals with named constants.

Fixes #292

The pegin and issuance flags are stored in the high bits of the PSET
`previous_output_index`, but they are not part of the outpoint itself:
Elements Core keeps them separate in memory and only re-adds them when
serializing. `Input::issuance_ids` was computing the asset entropy over
the flagged index, so any new issuance round-tripped through a PSET
derived different asset and token IDs than `TxIn::issuance_ids` and than
Elements Core does. Those IDs also feed the blinding code.

`extract_tx` already masked the flags, but did so inline. Add
`Input::previous_outpoint`, which strips them (leaving the all-1's
coinbase index alone, as it carries no flags), and use it from both
places so the two cannot drift apart again. Also replace the bare
`1 << 30` / `1 << 31` literals with named constants.

Fixes ElementsProject#292
@apoelstra

Copy link
Copy Markdown
Member

Nice. Principled fix.

@apoelstra apoelstra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK e30b020; successfully ran local tests

@apoelstra
apoelstra merged commit 8fa98de into ElementsProject:master Aug 4, 2026
10 checks passed
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.

PSET extraction leaves pegin flag in TxIn.previous_output.vout

2 participants