mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 14:52:17 +00:00
tendermint send_tx
This commit is contained in:
parent
1a27d4dd63
commit
56b195a899
@ -2,8 +2,8 @@ package account
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/tendermint/tendermint/Godeps/_workspace/src/github.com/tendermint/ed25519"
|
"github.com/tendermint/tendermint/Godeps/_workspace/src/github.com/tendermint/ed25519"
|
||||||
"github.com/tendermint/tendermint/wire"
|
|
||||||
. "github.com/tendermint/tendermint/common"
|
. "github.com/tendermint/tendermint/common"
|
||||||
|
"github.com/tendermint/tendermint/wire"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PrivAccount struct {
|
type PrivAccount struct {
|
||||||
@ -47,9 +47,14 @@ func GenPrivAccount() *PrivAccount {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Generates 32 priv key bytes from secret
|
||||||
|
func GenPrivKeyBytesFromSecret(secret string) []byte {
|
||||||
|
return wire.BinarySha256(secret) // Not Ripemd160 because we want 32 bytes.
|
||||||
|
}
|
||||||
|
|
||||||
// Generates a new account with private key from SHA256 hash of a secret
|
// Generates a new account with private key from SHA256 hash of a secret
|
||||||
func GenPrivAccountFromSecret(secret []byte) *PrivAccount {
|
func GenPrivAccountFromSecret(secret string) *PrivAccount {
|
||||||
privKey32 := wire.BinarySha256(secret) // Not Ripemd160 because we want 32 bytes.
|
privKey32 := GenPrivKeyBytesFromSecret(secret)
|
||||||
privKeyBytes := new([64]byte)
|
privKeyBytes := new([64]byte)
|
||||||
copy(privKeyBytes[:32], privKey32)
|
copy(privKeyBytes[:32], privKey32)
|
||||||
pubKeyBytes := ed25519.MakePublicKey(privKeyBytes)
|
pubKeyBytes := ed25519.MakePublicKey(privKeyBytes)
|
||||||
@ -62,13 +67,15 @@ func GenPrivAccountFromSecret(secret []byte) *PrivAccount {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func GenPrivAccountFromPrivKeyBytes(privKeyBytes *[64]byte) *PrivAccount {
|
func GenPrivAccountFromPrivKeyBytes(privKeyBytes []byte) *PrivAccount {
|
||||||
if len(privKeyBytes) != 64 {
|
if len(privKeyBytes) != 64 {
|
||||||
PanicSanity(Fmt("Expected 64 bytes but got %v", len(privKeyBytes)))
|
PanicSanity(Fmt("Expected 64 bytes but got %v", len(privKeyBytes)))
|
||||||
}
|
}
|
||||||
pubKeyBytes := ed25519.MakePublicKey(privKeyBytes)
|
var privKeyArray [64]byte
|
||||||
|
copy(privKeyArray[:], privKeyBytes)
|
||||||
|
pubKeyBytes := ed25519.MakePublicKey(&privKeyArray)
|
||||||
pubKey := PubKeyEd25519(*pubKeyBytes)
|
pubKey := PubKeyEd25519(*pubKeyBytes)
|
||||||
privKey := PrivKeyEd25519(*privKeyBytes)
|
privKey := PrivKeyEd25519(privKeyArray)
|
||||||
return &PrivAccount{
|
return &PrivAccount{
|
||||||
Address: pubKey.Address(),
|
Address: pubKey.Address(),
|
||||||
PubKey: pubKey,
|
PubKey: pubKey,
|
||||||
|
@ -42,9 +42,7 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
var privKeyArray [64]byte
|
root := acm.GenPrivAccountFromPrivKeyBytes(privKeyBytes)
|
||||||
copy(privKeyArray[:], privKeyBytes)
|
|
||||||
root := acm.GenPrivAccountFromPrivKeyBytes(&privKeyArray)
|
|
||||||
fmt.Println("Computed address: %X", root.Address)
|
fmt.Println("Computed address: %X", root.Address)
|
||||||
|
|
||||||
// Get root account.
|
// Get root account.
|
||||||
|
@ -10,14 +10,14 @@ import (
|
|||||||
|
|
||||||
func gen_account() {
|
func gen_account() {
|
||||||
|
|
||||||
seed, err := Prompt(`Enter your desired seed, or just hit <Enter> to generate a random account.
|
secret, err := Prompt(`Enter your desired secret, or just hit <Enter> to generate a random account.
|
||||||
IMPORTANT: If you don't know what a dictionary attack is, just hit Enter
|
IMPORTANT: If you don't know what a dictionary attack is, just hit Enter
|
||||||
> `, "")
|
> `, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
Exit(Fmt("Not sure what happened: %v", err))
|
Exit(Fmt("Not sure what happened: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
if seed == "" {
|
if secret == "" {
|
||||||
privAccount := acm.GenPrivAccount()
|
privAccount := acm.GenPrivAccount()
|
||||||
privAccountJSONBytes := wire.JSONBytes(privAccount)
|
privAccountJSONBytes := wire.JSONBytes(privAccount)
|
||||||
fmt.Printf(`Generated a new random account!
|
fmt.Printf(`Generated a new random account!
|
||||||
@ -28,14 +28,14 @@ IMPORTANT: If you don't know what a dictionary attack is, just hit Enter
|
|||||||
string(privAccountJSONBytes),
|
string(privAccountJSONBytes),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
privAccount := acm.GenPrivAccountFromSecret([]byte(seed))
|
privAccount := acm.GenPrivAccountFromSecret(secret)
|
||||||
privAccountJSONBytes := wire.JSONBytes(privAccount)
|
privAccountJSONBytes := wire.JSONBytes(privAccount)
|
||||||
fmt.Printf(`Generated a new account from seed: [%v]!
|
fmt.Printf(`Generated a new account from secret: [%v]!
|
||||||
|
|
||||||
%v
|
%v
|
||||||
|
|
||||||
`,
|
`,
|
||||||
seed,
|
secret,
|
||||||
string(privAccountJSONBytes),
|
string(privAccountJSONBytes),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1,119 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bufio"
|
|
||||||
"bytes"
|
|
||||||
"encoding/hex"
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
acm "github.com/tendermint/tendermint/account"
|
|
||||||
"github.com/tendermint/tendermint/wire"
|
|
||||||
. "github.com/tendermint/tendermint/common"
|
|
||||||
dbm "github.com/tendermint/tendermint/db"
|
|
||||||
sm "github.com/tendermint/tendermint/state"
|
|
||||||
"github.com/tendermint/tendermint/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
func getString(prompt string) string {
|
|
||||||
reader := bufio.NewReader(os.Stdin)
|
|
||||||
fmt.Print(prompt)
|
|
||||||
input, _ := reader.ReadString('\n')
|
|
||||||
return input[:len(input)-1]
|
|
||||||
}
|
|
||||||
|
|
||||||
func getByteSliceFromHex(prompt string) []byte {
|
|
||||||
input := getString(prompt)
|
|
||||||
bytes, err := hex.DecodeString(input)
|
|
||||||
if err != nil {
|
|
||||||
Exit(Fmt("Not in hex format: %v\nError: %v\n", input, err))
|
|
||||||
}
|
|
||||||
return bytes
|
|
||||||
}
|
|
||||||
|
|
||||||
func getInt(prompt string) int {
|
|
||||||
input := getString(prompt)
|
|
||||||
i, err := strconv.Atoi(input)
|
|
||||||
if err != nil {
|
|
||||||
Exit(Fmt("Not a valid int64 amount: %v\nError: %v\n", input, err))
|
|
||||||
}
|
|
||||||
return i
|
|
||||||
}
|
|
||||||
|
|
||||||
func getInt64(prompt string) int64 {
|
|
||||||
return int64(getInt(prompt))
|
|
||||||
}
|
|
||||||
|
|
||||||
func gen_tx() {
|
|
||||||
|
|
||||||
// Get State, which may be nil.
|
|
||||||
stateDB := dbm.GetDB("state")
|
|
||||||
state := sm.LoadState(stateDB)
|
|
||||||
|
|
||||||
// Get source pubkey
|
|
||||||
srcPubKeyBytes := getByteSliceFromHex("Enter source pubkey: ")
|
|
||||||
r, n, err := bytes.NewReader(srcPubKeyBytes), new(int64), new(error)
|
|
||||||
srcPubKey := wire.ReadBinary(struct{ acm.PubKey }{}, r, n, err).(struct{ acm.PubKey }).PubKey
|
|
||||||
if *err != nil {
|
|
||||||
Exit(Fmt("Invalid PubKey. Error: %v", err))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the state of the account.
|
|
||||||
var srcAccount *acm.Account
|
|
||||||
var srcAccountAddress = srcPubKey.Address()
|
|
||||||
var srcAccountBalanceStr = "unknown"
|
|
||||||
var srcAccountSequenceStr = "unknown"
|
|
||||||
srcAddress := srcPubKey.Address()
|
|
||||||
if state != nil {
|
|
||||||
srcAccount = state.GetAccount(srcAddress)
|
|
||||||
srcAccountBalanceStr = Fmt("%v", srcAccount.Balance)
|
|
||||||
srcAccountSequenceStr = Fmt("%v", srcAccount.Sequence+1)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the amount to send from src account
|
|
||||||
srcSendAmount := getInt64(Fmt("Enter amount to send from %X (total: %v): ", srcAccountAddress, srcAccountBalanceStr))
|
|
||||||
|
|
||||||
// Get the next sequence of src account
|
|
||||||
srcSendSequence := getInt(Fmt("Enter next sequence for %X (guess: %v): ", srcAccountAddress, srcAccountSequenceStr))
|
|
||||||
|
|
||||||
// Get dest address
|
|
||||||
dstAddress := getByteSliceFromHex("Enter destination address: ")
|
|
||||||
|
|
||||||
// Get the amount to send to dst account
|
|
||||||
dstSendAmount := getInt64(Fmt("Enter amount to send to %X: ", dstAddress))
|
|
||||||
|
|
||||||
// Construct SendTx
|
|
||||||
tx := &types.SendTx{
|
|
||||||
Inputs: []*types.TxInput{
|
|
||||||
&types.TxInput{
|
|
||||||
Address: srcAddress,
|
|
||||||
Amount: srcSendAmount,
|
|
||||||
Sequence: srcSendSequence,
|
|
||||||
Signature: acm.SignatureEd25519{},
|
|
||||||
PubKey: srcPubKey,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
Outputs: []*types.TxOutput{
|
|
||||||
&types.TxOutput{
|
|
||||||
Address: dstAddress,
|
|
||||||
Amount: dstSendAmount,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
// Show the intermediate form.
|
|
||||||
fmt.Printf("Generated tx: %X\n", wire.BinaryBytes(tx))
|
|
||||||
|
|
||||||
// Get source privkey (for signing)
|
|
||||||
srcPrivKeyBytes := getByteSliceFromHex("Enter source privkey (for signing): ")
|
|
||||||
r, n, err = bytes.NewReader(srcPrivKeyBytes), new(int64), new(error)
|
|
||||||
srcPrivKey := wire.ReadBinary(struct{ acm.PrivKey }{}, r, n, err).(struct{ acm.PrivKey }).PrivKey
|
|
||||||
if *err != nil {
|
|
||||||
Exit(Fmt("Invalid PrivKey. Error: %v", err))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sign
|
|
||||||
tx.Inputs[0].Signature = srcPrivKey.Sign(acm.SignBytes(config.GetString("chain_id"), tx))
|
|
||||||
fmt.Printf("Signed tx: %X\n", wire.BinaryBytes(tx))
|
|
||||||
}
|
|
39
cmd/tendermint/get_account.go
Normal file
39
cmd/tendermint/get_account.go
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/hex"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
. "github.com/tendermint/tendermint/common"
|
||||||
|
cclient "github.com/tendermint/tendermint/rpc/core_client"
|
||||||
|
)
|
||||||
|
|
||||||
|
func get_account() {
|
||||||
|
addrHex, err := Prompt("Enter the address of the account in HEX (e.g. 9FCBA7F840A0BFEBBE755E853C9947270A912D04):\n> ", "")
|
||||||
|
if err != nil {
|
||||||
|
Exit(Fmt("Error: %v", err))
|
||||||
|
}
|
||||||
|
cli := cclient.NewClient("http://localhost:46657", "JSONRPC")
|
||||||
|
address, err := hex.DecodeString(addrHex)
|
||||||
|
if err != nil {
|
||||||
|
Exit(Fmt("Address was not hex: %v", addrHex))
|
||||||
|
}
|
||||||
|
res, err := cli.GetAccount(address)
|
||||||
|
if err != nil {
|
||||||
|
Exit(Fmt("Error fetching account: %v", err))
|
||||||
|
}
|
||||||
|
acc := res.Account
|
||||||
|
|
||||||
|
fmt.Printf(`
|
||||||
|
Address: %X
|
||||||
|
PubKey: %v
|
||||||
|
Sequence: %v
|
||||||
|
Balance: %v
|
||||||
|
Permissions: %v
|
||||||
|
`,
|
||||||
|
acc.Address,
|
||||||
|
acc.PubKey,
|
||||||
|
acc.Sequence,
|
||||||
|
acc.Balance,
|
||||||
|
acc.Permissions)
|
||||||
|
}
|
@ -19,7 +19,8 @@ Commands:
|
|||||||
node Run the tendermint node
|
node Run the tendermint node
|
||||||
gen_account Generate new account keypair
|
gen_account Generate new account keypair
|
||||||
gen_validator Generate new validator keypair
|
gen_validator Generate new validator keypair
|
||||||
gen_tx Generate new transaction
|
get_account Get account balance
|
||||||
|
send_tx Sign and publish a SendTx
|
||||||
probe_upnp Test UPnP functionality
|
probe_upnp Test UPnP functionality
|
||||||
version Show version info
|
version Show version info
|
||||||
`)
|
`)
|
||||||
@ -38,8 +39,10 @@ Commands:
|
|||||||
gen_account()
|
gen_account()
|
||||||
case "gen_validator":
|
case "gen_validator":
|
||||||
gen_validator()
|
gen_validator()
|
||||||
case "gen_tx":
|
case "get_account":
|
||||||
gen_tx()
|
get_account()
|
||||||
|
case "send_tx":
|
||||||
|
send_tx()
|
||||||
case "probe_upnp":
|
case "probe_upnp":
|
||||||
probe_upnp()
|
probe_upnp()
|
||||||
case "unsafe_reset_priv_validator":
|
case "unsafe_reset_priv_validator":
|
||||||
|
120
cmd/tendermint/send_tx.go
Normal file
120
cmd/tendermint/send_tx.go
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/hex"
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
acm "github.com/tendermint/tendermint/account"
|
||||||
|
. "github.com/tendermint/tendermint/common"
|
||||||
|
cclient "github.com/tendermint/tendermint/rpc/core_client"
|
||||||
|
"github.com/tendermint/tendermint/types"
|
||||||
|
)
|
||||||
|
|
||||||
|
func getString(prompt string) string {
|
||||||
|
input, err := Prompt(prompt, "")
|
||||||
|
if err != nil {
|
||||||
|
Exit(Fmt("Error reading input: %v", err))
|
||||||
|
}
|
||||||
|
return input
|
||||||
|
}
|
||||||
|
|
||||||
|
func getByteSliceFromHex(prompt string) []byte {
|
||||||
|
input := getString(prompt)
|
||||||
|
bytes, err := hex.DecodeString(input)
|
||||||
|
if err != nil {
|
||||||
|
Exit(Fmt("Not in hex format: %v\nError: %v\n", input, err))
|
||||||
|
}
|
||||||
|
return bytes
|
||||||
|
}
|
||||||
|
|
||||||
|
func getInt(prompt string) int {
|
||||||
|
input := getString(prompt)
|
||||||
|
i, err := strconv.Atoi(input)
|
||||||
|
if err != nil {
|
||||||
|
Exit(Fmt("Not a valid int64 amount: %v\nError: %v\n", input, err))
|
||||||
|
}
|
||||||
|
return i
|
||||||
|
}
|
||||||
|
|
||||||
|
func getInt64(prompt string) int64 {
|
||||||
|
return int64(getInt(prompt))
|
||||||
|
}
|
||||||
|
|
||||||
|
func send_tx() {
|
||||||
|
|
||||||
|
// Get PrivAccount
|
||||||
|
var privAccount *acm.PrivAccount
|
||||||
|
secret := getString("Enter your secret, or just hit <Enter> to enter a private key in HEX.\n> ")
|
||||||
|
if secret == "" {
|
||||||
|
privKeyBytes := getByteSliceFromHex("Enter your private key in HEX (e.g. E353CAD81134A301A542AEBE2D2E4EF1A64A145117EC72743AE9C9D171A4AA69F3A7DD670A9E9307AAED000D97D5B3C07D90276BFCEEDA5ED11DA089A4E87A81):\n> ")
|
||||||
|
privAccount = acm.GenPrivAccountFromPrivKeyBytes(privKeyBytes)
|
||||||
|
} else {
|
||||||
|
// Auto-detect private key hex
|
||||||
|
if len(secret) == 128 {
|
||||||
|
privKeyBytes, err := hex.DecodeString(secret)
|
||||||
|
if err == nil {
|
||||||
|
fmt.Println("Detected priv-key bytes...")
|
||||||
|
privAccount = acm.GenPrivAccountFromPrivKeyBytes(privKeyBytes)
|
||||||
|
} else {
|
||||||
|
fmt.Println("That's a long seed...")
|
||||||
|
privAccount = acm.GenPrivAccountFromSecret(secret)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
privAccount = acm.GenPrivAccountFromSecret(secret)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pubKey := privAccount.PubKey
|
||||||
|
|
||||||
|
// Get account data
|
||||||
|
cli := cclient.NewClient("http://localhost:46657", "JSONRPC")
|
||||||
|
res, err := cli.GetAccount(privAccount.Address)
|
||||||
|
if err != nil {
|
||||||
|
Exit(Fmt("Error fetching account: %v", err))
|
||||||
|
}
|
||||||
|
if res == nil {
|
||||||
|
Exit(Fmt("No account was found with that secret/private-key"))
|
||||||
|
}
|
||||||
|
inputAcc := res.Account
|
||||||
|
fmt.Printf(`
|
||||||
|
Source account:
|
||||||
|
Address: %X
|
||||||
|
PubKey: %v
|
||||||
|
Sequence: %v
|
||||||
|
Balance: %v
|
||||||
|
Permissions: %v
|
||||||
|
`,
|
||||||
|
inputAcc.Address,
|
||||||
|
pubKey,
|
||||||
|
inputAcc.Sequence,
|
||||||
|
inputAcc.Balance,
|
||||||
|
inputAcc.Permissions)
|
||||||
|
|
||||||
|
output := getByteSliceFromHex("\nEnter the output address in HEX:\n> ")
|
||||||
|
amount := getInt64("Enter the amount to send:\n> ")
|
||||||
|
|
||||||
|
// Construct transaction
|
||||||
|
tx := types.NewSendTx()
|
||||||
|
tx.AddInputWithNonce(pubKey, amount, inputAcc.Sequence+1)
|
||||||
|
tx.AddOutput(output, amount)
|
||||||
|
tx.Inputs[0].Signature = privAccount.Sign(config.GetString("chain_id"), tx)
|
||||||
|
fmt.Println("Signed SendTx!: ", tx)
|
||||||
|
|
||||||
|
// Sign up for events
|
||||||
|
wsCli := cclient.NewWSClient("ws://localhost:46657/websocket")
|
||||||
|
wsCli.Start()
|
||||||
|
err = wsCli.Subscribe(types.EventStringAccInput(inputAcc.Address))
|
||||||
|
if err != nil {
|
||||||
|
Exit(Fmt("Error subscribing to account send event: %v", err))
|
||||||
|
}
|
||||||
|
|
||||||
|
// Broadcast transaction
|
||||||
|
_, err = cli.BroadcastTx(tx)
|
||||||
|
if err != nil {
|
||||||
|
Exit(Fmt("Error broadcasting transaction: %v", err))
|
||||||
|
}
|
||||||
|
fmt.Println("Waiting for confirmation...")
|
||||||
|
|
||||||
|
_ = <-wsCli.EventsCh
|
||||||
|
fmt.Println("Confirmed.")
|
||||||
|
}
|
@ -76,6 +76,8 @@ func NewClient(addr, typ string) Client {
|
|||||||
return &ClientHTTP{addr}
|
return &ClientHTTP{addr}
|
||||||
case "JSONRPC":
|
case "JSONRPC":
|
||||||
return &ClientJSON{addr}
|
return &ClientJSON{addr}
|
||||||
|
default:
|
||||||
|
panic("Unknown client type " + typ + ". Select HTTP or JSONRPC")
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -195,6 +197,9 @@ fmt
|
|||||||
if err != nil{
|
if err != nil{
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.({{response.0}})
|
result, ok := response.Result.({{response.0}})
|
||||||
if !ok{
|
if !ok{
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -220,6 +225,9 @@ fmt
|
|||||||
if err != nil{
|
if err != nil{
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.({{response.0}})
|
result, ok := response.Result.({{response.0}})
|
||||||
if !ok{
|
if !ok{
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
|
@ -52,6 +52,9 @@ func (c *ClientHTTP) BlockchainInfo(minHeight int, maxHeight int) (*ctypes.Resul
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultBlockchainInfo)
|
result, ok := response.Result.(*ctypes.ResultBlockchainInfo)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -77,6 +80,9 @@ func (c *ClientHTTP) BroadcastTx(tx types.Tx) (*ctypes.ResultBroadcastTx, error)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultBroadcastTx)
|
result, ok := response.Result.(*ctypes.ResultBroadcastTx)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -102,6 +108,9 @@ func (c *ClientHTTP) Call(fromAddress []byte, toAddress []byte, data []byte) (*c
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultCall)
|
result, ok := response.Result.(*ctypes.ResultCall)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -127,6 +136,9 @@ func (c *ClientHTTP) CallCode(fromAddress []byte, code []byte, data []byte) (*ct
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultCall)
|
result, ok := response.Result.(*ctypes.ResultCall)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -152,6 +164,9 @@ func (c *ClientHTTP) DumpConsensusState() (*ctypes.ResultDumpConsensusState, err
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultDumpConsensusState)
|
result, ok := response.Result.(*ctypes.ResultDumpConsensusState)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -177,6 +192,9 @@ func (c *ClientHTTP) DumpStorage(address []byte) (*ctypes.ResultDumpStorage, err
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultDumpStorage)
|
result, ok := response.Result.(*ctypes.ResultDumpStorage)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -202,6 +220,9 @@ func (c *ClientHTTP) GenPrivAccount() (*ctypes.ResultGenPrivAccount, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultGenPrivAccount)
|
result, ok := response.Result.(*ctypes.ResultGenPrivAccount)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -227,6 +248,9 @@ func (c *ClientHTTP) Genesis() (*ctypes.ResultGenesis, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultGenesis)
|
result, ok := response.Result.(*ctypes.ResultGenesis)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -252,6 +276,9 @@ func (c *ClientHTTP) GetAccount(address []byte) (*ctypes.ResultGetAccount, error
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultGetAccount)
|
result, ok := response.Result.(*ctypes.ResultGetAccount)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -277,6 +304,9 @@ func (c *ClientHTTP) GetBlock(height int) (*ctypes.ResultGetBlock, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultGetBlock)
|
result, ok := response.Result.(*ctypes.ResultGetBlock)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -302,6 +332,9 @@ func (c *ClientHTTP) GetName(name string) (*ctypes.ResultGetName, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultGetName)
|
result, ok := response.Result.(*ctypes.ResultGetName)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -327,6 +360,9 @@ func (c *ClientHTTP) GetStorage(address []byte, key []byte) (*ctypes.ResultGetSt
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultGetStorage)
|
result, ok := response.Result.(*ctypes.ResultGetStorage)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -352,6 +388,9 @@ func (c *ClientHTTP) ListAccounts() (*ctypes.ResultListAccounts, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultListAccounts)
|
result, ok := response.Result.(*ctypes.ResultListAccounts)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -377,6 +416,9 @@ func (c *ClientHTTP) ListNames() (*ctypes.ResultListNames, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultListNames)
|
result, ok := response.Result.(*ctypes.ResultListNames)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -402,6 +444,9 @@ func (c *ClientHTTP) ListUnconfirmedTxs() (*ctypes.ResultListUnconfirmedTxs, err
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultListUnconfirmedTxs)
|
result, ok := response.Result.(*ctypes.ResultListUnconfirmedTxs)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -427,6 +472,9 @@ func (c *ClientHTTP) ListValidators() (*ctypes.ResultListValidators, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultListValidators)
|
result, ok := response.Result.(*ctypes.ResultListValidators)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -452,6 +500,9 @@ func (c *ClientHTTP) NetInfo() (*ctypes.ResultNetInfo, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultNetInfo)
|
result, ok := response.Result.(*ctypes.ResultNetInfo)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -477,6 +528,9 @@ func (c *ClientHTTP) SignTx(tx types.Tx, privAccounts []*acm.PrivAccount) (*ctyp
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultSignTx)
|
result, ok := response.Result.(*ctypes.ResultSignTx)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -502,6 +556,9 @@ func (c *ClientHTTP) Status() (*ctypes.ResultStatus, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultStatus)
|
result, ok := response.Result.(*ctypes.ResultStatus)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -524,6 +581,9 @@ func (c *ClientJSON) BlockchainInfo(minHeight int, maxHeight int) (*ctypes.Resul
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultBlockchainInfo)
|
result, ok := response.Result.(*ctypes.ResultBlockchainInfo)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -546,6 +606,9 @@ func (c *ClientJSON) BroadcastTx(tx types.Tx) (*ctypes.ResultBroadcastTx, error)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultBroadcastTx)
|
result, ok := response.Result.(*ctypes.ResultBroadcastTx)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -568,6 +631,9 @@ func (c *ClientJSON) Call(fromAddress []byte, toAddress []byte, data []byte) (*c
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultCall)
|
result, ok := response.Result.(*ctypes.ResultCall)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -590,6 +656,9 @@ func (c *ClientJSON) CallCode(fromAddress []byte, code []byte, data []byte) (*ct
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultCall)
|
result, ok := response.Result.(*ctypes.ResultCall)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -612,6 +681,9 @@ func (c *ClientJSON) DumpConsensusState() (*ctypes.ResultDumpConsensusState, err
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultDumpConsensusState)
|
result, ok := response.Result.(*ctypes.ResultDumpConsensusState)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -634,6 +706,9 @@ func (c *ClientJSON) DumpStorage(address []byte) (*ctypes.ResultDumpStorage, err
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultDumpStorage)
|
result, ok := response.Result.(*ctypes.ResultDumpStorage)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -656,6 +731,9 @@ func (c *ClientJSON) GenPrivAccount() (*ctypes.ResultGenPrivAccount, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultGenPrivAccount)
|
result, ok := response.Result.(*ctypes.ResultGenPrivAccount)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -678,6 +756,9 @@ func (c *ClientJSON) Genesis() (*ctypes.ResultGenesis, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultGenesis)
|
result, ok := response.Result.(*ctypes.ResultGenesis)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -700,6 +781,9 @@ func (c *ClientJSON) GetAccount(address []byte) (*ctypes.ResultGetAccount, error
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultGetAccount)
|
result, ok := response.Result.(*ctypes.ResultGetAccount)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -722,6 +806,9 @@ func (c *ClientJSON) GetBlock(height int) (*ctypes.ResultGetBlock, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultGetBlock)
|
result, ok := response.Result.(*ctypes.ResultGetBlock)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -744,6 +831,9 @@ func (c *ClientJSON) GetName(name string) (*ctypes.ResultGetName, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultGetName)
|
result, ok := response.Result.(*ctypes.ResultGetName)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -766,6 +856,9 @@ func (c *ClientJSON) GetStorage(address []byte, key []byte) (*ctypes.ResultGetSt
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultGetStorage)
|
result, ok := response.Result.(*ctypes.ResultGetStorage)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -788,6 +881,9 @@ func (c *ClientJSON) ListAccounts() (*ctypes.ResultListAccounts, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultListAccounts)
|
result, ok := response.Result.(*ctypes.ResultListAccounts)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -810,6 +906,9 @@ func (c *ClientJSON) ListNames() (*ctypes.ResultListNames, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultListNames)
|
result, ok := response.Result.(*ctypes.ResultListNames)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -832,6 +931,9 @@ func (c *ClientJSON) ListUnconfirmedTxs() (*ctypes.ResultListUnconfirmedTxs, err
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultListUnconfirmedTxs)
|
result, ok := response.Result.(*ctypes.ResultListUnconfirmedTxs)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -854,6 +956,9 @@ func (c *ClientJSON) ListValidators() (*ctypes.ResultListValidators, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultListValidators)
|
result, ok := response.Result.(*ctypes.ResultListValidators)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -876,6 +981,9 @@ func (c *ClientJSON) NetInfo() (*ctypes.ResultNetInfo, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultNetInfo)
|
result, ok := response.Result.(*ctypes.ResultNetInfo)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -898,6 +1006,9 @@ func (c *ClientJSON) SignTx(tx types.Tx, privAccounts []*acm.PrivAccount) (*ctyp
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultSignTx)
|
result, ok := response.Result.(*ctypes.ResultSignTx)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
@ -920,6 +1031,9 @@ func (c *ClientJSON) Status() (*ctypes.ResultStatus, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if response.Result == nil {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
result, ok := response.Result.(*ctypes.ResultStatus)
|
result, ok := response.Result.(*ctypes.ResultStatus)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("response result was wrong type")
|
return nil, fmt.Errorf("response result was wrong type")
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package core_client
|
package core_client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -10,6 +9,7 @@ import (
|
|||||||
_ "github.com/tendermint/tendermint/config/tendermint_test"
|
_ "github.com/tendermint/tendermint/config/tendermint_test"
|
||||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||||
"github.com/tendermint/tendermint/rpc/types"
|
"github.com/tendermint/tendermint/rpc/types"
|
||||||
|
"github.com/tendermint/tendermint/wire"
|
||||||
)
|
)
|
||||||
|
|
||||||
const wsEventsChannelCapacity = 10
|
const wsEventsChannelCapacity = 10
|
||||||
@ -70,13 +70,14 @@ func (wsc *WSClient) receiveEventsRoutine() {
|
|||||||
break
|
break
|
||||||
} else {
|
} else {
|
||||||
var response ctypes.Response
|
var response ctypes.Response
|
||||||
if err := json.Unmarshal(data, &response); err != nil {
|
wire.ReadJSON(&response, data, &err)
|
||||||
|
if err != nil {
|
||||||
log.Info(Fmt("WSClient failed to parse message: %v", err))
|
log.Info(Fmt("WSClient failed to parse message: %v", err))
|
||||||
wsc.Stop()
|
wsc.Stop()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if strings.HasSuffix(response.Id, "#event") {
|
if strings.HasSuffix(response.Id, "#event") {
|
||||||
wsc.EventsCh <- response.Result.(ctypes.ResultEvent)
|
wsc.EventsCh <- *response.Result.(*ctypes.ResultEvent)
|
||||||
} else {
|
} else {
|
||||||
wsc.ResultsCh <- response.Result
|
wsc.ResultsCh <- response.Result
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ var (
|
|||||||
func makeUsers(n int) []*acm.PrivAccount {
|
func makeUsers(n int) []*acm.PrivAccount {
|
||||||
accounts := []*acm.PrivAccount{}
|
accounts := []*acm.PrivAccount{}
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
secret := []byte("mysecret" + strconv.Itoa(i))
|
secret := ("mysecret" + strconv.Itoa(i))
|
||||||
user := acm.GenPrivAccountFromSecret(secret)
|
user := acm.GenPrivAccountFromSecret(secret)
|
||||||
accounts = append(accounts, user)
|
accounts = append(accounts, user)
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ var chainID = "testchain"
|
|||||||
func makeUsers(n int) []*acm.PrivAccount {
|
func makeUsers(n int) []*acm.PrivAccount {
|
||||||
accounts := []*acm.PrivAccount{}
|
accounts := []*acm.PrivAccount{}
|
||||||
for i := 0; i < n; i++ {
|
for i := 0; i < n; i++ {
|
||||||
secret := []byte("mysecret" + strconv.Itoa(i))
|
secret := ("mysecret" + strconv.Itoa(i))
|
||||||
user := acm.GenPrivAccountFromSecret(secret)
|
user := acm.GenPrivAccountFromSecret(secret)
|
||||||
accounts = append(accounts, user)
|
accounts = append(accounts, user)
|
||||||
}
|
}
|
||||||
|
@ -92,9 +92,7 @@ func TestNameTxSignable(t *testing.T) {
|
|||||||
|
|
||||||
func TestBondTxSignable(t *testing.T) {
|
func TestBondTxSignable(t *testing.T) {
|
||||||
privKeyBytes := make([]byte, 64)
|
privKeyBytes := make([]byte, 64)
|
||||||
var privKeyArray [64]byte
|
privAccount := acm.GenPrivAccountFromPrivKeyBytes(privKeyBytes)
|
||||||
copy(privKeyArray[:], privKeyBytes)
|
|
||||||
privAccount := acm.GenPrivAccountFromPrivKeyBytes(&privKeyArray)
|
|
||||||
bondTx := &BondTx{
|
bondTx := &BondTx{
|
||||||
PubKey: privAccount.PubKey.(acm.PubKeyEd25519),
|
PubKey: privAccount.PubKey.(acm.PubKeyEd25519),
|
||||||
Inputs: []*TxInput{
|
Inputs: []*TxInput{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user