Git Product home page Git Product logo

hardwallet's Introduction

Hyperpay Wallet HardWallet

HardWallet is committed to build a straightforward and easy-to-use library. The open source framework displays all functions and methods related to the hardware wallet. Contains related mnemonics, private keys, addresses and related signed transactions. And use a ble middleware to simulate the relevant data compression and transmission under Bluetooth communication.

Environment Setup

  • Go Installation
  • git clone https://github.com/hyperpayorg/hardwallet
  • About the missing librarys, use go get xxx .. to install them
  • cd hardwallet

How To Use

For ease of use and understanding, some tests that can be tested directly are written. This can help to quickly understand the relationship between the various components.

Generate Wallet

Private key, public key and address can be generated by GenerateMnWallet func. Language supports: englishkoreanchinese_simplified ,etc. Mnemonics supports: 12 words24 words,etc. Password supported.

ceateAccount := &clientwallet.CreateAccount{
	Language: "english",
	Length:   12,
	Password: "123456",
}
fmt.Println(ceateAccount)
isCreated := clientwallet.GenerateMnWallet(ceateAccount)
fmt.Println(isCreated)

Wallet SignRawTransation

SignRawTransation can be generated by func SignRawTransaction(signIn *SignInput) func.

signIn := &clientwallet.SignInput{
		Coin:     "btc",
		Symbol:   "btc",
		Amount:   10000,
		Change:   25000000 - 10000 - 10000,
		Fee:      10000,
		SrcAddr:  "",
		DestAddr: "",
		Net:      "testnet",
		Password: "123456",
		Inputs:   jsonInputs,
}

signResult := clientwallet.SignRawTransaction(signIn)
fmt.Println(signResult)

Data structure returned as follow:

type WalletAccount struct {
	ResCode    int    // 0 fail 1 Success
	Address    string
	PublicKey  string
	PrivateKey string
	Seed       string // root seed
	Coin       string
	ErrMsg     string // fail messages
	ErrCode    int    // err code
	Params     []byte // reserved fields
}

Wallet EnKeystore

Key information storage supports pwd & udid.

Key := "L1oh9KNH4XpJgqDodxhjPgaEVS1qwXToWvPf2Zyn6bcm7xxxxxxx"
pwd := "11111"
udid := "AOIJF-QWEQR-VDFBET-YTAWWE"

// Encode
enResult := EnKeystore(Key, pwd, udid)
fmt.Println("Keystore : \n", enResult.Result)

Wallet KeyStore File Decrypt

The keystore file is decrypted using the KeyStore json, udid and the password.

To decrypt keystore file, use the following methods:

func DeKeystore(json, password, udid string)

Description: JSON is the KeyStore JSON file

Data structure returned as KeystoreResult

Wallet DeKeystore

enResult := "xxxxxxx"
pwd := "11111"
udid := "AOIJF-QWEQR-VDFBET-YTAWWE"
// Decode
deResult := DeKeystore(enResult, pwd, udid)
fmt.Println("PrivateKey : ", deResult.Result)

hardwallet's People

Contributors

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