Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bchainhub/go-core-hdwallet
https://github.com/bchainhub/go-core-hdwallet
Last synced: about 11 hours ago
JSON representation
- Host: GitHub
- URL: https://github.com/bchainhub/go-core-hdwallet
- Owner: bchainhub
- License: mit
- Created: 2022-10-13T10:43:11.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2022-10-18T08:06:58.000Z (about 2 years ago)
- Last Synced: 2024-09-17T03:34:33.657Z (about 2 months ago)
- Language: Go
- Size: 1.57 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# go-core-hdwallet
> Ethereum HD Wallet derivations from [mnemonic] seed in Go (golang). Implements the [go-core](https://github.com/core-coin/go-core) [`accounts.Wallet`](https://github.com/core-coin/go-core/blob/master/accounts/accounts.go) interface.
[![License](http://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/miguelmota/go-core-hdwallet/master/LICENSE) [![Build Status](https://travis-ci.org/miguelmota/go-core-hdwallet.svg?branch=master)](https://travis-ci.org/miguelmota/go-core-hdwallet) [![Go Report Card](https://goreportcard.com/badge/github.com/cryptohub-digital/go-core-hdwallet?)](https://goreportcard.com/report/github.com/cryptohub-digital/go-core-hdwallet) [![GoDoc](https://godoc.org/github.com/cryptohub-digital/go-core-hdwallet?status.svg)](https://godoc.org/github.com/cryptohub-digital/go-core-hdwallet)
## Install
```bash
go get -u github.com/cryptohub-digital/go-core-hdwallet
```## Documenation
[https://godoc.org/github.com/cryptohub-digital/go-core-hdwallet](https://godoc.org/github.com/cryptohub-digital/go-core-hdwallet)
## Getting started
```go
package mainimport (
"fmt"
"log""github.com/cryptohub-digital/go-core-hdwallet"
)func main() {
mnemonic := "tag volcano eight thank tide danger coast health above argue embrace heavy"
wallet, err := hdwallet.NewFromMnemonic(mnemonic)
if err != nil {
log.Fatal(err)
}path := hdwallet.MustParseDerivationPath("m/44'/60'/0'/0/0")
account, err := wallet.Derive(path, false)
if err != nil {
log.Fatal(err)
}fmt.Println(account.Address.Hex()) // 0xC49926C4124cEe1cbA0Ea94Ea31a6c12318df947
path = hdwallet.MustParseDerivationPath("m/44'/60'/0'/0/1")
account, err = wallet.Derive(path, false)
if err != nil {
log.Fatal(err)
}fmt.Println(account.Address.Hex()) // 0x8230645aC28A4EdD1b0B53E7Cd8019744E9dD559
}
```### Signing transaction
```go
package mainimport (
"log"
"math/big""github.com/davecgh/go-spew/spew"
"github.com/core-coin/go-core/common"
"github.com/core-coin/go-core/core/types"
"github.com/cryptohub-digital/go-core-hdwallet"
)func main() {
mnemonic := "tag volcano eight thank tide danger coast health above argue embrace heavy"
wallet, err := hdwallet.NewFromMnemonic(mnemonic)
if err != nil {
log.Fatal(err)
}path := hdwallet.MustParseDerivationPath("m/44'/60'/0'/0/0")
account, err := wallet.Derive(path, true)
if err != nil {
log.Fatal(err)
}nonce := uint64(0)
value := big.NewInt(1000000000000000000)
toAddress := common.HexToAddress("0x0")
gasLimit := uint64(21000)
gasPrice := big.NewInt(21000000000)
var data []bytetx := types.NewTransaction(nonce, toAddress, value, gasLimit, gasPrice, data)
signedTx, err := wallet.SignTx(account, tx, nil)
if err != nil {
log.Fatal(err)
}spew.Dump(signedTx)
}
```## Test
```bash
make test
```## License
[MIT](LICENSE)