diff --git a/jsoncmd.go b/jsoncmd.go index 1bb85c45..2119663a 100644 --- a/jsoncmd.go +++ b/jsoncmd.go @@ -3586,7 +3586,7 @@ func (cmd *ImportPrivKeyCmd) UnmarshalJSON(b []byte) error { return err } - if len(r.Params) > 3 { + if len(r.Params) == 0 || len(r.Params) > 3 { return ErrWrongNumberOfParams } diff --git a/jsoncmd_test.go b/jsoncmd_test.go index f5465c33..09656208 100644 --- a/jsoncmd_test.go +++ b/jsoncmd_test.go @@ -674,7 +674,21 @@ var jsoncmdtests = []struct { }, }, { - name: "basic importprivkey + opts", + name: "basic importprivkey + 1 opt", + f: func() (Cmd, error) { + return NewImportPrivKeyCmd(float64(1), + "somereallongprivatekey", + "some text") + }, + result: &ImportPrivKeyCmd{ + id: float64(1), + PrivKey: "somereallongprivatekey", + Label: "some text", + Rescan: true, + }, + }, + { + name: "basic importprivkey + 2 opts", f: func() (Cmd, error) { return NewImportPrivKeyCmd(float64(1), "somereallongprivatekey",