BitcoinKit implements Bitcoin protocol in Swift. It is an implementation of the Bitcoin SPV protocol written (almost) entirely in swift.
- Send/receive transactions.
- See current balance in a wallet.
- Encoding/decoding addresses: P2PKH, WIF format.
- Transaction building blocks: inputs, outputs, scripts.
- EC keys and signatures.
- BIP32, BIP44 hierarchical deterministic wallets.
- BIP39 implementation.
sh ./setup/build_libraries.sh
let privateKey = PrivateKey(network: .testnet) // You can choose .mainnet or .testnet
let wallet = Wallet(privateKey: privateKey)
let wallet = try Wallet(wif: "92pMamV6jNyEq9pDpY4f6nBy9KpV2cfJT4L5zDUYiGqyQHJfF1K")
// Generate mnemonic
let mnemonic = try Mnemonic.generate()
// Generate seed from the mnemonic
let seed = Mnemonic.seed(mnemonic: mnemonic)
let wallet = HDWallet(seed: seed, network: .testnet)
let mnemonic = try Mnemonic.generate()
let seed = Mnemonic.seed(mnemonic: mnemonic)
let privateKey = HDPrivateKey(seed: seed, network: .testnet)
// m/0'
let m0prv = try! privateKey.derived(at: 0, hardened: true)
// m/0'/1
let m01prv = try! m0prv.derived(at: 1)
// m/0'/1/2'
let m012prv = try! m01prv.derived(at: 2, hardened: true)
let extendedKey = privateKey.extended()
let blockStore = try! SQLiteBlockStore.default()
let blockChain = BlockChain(wallet: wallet, blockStore: blockStore)
let peerGroup = PeerGroup(blockChain: blockChain)
let peerGroup.delegate = self
let peerGroup.start()
BitcoinKit is available through Carthage. To install it, simply add the following line to your Cartfile:
github "kishikawakatsumi/BitcoinKit"
Feel free to open issues, drop us pull requests or contact us to discuss how to do things.
Email: [email protected]
Twitter: @k_katsumi
BitcoinKit is available under the Apache 2.0 license. See the LICENSE file for more info.