Skip to content

Conversation

@LexxXell
Copy link

📝 Summary

This PR fixes the incorrect parsing and serialization logic for ProRegTx extra payloads (DIP-3 / DIP-23), which caused deserialization errors and txid mismatches when re-encoding transactions using the latest Dash Core ≥ v19/v20 formats.


🔍 Problem

  • For payloadVersion ≥ 2 (DIP-23 “basic” BLS scheme), the payloadSig field 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() and serialize() to follow DIP-3 / DIP-23 spec:

    • Read/write payloadSig as raw 90 / 96 bytes for version ≥ 2 (no length prefix).
    • Keep legacy read_varbytes() behavior for version < 2.
    • Compute signature length as remaining bytes in extraPayload when deserializing.
    • Added explicit sanity checks for 90 / 96 bytes.
    • Preserve correct combined header version (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:

    • Deserialization succeeds without “read past end” errors.
    • Re-serialization yields identical hex and matching 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.

@pshenmic pshenmic merged commit cf112b6 into pshenmic:develop Nov 14, 2025
1 check failed
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