Documentation
¶
Overview ¶
Package key implements key manager and helper functions.
Index ¶
Constants ¶
View Source
const (
EwoqPrivateKey = "PrivateKey-" + rawEwoqPk
)
Variables ¶
View Source
var ( ErrInvalidType = errors.New("invalid type") // ErrInvalidPrivateKey is returned when specified privates are invalid. ErrInvalidPrivateKey = errors.New("invalid private key") ErrInvalidPrivateKeyLen = errors.New("invalid private key length (expect 64 bytes in hex)") ErrInvalidPrivateKeyEnding = errors.New("invalid private key ending") ErrInvalidPrivateKeyEncoding = errors.New("invalid private key encoding") )
Functions ¶
This section is empty.
Types ¶
type Key ¶
type Key interface {
Addresser
Spender
// Returns the name of the key.
Name() string
// Returns the private key.
Key() *crypto.PrivateKeySECP256K1R
// Returns the private key in raw bytes.
Raw() []byte
// Returns the private key encoded in CB58 and "PrivateKey-" prefix.
Encode() string
// Saves the private key to disk with hex encoding.
Save(p string) error
}
Key defines methods for key manager interface.
type OpOption ¶
type OpOption func(*Op)
func WithFeeDeduct ¶
To deduct transfer fee from total spend (output). e.g., "units.MilliAvax" for X/P-Chain transfer.
func WithPrivateKey ¶
func WithPrivateKey(privKey *crypto.PrivateKeySECP256K1R) OpOption
To create a new key manager with a pre-loaded private key.
func WithPrivateKeyEncoded ¶
To create a new key manager with a pre-defined private key.
func WithTargetAmount ¶
type Spender ¶
type Spender interface {
// Spend attempts to spend all specified UTXOs (outputs)
// and returns the new UTXO inputs.
// If target amount is specified, it only uses the
// outputs until the total spending is below the target
// amount.
Spends(outputs []*avax.UTXO, opts ...OpOption) (
totalBalanceToSpend uint64,
inputs []*avax.TransferableInput,
inputSigners [][]*crypto.PrivateKeySECP256K1R,
)
}
Click to show internal directories.
Click to hide internal directories.