wallet

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: Apache-2.0 Imports: 20 Imported by: 11

Documentation

Index

Constants

View Source
const (
	AddrVersionP2PKH = 0
	AddrVersionP2SH  = 5
)
View Source
const (
	BitcoinPrefix  = "bitcoin"
	CashAddrPrefix = "bitcoincash"
	SlpAddrPrefix  = "simpleledger"

	UnknownAddressTypeErrorMessage = "unknown address type"
)
View Source
const (
	TooManyAddressesErrorMsg = "error too many addresses in pk script"
	NoAddressesErrorMsg      = "error unable to find any addresses"
)
View Source
const (
	Bip44CoinTypeBTC = 0
	Bip44CoinTypeBCH = 145
	Bip44CoinTypeBSV = 236
	Bip44CoinTypeSLP = 245
)
View Source
const (
	ChainNameABC = "abc"
	ChainNameSV  = "sv"

	ChainNameFullBCH  = "bch"
	ChainNameFullBSV  = "bsv"
	ChainNameFullBCHA = "bcha"
)
View Source
const SigHashForkID txscript.SigHashType = 0x40

Variables

This section is empty.

Functions

func AddrsToSlices

func AddrsToSlices(addrs []Addr) [][]byte

func ConvertFloatSatoshisToBch

func ConvertFloatSatoshisToBch(satoshis float64) float64

func ConvertSatoshisToBch

func ConvertSatoshisToBch(satoshis uint64) float64

func DecodeTx

func DecodeTx(txHex string) (*wire.MsgTx, error)

func EncodeTx

func EncodeTx(tx *wire.MsgTx) string

func GetAddressListPkHashes

func GetAddressListPkHashes(addresses []Address) [][]byte

func GetAddressStringFromPkScript

func GetAddressStringFromPkScript(pkScript []byte) string

func GetBip44CoinPath

func GetBip44CoinPath(coinType uint) string

func GetBip44Path

func GetBip44Path(coinType, index uint, change bool) string

func GetChainNameFromFull

func GetChainNameFromFull(full string) string

func GetChainNameFullFromFull

func GetChainNameFullFromFull(full string) string

func GetMainNetParams

func GetMainNetParams() *chaincfg.Params

func GetSLPPath

func GetSLPPath() string

func GetSatoshiPath

func GetSatoshiPath() string

func IsAddressQuantityError

func IsAddressQuantityError(err error) bool

func IsDataOpCode

func IsDataOpCode(code byte) bool

func IsNoAddressesError

func IsNoAddressesError(err error) bool

func IsParsingMnemonicError

func IsParsingMnemonicError(err error) bool

func IsTooManyAddressesError

func IsTooManyAddressesError(err error) bool

Types

type Addr

type Addr [25]byte

func GetAddrFromBytes

func GetAddrFromBytes(b []byte) *Addr

func GetAddrFromLockScript

func GetAddrFromLockScript(lockScript []byte) (*Addr, error)

func GetAddrFromPkHash

func GetAddrFromPkHash(pkHash []byte) *Addr

func GetAddrFromString

func GetAddrFromString(addrString string) (*Addr, error)

func GetAddrFromUnlockScript

func GetAddrFromUnlockScript(unlockScript []byte) (*Addr, error)

func GetP2pkhAddrFromLockScript

func GetP2pkhAddrFromLockScript(lockScript []byte) (*Addr, error)

func GetP2pkhAddrFromUnlockScript

func GetP2pkhAddrFromUnlockScript(unlockScript []byte) (*Addr, error)

func GetP2shAddrFromLockScript

func GetP2shAddrFromLockScript(lockScript []byte) (*Addr, error)

func GetP2shAddrFromUnlockScript

func GetP2shAddrFromUnlockScript(unlockScript []byte) (*Addr, error)

func (Addr) Equals

func (a Addr) Equals(b Addr) bool

func (Addr) GetPkHash

func (a Addr) GetPkHash() []byte

func (Addr) IsP2PKH

func (a Addr) IsP2PKH() bool

func (Addr) IsP2SH

func (a Addr) IsP2SH() bool

func (Addr) OldAddress

func (a Addr) OldAddress() Address

func (Addr) String

func (a Addr) String() string

type Address

type Address struct {
	// contains filtered or unexported fields
}

func GetAddress

func GetAddress(pubKey []byte) Address

func GetAddressFromPkHash

func GetAddressFromPkHash(pkHash []byte) Address

func GetAddressFromPkHashNew

func GetAddressFromPkHashNew(pkHash []byte) (Address, error)

func GetAddressFromPkScript

func GetAddressFromPkScript(pkScript []byte) (*Address, error)

func GetAddressFromRedeemScript

func GetAddressFromRedeemScript(redeemScript []byte) (*Address, error)

func GetAddressFromScriptHash

func GetAddressFromScriptHash(scriptHash []byte) Address

func GetAddressFromScriptHashNew

func GetAddressFromScriptHashNew(scriptHash []byte) (*Address, error)

func GetAddressFromSignatureScript

func GetAddressFromSignatureScript(unlockScript []byte) (*Address, error)

func GetAddressFromString

func GetAddressFromString(addressString string) Address

func GetAddressFromStringErr

func GetAddressFromStringErr(addressString string) (*Address, error)

func GetAddressesForPkHashes

func GetAddressesForPkHashes(pkHashes [][]byte) ([]Address, error)

func (Address) GetAddr

func (a Address) GetAddr() Addr

func (Address) GetAddress

func (a Address) GetAddress() btcutil.Address

func (Address) GetCashAddrString

func (a Address) GetCashAddrString() string

func (Address) GetEncoded

func (a Address) GetEncoded() string

func (Address) GetPkHash

func (a Address) GetPkHash() []byte

func (Address) GetSlpAddrString

func (a Address) GetSlpAddrString() string

func (Address) IsP2PK

func (a Address) IsP2PK() bool

func (Address) IsP2PKH

func (a Address) IsP2PKH() bool

func (Address) IsP2SH

func (a Address) IsP2SH() bool

func (Address) IsSame

func (a Address) IsSame(b Address) bool

func (Address) IsSet

func (a Address) IsSet() bool

func (Address) ScriptAddress

func (a Address) ScriptAddress() []byte

type Block

type Block struct {
	Hash       *chainhash.Hash
	MerkleRoot *chainhash.Hash
}

func GetFirstBlock

func GetFirstBlock() Block

func GetGenesisBlock

func GetGenesisBlock() Block

type Change

type Change struct {
	Main Address
	Slp  Address
}

func GetChange

func GetChange(address Address) Change

func (Change) GetSlp

func (c Change) GetSlp() Address

type KeyRing

type KeyRing struct {
	Keys []PrivateKey
}

func GetSingleKeyRing

func GetSingleKeyRing(privateKey PrivateKey) KeyRing

func (KeyRing) GetKey

func (k KeyRing) GetKey(pkHash []byte) PrivateKey

type Mnemonic

type Mnemonic struct {
	Mnemonic bip39.Mnemonic
	Sentence string
}

func GenerateMnemonic

func GenerateMnemonic() (*Mnemonic, error)

func GetMnemonic

func GetMnemonic(entropy []byte) (*Mnemonic, error)

func GetMnemonicFromString

func GetMnemonicFromString(sentence string) (*Mnemonic, error)

func GetNewMnemonic

func GetNewMnemonic(mnemonic bip39.Mnemonic) *Mnemonic

func (*Mnemonic) GetPath

func (m *Mnemonic) GetPath(path string) (*PrivateKey, error)

func (*Mnemonic) GetPathExtended

func (m *Mnemonic) GetPathExtended(path string) (*hdkeychain.ExtendedKey, error)

BIP32 / BIP44

func (Mnemonic) IsSet

func (m Mnemonic) IsSet() bool

type OpCode

type OpCode struct {
	Code byte
	Data []byte
}

func Decompile

func Decompile(script []byte) []OpCode

func (OpCode) IsData

func (o OpCode) IsData() bool

func (OpCode) String

func (o OpCode) String() string

type OpCodes

type OpCodes []OpCode

func (OpCodes) String

func (o OpCodes) String() string

type PrivateKey

type PrivateKey struct {
	Secret []byte
}

func GeneratePrivateKey

func GeneratePrivateKey() PrivateKey

func GetPrivateKey

func GetPrivateKey(secretHex string) PrivateKey

func ImportPrivateKey

func ImportPrivateKey(wifString string) (PrivateKey, error)

func ImportPrivateKeyNew

func ImportPrivateKeyNew(wifString string) PrivateKey

func (PrivateKey) GetAddr

func (k PrivateKey) GetAddr() Addr

func (PrivateKey) GetAddress

func (k PrivateKey) GetAddress() Address

func (PrivateKey) GetBase58

func (k PrivateKey) GetBase58() string

func (PrivateKey) GetBase58Compressed

func (k PrivateKey) GetBase58Compressed() string

func (PrivateKey) GetBinaryString

func (k PrivateKey) GetBinaryString() string

func (PrivateKey) GetBtcEcPrivateKey

func (k PrivateKey) GetBtcEcPrivateKey() *btcec.PrivateKey

func (PrivateKey) GetHex

func (k PrivateKey) GetHex() string

func (PrivateKey) GetHexCompressed

func (k PrivateKey) GetHexCompressed() string

func (PrivateKey) GetPkHash

func (k PrivateKey) GetPkHash() []byte

func (PrivateKey) GetPublicKey

func (k PrivateKey) GetPublicKey() PublicKey

func (PrivateKey) IsSet

func (k PrivateKey) IsSet() bool

type PublicKey

type PublicKey struct {
	// contains filtered or unexported fields
}

func GetPublicKey

func GetPublicKey(pkBytes []byte) (PublicKey, error)

func (PublicKey) GetAddress

func (k PublicKey) GetAddress() Address

func (PublicKey) GetBtcEcPubKey

func (k PublicKey) GetBtcEcPubKey() *btcec.PublicKey

func (PublicKey) GetPkHash

func (k PublicKey) GetPkHash() []byte

func (PublicKey) GetSerialized

func (k PublicKey) GetSerialized() []byte

func (PublicKey) GetSerializedString

func (k PublicKey) GetSerializedString() string

type Wallet

type Wallet struct {
	Entropy    []byte
	Passphrase string
}

func GetWallet

func GetWallet(mnemonicPhrase string, passphrase string) (Wallet, error)

func (*Wallet) GetEntropy

func (w *Wallet) GetEntropy() string

func (*Wallet) GetSeed

func (w *Wallet) GetSeed() (string, error)

Jump to

Keyboard shortcuts

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