GithubHelp home page GithubHelp logo

astrokin / cryptocore Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kevinvitale/walletkit

1.0 1.0 3.0 392 KB

Modern Swift implementations of BIP39, BIP32, and BIP44

License: Apache License 2.0

Dockerfile 0.06% Swift 14.42% C 85.52%

cryptocore's Introduction

PLEASE NOTE!

This is fork from KevinVitale/WalletKit

Due to SPM (Swift package manager) and github restrictions it's impossible to add original KevinVitale wallet as dependency to SPM in XCode. That's why below repos had been created to make it work:

Adding WalletKit as a Dependency

To use the WalletKit library in a Swift Package Manager (SPM) project, add the following line to the dependencies in you Package.swift file:

.package(url: "https://github.com/astrokin/WalletKit", branch: "main"),

The WalletKit library is under active development, and while attempts are made to maintain source-stability, this is not guaranteed between minor versions. You may specify .upToNextMinor(from:), instead of from(_:), if you need to be at a specific version.

Platforms

  • macOS, v10.15+;
  • iOS, v13+;
  • Linux

CLI Utility

This CLI utility is cross-platform, and demonstrates a portion of this framework's functionality.

Usage

import WalletKit

let wallet  = try Mnemonic().createWallet()
let account = try wallet.account(coinType: .ETH, atIndex: 0)

// 'Normal' addresses...
account[.normal(0..<10)].forEach { 
    print($0.address)
}

// 'Hardened' addresses...
account[.hardened(0..<10)].forEach { 
    print($0.address)
}

Examples

let mnemonic = try Mnemonic()
  print(mnemonic.phrase)

  let accounts = try mnemonic.createWallet().account(coinType: .ETH, atIndex: 0)
  accounts[.hardened(0..<10)].enumerated().forEach { (index, account) in
    let address = account.address
    let privateKey = "0x" + account.privateKey.key.dropFirst().hexString
    
    print("[idx: \(index)]", address, privateKey)
  }
}

// Console output
<24-word seed phrase>
[idx: 0] 0x95e18dd2115c49651a5195cdaed1e4589d9a882d 0x...privatekey...
[idx: 1] 0x70c52be490029822278eecf2d9e4324c6e0505b8 0x...privatekey...
[idx: 2] 0x11194b63c701ba9612d8b4c29e9d34127160043c 0x...privatekey...
[idx: 3] 0x90ec34dd860c4e2876ea3e2ce3f7362d6ef9c8b5 0x...privatekey...
[idx: 4] 0x3a0a814ad24e703aae2b1acb2211dba4dab7330f 0x...privatekey...
[idx: 5] 0x9cc103ff117e604fbf5fee3d4b90b2646576190f 0x...privatekey...
[idx: 6] 0x263c0757284090a3ceec27243d483399bbc0a570 0x...privatekey...
[idx: 7] 0x645b93bda895c130451b5e20341130665f693c53 0x...privatekey...
[idx: 8] 0x14b6fdfdbe37fbcd6a2e4a6f85a303bcc8327552 0x...privatekey...
[idx: 9] 0xffd4e7a268a8cf75f4215f06a8ebc049195c1b4e 0x...privatekey...

Command-Line Interface

USAGE: cli [--seed-phrase <seed-phrase>] [--passphrase <passphrase>]

OPTIONS:
  -s, --seed-phrase <seed-phrase>
                          A specific mnemonic seed phrase used to create the wallet. 
  -p, --passphrase <passphrase>
                          An optional passphrase for improving entropy. 
  -h, --help              Show help information.

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.