← Back to Bitcoin Improvement Proposals
BIPinformationalopcodeskey-managementtransactionsscript

BIP 345: Fix OP_VAULT_RECOVER specification for the recovery-sPK-hash

The recovery scriptPubKey needs to be prefixed with its CompactSize-encoded length when computing the sPK hash. I verified this by: - Checking the [functional tests](https://github.com/jamesob/bitcoin/commit/5e59c074703f0913db7ee004b99d086857d10ad6#diff-65a47d52759ba7800338bacb3005836bdc0f3962de356621e5c50887c85c4af8R1407-R1409), where `recovery_spk_tagged_hash()` is implemented using [`ser_string()`](https://github.com/bitcoin/bitcoin/blob/af3dee0b8d456a8aa9ade9c6e7f4283a90590eae/test/function

No reviews
shesek·Updated Aug 8, 2025·0 reviews·0 attestations·View source
Collections:BIPs — Merged

Specification

The recovery scriptPubKey needs to be prefixed with its CompactSize-encoded length when computing the sPK hash.

I verified this by:

  • Checking the functional tests, where recovery_spk_tagged_hash() is implemented using ser_string() which adds the CompactSize-encoded length prefix
  • Using an implementation in Minsc to construct a transaction spending using OP_VAULT_RECOVER and broadcasting it to mutinynet (see line 2 for the recovery sPK hash computation)
  • Checking with @jamesob

Alternatively, the implementation could be amended to match the current specification and drop the length prefix. Since this is committing to a single element, the length isn't really necessary.

Discussion (0 threads)

Loading discussions...