add decoderawtransaction, getbestblockhash, getdifficulty, and

getrawmempool to btcctl.
This commit is contained in:
David Hill 2013-10-17 12:35:27 -04:00
parent 4c50ff541f
commit ff20c420a2

View file

@ -43,6 +43,34 @@ func main() {
switch args[0] { switch args[0] {
default: default:
usage(parser) usage(parser)
case "decoderawtransaction":
if len(args) != 2 {
usage(parser)
break
}
msg, err := btcjson.CreateMessage("decoderawtransaction", args[1])
if err != nil {
fmt.Printf("CreateMessage: %v\n", err)
break
}
reply, err := send(&cfg, msg)
if err != nil {
fmt.Printf("RpcCommand: %v\n", err)
break
}
spew.Dump(reply)
case "getbestblockhash":
msg, err := btcjson.CreateMessage("getbestblockhash")
if err != nil {
fmt.Printf("CreateMessage: %v\n", err)
break
}
reply, err := send(&cfg, msg)
if err != nil {
fmt.Printf("RpcCommand: %v\n", err)
break
}
fmt.Printf("%s\n", reply.(string))
case "getblock": case "getblock":
if len(args) != 2 { if len(args) != 2 {
usage(parser) usage(parser)
@ -92,6 +120,18 @@ func main() {
break break
} }
fmt.Printf("%v\n", reply) fmt.Printf("%v\n", reply)
case "getdifficulty":
msg, err := btcjson.CreateMessage("getdifficulty")
if err != nil {
fmt.Printf("CreateMessage: %v\n", err)
break
}
reply, err := send(&cfg, msg)
if err != nil {
fmt.Printf("RpcCommand: %v\n", err)
break
}
fmt.Printf("%f\n", reply.(float64))
case "getgenerate": case "getgenerate":
msg, err := btcjson.CreateMessage("getgenerate") msg, err := btcjson.CreateMessage("getgenerate")
if err != nil { if err != nil {
@ -104,6 +144,18 @@ func main() {
break break
} }
fmt.Printf("%v\n", reply.(bool)) fmt.Printf("%v\n", reply.(bool))
case "getrawmempool":
msg, err := btcjson.CreateMessage("getrawmempool")
if err != nil {
fmt.Printf("CreateMessage: %v\n", err)
break
}
reply, err := send(&cfg, msg)
if err != nil {
fmt.Printf("RpcCommand: %v\n", err)
break
}
spew.Dump(reply)
case "getrawtransaction": case "getrawtransaction":
if len(args) != 2 { if len(args) != 2 {
usage(parser) usage(parser)
@ -151,10 +203,14 @@ func usage(parser *flags.Parser) {
parser.WriteHelp(os.Stderr) parser.WriteHelp(os.Stderr)
fmt.Fprintf(os.Stderr, fmt.Fprintf(os.Stderr,
"\nCommands:\n"+ "\nCommands:\n"+
"\tdecoderawtransaction <txhash>\n"+
"\tgetbestblockhash\n"+
"\tgetblock <blockhash>\n"+ "\tgetblock <blockhash>\n"+
"\tgetblockcount\n"+ "\tgetblockcount\n"+
"\tgetblockhash <blocknumber>\n"+ "\tgetblockhash <blocknumber>\n"+
"\tgetdifficulty\n"+
"\tgetgenerate\n"+ "\tgetgenerate\n"+
"\tgetrawmempool\n"+
"\tgetrawtransaction <txhash>\n"+ "\tgetrawtransaction <txhash>\n"+
"\tstop\n") "\tstop\n")
} }