Skip to content

Hierarchical Deterministic(HD) wallet for cryptocurrencies

License

Notifications You must be signed in to change notification settings

Samourai-Wallet/HDWalletKit

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WalletKit

WalletKit is a Swift framework that enables you to create and use HD wallets (Hierarchical Deterministic Wallets) in your own app.

You can check if the address generation is working right here.

Features

How to use

  • Generate seed and convert it to mnemonic sentence.
let entropy = Data(hex: "000102030405060708090a0b0c0d0e0f")
let mnemonic = Mnemonic.create(entropy: entropy)
print(mnemonic)
// abandon amount liar amount expire adjust cage candy arch gather drum buyer

let seed = Mnemonic.createSeed(mnemonic: mnemonic)
print(seed.toHexString())
  • PrivateKey and key derivation (BIP32, BIP44).
let masterPrivateKey = PrivateKey(seed: seed, network: .main)

// m/44'
let purpose = masterPrivateKey.derived(at: 44, hardens: true)

// m/44'/0'
let coinType = purpose.derived(at: 0, hardens: true)

// m/44'/0'/0'
let account = coinType.derived(at: 0, hardens: true)

// m/44'/0'/0'/0
let change = account.derived(at: 0)

// m/44'/0'/0'/0
let firstPrivateKey = change.derived(at: 0)
print(firstPrivateKey.publicKey.address)
  • Create your wallet and generate addresses.
// It generates master key pair from the seed provided.
let wallet = Wallet(seed: seed, network: .main)

let firstAddress = wallet.generateAddress(at: 0)
print(firstAddress)

let secondAddress = wallet.generateAddress(at: 1)
print(secondAddress)

let thirdAddress = wallet.generateAddress(at: 2)
print(thirdAddress)

License

WalletKit is released under the MIT License.

About

Hierarchical Deterministic(HD) wallet for cryptocurrencies

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 99.4%
  • Ruby 0.6%