Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatBalance ¶
FormatBalance converts the balance to the denomination specified and returns a string with the value and the unit.
Initially, balance is represented in satoshis.
func HashPubKey ¶
HashPubKey hashes the public key.
func ValidateAddress ¶
ValidateAddress checks if address is valid.
Types ¶
type Account ¶
type Account struct {
// Use one mutex for both maps as they are accessed
PrivKey *Key
PubKey *Key
ChangeAddresses map[string]struct{}
ReceivingAddresses map[string]struct{}
NextKeyIndex uint32
}
Account contains a master key and the name the user has chosen to identify it.
func NewAccount ¶
NewAccount returns a new account with the key provided.
func (*Account) NewAddress ¶
NewAddress returns an address corresponding to the account that hasn't been used before.
If receiving is false, the address will be marked as a change address.
func (*Account) NewAddresses ¶
NewAddresses returns a list of receiving addresses. Change addresses are handled internally.
func (*Account) PrivateKey ¶
func (a *Account) PrivateKey() *ecdsa.PrivateKey
PrivateKey returns the private key of an account.
func (*Account) UsedAddresses ¶
UsedAddresses returns receiving and change addresses that were utilizied.
type Key ¶
type Key struct {
// Version bytes (4 bytes)
Vbytes []byte
// Fingerprint of the parent's key (4 bytes)
Fingerprint []byte
// Child number (4 bytes)
ChildNumber []byte
// Chain code (32 bytes)
Chaincode []byte
// Public/Private key data (33 bytes)
Key []byte
// Depth (1 byte)
Depth uint16
}
Key defines the components of a hierarchical deterministic wallet master key.
func DeserializeKey ¶
DeserializeKey takes a byte slice and creates a Key.
func NewMasterKey ¶
NewMasterKey returns a new master key given a random seed.
type Wallet ¶
type Wallet struct {
MasterKey *Key
// map[name]Account
Accounts map[string]*Account
NextChildIndex uint32
}
Wallet represents a hierarchical deterministic wallet.
func Load ¶
Load loads the wallet from persistent storage.
Call Save to write the Wallet's changes to persistent storage when done.
func (*Wallet) AccountExists ¶
AccountExists returns whether the account exists or not.
func (*Wallet) AccountNames ¶
AccountNames returns the wallet accounts.
func (*Wallet) NewAccount ¶
NewAccount creates a new account.