Coder Social home page Coder Social logo

bitcoinkit's Introduction

BitcoinKit

CI Status codecov Carthage compatible Version Platform

BitcoinKit implements Bitcoin protocol in Swift. It is an implementation of the Bitcoin SPV protocol written (almost) entirely in swift.

ย 

Features

  • 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.

Usage

Creating new wallet

let privateKey = PrivateKey(network: .testnet) // You can choose .mainnet or .testnet
let wallet = Wallet(privateKey: privateKey)

Import wallet from WIF

let wallet = try Wallet(wif: "92pMamV6jNyEq9pDpY4f6nBy9KpV2cfJT4L5zDUYiGqyQHJfF1K")

Hierarchical Deterministic Wallet

// 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)

Key derivation

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)

HD Wallet Key derivation

let keychain = HDKeychain(seed: seed, network: .mainnet)
let privateKey = try! keychain.derivedKey(path: "m/44'/1'/0'/0/0")
...

Extended Keys

let extendedKey = privateKey.extended()

Sync blockchain

let blockStore = try! SQLiteBlockStore.default()
let blockChain = BlockChain(wallet: wallet, blockStore: blockStore)

let peerGroup = PeerGroup(blockChain: blockChain)
let peerGroup.delegate = self

let peerGroup.start()

Installation

Carthage

BitcoinKit is available through Carthage. To install it, simply add the following line to your Cartfile:

github "kishikawakatsumi/BitcoinKit"

CocoaPods

BitcoinKit is available through CocoaPods. To install it, simply add the following lines to your Podfile:

use_frameworks!
pod 'BitcoinKit'

Contribute

Feel free to open issues, drop us pull requests or contact us to discuss how to do things.

Email: [email protected]

Twitter: @k_katsumi

License

BitcoinKit is available under the Apache 2.0 license. See the LICENSE file for more info.

bitcoinkit's People

Contributors

kishikawakatsumi avatar d-date avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.