|
1 |
| -# hardwallet |
2 |
| -Hyperpay hardwallet |
| 1 | +# Hyperpay Wallet HardWallet |
| 2 | + |
| 3 | +HardWallet is committed to build a straightforward and easy-to-use library. |
| 4 | +The open source framework displays all functions and methods related to the hardware wallet. Contains related mnemonics, private keys, addresses and related signed transactions. |
| 5 | +And use a ble middleware to simulate the relevant data compression and transmission under Bluetooth communication. |
| 6 | + |
| 7 | +## Environment Setup |
| 8 | + |
| 9 | +- [Go Installation](https://golang.org/doc/install) |
| 10 | +- About the missing librarys, use `go get xxx ..` to install them |
| 11 | +- `git clone https://github.com/hyperpayorg/hardwallet` |
| 12 | +- `cd hardwallet` |
| 13 | + |
| 14 | +## How to use |
| 15 | + |
| 16 | +For ease of use and understanding, some tests that can be tested directly are written. |
| 17 | +This can help to quickly understand the relationship between the various components. |
| 18 | + |
| 19 | + |
| 20 | +## Generate wallet |
| 21 | +Private key, public key and address can be generated by `GenerateMnWallet` func. |
| 22 | +Language supports: `english`、`korean`、`chinese_simplified` ,etc. |
| 23 | +Mnemonics supports: `12 words`、`24 words`,etc. |
| 24 | +Password supported. |
| 25 | +```go |
| 26 | +ceateAccount := &clientwallet.CreateAccount{ |
| 27 | + Language: "english", |
| 28 | + Length: 12, |
| 29 | + Password: "123456", |
| 30 | +} |
| 31 | +fmt.Println(ceateAccount) |
| 32 | +isCreated := clientwallet.GenerateMnWallet(ceateAccount) |
| 33 | +fmt.Println(isCreated) |
| 34 | +``` |
| 35 | +## Wallet SignRawTransation |
| 36 | +SignRawTransation can be generated by `func SignRawTransaction(signIn *SignInput)` func. |
| 37 | + |
| 38 | +```go |
| 39 | +signIn := &clientwallet.SignInput{ |
| 40 | + Coin: "btc", |
| 41 | + Symbol: "btc", |
| 42 | + Amount: 10000, |
| 43 | + Change: 25000000 - 10000 - 10000, |
| 44 | + Fee: 10000, |
| 45 | + SrcAddr: "", |
| 46 | + DestAddr: "", |
| 47 | + Net: "testnet", |
| 48 | + Password: "123456", |
| 49 | + Inputs: jsonInputs, |
| 50 | +} |
| 51 | + |
| 52 | +signResult := clientwallet.SignRawTransaction(signIn) |
| 53 | +fmt.Println(signResult) |
| 54 | +``` |
| 55 | +Data structure returned as follow: |
| 56 | +```go |
| 57 | +type WalletAccount struct { |
| 58 | + ResCode int // 0 fail 1 Success |
| 59 | + Address string |
| 60 | + PublicKey string |
| 61 | + PrivateKey string |
| 62 | + Seed string // root seed |
| 63 | + Coin string |
| 64 | + ErrMsg string // fail messages |
| 65 | + ErrCode int // err code |
| 66 | + Params []byte // reserved fields |
| 67 | +} |
| 68 | +``` |
| 69 | + |
| 70 | + |
| 71 | +### Wallet EnKeystore |
| 72 | + |
| 73 | +Key information storage supports pwd & udid. |
| 74 | +```go |
| 75 | +Key := "L1oh9KNH4XpJgqDodxhjPgaEVS1qwXToWvPf2Zyn6bcm7xxxxxxx" |
| 76 | +pwd := "11111" |
| 77 | +udid := "AOIJF-QWEQR-VDFBET-YTAWWE" |
| 78 | + |
| 79 | +// Encode |
| 80 | +enResult := EnKeystore(Key, pwd, udid) |
| 81 | +fmt.Println("Keystore : \n", enResult.Result) |
| 82 | +``` |
| 83 | +## Wallet KeyStore File Decrypt |
| 84 | +The keystore file is decrypted using the KeyStore json, udid and the password. |
| 85 | + |
| 86 | +To decrypt keystore file, use the following methods: |
| 87 | + |
| 88 | + |
| 89 | +```go |
| 90 | +func DeKeystore(json, password, udid string) |
| 91 | +``` |
| 92 | + |
| 93 | +> Description: JSON is the KeyStore JSON file |
| 94 | + |
| 95 | +Data structure returned as `KeystoreResult`。 |
| 96 | + |
| 97 | +### Wallet DeKeystore |
| 98 | +```go |
| 99 | + enResult := "xxxxxxx" |
| 100 | + pwd := "11111" |
| 101 | + udid := "AOIJF-QWEQR-VDFBET-YTAWWE" |
| 102 | + // Decode |
| 103 | + deResult := DeKeystore(enResult, pwd, udid) |
| 104 | + fmt.Println("PrivateKey : ", deResult.Result) |
| 105 | +``` |
0 commit comments