tiny fixes
This commit is contained in:
parent
04f79f3ad2
commit
6da5f72de9
|
@ -91,7 +91,7 @@ func init() {
|
||||||
packetCreateFlags := []Flag2Register{
|
packetCreateFlags := []Flag2Register{
|
||||||
fromFlagReg,
|
fromFlagReg,
|
||||||
{&ibcToFlag, "to", "", "Destination ChainID"},
|
{&ibcToFlag, "to", "", "Destination ChainID"},
|
||||||
{&ibcTypeFlag, "type", "", "IBC packet type (eg. coin},"},
|
{&ibcTypeFlag, "type", "", "IBC packet type (eg. coin)"},
|
||||||
{&ibcPayloadFlag, "payload", "", "IBC packet payload"},
|
{&ibcPayloadFlag, "payload", "", "IBC packet payload"},
|
||||||
{&ibcSequenceFlag, "ibc_sequence", -1, "sequence number for IBC packet"},
|
{&ibcSequenceFlag, "ibc_sequence", -1, "sequence number for IBC packet"},
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,11 +19,10 @@ var (
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
// setupFile aborts on error... or should we return it??
|
|
||||||
// returns 1 iff it set a file, otherwise 0 (so we can add them)
|
// returns 1 iff it set a file, otherwise 0 (so we can add them)
|
||||||
func setupFile(path, data string, perm os.FileMode) (int, error) {
|
func setupFile(path, data string, perm os.FileMode) (int, error) {
|
||||||
_, err := os.Stat(path)
|
_, err := os.Stat(path)
|
||||||
if !os.IsNotExist(err) {
|
if !os.IsNotExist(err) { //permission errors generated if use os.IsExist
|
||||||
return 0, nil
|
return 0, nil
|
||||||
}
|
}
|
||||||
err = ioutil.WriteFile(path, []byte(data), perm)
|
err = ioutil.WriteFile(path, []byte(data), perm)
|
||||||
|
|
|
@ -31,7 +31,6 @@ var (
|
||||||
func newKeyCmd(cmd *cobra.Command, args []string) error {
|
func newKeyCmd(cmd *cobra.Command, args []string) error {
|
||||||
key := genKey()
|
key := genKey()
|
||||||
keyJSON, err := json.MarshalIndent(key, "", "\t")
|
keyJSON, err := json.MarshalIndent(key, "", "\t")
|
||||||
fmt.Println(&key)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,6 +198,9 @@ func verifyCmd(cmd *cobra.Command, args []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
proofBytes, err := hex.DecodeString(StripHex(proofFlag))
|
proofBytes, err := hex.DecodeString(StripHex(proofFlag))
|
||||||
|
if err != nil {
|
||||||
|
return errors.Errorf("Proof (%v) is invalid hex: %v\n", proofBytes, err)
|
||||||
|
}
|
||||||
|
|
||||||
proof, err := merkle.ReadProof(proofBytes)
|
proof, err := merkle.ReadProof(proofBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -43,12 +43,9 @@ func init() {
|
||||||
{&addrFlag, "address", "tcp://0.0.0.0:46658", "Listen address"},
|
{&addrFlag, "address", "tcp://0.0.0.0:46658", "Listen address"},
|
||||||
{&eyesFlag, "eyes", "local", "MerkleEyes address, or 'local' for embedded"},
|
{&eyesFlag, "eyes", "local", "MerkleEyes address, or 'local' for embedded"},
|
||||||
{&dirFlag, "dir", ".", "Root directory"},
|
{&dirFlag, "dir", ".", "Root directory"},
|
||||||
{&withoutTendermintFlag, "without-tendermint", false, "RunE Tendermint in-process with the App"},
|
{&withoutTendermintFlag, "without-tendermint", false, "Run Tendermint in-process with the App"},
|
||||||
}
|
}
|
||||||
RegisterFlags(StartCmd, flags)
|
RegisterFlags(StartCmd, flags)
|
||||||
|
|
||||||
// TODO: move to config file
|
|
||||||
// eyesCacheSizePtr := flag.Int("eyes-cache-size", 10000, "MerkleEyes db cache size, for embedded")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func startCmd(cmd *cobra.Command, args []string) error {
|
func startCmd(cmd *cobra.Command, args []string) error {
|
||||||
|
@ -134,7 +131,7 @@ func startTendermint(dir string, basecoinApp *app.Basecoin) error {
|
||||||
|
|
||||||
_, err := n.Start()
|
_, err := n.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Errorf("%v\n", err)
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait forever
|
// Wait forever
|
||||||
|
|
|
@ -58,10 +58,10 @@ func init() {
|
||||||
{&txNodeFlag, "node", "tcp://localhost:46657", "Tendermint RPC address"},
|
{&txNodeFlag, "node", "tcp://localhost:46657", "Tendermint RPC address"},
|
||||||
{&chainIDFlag, "chain_id", "test_chain_id", "ID of the chain for replay protection"},
|
{&chainIDFlag, "chain_id", "test_chain_id", "ID of the chain for replay protection"},
|
||||||
{&fromFlag, "from", "key.json", "Path to a private key to sign the transaction"},
|
{&fromFlag, "from", "key.json", "Path to a private key to sign the transaction"},
|
||||||
{&amountFlag, "amount", "", "Coins to send in transaction of the format <amt><coin>,<amt2><coin2>,... (eg: 1btc,2gold,5silver},"},
|
{&amountFlag, "amount", "", "Coins to send in transaction of the format <amt><coin>,<amt2><coin2>,... (eg: 1btc,2gold,5silver)"},
|
||||||
{&gasFlag, "gas", 0, "The amount of gas for the transaction"},
|
{&gasFlag, "gas", 0, "The amount of gas for the transaction"},
|
||||||
{&feeFlag, "fee", "", "Coins for the transaction fee of the format <amt><coin>"},
|
{&feeFlag, "fee", "", "Coins for the transaction fee of the format <amt><coin>"},
|
||||||
{&seqFlag, "sequence", -1, "Sequence number for the account (-1 to autocalculate},"},
|
{&seqFlag, "sequence", -1, "Sequence number for the account (-1 to autocalculate)"},
|
||||||
}
|
}
|
||||||
|
|
||||||
sendTxFlags := []Flag2Register{
|
sendTxFlags := []Flag2Register{
|
||||||
|
|
|
@ -4,6 +4,10 @@ import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
|
"regexp"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -22,14 +26,14 @@ import (
|
||||||
|
|
||||||
//This variable can be overwritten by plugin applications
|
//This variable can be overwritten by plugin applications
|
||||||
// if they require a different working directory
|
// if they require a different working directory
|
||||||
var DefaultHome = "basecoin"
|
var DefaultHome = ".basecoin"
|
||||||
|
|
||||||
func BasecoinRoot(rootDir string) string {
|
func BasecoinRoot(rootDir string) string {
|
||||||
if rootDir == "" {
|
if rootDir == "" {
|
||||||
rootDir = os.Getenv("BCHOME")
|
rootDir = os.Getenv("BCHOME")
|
||||||
}
|
}
|
||||||
if rootDir == "" {
|
if rootDir == "" {
|
||||||
rootDir = os.Getenv("HOME") + "/." + DefaultHome
|
rootDir = path.Join(os.Getenv("HOME"), DefaultHome)
|
||||||
}
|
}
|
||||||
return rootDir
|
return rootDir
|
||||||
}
|
}
|
||||||
|
@ -48,6 +52,14 @@ func ExecuteWithDebug(RootCmd *cobra.Command) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Quickly registering flags can be quickly achieved through using the utility functions
|
||||||
|
//RegisterFlags, and RegisterPersistentFlags. Ex:
|
||||||
|
// flags := []Flag2Register{
|
||||||
|
// {&myStringFlag, "mystringflag", "foobar", "description of what this flag does"},
|
||||||
|
// {&myBoolFlag, "myboolflag", false, "description of what this flag does"},
|
||||||
|
// {&myInt64Flag, "myintflag", 333, "description of what this flag does"},
|
||||||
|
// }
|
||||||
|
// RegisterFlags(MyCobraCmd, flags)
|
||||||
type Flag2Register struct {
|
type Flag2Register struct {
|
||||||
Pointer interface{}
|
Pointer interface{}
|
||||||
Use string
|
Use string
|
||||||
|
|
Loading…
Reference in New Issue