commit
7457802806
|
@ -5,7 +5,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
abci "github.com/tendermint/abci/types"
|
abci "github.com/tendermint/abci/types"
|
||||||
. "github.com/tendermint/go-common"
|
. "github.com/tendermint/tmlibs/common"
|
||||||
"github.com/tendermint/go-wire"
|
"github.com/tendermint/go-wire"
|
||||||
eyes "github.com/tendermint/merkleeyes/client"
|
eyes "github.com/tendermint/merkleeyes/client"
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/tendermint/basecoin/types"
|
"github.com/tendermint/basecoin/types"
|
||||||
cmn "github.com/tendermint/go-common"
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
//tmtypes "github.com/tendermint/tendermint/types"
|
//tmtypes "github.com/tendermint/tendermint/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ func loadGenesis(filePath string) (*FullGenesisDoc, error) {
|
||||||
// tmGenesis := new(tmtypes.GenesisDoc)
|
// tmGenesis := new(tmtypes.GenesisDoc)
|
||||||
// err = wire.ReadJSONBytes(bytes, tmGenesis)
|
// err = wire.ReadJSONBytes(bytes, tmGenesis)
|
||||||
|
|
||||||
// the basecoin genesis go-data :)
|
// the basecoin genesis go-wire/data :)
|
||||||
genDoc := new(FullGenesisDoc)
|
genDoc := new(FullGenesisDoc)
|
||||||
err = json.Unmarshal(bytes, genDoc)
|
err = json.Unmarshal(bytes, genDoc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
cmn "github.com/tendermint/go-common"
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
"github.com/tendermint/go-crypto"
|
"github.com/tendermint/go-crypto"
|
||||||
eyescli "github.com/tendermint/merkleeyes/client"
|
eyescli "github.com/tendermint/merkleeyes/client"
|
||||||
)
|
)
|
||||||
|
@ -38,7 +38,7 @@ func TestLoadGenesis(t *testing.T) {
|
||||||
assert.EqualValues("blank", acct.Balance[0].Denom)
|
assert.EqualValues("blank", acct.Balance[0].Denom)
|
||||||
|
|
||||||
// and public key is parsed properly
|
// and public key is parsed properly
|
||||||
apk := acct.PubKey.PubKey
|
apk := acct.PubKey.Unwrap()
|
||||||
require.NotNil(apk)
|
require.NotNil(apk)
|
||||||
epk, ok := apk.(crypto.PubKeyEd25519)
|
epk, ok := apk.(crypto.PubKeyEd25519)
|
||||||
if assert.True(ok) {
|
if assert.True(ok) {
|
||||||
|
@ -52,7 +52,7 @@ func TestParseGenesisList(t *testing.T) {
|
||||||
bytes, err := cmn.ReadFile(genesisFilepath)
|
bytes, err := cmn.ReadFile(genesisFilepath)
|
||||||
require.Nil(err, "loading genesis file %+v", err)
|
require.Nil(err, "loading genesis file %+v", err)
|
||||||
|
|
||||||
// the basecoin genesis go-data :)
|
// the basecoin genesis go-wire/data :)
|
||||||
genDoc := new(FullGenesisDoc)
|
genDoc := new(FullGenesisDoc)
|
||||||
err = json.Unmarshal(bytes, genDoc)
|
err = json.Unmarshal(bytes, genDoc)
|
||||||
require.Nil(err, "unmarshaling genesis file %+v", err)
|
require.Nil(err, "unmarshaling genesis file %+v", err)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/tendermint/go-logger"
|
"github.com/tendermint/tmlibs/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
var log = logger.New("module", "app")
|
var log = logger.New("module", "app")
|
||||||
|
|
|
@ -10,8 +10,8 @@ import (
|
||||||
|
|
||||||
"github.com/tendermint/basecoin/plugins/ibc"
|
"github.com/tendermint/basecoin/plugins/ibc"
|
||||||
|
|
||||||
"github.com/tendermint/go-merkle"
|
|
||||||
"github.com/tendermint/go-wire"
|
"github.com/tendermint/go-wire"
|
||||||
|
"github.com/tendermint/merkleeyes/iavl"
|
||||||
tmtypes "github.com/tendermint/tendermint/types"
|
tmtypes "github.com/tendermint/tendermint/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -229,7 +229,7 @@ func ibcPacketPostTxCmd(cmd *cobra.Command, args []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
var packet ibc.Packet
|
var packet ibc.Packet
|
||||||
proof := new(merkle.IAVLProof)
|
proof := new(iavl.IAVLProof)
|
||||||
|
|
||||||
err = wire.ReadBinaryBytes(packetBytes, &packet)
|
err = wire.ReadBinaryBytes(packetBytes, &packet)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
cmn "github.com/tendermint/go-common"
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
//commands
|
//commands
|
||||||
|
|
|
@ -63,8 +63,8 @@ func (a *Address) UnmarshalJSON(addrHex []byte) error {
|
||||||
|
|
||||||
type Key struct {
|
type Key struct {
|
||||||
Address Address `json:"address"`
|
Address Address `json:"address"`
|
||||||
PubKey crypto.PubKeyS `json:"pub_key"`
|
PubKey crypto.PubKey `json:"pub_key"`
|
||||||
PrivKey crypto.PrivKeyS `json:"priv_key"`
|
PrivKey crypto.PrivKey `json:"priv_key"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements Signer
|
// Implements Signer
|
||||||
|
@ -75,13 +75,14 @@ func (k *Key) Sign(msg []byte) crypto.Signature {
|
||||||
// Generates a new validator with private key.
|
// Generates a new validator with private key.
|
||||||
func genKey() *Key {
|
func genKey() *Key {
|
||||||
privKey := crypto.GenPrivKeyEd25519()
|
privKey := crypto.GenPrivKeyEd25519()
|
||||||
addrBytes := privKey.PubKey().Address()
|
pubKey := privKey.PubKey()
|
||||||
|
addrBytes := pubKey.Address()
|
||||||
var addr Address
|
var addr Address
|
||||||
copy(addr[:], addrBytes)
|
copy(addr[:], addrBytes)
|
||||||
return &Key{
|
return &Key{
|
||||||
Address: addr,
|
Address: addr,
|
||||||
PubKey: crypto.PubKeyS{privKey.PubKey()},
|
PubKey: pubKey,
|
||||||
PrivKey: crypto.PrivKeyS{privKey},
|
PrivKey: privKey.Wrap(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package commands
|
package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/tendermint/go-logger"
|
"github.com/tendermint/tmlibs/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
var log = logger.New("module", "commands")
|
var log = logger.New("module", "commands")
|
||||||
|
|
|
@ -8,8 +8,8 @@ import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/tendermint/go-merkle"
|
|
||||||
"github.com/tendermint/go-wire"
|
"github.com/tendermint/go-wire"
|
||||||
|
"github.com/tendermint/merkleeyes/iavl"
|
||||||
tmtypes "github.com/tendermint/tendermint/types"
|
tmtypes "github.com/tendermint/tendermint/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ func verifyCmd(cmd *cobra.Command, args []string) error {
|
||||||
return errors.Errorf("Proof (%v) is invalid hex: %v\n", proofFlag, err)
|
return errors.Errorf("Proof (%v) is invalid hex: %v\n", proofFlag, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
proof, err := merkle.ReadProof(proofBytes)
|
proof, err := iavl.ReadProof(proofBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Errorf("Error unmarshalling proof: %v\n", err)
|
return errors.Errorf("Error unmarshalling proof: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/tendermint/abci/server"
|
"github.com/tendermint/abci/server"
|
||||||
cmn "github.com/tendermint/go-common"
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
eyes "github.com/tendermint/merkleeyes/client"
|
eyes "github.com/tendermint/merkleeyes/client"
|
||||||
|
|
||||||
tmcfg "github.com/tendermint/tendermint/config/tendermint"
|
tmcfg "github.com/tendermint/tendermint/config/tendermint"
|
||||||
|
|
|
@ -8,9 +8,8 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/tendermint/basecoin/types"
|
"github.com/tendermint/basecoin/types"
|
||||||
crypto "github.com/tendermint/go-crypto"
|
|
||||||
|
|
||||||
client "github.com/tendermint/go-rpc/client"
|
client "github.com/tendermint/tendermint/rpc/lib/client"
|
||||||
wire "github.com/tendermint/go-wire"
|
wire "github.com/tendermint/go-wire"
|
||||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||||
)
|
)
|
||||||
|
@ -123,7 +122,7 @@ func sendTxCmd(cmd *cobra.Command, args []string) error {
|
||||||
|
|
||||||
// sign that puppy
|
// sign that puppy
|
||||||
signBytes := tx.SignBytes(chainIDFlag)
|
signBytes := tx.SignBytes(chainIDFlag)
|
||||||
tx.Inputs[0].Signature = crypto.SignatureS{privKey.Sign(signBytes)}
|
tx.Inputs[0].Signature = privKey.Sign(signBytes)
|
||||||
|
|
||||||
fmt.Println("Signed SendTx:")
|
fmt.Println("Signed SendTx:")
|
||||||
fmt.Println(string(wire.JSONBytes(tx)))
|
fmt.Println(string(wire.JSONBytes(tx)))
|
||||||
|
@ -179,7 +178,7 @@ func AppTx(name string, data []byte) error {
|
||||||
Data: data,
|
Data: data,
|
||||||
}
|
}
|
||||||
|
|
||||||
tx.Input.Signature = crypto.SignatureS{privKey.Sign(tx.SignBytes(chainIDFlag))}
|
tx.Input.Signature = privKey.Sign(tx.SignBytes(chainIDFlag))
|
||||||
|
|
||||||
fmt.Println("Signed AppTx:")
|
fmt.Println("Signed AppTx:")
|
||||||
fmt.Println(string(wire.JSONBytes(tx)))
|
fmt.Println(string(wire.JSONBytes(tx)))
|
||||||
|
|
|
@ -14,8 +14,8 @@ import (
|
||||||
"github.com/tendermint/basecoin/types"
|
"github.com/tendermint/basecoin/types"
|
||||||
|
|
||||||
abci "github.com/tendermint/abci/types"
|
abci "github.com/tendermint/abci/types"
|
||||||
cmn "github.com/tendermint/go-common"
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
client "github.com/tendermint/go-rpc/client"
|
client "github.com/tendermint/tendermint/rpc/lib/client"
|
||||||
wire "github.com/tendermint/go-wire"
|
wire "github.com/tendermint/go-wire"
|
||||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||||
tmtypes "github.com/tendermint/tendermint/types"
|
tmtypes "github.com/tendermint/tendermint/types"
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
hash: c6e5febc35b5fd1003066820defb8a089db048b407239dad9faf44553fdc15e8
|
hash: ab7d4136802bfb9c56c25d6c384ce65891adfda2f2fc338fb4532ecc8e85ad40
|
||||||
updated: 2017-04-21T12:55:42.7004558-04:00
|
updated: 2017-04-27T12:49:42.595893036-04:00
|
||||||
imports:
|
imports:
|
||||||
- name: github.com/btcsuite/btcd
|
- name: github.com/btcsuite/btcd
|
||||||
version: 4b348c1d33373d672edd83fc576892d0e46686d2
|
version: 4b348c1d33373d672edd83fc576892d0e46686d2
|
||||||
subpackages:
|
subpackages:
|
||||||
- btcec
|
- btcec
|
||||||
- name: github.com/BurntSushi/toml
|
|
||||||
version: b26d9c308763d68093482582cea63d69be07a0f0
|
|
||||||
- name: github.com/ebuchman/fail-test
|
- name: github.com/ebuchman/fail-test
|
||||||
version: 95f809107225be108efcf10a3509e4ea6ceef3c4
|
version: 95f809107225be108efcf10a3509e4ea6ceef3c4
|
||||||
|
- name: github.com/fsnotify/fsnotify
|
||||||
|
version: 4da3e2cfbabc9f751898f250b49f2439785783a1
|
||||||
- name: github.com/go-stack/stack
|
- name: github.com/go-stack/stack
|
||||||
version: 100eb0c0a9c5b306ca2fb4f165df21d80ada4b82
|
version: 100eb0c0a9c5b306ca2fb4f165df21d80ada4b82
|
||||||
- name: github.com/golang/protobuf
|
- name: github.com/golang/protobuf
|
||||||
|
@ -20,20 +20,49 @@ imports:
|
||||||
version: 553a641470496b2327abcac10b36396bd98e45c9
|
version: 553a641470496b2327abcac10b36396bd98e45c9
|
||||||
- name: github.com/gorilla/websocket
|
- name: github.com/gorilla/websocket
|
||||||
version: 3ab3a8b8831546bd18fd182c20687ca853b2bb13
|
version: 3ab3a8b8831546bd18fd182c20687ca853b2bb13
|
||||||
|
- name: github.com/hashicorp/hcl
|
||||||
|
version: 630949a3c5fa3c613328e1b8256052cbc2327c9b
|
||||||
|
subpackages:
|
||||||
|
- hcl/ast
|
||||||
|
- hcl/parser
|
||||||
|
- hcl/scanner
|
||||||
|
- hcl/strconv
|
||||||
|
- hcl/token
|
||||||
|
- json/parser
|
||||||
|
- json/scanner
|
||||||
|
- json/token
|
||||||
- name: github.com/inconshreveable/mousetrap
|
- name: github.com/inconshreveable/mousetrap
|
||||||
version: 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75
|
version: 76626ae9c91c4f2a10f34cad8ce83ea42c93bb75
|
||||||
- name: github.com/jmhodges/levigo
|
- name: github.com/jmhodges/levigo
|
||||||
version: c42d9e0ca023e2198120196f842701bb4c55d7b9
|
version: c42d9e0ca023e2198120196f842701bb4c55d7b9
|
||||||
|
- name: github.com/magiconair/properties
|
||||||
|
version: 51463bfca2576e06c62a8504b5c0f06d61312647
|
||||||
- name: github.com/mattn/go-colorable
|
- name: github.com/mattn/go-colorable
|
||||||
version: ded68f7a9561c023e790de24279db7ebf473ea80
|
version: ded68f7a9561c023e790de24279db7ebf473ea80
|
||||||
- name: github.com/mattn/go-isatty
|
- name: github.com/mattn/go-isatty
|
||||||
version: fc9e8d8ef48496124e79ae0df75490096eccf6fe
|
version: fc9e8d8ef48496124e79ae0df75490096eccf6fe
|
||||||
|
- name: github.com/mitchellh/mapstructure
|
||||||
|
version: 53818660ed4955e899c0bcafa97299a388bd7c8e
|
||||||
|
- name: github.com/pelletier/go-buffruneio
|
||||||
|
version: c37440a7cf42ac63b919c752ca73a85067e05992
|
||||||
|
- name: github.com/pelletier/go-toml
|
||||||
|
version: 13d49d4606eb801b8f01ae542b4afc4c6ee3d84a
|
||||||
- name: github.com/pkg/errors
|
- name: github.com/pkg/errors
|
||||||
version: ff09b135c25aae272398c51a07235b90a75aa4f0
|
version: ff09b135c25aae272398c51a07235b90a75aa4f0
|
||||||
|
- name: github.com/spf13/afero
|
||||||
|
version: 9be650865eab0c12963d8753212f4f9c66cdcf12
|
||||||
|
subpackages:
|
||||||
|
- mem
|
||||||
|
- name: github.com/spf13/cast
|
||||||
|
version: acbeb36b902d72a7a4c18e8f3241075e7ab763e4
|
||||||
- name: github.com/spf13/cobra
|
- name: github.com/spf13/cobra
|
||||||
version: 10f6b9d7e1631a54ad07c5c0fb71c28a1abfd3c2
|
version: 10f6b9d7e1631a54ad07c5c0fb71c28a1abfd3c2
|
||||||
|
- name: github.com/spf13/jwalterweatherman
|
||||||
|
version: fa7ca7e836cf3a8bb4ebf799f472c12d7e903d66
|
||||||
- name: github.com/spf13/pflag
|
- name: github.com/spf13/pflag
|
||||||
version: 2300d0f8576fe575f71aaa5b9bbe4e1b0dc2eb51
|
version: 2300d0f8576fe575f71aaa5b9bbe4e1b0dc2eb51
|
||||||
|
- name: github.com/spf13/viper
|
||||||
|
version: 5d46e70da8c0b6f812e0b170b7a985753b5c63cb
|
||||||
- name: github.com/syndtr/goleveldb
|
- name: github.com/syndtr/goleveldb
|
||||||
version: 8c81ea47d4c41a385645e133e15510fc6a2a74b4
|
version: 8c81ea47d4c41a385645e133e15510fc6a2a74b4
|
||||||
subpackages:
|
subpackages:
|
||||||
|
@ -50,7 +79,7 @@ imports:
|
||||||
- leveldb/table
|
- leveldb/table
|
||||||
- leveldb/util
|
- leveldb/util
|
||||||
- name: github.com/tendermint/abci
|
- name: github.com/tendermint/abci
|
||||||
version: 56e13d87f4e3ec1ea756957d6b23caa6ebcf0998
|
version: c709d3cc857929a8dd36a90da3640122d7e75770
|
||||||
subpackages:
|
subpackages:
|
||||||
- client
|
- client
|
||||||
- example/dummy
|
- example/dummy
|
||||||
|
@ -61,53 +90,24 @@ imports:
|
||||||
subpackages:
|
subpackages:
|
||||||
- edwards25519
|
- edwards25519
|
||||||
- extra25519
|
- extra25519
|
||||||
- name: github.com/tendermint/go-autofile
|
|
||||||
version: 48b17de82914e1ec2f134ce823ba426337d2c518
|
|
||||||
- name: github.com/tendermint/go-clist
|
|
||||||
version: 3baa390bbaf7634251c42ad69a8682e7e3990552
|
|
||||||
- name: github.com/tendermint/go-common
|
|
||||||
version: f9e3db037330c8a8d61d3966de8473eaf01154fa
|
|
||||||
- name: github.com/tendermint/go-config
|
|
||||||
version: 620dcbbd7d587cf3599dedbf329b64311b0c307a
|
|
||||||
- name: github.com/tendermint/go-crypto
|
- name: github.com/tendermint/go-crypto
|
||||||
version: 0ca2c6fdb0706001ca4c4b9b80c9f428e8cf39da
|
version: 9b95da8fa4187f6799558d89b271dc8ab6485615
|
||||||
- name: github.com/tendermint/go-data
|
|
||||||
version: e7fcc6d081ec8518912fcdc103188275f83a3ee5
|
|
||||||
- name: github.com/tendermint/go-db
|
|
||||||
version: 9643f60bc2578693844aacf380a7c32e4c029fee
|
|
||||||
- name: github.com/tendermint/go-events
|
|
||||||
version: f8ffbfb2be3483e9e7927495590a727f51c0c11f
|
|
||||||
- name: github.com/tendermint/go-flowrate
|
|
||||||
version: a20c98e61957faa93b4014fbd902f20ab9317a6a
|
|
||||||
subpackages:
|
|
||||||
- flowrate
|
|
||||||
- name: github.com/tendermint/go-logger
|
|
||||||
version: cefb3a45c0bf3c493a04e9bcd9b1540528be59f2
|
|
||||||
- name: github.com/tendermint/go-merkle
|
|
||||||
version: 714d4d04557fd068a7c2a1748241ce8428015a96
|
|
||||||
- name: github.com/tendermint/go-p2p
|
|
||||||
version: 17124989a93774833df33107fbf17157a7f8ef31
|
|
||||||
subpackages:
|
|
||||||
- upnp
|
|
||||||
- name: github.com/tendermint/go-rpc
|
|
||||||
version: 559613689d56eaa423b19a3a4158546beb4857de
|
|
||||||
subpackages:
|
|
||||||
- client
|
|
||||||
- server
|
|
||||||
- types
|
|
||||||
- name: github.com/tendermint/go-wire
|
- name: github.com/tendermint/go-wire
|
||||||
version: c1c9a57ab8038448ddea1714c0698f8051e5748c
|
version: 334005c236d19c632fb5f073f9de3b0fab6a522b
|
||||||
|
subpackages:
|
||||||
|
- data
|
||||||
- name: github.com/tendermint/log15
|
- name: github.com/tendermint/log15
|
||||||
version: ae0f3d6450da9eac7074b439c8e1c3cabf0d5ce6
|
version: ae0f3d6450da9eac7074b439c8e1c3cabf0d5ce6
|
||||||
subpackages:
|
subpackages:
|
||||||
- term
|
- term
|
||||||
- name: github.com/tendermint/merkleeyes
|
- name: github.com/tendermint/merkleeyes
|
||||||
version: 9fb76efa5aebe773a598f97e68e75fe53d520e70
|
version: 6fd69aa0871a4e685a5570aa7ab3d12e4068a722
|
||||||
subpackages:
|
subpackages:
|
||||||
- app
|
- app
|
||||||
- client
|
- client
|
||||||
|
- iavl
|
||||||
- name: github.com/tendermint/tendermint
|
- name: github.com/tendermint/tendermint
|
||||||
version: 6bcd4242f1f336e2b2ef4f644fabaf56222b34d0
|
version: 1310c7264750efa8939680536098ded9f9e8df74
|
||||||
subpackages:
|
subpackages:
|
||||||
- blockchain
|
- blockchain
|
||||||
- cmd/tendermint/commands
|
- cmd/tendermint/commands
|
||||||
|
@ -115,16 +115,33 @@ imports:
|
||||||
- consensus
|
- consensus
|
||||||
- mempool
|
- mempool
|
||||||
- node
|
- node
|
||||||
|
- p2p
|
||||||
|
- p2p/upnp
|
||||||
- proxy
|
- proxy
|
||||||
- rpc/core
|
- rpc/core
|
||||||
- rpc/core/types
|
- rpc/core/types
|
||||||
- rpc/grpc
|
- rpc/grpc
|
||||||
|
- rpc/lib
|
||||||
|
- rpc/lib/client
|
||||||
|
- rpc/lib/server
|
||||||
|
- rpc/lib/types
|
||||||
- state
|
- state
|
||||||
- state/txindex
|
- state/txindex
|
||||||
- state/txindex/kv
|
- state/txindex/kv
|
||||||
- state/txindex/null
|
- state/txindex/null
|
||||||
- types
|
- types
|
||||||
- version
|
- version
|
||||||
|
- name: github.com/tendermint/tmlibs
|
||||||
|
version: df250b69416a35a943a6e2a92118667e9ef031d4
|
||||||
|
subpackages:
|
||||||
|
- autofile
|
||||||
|
- clist
|
||||||
|
- common
|
||||||
|
- db
|
||||||
|
- events
|
||||||
|
- flowrate
|
||||||
|
- logger
|
||||||
|
- merkle
|
||||||
- name: golang.org/x/crypto
|
- name: golang.org/x/crypto
|
||||||
version: 96846453c37f0876340a66a47f3f75b1f3a6cd2d
|
version: 96846453c37f0876340a66a47f3f75b1f3a6cd2d
|
||||||
subpackages:
|
subpackages:
|
||||||
|
@ -176,6 +193,8 @@ imports:
|
||||||
- status
|
- status
|
||||||
- tap
|
- tap
|
||||||
- transport
|
- transport
|
||||||
|
- name: gopkg.in/yaml.v2
|
||||||
|
version: cd8b52f8269e0feb286dfeef29f8fe4d5b397e0b
|
||||||
testImports:
|
testImports:
|
||||||
- name: github.com/davecgh/go-spew
|
- name: github.com/davecgh/go-spew
|
||||||
version: 6d212800a42e8ab5c146b8ace3490ee17e5225f9
|
version: 6d212800a42e8ab5c146b8ace3490ee17e5225f9
|
||||||
|
|
44
glide.yaml
44
glide.yaml
|
@ -1,24 +1,44 @@
|
||||||
package: github.com/tendermint/basecoin
|
package: github.com/tendermint/basecoin
|
||||||
import:
|
import:
|
||||||
- package: github.com/tendermint/go-common
|
- package: github.com/gorilla/websocket
|
||||||
|
- package: github.com/pkg/errors
|
||||||
|
- package: github.com/spf13/cobra
|
||||||
|
- package: github.com/spf13/pflag
|
||||||
|
- package: github.com/tendermint/abci
|
||||||
version: develop
|
version: develop
|
||||||
|
subpackages:
|
||||||
|
- server
|
||||||
|
- types
|
||||||
- package: github.com/tendermint/go-crypto
|
- package: github.com/tendermint/go-crypto
|
||||||
version: develop
|
version: develop
|
||||||
- package: github.com/tendermint/go-events
|
|
||||||
version: develop
|
|
||||||
- package: github.com/tendermint/go-logger
|
|
||||||
version: develop
|
|
||||||
- package: github.com/tendermint/go-data
|
|
||||||
version: develop
|
|
||||||
- package: github.com/tendermint/go-rpc
|
|
||||||
version: develop
|
|
||||||
- package: github.com/tendermint/go-wire
|
- package: github.com/tendermint/go-wire
|
||||||
version: develop
|
version: develop
|
||||||
|
subpackages:
|
||||||
|
- data
|
||||||
- package: github.com/tendermint/merkleeyes
|
- package: github.com/tendermint/merkleeyes
|
||||||
version: develop
|
version: develop
|
||||||
|
subpackages:
|
||||||
|
- client
|
||||||
|
- iavl
|
||||||
- package: github.com/tendermint/tendermint
|
- package: github.com/tendermint/tendermint
|
||||||
version: develop
|
version: develop
|
||||||
- package: github.com/tendermint/abci
|
subpackages:
|
||||||
|
- cmd/tendermint/commands
|
||||||
|
- config/tendermint
|
||||||
|
- node
|
||||||
|
- proxy
|
||||||
|
- rpc/core/types
|
||||||
|
- rpc/lib/client
|
||||||
|
- rpc/lib/types
|
||||||
|
- types
|
||||||
|
- package: github.com/tendermint/tmlibs
|
||||||
version: develop
|
version: develop
|
||||||
- package: github.com/gorilla/websocket
|
subpackages:
|
||||||
version: v1.1.0
|
- common
|
||||||
|
- events
|
||||||
|
- logger
|
||||||
|
testImport:
|
||||||
|
- package: github.com/stretchr/testify
|
||||||
|
subpackages:
|
||||||
|
- assert
|
||||||
|
- require
|
||||||
|
|
|
@ -9,7 +9,6 @@ import (
|
||||||
abci "github.com/tendermint/abci/types"
|
abci "github.com/tendermint/abci/types"
|
||||||
"github.com/tendermint/basecoin/app"
|
"github.com/tendermint/basecoin/app"
|
||||||
"github.com/tendermint/basecoin/types"
|
"github.com/tendermint/basecoin/types"
|
||||||
crypto "github.com/tendermint/go-crypto"
|
|
||||||
"github.com/tendermint/go-wire"
|
"github.com/tendermint/go-wire"
|
||||||
eyescli "github.com/tendermint/merkleeyes/client"
|
eyescli "github.com/tendermint/merkleeyes/client"
|
||||||
)
|
)
|
||||||
|
@ -52,8 +51,7 @@ func TestCounterPlugin(t *testing.T) {
|
||||||
// Sign request
|
// Sign request
|
||||||
signBytes := tx.SignBytes(chainID)
|
signBytes := tx.SignBytes(chainID)
|
||||||
// t.Logf("Sign bytes: %X\n", signBytes)
|
// t.Logf("Sign bytes: %X\n", signBytes)
|
||||||
sig := test1PrivAcc.Sign(signBytes)
|
tx.Input.Signature = test1PrivAcc.Sign(signBytes)
|
||||||
tx.Input.Signature = crypto.SignatureS{sig}
|
|
||||||
// t.Logf("Signed TX bytes: %X\n", wire.BinaryBytes(struct{ types.Tx }{tx}))
|
// t.Logf("Signed TX bytes: %X\n", wire.BinaryBytes(struct{ types.Tx }{tx}))
|
||||||
|
|
||||||
// Write request
|
// Write request
|
||||||
|
|
|
@ -8,8 +8,8 @@ import (
|
||||||
|
|
||||||
abci "github.com/tendermint/abci/types"
|
abci "github.com/tendermint/abci/types"
|
||||||
"github.com/tendermint/basecoin/types"
|
"github.com/tendermint/basecoin/types"
|
||||||
cmn "github.com/tendermint/go-common"
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
merkle "github.com/tendermint/go-merkle"
|
merkle "github.com/tendermint/merkleeyes/iavl"
|
||||||
"github.com/tendermint/go-wire"
|
"github.com/tendermint/go-wire"
|
||||||
tm "github.com/tendermint/tendermint/types"
|
tm "github.com/tendermint/tendermint/types"
|
||||||
)
|
)
|
||||||
|
|
|
@ -9,12 +9,12 @@ import (
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
abci "github.com/tendermint/abci/types"
|
abci "github.com/tendermint/abci/types"
|
||||||
"github.com/tendermint/basecoin/types"
|
"github.com/tendermint/basecoin/types"
|
||||||
cmn "github.com/tendermint/go-common"
|
|
||||||
crypto "github.com/tendermint/go-crypto"
|
crypto "github.com/tendermint/go-crypto"
|
||||||
"github.com/tendermint/go-merkle"
|
|
||||||
"github.com/tendermint/go-wire"
|
"github.com/tendermint/go-wire"
|
||||||
eyes "github.com/tendermint/merkleeyes/client"
|
eyes "github.com/tendermint/merkleeyes/client"
|
||||||
|
"github.com/tendermint/merkleeyes/iavl"
|
||||||
tm "github.com/tendermint/tendermint/types"
|
tm "github.com/tendermint/tendermint/types"
|
||||||
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NOTE: PrivAccounts are sorted by Address,
|
// NOTE: PrivAccounts are sorted by Address,
|
||||||
|
@ -30,7 +30,7 @@ func genGenesisDoc(chainID string, numVals int) (*tm.GenesisDoc, []types.PrivAcc
|
||||||
name := cmn.Fmt("%v_val_%v", chainID, i)
|
name := cmn.Fmt("%v_val_%v", chainID, i)
|
||||||
privAcc := types.PrivAccountFromSecret(name)
|
privAcc := types.PrivAccountFromSecret(name)
|
||||||
genDoc.Validators = append(genDoc.Validators, tm.GenesisValidator{
|
genDoc.Validators = append(genDoc.Validators, tm.GenesisValidator{
|
||||||
PubKey: privAcc.PubKey.PubKey,
|
PubKey: privAcc.PubKey,
|
||||||
Amount: 1,
|
Amount: 1,
|
||||||
Name: name,
|
Name: name,
|
||||||
})
|
})
|
||||||
|
@ -192,7 +192,7 @@ func TestIBCPlugin(t *testing.T) {
|
||||||
Prove: true,
|
Prove: true,
|
||||||
})
|
})
|
||||||
assert.Nil(err)
|
assert.Nil(err)
|
||||||
var proof *merkle.IAVLProof
|
var proof *iavl.IAVLProof
|
||||||
err = wire.ReadBinaryBytes(resQuery.Proof, &proof)
|
err = wire.ReadBinaryBytes(resQuery.Proof, &proof)
|
||||||
assert.Nil(err)
|
assert.Nil(err)
|
||||||
|
|
||||||
|
@ -268,9 +268,9 @@ func TestIBCPluginBadCommit(t *testing.T) {
|
||||||
|
|
||||||
// Update a chain with a broken commit
|
// Update a chain with a broken commit
|
||||||
// Modify the first byte of the first signature
|
// Modify the first byte of the first signature
|
||||||
sig := commit.Precommits[0].Signature.(crypto.SignatureEd25519)
|
sig := commit.Precommits[0].Signature.Unwrap().(crypto.SignatureEd25519)
|
||||||
sig[0] += 1
|
sig[0] += 1
|
||||||
commit.Precommits[0].Signature = sig
|
commit.Precommits[0].Signature = sig.Wrap()
|
||||||
res = ibcPlugin.RunTx(store, ctx, wire.BinaryBytes(struct{ IBCTx }{IBCUpdateChainTx{
|
res = ibcPlugin.RunTx(store, ctx, wire.BinaryBytes(struct{ IBCTx }{IBCUpdateChainTx{
|
||||||
Header: header,
|
Header: header,
|
||||||
Commit: commit,
|
Commit: commit,
|
||||||
|
@ -379,7 +379,7 @@ func TestIBCPluginBadProof(t *testing.T) {
|
||||||
Prove: true,
|
Prove: true,
|
||||||
})
|
})
|
||||||
assert.Nil(err)
|
assert.Nil(err)
|
||||||
var proof *merkle.IAVLProof
|
var proof *iavl.IAVLProof
|
||||||
err = wire.ReadBinaryBytes(resQuery.Proof, &proof)
|
err = wire.ReadBinaryBytes(resQuery.Proof, &proof)
|
||||||
assert.Nil(err)
|
assert.Nil(err)
|
||||||
|
|
||||||
|
|
|
@ -9,9 +9,9 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
cmn "github.com/tendermint/go-common"
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
"github.com/tendermint/go-rpc/client"
|
"github.com/tendermint/tendermint/rpc/lib/client"
|
||||||
"github.com/tendermint/go-rpc/types"
|
"github.com/tendermint/tendermint/rpc/lib/types"
|
||||||
"github.com/tendermint/go-wire"
|
"github.com/tendermint/go-wire"
|
||||||
_ "github.com/tendermint/tendermint/rpc/core/types" // Register RPCResponse > Result types
|
_ "github.com/tendermint/tendermint/rpc/core/types" // Register RPCResponse > Result types
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,8 +3,8 @@ package state
|
||||||
import (
|
import (
|
||||||
abci "github.com/tendermint/abci/types"
|
abci "github.com/tendermint/abci/types"
|
||||||
"github.com/tendermint/basecoin/types"
|
"github.com/tendermint/basecoin/types"
|
||||||
cmn "github.com/tendermint/go-common"
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
"github.com/tendermint/go-events"
|
"github.com/tendermint/tmlibs/events"
|
||||||
)
|
)
|
||||||
|
|
||||||
// If the tx is invalid, a TMSP error will be returned.
|
// If the tx is invalid, a TMSP error will be returned.
|
||||||
|
@ -244,7 +244,7 @@ func validateInputAdvanced(acc *types.Account, signBytes []byte, in types.TxInpu
|
||||||
return abci.ErrBaseInsufficientFunds.AppendLog(cmn.Fmt("balance is %v, tried to send %v", balance, in.Coins))
|
return abci.ErrBaseInsufficientFunds.AppendLog(cmn.Fmt("balance is %v, tried to send %v", balance, in.Coins))
|
||||||
}
|
}
|
||||||
// Check signatures
|
// Check signatures
|
||||||
if !acc.PubKey.VerifyBytes(signBytes, in.Signature.Signature) {
|
if !acc.PubKey.VerifyBytes(signBytes, in.Signature) {
|
||||||
return abci.ErrBaseInvalidSignature.AppendLog(cmn.Fmt("SignBytes: %X", signBytes))
|
return abci.ErrBaseInvalidSignature.AppendLog(cmn.Fmt("SignBytes: %X", signBytes))
|
||||||
}
|
}
|
||||||
return abci.OK
|
return abci.OK
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package state
|
package state
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/tendermint/go-logger"
|
"github.com/tendermint/tmlibs/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
var log = logger.New("module", "state")
|
var log = logger.New("module", "state")
|
||||||
|
|
|
@ -3,7 +3,7 @@ package state
|
||||||
import (
|
import (
|
||||||
abci "github.com/tendermint/abci/types"
|
abci "github.com/tendermint/abci/types"
|
||||||
"github.com/tendermint/basecoin/types"
|
"github.com/tendermint/basecoin/types"
|
||||||
. "github.com/tendermint/go-common"
|
. "github.com/tendermint/tmlibs/common"
|
||||||
"github.com/tendermint/go-wire"
|
"github.com/tendermint/go-wire"
|
||||||
eyes "github.com/tendermint/merkleeyes/client"
|
eyes "github.com/tendermint/merkleeyes/client"
|
||||||
)
|
)
|
||||||
|
|
|
@ -6,10 +6,9 @@ import (
|
||||||
|
|
||||||
"github.com/gorilla/websocket"
|
"github.com/gorilla/websocket"
|
||||||
"github.com/tendermint/basecoin/types"
|
"github.com/tendermint/basecoin/types"
|
||||||
cmn "github.com/tendermint/go-common"
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
crypto "github.com/tendermint/go-crypto"
|
"github.com/tendermint/tendermint/rpc/lib/client"
|
||||||
rpcclient "github.com/tendermint/go-rpc/client"
|
"github.com/tendermint/tendermint/rpc/lib/types"
|
||||||
"github.com/tendermint/go-rpc/types"
|
|
||||||
wire "github.com/tendermint/go-wire"
|
wire "github.com/tendermint/go-wire"
|
||||||
_ "github.com/tendermint/tendermint/rpc/core/types" // Register RPCResponse > Result types
|
_ "github.com/tendermint/tendermint/rpc/core/types" // Register RPCResponse > Result types
|
||||||
)
|
)
|
||||||
|
@ -67,7 +66,7 @@ func main() {
|
||||||
// Sign request
|
// Sign request
|
||||||
signBytes := tx.SignBytes(chainID)
|
signBytes := tx.SignBytes(chainID)
|
||||||
sig := root.Sign(signBytes)
|
sig := root.Sign(signBytes)
|
||||||
tx.Inputs[0].Signature = crypto.SignatureS{sig}
|
tx.Inputs[0].Signature = sig
|
||||||
//fmt.Println("tx:", tx)
|
//fmt.Println("tx:", tx)
|
||||||
|
|
||||||
// Write request
|
// Write request
|
||||||
|
@ -118,7 +117,7 @@ func main() {
|
||||||
// Sign request
|
// Sign request
|
||||||
signBytes := tx.SignBytes(chainID)
|
signBytes := tx.SignBytes(chainID)
|
||||||
sig := privAccountA.Sign(signBytes)
|
sig := privAccountA.Sign(signBytes)
|
||||||
tx.Inputs[0].Signature = crypto.SignatureS{sig}
|
tx.Inputs[0].Signature = sig
|
||||||
//fmt.Println("tx:", tx)
|
//fmt.Println("tx:", tx)
|
||||||
|
|
||||||
// Write request
|
// Write request
|
||||||
|
|
|
@ -8,8 +8,7 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/tendermint/basecoin/app"
|
"github.com/tendermint/basecoin/app"
|
||||||
"github.com/tendermint/basecoin/types"
|
"github.com/tendermint/basecoin/types"
|
||||||
cmn "github.com/tendermint/go-common"
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
crypto "github.com/tendermint/go-crypto"
|
|
||||||
"github.com/tendermint/go-wire"
|
"github.com/tendermint/go-wire"
|
||||||
eyescli "github.com/tendermint/merkleeyes/client"
|
eyescli "github.com/tendermint/merkleeyes/client"
|
||||||
)
|
)
|
||||||
|
@ -50,7 +49,7 @@ func TestSendTx(t *testing.T) {
|
||||||
signBytes := tx.SignBytes(chainID)
|
signBytes := tx.SignBytes(chainID)
|
||||||
// t.Log("Sign bytes: %X\n", signBytes)
|
// t.Log("Sign bytes: %X\n", signBytes)
|
||||||
sig := test1PrivAcc.Sign(signBytes)
|
sig := test1PrivAcc.Sign(signBytes)
|
||||||
tx.Inputs[0].Signature = crypto.SignatureS{sig}
|
tx.Inputs[0].Signature = sig
|
||||||
// t.Log("Signed TX bytes: %X\n", wire.BinaryBytes(types.TxS{tx}))
|
// t.Log("Signed TX bytes: %X\n", wire.BinaryBytes(types.TxS{tx}))
|
||||||
|
|
||||||
// Write request
|
// Write request
|
||||||
|
@ -102,7 +101,7 @@ func TestSequence(t *testing.T) {
|
||||||
// Sign request
|
// Sign request
|
||||||
signBytes := tx.SignBytes(chainID)
|
signBytes := tx.SignBytes(chainID)
|
||||||
sig := test1PrivAcc.Sign(signBytes)
|
sig := test1PrivAcc.Sign(signBytes)
|
||||||
tx.Inputs[0].Signature = crypto.SignatureS{sig}
|
tx.Inputs[0].Signature = sig
|
||||||
// t.Log("ADDR: %X -> %X\n", tx.Inputs[0].Address, tx.Outputs[0].Address)
|
// t.Log("ADDR: %X -> %X\n", tx.Inputs[0].Address, tx.Outputs[0].Address)
|
||||||
|
|
||||||
// Write request
|
// Write request
|
||||||
|
@ -146,7 +145,7 @@ func TestSequence(t *testing.T) {
|
||||||
// Sign request
|
// Sign request
|
||||||
signBytes := tx.SignBytes(chainID)
|
signBytes := tx.SignBytes(chainID)
|
||||||
sig := privAccountA.Sign(signBytes)
|
sig := privAccountA.Sign(signBytes)
|
||||||
tx.Inputs[0].Signature = crypto.SignatureS{sig}
|
tx.Inputs[0].Signature = sig
|
||||||
// t.Log("ADDR: %X -> %X\n", tx.Inputs[0].Address, tx.Outputs[0].Address)
|
// t.Log("ADDR: %X -> %X\n", tx.Inputs[0].Address, tx.Outputs[0].Address)
|
||||||
|
|
||||||
// Write request
|
// Write request
|
||||||
|
|
|
@ -7,7 +7,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Account struct {
|
type Account struct {
|
||||||
PubKey crypto.PubKeyS `json:"pub_key"` // May be nil, if not known.
|
PubKey crypto.PubKey `json:"pub_key"` // May be nil, if not known.
|
||||||
Sequence int `json:"sequence"`
|
Sequence int `json:"sequence"`
|
||||||
Balance Coins `json:"coins"`
|
Balance Coins `json:"coins"`
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ func (acc *Account) String() string {
|
||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
|
|
||||||
type PrivAccount struct {
|
type PrivAccount struct {
|
||||||
crypto.PrivKeyS
|
crypto.PrivKey
|
||||||
Account
|
Account
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"container/list"
|
"container/list"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
. "github.com/tendermint/go-common"
|
. "github.com/tendermint/tmlibs/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
type KVStore interface {
|
type KVStore interface {
|
||||||
|
|
|
@ -3,18 +3,19 @@ package types
|
||||||
// Helper functions for testing
|
// Helper functions for testing
|
||||||
|
|
||||||
import (
|
import (
|
||||||
cmn "github.com/tendermint/go-common"
|
|
||||||
"github.com/tendermint/go-crypto"
|
"github.com/tendermint/go-crypto"
|
||||||
|
cmn "github.com/tendermint/tmlibs/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Creates a PrivAccount from secret.
|
// Creates a PrivAccount from secret.
|
||||||
// The amount is not set.
|
// The amount is not set.
|
||||||
func PrivAccountFromSecret(secret string) PrivAccount {
|
func PrivAccountFromSecret(secret string) PrivAccount {
|
||||||
privKey := crypto.GenPrivKeyEd25519FromSecret([]byte(secret))
|
privKey :=
|
||||||
|
crypto.GenPrivKeyEd25519FromSecret([]byte(secret)).Wrap()
|
||||||
privAccount := PrivAccount{
|
privAccount := PrivAccount{
|
||||||
PrivKeyS: crypto.PrivKeyS{privKey},
|
PrivKey: privKey,
|
||||||
Account: Account{
|
Account: Account{
|
||||||
PubKey: crypto.PubKeyS{privKey.PubKey()},
|
PubKey: privKey.PubKey(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return privAccount
|
return privAccount
|
||||||
|
@ -30,10 +31,10 @@ func RandAccounts(num int, minAmount int64, maxAmount int64) []PrivAccount {
|
||||||
balance += cmn.RandInt64() % (maxAmount - minAmount)
|
balance += cmn.RandInt64() % (maxAmount - minAmount)
|
||||||
}
|
}
|
||||||
|
|
||||||
privKey := crypto.GenPrivKeyEd25519()
|
privKey := crypto.GenPrivKeyEd25519().Wrap()
|
||||||
pubKey := crypto.PubKeyS{privKey.PubKey()}
|
pubKey := privKey.PubKey()
|
||||||
privAccs[i] = PrivAccount{
|
privAccs[i] = PrivAccount{
|
||||||
PrivKeyS: crypto.PrivKeyS{privKey},
|
PrivKey: privKey,
|
||||||
Account: Account{
|
Account: Account{
|
||||||
PubKey: pubKey,
|
PubKey: pubKey,
|
||||||
Balance: Coins{Coin{"", balance}},
|
Balance: Coins{Coin{"", balance}},
|
||||||
|
@ -99,6 +100,6 @@ func GetTx(seq int, accOut PrivAccount, accsIn ...PrivAccount) *SendTx {
|
||||||
func SignTx(chainID string, tx *SendTx, accs ...PrivAccount) {
|
func SignTx(chainID string, tx *SendTx, accs ...PrivAccount) {
|
||||||
signBytes := tx.SignBytes(chainID)
|
signBytes := tx.SignBytes(chainID)
|
||||||
for i, _ := range tx.Inputs {
|
for i, _ := range tx.Inputs {
|
||||||
tx.Inputs[i].Signature = crypto.SignatureS{accs[i].Sign(signBytes)}
|
tx.Inputs[i].Signature = accs[i].Sign(signBytes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
40
types/tx.go
40
types/tx.go
|
@ -5,9 +5,9 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
abci "github.com/tendermint/abci/types"
|
abci "github.com/tendermint/abci/types"
|
||||||
. "github.com/tendermint/go-common"
|
. "github.com/tendermint/tmlibs/common"
|
||||||
"github.com/tendermint/go-crypto"
|
"github.com/tendermint/go-crypto"
|
||||||
"github.com/tendermint/go-data"
|
"github.com/tendermint/go-wire/data"
|
||||||
"github.com/tendermint/go-wire"
|
"github.com/tendermint/go-wire"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ func (_ *AppTx) AssertIsTx() {}
|
||||||
|
|
||||||
var txMapper data.Mapper
|
var txMapper data.Mapper
|
||||||
|
|
||||||
// register both private key types with go-data (and thus go-wire)
|
// register both private key types with go-wire/data (and thus go-wire)
|
||||||
func init() {
|
func init() {
|
||||||
txMapper = data.NewMapper(TxS{}).
|
txMapper = data.NewMapper(TxS{}).
|
||||||
RegisterImplementation(&SendTx{}, TxNameSend, TxTypeSend).
|
RegisterImplementation(&SendTx{}, TxNameSend, TxTypeSend).
|
||||||
|
@ -67,8 +67,8 @@ type TxInput struct {
|
||||||
Address data.Bytes `json:"address"` // Hash of the PubKey
|
Address data.Bytes `json:"address"` // Hash of the PubKey
|
||||||
Coins Coins `json:"coins"` //
|
Coins Coins `json:"coins"` //
|
||||||
Sequence int `json:"sequence"` // Must be 1 greater than the last committed TxInput
|
Sequence int `json:"sequence"` // Must be 1 greater than the last committed TxInput
|
||||||
Signature crypto.SignatureS `json:"signature"` // Depends on the PubKey type and the whole Tx
|
Signature crypto.Signature `json:"signature"` // Depends on the PubKey type and the whole Tx
|
||||||
PubKey crypto.PubKeyS `json:"pub_key"` // Is present iff Sequence == 0
|
PubKey crypto.PubKey `json:"pub_key"` // Is present iff Sequence == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (txIn TxInput) ValidateBasic() abci.Result {
|
func (txIn TxInput) ValidateBasic() abci.Result {
|
||||||
|
@ -104,13 +104,7 @@ func NewTxInput(pubKey crypto.PubKey, coins Coins, sequence int) TxInput {
|
||||||
Sequence: sequence,
|
Sequence: sequence,
|
||||||
}
|
}
|
||||||
if sequence == 1 {
|
if sequence == 1 {
|
||||||
// safely wrap if needed
|
input.PubKey = pubKey
|
||||||
// TODO: extract this as utility function?
|
|
||||||
ps, ok := pubKey.(crypto.PubKeyS)
|
|
||||||
if !ok {
|
|
||||||
ps = crypto.PubKeyS{pubKey}
|
|
||||||
}
|
|
||||||
input.PubKey = ps
|
|
||||||
}
|
}
|
||||||
return input
|
return input
|
||||||
}
|
}
|
||||||
|
@ -151,25 +145,21 @@ type SendTx struct {
|
||||||
func (tx *SendTx) SignBytes(chainID string) []byte {
|
func (tx *SendTx) SignBytes(chainID string) []byte {
|
||||||
signBytes := wire.BinaryBytes(chainID)
|
signBytes := wire.BinaryBytes(chainID)
|
||||||
sigz := make([]crypto.Signature, len(tx.Inputs))
|
sigz := make([]crypto.Signature, len(tx.Inputs))
|
||||||
for i, input := range tx.Inputs {
|
for i := range tx.Inputs {
|
||||||
sigz[i] = input.Signature.Signature
|
sigz[i] = tx.Inputs[i].Signature
|
||||||
tx.Inputs[i].Signature.Signature = nil
|
tx.Inputs[i].Signature = crypto.Signature{}
|
||||||
}
|
}
|
||||||
signBytes = append(signBytes, wire.BinaryBytes(tx)...)
|
signBytes = append(signBytes, wire.BinaryBytes(tx)...)
|
||||||
for i := range tx.Inputs {
|
for i := range tx.Inputs {
|
||||||
tx.Inputs[i].Signature.Signature = sigz[i]
|
tx.Inputs[i].Signature = sigz[i]
|
||||||
}
|
}
|
||||||
return signBytes
|
return signBytes
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tx *SendTx) SetSignature(addr []byte, sig crypto.Signature) bool {
|
func (tx *SendTx) SetSignature(addr []byte, sig crypto.Signature) bool {
|
||||||
sigs, ok := sig.(crypto.SignatureS)
|
|
||||||
if !ok {
|
|
||||||
sigs = crypto.SignatureS{sig}
|
|
||||||
}
|
|
||||||
for i, input := range tx.Inputs {
|
for i, input := range tx.Inputs {
|
||||||
if bytes.Equal(input.Address, addr) {
|
if bytes.Equal(input.Address, addr) {
|
||||||
tx.Inputs[i].Signature = sigs
|
tx.Inputs[i].Signature = sig
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -193,18 +183,14 @@ type AppTx struct {
|
||||||
func (tx *AppTx) SignBytes(chainID string) []byte {
|
func (tx *AppTx) SignBytes(chainID string) []byte {
|
||||||
signBytes := wire.BinaryBytes(chainID)
|
signBytes := wire.BinaryBytes(chainID)
|
||||||
sig := tx.Input.Signature
|
sig := tx.Input.Signature
|
||||||
tx.Input.Signature.Signature = nil
|
tx.Input.Signature = crypto.Signature{}
|
||||||
signBytes = append(signBytes, wire.BinaryBytes(tx)...)
|
signBytes = append(signBytes, wire.BinaryBytes(tx)...)
|
||||||
tx.Input.Signature = sig
|
tx.Input.Signature = sig
|
||||||
return signBytes
|
return signBytes
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tx *AppTx) SetSignature(sig crypto.Signature) bool {
|
func (tx *AppTx) SetSignature(sig crypto.Signature) bool {
|
||||||
sigs, ok := sig.(crypto.SignatureS)
|
tx.Input.Signature = sig
|
||||||
if !ok {
|
|
||||||
sigs = crypto.SignatureS{sig}
|
|
||||||
}
|
|
||||||
tx.Input.Signature = sigs
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,7 @@ import (
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
crypto "github.com/tendermint/go-crypto"
|
data "github.com/tendermint/go-wire/data"
|
||||||
data "github.com/tendermint/go-data"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var chainID string = "test_chain"
|
var chainID string = "test_chain"
|
||||||
|
@ -109,7 +108,7 @@ func TestSendTxJSON(t *testing.T) {
|
||||||
sig := test1PrivAcc.Sign(signBytes)
|
sig := test1PrivAcc.Sign(signBytes)
|
||||||
// we handle both raw sig and wrapped sig the same
|
// we handle both raw sig and wrapped sig the same
|
||||||
tx.SetSignature(test1PrivAcc.PubKey.Address(), sig)
|
tx.SetSignature(test1PrivAcc.PubKey.Address(), sig)
|
||||||
tx2.SetSignature(test1PrivAcc.PubKey.Address(), crypto.SignatureS{sig})
|
tx2.SetSignature(test1PrivAcc.PubKey.Address(), sig)
|
||||||
assert.Equal(tx, tx2)
|
assert.Equal(tx, tx2)
|
||||||
|
|
||||||
// let's marshal / unmarshal this with signature
|
// let's marshal / unmarshal this with signature
|
||||||
|
|
Loading…
Reference in New Issue