Skip to content

Commit

Permalink
dcrjson: Add VerifySeedCmd.
Browse files Browse the repository at this point in the history
  • Loading branch information
githubsands authored and davecgh committed Mar 30, 2018
1 parent 71500c8 commit fd99f57
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 6 deletions.
6 changes: 3 additions & 3 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 20 additions & 1 deletion dcrjson/walletsvrcmds.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2014 The btcsuite developers
// Copyright (c) 2015-2016 The Decred developers
// Copyright (c) 2015-2018 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

Expand Down Expand Up @@ -524,6 +524,24 @@ func NewSignRawTransactionCmd(hexEncodedTx string, inputs *[]RawTxInput, privKey
}
}

// VerifySeedCmd defines the verifyseed JSON-RPC command.
type VerifySeedCmd struct {
Seed string
Account *uint32
}

// NewVerifySeedCmd returns a new instance which can be used to issue a
// walletlock JSON-RPC command.
//
// The parameters which are pointers indicate that they are optional. Passing
// nil for the optional parameters will use the default value.
func NewVerifySeedCmd(seed string, account *uint32) *VerifySeedCmd {
return &VerifySeedCmd{
Seed: seed,
Account: account,
}
}

// WalletLockCmd defines the walletlock JSON-RPC command.
type WalletLockCmd struct{}

Expand Down Expand Up @@ -597,6 +615,7 @@ func init() {
MustRegisterCmd("settxfee", (*SetTxFeeCmd)(nil), flags)
MustRegisterCmd("signmessage", (*SignMessageCmd)(nil), flags)
MustRegisterCmd("signrawtransaction", (*SignRawTransactionCmd)(nil), flags)
MustRegisterCmd("verifyseed", (*VerifySeedCmd)(nil), flags)
MustRegisterCmd("walletlock", (*WalletLockCmd)(nil), flags)
MustRegisterCmd("walletpassphrase", (*WalletPassphraseCmd)(nil), flags)
MustRegisterCmd("walletpassphrasechange", (*WalletPassphraseChangeCmd)(nil), flags)
Expand Down
31 changes: 30 additions & 1 deletion dcrjson/walletsvrcmds_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2014 The btcsuite developers
// Copyright (c) 2015-2016 The Decred developers
// Copyright (c) 2015-2018 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

Expand Down Expand Up @@ -1071,6 +1071,35 @@ func TestWalletSvrCmds(t *testing.T) {
Flags: dcrjson.String("ALL"),
},
},
{
name: "verifyseed",
newCmd: func() (interface{}, error) {
return dcrjson.NewCmd("verifyseed", "abc")
},
staticCmd: func() interface{} {
return dcrjson.NewVerifySeedCmd("abc", nil)
},
marshalled: `{"jsonrpc":"1.0","method":"verifyseed","params":["abc"],"id":1}`,
unmarshalled: &dcrjson.VerifySeedCmd{
Seed: "abc",
Account: nil,
},
},
{
name: "verifyseed optional",
newCmd: func() (interface{}, error) {
return dcrjson.NewCmd("verifyseed", "abc", 5)
},
staticCmd: func() interface{} {
account := dcrjson.Uint32(5)
return dcrjson.NewVerifySeedCmd("abc", account)
},
marshalled: `{"jsonrpc":"1.0","method":"verifyseed","params":["abc",5],"id":1}`,
unmarshalled: &dcrjson.VerifySeedCmd{
Seed: "abc",
Account: dcrjson.Uint32(5),
},
},
{
name: "walletlock",
newCmd: func() (interface{}, error) {
Expand Down
9 changes: 8 additions & 1 deletion dcrjson/walletsvrresults.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2014 The btcsuite developers
// Copyright (c) 2015-2016 The Decred developers
// Copyright (c) 2015-2018 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

Expand Down Expand Up @@ -187,6 +187,13 @@ type SignRawTransactionResult struct {
Errors []SignRawTransactionError `json:"errors,omitempty"`
}

// VerifySeedResult models the data returned by the wallet server verify
// seed command.
type VerifySeedResult struct {
Result bool `json:"keyresult"`
CoinType uint32 `json:"cointype"`
}

// ValidateAddressWalletResult models the data returned by the wallet server
// validateaddress command.
type ValidateAddressWalletResult struct {
Expand Down
1 change: 1 addition & 0 deletions rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ var rpcAskWallet = map[string]struct{}{
"signrawtransaction": {},
"sweepaccount": {},
"stakepooluserinfo": {},
"verifyseed": {},
"walletinfo": {},
"walletlock": {},
"walletpassphrase": {},
Expand Down

0 comments on commit fd99f57

Please sign in to comment.