Skip to content

Revert local xpub decoder once bitkit-core lands serializedExtendedPubkey on master #646

Description

@jvsena42

Context

737918d (landed via #632) replaced the BitkitCore.serializedExtendedPubkey FFI call in WatchOnlyAccountClaimCodec.serializedXpub with a local base58check decoder plus a secp256k1 point check on the trailing compressed key.

Discussion on the PR records the upstream state at the time this landed (2026-07-28): dd99b46d was still not on bitkit-core master, and neither release cut since carried it — v0.4.4 predates it and v0.5.3 was cut from the Boltz branch. So there was no tag with both serializedExtendedPubkey and the Boltz module. Re-check that before assuming this is still blocked.

This was a workaround, not a preference. serializedExtendedPubkey only ever shipped in bitkit-core v0.4.2, a tag cut from a branch that never merged to bitkit-core master. No later release (0.4.3, any 0.5.x, or master) carries it, so depending on it pinned this repo to a dead-end tag and blocked every bitkit-core upgrade — including the 0.5.3 bump that #632 needs for the Boltz module.

What to do

Once bitkit-core lands dd99b46d "feat: expose serialized extended public keys" on master and cuts a release carrying both that symbol and the Boltz module:

  • Bump bitkit-core to that release
  • Restore serializedXpub to call BitkitCore.serializedExtendedPubkey
  • Delete the local helpers: base58CheckDecode, base58Decode, isValidCompressedPublicKey, base58Alphabet, and the import secp256k1 added for them
  • Remove the TODO in Bitkit/Services/WatchOnlyAccountService.swift

The testSerializedXpub* cases in BitkitTests/WatchOnlyAccountServiceTests.swift pin the behaviour byte-for-byte against bitkit-core's own vectors, so they should pass unchanged across the swap and are the check that the revert is faithful. Keep them.

Why it is worth reverting

The local decoder is byte-exact on the tested vectors but is a looser validator than rust-bitcoin's Xpub::from_str: it does not check the 4-byte version prefix, so any 78-byte base58check payload with a valid curve point is accepted (ypub/zpub or arbitrary version bytes), where the FFI path would reject them. An xprv is still correctly rejected, since its 0x00 key prefix fails secp256k1_ec_pubkey_parse. Accepting both xpub and tpub is intentional and pinned by tests.

If the revert cannot happen by 2.5.0, consider whitelisting the known mainnet/testnet version prefixes in the local decoder as a stopgap.

Files

  • Bitkit/Services/WatchOnlyAccountService.swift
  • BitkitTests/WatchOnlyAccountServiceTests.swift

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions