* git# This is a combination of 18 commits.
fix json name for submit transaction
remove useless code in blockchain/reactor.go (#441)
add interface get-transaction (#439)
* standard transaction reserve utxo filter out contract utxo
* add interface get-transaction
motify response json name
* update dashboard
Block json (#442)
* init version of get-block api
* edit for small details
* fix for golint
init push for add newBlockCh for p2p (#443)
init push for validate-address API (#444)
init push for list address (#445)
fix transaction API response json format and bytomcli API (#446)
* standard transaction reserve utxo filter out contract utxo
* add interface get-transaction
motify response json name
* modify json name for api
* fix transaction API response json format
* bytomcli add get-block
* retired xprv
modify get-block-count API (#447)
* standard transaction reserve utxo filter out contract utxo
* add interface get-transaction
motify response json name
* modify json name for api
* fix transaction API response json format
* bytomcli add get-block
* retired xprv
* modify get-block-count
remove accounts and assets from BlockchainReactor (#448)
* remove accounts field in BlockchainReactor
* remove assets field in BlockchainReactor
put hsm from BlockchainReactor to Wallet (#451)
put token management from BlockchainReactor to Wallet (#452)
init push for submit-tx (#450)
modify get-transaction block_time types (#449)
* standard transaction reserve utxo filter out contract utxo
* add interface get-transaction
motify response json name
* modify json name for api
* fix transaction API response json format
* bytomcli add get-block
* retired xprv
* modify get-block-count
* modify block_time types
fix golint suggest
bytomcli add validate-address and list-addresses
edit the create-address api (#453)
* edit the create-address api
* update dashboard
add GetAccountBalances to wallet (#454)
* add GetAccountBalances to wallet
* fix import order
bytomcli add validate-address and list-addresses (#455)
* fix json name for submit transaction
* bytomcli add validate-address and list-addresses
* add reset-key-password
return bcr.wallet.Hsm.XSign(xpub, path, data[:], password)
}
-func (bcr *BlockchainReactor) pseudohsmResetPassword(ctx context.Context, x struct {
- OldPassword string
- NewPassword string
- XPub chainkd.XPub `json:"xpubs"`
-}) error {
- return bcr.wallet.Hsm.ResetPassword(x.XPub, x.OldPassword, x.NewPassword)
+func (bcr *BlockchainReactor) pseudohsmResetPassword(ctx context.Context, ins struct {
+ XPub chainkd.XPub `json:"xpub"`
+ OldPassword string `json:"old_password"`
+ NewPassword string `json:"new_password"`
+}) Response {
+ if err := bcr.wallet.Hsm.ResetPassword(ins.XPub, ins.OldPassword, ins.NewPassword); err != nil {
+ return NewErrorResponse(err)
+ }
+ return NewSuccessResponse(nil)
}
return xpb, xkey, err
}
-// ResetPassword the passphrase of an existing xpub
-func (h *HSM) ResetPassword(xpub chainkd.XPub, auth, newAuth string) error {
- xpb, xkey, err := h.loadDecryptedKey(xpub, auth)
+// ResetPassword reset passphrase for an existing xpub
+func (h *HSM) ResetPassword(xpub chainkd.XPub, oldAuth, newAuth string) error {
+ xpb, xkey, err := h.loadDecryptedKey(xpub, oldAuth)
if err != nil {
return err
}
return h.keyStore.StoreKey(xpb.File, xkey, newAuth)
}
+// HasAlias check whether the key alias exists
func (h *HSM) HasAlias(alias string) bool {
return h.cache.hasAlias(alias)
}
+// HasKey check whether the private key exists
func (h *HSM) HasKey(xprv chainkd.XPrv) bool {
return h.cache.hasKey(xprv.XPub())
}
m.Handle("/create-key", jsonHandler(bcr.pseudohsmCreateKey))
m.Handle("/list-keys", jsonHandler(bcr.pseudohsmListKeys))
m.Handle("/delete-key", jsonHandler(bcr.pseudohsmDeleteKey))
+ m.Handle("/reset-key-password", jsonHandler(bcr.pseudohsmResetPassword))
m.Handle("/get-transaction", jsonHandler(bcr.getTransaction))
m.Handle("/list-transactions", jsonHandler(bcr.listTransactions))
m.Handle("/list-balances", jsonHandler(bcr.listBalances))
- m.Handle("/reset-password", jsonHandler(bcr.pseudohsmResetPassword))
} else {
log.Warn("Please enable wallet")
}
BytomcliCmd.AddCommand(createKeyCmd)
BytomcliCmd.AddCommand(deleteKeyCmd)
BytomcliCmd.AddCommand(listKeysCmd)
+ BytomcliCmd.AddCommand(resetKeyPwdCmd)
BytomcliCmd.AddCommand(exportPrivateCmd)
BytomcliCmd.AddCommand(importPrivateCmd)
BytomcliCmd.AddCommand(importKeyProgressCmd)
},
}
+var resetKeyPwdCmd = &cobra.Command{
+ Use: "reset-key-password <xpub> <old-password> <new-password>",
+ Short: "Delete a key",
+ Args: cobra.ExactArgs(3),
+ Run: func(cmd *cobra.Command, args []string) {
+ xpub := new(chainkd.XPub)
+ if err := xpub.UnmarshalText([]byte(args[0])); err != nil {
+ jww.ERROR.Println("reset-key-password args not vaild:", err)
+ os.Exit(util.ErrLocalExe)
+ }
+
+ ins := struct {
+ XPub chainkd.XPub `json:"xpub"`
+ OldPassword string `json:"old_password"`
+ NewPassword string `json:"new_password"`
+ }{XPub: *xpub, OldPassword: args[1], NewPassword: args[2]}
+
+ if _, exitCode := util.ClientCall("/reset-key-password", &ins); exitCode != util.Success {
+ os.Exit(exitCode)
+ }
+ jww.FEEDBACK.Println("Successfully reset key password")
+ },
+}
+
var exportPrivateCmd = &cobra.Command{
Use: "export-private-key <xpub> <password>",
Short: "Export the private key",