When Taproot? Now.
Bitcoin Dev Kit (BDK) provides a comprehensive toolkit for bitcoin development, and bdk-ffi recently added the Taproot BIP-86 descriptor template.
Default Taproot
The BDK Swift Example Wallet currently defaults to using Taproot. This deliberate choice underscores the importance of Taproot's features such as enhanced privacy and efficiency, even though currently not all major exchanges support even sending to Taproot addresses.
Address Types
Having different types of addresses in the bitcoin ecosystem allows for flexibility in transactions, cost savings, and improvements in privacy and security. There are different types of bitcoin addresses:
Pay-to-Public-Key-Hash (P2PKH)
P2PKH addresses usually start with '1'.
Pay-to-Script-Hash (P2SH)
P2SH addresses usually start with '3'.
Segregated Witness (SegWit)
SegWit addresses usually start with 'bc1'.
Taproot
Taproot addresses also start with 'bc1', but are distinguishable by their length and characters used.
Taproot Benefits
Taproot is a soft fork change to bitcoin that went into effect in November 2021 and it represents a major advancement in bitcoin technology. It offers potential improvements including:
Enhanced Privacy: Combines various transaction types into one, making it difficult to distinguish between them.
Reduced Costs: Uses less blockchain space, translating to lower transaction fees.
For a nice overview of Taproot check out this cool Taproot Zine, and for a specific look at BIP-86 check it out on GitHub.
bdk-ffi
The Taproot BIP-86 descriptor template was merged into bdk-ffi in August 2023 and is included in Release v0.30.0 from September 2023.
Taproot + bdk-swift
Since the bdk-ffi Swift bindings flow from bdk-ffi, the BIP-86 template is now available in the newest bdk-swift release as well: bdk-swift 0.30.0.
In Developing a Bitcoin Wallet for iOS the code that is related to using this template when creating a wallet is in the section “Create Wallet”:
let mnemonicWords12 =
"space echo position wrist orient erupt relief museum myself grain wisdom tumble"
let mnemonic = try Mnemonic.fromString(mnemonic: mnemonicWords12)
let secretKey = DescriptorSecretKey(
network: .testnet,
mnemonic: mnemonic,
password: nil
)
let descriptor = Descriptor.newBip86(
secretKey: secretKey,
keychain: .external,
network: .testnet
)
let changeDescriptor = Descriptor.newBip86(
secretKey: secretKey,
keychain: .internal,
network: .testnet
)
let wallet = try Wallet(
descriptor: descriptor,
changeDescriptor: changeDescriptor,
network: .testnet,
databaseConfig: .memory
)
`newBip86` is the Taproot BIP-86 template
Next Steps
The suggestion is to make Taproot the default in a bitcoin wallet to take advantage of its benefits as well as increase wallet interoperability.
Now that we have completed:
Developing a bitcoin wallet
Designing a bitcoin wallet
Defaulting to Taproot
… let’s speed up our development and iteration by using Mutinynet.