Documentation
¶
Overview ¶
Package key implements key manager and helper functions.
Index ¶
- Constants
- Variables
- func GetHRP(networkID uint32) string
- func SortTransferableInputsWithSigners(ins []*dione.TransferableInput, signers [][]ids.ShortID)
- type Key
- type Op
- type OpOption
- type SOp
- type SOpOption
- type SoftKey
- func (m *SoftKey) A() []string
- func (m *SoftKey) Addresses() []ids.ShortID
- func (m *SoftKey) D() string
- func (m *SoftKey) Encode() string
- func (m *SoftKey) Key() *secp256k1.PrivateKey
- func (m *SoftKey) KeyChain() *secp256k1fx.Keychain
- func (m *SoftKey) Match(owners *secp256k1fx.OutputOwners, time uint64) ([]uint32, []ids.ShortID, bool)
- func (m *SoftKey) O() []string
- func (m *SoftKey) Raw() []byte
- func (m *SoftKey) Save(p string) error
- func (m *SoftKey) Sign(oTx *txs.Tx, signers [][]ids.ShortID) error
- func (m *SoftKey) Spends(outputs []*dione.UTXO, opts ...OpOption) (totalBalanceToSpend uint64, inputs []*dione.TransferableInput, ...)
Constants ¶
View Source
const (
EwoqPrivateKey = privKeyEncPfx + rawEwoqPk
)
Variables ¶
View Source
var ( ErrInvalidType = errors.New("invalid type") ErrCantSpend = errors.New("can't spend") )
View Source
var ( 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 ¶
func SortTransferableInputsWithSigners ¶
func SortTransferableInputsWithSigners(ins []*dione.TransferableInput, signers [][]ids.ShortID)
SortTransferableInputsWithSigners sorts the inputs and signers based on the input's utxo ID.
Types ¶
type Key ¶
type Key interface {
// O returns all formatted O-Chain addresses.
O() []string
// D returns the D-Chain address in Ethereum format
D() string
// Addresses returns the all raw ids.ShortID address.
Addresses() []ids.ShortID
// Match attempts to match a list of addresses up to the provided threshold.
Match(owners *secp256k1fx.OutputOwners, time uint64) ([]uint32, []ids.ShortID, bool)
// 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 []*dione.UTXO, opts ...OpOption) (
totalBalanceToSpend uint64,
inputs []*dione.TransferableInput,
signers [][]ids.ShortID,
)
// Sign generates [numSigs] signatures and attaches them to [oTx].
Sign(oTx *txs.Tx, signers [][]ids.ShortID) 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.MilliDione" for A/O-Chain transfer.
func WithTargetAmount ¶
type SOpOption ¶
type SOpOption func(*SOp)
func WithPrivateKey ¶
func WithPrivateKey(privKey *secp256k1.PrivateKey) SOpOption
To create a new key SoftKey with a pre-loaded private key.
func WithPrivateKeyEncoded ¶
To create a new key SoftKey with a pre-defined private key.
type SoftKey ¶
type SoftKey struct {
// contains filtered or unexported fields
}
func LoadSoftFromBytes ¶
LoadSoftFromBytes loads the private key from bytes and creates the corresponding SoftKey.
func (*SoftKey) Match ¶
func (m *SoftKey) Match(owners *secp256k1fx.OutputOwners, time uint64) ([]uint32, []ids.ShortID, bool)
Click to show internal directories.
Click to hide internal directories.