wallet

package
v0.0.0-...-6d370a6 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ZeroCoinType uint32 = 0x80000000
)

Variables

View Source
var DefaultPath = Path{
	Purpose:      2147483692,
	CoinType:     2147483648,
	Account:      2147483648,
	Change:       0,
	AddressIndex: 0,
}

Functions

func Int2Hex

func Int2Hex(n int64) []byte

func SerializeIns

func SerializeIns(ins []*TxIn) []byte

func Serializeouts

func Serializeouts(outs []*TxOut) []byte

func Str2Number

func Str2Number(str string) uint32

Types

type Account

type Account struct {
	ExtendedKey *hdkeychain.ExtendedKey // extended private key

	BtcecPriv *btcec.PrivateKey
	BtcecPub  *btcec.PublicKey

	PriavateKey *ecdsa.PrivateKey
	PublicKey   *ecdsa.PublicKey

	PublicKeyByte []byte // serialized compressed Public Key
	Address       string

	Path Path
}

func (*Account) SignTx

func (a *Account) SignTx(tx *Transaction)

type Chainid

type Chainid int

type Path

type Path struct {
	Purpose      uint32
	CoinType     uint32
	Account      uint32
	Change       uint32
	AddressIndex uint32
}

func String2Path

func String2Path(path string) Path

func (Path) String

func (p Path) String() string

type Publickey

type Publickey []byte // btcec serialized compressed publickey

type Publickeyhash

type Publickeyhash []byte

type Transaction

type Transaction struct {
	Timestamp time.Duration
	TxID      []byte
	TxInputs  []*TxIn
	TxOutputs []*TxOut
}

func NewTX

func NewTX(utxos []*UTXO, from Publickey, to Publickeyhash, amount int) (*Transaction, error)

func (*Transaction) Hash

func (tx *Transaction) Hash() []byte

func (*Transaction) Serialize

func (tx *Transaction) Serialize() []byte

type TxIn

type TxIn struct {
	OutPoint  []byte
	Vout      uint
	Value     int
	PublicKey []byte
	Signature []byte
}

type TxOut

type TxOut struct {
	PublicKeyHash []byte
	Value         int
}

type UTXO

type UTXO struct {
	Txid  []byte
	Index uint
	Txout *TxOut
}

type Wallet

type Wallet struct {
	MasterKey string
	Mnemonic  string
	Seed      []byte
	Accounts  map[string]*Account
}

func NewWallet

func NewWallet(mnemonic string) *Wallet

func (*Wallet) Account

func (w *Wallet) Account(a string) *Account

func (*Wallet) NewAccount

func (w *Wallet) NewAccount()

func (*Wallet) SortAccounts

func (w *Wallet) SortAccounts() []*Account

Jump to

Keyboard shortcuts

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