github.com/algorand/go-algorand-sdk@v1.24.0/client/kmd/responses.go (about)

     1  package kmd
     2  
     3  import (
     4  	"errors"
     5  
     6  	"golang.org/x/crypto/ed25519"
     7  
     8  	"github.com/algorand/go-algorand-sdk/types"
     9  )
    10  
    11  // APIV1Response is the interface that all API V1 responses must satisfy
    12  type APIV1Response interface {
    13  	GetError() error
    14  }
    15  
    16  // APIV1ResponseEnvelope is a common envelope that all API V1 responses must embed
    17  type APIV1ResponseEnvelope struct {
    18  	_struct struct{} `codec:",omitempty,omitemptyarray"`
    19  	Error   bool     `json:"error"`
    20  	Message string   `json:"message"`
    21  }
    22  
    23  // GetError allows VersionResponse to satisfy the APIV1Response interface, even
    24  // though it can never return an error and is not versioned
    25  func (r VersionsResponse) GetError() error {
    26  	return nil
    27  }
    28  
    29  // GetError allows responses that embed an APIV1ResponseEnvelope to satisfy the
    30  // APIV1Response interface
    31  func (r APIV1ResponseEnvelope) GetError() error {
    32  	if r.Error {
    33  		return errors.New(r.Message)
    34  	}
    35  	return nil
    36  }
    37  
    38  // VersionsResponse is the response to `GET /versions`
    39  type VersionsResponse struct {
    40  	_struct  struct{} `codec:",omitempty,omitemptyarray"`
    41  	Versions []string `json:"versions"`
    42  }
    43  
    44  // ListWalletsResponse is the response to `GET /v1/wallets`
    45  type ListWalletsResponse struct {
    46  	APIV1ResponseEnvelope
    47  	Wallets []APIV1Wallet `json:"wallets"`
    48  }
    49  
    50  // CreateWalletResponse is the response to `POST /v1/wallet`
    51  type CreateWalletResponse struct {
    52  	APIV1ResponseEnvelope
    53  	Wallet APIV1Wallet `json:"wallet"`
    54  }
    55  
    56  // InitWalletHandleResponse is the response to `POST /v1/wallet/init`
    57  type InitWalletHandleResponse struct {
    58  	APIV1ResponseEnvelope
    59  	WalletHandleToken string `json:"wallet_handle_token"`
    60  }
    61  
    62  // ReleaseWalletHandleResponse is the response to `POST /v1/wallet/release`
    63  type ReleaseWalletHandleResponse struct {
    64  	APIV1ResponseEnvelope
    65  }
    66  
    67  // RenewWalletHandleResponse is the response to `POST /v1/wallet/renew`
    68  type RenewWalletHandleResponse struct {
    69  	APIV1ResponseEnvelope
    70  	WalletHandle APIV1WalletHandle `json:"wallet_handle"`
    71  }
    72  
    73  // RenameWalletResponse is the response to `POST /v1/wallet/rename`
    74  type RenameWalletResponse struct {
    75  	APIV1ResponseEnvelope
    76  	Wallet APIV1Wallet `json:"wallet"`
    77  }
    78  
    79  // GetWalletResponse is the response to `POST /v1/wallet/info`
    80  type GetWalletResponse struct {
    81  	APIV1ResponseEnvelope
    82  	WalletHandle APIV1WalletHandle `json:"wallet_handle"`
    83  }
    84  
    85  // ExportMasterDerivationKeyResponse is the response to `POST /v1/master-key/export`
    86  type ExportMasterDerivationKeyResponse struct {
    87  	APIV1ResponseEnvelope
    88  	MasterDerivationKey types.MasterDerivationKey `json:"master_derivation_key"`
    89  }
    90  
    91  // ImportKeyResponse is the response to `POST /v1/key/import`
    92  type ImportKeyResponse struct {
    93  	APIV1ResponseEnvelope
    94  	Address string `json:"address"`
    95  }
    96  
    97  // ExportKeyResponse is the response to `POST /v1/key/export`
    98  type ExportKeyResponse struct {
    99  	APIV1ResponseEnvelope
   100  	PrivateKey ed25519.PrivateKey `json:"private_key"`
   101  }
   102  
   103  // GenerateKeyResponse is the response to `POST /v1/key`
   104  type GenerateKeyResponse struct {
   105  	APIV1ResponseEnvelope
   106  	Address string `json:"address"`
   107  }
   108  
   109  // DeleteKeyResponse is the response to `DELETE /v1/key`
   110  type DeleteKeyResponse struct {
   111  	APIV1ResponseEnvelope
   112  }
   113  
   114  // ListKeysResponse is the response to `POST /v1/key/list`
   115  type ListKeysResponse struct {
   116  	APIV1ResponseEnvelope
   117  	Addresses []string `json:"addresses"`
   118  }
   119  
   120  // SignTransactionResponse is the response to `POST /v1/transaction/sign`
   121  type SignTransactionResponse struct {
   122  	APIV1ResponseEnvelope
   123  	SignedTransaction []byte `json:"signed_transaction"`
   124  }
   125  
   126  // ListMultisigResponse is the response to `POST /v1/multisig/list`
   127  type ListMultisigResponse struct {
   128  	APIV1ResponseEnvelope
   129  	Addresses []string `json:"addresses"`
   130  }
   131  
   132  // ImportMultisigResponse is the response to `POST /v1/multisig/import`
   133  type ImportMultisigResponse struct {
   134  	APIV1ResponseEnvelope
   135  	Address string `json:"address"`
   136  }
   137  
   138  // ExportMultisigResponse is the response to `POST /v1/multisig/export`
   139  type ExportMultisigResponse struct {
   140  	APIV1ResponseEnvelope
   141  	Version   uint8               `json:"multisig_version"`
   142  	Threshold uint8               `json:"threshold"`
   143  	PKs       []ed25519.PublicKey `json:"pks"`
   144  }
   145  
   146  // DeleteMultisigResponse is the response to POST /v1/multisig/delete`
   147  type DeleteMultisigResponse struct {
   148  	APIV1ResponseEnvelope
   149  }
   150  
   151  // SignMultisigTransactionResponse is the response to `POST /v1/multisig/sign`
   152  type SignMultisigTransactionResponse struct {
   153  	APIV1ResponseEnvelope
   154  	Multisig []byte `json:"multisig"`
   155  }