github.com/Finschia/finschia-sdk@v0.48.1/client/keys/types.go (about)

     1  package keys
     2  
     3  // used for outputting keyring.Info over REST
     4  
     5  // AddNewKey request a new key
     6  type AddNewKey struct {
     7  	Name     string `json:"name"`
     8  	Password string `json:"password"`
     9  	Mnemonic string `json:"mnemonic"`
    10  	Account  int    `json:"account,string,omitempty"`
    11  	Index    int    `json:"index,string,omitempty"`
    12  }
    13  
    14  // NewAddNewKey constructs a new AddNewKey request structure.
    15  func NewAddNewKey(name, password, mnemonic string, account, index int) AddNewKey {
    16  	return AddNewKey{
    17  		Name:     name,
    18  		Password: password,
    19  		Mnemonic: mnemonic,
    20  		Account:  account,
    21  		Index:    index,
    22  	}
    23  }
    24  
    25  // RecoverKeyBody recovers a key
    26  type RecoverKey struct {
    27  	Password string `json:"password"`
    28  	Mnemonic string `json:"mnemonic"`
    29  	Account  int    `json:"account,string,omitempty"`
    30  	Index    int    `json:"index,string,omitempty"`
    31  }
    32  
    33  // NewRecoverKey constructs a new RecoverKey request structure.
    34  func NewRecoverKey(password, mnemonic string, account, index int) RecoverKey {
    35  	return RecoverKey{Password: password, Mnemonic: mnemonic, Account: account, Index: index}
    36  }
    37  
    38  // UpdateKeyReq requests updating a key
    39  type UpdateKeyReq struct {
    40  	OldPassword string `json:"old_password"`
    41  	NewPassword string `json:"new_password"`
    42  }
    43  
    44  // NewUpdateKeyReq constructs a new UpdateKeyReq structure.
    45  func NewUpdateKeyReq(old, new string) UpdateKeyReq {
    46  	return UpdateKeyReq{OldPassword: old, NewPassword: new}
    47  }
    48  
    49  // DeleteKeyReq requests deleting a key
    50  type DeleteKeyReq struct {
    51  	Password string `json:"password"`
    52  }
    53  
    54  // NewDeleteKeyReq constructs a new DeleteKeyReq structure.
    55  func NewDeleteKeyReq(password string) DeleteKeyReq { return DeleteKeyReq{Password: password} }