Fix for signrawtransaction.
Add sendrawtransaction to list of commands we know the return type for.
This commit is contained in:
parent
dc9618c9ab
commit
5444d262b8
3 changed files with 38 additions and 21 deletions
38
jsonapi.go
38
jsonapi.go
|
@ -649,9 +649,10 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
|
|||
return finalMessage, err
|
||||
}
|
||||
finalMessage, err = jsonWithArgs(message, id, args)
|
||||
// one required string (hex) and sets of 4 optional strings.
|
||||
// one required string (hex) and optional sets of one string, one int,
|
||||
// and one string along with another optional string.
|
||||
case "signrawtransaction":
|
||||
if len(args) < 1 || (len(args)-1)%4 != 0 {
|
||||
if len(args) < 1 {
|
||||
err = fmt.Errorf("Wrong number of arguments for %s", message)
|
||||
return finalMessage, err
|
||||
}
|
||||
|
@ -662,16 +663,31 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
|
|||
}
|
||||
type txlist struct {
|
||||
Txid string `json:"txid"`
|
||||
Vout string `json:"vout"`
|
||||
Vout int `json:"vout"`
|
||||
ScriptPubKey string `json:"scriptPubKey"`
|
||||
}
|
||||
txList := make([]txlist, (len(args)-1)/4)
|
||||
txList := make([]txlist, 1)
|
||||
|
||||
if len(args) > 1 {
|
||||
txid, ok2 := args[1].(string)
|
||||
vout, ok3 := args[2].(int)
|
||||
spkey, ok4 := args[3].(string)
|
||||
if !ok1 || !ok2 || !ok3 || !ok4 {
|
||||
err = fmt.Errorf("Incorrect arguement types.")
|
||||
return finalMessage, err
|
||||
}
|
||||
txList[0].Txid = txid
|
||||
txList[0].Vout = vout
|
||||
txList[0].ScriptPubKey = spkey
|
||||
}
|
||||
/*
|
||||
pkeyList := make([]string, (len(args)-1)/4)
|
||||
for i := 0; i < len(args)/4; i += 1 {
|
||||
txid, ok1 := args[(i*4)+0].(string)
|
||||
vout, ok2 := args[(i*4)+1].(string)
|
||||
spkey, ok3 := args[(i*4)+2].(string)
|
||||
pkey, ok4 := args[(i*4)+3].(string)
|
||||
fmt.Println(args[(i*4)+4])
|
||||
txid, ok1 := args[(i*4)+1].(string)
|
||||
vout, ok2 := args[(i*4)+2].(int)
|
||||
spkey, ok3 := args[(i*4)+3].(string)
|
||||
pkey, ok4 := args[(i*4)+4].(string)
|
||||
if !ok1 || !ok2 || !ok3 || !ok4 {
|
||||
err = fmt.Errorf("Incorrect arguement types.")
|
||||
return finalMessage, err
|
||||
|
@ -681,7 +697,8 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
|
|||
txList[i].ScriptPubKey = spkey
|
||||
pkeyList[i] = pkey
|
||||
}
|
||||
finalMessage, err = jsonWithArgs(message, id, []interface{}{args[0].(string), txList, pkeyList})
|
||||
*/
|
||||
finalMessage, err = jsonWithArgs(message, id, []interface{}{args[0].(string), txList})
|
||||
// Any other message
|
||||
default:
|
||||
err = fmt.Errorf("Not a valid command: %s", message)
|
||||
|
@ -780,7 +797,8 @@ func ReadResultCmd(cmd string, message []byte) (Reply, error) {
|
|||
case "getblockcount", "getbalance", "getblocknumber", "getgenerate",
|
||||
"getconnetioncount", "getdifficulty", "gethashespersec",
|
||||
"setgenerate", "stop", "settxfee", "getaccount",
|
||||
"getnewaddress", "sendtoaddress", "createrawtransaction":
|
||||
"getnewaddress", "sendtoaddress", "createrawtransaction",
|
||||
"sendrawtransaction":
|
||||
err = json.Unmarshal(message, &result)
|
||||
// For anything else put it in an interface. All the data is still
|
||||
// there, just a little less convenient to deal with.
|
||||
|
|
|
@ -156,12 +156,11 @@ var cmdtests = []struct {
|
|||
{"lockunspent", []interface{}{true, "something"}, true},
|
||||
{"lockunspent", []interface{}{true}, false},
|
||||
{"lockunspent", []interface{}{1.0, "something"}, false},
|
||||
{"signrawtransaction", []interface{}{"hexstring"}, true},
|
||||
{"signrawtransaction", []interface{}{"hexstring", "test", "test2", "test3", "test4"}, true},
|
||||
{"signrawtransaction", []interface{}{"hexstring", "test", 1, "test"}, true},
|
||||
{"signrawtransaction", []interface{}{"hexstring", "test", "test2", "test3", "test4"}, false},
|
||||
{"signrawtransaction", []interface{}{"hexstring", "test", "test2", "test3"}, false},
|
||||
{"signrawtransaction", []interface{}{1.2, "test", "test2", "test3", "test4"}, false},
|
||||
{"signrawtransaction", []interface{}{"hexstring", 1, "test2", "test3", "test4"}, false},
|
||||
{"signrawtransaction", []interface{}{"hexstring", "test", 2, "test3", "test4"}, false},
|
||||
{"signrawtransaction", []interface{}{"hexstring", "test", "test2", 3, "test4"}, false},
|
||||
{"listsinceblock", []interface{}{"test", "test"}, true},
|
||||
{"listsinceblock", []interface{}{"test", "test", "test"}, false},
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
github.com/conformal/btcjson/jsonapi.go CreateMessageWithId 100.00% (332/332)
|
||||
github.com/conformal/btcjson/jsonapi.go ReadResultCmd 100.00% (64/64)
|
||||
github.com/conformal/btcjson/jsonapi.go JSONToAmount 100.00% (15/15)
|
||||
github.com/conformal/btcjson/jsonapi.go JSONGetMethod 100.00% (14/14)
|
||||
|
@ -9,7 +8,8 @@ github.com/conformal/btcjson/jsonfxns.go GetRaw 100.00% (6/6)
|
|||
github.com/conformal/btcjson/jsonapi.go jsonWithArgs 100.00% (5/5)
|
||||
github.com/conformal/btcjson/jsonapi.go IsValidIdType 100.00% (3/3)
|
||||
github.com/conformal/btcjson/jsonapi.go CreateMessage 100.00% (2/2)
|
||||
github.com/conformal/btcjson/jsonapi.go CreateMessageWithId 99.39% (327/329)
|
||||
github.com/conformal/btcjson/jsonapi.go RpcCommand 61.54% (8/13)
|
||||
github.com/conformal/btcjson/jsonapi.go RpcRawCommand 53.33% (8/15)
|
||||
github.com/conformal/btcjson ------------------- 97.52% (471/483)
|
||||
github.com/conformal/btcjson ------------------- 97.08% (466/480)
|
||||
|
||||
|
|
Loading…
Reference in a new issue