Skip to content

Commit

Permalink
Accept both ' and h suffixes for hardened indexes
Browse files Browse the repository at this point in the history
Needed to parse descriptors and pubkey path returned by Bitcoin Core.
  • Loading branch information
sstone committed May 29, 2023
1 parent 2c61e94 commit a78c78c
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,8 @@ class BitcoinCoreClient(val rpcClient: BitcoinJsonRPCClient, val onchainKeyManag
val extracted = PublicKey(ByteVector.fromValidHex(rawKey))
// check that when we manage private keys we can re-compute the public key we got from bitcoin core
// and that the address and public key match
val computed_opt = this.onchainKeyManager_opt.map(_.getPublicKey(DeterministicWallet.KeyPath(keyPath)))
val keyPath1 = keyPath.replace('h', '\'') // our bitcoin lib expects a ' suffix for hardened indexes and does not yet accept the h suffix
val computed_opt = this.onchainKeyManager_opt.map(_.getPublicKey(DeterministicWallet.KeyPath(keyPath1)))
require(computed_opt.forall(_ == (extracted, address)), "cannot recompute pubkey generated by bitcoin core")
extracted
}
Expand Down

0 comments on commit a78c78c

Please sign in to comment.