[wip] nitro bank, server

This commit is contained in:
Roy Crihfield 2025-01-15 15:49:43 +08:00
parent f69db263b0
commit eb94500f70
15 changed files with 828 additions and 196 deletions

View File

@ -1,101 +0,0 @@
package nitro
import (
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/spf13/cobra"
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/statechannels/go-nitro/channel/state/outcome"
gonitrotypes "github.com/statechannels/go-nitro/types"
"git.vdb.to/cerc-io/laconicd/x/bond"
"git.vdb.to/cerc-io/laconicd/x/nitrobank"
)
const (
FlagAssetAddress = "asset"
// FlagEthKey = "eth-key"
)
// type CreateLedgerChannelRequest struct {
// Counterparty gonitrotypes.Address
// ChallengeDuration uint32
// outcome outcome.Exit
// }
// FundCmd opens and funds a new payment channel
// - broadcasts MsgOpenChannel to trigger multisig generation
// - submits a tx to the Ethereum chain to fund the channel
func (s *Server) FundCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "fund <amount>", // TODO: doc args?
Short: "Fund a payment channel",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
// TODO make nitro work with laconic address?
counterparty := gonitrotypes.LedgerAddress(bond.ModuleAccountAddress)
amount, ok := new(big.Int).SetString(args[1], 10)
if !ok {
return fmt.Errorf("invalid amount: %s", args[1])
}
// send message to trigger multisig generation
openChannelMsg := &nitrobank.MsgOpenChannel{
FromAddress: s.ScAddr.String(),
ToAddress: counterparty.String(),
Amount: amount.String(),
// ChallengeDuration: 0, // todo
}
err = tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), openChannelMsg)
if err != nil {
return err
}
assetStr, err := cmd.Flags().GetString(FlagAssetAddress)
if err != nil {
return err
}
asset := common.HexToAddress(assetStr)
exit := outcome.Exit{
outcome.SingleAssetExit{
Asset: asset,
Allocations: []outcome.Allocation{
{
Destination: gonitrotypes.AddressToDestination(counterparty),
Amount: amount,
},
},
},
}
r, err := s.CreateLedgerChannel(counterparty, 0, exit)
if err != nil {
return err
}
fmt.Println("objective response:", r)
// TODO can we use coin denom syntax for eth tokens? how do we map denoms to addresses?
// amount, err := sdk.ParseCoinsNormalized(args[1])
// if err != nil {
// return err
// }
return nil
},
}
cmd.Flags().String(FlagAssetAddress, "", "The address of the asset to fund the channel with")
// cmd.Flags().String(FlagEthKey, "", "The Ethereum signing key")
AddNitroFlags(cmd.Flags())
return cmd
}

View File

@ -1,36 +0,0 @@
package nitro
type Config struct {
// TODO: use keyring
Pk string `mapstructure:"pk" toml:"pk" comment:"pk specifies the private key used by the nitro node."`
// TODO: use keyring
EthPk string `mapstructure:"eth-pk" toml:"eth-pk" comment:"eth-pk specifies the private key to use when interacting with the Ethereum chain."`
EthUrl string `mapstructure:"eth-url" toml:"eth-url" comment:"eth-url specifies the URL of the Ethereum node to connect to."`
EthAuthToken string `mapstructure:"eth-auth-token" toml:"eth-auth-token" comment:"eth-auth-token specifies the bearer token used for auth in requests to the Ethereum chain's RPC endpoint."`
EthStartBlock uint64 `mapstructure:"eth-start-block" toml:"eth-start-block" comment:"eth-start-block specifies the Ethereum block number to start listening for Nitro Adjudicator events."`
EthNaAddress string `mapstructure:"eth-na-address" toml:"na-address" comment:"na-address specifies the address of the Nitro Adjudicator contract."`
EthVpaAddress string `mapstructure:"eth-vpa-address" toml:"vpa-address" comment:"vpa-address specifies the address of the Virtual Payment App contract."`
EthCaAddress string `mapstructure:"eth-ca-address" toml:"ca-address" comment:"ca-address specifies the address of the Consensus App contract."`
BootPeers string `mapstructure:"boot-peers" toml:"boot-peers" comment:"boot-peers is a comma-delimited list of peer multiaddrs the messaging service will connect to when initialized."`
PublicIp string `mapstructure:"public-ip" toml:"public-ip" comment:"public-ip specifies the public IP address used for the message service."`
ExtMultiAddr string `mapstructure:"ext-multiaddr" toml:"ext-multiaddr" comment:"ext-multiaddr specifies an additional external multiaddr to advertise."`
MsgPort int `mapstructure:"msg-port" toml:"msg-port" comment:"msg-port specifies the TCP port for the message service."`
WsMsgPort int `mapstructure:"ws-msg-port" toml:"ws-msg-port" comment:"ws-msg-port specifies the WebSocket port for the message service."`
RpcPort int `mapstructure:"rpc-port" toml:"rpc-port" comment:"rpc-port specifies the TCP port for the RPC server."`
TlsCertFilepath string `mapstructure:"tls-cert-filepath" toml:"tls-cert-filepath" comment:"tls-cert-filepath specifies the filepath to the TLS certificate. If not specified, TLS will not be used with the RPC transport."`
TlsKeyFilepath string `mapstructure:"tls-key-filepath" toml:"tls-key-filepath" comment:"tls-key-filepath specifies the filepath to the TLS private key. If not specified, TLS will not be used with the RPC transport."`
}
func DefaultConfig() *Config {
return &Config{
EthUrl: "http://localhost:8545",
PublicIp: "127.0.0.1",
MsgPort: 3005,
WsMsgPort: 6005,
RpcPort: 4005,
// TlsCertFilepath: "./tls/statechannels.org.pem",
// TlsKeyFilepath: "./tls/statechannels.org_key.pem",
}
}

View File

@ -9,21 +9,55 @@ import "cerc/nitrobank/v1/nitrobank.proto";
option go_package = "git.vdb.to/cerc-io/laconicd/x/nitrobank";
// 1. user account initiates opening of ledger channel with consensus-controlled module account as
// counterparty
//
// 2. open-channel request is gossiped to validator set
//
// 3. validators submit partial signatures for pending open-channel request
//
// 4. block proposer checks pending open-channel requests and creates ledger channels for those with
// complete signatures
// MsgInitAccount initializes a nitro-based account
message MsgInitAccount {
string nitro_address = 1;
}
message MsgInitAccountResponse {}
// MsgOpenChannel opens a ledger channel with the sending account as a participant
message MsgOpenChannel {
// Nitro address of payer
option (cosmos.msg.v1.signer) = "from_address";
// TODO: this is the nitro address of the sending account
// // Nitro address of sending party
string from_address = 1;
// Nitro address of payee ("counterparty" module account)
// Nitro address of counterparty
string to_address = 2;
// Simplified outcome just includes the funding amount from payer
string amount = 3;
// TODO
// uint32 challenge_duration = 3;
}
message MsgOpenChannelResponse {}
service Msg {
rpc ProposeChannel(MsgProposeChannel) returns (MsgProposeChannelResponse) {
option (google.api.http).post = "/cerc/nitrobank/v1/propose_channel";
}
}
message MsgProposeChannel {
option (cosmos.msg.v1.signer) = "from_address";
// Nitro address of sending party (payer)
string from_address = 1;
// Nitro address of counterparty
string to_address = 2;
// Simplified outcome just includes the funding amount from payer
string amount = 3;
// TODO
// uint32 challenge_duration = 3;
}
message MsgProposeChannelResponse {}

35
server/nitro/config.go Normal file
View File

@ -0,0 +1,35 @@
package nitro
type Config struct {
// TODO: use keyring
Pk string `mapstructure:"pk" toml:"pk" comment:"The private key used by the Nitro node."`
// EthPk string `mapstructure:"eth-pk" toml:"eth-pk" comment:"eth-pk specifies the private key to use when interacting with the Ethereum chain."`
EthUrl string `mapstructure:"eth-url" toml:"eth-url" comment:"The URL of the Ethereum node to connect to."`
EthAuthToken string `mapstructure:"eth-auth-token" toml:"eth-auth-token" comment:"The bearer token used for auth in requests to the Ethereum chain's RPC endpoint."`
EthStartBlock uint64 `mapstructure:"eth-start-block" toml:"eth-start-block" comment:"Ethereum block number to start listening for Nitro Adjudicator events."`
EthNaAddress string `mapstructure:"eth-na-address" toml:"na-address" comment:"Ethereum address of the Nitro Adjudicator contract."`
EthVpaAddress string `mapstructure:"eth-vpa-address" toml:"vpa-address" comment:"Ethereum address of the Virtual Payment App contract."`
EthCaAddress string `mapstructure:"eth-ca-address" toml:"ca-address" comment:"Ethereum address of the Consensus App contract."`
BootPeers string `mapstructure:"boot-peers" toml:"boot-peers" comment:"Comma-delimited list of peer multiaddrs the messaging service will connect to when initialized."`
PublicIp string `mapstructure:"public-ip" toml:"public-ip" comment:"The public IP address used for the Nitro message service."`
ExtMultiAddr string `mapstructure:"ext-multiaddr" toml:"ext-multiaddr" comment:"An additional external multiaddr to advertise."`
MsgPort int `mapstructure:"msg-port" toml:"msg-port" comment:"The TCP port for the Nitro message service."`
WsMsgPort int `mapstructure:"ws-msg-port" toml:"ws-msg-port" comment:"The WebSocket port for the Nitro message service."`
RpcPort int `mapstructure:"rpc-port" toml:"rpc-port" comment:"The TCP port for the Nitro RPC server."`
TlsCertFilepath string `mapstructure:"tls-cert-filepath" toml:"tls-cert-filepath" comment:"Filepath to the TLS certificate. If not specified, TLS will not be used with the RPC transport."`
TlsKeyFilepath string `mapstructure:"tls-key-filepath" toml:"tls-key-filepath" comment:"Filepath to the TLS private key. If not specified, TLS will not be used with the RPC transport."`
}
func DefaultConfig() *Config {
return &Config{
EthUrl: "http://localhost:8545",
PublicIp: "127.0.0.1",
MsgPort: 3005,
WsMsgPort: 6005,
RpcPort: 4005,
// TlsCertFilepath: "./tls/statechannels.org.pem",
// TlsKeyFilepath: "./tls/statechannels.org_key.pem",
}
}

View File

@ -14,7 +14,7 @@ func prefix(f string) string {
var (
flag_pk = prefix("pk") // "pk"
flag_eth_pk = prefix("eth-pk") // "chainpk"
// flag_eth_pk = prefix("eth-pk") // "chainpk"
flag_eth_url = prefix("eth-url") // "chainurl"
flag_eth_start_block = prefix("eth-start-block") // "chainstartblock"
flag_eth_auth_token = prefix("eth-auth-token") // "chainauthtoken"
@ -34,8 +34,6 @@ var (
// flag_gui_port = prefix("gui-port") // "guiport"
)
// func addFlags(cmd *cobra.Command) {
// flags := cmd.Flags()
func AddNitroFlags(flags *pflag.FlagSet) {
flags.String(flag_pk, "",
"name of private key used by the Nitro node",
@ -49,10 +47,10 @@ func AddNitroFlags(flags *pflag.FlagSet) {
"bearer token used for auth in requests to the Ethereum chain's RPC endpoint",
// EnvVars: []string{"CHAIN_AUTH_TOKEN"},
)
flags.String(flag_eth_pk, "",
"name of private key to use when interacting with the Ethereum chain",
// EnvVars: []string{"CHAIN_PK"},
)
// flags.String(flag_eth_pk, "",
// "name of private key to use when interacting with the Ethereum chain",
// // EnvVars: []string{"CHAIN_PK"},
// )
flags.Uint64(flag_eth_start_block, 0,
"Ethereum block number to start listening for Nitro Adjudicator events",
// EnvVars: []string{"CHAIN_START_BLOCK"},
@ -70,20 +68,20 @@ func AddNitroFlags(flags *pflag.FlagSet) {
// "Specifies the address of the bridge contract.",
// )
flags.String(flag_public_ip, "127.0.0.1",
"public IP address used for the message service",
"public IP address used for the Nitro message service",
// EnvVars: []string{"NITRO_PUBLIC_IP"},
)
flags.String(flag_ext_multiaddr, "",
"additional external multiaddr to advertise",
)
flags.Int(flag_msg_port, 3005,
"TCP port for the message service",
"TCP port for the Nitro message service",
)
flags.Int(flag_ws_msg_port, 6005,
"WebSocket port for the message service",
"WebSocket port for the Nitro message service",
)
flags.Int(flag_rpc_port, 4005,
"TCP port for the RPC server",
"TCP port for the Nitro RPC server",
)
// flags.Int(flag_gui_port, 5005,
// "Specifies the tcp port for the Nitro Connect GUI.",

View File

@ -2,7 +2,6 @@ package nitro
import (
"context"
"encoding/hex"
"errors"
"fmt"
"log/slog"
@ -22,15 +21,9 @@ import (
"github.com/statechannels/go-nitro/node/engine/chainservice"
p2pms "github.com/statechannels/go-nitro/node/engine/messageservice/p2p-message-service"
"github.com/statechannels/go-nitro/node/engine/store"
"github.com/statechannels/go-nitro/types"
nitrotypes "github.com/statechannels/go-nitro/types"
)
// type ServerComponent[T transaction.Tx] interface {
// Name() string
// Start(context.Context) error
// Stop(context.Context) error
// }
const (
serverName = "nitro"
)
@ -43,6 +36,12 @@ var (
// _ serverv2.ConfigWriter = (*Server)(nil)
)
// TODO:
// - move multisig stuff into here. DKG is init'd from eth key.
// - server.SetParticipants() updates DKG members
// - onboarding module calls this
// - onboarding sets deals?
type Server struct {
*node.Node
@ -54,15 +53,15 @@ type Server struct {
// path to Nitro store directory
storeDir string
ScAddr types.PartyAddress
ScAddr nitrotypes.PartyAddress
}
func NewServer(logger log.Logger, cfg server.ConfigMap, clientCtx client.Context) (*Server, error) {
home, _ := cfg[serverv2.FlagHome].(string)
s := &Server{
logger: logger.With(log.ModuleKey, serverName),
storeDir: filepath.Join(home, "nitro"),
}
s.logger = logger.With(log.ModuleKey, s.Name())
s.config = s.Config().(*Config)
if len(cfg) > 0 {
@ -216,7 +215,7 @@ func (s *Server) CLICommands() serverv2.CLIConfig {
return serverv2.CLIConfig{
Commands: []*cobra.Command{
// command to create payment channel
s.FundCmd(),
// s.FundCmd(),
},
// Queries: []*cobra.Command{},
}

20
server/nitro/service.go Normal file
View File

@ -0,0 +1,20 @@
package nitro
import (
"github.com/cometbft/cometbft/types"
"github.com/statechannels/go-nitro/channel/state/outcome"
"github.com/statechannels/go-nitro/protocols/directfund"
"github.com/statechannels/go-nitro/protocols/virtualfund"
)
// Service represents a service which triggers Nitro state channel actions
// TODO
type Service interface {
// CreatePaymentChannel creates a new virtual payment channel with the specified intermediaries,
// counterparty, ChallengeDuration, and outcome
CreatePaymentChannel(intermediaries []types.Address, counterparty types.Address, ChallengeDuration uint32, outcome outcome.Exit) (virtualfund.ObjectiveResponse, error)
// CreateLedgerChannel creates a new ledger channel with the specified counterparty,
// ChallengeDuration, and outcome
CreateLedgerChannel(counterparty types.Address, ChallengeDuration uint32, outcome outcome.Exit) (directfund.ObjectiveResponse, error)
}

View File

@ -22,7 +22,7 @@ import (
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
bondtypes "git.vdb.to/cerc-io/laconicd/x/bond"
"git.vdb.to/cerc-io/laconicd/x/nitrobank"
nitrokeeper "git.vdb.to/cerc-io/laconicd/x/nitrobank/keeper"
)
type BondsIndexes struct {
@ -56,7 +56,7 @@ type Keeper struct {
// External keepers
accountKeeper auth.AccountKeeper
bankKeeper bank.Keeper
nitroKeeper nitrobank.Keeper
nitroKeeper nitrokeeper.Keeper
// Track bond usage in other cosmos-sdk modules (more like a usage tracker).
usageKeepers []bondtypes.BondUsageKeeper

View File

@ -8,7 +8,7 @@ import (
// "github.com/ethereum/go-ethereum/common"
nitro "git.vdb.to/cerc-io/laconicd/nitro/service"
"git.vdb.to/cerc-io/laconicd/server/nitro"
)
var (
@ -23,7 +23,7 @@ type Account struct {
// NitroAddress is the address corresponding to the Nitro node private key
NitroAddress collections.Item[[]byte]
// Name is the name of the module account
Name collections.Item[string]
// Name collections.Item[string]
nitroService nitro.Service
}
@ -33,12 +33,12 @@ func NewAccount(d accountstd.Dependencies) *Account {
return &Account{
// EthAddress: collections.NewItem(d.SchemaBuilder, EthAddressPrefix, "eth_address", collections.BytesValue),
NitroAddress: collections.NewItem(d.SchemaBuilder, NitroAddressPrefix, "nitro_address", collections.BytesValue),
Name: collections.NewItem(d.SchemaBuilder, NamePrefix, "name", collections.StringValue),
// Name: collections.NewItem(d.SchemaBuilder, NamePrefix, "name", collections.StringValue),
}
}
func (a Account) Init(ctx context.Context, msg *MsgInitAccount) (*MsgInitAccountResponse, error) {
// use Whoami to register account address as consensus-controlled
// TODO use Whoami to register account address as consensus-controlled
// addr := accountstd.Whoami(ctx)
// a.nitroService.SetConsensusAccount(addr)
@ -46,12 +46,19 @@ func (a Account) Init(ctx context.Context, msg *MsgInitAccount) (*MsgInitAccount
return &MsgInitAccountResponse{}, nil
}
func (a Account) RegisterInitHandler(builder *accountstd.InitBuilder) {
accountstd.RegisterInitHandler(builder, a.Init)
}
func (a Account) OpenChannel(msg *MsgOpenChannel) (*MsgOpenChannelResponse, error) {
func (a Account) OpenChannel(_ context.Context, msg *MsgOpenChannel) (*MsgOpenChannelResponse, error) {
// produce a partial signature to open a ledger and payment channel between the requesting
// counterparty and this consensus controlled account
return nil, nil
}
// TODO Authenticate(context.Context, *MsgAuthenticate)
func (a Account) RegisterInitHandler(builder *accountstd.InitBuilder) {
accountstd.RegisterInitHandler(builder, a.Init)
}
// RegisterExecuteHandlers registers the execution handlers for the account.
func (a Account) RegisterExecuteHandlers(builder *accountstd.ExecuteBuilder) {
accountstd.RegisterExecuteHandler(builder, a.OpenChannel)
}

18
x/nitrobank/codec.go Normal file
View File

@ -0,0 +1,18 @@
package nitrobank
import (
"cosmossdk.io/core/registry"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/msgservice"
)
// RegisterInterfaces registers the interfaces types with the interface registry.
func RegisterInterfaces(registry registry.InterfaceRegistrar) {
registry.RegisterImplementations((*sdk.Msg)(nil),
&MsgProposeChannel{},
// account messages TODO verify whether these need registration
&MsgInitAccount{},
&MsgOpenChannel{},
)
msgservice.RegisterMsgServiceDesc(registry, &Msg_serviceDesc)
}

View File

@ -0,0 +1,23 @@
package keeper
import (
"context"
"git.vdb.to/cerc-io/laconicd/x/nitrobank"
)
type handlers struct {
*Keeper
}
// NewHandlers creates a new nitrobank handlers
func NewHandlers(k *Keeper) handlers {
return handlers{k}
}
func (h handlers) MsgProposeChannel(
ctx context.Context, msg *nitrobank.MsgProposeChannel,
) (*nitrobank.MsgProposeChannelResponse, error) {
// TODO
return nil, nil
}

View File

@ -0,0 +1,24 @@
package keeper
import (
"context"
appmodule "cosmossdk.io/core/appmodule/v2"
banktypes "cosmossdk.io/x/bank/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)
type Keeper struct {
appmodule.Environment
// use interface from bank module
acctKeeper banktypes.AccountKeeper
}
// func (k Keeper) EnsurePaymentChannel(from, to sdk.AccAddress, amount sdk.Coins) error {
func (k Keeper) EnsurePaymentChannel(from sdk.AccAddress, to string, amount sdk.Coins) error {
// TODO client must open the channel; we verify it with the nitro service
return nil
}
func (k Keeper) ProposeChannel(ctx context.Context) {}

View File

@ -0,0 +1,122 @@
package module
import (
// "google.golang.org/grpc"
appmodule "cosmossdk.io/core/appmodule/v2"
"cosmossdk.io/core/registry"
"github.com/cosmos/cosmos-sdk/codec"
"git.vdb.to/cerc-io/laconicd/x/nitrobank"
"git.vdb.to/cerc-io/laconicd/x/nitrobank/keeper"
)
var (
_ appmodule.HasConsensusVersion = AppModule{}
// _ appmodule.HasGenesis = AppModule{}
// _ appmodule.HasMsgHandlers = AppModule{}
// _ appmodule.HasQueryHandlers = AppModule{}
// _ appmodule.HasRegisterInterfaces = AppModule{}
// _ module.HasGRPCGateway = AppModule{}
// _ module.HasServices = AppModule{}
// _ module.HasInvariants = AppModule{}
// _ module.HasAminoCodec = AppModule{} // TODO
)
// ConsensusVersion defines the current module consensus version
const ConsensusVersion = 1
type AppModule struct {
cdc codec.Codec
keeper *nitrobank.Keeper
}
// NewAppModule creates a new AppModule object
func NewAppModule(cdc codec.Codec, keeper *nitrobank.Keeper) AppModule {
return AppModule{
cdc: cdc,
keeper: keeper,
}
}
// // module.HasGRPCGateway
// // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the bond module.
// func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux) {
// if err := nitrobank.RegisterQueryHandlerClient(context.Background(), mux, nitrobank.NewQueryClient(clientCtx)); err != nil {
// panic(err)
// }
// }
// appmodule.HasRegisterInterfaces
// RegisterInterfaces registers interfaces and implementations of the bond module.
func (AppModule) RegisterInterfaces(registry registry.InterfaceRegistrar) {
nitrobank.RegisterInterfaces(registry)
}
// appmodule.HasConsensusVersion
// ConsensusVersion implements AppModule/ConsensusVersion.
func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion }
// // appmodule.HasGenesis
// // DefaultGenesis returns default genesis state as raw bytes for the module.
// func (am AppModule) DefaultGenesis() json.RawMessage {
// return am.cdc.MustMarshalJSON(nitrobank.DefaultGenesisState())
// }
// // ValidateGenesis performs genesis state validation for the module.
// func (am AppModule) ValidateGenesis(message json.RawMessage) error {
// var data nitrobank.GenesisState
// if err := am.cdc.UnmarshalJSON(message, &data); err != nil {
// return fmt.Errorf("failed to unmarshal %s genesis state: %w", nitrobank.ModuleName, err)
// }
// return data.Validate()
// }
// // InitGenesis performs genesis initialization for the bond module.
// // It returns no validator updates.
// func (am AppModule) InitGenesis(ctx context.Context, data json.RawMessage) error {
// var genesisState nitrobank.GenesisState
// am.cdc.MustUnmarshalJSON(data, &genesisState)
// if err := am.keeper.InitGenesis(ctx, &genesisState); err != nil {
// return fmt.Errorf("failed to initialize %s genesis state: %w", nitrobank.ModuleName, err)
// }
// return nil
// }
// // ExportGenesis returns the exported genesis state as raw bytes for the circuit
// // module.
// func (am AppModule) ExportGenesis(ctx context.Context) (json.RawMessage, error) {
// gs, err := am.keeper.ExportGenesis(ctx)
// if err != nil {
// panic(fmt.Sprintf("failed to export %s genesis state: %v", nitrobank.ModuleName, err))
// }
// return am.cdc.MustMarshalJSON(gs), nil
// }
// module.HasInvariants
// func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {
// keeper.RegisterInvariants(ir, am.keeper)
// }
// RegisterMsgHandlers registers the message handlers for the bond module.
func (am AppModule) RegisterMsgHandlers(router appmodule.MsgRouter) {
handlers := keeper.NewHandlers(am.keeper)
appmodule.RegisterMsgHandler(router, handlers.MsgProposeChannel)
}
// // RegisterQueryHandlers registers the query handlers for the bond module.
// func (am AppModule) RegisterQueryHandlers(router appmodule.QueryRouter) {
// handlers := keeper.NewQueryServerImpl(am.keeper)
// }

View File

@ -4,11 +4,16 @@
package nitrobank
import (
context "context"
fmt "fmt"
_ "github.com/cosmos/cosmos-sdk/types/msgservice"
_ "github.com/cosmos/gogoproto/gogoproto"
grpc1 "github.com/cosmos/gogoproto/grpc"
proto "github.com/cosmos/gogoproto/proto"
_ "google.golang.org/genproto/googleapis/api/annotations"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
io "io"
math "math"
math_bits "math/bits"
@ -25,6 +30,7 @@ var _ = math.Inf
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
// MsgInitAccount initializes a nitro-based account
type MsgInitAccount struct {
NitroAddress string `protobuf:"bytes,1,opt,name=nitro_address,json=nitroAddress,proto3" json:"nitro_address,omitempty"`
}
@ -105,10 +111,12 @@ func (m *MsgInitAccountResponse) XXX_DiscardUnknown() {
var xxx_messageInfo_MsgInitAccountResponse proto.InternalMessageInfo
// MsgOpenChannel opens a ledger channel with the sending account as a participant
type MsgOpenChannel struct {
// Nitro address of payer
// TODO: this is the nitro address of the sending account
// // Nitro address of sending party
FromAddress string `protobuf:"bytes,1,opt,name=from_address,json=fromAddress,proto3" json:"from_address,omitempty"`
// Nitro address of payee ("counterparty" module account)
// Nitro address of counterparty
ToAddress string `protobuf:"bytes,2,opt,name=to_address,json=toAddress,proto3" json:"to_address,omitempty"`
// Simplified outcome just includes the funding amount from payer
Amount string `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"`
@ -204,36 +212,224 @@ func (m *MsgOpenChannelResponse) XXX_DiscardUnknown() {
var xxx_messageInfo_MsgOpenChannelResponse proto.InternalMessageInfo
type MsgProposeChannel struct {
// Nitro address of sending party (payer)
FromAddress string `protobuf:"bytes,1,opt,name=from_address,json=fromAddress,proto3" json:"from_address,omitempty"`
// Nitro address of counterparty
ToAddress string `protobuf:"bytes,2,opt,name=to_address,json=toAddress,proto3" json:"to_address,omitempty"`
// Simplified outcome just includes the funding amount from payer
Amount string `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"`
}
func (m *MsgProposeChannel) Reset() { *m = MsgProposeChannel{} }
func (m *MsgProposeChannel) String() string { return proto.CompactTextString(m) }
func (*MsgProposeChannel) ProtoMessage() {}
func (*MsgProposeChannel) Descriptor() ([]byte, []int) {
return fileDescriptor_7647fae54567b5bd, []int{4}
}
func (m *MsgProposeChannel) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *MsgProposeChannel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_MsgProposeChannel.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *MsgProposeChannel) XXX_Merge(src proto.Message) {
xxx_messageInfo_MsgProposeChannel.Merge(m, src)
}
func (m *MsgProposeChannel) XXX_Size() int {
return m.Size()
}
func (m *MsgProposeChannel) XXX_DiscardUnknown() {
xxx_messageInfo_MsgProposeChannel.DiscardUnknown(m)
}
var xxx_messageInfo_MsgProposeChannel proto.InternalMessageInfo
func (m *MsgProposeChannel) GetFromAddress() string {
if m != nil {
return m.FromAddress
}
return ""
}
func (m *MsgProposeChannel) GetToAddress() string {
if m != nil {
return m.ToAddress
}
return ""
}
func (m *MsgProposeChannel) GetAmount() string {
if m != nil {
return m.Amount
}
return ""
}
type MsgProposeChannelResponse struct {
}
func (m *MsgProposeChannelResponse) Reset() { *m = MsgProposeChannelResponse{} }
func (m *MsgProposeChannelResponse) String() string { return proto.CompactTextString(m) }
func (*MsgProposeChannelResponse) ProtoMessage() {}
func (*MsgProposeChannelResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_7647fae54567b5bd, []int{5}
}
func (m *MsgProposeChannelResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *MsgProposeChannelResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_MsgProposeChannelResponse.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *MsgProposeChannelResponse) XXX_Merge(src proto.Message) {
xxx_messageInfo_MsgProposeChannelResponse.Merge(m, src)
}
func (m *MsgProposeChannelResponse) XXX_Size() int {
return m.Size()
}
func (m *MsgProposeChannelResponse) XXX_DiscardUnknown() {
xxx_messageInfo_MsgProposeChannelResponse.DiscardUnknown(m)
}
var xxx_messageInfo_MsgProposeChannelResponse proto.InternalMessageInfo
func init() {
proto.RegisterType((*MsgInitAccount)(nil), "cerc.nitrobank.v1.MsgInitAccount")
proto.RegisterType((*MsgInitAccountResponse)(nil), "cerc.nitrobank.v1.MsgInitAccountResponse")
proto.RegisterType((*MsgOpenChannel)(nil), "cerc.nitrobank.v1.MsgOpenChannel")
proto.RegisterType((*MsgOpenChannelResponse)(nil), "cerc.nitrobank.v1.MsgOpenChannelResponse")
proto.RegisterType((*MsgProposeChannel)(nil), "cerc.nitrobank.v1.MsgProposeChannel")
proto.RegisterType((*MsgProposeChannelResponse)(nil), "cerc.nitrobank.v1.MsgProposeChannelResponse")
}
func init() { proto.RegisterFile("cerc/nitrobank/v1/tx.proto", fileDescriptor_7647fae54567b5bd) }
var fileDescriptor_7647fae54567b5bd = []byte{
// 304 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x64, 0x90, 0xbf, 0x4e, 0xf3, 0x30,
0x14, 0xc5, 0x9b, 0xef, 0x93, 0x2a, 0xd5, 0x14, 0x24, 0x22, 0x54, 0xaa, 0x0a, 0x2c, 0x5a, 0x06,
0x58, 0x88, 0x55, 0x21, 0x1e, 0x20, 0x30, 0x31, 0x20, 0xa4, 0x8e, 0x2c, 0xc8, 0x71, 0x8c, 0x31,
0x24, 0xf7, 0x46, 0xb1, 0x89, 0xfa, 0x18, 0x3c, 0x16, 0x63, 0x47, 0x46, 0x94, 0xbc, 0x08, 0xb2,
0x9b, 0x12, 0xfe, 0x6c, 0xd7, 0xe7, 0x1c, 0xdf, 0xdf, 0xd5, 0x21, 0x13, 0x21, 0x4b, 0xc1, 0x40,
0xdb, 0x12, 0x13, 0x0e, 0xcf, 0xac, 0x9a, 0x33, 0xbb, 0x8c, 0x8a, 0x12, 0x2d, 0x86, 0xbb, 0xce,
0x8b, 0xbe, 0xbc, 0xa8, 0x9a, 0x4f, 0xf6, 0x05, 0x9a, 0x1c, 0x0d, 0xcb, 0x8d, 0x72, 0xd1, 0xdc,
0xa8, 0x75, 0x76, 0xb2, 0xa7, 0x50, 0xa1, 0x1f, 0x99, 0x9b, 0x5a, 0xf5, 0x40, 0x21, 0xaa, 0x4c,
0x32, 0x5e, 0x68, 0xc6, 0x01, 0xd0, 0x72, 0xab, 0x11, 0x4c, 0xeb, 0x4e, 0xff, 0xb2, 0x3b, 0x98,
0x8f, 0xcc, 0x2e, 0xc8, 0xce, 0x8d, 0x51, 0xd7, 0xa0, 0x6d, 0x2c, 0x04, 0xbe, 0x80, 0x0d, 0x8f,
0xc9, 0xb6, 0x0f, 0xdd, 0xf3, 0x34, 0x2d, 0xa5, 0x31, 0xe3, 0xe0, 0x28, 0x38, 0x1d, 0x2c, 0x86,
0x5e, 0x8c, 0xd7, 0xda, 0x6c, 0x4c, 0x46, 0x3f, 0xbf, 0x2d, 0xa4, 0x29, 0x10, 0x8c, 0x9c, 0x3d,
0xf9, 0x85, 0xb7, 0x85, 0x84, 0xab, 0x47, 0x0e, 0x20, 0xb3, 0x70, 0x4a, 0x86, 0x0f, 0x25, 0xe6,
0xbf, 0xf6, 0x6d, 0x39, 0xad, 0x5d, 0x17, 0x1e, 0x12, 0x62, 0x3b, 0xe0, 0x3f, 0x1f, 0x18, 0xd8,
0x0d, 0x2d, 0x1c, 0x91, 0x3e, 0xcf, 0x1d, 0x65, 0xfc, 0xdf, 0x5b, 0xed, 0xab, 0xbd, 0xe2, 0x1b,
0x6b, 0x73, 0xc5, 0x65, 0xfc, 0x56, 0xd3, 0x60, 0x55, 0xd3, 0xe0, 0xa3, 0xa6, 0xc1, 0x6b, 0x43,
0x7b, 0xab, 0x86, 0xf6, 0xde, 0x1b, 0xda, 0xbb, 0x3b, 0x51, 0xda, 0x46, 0x55, 0x9a, 0x44, 0x16,
0x99, 0xab, 0xe7, 0x4c, 0x23, 0xcb, 0xb8, 0x40, 0xd0, 0x22, 0x65, 0xcb, 0xae, 0x9f, 0xa4, 0xef,
0x0b, 0x3a, 0xff, 0x0c, 0x00, 0x00, 0xff, 0xff, 0xd1, 0x6e, 0x50, 0x5b, 0xc1, 0x01, 0x00, 0x00,
// 400 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x92, 0xc1, 0x6a, 0x1a, 0x41,
0x18, 0xc7, 0x1d, 0xa5, 0x82, 0x53, 0x2b, 0xb8, 0x14, 0x6b, 0xb7, 0xed, 0x52, 0xb7, 0x42, 0x8b,
0xb4, 0x3b, 0xd8, 0xd2, 0x4b, 0x6f, 0xb6, 0xa7, 0x1e, 0xa4, 0xc5, 0x63, 0x2f, 0x32, 0xce, 0x4e,
0x27, 0x4b, 0xdc, 0xf9, 0x96, 0x9d, 0x89, 0x78, 0x09, 0x88, 0x4f, 0x20, 0xe4, 0x01, 0xf2, 0x0a,
0x3e, 0x46, 0x8e, 0x42, 0x2e, 0x39, 0x06, 0x0d, 0xf8, 0x1a, 0x61, 0xc7, 0x55, 0xa3, 0x7b, 0xc9,
0x2d, 0xb7, 0xd9, 0xef, 0xff, 0xff, 0x7e, 0xff, 0x3f, 0xcb, 0x87, 0x6d, 0xc6, 0x63, 0x46, 0x64,
0xa0, 0x63, 0x18, 0x50, 0x79, 0x4a, 0x46, 0x6d, 0xa2, 0xc7, 0x5e, 0x14, 0x83, 0x06, 0xab, 0x9a,
0x68, 0xde, 0x4e, 0xf3, 0x46, 0x6d, 0xfb, 0x15, 0x03, 0x15, 0x82, 0x22, 0xa1, 0x12, 0x89, 0x35,
0x54, 0x62, 0xe3, 0xb5, 0x5f, 0x0a, 0x10, 0x60, 0x9e, 0x24, 0x79, 0xa5, 0xd3, 0xb7, 0x02, 0x40,
0x0c, 0x39, 0xa1, 0x51, 0x40, 0xa8, 0x94, 0xa0, 0xa9, 0x0e, 0x40, 0xaa, 0x54, 0x6d, 0x64, 0xb3,
0xf7, 0x61, 0xc6, 0xe2, 0x7e, 0xc7, 0x95, 0xae, 0x12, 0xbf, 0x65, 0xa0, 0x3b, 0x8c, 0xc1, 0x99,
0xd4, 0xd6, 0x07, 0xfc, 0xc2, 0x98, 0xfa, 0xd4, 0xf7, 0x63, 0xae, 0x54, 0x1d, 0xbd, 0x47, 0x9f,
0x4a, 0xbd, 0xb2, 0x19, 0x76, 0x36, 0x33, 0xb7, 0x8e, 0x6b, 0x87, 0x6b, 0x3d, 0xae, 0x22, 0x90,
0x8a, 0xbb, 0xe7, 0x06, 0xf8, 0x27, 0xe2, 0xf2, 0xd7, 0x09, 0x95, 0x92, 0x0f, 0xad, 0x06, 0x2e,
0xff, 0x8f, 0x21, 0x3c, 0xe2, 0x3d, 0x4f, 0x66, 0x29, 0xce, 0x7a, 0x87, 0xb1, 0xde, 0x07, 0xe6,
0x8d, 0xa1, 0xa4, 0xb7, 0x69, 0x56, 0x0d, 0x17, 0x69, 0x98, 0xa4, 0xd4, 0x0b, 0x46, 0x4a, 0xbf,
0x7e, 0x54, 0xa7, 0xeb, 0x79, 0xeb, 0x00, 0x9e, 0x16, 0x7b, 0x10, 0xbf, 0x2b, 0x36, 0x41, 0xb8,
0xda, 0x55, 0xe2, 0x6f, 0x0c, 0x11, 0x28, 0xfe, 0x24, 0xe5, 0xde, 0xe0, 0xd7, 0x99, 0x06, 0xdb,
0x7e, 0x5f, 0x2f, 0x11, 0x2e, 0x74, 0x95, 0xb0, 0x66, 0x08, 0x57, 0x8e, 0x4a, 0x36, 0xbd, 0xcc,
0xa1, 0x78, 0x19, 0x90, 0xfd, 0xf9, 0x31, 0xae, 0xdd, 0xef, 0x68, 0x4d, 0xaf, 0xef, 0x2e, 0xf2,
0x4d, 0xd7, 0x25, 0xd9, 0x23, 0x89, 0x36, 0x2b, 0x7d, 0x96, 0x92, 0x9f, 0x4d, 0xd6, 0xf3, 0x16,
0xfa, 0xd9, 0xb9, 0x5a, 0x3a, 0x68, 0xb1, 0x74, 0xd0, 0xed, 0xd2, 0x41, 0xb3, 0x95, 0x93, 0x5b,
0xac, 0x9c, 0xdc, 0xcd, 0xca, 0xc9, 0xfd, 0xfb, 0x28, 0x02, 0xed, 0x8d, 0xfc, 0x81, 0xa7, 0xc1,
0xe0, 0xbe, 0x04, 0x40, 0x86, 0x94, 0x81, 0x0c, 0x98, 0x4f, 0xc6, 0x7b, 0xf8, 0xa0, 0x68, 0xae,
0xee, 0xdb, 0x7d, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf6, 0x95, 0xda, 0x82, 0x16, 0x03, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConn
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion4
// MsgClient is the client API for Msg service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type MsgClient interface {
ProposeChannel(ctx context.Context, in *MsgProposeChannel, opts ...grpc.CallOption) (*MsgProposeChannelResponse, error)
}
type msgClient struct {
cc grpc1.ClientConn
}
func NewMsgClient(cc grpc1.ClientConn) MsgClient {
return &msgClient{cc}
}
func (c *msgClient) ProposeChannel(ctx context.Context, in *MsgProposeChannel, opts ...grpc.CallOption) (*MsgProposeChannelResponse, error) {
out := new(MsgProposeChannelResponse)
err := c.cc.Invoke(ctx, "/cerc.nitrobank.v1.Msg/ProposeChannel", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// MsgServer is the server API for Msg service.
type MsgServer interface {
ProposeChannel(context.Context, *MsgProposeChannel) (*MsgProposeChannelResponse, error)
}
// UnimplementedMsgServer can be embedded to have forward compatible implementations.
type UnimplementedMsgServer struct {
}
func (*UnimplementedMsgServer) ProposeChannel(ctx context.Context, req *MsgProposeChannel) (*MsgProposeChannelResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ProposeChannel not implemented")
}
func RegisterMsgServer(s grpc1.Server, srv MsgServer) {
s.RegisterService(&_Msg_serviceDesc, srv)
}
func _Msg_ProposeChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(MsgProposeChannel)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(MsgServer).ProposeChannel(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/cerc.nitrobank.v1.Msg/ProposeChannel",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MsgServer).ProposeChannel(ctx, req.(*MsgProposeChannel))
}
return interceptor(ctx, in, info, handler)
}
var Msg_serviceDesc = _Msg_serviceDesc
var _Msg_serviceDesc = grpc.ServiceDesc{
ServiceName: "cerc.nitrobank.v1.Msg",
HandlerType: (*MsgServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "ProposeChannel",
Handler: _Msg_ProposeChannel_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "cerc/nitrobank/v1/tx.proto",
}
func (m *MsgInitAccount) Marshal() (dAtA []byte, err error) {
@ -356,6 +552,73 @@ func (m *MsgOpenChannelResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)
return len(dAtA) - i, nil
}
func (m *MsgProposeChannel) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *MsgProposeChannel) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *MsgProposeChannel) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if len(m.Amount) > 0 {
i -= len(m.Amount)
copy(dAtA[i:], m.Amount)
i = encodeVarintTx(dAtA, i, uint64(len(m.Amount)))
i--
dAtA[i] = 0x1a
}
if len(m.ToAddress) > 0 {
i -= len(m.ToAddress)
copy(dAtA[i:], m.ToAddress)
i = encodeVarintTx(dAtA, i, uint64(len(m.ToAddress)))
i--
dAtA[i] = 0x12
}
if len(m.FromAddress) > 0 {
i -= len(m.FromAddress)
copy(dAtA[i:], m.FromAddress)
i = encodeVarintTx(dAtA, i, uint64(len(m.FromAddress)))
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
}
func (m *MsgProposeChannelResponse) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *MsgProposeChannelResponse) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *MsgProposeChannelResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
return len(dAtA) - i, nil
}
func encodeVarintTx(dAtA []byte, offset int, v uint64) int {
offset -= sovTx(v)
base := offset
@ -419,6 +682,36 @@ func (m *MsgOpenChannelResponse) Size() (n int) {
return n
}
func (m *MsgProposeChannel) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = len(m.FromAddress)
if l > 0 {
n += 1 + l + sovTx(uint64(l))
}
l = len(m.ToAddress)
if l > 0 {
n += 1 + l + sovTx(uint64(l))
}
l = len(m.Amount)
if l > 0 {
n += 1 + l + sovTx(uint64(l))
}
return n
}
func (m *MsgProposeChannelResponse) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
return n
}
func sovTx(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7
}
@ -753,6 +1046,202 @@ func (m *MsgOpenChannelResponse) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *MsgProposeChannel) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTx
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: MsgProposeChannel: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: MsgProposeChannel: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field FromAddress", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTx
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthTx
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthTx
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.FromAddress = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field ToAddress", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTx
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthTx
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthTx
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.ToAddress = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTx
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthTx
}
postIndex := iNdEx + intStringLen
if postIndex < 0 {
return ErrInvalidLengthTx
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Amount = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipTx(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthTx
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *MsgProposeChannelResponse) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowTx
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: MsgProposeChannelResponse: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: MsgProposeChannelResponse: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
default:
iNdEx = preIndex
skippy, err := skipTx(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthTx
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipTx(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0