hdwallet

package
v0.0.0-...-d238806 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2019 License: GPL-2.0, GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Copyright 2013-present wemeetagain https://github.com/wemeetagain/go-hdwallet Copyright 2019-present Varunram Ganesh

Index

Constants

This section is empty.

Variables

View Source
var (
	MnPubkeyVByte    = []byte{4, 136, 178, 30}  // mainnet magic bytes
	MnPrivkeyVByte   = []byte{4, 136, 173, 228} // mainnet magic bytes
	TestPubkeyVByte  = []byte{4, 53, 135, 207}  // testnet magic bytes
	TestPrivkeyVByte = []byte{4, 53, 131, 148}  // testnet magic bytes
	HmacKey          = []byte("Bitcoin seed")   // HMAC Key
)

declare version bytes and HMAC key

Functions

func GenSeed

func GenSeed(length int) ([]byte, error)

GenSeed returns a random seed with a length measured in bytes. The length must be at least 128.

Types

type HDWallet

type HDWallet struct {
	VersionBytes []byte //4 bytes
	Depth        uint16 //1 byte
	Fingerprint  []byte //4 bytes
	ChildNumber  []byte //4 bytes
	Chaincode    []byte //32 bytes
	Key          []byte //33 bytes
}

HDWallet defines the components of a hierarchical deterministic wallet

func MasterKey

func MasterKey(seed []byte) *HDWallet

MasterKey returns a new wallet given a random seed.

func (*HDWallet) Address

func (w *HDWallet) Address() string

Address returns bitcoin address represented by wallet w.

func (*HDWallet) Child

func (w *HDWallet) Child(i uint32) (*HDWallet, error)

Child returns the ith child of wallet w. Values of i >= 2^31 signify private key derivation. Attempting private key derivation with a public key will throw an error.

func (*HDWallet) Pub

func (w *HDWallet) Pub() *HDWallet

Pub returns a new wallet which is the public key version of w. If w is a public key, Pub returns a copy of w

func (*HDWallet) Serialize

func (w *HDWallet) Serialize() []byte

Serialize returns the serialized form of the wallet.

func (*HDWallet) String

func (w *HDWallet) String() string

String returns the base58-encoded string form of the wallet.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL