add sendmany to btcctl
This commit is contained in:
parent
b354015426
commit
c0d6180685
1 changed files with 25 additions and 0 deletions
|
@ -76,6 +76,7 @@ var commandHandlers = map[string]*handlerData{
|
||||||
"ping": &handlerData{0, 0, displayGeneric, nil, makePing, ""},
|
"ping": &handlerData{0, 0, displayGeneric, nil, makePing, ""},
|
||||||
"sendfrom": &handlerData{3, 3, displayGeneric, []conversionHandler{nil, nil, toSatoshi, toInt, nil, nil},
|
"sendfrom": &handlerData{3, 3, displayGeneric, []conversionHandler{nil, nil, toSatoshi, toInt, nil, nil},
|
||||||
makeSendFrom, "<account> <address> <amount> [minconf=1] [comment] [comment-to]"},
|
makeSendFrom, "<account> <address> <amount> [minconf=1] [comment] [comment-to]"},
|
||||||
|
"sendmany": &handlerData{2, 2, displayGeneric, []conversionHandler{nil, nil, toInt, nil}, makeSendMany, "<account> <{\"address\":amount,...}> [minconf=1] [comment]"},
|
||||||
"sendrawtransaction": &handlerData{1, 0, displayGeneric, nil, makeSendRawTransaction, "<hextx>"},
|
"sendrawtransaction": &handlerData{1, 0, displayGeneric, nil, makeSendRawTransaction, "<hextx>"},
|
||||||
"stop": &handlerData{0, 0, displayGeneric, nil, makeStop, ""},
|
"stop": &handlerData{0, 0, displayGeneric, nil, makeStop, ""},
|
||||||
"submitblock": &handlerData{1, 1, displayGeneric, nil, makeSubmitBlock, "<hexdata> [jsonparametersobject]"},
|
"submitblock": &handlerData{1, 1, displayGeneric, nil, makeSubmitBlock, "<hexdata> [jsonparametersobject]"},
|
||||||
|
@ -463,6 +464,30 @@ func makeSendFrom(args []interface{}) (btcjson.Cmd, error) {
|
||||||
args[2].(int64), minconf, comment, commentTo)
|
args[2].(int64), minconf, comment, commentTo)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// makeSendMany generates the cmd structure for sendmany commands.
|
||||||
|
func makeSendMany(args []interface{}) (btcjson.Cmd, error) {
|
||||||
|
minconf := 1
|
||||||
|
comment := ""
|
||||||
|
|
||||||
|
origPairs := make(map[string]float64)
|
||||||
|
err := json.Unmarshal([]byte(args[1].(string)), &origPairs)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
pairs := make(map[string]int64)
|
||||||
|
for addr, value := range origPairs {
|
||||||
|
pairs[addr] = int64(float64(btcutil.SatoshiPerBitcoin) * value)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(args) > 2 {
|
||||||
|
minconf = args[2].(int)
|
||||||
|
}
|
||||||
|
if len(args) > 3 {
|
||||||
|
comment = args[3].(string)
|
||||||
|
}
|
||||||
|
return btcjson.NewSendManyCmd("btcctl", args[0].(string), pairs, minconf, comment)
|
||||||
|
}
|
||||||
|
|
||||||
// makeSendRawTransaction generates the cmd structure for sendrawtransaction
|
// makeSendRawTransaction generates the cmd structure for sendrawtransaction
|
||||||
// commands.
|
// commands.
|
||||||
func makeSendRawTransaction(args []interface{}) (btcjson.Cmd, error) {
|
func makeSendRawTransaction(args []interface{}) (btcjson.Cmd, error) {
|
||||||
|
|
Loading…
Reference in a new issue