BCSkill (Block chain skill )
区块链中文技术社区

只讨论区块链底层技术
遵守一切相关法律政策!

由Golang实现的多币种HD钱包

https://github.com/foxnut/go-hdwallet

supported coins

  • BTC
  • LTC
  • DOGE
  • DASH
  • ETH
  • ETC
  • BCH
  • QTUM
  • USDT
  • IOST
  • USDC

install

go get -v -u github.com/foxnut/go-hdwallet

example

package main

import (
    "fmt"

    "github.com/foxnut/go-hdwallet"
)

var (
    mnemonic = "range sheriff try enroll deer over ten level bring display stamp recycle"
)

func main() {
    master, err := hdwallet.NewKey(
        hdwallet.Mnemonic(mnemonic),
    )
    if err != nil {
        panic(err)
    }

    // BTC: 1AwEPfoojHnKrhgt1vfuZAhrvPrmz7Rh4
    wallet, _ := master.GetWallet(hdwallet.CoinType(hdwallet.BTC), hdwallet.AddressIndex(1))
    address, _ := wallet.GetAddress()
    addressP2WPKH, _ := wallet.GetKey().AddressP2WPKH()
    addressP2WPKHInP2SH, _ := wallet.GetKey().AddressP2WPKHInP2SH()
    fmt.Println("BTC: ", address, addressP2WPKH, addressP2WPKHInP2SH)

    // BCH: 1CSBT18sjcCwLCpmnnyN5iqLc46Qx7CC91
    wallet, _ = master.GetWallet(hdwallet.CoinType(hdwallet.BCH))
    address, _ = wallet.GetAddress()
    addressBCH, _ := wallet.GetKey().AddressBCH()
    fmt.Println("BCH: ", address, addressBCH)

    // LTC: LLCaMFT8AKjDTvz1Ju8JoyYXxuug4PZZmS
    wallet, _ = master.GetWallet(hdwallet.CoinType(hdwallet.LTC))
    address, _ = wallet.GetAddress()
    fmt.Println("LTC: ", address)

    // DOGE: DHLA3rJcCjG2tQwvnmoJzD5Ej7dBTQqhHK
    wallet, _ = master.GetWallet(hdwallet.CoinType(hdwallet.DOGE))
    address, _ = wallet.GetAddress()
    fmt.Println("DOGE:", address)

    // ETH: 0x37039021cBA199663cBCb8e86bB63576991A28C1
    wallet, _ = master.GetWallet(hdwallet.CoinType(hdwallet.ETH))
    address, _ = wallet.GetAddress()
    fmt.Println("ETH: ", address)

    // ETC: 0x480C69E014C7f018dAbF17A98273e90f0b0680cf
    wallet, _ = master.GetWallet(hdwallet.CoinType(hdwallet.ETC))
    address, _ = wallet.GetAddress()
    fmt.Println("ETC: ", address)
}

以太坊观察者

https://github.com/HydroProtocol/ethereum-watcher

ethereum-watcher是用Golang编写的以太坊区块链的事件监听器。使用以太坊观察器,您可以监视和跟踪以太坊区块链上发生的当前或历史事件。

背景

与以太坊区块链交互的许多应用程序需要知道链上何时发生特定动作,但无法直接访问链上数据。ethereum-watcher充当应用程序和链之间的接口:从区块链收集指定的数据,以便应用程序可以与链上事件进行更无缝的交互。

特征

插件友好。您可以轻松地向以太坊观察者添加一个插件,以侦听任何类型的链上事件。
叉公差。如果发生派生,则将一条还原消息发送给订户。