Fix: Correct ProRegTx extraPayload parsing and serialization (BLS signature handling) #41
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.
📝 Summary
This PR fixes the incorrect parsing and serialization logic for ProRegTx extra payloads (DIP-3 / DIP-23), which caused deserialization errors and
txidmismatches when re-encoding transactions using the latest Dash Core ≥ v19/v20 formats.🔍 Problem
For payloadVersion ≥ 2 (DIP-23 “basic” BLS scheme), the
payloadSigfield was being serialized as varbytes (CompactSize + bytes).According to the current Dash Core implementation, v2+ payloads store the signature as a fixed-length 90 or 96 byte sequence without CompactSize prefix.
As a result:
deserialize()could fail with “attempt to read past end of buffer”;txid()validation failed (expected … got …) because re-serialized bytes differed by one byte (missing CompactSize fix).🛠️ Changes
Updated
DashProRegTx.read_vds()andserialize()to follow DIP-3 / DIP-23 spec:payloadSigas raw 90 / 96 bytes forversion ≥ 2(no length prefix).read_varbytes()behavior forversion < 2.(type << 16 | base_version)to ensure txid stability.Minor cleanup: consistent big-endian port serialization, added asserts for field sizes.
✅ Verification
Tested against known ProRegTx v2 samples from mainnet/testnet:
txid.Backward-compatible with legacy (v1) payloads — varbytes signature still supported.
🧩 References
⚙️ Impact
This fix ensures that ProRegTx parsing and re-serialization are binary-accurate to Dash Core ≥ v19+, preventing signature truncation and txid mismatches in wallet and node implementations.