kmd

package
v2.0.0-...-1c2efa0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultWalletDriver = "sqlite"

DefaultWalletDriver is the wallet backend that kmd will use by default

Variables

This section is empty.

Functions

This section is empty.

Types

type APIV1Request

type APIV1Request interface{}

APIV1Request is the interface that all API V1 requests must satisfy

type APIV1RequestEnvelope

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

APIV1RequestEnvelope is a common envelope that all API V1 requests must embed

type APIV1Response

type APIV1Response interface {
	GetError() error
}

APIV1Response is the interface that all API V1 responses must satisfy

type APIV1ResponseEnvelope

type APIV1ResponseEnvelope struct {
	Error   bool   `json:"error"`
	Message string `json:"message"`
	// contains filtered or unexported fields
}

APIV1ResponseEnvelope is a common envelope that all API V1 responses must embed

func (APIV1ResponseEnvelope) GetError

func (r APIV1ResponseEnvelope) GetError() error

GetError allows responses that embed an APIV1ResponseEnvelope to satisfy the APIV1Response interface

type APIV1Wallet

type APIV1Wallet struct {
	ID                    string         `json:"id"`
	Name                  string         `json:"name"`
	DriverName            string         `json:"driver_name"`
	DriverVersion         uint32         `json:"driver_version"`
	SupportsMnemonicUX    bool           `json:"mnemonic_ux"`
	SupportedTransactions []types.TxType `json:"supported_txs"`
}

APIV1Wallet is the API's representation of a wallet

type APIV1WalletHandle

type APIV1WalletHandle struct {
	Wallet         APIV1Wallet `json:"wallet"`
	ExpiresSeconds int64       `json:"expires_seconds"`
}

APIV1WalletHandle includes the wallet the handle corresponds to and the number of number of seconds to expiration

type Client

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

Client is the client used to interact with the kmd API

func MakeClient

func MakeClient(address string, apiToken string) (Client, error)

MakeClient instantiates a Client for the given address and apiToken

func (Client) CreateWallet

func (kcl Client) CreateWallet(walletName, walletPassword, walletDriverName string, walletMDK types.MasterDerivationKey) (resp CreateWalletResponse, err error)

CreateWallet creates a wallet with the specified name, password, driver, and master derivation key. If the master derivation key is blank, one is generated internally to kmd. CreateWallet returns a CreateWalletResponse containing information about the new wallet.

func (Client) DeleteKey

func (kcl Client) DeleteKey(walletHandle, walletPassword, addr string) (resp DeleteKeyResponse, err error)

DeleteKey accepts a wallet handle, wallet password, and address, and deletes the information about this address from the wallet (including address and secret key). If DeleteKey is called on a key generated using GenerateKey, the same key will not be generated again. However, if a wallet is recovered using the master derivation key, a key generated in this way can be recovered.

func (Client) DeleteMultisig

func (kcl Client) DeleteMultisig(walletHandle, walletPassword, addr string) (resp DeleteMultisigResponse, err error)

DeleteMultisig accepts a wallet handle, wallet password, and address, and deletes the information about this multisig address from the wallet.

func (Client) DoV1Request

func (kcl Client) DoV1Request(req APIV1Request, resp APIV1Response) error

DoV1Request accepts a request from kmdapi/requests and

func (Client) ExportKey

func (kcl Client) ExportKey(walletHandle, walletPassword, addr string) (resp ExportKeyResponse, err error)

ExportKey accepts a wallet handle, wallet password, and address, and returns an ExportKeyResponse containing the ed25519 private key corresponding to the address stored in the wallet.

func (Client) ExportMasterDerivationKey

func (kcl Client) ExportMasterDerivationKey(walletHandle, walletPassword string) (resp ExportMasterDerivationKeyResponse, err error)

ExportMasterDerivationKey accepts a wallet handle and a wallet password, and returns an ExportMasterDerivationKeyResponse containing the master derivation key. This key can be used as an argument to CreateWallet in order to recover the keys generated by this wallet. The master derivation key can be encoded as a sequence of words using the mnemonic library, and displayed to the user as a backup phrase.

func (Client) ExportMultisig

func (kcl Client) ExportMultisig(walletHandle, walletPassword, addr string) (resp ExportMultisigResponse, err error)

ExportMultisig accepts a wallet handle, wallet password, and multisig address, and returns an ExportMultisigResponse containing the stored multisig preimage. The preimage contains all of the information necessary to derive the multisig address, including version, threshold, and a list of public keys.

func (Client) GenerateKey

func (kcl Client) GenerateKey(walletHandle string) (resp GenerateKeyResponse, err error)

GenerateKey accepts a wallet handle, and then generates the next key in the wallet using its internal master derivation key. Two wallets with the same master derivation key will generate the same sequence of keys.

func (Client) GetWallet

func (kcl Client) GetWallet(walletHandle string) (resp GetWalletResponse, err error)

GetWallet accepts a wallet handle and returns high level information about this wallet in a GetWalletResponse.

func (Client) ImportKey

func (kcl Client) ImportKey(walletHandle string, secretKey ed25519.PrivateKey) (resp ImportKeyResponse, err error)

ImportKey accepts a wallet handle and an ed25519 private key, and imports the key into the wallet. It returns an ImportKeyResponse containing the address corresponding to this private key.

func (Client) ImportMultisig

func (kcl Client) ImportMultisig(walletHandle string, version, threshold uint8, pks []ed25519.PublicKey) (resp ImportMultisigResponse, err error)

ImportMultisig accepts a wallet handle and the information required to generate a multisig address. It derives this address, and stores all of the information within the wallet. It returns a ImportMultisigResponse with the derived address.

func (Client) InitWalletHandle

func (kcl Client) InitWalletHandle(walletID, walletPassword string) (resp InitWalletHandleResponse, err error)

InitWalletHandle accepts a wallet ID and a wallet password, and returns an InitWalletHandleResponse containing a wallet handle token. This wallet handle token can be used for subsequent operations on this wallet, like key generation, transaction signing, etc.. WalletHandleTokens expire after a configurable number of seconds, and must be renewed periodically with RenewWalletHandle. It is good practice to call ReleaseWalletHandle when you're done interacting with this wallet.

func (Client) ListKeys

func (kcl Client) ListKeys(walletHandle string) (resp ListKeysResponse, err error)

ListKeys accepts a wallet handle and returns a ListKeysResponse containing all of the addresses for which this wallet contains secret keys.

func (Client) ListMultisig

func (kcl Client) ListMultisig(walletHandle string) (resp ListMultisigResponse, err error)

ListMultisig accepts a wallet handle and returns a ListMultisigResponse containing the multisig addresses whose preimages are stored in this wallet. A preimage is the information needed to reconstruct this multisig address, including multisig version information, threshold information, and a list of public keys.

func (Client) ListWallets

func (kcl Client) ListWallets() (resp ListWalletsResponse, err error)

ListWallets returns a ListWalletsResponse containing the list of wallets known to kmd. Using a wallet ID returned from this endpoint, you can initialize a wallet handle with client.InitWalletHandle

func (Client) MultisigSignTransaction

func (kcl Client) MultisigSignTransaction(walletHandle, walletPassword string, tx types.Transaction, pk ed25519.PublicKey, partial types.MultisigSig) (resp SignMultisigTransactionResponse, err error)

MultisigSignTransaction accepts a wallet handle, wallet password, transaction, public key (*not* an address), and an optional partial MultisigSig. It looks up the secret key corresponding to the public key, and returns a SignMultisigTransactionResponse containing a MultisigSig with a signature by the secret key included.

func (Client) ReleaseWalletHandle

func (kcl Client) ReleaseWalletHandle(walletHandle string) (resp ReleaseWalletHandleResponse, err error)

ReleaseWalletHandle invalidates the passed wallet handle token, making it unusable for subsequent wallet operations.

func (Client) RenameWallet

func (kcl Client) RenameWallet(walletID, walletPassword, newWalletName string) (resp RenameWalletResponse, err error)

RenameWallet accepts a wallet ID, wallet password, and a new wallet name, and renames the underlying wallet.

func (Client) RenewWalletHandle

func (kcl Client) RenewWalletHandle(walletHandle string) (resp RenewWalletHandleResponse, err error)

RenewWalletHandle accepts a wallet handle and attempts to renew it, moving the expiration time to some number of seconds in the future. It returns a RenewWalletHandleResponse containing the walletHandle and the number of seconds until expiration

func (Client) SignTransaction

func (kcl Client) SignTransaction(walletHandle, walletPassword string, tx types.Transaction) (resp SignTransactionResponse, err error)

SignTransaction accepts a wallet handle, a wallet password, a transaction, and returns SignTransactionResponse containing an encoded, signed transaction. The transaction is signed using the key corresponding to the Sender field.

func (Client) SignTransactionWithSpecificPublicKey

func (kcl Client) SignTransactionWithSpecificPublicKey(walletHandle, walletPassword string, tx types.Transaction, pk ed25519.PublicKey) (resp SignTransactionResponse, err error)

SignTransactionWithSpecificPublicKey accepts a wallet handle, a wallet password, a transaction, and a public key to sign with its corresponding sk, and returns and SignTransactionResponse containing an encoded, signed transaction. The transaction is signed using the key corresponding to the Sender field.

func (Client) Version

func (kcl Client) Version() (resp VersionsResponse, err error)

Version returns a VersionResponse containing a list of kmd API versions supported by this running kmd instance.

type CreateWalletRequest

type CreateWalletRequest struct {
	APIV1RequestEnvelope
	WalletName          string                    `json:"wallet_name"`
	WalletDriverName    string                    `json:"wallet_driver_name"`
	WalletPassword      string                    `json:"wallet_password"`
	MasterDerivationKey types.MasterDerivationKey `json:"master_derivation_key"`
}

CreateWalletRequest is the request for `POST /v1/wallet`

type CreateWalletResponse

type CreateWalletResponse struct {
	APIV1ResponseEnvelope
	Wallet APIV1Wallet `json:"wallet"`
}

CreateWalletResponse is the response to `POST /v1/wallet`

type DeleteKeyRequest

type DeleteKeyRequest struct {
	APIV1RequestEnvelope
	WalletHandleToken string `json:"wallet_handle_token"`
	Address           string `json:"address"`
	WalletPassword    string `json:"wallet_password"`
}

DeleteKeyRequest is the request for `DELETE /v1/key`

type DeleteKeyResponse

type DeleteKeyResponse struct {
	APIV1ResponseEnvelope
}

DeleteKeyResponse is the response to `DELETE /v1/key`

type DeleteMultisigRequest

type DeleteMultisigRequest struct {
	APIV1RequestEnvelope
	WalletHandleToken string `json:"wallet_handle_token"`
	Address           string `json:"address"`
	WalletPassword    string `json:"wallet_password"`
}

DeleteMultisigRequest is the request for `POST /v1/multisig/delete`

type DeleteMultisigResponse

type DeleteMultisigResponse struct {
	APIV1ResponseEnvelope
}

DeleteMultisigResponse is the response to POST /v1/multisig/delete`

type ExportKeyRequest

type ExportKeyRequest struct {
	APIV1RequestEnvelope
	WalletHandleToken string `json:"wallet_handle_token"`
	Address           string `json:"address"`
	WalletPassword    string `json:"wallet_password"`
}

ExportKeyRequest is the request for `POST /v1/key/export`

type ExportKeyResponse

type ExportKeyResponse struct {
	APIV1ResponseEnvelope
	PrivateKey ed25519.PrivateKey `json:"private_key"`
}

ExportKeyResponse is the response to `POST /v1/key/export`

type ExportMasterDerivationKeyRequest

type ExportMasterDerivationKeyRequest struct {
	APIV1RequestEnvelope
	WalletHandleToken string `json:"wallet_handle_token"`
	WalletPassword    string `json:"wallet_password"`
}

ExportMasterDerivationKeyRequest is the request for `POST /v1/master_key/export`

type ExportMasterDerivationKeyResponse

type ExportMasterDerivationKeyResponse struct {
	APIV1ResponseEnvelope
	MasterDerivationKey types.MasterDerivationKey `json:"master_derivation_key"`
}

ExportMasterDerivationKeyResponse is the response to `POST /v1/master-key/export`

type ExportMultisigRequest

type ExportMultisigRequest struct {
	APIV1RequestEnvelope
	WalletHandleToken string `json:"wallet_handle_token"`
	Address           string `json:"address"`
	WalletPassword    string `json:"wallet_password"`
}

ExportMultisigRequest is the request for `POST /v1/multisig/export`

type ExportMultisigResponse

type ExportMultisigResponse struct {
	APIV1ResponseEnvelope
	Version   uint8               `json:"multisig_version"`
	Threshold uint8               `json:"threshold"`
	PKs       []ed25519.PublicKey `json:"pks"`
}

ExportMultisigResponse is the response to `POST /v1/multisig/export`

type GenerateKeyRequest

type GenerateKeyRequest struct {
	APIV1RequestEnvelope
	WalletHandleToken string `json:"wallet_handle_token"`
	DisplayMnemonic   bool   `json:"display_mnemonic"`
}

GenerateKeyRequest is the request for `POST /v1/key`

type GenerateKeyResponse

type GenerateKeyResponse struct {
	APIV1ResponseEnvelope
	Address string `json:"address"`
}

GenerateKeyResponse is the response to `POST /v1/key`

type GetWalletRequest

type GetWalletRequest struct {
	APIV1RequestEnvelope
	WalletHandleToken string `json:"wallet_handle_token"`
}

GetWalletRequest is the request for `POST /v1/wallet/info`

type GetWalletResponse

type GetWalletResponse struct {
	APIV1ResponseEnvelope
	WalletHandle APIV1WalletHandle `json:"wallet_handle"`
}

GetWalletResponse is the response to `POST /v1/wallet/info`

type ImportKeyRequest

type ImportKeyRequest struct {
	APIV1RequestEnvelope
	WalletHandleToken string             `json:"wallet_handle_token"`
	PrivateKey        ed25519.PrivateKey `json:"private_key"`
}

ImportKeyRequest is the request for `POST /v1/key/import`

type ImportKeyResponse

type ImportKeyResponse struct {
	APIV1ResponseEnvelope
	Address string `json:"address"`
}

ImportKeyResponse is the response to `POST /v1/key/import`

type ImportMultisigRequest

type ImportMultisigRequest struct {
	APIV1RequestEnvelope
	WalletHandleToken string              `json:"wallet_handle_token"`
	Version           uint8               `json:"multisig_version"`
	Threshold         uint8               `json:"threshold"`
	PKs               []ed25519.PublicKey `json:"pks"`
}

ImportMultisigRequest is the request for `POST /v1/multisig/import`

type ImportMultisigResponse

type ImportMultisigResponse struct {
	APIV1ResponseEnvelope
	Address string `json:"address"`
}

ImportMultisigResponse is the response to `POST /v1/multisig/import`

type InitWalletHandleRequest

type InitWalletHandleRequest struct {
	APIV1RequestEnvelope
	WalletID       string `json:"wallet_id"`
	WalletPassword string `json:"wallet_password"`
}

InitWalletHandleRequest is the request for `POST /v1/wallet/init`

type InitWalletHandleResponse

type InitWalletHandleResponse struct {
	APIV1ResponseEnvelope
	WalletHandleToken string `json:"wallet_handle_token"`
}

InitWalletHandleResponse is the response to `POST /v1/wallet/init`

type ListKeysRequest

type ListKeysRequest struct {
	APIV1RequestEnvelope
	WalletHandleToken string `json:"wallet_handle_token"`
}

ListKeysRequest is the request for `POST /v1/keys/list`

type ListKeysResponse

type ListKeysResponse struct {
	APIV1ResponseEnvelope
	Addresses []string `json:"addresses"`
}

ListKeysResponse is the response to `POST /v1/key/list`

type ListMultisigRequest

type ListMultisigRequest struct {
	APIV1RequestEnvelope
	WalletHandleToken string `json:"wallet_handle_token"`
}

ListMultisigRequest is the request for `POST /v1/multisig/list`

type ListMultisigResponse

type ListMultisigResponse struct {
	APIV1ResponseEnvelope
	Addresses []string `json:"addresses"`
}

ListMultisigResponse is the response to `POST /v1/multisig/list`

type ListWalletsRequest

type ListWalletsRequest struct {
	APIV1RequestEnvelope
}

ListWalletsRequest is the request for `GET /v1/wallets`

type ListWalletsResponse

type ListWalletsResponse struct {
	APIV1ResponseEnvelope
	Wallets []APIV1Wallet `json:"wallets"`
}

ListWalletsResponse is the response to `GET /v1/wallets`

type ReleaseWalletHandleRequest

type ReleaseWalletHandleRequest struct {
	APIV1RequestEnvelope
	WalletHandleToken string `json:"wallet_handle_token"`
}

ReleaseWalletHandleRequest is the request for `POST /v1/wallet/release`

type ReleaseWalletHandleResponse

type ReleaseWalletHandleResponse struct {
	APIV1ResponseEnvelope
}

ReleaseWalletHandleResponse is the response to `POST /v1/wallet/release`

type RenameWalletRequest

type RenameWalletRequest struct {
	APIV1RequestEnvelope
	WalletID       string `json:"wallet_id"`
	WalletPassword string `json:"wallet_password"`
	NewWalletName  string `json:"wallet_name"`
}

RenameWalletRequest is the request for `POST /v1/wallet/rename`

type RenameWalletResponse

type RenameWalletResponse struct {
	APIV1ResponseEnvelope
	Wallet APIV1Wallet `json:"wallet"`
}

RenameWalletResponse is the response to `POST /v1/wallet/rename`

type RenewWalletHandleRequest

type RenewWalletHandleRequest struct {
	APIV1RequestEnvelope
	WalletHandleToken string `json:"wallet_handle_token"`
}

RenewWalletHandleRequest is the request for `POST /v1/wallet/renew`

type RenewWalletHandleResponse

type RenewWalletHandleResponse struct {
	APIV1ResponseEnvelope
	WalletHandle APIV1WalletHandle `json:"wallet_handle"`
}

RenewWalletHandleResponse is the response to `POST /v1/wallet/renew`

type SignMultisigTransactionRequest

type SignMultisigTransactionRequest struct {
	APIV1RequestEnvelope
	WalletHandleToken string            `json:"wallet_handle_token"`
	Transaction       []byte            `json:"transaction"`
	PublicKey         ed25519.PublicKey `json:"public_key"`
	PartialMsig       types.MultisigSig `json:"partial_multisig"`
	WalletPassword    string            `json:"wallet_password"`
}

SignMultisigTransactionRequest is the request for `POST /v1/multisig/sign`

type SignMultisigTransactionResponse

type SignMultisigTransactionResponse struct {
	APIV1ResponseEnvelope
	Multisig []byte `json:"multisig"`
}

SignMultisigTransactionResponse is the response to `POST /v1/multisig/sign`

type SignTransactionRequest

type SignTransactionRequest struct {
	APIV1RequestEnvelope
	WalletHandleToken string            `json:"wallet_handle_token"`
	Transaction       []byte            `json:"transaction"`
	WalletPassword    string            `json:"wallet_password"`
	PublicKey         ed25519.PublicKey `json:"public_key"`
}

SignTransactionRequest is the request for `POST /v1/transaction/sign`

type SignTransactionResponse

type SignTransactionResponse struct {
	APIV1ResponseEnvelope
	SignedTransaction []byte `json:"signed_transaction"`
}

SignTransactionResponse is the response to `POST /v1/transaction/sign`

type VersionsRequest

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

VersionsRequest is the request for `GET /versions`

type VersionsResponse

type VersionsResponse struct {
	Versions []string `json:"versions"`
	// contains filtered or unexported fields
}

VersionsResponse is the response to `GET /versions`

func (VersionsResponse) GetError

func (r VersionsResponse) GetError() error

GetError allows VersionResponse to satisfy the APIV1Response interface, even though it can never return an error and is not versioned

Jump to

Keyboard shortcuts

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