parent
9ddb768c47
commit
cbd3d730a9
2 changed files with 24 additions and 0 deletions
19
jsonapi.go
19
jsonapi.go
|
@ -388,6 +388,25 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
|
||||||
return finalMessage, err
|
return finalMessage, err
|
||||||
}
|
}
|
||||||
finalMessage, err = jsonWithArgs(message, id, args)
|
finalMessage, err = jsonWithArgs(message, id, args)
|
||||||
|
// One required string, one optional string
|
||||||
|
// Strictly, the optional arg for submit block is an object, but
|
||||||
|
// bitcoind ignores it for now, so best to just allow string until
|
||||||
|
// support for it is complete.
|
||||||
|
case "submitblock":
|
||||||
|
if len(args) > 2 || len(args) == 0 {
|
||||||
|
err = fmt.Errorf("Wrong number of argument for %s", message)
|
||||||
|
return finalMessage, err
|
||||||
|
}
|
||||||
|
_, ok1 := args[0].(string)
|
||||||
|
ok2 := true
|
||||||
|
if len(args) == 2 {
|
||||||
|
_, ok2 = args[1].(string)
|
||||||
|
}
|
||||||
|
if !ok1 || !ok2 {
|
||||||
|
err = fmt.Errorf("Arguments must be string and optionally string for %s", message)
|
||||||
|
return finalMessage, err
|
||||||
|
}
|
||||||
|
finalMessage, err = jsonWithArgs(message, id, args)
|
||||||
// One optional int, one optional bool
|
// One optional int, one optional bool
|
||||||
case "listreceivedbyaccount", "listreceivedbyaddress":
|
case "listreceivedbyaccount", "listreceivedbyaddress":
|
||||||
if len(args) > 2 {
|
if len(args) > 2 {
|
||||||
|
|
|
@ -176,6 +176,11 @@ var cmdtests = []struct {
|
||||||
{"getrawchangeaddress", []interface{}{"something", "test"}, false},
|
{"getrawchangeaddress", []interface{}{"something", "test"}, false},
|
||||||
{"getbestblockhash", []interface{}{}, true},
|
{"getbestblockhash", []interface{}{}, true},
|
||||||
{"getbestblockhash", []interface{}{"something"}, false},
|
{"getbestblockhash", []interface{}{"something"}, false},
|
||||||
|
{"submitblock", []interface{}{}, false},
|
||||||
|
{"submitblock", []interface{}{"something"}, true},
|
||||||
|
{"submitblock", []interface{}{"something", "something else"}, true},
|
||||||
|
{"submitblock", []interface{}{"something", "something else", "more"}, false},
|
||||||
|
{"submitblock", []interface{}{"something", 1}, false},
|
||||||
{"fakecommand", nil, false},
|
{"fakecommand", nil, false},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue