Bitcoin support on Turnkey
BIP32 and BIP44: the basis for Turnkey wallets
BIP32 and BIP44 are standards developed in the Bitcoin ecosystem. Turnkey closely follows this to power Wallets since they're adopted within Bitcoin and outside, spanning many other ecosystems.
BIP39: mnemonics
Turnkey supports importing and exporting keys in mnemonics form, following BIP39. This standard is now a de-facto standard across virtually all blockchains today.
Address derivation
You can derive Bitcoin addresses when creating a Turnkey wallet or private key. The address types we support currently:
- P2PKH (Pay-To-Public-Key-Hash)
- P2SH (Pay-To-Script-Hash)
- P2WPKH (Pay-to-Witness-Public-Key-Hash) -- segwit-enabled
- P2WSH (Pay-to-Witness-Script-Hash) -- segwit-enabled
- P2TR (Pay-to-Taproot) -- taproot-enabled
Bitcoin addresses change depending on the network you're using (more precisely, their prefix!). When you derive an address the network will be part of the address format. We support the following networks:
- Mainnet (
MAINNET
) - Testnet (
TESTNET
) - Regtest (
REGTEST
) - Signet (
SIGNET
)
For example:
- To derive a P2TR address on testnet, use
ADDRESS_FORMAT_BITCOIN_TESTNET_P2TR
. - To derive a P2SH address on mainnet, use
ADDRESS_FORMAT_BITCOIN_MAINNET_P2SH
.
Schnorr signatures and tweaks
The historical signature scheme for Bitcoin is ECDSA. Turnkey supports ECDSA of course, but we also support Schnorr signatures for Taproot addresses.
To sign with Schnorr, pass a taproot (P2TR) address inside of your activity's signWith
parameter. Turnkey's signer will switch to Schnorr and apply the correct cryptographic tweak before signing.
SDK example
If you want to get started with Bitcoin we encourage you to look at the following SDK example: examples/with-bitcoin
. It showcases transaction construction and signing with bitcoinjs-lib
, a widely used JS library.
This demo contains a client-side signer which seamlessly integrates Turnkey signing with this library for both taproot and non-taproot output signatures. Let us know if you're interested in using it. We have not yet published it as a standalone NPM package, but could do it if we hear enough interest!