Documentation ¶
Overview ¶
Package key implements key manager and helper functions.
Index ¶
- Constants
- Variables
- type HardKey
- type Key
- type Op
- type OpOption
- type SOp
- type SOpOption
- type SoftKey
- func (m *SoftKey) Address() ids.ShortID
- func (m *SoftKey) Encode() string
- func (m *SoftKey) Key() *crypto.PrivateKeySECP256K1R
- func (m *SoftKey) P() string
- func (m *SoftKey) Raw() []byte
- func (m *SoftKey) Save(p string) error
- func (m *SoftKey) Sign(pTx *platformvm.Tx, sigs int) error
- func (m *SoftKey) Spends(outputs []*djtx.UTXO, opts ...OpOption) (totalBalanceToSpend uint64, inputs []*djtx.TransferableInput)
Constants ¶
View Source
const (
EwoqPrivateKey = "PrivateKey-" + 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 ¶
This section is empty.
Types ¶
type HardKey ¶
type HardKey struct {
// contains filtered or unexported fields
}
func (*HardKey) Disconnect ¶
type Key ¶
type Key interface { // P returns the formatted P-Chain address. P() string // Address returns the raw ids.ShortID address. Address() ids.ShortID // 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 []*djtx.UTXO, opts ...OpOption) ( totalBalanceToSpend uint64, inputs []*djtx.TransferableInput, ) // Sign generates [numSigs] signatures and attaches them to [pTx]. Sign(pTx *platformvm.Tx, numSigs int) 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.MilliDjtx" for X/P-Chain transfer.
func WithTargetAmount ¶
type SOpOption ¶
type SOpOption func(*SOp)
func WithPrivateKey ¶
func WithPrivateKey(privKey *crypto.PrivateKeySECP256K1R) 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
}
Click to show internal directories.
Click to hide internal directories.