Make params which reference txout indices uint32.
This reasons for this change follow: - All instances of the same key should be consistent amongst the commands and returns - Output indices can't be negative, so rather than adding more code to check for a negative after unmarshal, just allow the unmarshal to weed out negatives ok @jcvernaleo
This commit is contained in:
parent
1997d73c65
commit
b585d4e3a0
4 changed files with 10 additions and 10 deletions
|
@ -490,13 +490,13 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
|
||||||
}
|
}
|
||||||
type vlist struct {
|
type vlist struct {
|
||||||
Txid string `json:"txid"`
|
Txid string `json:"txid"`
|
||||||
Vout int `json:"vout"`
|
Vout uint32 `json:"vout"`
|
||||||
}
|
}
|
||||||
vList := make([]vlist, len(args)/4)
|
vList := make([]vlist, len(args)/4)
|
||||||
addresses := make(map[string]float64)
|
addresses := make(map[string]float64)
|
||||||
for i := 0; i < len(args)/4; i += 1 {
|
for i := 0; i < len(args)/4; i += 1 {
|
||||||
txid, ok1 := args[(i*4)+0].(string)
|
txid, ok1 := args[(i*4)+0].(string)
|
||||||
vout, ok2 := args[(i*4)+1].(int)
|
vout, ok2 := args[(i*4)+1].(uint32)
|
||||||
add, ok3 := args[(i*4)+2].(string)
|
add, ok3 := args[(i*4)+2].(string)
|
||||||
amt, ok4 := args[(i*4)+3].(float64)
|
amt, ok4 := args[(i*4)+3].(float64)
|
||||||
if !ok1 || !ok2 || !ok3 || !ok4 {
|
if !ok1 || !ok2 || !ok3 || !ok4 {
|
||||||
|
@ -574,14 +574,14 @@ func CreateMessageWithId(message string, id interface{}, args ...interface{}) ([
|
||||||
}
|
}
|
||||||
type txlist struct {
|
type txlist struct {
|
||||||
Txid string `json:"txid"`
|
Txid string `json:"txid"`
|
||||||
Vout int `json:"vout"`
|
Vout uint32 `json:"vout"`
|
||||||
ScriptPubKey string `json:"scriptPubKey"`
|
ScriptPubKey string `json:"scriptPubKey"`
|
||||||
}
|
}
|
||||||
txList := make([]txlist, 1)
|
txList := make([]txlist, 1)
|
||||||
|
|
||||||
if len(args) > 1 {
|
if len(args) > 1 {
|
||||||
txid, ok2 := args[1].(string)
|
txid, ok2 := args[1].(string)
|
||||||
vout, ok3 := args[2].(int)
|
vout, ok3 := args[2].(uint32)
|
||||||
spkey, ok4 := args[3].(string)
|
spkey, ok4 := args[3].(string)
|
||||||
if !ok1 || !ok2 || !ok3 || !ok4 {
|
if !ok1 || !ok2 || !ok3 || !ok4 {
|
||||||
err = fmt.Errorf("Incorrect arguement types.")
|
err = fmt.Errorf("Incorrect arguement types.")
|
||||||
|
|
|
@ -154,7 +154,7 @@ var cmdtests = []struct {
|
||||||
{"addmultisignaddress", []interface{}{1, "test"}, false},
|
{"addmultisignaddress", []interface{}{1, "test"}, false},
|
||||||
{"addmultisignaddress", []interface{}{1, 1.0, "test"}, false},
|
{"addmultisignaddress", []interface{}{1, 1.0, "test"}, false},
|
||||||
{"addmultisignaddress", []interface{}{1, "test", "test", "test"}, true},
|
{"addmultisignaddress", []interface{}{1, "test", "test", "test"}, true},
|
||||||
{"createrawtransaction", []interface{}{"in1", 0, "a1", 1.0}, true},
|
{"createrawtransaction", []interface{}{"in1", uint32(0), "a1", 1.0}, true},
|
||||||
{"createrawtransaction", []interface{}{"in1", "out1", "a1", 1.0, "test"}, false},
|
{"createrawtransaction", []interface{}{"in1", "out1", "a1", 1.0, "test"}, false},
|
||||||
{"createrawtransaction", []interface{}{}, false},
|
{"createrawtransaction", []interface{}{}, false},
|
||||||
{"createrawtransaction", []interface{}{"in1", 1.0, "a1", 1.0}, false},
|
{"createrawtransaction", []interface{}{"in1", 1.0, "a1", 1.0}, false},
|
||||||
|
@ -166,7 +166,7 @@ var cmdtests = []struct {
|
||||||
{"lockunspent", []interface{}{true, "something"}, true},
|
{"lockunspent", []interface{}{true, "something"}, true},
|
||||||
{"lockunspent", []interface{}{true}, false},
|
{"lockunspent", []interface{}{true}, false},
|
||||||
{"lockunspent", []interface{}{1.0, "something"}, false},
|
{"lockunspent", []interface{}{1.0, "something"}, false},
|
||||||
{"signrawtransaction", []interface{}{"hexstring", "test", 1, "test"}, true},
|
{"signrawtransaction", []interface{}{"hexstring", "test", uint32(1), "test"}, true},
|
||||||
{"signrawtransaction", []interface{}{"hexstring", "test", "test2", "test3", "test4"}, false},
|
{"signrawtransaction", []interface{}{"hexstring", "test", "test2", "test3", "test4"}, false},
|
||||||
{"signrawtransaction", []interface{}{"hexstring", "test", "test2", "test3"}, false},
|
{"signrawtransaction", []interface{}{"hexstring", "test", "test2", "test3"}, false},
|
||||||
{"signrawtransaction", []interface{}{1.2, "test", "test2", "test3", "test4"}, false},
|
{"signrawtransaction", []interface{}{1.2, "test", "test2", "test3", "test4"}, false},
|
||||||
|
|
|
@ -752,7 +752,7 @@ func (cmd *CreateMultisigCmd) UnmarshalJSON(b []byte) error {
|
||||||
// transactionsha and output number pair.
|
// transactionsha and output number pair.
|
||||||
type TransactionInput struct {
|
type TransactionInput struct {
|
||||||
Txid string `json:"txid"`
|
Txid string `json:"txid"`
|
||||||
Vout int `json:"vout"`
|
Vout uint32 `json:"vout"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateRawTransactionCmd is a type handling custom marshaling and
|
// CreateRawTransactionCmd is a type handling custom marshaling and
|
||||||
|
|
|
@ -158,7 +158,7 @@ type ScriptSig struct {
|
||||||
type Vin struct {
|
type Vin struct {
|
||||||
Coinbase string `json:"coinbase"`
|
Coinbase string `json:"coinbase"`
|
||||||
Txid string `json:"txid"`
|
Txid string `json:"txid"`
|
||||||
Vout int `json:"vout"`
|
Vout uint32 `json:"vout"`
|
||||||
ScriptSig *ScriptSig `json:"scriptSig"`
|
ScriptSig *ScriptSig `json:"scriptSig"`
|
||||||
Sequence uint32 `json:"sequence"`
|
Sequence uint32 `json:"sequence"`
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ func (v *Vin) MarshalJSON() ([]byte, error) {
|
||||||
|
|
||||||
txStruct := struct {
|
txStruct := struct {
|
||||||
Txid string `json:"txid"`
|
Txid string `json:"txid"`
|
||||||
Vout int `json:"vout"`
|
Vout uint32 `json:"vout"`
|
||||||
ScriptSig *ScriptSig `json:"scriptSig"`
|
ScriptSig *ScriptSig `json:"scriptSig"`
|
||||||
Sequence uint32 `json:"sequence"`
|
Sequence uint32 `json:"sequence"`
|
||||||
}{
|
}{
|
||||||
|
@ -199,7 +199,7 @@ func (v *Vin) MarshalJSON() ([]byte, error) {
|
||||||
// getrawtransaction and decoderawtransaction use the same structure.
|
// getrawtransaction and decoderawtransaction use the same structure.
|
||||||
type Vout struct {
|
type Vout struct {
|
||||||
Value float64 `json:"value"`
|
Value float64 `json:"value"`
|
||||||
N int `json:"n"`
|
N uint32 `json:"n"`
|
||||||
ScriptPubKey struct {
|
ScriptPubKey struct {
|
||||||
Asm string `json:"asm"`
|
Asm string `json:"asm"`
|
||||||
Hex string `json:"hex"`
|
Hex string `json:"hex"`
|
||||||
|
|
Loading…
Reference in a new issue