From 8adfed0533756dbc75cce835913058109dbdd8a6 Mon Sep 17 00:00:00 2001 From: DedicatedDev Date: Wed, 6 Mar 2024 13:15:29 +0200 Subject: [PATCH 01/71] chore: enable events --- x/gmm/types/message_add_liquidity.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/x/gmm/types/message_add_liquidity.go b/x/gmm/types/message_add_liquidity.go index f16a6519..6c95662f 100644 --- a/x/gmm/types/message_add_liquidity.go +++ b/x/gmm/types/message_add_liquidity.go @@ -63,6 +63,4 @@ func (msg *MsgAddLiquidity) ValidateBasic() error { return nil } -func (msg *MsgAddLiquidity) GetLiquidityAsCoins() sdk.Coins { - return sdk.NewCoins(msg.Liquidity...).Sort() -} + From e697bbf968d736a5661a8309da15cb3c75d269b1 Mon Sep 17 00:00:00 2001 From: DedicatedDev Date: Mon, 11 Mar 2024 09:16:28 +0200 Subject: [PATCH 02/71] chore: update pfm version --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 28c92ff5..be95006a 100644 --- a/go.mod +++ b/go.mod @@ -191,7 +191,7 @@ require ( github.com/cosmos/cosmos-proto v1.0.0-beta.4 github.com/cosmos/ics23/go v0.10.0 github.com/prometheus/client_golang v1.15.0 - github.com/sideprotocol/packet-forward-middleware/v7 v7.0.0-20240301130023-4ffe7ac5619b + github.com/sideprotocol/packet-forward-middleware/v7 v7.0.0-20240311071335-a58b48b0a6d6 google.golang.org/genproto/googleapis/api v0.0.0-20231212172506-995d672761c0 google.golang.org/grpc v1.60.1 google.golang.org/protobuf v1.32.0 diff --git a/go.sum b/go.sum index 50275361..a45a580b 100644 --- a/go.sum +++ b/go.sum @@ -898,8 +898,8 @@ github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71e github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/sideprotocol/packet-forward-middleware/v7 v7.0.0-20240301130023-4ffe7ac5619b h1:RaO0cBgS0RsZEE+27g7PoyrADVZwmIzW6iihwi1zp1A= -github.com/sideprotocol/packet-forward-middleware/v7 v7.0.0-20240301130023-4ffe7ac5619b/go.mod h1:/euetAAJE1/s/m6TxGFBLBv1UamUDcIH3Xgn3CJnnKI= +github.com/sideprotocol/packet-forward-middleware/v7 v7.0.0-20240311071335-a58b48b0a6d6 h1:Uy+xnAR08JEjFm2OO0pOSnLtbkMS5B1XXZmHvXqBYyE= +github.com/sideprotocol/packet-forward-middleware/v7 v7.0.0-20240311071335-a58b48b0a6d6/go.mod h1:/euetAAJE1/s/m6TxGFBLBv1UamUDcIH3Xgn3CJnnKI= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= From ce140f0e43fa7cb2ce0fd1ed0cf4240c8adde320 Mon Sep 17 00:00:00 2001 From: DedicatedDev Date: Mon, 11 Mar 2024 10:34:58 +0200 Subject: [PATCH 03/71] feat: disable pfm --- app/keepers/keepers.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 02d8c613..9e318e39 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -80,7 +80,7 @@ import ( wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" - "github.com/sideprotocol/packet-forward-middleware/v7/packetforward" + // "github.com/sideprotocol/packet-forward-middleware/v7/packetforward" packetforwardkeeper "github.com/sideprotocol/packet-forward-middleware/v7/packetforward/keeper" packetforwardtypes "github.com/sideprotocol/packet-forward-middleware/v7/packetforward/types" ) @@ -437,15 +437,15 @@ func (appKeepers *AppKeepers) InitNormalKeepers( // wire up x/wasm to IBC // Create static IBC router, add transfer route, then set and seal it - var ics101WasmStack ibcporttypes.IBCModule - ics101WasmStack = wasm.NewIBCHandler(appKeepers.WasmKeeper, appKeepers.IBCKeeper.ChannelKeeper, appKeepers.IBCKeeper.ChannelKeeper) - ics101WasmStack = packetforward.NewIBCMiddleware( - ics101WasmStack, - appKeepers.PacketForwardKeeper, - 0, // retries on timeout - packetforwardkeeper.DefaultForwardTransferPacketTimeoutTimestamp, // forward timeout - packetforwardkeeper.DefaultRefundTransferPacketTimeoutTimestamp, // refund timeout - ) + //var ics101WasmStack ibcporttypes.IBCModule + ics101WasmStack := wasm.NewIBCHandler(appKeepers.WasmKeeper, appKeepers.IBCKeeper.ChannelKeeper, appKeepers.IBCKeeper.ChannelKeeper) + // ics101WasmStack = packetforward.NewIBCMiddleware( + // ics101WasmStack, + // appKeepers.PacketForwardKeeper, + // 0, // retries on timeout + // packetforwardkeeper.DefaultForwardTransferPacketTimeoutTimestamp, // forward timeout + // packetforwardkeeper.DefaultRefundTransferPacketTimeoutTimestamp, // refund timeout + // ) ibcRouter := ibcporttypes.NewRouter() ibcRouter.AddRoute(icahosttypes.SubModuleName, icaHostIBCModule). From b66d2c46da5a1514d226c2e6121cb1a50bb574e9 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Thu, 9 May 2024 15:12:36 +0800 Subject: [PATCH 04/71] add protobuf for bitcoin light client --- app/keepers/keepers.go | 5 - go.sum | 5 - proto/side/btclightclient/genesis.proto | 13 + proto/side/btclightclient/params.proto | 24 + proto/side/btclightclient/query.proto | 67 + proto/side/btclightclient/tx.proto | 40 + x/btclightclient/types/genesis.pb.go | 385 ++++++ x/btclightclient/types/params.pb.go | 795 +++++++++++ x/btclightclient/types/query.pb.go | 1678 +++++++++++++++++++++++ x/btclightclient/types/query.pb.gw.go | 420 ++++++ x/btclightclient/types/tx.pb.go | 981 +++++++++++++ 11 files changed, 4403 insertions(+), 10 deletions(-) create mode 100644 proto/side/btclightclient/genesis.proto create mode 100644 proto/side/btclightclient/params.proto create mode 100644 proto/side/btclightclient/query.proto create mode 100644 proto/side/btclightclient/tx.proto create mode 100644 x/btclightclient/types/genesis.pb.go create mode 100644 x/btclightclient/types/params.pb.go create mode 100644 x/btclightclient/types/query.pb.go create mode 100644 x/btclightclient/types/query.pb.gw.go create mode 100644 x/btclightclient/types/tx.pb.go diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 8d4b45e0..525f8b4b 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -80,7 +80,6 @@ import ( "github.com/CosmWasm/wasmd/x/wasm" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" - ) const ( @@ -427,10 +426,6 @@ func (appKeepers *AppKeepers) InitNormalKeepers( // wire up x/wasm to IBC // Create static IBC router, add transfer route, then set and seal it -<<<<<<< HEAD - //var ics101WasmStack ibcporttypes.IBCModule -======= ->>>>>>> main ics101WasmStack := wasm.NewIBCHandler(appKeepers.WasmKeeper, appKeepers.IBCKeeper.ChannelKeeper, appKeepers.IBCKeeper.ChannelKeeper) // ics101WasmStack = packetforward.NewIBCMiddleware( // ics101WasmStack, diff --git a/go.sum b/go.sum index 0aaeabf3..f8f4e1b5 100644 --- a/go.sum +++ b/go.sum @@ -973,13 +973,8 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -<<<<<<< HEAD -github.com/sideprotocol/packet-forward-middleware/v7 v7.0.0-20240311071335-a58b48b0a6d6 h1:Uy+xnAR08JEjFm2OO0pOSnLtbkMS5B1XXZmHvXqBYyE= -github.com/sideprotocol/packet-forward-middleware/v7 v7.0.0-20240311071335-a58b48b0a6d6/go.mod h1:/euetAAJE1/s/m6TxGFBLBv1UamUDcIH3Xgn3CJnnKI= -======= github.com/sideprotocol/cosmos-sdk v0.47.116 h1:9qXEko5qj+RVHR5a01dheCjqzw5MlnYqxu36fqJm5MU= github.com/sideprotocol/cosmos-sdk v0.47.116/go.mod h1:Ql8d4j8oRXssuNQfVIaa6LRo7VsFMJgSy2Qckd/dcr0= ->>>>>>> main github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= diff --git a/proto/side/btclightclient/genesis.proto b/proto/side/btclightclient/genesis.proto new file mode 100644 index 00000000..2ee08030 --- /dev/null +++ b/proto/side/btclightclient/genesis.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; +package side.btclightclient; + +import "gogoproto/gogo.proto"; +import "side/btclightclient/params.proto"; + +option go_package = "github.com/sideprotocol/side/x/btclightclient/types"; + +// GenesisState defines the btc light client module's genesis state. +message GenesisState { + Params params = 1 [(gogoproto.nullable) = false]; + repeated BlockHeader block_headers = 2; +} diff --git a/proto/side/btclightclient/params.proto b/proto/side/btclightclient/params.proto new file mode 100644 index 00000000..01a8b0b2 --- /dev/null +++ b/proto/side/btclightclient/params.proto @@ -0,0 +1,24 @@ +syntax = "proto3"; +package side.btclightclient; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/sideprotocol/side/x/btclightclient/types"; + +// Params defines the parameters for the module. +message Params { + // Only accept blocks sending from these addresses + repeated string senders = 1; +} + +// Bitcoin Block Header +message BlockHeader { + string hash = 1; + uint64 height = 2; + string previous_block_hash = 3; + string merkle_root = 4; + uint64 nonce = 5; + string bits = 6; + uint64 time = 7; + uint64 ntx = 8; +} diff --git a/proto/side/btclightclient/query.proto b/proto/side/btclightclient/query.proto new file mode 100644 index 00000000..397eb393 --- /dev/null +++ b/proto/side/btclightclient/query.proto @@ -0,0 +1,67 @@ +syntax = "proto3"; +package side.btclightclient; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "side/btclightclient/params.proto"; + +option go_package = "github.com/sideprotocol/side/x/btclightclient/types"; + +// Query defines the gRPC querier service. +service Query { + // Parameters queries the parameters of the module. + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/sideprotocol/side/btclightclient/params"; + } + // ChainTip queries the chain tip of the module. + rpc GetChainTip(QueryChainTipRequest) returns (GetChainTipResponse) { + option (google.api.http).get = "/sideprotocol/side/btclightclient/tip"; + } + // BlockHeaderByHeight queries the block header by height. + rpc GetBlockHeaderByHeight(QueryBlockHeaderByHeightRequest) returns (GetBlockHeaderByHeightResponse) { + option (google.api.http).get = "/sideprotocol/side/btclightclient/height/{height}"; + } + // BlockHeaderByHash queries the block header by hash. + rpc GetBlockHeaderByHash(QueryBlockHeaderByHashRequest) returns (GetBlockHeaderByHashResponse) { + option (google.api.http).get = "/sideprotocol/side/btclightclient/hash/{hash}"; + } +} + +// QueryParamsRequest is request type for the Query/Params RPC method. +message QueryParamsRequest {} + +// QueryParamsResponse is response type for the Query/Params RPC method. +message QueryParamsResponse { + // params holds all the parameters of this module. + Params params = 1 [(gogoproto.nullable) = false]; +} + +// QueryChainTipRequest is request type for the Query/GetChainTip RPC method. +message QueryChainTipRequest {} + +// QueryChainTipResponse is response type for the Query/GetChainTip RPC method. +message GetChainTipResponse { + string hash = 1; + int64 height = 2; +} + +// QueryBlockHeaderByHeightRequest is the request type for the Query/BlockHeaderByHeight RPC method. +message QueryBlockHeaderByHeightRequest { + int64 height = 1; +} + +// GetBlockHeaderByHeightResponse is the response type for the Query/BlockHeaderByHeight RPC method. +message GetBlockHeaderByHeightResponse { + BlockHeader block_header = 1; +} + +// QueryBlockHeaderByHashRequest is the request type for the Query/BlockHeaderByHash RPC method. +message QueryBlockHeaderByHashRequest { + string hash = 1; +} + +// GetBlockHeaderByHashResponse is the response type for the Query/BlockHeaderByHash RPC method. +message GetBlockHeaderByHashResponse { + BlockHeader block_header = 1; +} diff --git a/proto/side/btclightclient/tx.proto b/proto/side/btclightclient/tx.proto new file mode 100644 index 00000000..029dd243 --- /dev/null +++ b/proto/side/btclightclient/tx.proto @@ -0,0 +1,40 @@ +syntax = "proto3"; + +package side.btclightclient; + +import "gogoproto/gogo.proto"; +import "side/btclightclient/params.proto"; + +option go_package = "github.com/sideprotocol/side/x/btclightclient/types"; + +// Msg defines the Msg service. +service Msg { + // SubmitBlockHeaders submits bitcoin block headers to the side chain. + rpc SubmitBlockHeaders (MsgBlockHeaderRequest) returns (MsgSubmitBlockHeadersResponse); + // UpdateSenders updates the senders of the side chain. + rpc UpdateSenders (MsgUpdateSenderRequest) returns (MsgUpdateSendersResponse); +} + +// MsgBlockHeaderRequest defines the Msg/SubmitBlockHeaders request type. +message MsgBlockHeaderRequest { + string sender = 1; + repeated BlockHeader block_headers = 2; +} + +// MsgSubmitBlockHeadersResponse defines the Msg/SubmitBlockHeaders response type. +message MsgSubmitBlockHeadersResponse { +} + +// Msg defines the MsgUpdateSender service. +message MsgUpdateSenderRequest { + string sender = 1; + // update senders who can send block headers to the side chain + repeated string senders = 2; +} + +// MsgUpdateSenderResponse defines the Msg/UpdateSender response type. +message MsgUpdateSendersResponse { +} + + + diff --git a/x/btclightclient/types/genesis.pb.go b/x/btclightclient/types/genesis.pb.go new file mode 100644 index 00000000..5e95a166 --- /dev/null +++ b/x/btclightclient/types/genesis.pb.go @@ -0,0 +1,385 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: side/btclightclient/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// GenesisState defines the btc light client module's genesis state. +type GenesisState struct { + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + BlockHeaders []*BlockHeader `protobuf:"bytes,2,rep,name=block_headers,json=blockHeaders,proto3" json:"block_headers,omitempty"` +} + +func (m *GenesisState) Reset() { *m = GenesisState{} } +func (m *GenesisState) String() string { return proto.CompactTextString(m) } +func (*GenesisState) ProtoMessage() {} +func (*GenesisState) Descriptor() ([]byte, []int) { + return fileDescriptor_84e124efbd6ad9f4, []int{0} +} +func (m *GenesisState) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { + xxx_messageInfo_GenesisState.Merge(m, src) +} +func (m *GenesisState) XXX_Size() int { + return m.Size() +} +func (m *GenesisState) XXX_DiscardUnknown() { + xxx_messageInfo_GenesisState.DiscardUnknown(m) +} + +var xxx_messageInfo_GenesisState proto.InternalMessageInfo + +func (m *GenesisState) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +func (m *GenesisState) GetBlockHeaders() []*BlockHeader { + if m != nil { + return m.BlockHeaders + } + return nil +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "side.btclightclient.GenesisState") +} + +func init() { proto.RegisterFile("side/btclightclient/genesis.proto", fileDescriptor_84e124efbd6ad9f4) } + +var fileDescriptor_84e124efbd6ad9f4 = []byte{ + // 235 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2c, 0xce, 0x4c, 0x49, + 0xd5, 0x4f, 0x2a, 0x49, 0xce, 0xc9, 0x4c, 0xcf, 0x00, 0x91, 0xa9, 0x79, 0x25, 0xfa, 0xe9, 0xa9, + 0x79, 0xa9, 0xc5, 0x99, 0xc5, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0xc2, 0x20, 0x25, 0x7a, + 0xa8, 0x4a, 0xa4, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0xf2, 0xfa, 0x20, 0x16, 0x44, 0xa9, 0x94, + 0x02, 0x36, 0xd3, 0x0a, 0x12, 0x8b, 0x12, 0x73, 0xa1, 0x86, 0x29, 0x4d, 0x60, 0xe4, 0xe2, 0x71, + 0x87, 0x18, 0x1f, 0x5c, 0x92, 0x58, 0x92, 0x2a, 0x64, 0xc9, 0xc5, 0x06, 0x51, 0x20, 0xc1, 0xa8, + 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xad, 0x87, 0xc5, 0x3a, 0xbd, 0x00, 0xb0, 0x12, 0x27, 0x96, 0x13, + 0xf7, 0xe4, 0x19, 0x82, 0xa0, 0x1a, 0x84, 0x5c, 0xb9, 0x78, 0x93, 0x72, 0xf2, 0x93, 0xb3, 0xe3, + 0x33, 0x52, 0x13, 0x53, 0x52, 0x8b, 0x8a, 0x25, 0x98, 0x14, 0x98, 0x35, 0xb8, 0x8d, 0x14, 0xb0, + 0x9a, 0xe0, 0x04, 0x52, 0xe9, 0x01, 0x56, 0x18, 0xc4, 0x93, 0x84, 0xe0, 0x14, 0x3b, 0xf9, 0x9e, + 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, + 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x71, 0x7a, 0x66, 0x49, 0x46, 0x69, + 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xc8, 0x4c, 0xb0, 0x17, 0x92, 0xf3, 0x73, 0xc0, 0x1c, 0xfd, + 0x0a, 0x74, 0x8f, 0x96, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x55, 0x19, 0x03, 0x02, 0x00, + 0x00, 0xff, 0xff, 0x7b, 0xe8, 0x2f, 0x7a, 0x5a, 0x01, 0x00, 0x00, +} + +func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.BlockHeaders) > 0 { + for iNdEx := len(m.BlockHeaders) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.BlockHeaders[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { + offset -= sovGenesis(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *GenesisState) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovGenesis(uint64(l)) + if len(m.BlockHeaders) > 0 { + for _, e := range m.BlockHeaders { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + return n +} + +func sovGenesis(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGenesis(x uint64) (n int) { + return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *GenesisState) 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 ErrIntOverflowGenesis + } + 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: GenesisState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeaders", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BlockHeaders = append(m.BlockHeaders, &BlockHeader{}) + if err := m.BlockHeaders[len(m.BlockHeaders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGenesis(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowGenesis + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthGenesis + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGenesis + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGenesis + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/btclightclient/types/params.pb.go b/x/btclightclient/types/params.pb.go new file mode 100644 index 00000000..0751ab0b --- /dev/null +++ b/x/btclightclient/types/params.pb.go @@ -0,0 +1,795 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: side/btclightclient/params.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Params defines the parameters for the module. +type Params struct { + // Only accept blocks sending from these addresses + Senders []string `protobuf:"bytes,1,rep,name=senders,proto3" json:"senders,omitempty"` +} + +func (m *Params) Reset() { *m = Params{} } +func (m *Params) String() string { return proto.CompactTextString(m) } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_3b47f8b78acf6f6e, []int{0} +} +func (m *Params) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Params.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 *Params) XXX_Merge(src proto.Message) { + xxx_messageInfo_Params.Merge(m, src) +} +func (m *Params) XXX_Size() int { + return m.Size() +} +func (m *Params) XXX_DiscardUnknown() { + xxx_messageInfo_Params.DiscardUnknown(m) +} + +var xxx_messageInfo_Params proto.InternalMessageInfo + +func (m *Params) GetSenders() []string { + if m != nil { + return m.Senders + } + return nil +} + +// Bitcoin Block Header +type BlockHeader struct { + Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` + Height uint64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` + PreviousBlockHash string `protobuf:"bytes,3,opt,name=previous_block_hash,json=previousBlockHash,proto3" json:"previous_block_hash,omitempty"` + MerkleRoot string `protobuf:"bytes,4,opt,name=merkle_root,json=merkleRoot,proto3" json:"merkle_root,omitempty"` + Nonce uint64 `protobuf:"varint,5,opt,name=nonce,proto3" json:"nonce,omitempty"` + Bits string `protobuf:"bytes,6,opt,name=bits,proto3" json:"bits,omitempty"` + Time uint64 `protobuf:"varint,7,opt,name=time,proto3" json:"time,omitempty"` + Ntx uint64 `protobuf:"varint,8,opt,name=ntx,proto3" json:"ntx,omitempty"` +} + +func (m *BlockHeader) Reset() { *m = BlockHeader{} } +func (m *BlockHeader) String() string { return proto.CompactTextString(m) } +func (*BlockHeader) ProtoMessage() {} +func (*BlockHeader) Descriptor() ([]byte, []int) { + return fileDescriptor_3b47f8b78acf6f6e, []int{1} +} +func (m *BlockHeader) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BlockHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BlockHeader.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 *BlockHeader) XXX_Merge(src proto.Message) { + xxx_messageInfo_BlockHeader.Merge(m, src) +} +func (m *BlockHeader) XXX_Size() int { + return m.Size() +} +func (m *BlockHeader) XXX_DiscardUnknown() { + xxx_messageInfo_BlockHeader.DiscardUnknown(m) +} + +var xxx_messageInfo_BlockHeader proto.InternalMessageInfo + +func (m *BlockHeader) GetHash() string { + if m != nil { + return m.Hash + } + return "" +} + +func (m *BlockHeader) GetHeight() uint64 { + if m != nil { + return m.Height + } + return 0 +} + +func (m *BlockHeader) GetPreviousBlockHash() string { + if m != nil { + return m.PreviousBlockHash + } + return "" +} + +func (m *BlockHeader) GetMerkleRoot() string { + if m != nil { + return m.MerkleRoot + } + return "" +} + +func (m *BlockHeader) GetNonce() uint64 { + if m != nil { + return m.Nonce + } + return 0 +} + +func (m *BlockHeader) GetBits() string { + if m != nil { + return m.Bits + } + return "" +} + +func (m *BlockHeader) GetTime() uint64 { + if m != nil { + return m.Time + } + return 0 +} + +func (m *BlockHeader) GetNtx() uint64 { + if m != nil { + return m.Ntx + } + return 0 +} + +func init() { + proto.RegisterType((*Params)(nil), "side.btclightclient.Params") + proto.RegisterType((*BlockHeader)(nil), "side.btclightclient.BlockHeader") +} + +func init() { proto.RegisterFile("side/btclightclient/params.proto", fileDescriptor_3b47f8b78acf6f6e) } + +var fileDescriptor_3b47f8b78acf6f6e = []byte{ + // 305 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 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0x0f, 0x7c, 0x56, 0x83, + 0xd9, 0x57, 0xb0, 0x35, 0x88, 0x4e, 0x8e, 0x88, 0xe3, 0x7d, 0x28, 0x41, 0x74, 0x62, 0xc1, 0xc7, + 0x0d, 0x36, 0x39, 0xc8, 0x31, 0xcd, 0xe9, 0x8d, 0x5f, 0x29, 0xd3, 0xce, 0xca, 0xa0, 0x5f, 0xc9, + 0x6b, 0x1f, 0x73, 0xba, 0x06, 0x39, 0x21, 0x90, 0xb4, 0xb8, 0xe1, 0xc3, 0xc6, 0x1d, 0xe5, 0x35, + 0x85, 0xbc, 0xdc, 0x3c, 0x7d, 0x9c, 0x15, 0x3b, 0x9d, 0x15, 0xfb, 0x3e, 0x2b, 0xf6, 0xde, 0xa9, + 0xc1, 0xa9, 0x53, 0x83, 0xcf, 0x4e, 0x0d, 0x5e, 0xd6, 0x85, 0x76, 0xe5, 0x21, 0x8b, 0x72, 0xac, + 0x63, 0x7f, 0x50, 0x3a, 0x58, 0x8e, 0x15, 0x99, 0xf8, 0xf8, 0xff, 0x07, 0xdc, 0x5b, 0x0b, 0x36, + 0x0b, 0x88, 0x5a, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x15, 0xd9, 0x5f, 0x9d, 0xa5, 0x01, 0x00, + 0x00, +} + +func (m *Params) 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 *Params) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Senders) > 0 { + for iNdEx := len(m.Senders) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Senders[iNdEx]) + copy(dAtA[i:], m.Senders[iNdEx]) + i = encodeVarintParams(dAtA, i, uint64(len(m.Senders[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *BlockHeader) 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 *BlockHeader) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BlockHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Ntx != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.Ntx)) + i-- + dAtA[i] = 0x40 + } + if m.Time != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.Time)) + i-- + dAtA[i] = 0x38 + } + if len(m.Bits) > 0 { + i -= len(m.Bits) + copy(dAtA[i:], m.Bits) + i = encodeVarintParams(dAtA, i, uint64(len(m.Bits))) + i-- + dAtA[i] = 0x32 + } + if m.Nonce != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.Nonce)) + i-- + dAtA[i] = 0x28 + } + if len(m.MerkleRoot) > 0 { + i -= len(m.MerkleRoot) + copy(dAtA[i:], m.MerkleRoot) + i = encodeVarintParams(dAtA, i, uint64(len(m.MerkleRoot))) + i-- + dAtA[i] = 0x22 + } + if len(m.PreviousBlockHash) > 0 { + i -= len(m.PreviousBlockHash) + copy(dAtA[i:], m.PreviousBlockHash) + i = encodeVarintParams(dAtA, i, uint64(len(m.PreviousBlockHash))) + i-- + dAtA[i] = 0x1a + } + if m.Height != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x10 + } + if len(m.Hash) > 0 { + i -= len(m.Hash) + copy(dAtA[i:], m.Hash) + i = encodeVarintParams(dAtA, i, uint64(len(m.Hash))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintParams(dAtA []byte, offset int, v uint64) int { + offset -= sovParams(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Params) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Senders) > 0 { + for _, s := range m.Senders { + l = len(s) + n += 1 + l + sovParams(uint64(l)) + } + } + return n +} + +func (m *BlockHeader) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Hash) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + if m.Height != 0 { + n += 1 + sovParams(uint64(m.Height)) + } + l = len(m.PreviousBlockHash) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = len(m.MerkleRoot) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + if m.Nonce != 0 { + n += 1 + sovParams(uint64(m.Nonce)) + } + l = len(m.Bits) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + if m.Time != 0 { + n += 1 + sovParams(uint64(m.Time)) + } + if m.Ntx != 0 { + n += 1 + sovParams(uint64(m.Ntx)) + } + return n +} + +func sovParams(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozParams(x uint64) (n int) { + return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Params) 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 ErrIntOverflowParams + } + 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: Params: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Senders", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Senders = append(m.Senders, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *BlockHeader) 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 ErrIntOverflowParams + } + 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: BlockHeader: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BlockHeader: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Hash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PreviousBlockHash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PreviousBlockHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MerkleRoot", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MerkleRoot = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Nonce", wireType) + } + m.Nonce = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Nonce |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bits", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Bits = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Time", wireType) + } + m.Time = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Time |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Ntx", wireType) + } + m.Ntx = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Ntx |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipParams(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowParams + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthParams + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupParams + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthParams + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/btclightclient/types/query.pb.go b/x/btclightclient/types/query.pb.go new file mode 100644 index 00000000..9208a1d5 --- /dev/null +++ b/x/btclightclient/types/query.pb.go @@ -0,0 +1,1678 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: side/btclightclient/query.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-sdk/types/query" + _ "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" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// QueryParamsRequest is request type for the Query/Params RPC method. +type QueryParamsRequest struct { +} + +func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } +func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryParamsRequest) ProtoMessage() {} +func (*QueryParamsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f299b49d16182dbc, []int{0} +} +func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsRequest.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 *QueryParamsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsRequest.Merge(m, src) +} +func (m *QueryParamsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsRequest proto.InternalMessageInfo + +// QueryParamsResponse is response type for the Query/Params RPC method. +type QueryParamsResponse struct { + // params holds all the parameters of this module. + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` +} + +func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } +func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryParamsResponse) ProtoMessage() {} +func (*QueryParamsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f299b49d16182dbc, []int{1} +} +func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryParamsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryParamsResponse.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 *QueryParamsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryParamsResponse.Merge(m, src) +} +func (m *QueryParamsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryParamsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryParamsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryParamsResponse proto.InternalMessageInfo + +func (m *QueryParamsResponse) GetParams() Params { + if m != nil { + return m.Params + } + return Params{} +} + +// QueryChainTipRequest is request type for the Query/GetChainTip RPC method. +type QueryChainTipRequest struct { +} + +func (m *QueryChainTipRequest) Reset() { *m = QueryChainTipRequest{} } +func (m *QueryChainTipRequest) String() string { return proto.CompactTextString(m) } +func (*QueryChainTipRequest) ProtoMessage() {} +func (*QueryChainTipRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f299b49d16182dbc, []int{2} +} +func (m *QueryChainTipRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryChainTipRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryChainTipRequest.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 *QueryChainTipRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryChainTipRequest.Merge(m, src) +} +func (m *QueryChainTipRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryChainTipRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryChainTipRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryChainTipRequest proto.InternalMessageInfo + +// QueryChainTipResponse is response type for the Query/GetChainTip RPC method. +type GetChainTipResponse struct { + Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` + Height int64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` +} + +func (m *GetChainTipResponse) Reset() { *m = GetChainTipResponse{} } +func (m *GetChainTipResponse) String() string { return proto.CompactTextString(m) } +func (*GetChainTipResponse) ProtoMessage() {} +func (*GetChainTipResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f299b49d16182dbc, []int{3} +} +func (m *GetChainTipResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetChainTipResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetChainTipResponse.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 *GetChainTipResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetChainTipResponse.Merge(m, src) +} +func (m *GetChainTipResponse) XXX_Size() int { + return m.Size() +} +func (m *GetChainTipResponse) XXX_DiscardUnknown() { + xxx_messageInfo_GetChainTipResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_GetChainTipResponse proto.InternalMessageInfo + +func (m *GetChainTipResponse) GetHash() string { + if m != nil { + return m.Hash + } + return "" +} + +func (m *GetChainTipResponse) GetHeight() int64 { + if m != nil { + return m.Height + } + return 0 +} + +// QueryBlockHeaderByHeightRequest is the request type for the Query/BlockHeaderByHeight RPC method. +type QueryBlockHeaderByHeightRequest struct { + Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` +} + +func (m *QueryBlockHeaderByHeightRequest) Reset() { *m = QueryBlockHeaderByHeightRequest{} } +func (m *QueryBlockHeaderByHeightRequest) String() string { return proto.CompactTextString(m) } +func (*QueryBlockHeaderByHeightRequest) ProtoMessage() {} +func (*QueryBlockHeaderByHeightRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f299b49d16182dbc, []int{4} +} +func (m *QueryBlockHeaderByHeightRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryBlockHeaderByHeightRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryBlockHeaderByHeightRequest.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 *QueryBlockHeaderByHeightRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBlockHeaderByHeightRequest.Merge(m, src) +} +func (m *QueryBlockHeaderByHeightRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryBlockHeaderByHeightRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBlockHeaderByHeightRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryBlockHeaderByHeightRequest proto.InternalMessageInfo + +func (m *QueryBlockHeaderByHeightRequest) GetHeight() int64 { + if m != nil { + return m.Height + } + return 0 +} + +// GetBlockHeaderByHeightResponse is the response type for the Query/BlockHeaderByHeight RPC method. +type GetBlockHeaderByHeightResponse struct { + BlockHeader *BlockHeader `protobuf:"bytes,1,opt,name=block_header,json=blockHeader,proto3" json:"block_header,omitempty"` +} + +func (m *GetBlockHeaderByHeightResponse) Reset() { *m = GetBlockHeaderByHeightResponse{} } +func (m *GetBlockHeaderByHeightResponse) String() string { return proto.CompactTextString(m) } +func (*GetBlockHeaderByHeightResponse) ProtoMessage() {} +func (*GetBlockHeaderByHeightResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f299b49d16182dbc, []int{5} +} +func (m *GetBlockHeaderByHeightResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetBlockHeaderByHeightResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetBlockHeaderByHeightResponse.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 *GetBlockHeaderByHeightResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetBlockHeaderByHeightResponse.Merge(m, src) +} +func (m *GetBlockHeaderByHeightResponse) XXX_Size() int { + return m.Size() +} +func (m *GetBlockHeaderByHeightResponse) XXX_DiscardUnknown() { + xxx_messageInfo_GetBlockHeaderByHeightResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_GetBlockHeaderByHeightResponse proto.InternalMessageInfo + +func (m *GetBlockHeaderByHeightResponse) GetBlockHeader() *BlockHeader { + if m != nil { + return m.BlockHeader + } + return nil +} + +// QueryBlockHeaderByHashRequest is the request type for the Query/BlockHeaderByHash RPC method. +type QueryBlockHeaderByHashRequest struct { + Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` +} + +func (m *QueryBlockHeaderByHashRequest) Reset() { *m = QueryBlockHeaderByHashRequest{} } +func (m *QueryBlockHeaderByHashRequest) String() string { return proto.CompactTextString(m) } +func (*QueryBlockHeaderByHashRequest) ProtoMessage() {} +func (*QueryBlockHeaderByHashRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f299b49d16182dbc, []int{6} +} +func (m *QueryBlockHeaderByHashRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryBlockHeaderByHashRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryBlockHeaderByHashRequest.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 *QueryBlockHeaderByHashRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBlockHeaderByHashRequest.Merge(m, src) +} +func (m *QueryBlockHeaderByHashRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryBlockHeaderByHashRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBlockHeaderByHashRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryBlockHeaderByHashRequest proto.InternalMessageInfo + +func (m *QueryBlockHeaderByHashRequest) GetHash() string { + if m != nil { + return m.Hash + } + return "" +} + +// GetBlockHeaderByHashResponse is the response type for the Query/BlockHeaderByHash RPC method. +type GetBlockHeaderByHashResponse struct { + BlockHeader *BlockHeader `protobuf:"bytes,1,opt,name=block_header,json=blockHeader,proto3" json:"block_header,omitempty"` +} + +func (m *GetBlockHeaderByHashResponse) Reset() { *m = GetBlockHeaderByHashResponse{} } +func (m *GetBlockHeaderByHashResponse) String() string { return proto.CompactTextString(m) } +func (*GetBlockHeaderByHashResponse) ProtoMessage() {} +func (*GetBlockHeaderByHashResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f299b49d16182dbc, []int{7} +} +func (m *GetBlockHeaderByHashResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetBlockHeaderByHashResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetBlockHeaderByHashResponse.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 *GetBlockHeaderByHashResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetBlockHeaderByHashResponse.Merge(m, src) +} +func (m *GetBlockHeaderByHashResponse) XXX_Size() int { + return m.Size() +} +func (m *GetBlockHeaderByHashResponse) XXX_DiscardUnknown() { + xxx_messageInfo_GetBlockHeaderByHashResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_GetBlockHeaderByHashResponse proto.InternalMessageInfo + +func (m *GetBlockHeaderByHashResponse) GetBlockHeader() *BlockHeader { + if m != nil { + return m.BlockHeader + } + return nil +} + +func init() { + proto.RegisterType((*QueryParamsRequest)(nil), "side.btclightclient.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "side.btclightclient.QueryParamsResponse") + proto.RegisterType((*QueryChainTipRequest)(nil), "side.btclightclient.QueryChainTipRequest") + proto.RegisterType((*GetChainTipResponse)(nil), "side.btclightclient.GetChainTipResponse") + proto.RegisterType((*QueryBlockHeaderByHeightRequest)(nil), "side.btclightclient.QueryBlockHeaderByHeightRequest") + proto.RegisterType((*GetBlockHeaderByHeightResponse)(nil), "side.btclightclient.GetBlockHeaderByHeightResponse") + proto.RegisterType((*QueryBlockHeaderByHashRequest)(nil), "side.btclightclient.QueryBlockHeaderByHashRequest") + proto.RegisterType((*GetBlockHeaderByHashResponse)(nil), "side.btclightclient.GetBlockHeaderByHashResponse") +} + +func init() { proto.RegisterFile("side/btclightclient/query.proto", fileDescriptor_f299b49d16182dbc) } + +var fileDescriptor_f299b49d16182dbc = []byte{ + // 540 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x92, 0x3f, 0x6f, 0xd3, 0x40, + 0x18, 0xc6, 0x73, 0xa5, 0x8d, 0xc4, 0x5b, 0xa6, 0x4b, 0x14, 0x55, 0xa6, 0x38, 0xd1, 0x49, 0xa8, + 0xa1, 0x52, 0x7d, 0x24, 0x86, 0x21, 0x23, 0xe9, 0xd0, 0x2e, 0x48, 0xc5, 0x62, 0x62, 0x41, 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70, 0x3d, 0x96, 0x8a, + 0x53, 0xfc, 0x0d, 0x41, 0xc3, 0x9c, 0x17, 0xfc, 0xa4, 0x1c, 0xaf, 0x3c, 0x97, 0x96, 0x5b, 0x46, + 0xfa, 0x8f, 0x48, 0x92, 0x9e, 0x86, 0x76, 0x71, 0x67, 0x3d, 0x74, 0x1e, 0x73, 0x7a, 0x99, 0xbf, + 0xaf, 0xf0, 0x57, 0x04, 0x75, 0x53, 0xa8, 0x70, 0x77, 0x53, 0xfc, 0x79, 0x68, 0xad, 0xce, 0x66, + 0xf0, 0x0b, 0x99, 0x25, 0x4f, 0x35, 0x3a, 0xc5, 0x47, 0x1b, 0xa0, 0x33, 0x19, 0xd1, 0xcb, 0xec, + 0x79, 0xd5, 0x7f, 0x7e, 0x3d, 0xb5, 0xd1, 0xcd, 0xd4, 0x46, 0xbf, 0xa6, 0x36, 0xfa, 0x38, 0xb3, + 0x2b, 0x37, 0x33, 0xbb, 0xf2, 0x63, 0x66, 0x57, 0x5e, 0xb9, 0x61, 0xac, 0xa2, 0xb1, 0xef, 0x04, + 0x62, 0x68, 0x18, 0xf9, 0x6e, 0xe5, 0x12, 0x27, 0x29, 0x97, 0x7e, 0x55, 0x77, 0xb9, 0x7f, 0x02, + 0x00, 0x00, 0xff, 0xff, 0x41, 0xdf, 0x19, 0xc1, 0xb4, 0x05, 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 + +// QueryClient is the client API for Query service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type QueryClient interface { + // Parameters queries the parameters of the module. + Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // ChainTip queries the chain tip of the module. + GetChainTip(ctx context.Context, in *QueryChainTipRequest, opts ...grpc.CallOption) (*GetChainTipResponse, error) + // BlockHeaderByHeight queries the block header by height. + GetBlockHeaderByHeight(ctx context.Context, in *QueryBlockHeaderByHeightRequest, opts ...grpc.CallOption) (*GetBlockHeaderByHeightResponse, error) + // BlockHeaderByHash queries the block header by hash. + GetBlockHeaderByHash(ctx context.Context, in *QueryBlockHeaderByHashRequest, opts ...grpc.CallOption) (*GetBlockHeaderByHashResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { + out := new(QueryParamsResponse) + err := c.cc.Invoke(ctx, "/side.btclightclient.Query/Params", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) GetChainTip(ctx context.Context, in *QueryChainTipRequest, opts ...grpc.CallOption) (*GetChainTipResponse, error) { + out := new(GetChainTipResponse) + err := c.cc.Invoke(ctx, "/side.btclightclient.Query/GetChainTip", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) GetBlockHeaderByHeight(ctx context.Context, in *QueryBlockHeaderByHeightRequest, opts ...grpc.CallOption) (*GetBlockHeaderByHeightResponse, error) { + out := new(GetBlockHeaderByHeightResponse) + err := c.cc.Invoke(ctx, "/side.btclightclient.Query/GetBlockHeaderByHeight", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) GetBlockHeaderByHash(ctx context.Context, in *QueryBlockHeaderByHashRequest, opts ...grpc.CallOption) (*GetBlockHeaderByHashResponse, error) { + out := new(GetBlockHeaderByHashResponse) + err := c.cc.Invoke(ctx, "/side.btclightclient.Query/GetBlockHeaderByHash", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // Parameters queries the parameters of the module. + Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + // ChainTip queries the chain tip of the module. + GetChainTip(context.Context, *QueryChainTipRequest) (*GetChainTipResponse, error) + // BlockHeaderByHeight queries the block header by height. + GetBlockHeaderByHeight(context.Context, *QueryBlockHeaderByHeightRequest) (*GetBlockHeaderByHeightResponse, error) + // BlockHeaderByHash queries the block header by hash. + GetBlockHeaderByHash(context.Context, *QueryBlockHeaderByHashRequest) (*GetBlockHeaderByHashResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +} +func (*UnimplementedQueryServer) GetChainTip(ctx context.Context, req *QueryChainTipRequest) (*GetChainTipResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetChainTip not implemented") +} +func (*UnimplementedQueryServer) GetBlockHeaderByHeight(ctx context.Context, req *QueryBlockHeaderByHeightRequest) (*GetBlockHeaderByHeightResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetBlockHeaderByHeight not implemented") +} +func (*UnimplementedQueryServer) GetBlockHeaderByHash(ctx context.Context, req *QueryBlockHeaderByHashRequest) (*GetBlockHeaderByHashResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetBlockHeaderByHash not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryParamsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Params(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/side.btclightclient.Query/Params", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_GetChainTip_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryChainTipRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetChainTip(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/side.btclightclient.Query/GetChainTip", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetChainTip(ctx, req.(*QueryChainTipRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_GetBlockHeaderByHeight_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryBlockHeaderByHeightRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetBlockHeaderByHeight(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/side.btclightclient.Query/GetBlockHeaderByHeight", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetBlockHeaderByHeight(ctx, req.(*QueryBlockHeaderByHeightRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_GetBlockHeaderByHash_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryBlockHeaderByHashRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetBlockHeaderByHash(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/side.btclightclient.Query/GetBlockHeaderByHash", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetBlockHeaderByHash(ctx, req.(*QueryBlockHeaderByHashRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "side.btclightclient.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + { + MethodName: "GetChainTip", + Handler: _Query_GetChainTip_Handler, + }, + { + MethodName: "GetBlockHeaderByHeight", + Handler: _Query_GetBlockHeaderByHeight_Handler, + }, + { + MethodName: "GetBlockHeaderByHash", + Handler: _Query_GetBlockHeaderByHash_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "side/btclightclient/query.proto", +} + +func (m *QueryParamsRequest) 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 *QueryParamsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryParamsResponse) 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 *QueryParamsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + +func (m *QueryChainTipRequest) 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 *QueryChainTipRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryChainTipRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *GetChainTipResponse) 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 *GetChainTipResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GetChainTipResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Height != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x10 + } + if len(m.Hash) > 0 { + i -= len(m.Hash) + copy(dAtA[i:], m.Hash) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Hash))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryBlockHeaderByHeightRequest) 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 *QueryBlockHeaderByHeightRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryBlockHeaderByHeightRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Height != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *GetBlockHeaderByHeightResponse) 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 *GetBlockHeaderByHeightResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GetBlockHeaderByHeightResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.BlockHeader != nil { + { + size, err := m.BlockHeader.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryBlockHeaderByHashRequest) 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 *QueryBlockHeaderByHashRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryBlockHeaderByHashRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Hash) > 0 { + i -= len(m.Hash) + copy(dAtA[i:], m.Hash) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Hash))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *GetBlockHeaderByHashResponse) 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 *GetBlockHeaderByHashResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GetBlockHeaderByHashResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.BlockHeader != nil { + { + size, err := m.BlockHeader.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { + offset -= sovQuery(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *QueryParamsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryParamsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.Params.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryChainTipRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *GetChainTipResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Hash) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + return n +} + +func (m *QueryBlockHeaderByHeightRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Height != 0 { + n += 1 + sovQuery(uint64(m.Height)) + } + return n +} + +func (m *GetBlockHeaderByHeightResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BlockHeader != nil { + l = m.BlockHeader.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryBlockHeaderByHashRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Hash) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *GetBlockHeaderByHashResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.BlockHeader != nil { + l = m.BlockHeader.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozQuery(x uint64) (n int) { + return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *QueryParamsRequest) 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 ErrIntOverflowQuery + } + 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: QueryParamsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryParamsResponse) 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 ErrIntOverflowQuery + } + 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: QueryParamsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryChainTipRequest) 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 ErrIntOverflowQuery + } + 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: QueryChainTipRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryChainTipRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GetChainTipResponse) 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 ErrIntOverflowQuery + } + 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: GetChainTipResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetChainTipResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Hash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryBlockHeaderByHeightRequest) 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 ErrIntOverflowQuery + } + 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: QueryBlockHeaderByHeightRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryBlockHeaderByHeightRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GetBlockHeaderByHeightResponse) 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 ErrIntOverflowQuery + } + 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: GetBlockHeaderByHeightResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetBlockHeaderByHeightResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeader", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.BlockHeader == nil { + m.BlockHeader = &BlockHeader{} + } + if err := m.BlockHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryBlockHeaderByHashRequest) 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 ErrIntOverflowQuery + } + 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: QueryBlockHeaderByHashRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryBlockHeaderByHashRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Hash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GetBlockHeaderByHashResponse) 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 ErrIntOverflowQuery + } + 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: GetBlockHeaderByHashResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetBlockHeaderByHashResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeader", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.BlockHeader == nil { + m.BlockHeader = &BlockHeader{} + } + if err := m.BlockHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipQuery(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowQuery + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthQuery + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupQuery + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthQuery + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/btclightclient/types/query.pb.gw.go b/x/btclightclient/types/query.pb.gw.go new file mode 100644 index 00000000..0317933c --- /dev/null +++ b/x/btclightclient/types/query.pb.gw.go @@ -0,0 +1,420 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: side/btclightclient/query.proto + +/* +Package types is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package types + +import ( + "context" + "io" + "net/http" + + "github.com/golang/protobuf/descriptor" + "github.com/golang/protobuf/proto" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/grpc-ecosystem/grpc-gateway/utilities" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +// Suppress "imported and not used" errors +var _ codes.Code +var _ io.Reader +var _ status.Status +var _ = runtime.String +var _ = utilities.NewDoubleArray +var _ = descriptor.ForMessage +var _ = metadata.Join + +func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryParamsRequest + var metadata runtime.ServerMetadata + + msg, err := server.Params(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_GetChainTip_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryChainTipRequest + var metadata runtime.ServerMetadata + + msg, err := client.GetChainTip(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GetChainTip_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryChainTipRequest + var metadata runtime.ServerMetadata + + msg, err := server.GetChainTip(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_GetBlockHeaderByHeight_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryBlockHeaderByHeightRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["height"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") + } + + protoReq.Height, err = runtime.Int64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) + } + + msg, err := client.GetBlockHeaderByHeight(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GetBlockHeaderByHeight_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryBlockHeaderByHeightRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["height"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") + } + + protoReq.Height, err = runtime.Int64(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) + } + + msg, err := server.GetBlockHeaderByHeight(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_GetBlockHeaderByHash_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryBlockHeaderByHashRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["hash"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "hash") + } + + protoReq.Hash, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "hash", err) + } + + msg, err := client.GetBlockHeaderByHash(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GetBlockHeaderByHash_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryBlockHeaderByHashRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["hash"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "hash") + } + + protoReq.Hash, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "hash", err) + } + + msg, err := server.GetBlockHeaderByHash(ctx, &protoReq) + return msg, metadata, err + +} + +// RegisterQueryHandlerServer registers the http handlers for service Query to "mux". +// UnaryRPC :call QueryServer directly. +// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetChainTip_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_GetChainTip_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetChainTip_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetBlockHeaderByHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_GetBlockHeaderByHeight_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetBlockHeaderByHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetBlockHeaderByHash_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_GetBlockHeaderByHash_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetBlockHeaderByHash_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { + conn, err := grpc.Dial(endpoint, opts...) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterQueryHandler(ctx, mux, conn) +} + +// RegisterQueryHandler registers the http handlers for service Query to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) +} + +// RegisterQueryHandlerClient registers the http handlers for service Query +// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". +// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" +// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in +// "QueryClient" to call the correct interceptors. +func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { + + mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetChainTip_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_GetChainTip_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetChainTip_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetBlockHeaderByHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_GetBlockHeaderByHeight_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetBlockHeaderByHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetBlockHeaderByHash_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_GetBlockHeaderByHash_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_GetBlockHeaderByHash_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sideprotocol", "side", "btclightclient", "params"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_GetChainTip_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sideprotocol", "side", "btclightclient", "tip"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_GetBlockHeaderByHeight_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 3}, []string{"sideprotocol", "side", "btclightclient", "height"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_GetBlockHeaderByHash_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 3}, []string{"sideprotocol", "side", "btclightclient", "hash"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_GetChainTip_0 = runtime.ForwardResponseMessage + + forward_Query_GetBlockHeaderByHeight_0 = runtime.ForwardResponseMessage + + forward_Query_GetBlockHeaderByHash_0 = runtime.ForwardResponseMessage +) diff --git a/x/btclightclient/types/tx.pb.go b/x/btclightclient/types/tx.pb.go new file mode 100644 index 00000000..ad2d1645 --- /dev/null +++ b/x/btclightclient/types/tx.pb.go @@ -0,0 +1,981 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: side/btclightclient/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + 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" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// MsgBlockHeaderRequest defines the Msg/SubmitBlockHeaders request type. +type MsgBlockHeaderRequest struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + BlockHeaders []*BlockHeader `protobuf:"bytes,2,rep,name=block_headers,json=blockHeaders,proto3" json:"block_headers,omitempty"` +} + +func (m *MsgBlockHeaderRequest) Reset() { *m = MsgBlockHeaderRequest{} } +func (m *MsgBlockHeaderRequest) String() string { return proto.CompactTextString(m) } +func (*MsgBlockHeaderRequest) ProtoMessage() {} +func (*MsgBlockHeaderRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4df07798138ba91c, []int{0} +} +func (m *MsgBlockHeaderRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgBlockHeaderRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgBlockHeaderRequest.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 *MsgBlockHeaderRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgBlockHeaderRequest.Merge(m, src) +} +func (m *MsgBlockHeaderRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgBlockHeaderRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgBlockHeaderRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgBlockHeaderRequest proto.InternalMessageInfo + +func (m *MsgBlockHeaderRequest) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgBlockHeaderRequest) GetBlockHeaders() []*BlockHeader { + if m != nil { + return m.BlockHeaders + } + return nil +} + +// MsgSubmitBlockHeadersResponse defines the Msg/SubmitBlockHeaders response type. +type MsgSubmitBlockHeadersResponse struct { +} + +func (m *MsgSubmitBlockHeadersResponse) Reset() { *m = MsgSubmitBlockHeadersResponse{} } +func (m *MsgSubmitBlockHeadersResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSubmitBlockHeadersResponse) ProtoMessage() {} +func (*MsgSubmitBlockHeadersResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4df07798138ba91c, []int{1} +} +func (m *MsgSubmitBlockHeadersResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSubmitBlockHeadersResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSubmitBlockHeadersResponse.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 *MsgSubmitBlockHeadersResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSubmitBlockHeadersResponse.Merge(m, src) +} +func (m *MsgSubmitBlockHeadersResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSubmitBlockHeadersResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSubmitBlockHeadersResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSubmitBlockHeadersResponse proto.InternalMessageInfo + +// Msg defines the MsgUpdateSender service. +type MsgUpdateSenderRequest struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + // update senders who can send block headers to the side chain + Senders []string `protobuf:"bytes,2,rep,name=senders,proto3" json:"senders,omitempty"` +} + +func (m *MsgUpdateSenderRequest) Reset() { *m = MsgUpdateSenderRequest{} } +func (m *MsgUpdateSenderRequest) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateSenderRequest) ProtoMessage() {} +func (*MsgUpdateSenderRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4df07798138ba91c, []int{2} +} +func (m *MsgUpdateSenderRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateSenderRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateSenderRequest.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 *MsgUpdateSenderRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateSenderRequest.Merge(m, src) +} +func (m *MsgUpdateSenderRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateSenderRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateSenderRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateSenderRequest proto.InternalMessageInfo + +func (m *MsgUpdateSenderRequest) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgUpdateSenderRequest) GetSenders() []string { + if m != nil { + return m.Senders + } + return nil +} + +// MsgUpdateSenderResponse defines the Msg/UpdateSender response type. +type MsgUpdateSendersResponse struct { +} + +func (m *MsgUpdateSendersResponse) Reset() { *m = MsgUpdateSendersResponse{} } +func (m *MsgUpdateSendersResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateSendersResponse) ProtoMessage() {} +func (*MsgUpdateSendersResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4df07798138ba91c, []int{3} +} +func (m *MsgUpdateSendersResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateSendersResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateSendersResponse.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 *MsgUpdateSendersResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateSendersResponse.Merge(m, src) +} +func (m *MsgUpdateSendersResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateSendersResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateSendersResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateSendersResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgBlockHeaderRequest)(nil), "side.btclightclient.MsgBlockHeaderRequest") + proto.RegisterType((*MsgSubmitBlockHeadersResponse)(nil), "side.btclightclient.MsgSubmitBlockHeadersResponse") + proto.RegisterType((*MsgUpdateSenderRequest)(nil), "side.btclightclient.MsgUpdateSenderRequest") + proto.RegisterType((*MsgUpdateSendersResponse)(nil), "side.btclightclient.MsgUpdateSendersResponse") +} + +func init() { proto.RegisterFile("side/btclightclient/tx.proto", fileDescriptor_4df07798138ba91c) } + +var fileDescriptor_4df07798138ba91c = []byte{ + // 330 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xcf, 0x4a, 0xc3, 0x40, + 0x10, 0xc6, 0x1b, 0x0b, 0x95, 0xae, 0xf6, 0xb2, 0x6a, 0x09, 0x41, 0xd7, 0x90, 0x53, 0x51, 0x4c, + 0xa0, 0x7d, 0x83, 0x82, 0x20, 0x42, 0x2e, 0x29, 0x5e, 0xbc, 0x48, 0x36, 0x19, 0xb6, 0xa1, 0x7f, + 0x36, 0x66, 0xb6, 0x52, 0xdf, 0xc2, 0xc7, 0xf2, 0xd8, 0xa3, 0x47, 0x69, 0x2f, 0x3e, 0x86, 0x64, + 0xa3, 0xb5, 0xb5, 0x09, 0x7a, 0x59, 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0x8b, 0x5e, + 0x56, 0x99, 0x94, 0x6c, 0xc2, 0xba, 0xfa, 0x0f, 0xbc, 0x6e, 0xd6, 0xf7, 0x5f, 0x97, 0xcc, 0x58, + 0x2c, 0x99, 0xf1, 0xbe, 0x64, 0xc6, 0xcb, 0x8a, 0xd5, 0x16, 0x2b, 0x56, 0x7b, 0x5b, 0xb1, 0xda, + 0x7d, 0x4f, 0x24, 0x6a, 0x38, 0xe3, 0x6e, 0x24, 0x27, 0x5e, 0x6e, 0xa9, 0x6f, 0x23, 0x92, 0x63, + 0x2d, 0xbc, 0xf9, 0xce, 0x29, 0x3e, 0xa7, 0x80, 0xbc, 0xa1, 0xa9, 0xde, 0x67, 0x00, 0x00, 0x00, + 0xff, 0xff, 0xe7, 0x2a, 0x56, 0x30, 0xae, 0x02, 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 { + // SubmitBlockHeaders submits bitcoin block headers to the side chain. + SubmitBlockHeaders(ctx context.Context, in *MsgBlockHeaderRequest, opts ...grpc.CallOption) (*MsgSubmitBlockHeadersResponse, error) + // UpdateSenders updates the senders of the side chain. + UpdateSenders(ctx context.Context, in *MsgUpdateSenderRequest, opts ...grpc.CallOption) (*MsgUpdateSendersResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) SubmitBlockHeaders(ctx context.Context, in *MsgBlockHeaderRequest, opts ...grpc.CallOption) (*MsgSubmitBlockHeadersResponse, error) { + out := new(MsgSubmitBlockHeadersResponse) + err := c.cc.Invoke(ctx, "/side.btclightclient.Msg/SubmitBlockHeaders", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateSenders(ctx context.Context, in *MsgUpdateSenderRequest, opts ...grpc.CallOption) (*MsgUpdateSendersResponse, error) { + out := new(MsgUpdateSendersResponse) + err := c.cc.Invoke(ctx, "/side.btclightclient.Msg/UpdateSenders", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // SubmitBlockHeaders submits bitcoin block headers to the side chain. + SubmitBlockHeaders(context.Context, *MsgBlockHeaderRequest) (*MsgSubmitBlockHeadersResponse, error) + // UpdateSenders updates the senders of the side chain. + UpdateSenders(context.Context, *MsgUpdateSenderRequest) (*MsgUpdateSendersResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) SubmitBlockHeaders(ctx context.Context, req *MsgBlockHeaderRequest) (*MsgSubmitBlockHeadersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SubmitBlockHeaders not implemented") +} +func (*UnimplementedMsgServer) UpdateSenders(ctx context.Context, req *MsgUpdateSenderRequest) (*MsgUpdateSendersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateSenders not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_SubmitBlockHeaders_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgBlockHeaderRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SubmitBlockHeaders(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/side.btclightclient.Msg/SubmitBlockHeaders", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SubmitBlockHeaders(ctx, req.(*MsgBlockHeaderRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateSenders_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateSenderRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateSenders(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/side.btclightclient.Msg/UpdateSenders", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateSenders(ctx, req.(*MsgUpdateSenderRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "side.btclightclient.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "SubmitBlockHeaders", + Handler: _Msg_SubmitBlockHeaders_Handler, + }, + { + MethodName: "UpdateSenders", + Handler: _Msg_UpdateSenders_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "side/btclightclient/tx.proto", +} + +func (m *MsgBlockHeaderRequest) 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 *MsgBlockHeaderRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgBlockHeaderRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.BlockHeaders) > 0 { + for iNdEx := len(m.BlockHeaders) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.BlockHeaders[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSubmitBlockHeadersResponse) 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 *MsgSubmitBlockHeadersResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSubmitBlockHeadersResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpdateSenderRequest) 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 *MsgUpdateSenderRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateSenderRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Senders) > 0 { + for iNdEx := len(m.Senders) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Senders[iNdEx]) + copy(dAtA[i:], m.Senders[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Senders[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateSendersResponse) 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 *MsgUpdateSendersResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateSendersResponse) 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 + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgBlockHeaderRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.BlockHeaders) > 0 { + for _, e := range m.BlockHeaders { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgSubmitBlockHeadersResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgUpdateSenderRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Senders) > 0 { + for _, s := range m.Senders { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgUpdateSendersResponse) 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 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgBlockHeaderRequest) 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: MsgBlockHeaderRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgBlockHeaderRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeaders", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BlockHeaders = append(m.BlockHeaders, &BlockHeader{}) + if err := m.BlockHeaders[len(m.BlockHeaders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + 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 *MsgSubmitBlockHeadersResponse) 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: MsgSubmitBlockHeadersResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSubmitBlockHeadersResponse: 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 (m *MsgUpdateSenderRequest) 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: MsgUpdateSenderRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateSenderRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Senders", 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.Senders = append(m.Senders, 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 *MsgUpdateSendersResponse) 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: MsgUpdateSendersResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateSendersResponse: 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 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTx + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) From 1d8c567a595dba87527b414d02bdf674cfeaae84 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Sat, 11 May 2024 15:47:16 +0800 Subject: [PATCH 05/71] complete bitcoin light client --- go.mod | 4 +- proto/side/btclightclient/genesis.proto | 4 +- proto/side/btclightclient/params.proto | 17 +- proto/side/btclightclient/query.proto | 26 +- proto/side/btclightclient/tx.proto | 8 +- testutil/keeper/btc_light_client.go | 46 +++ x/btclightclient/client/cli/query.go | 87 +++++ x/btclightclient/client/cli/tx.go | 125 +++++++ x/btclightclient/genesis.go | 30 ++ x/btclightclient/genesis_test.go | 29 ++ x/btclightclient/keeper/event.go | 24 ++ x/btclightclient/keeper/keeper.go | 169 +++++++++ x/btclightclient/keeper/msg_server.go | 72 ++++ x/btclightclient/keeper/queries.go | 64 ++++ x/btclightclient/keeper/util.go | 35 ++ x/btclightclient/module.go | 145 ++++++++ x/btclightclient/module_simulation.go | 1 + x/btclightclient/types/codec.go | 31 ++ x/btclightclient/types/errors.go | 17 + x/btclightclient/types/expected_keepers.go | 12 + x/btclightclient/types/genesis.go | 21 ++ x/btclightclient/types/genesis.pb.go | 88 ++++- x/btclightclient/types/keys.go | 43 +++ .../types/message_submit_headers.go | 52 +++ .../types/message_update_senders.go | 59 ++++ x/btclightclient/types/params.go | 36 ++ x/btclightclient/types/params.pb.go | 123 ++++--- x/btclightclient/types/query.pb.go | 328 +++++++++--------- x/btclightclient/types/query.pb.gw.go | 100 +++--- x/btclightclient/types/tx.pb.go | 164 ++++----- 30 files changed, 1579 insertions(+), 381 deletions(-) create mode 100644 testutil/keeper/btc_light_client.go create mode 100644 x/btclightclient/client/cli/query.go create mode 100644 x/btclightclient/client/cli/tx.go create mode 100644 x/btclightclient/genesis.go create mode 100644 x/btclightclient/genesis_test.go create mode 100644 x/btclightclient/keeper/event.go create mode 100644 x/btclightclient/keeper/keeper.go create mode 100644 x/btclightclient/keeper/msg_server.go create mode 100644 x/btclightclient/keeper/queries.go create mode 100644 x/btclightclient/keeper/util.go create mode 100644 x/btclightclient/module.go create mode 100644 x/btclightclient/module_simulation.go create mode 100644 x/btclightclient/types/codec.go create mode 100644 x/btclightclient/types/errors.go create mode 100644 x/btclightclient/types/expected_keepers.go create mode 100644 x/btclightclient/types/genesis.go create mode 100644 x/btclightclient/types/keys.go create mode 100644 x/btclightclient/types/message_submit_headers.go create mode 100644 x/btclightclient/types/message_update_senders.go create mode 100644 x/btclightclient/types/params.go diff --git a/go.mod b/go.mod index 59e9f3eb..96b995bc 100644 --- a/go.mod +++ b/go.mod @@ -40,10 +40,8 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect - github.com/btcsuite/btcd v0.24.1-0.20240318151728-2fc99e0496d2 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect github.com/btcsuite/btcd/btcutil v1.1.5 // indirect - github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 // indirect github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f // indirect github.com/bufbuild/connect-go v1.0.0 // indirect github.com/bufbuild/protocompile v0.8.0 // indirect @@ -216,6 +214,8 @@ require ( github.com/CosmWasm/wasmd v0.45.0 github.com/CosmWasm/wasmvm v1.5.2 github.com/Stride-Labs/stride/v16 v16.0.0 + github.com/btcsuite/btcd v0.24.1-0.20240318151728-2fc99e0496d2 + github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 github.com/bufbuild/buf v1.7.0 github.com/cosmos/cosmos-proto v1.0.0-beta.4 github.com/cosmos/ics23/go v0.10.0 diff --git a/proto/side/btclightclient/genesis.proto b/proto/side/btclightclient/genesis.proto index 2ee08030..0253649e 100644 --- a/proto/side/btclightclient/genesis.proto +++ b/proto/side/btclightclient/genesis.proto @@ -9,5 +9,7 @@ option go_package = "github.com/sideprotocol/side/x/btclightclient/types"; // GenesisState defines the btc light client module's genesis state. message GenesisState { Params params = 1 [(gogoproto.nullable) = false]; - repeated BlockHeader block_headers = 2; + // the chain tip of the bitcoin chain + BlockHeader best_block_header = 2; + repeated BlockHeader block_headers = 3; } diff --git a/proto/side/btclightclient/params.proto b/proto/side/btclightclient/params.proto index 01a8b0b2..5914b3a0 100644 --- a/proto/side/btclightclient/params.proto +++ b/proto/side/btclightclient/params.proto @@ -13,12 +13,13 @@ message Params { // Bitcoin Block Header message BlockHeader { - string hash = 1; - uint64 height = 2; - string previous_block_hash = 3; - string merkle_root = 4; - uint64 nonce = 5; - string bits = 6; - uint64 time = 7; - uint64 ntx = 8; + uint64 version = 1; + string hash = 2; + uint64 height = 3; + string previous_block_hash = 4; + string merkle_root = 5; + uint64 nonce = 6; + string bits = 7; + uint64 time = 8; + uint64 ntx = 9; } diff --git a/proto/side/btclightclient/query.proto b/proto/side/btclightclient/query.proto index 397eb393..991567d1 100644 --- a/proto/side/btclightclient/query.proto +++ b/proto/side/btclightclient/query.proto @@ -11,19 +11,19 @@ option go_package = "github.com/sideprotocol/side/x/btclightclient/types"; // Query defines the gRPC querier service. service Query { // Parameters queries the parameters of the module. - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + rpc QueryParams(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/sideprotocol/side/btclightclient/params"; } // ChainTip queries the chain tip of the module. - rpc GetChainTip(QueryChainTipRequest) returns (GetChainTipResponse) { + rpc QueryChainTip(QueryChainTipRequest) returns (QueryChainTipResponse) { option (google.api.http).get = "/sideprotocol/side/btclightclient/tip"; } // BlockHeaderByHeight queries the block header by height. - rpc GetBlockHeaderByHeight(QueryBlockHeaderByHeightRequest) returns (GetBlockHeaderByHeightResponse) { + rpc QueryBlockHeaderByHeight(QueryBlockHeaderByHeightRequest) returns (QueryBlockHeaderByHeightResponse) { option (google.api.http).get = "/sideprotocol/side/btclightclient/height/{height}"; } // BlockHeaderByHash queries the block header by hash. - rpc GetBlockHeaderByHash(QueryBlockHeaderByHashRequest) returns (GetBlockHeaderByHashResponse) { + rpc QueryBlockHeaderByHash(QueryBlockHeaderByHashRequest) returns (QueryBlockHeaderByHashResponse) { option (google.api.http).get = "/sideprotocol/side/btclightclient/hash/{hash}"; } } @@ -37,22 +37,22 @@ message QueryParamsResponse { Params params = 1 [(gogoproto.nullable) = false]; } -// QueryChainTipRequest is request type for the Query/GetChainTip RPC method. +// QueryChainTipRequest is request type for the Query/ChainTip RPC method. message QueryChainTipRequest {} -// QueryChainTipResponse is response type for the Query/GetChainTip RPC method. -message GetChainTipResponse { +// QueryChainTipResponse is response type for the Query/ChainTip RPC method. +message QueryChainTipResponse { string hash = 1; - int64 height = 2; + uint64 height = 2; } // QueryBlockHeaderByHeightRequest is the request type for the Query/BlockHeaderByHeight RPC method. message QueryBlockHeaderByHeightRequest { - int64 height = 1; + uint64 height = 1; } -// GetBlockHeaderByHeightResponse is the response type for the Query/BlockHeaderByHeight RPC method. -message GetBlockHeaderByHeightResponse { +// QueryBlockHeaderByHeightResponse is the response type for the Query/BlockHeaderByHeight RPC method. +message QueryBlockHeaderByHeightResponse { BlockHeader block_header = 1; } @@ -61,7 +61,7 @@ message QueryBlockHeaderByHashRequest { string hash = 1; } -// GetBlockHeaderByHashResponse is the response type for the Query/BlockHeaderByHash RPC method. -message GetBlockHeaderByHashResponse { +// QueryBlockHeaderByHashResponse is the response type for the Query/BlockHeaderByHash RPC method. +message QueryBlockHeaderByHashResponse { BlockHeader block_header = 1; } diff --git a/proto/side/btclightclient/tx.proto b/proto/side/btclightclient/tx.proto index 029dd243..22237dd0 100644 --- a/proto/side/btclightclient/tx.proto +++ b/proto/side/btclightclient/tx.proto @@ -10,13 +10,13 @@ option go_package = "github.com/sideprotocol/side/x/btclightclient/types"; // Msg defines the Msg service. service Msg { // SubmitBlockHeaders submits bitcoin block headers to the side chain. - rpc SubmitBlockHeaders (MsgBlockHeaderRequest) returns (MsgSubmitBlockHeadersResponse); + rpc SubmitBlockHeaders (MsgSubmitBlockHeaderRequest) returns (MsgSubmitBlockHeadersResponse); // UpdateSenders updates the senders of the side chain. - rpc UpdateSenders (MsgUpdateSenderRequest) returns (MsgUpdateSendersResponse); + rpc UpdateSenders (MsgUpdateSendersRequest) returns (MsgUpdateSendersResponse); } // MsgBlockHeaderRequest defines the Msg/SubmitBlockHeaders request type. -message MsgBlockHeaderRequest { +message MsgSubmitBlockHeaderRequest { string sender = 1; repeated BlockHeader block_headers = 2; } @@ -26,7 +26,7 @@ message MsgSubmitBlockHeadersResponse { } // Msg defines the MsgUpdateSender service. -message MsgUpdateSenderRequest { +message MsgUpdateSendersRequest { string sender = 1; // update senders who can send block headers to the side chain repeated string senders = 2; diff --git a/testutil/keeper/btc_light_client.go b/testutil/keeper/btc_light_client.go new file mode 100644 index 00000000..5b5e5a6a --- /dev/null +++ b/testutil/keeper/btc_light_client.go @@ -0,0 +1,46 @@ +package keeper + +import ( + "testing" + + tmdb "github.com/cometbft/cometbft-db" + "github.com/cometbft/cometbft/libs/log" + tmproto "github.com/cometbft/cometbft/proto/tendermint/types" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/store" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/sideprotocol/side/x/btclightclient/keeper" + "github.com/sideprotocol/side/x/btclightclient/types" + "github.com/stretchr/testify/require" +) + +func BtcLightClientKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { + // app := app.InitSideTestApp(false) + + storeKey := sdk.NewKVStoreKey(types.StoreKey) + memStoreKey := storetypes.NewMemoryStoreKey(types.StoreKey) + + db := tmdb.NewMemDB() + stateStore := store.NewCommitMultiStore(db) + stateStore.MountStoreWithDB(storeKey, storetypes.StoreTypeIAVL, db) + stateStore.MountStoreWithDB(memStoreKey, storetypes.StoreTypeMemory, nil) + require.NoError(t, stateStore.LoadLatestVersion()) + + registry := codectypes.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(registry) + + k := keeper.NewKeeper( + cdc, + storeKey, + memStoreKey, + ) + + ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) + + // Initialize params + k.SetParams(ctx, types.DefaultParams()) + + return k, ctx +} diff --git a/x/btclightclient/client/cli/query.go b/x/btclightclient/client/cli/query.go new file mode 100644 index 00000000..f0c51ec8 --- /dev/null +++ b/x/btclightclient/client/cli/query.go @@ -0,0 +1,87 @@ +package cli + +import ( + "fmt" + // "strings" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + + // "github.com/cosmos/cosmos-sdk/client/flags" + // sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/sideprotocol/side/x/btclightclient/types" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd(_ string) *cobra.Command { + // Group yield queries under a subcommand + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("Querying commands for the %s module", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand(CmdQueryParams()) + // this line is used by starport scaffolding # 1 + + return cmd +} + +func CmdQueryParams() *cobra.Command { + cmd := &cobra.Command{ + Use: "params", + Short: "shows the parameters of the module", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.QueryParams(cmd.Context(), &types.QueryParamsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdBestBlock() *cobra.Command { + cmd := &cobra.Command{ + Use: "best-block", + Short: "shows the best block header of the light client", + Args: cobra.NoArgs, + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.QueryChainTip(cmd.Context(), &types.QueryChainTipRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/btclightclient/client/cli/tx.go b/x/btclightclient/client/cli/tx.go new file mode 100644 index 00000000..4441e91b --- /dev/null +++ b/x/btclightclient/client/cli/tx.go @@ -0,0 +1,125 @@ +package cli + +import ( + "encoding/json" + "fmt" + "os" + "strings" + "time" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + + // "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/sideprotocol/side/x/btclightclient/types" +) + +var DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) + +// const ( +// flagPacketTimeoutTimestamp = "packet-timeout-timestamp" +// listSeparator = "," +// ) + +// GetTxCmd returns the transaction commands for this module +func GetTxCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: types.ModuleName, + Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName), + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmd.AddCommand(CmdSubmitBlocks()) + cmd.AddCommand(CmdUpdateSenders()) + // this line is used by starport scaffolding # 1 + + return cmd +} + +func CmdSubmitBlocks() *cobra.Command { + cmd := &cobra.Command{ + Use: "submit-blocks [file-path-to-block-headers.json]", + Short: "Submit Bitcoin block headers to the chain", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + // read the block headers from the file + blockHeaders, err := readBlockHeadersFromFile(args[0]) + if err != nil { + return err + } + + msg := types.NewMsgSubmitBlockHeaderRequest( + clientCtx.GetFromAddress().String(), + blockHeaders, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// Update Authorized Senders +func CmdUpdateSenders() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-senders [senders]", + Short: "Update authorized senders", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + // split the senders from args[0] + senders := strings.Split(args[0], ",") + if len(senders) == 0 { + return fmt.Errorf("senders can not be empty") + } + + msg := types.NewMsgUpdateSendersRequest( + clientCtx.GetFromAddress().String(), + senders, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + return cmd +} + +// readBlockHeadersFromFile reads the block headers from the file +func readBlockHeadersFromFile(filePath string) ([]*types.BlockHeader, error) { + // read the file + file, err := os.Open(filePath) + if err != nil { + return nil, err + } + defer file.Close() + + // read the block headers from the file + var blockHeaders []*types.BlockHeader + decoder := json.NewDecoder(file) + if err := decoder.Decode(&blockHeaders); err != nil { + return nil, err + } + return blockHeaders, nil +} diff --git a/x/btclightclient/genesis.go b/x/btclightclient/genesis.go new file mode 100644 index 00000000..4b8c5604 --- /dev/null +++ b/x/btclightclient/genesis.go @@ -0,0 +1,30 @@ +package btclightclient + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/sideprotocol/side/x/btclightclient/keeper" + "github.com/sideprotocol/side/x/btclightclient/types" +) + +// InitGenesis initializes the module's state from a provided genesis state. +func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + // this line is used by starport scaffolding # genesis/module/init + k.SetParams(ctx, genState.Params) + k.SetBestBlockHeader(ctx, genState.BestBlockHeader) + if len(genState.BlockHeaders) > 0 { + k.SetBlockHeaders(ctx, genState.BlockHeaders) + } + +} + +// ExportGenesis returns the module's exported genesis +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { + genesis := types.DefaultGenesis() + genesis.Params = k.GetParams(ctx) + genesis.BestBlockHeader = k.GetBestBlockHeader(ctx) + genesis.BlockHeaders = k.GetAllBlockHeaders(ctx) + + // this line is used by starport scaffolding # genesis/module/export + + return genesis +} diff --git a/x/btclightclient/genesis_test.go b/x/btclightclient/genesis_test.go new file mode 100644 index 00000000..de3ff5f9 --- /dev/null +++ b/x/btclightclient/genesis_test.go @@ -0,0 +1,29 @@ +package btclightclient_test + +import ( + "testing" + + keepertest "github.com/sideprotocol/side/testutil/keeper" + "github.com/sideprotocol/side/testutil/nullify" + "github.com/sideprotocol/side/x/btclightclient" + "github.com/sideprotocol/side/x/btclightclient/types" + "github.com/stretchr/testify/require" +) + +func TestGenesis(t *testing.T) { + genesisState := types.GenesisState{ + Params: types.DefaultParams(), + + // this line is used by starport scaffolding # genesis/test/state + } + + k, ctx := keepertest.BtcLightClientKeeper(t) + btclightclient.InitGenesis(ctx, *k, genesisState) + got := btclightclient.ExportGenesis(ctx, *k) + require.NotNil(t, got) + + nullify.Fill(&genesisState) + nullify.Fill(got) + + // this line is used by starport scaffolding # genesis/test/assert +} diff --git a/x/btclightclient/keeper/event.go b/x/btclightclient/keeper/event.go new file mode 100644 index 00000000..e4219c0e --- /dev/null +++ b/x/btclightclient/keeper/event.go @@ -0,0 +1,24 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/sideprotocol/side/x/btclightclient/types" +) + +func (k Keeper) EmitEvent(ctx sdk.Context, sender string, attr ...sdk.Attribute) { + headerAttr := []sdk.Attribute{ + { + Key: "sender", + Value: sender, + }, + } + + headerAttr = append(headerAttr, attr...) + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.ModuleName, + // attr..., + headerAttr..., + ), + ) +} diff --git a/x/btclightclient/keeper/keeper.go b/x/btclightclient/keeper/keeper.go new file mode 100644 index 00000000..5dfa6153 --- /dev/null +++ b/x/btclightclient/keeper/keeper.go @@ -0,0 +1,169 @@ +package keeper + +import ( + "fmt" + + "github.com/btcsuite/btcd/blockchain" + "github.com/btcsuite/btcd/chaincfg" + "github.com/cometbft/cometbft/libs/log" + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/sideprotocol/side/x/btclightclient/types" +) + +type ( + Keeper struct { + cdc codec.BinaryCodec + storeKey storetypes.StoreKey + memKey storetypes.StoreKey + } +) + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey, + memKey storetypes.StoreKey, +) *Keeper { + return &Keeper{ + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + } +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} + +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(¶ms) + store.Set(types.ParamsStoreKey, bz) +} + +func (k Keeper) GetParams(ctx sdk.Context) types.Params { + store := ctx.KVStore(k.storeKey) + var params types.Params + bz := store.Get(types.ParamsStoreKey) + k.cdc.MustUnmarshal(bz, ¶ms) + return params +} + +func (k Keeper) GetBestBlockHeader(ctx sdk.Context) *types.BlockHeader { + store := ctx.KVStore(k.storeKey) + var blockHeader *types.BlockHeader + bz := store.Get(types.BtcBestBlockHeaderKey) + k.cdc.MustUnmarshal(bz, blockHeader) + return blockHeader +} + +func (k Keeper) SetBestBlockHeader(ctx sdk.Context, header *types.BlockHeader) { + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(header) + store.Set(types.BtcBestBlockHeaderKey, bz) +} + +func (k Keeper) SetBlockHeaders(ctx sdk.Context, blockHeader []*types.BlockHeader) error { + store := ctx.KVStore(k.storeKey) + // check if the previous block header exists + best := k.GetBestBlockHeader(ctx) + for _, header := range blockHeader { + + // check the block header sanity + err := blockchain.CheckBlockHeaderSanity( + HeaderConvert(header), + chaincfg.MainNetParams.PowLimit, + blockchain.NewMedianTime(), + blockchain.BFNone, + ) + if err != nil { + return err + } + + // check whether it's next block header or not + if best.Hash != header.PreviousBlockHash { + // check if the block header already exists + // if exists, then it is a forked block header + if !store.Has(types.BtcBlockHeaderHeightKey(header.Height)) { + return types.ErrInvalidHeader + } + + // a forked block header is detected + // check if the new block header has more work than the old one + oldNode := k.GetBlockHeaderByHeight(ctx, header.Height) + worksOld := blockchain.CalcWork(BitsToTargetUint32(oldNode.Bits)) + worksNew := blockchain.CalcWork(BitsToTargetUint32(header.Bits)) + if worksNew.Cmp(worksOld) <= 0 { + return types.ErrForkedBlockHeader + } + + // remove the block headers after the forked block header + // and consider the forked block header as the best block header + for i := header.Height; i <= best.Height; i++ { + thash := k.GetBlockHashByHeight(ctx, i) + store.Delete(types.BtcBlockHeaderHashKey(thash)) + store.Delete(types.BtcBlockHeaderHeightKey(i)) + } + } + + // store the block header + bz := k.cdc.MustMarshal(header) + store.Set(types.BtcBlockHeaderHashKey(header.Hash), bz) + // store the height to hash mapping + store.Set(types.BtcBlockHeaderHeightKey(header.Height), []byte(header.Hash)) + // update the best block header + best = header + } + + if len(blockHeader) > 0 { + // set the best block header + k.SetBestBlockHeader(ctx, best) + } + + return nil +} + +func (k Keeper) GetBlockHeader(ctx sdk.Context, hash string) *types.BlockHeader { + store := ctx.KVStore(k.storeKey) + var blockHeader *types.BlockHeader + bz := store.Get(types.BtcBlockHeaderHashKey(hash)) + k.cdc.MustUnmarshal(bz, blockHeader) + return blockHeader +} + +func (k Keeper) GetBlockHashByHeight(ctx sdk.Context, height uint64) string { + store := ctx.KVStore(k.storeKey) + hash := store.Get(types.BtcBlockHeaderHeightKey(height)) + return string(hash) +} + +func (k Keeper) GetBlockHeaderByHeight(ctx sdk.Context, height uint64) *types.BlockHeader { + store := ctx.KVStore(k.storeKey) + hash := store.Get(types.BtcBlockHeaderHeightKey(height)) + return k.GetBlockHeader(ctx, string(hash)) +} + +// GetAllBlockHeaders returns all block headers +func (k Keeper) GetAllBlockHeaders(ctx sdk.Context) []*types.BlockHeader { + var headers []*types.BlockHeader + k.IterateBlockHeaders(ctx, func(header types.BlockHeader) (stop bool) { + headers = append(headers, &header) + return false + }) + return headers +} + +// IterateBlockHeaders iterates through all block headers +func (k Keeper) IterateBlockHeaders(ctx sdk.Context, process func(header types.BlockHeader) (stop bool)) { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, types.BtcBlockHeaderHashPrefix) + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + var header types.BlockHeader + k.cdc.MustUnmarshal(iterator.Value(), &header) + if process(header) { + break + } + } +} diff --git a/x/btclightclient/keeper/msg_server.go b/x/btclightclient/keeper/msg_server.go new file mode 100644 index 00000000..81c2f37e --- /dev/null +++ b/x/btclightclient/keeper/msg_server.go @@ -0,0 +1,72 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/sideprotocol/side/x/btclightclient/types" +) + +type msgServer struct { + Keeper +} + +// SubmitBlockHeaders implements types.MsgServer. +func (m msgServer) SubmitBlockHeaders(goCtx context.Context, msg *types.MsgSubmitBlockHeaderRequest) (*types.MsgSubmitBlockHeadersResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + if err := msg.ValidateBasic(); err != nil { + return nil, err + } + + // check if the sender is one of the authorized senders + param := m.GetParams(ctx) + if !param.IsAuthorizedSender(msg.Sender) { + return nil, types.ErrSenderAddressNotAuthorized + } + + // Set block headers + err := m.SetBlockHeaders(ctx, msg.BlockHeaders) + if err != nil { + return nil, err + } + + // Emit events + // m.EmitEvent( + // ctx, + // msg.Sender, + // sdk.Attribute{ + // Key: types.AttributeKeyPoolCreator, + // Value: msg.Sender, + // }, + // ) + return &types.MsgSubmitBlockHeadersResponse{}, nil +} + +// UpdateSenders implements types.MsgServer. +func (m msgServer) UpdateSenders(goCtx context.Context, msg *types.MsgUpdateSendersRequest) (*types.MsgUpdateSendersResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + if err := msg.ValidateBasic(); err != nil { + return nil, err + } + + // check if the sender is one of the authorized senders + param := m.GetParams(ctx) + if !param.IsAuthorizedSender(msg.Sender) { + return nil, types.ErrSenderAddressNotAuthorized + } + + // Set block headers + m.SetParams(ctx, types.NewParams(msg.Senders)) + + // Emit events + + return &types.MsgUpdateSendersResponse{}, nil +} + +// NewMsgServerImpl returns an implementation of the MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{Keeper: keeper} +} + +var _ types.MsgServer = msgServer{} diff --git a/x/btclightclient/keeper/queries.go b/x/btclightclient/keeper/queries.go new file mode 100644 index 00000000..9471b9ae --- /dev/null +++ b/x/btclightclient/keeper/queries.go @@ -0,0 +1,64 @@ +package keeper + +import ( + "context" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/sideprotocol/side/x/btclightclient/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +var _ types.QueryServer = Keeper{} + +func (k Keeper) QueryParams(goCtx context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil +} + +func (k Keeper) QueryChainTip(goCtx context.Context, req *types.QueryChainTipRequest) (*types.QueryChainTipResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + best := k.GetBestBlockHeader(ctx) + + return &types.QueryChainTipResponse{ + Hash: best.Hash, + Height: best.Height, + }, nil +} + +// BlockHeaderByHash queries the block header by hash. +func (k Keeper) QueryBlockHeaderByHash(goCtx context.Context, req *types.QueryBlockHeaderByHashRequest) (*types.QueryBlockHeaderByHashResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + header := k.GetBlockHeader(ctx, req.Hash) + if header == nil { + return nil, status.Error(codes.NotFound, "block header not found") + } + + return &types.QueryBlockHeaderByHashResponse{BlockHeader: header}, nil +} + +func (k Keeper) QueryBlockHeaderByHeight(goCtx context.Context, req *types.QueryBlockHeaderByHeightRequest) (*types.QueryBlockHeaderByHeightResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + header := k.GetBlockHeaderByHeight(ctx, req.Height) + if header == nil { + return nil, status.Error(codes.NotFound, "block header not found") + } + + return &types.QueryBlockHeaderByHeightResponse{BlockHeader: header}, nil +} diff --git a/x/btclightclient/keeper/util.go b/x/btclightclient/keeper/util.go new file mode 100644 index 00000000..989c2a7b --- /dev/null +++ b/x/btclightclient/keeper/util.go @@ -0,0 +1,35 @@ +package keeper + +import ( + "math/big" + "time" + + "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/wire" + "github.com/sideprotocol/side/x/btclightclient/types" +) + +func HeaderConvert(header *types.BlockHeader) *wire.BlockHeader { + prehash, _ := chainhash.NewHashFromStr(header.PreviousBlockHash) + root, _ := chainhash.NewHashFromStr(header.MerkleRoot) + n := new(big.Int) + n.SetString(header.Bits, 16) + return &wire.BlockHeader{ + Version: 0, + PrevBlock: *prehash, + MerkleRoot: *root, + Timestamp: time.Unix(int64(header.Time), 0), + Bits: uint32(n.Uint64()), + Nonce: uint32(header.Nonce), + } +} + +func BitsToTarget(bits string) *big.Int { + n := new(big.Int) + n.SetString(bits, 16) + return n +} + +func BitsToTargetUint32(bits string) uint32 { + return uint32(BitsToTarget(bits).Uint64()) +} diff --git a/x/btclightclient/module.go b/x/btclightclient/module.go new file mode 100644 index 00000000..25d70519 --- /dev/null +++ b/x/btclightclient/module.go @@ -0,0 +1,145 @@ +package btclightclient + +import ( + "context" + "encoding/json" + "fmt" + + // this line is used by starport scaffolding # 1 + + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + abci "github.com/cometbft/cometbft/abci/types" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/sideprotocol/side/x/btclightclient/client/cli" + "github.com/sideprotocol/side/x/btclightclient/keeper" + "github.com/sideprotocol/side/x/btclightclient/types" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface that defines the independent methods a Cosmos SDK module needs to implement. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the name of the module as a string +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +// RegisterLegacyAminoCodec registers the amino codec for the module, which is used to marshal and unmarshal structs to/from []byte in order to persist them in the module's KVStore +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +// RegisterInterfaces registers a module's interface types and their concrete implementations as proto.Message +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns a default GenesisState for the module, marshaled to json.RawMessage. The default GenesisState need to be defined by the module developer and is primarily used for testing +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis used to validate the GenesisState, given in its json.RawMessage form +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { + var genState types.GenesisState + if err := cdc.UnmarshalJSON(bz, &genState); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + return genState.Validate() +} + +// RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the module +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + if err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)); err != nil { + panic(err) + } +} + +// GetTxCmd returns the root Tx command for the module. The subcommands of this root command are used by end-users to generate new transactions containing messages defined in the module +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns the root query command for the module. The subcommands of this root command are used by end-users to generate new queries to the subset of the state defined by the module +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd(types.StoreKey) +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface that defines the inter-dependent methods that modules need to implement +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + } +} + +// RegisterServices registers a gRPC query service to respond to the module-specific gRPC queries +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// RegisterInvariants registers the invariants of the module. If an invariant deviates from its predicted value, the InvariantRegistry triggers appropriate logic (most often the chain will be halted) +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the module's genesis initialization. It returns no validator updates. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, gs json.RawMessage) []abci.ValidatorUpdate { + var genState types.GenesisState + // Initialize global index to index in genesis state + cdc.MustUnmarshalJSON(gs, &genState) + + InitGenesis(ctx, am.keeper, genState) + + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the module's exported genesis state as raw JSON bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + genState := ExportGenesis(ctx, am.keeper) + return cdc.MustMarshalJSON(genState) +} + +// ConsensusVersion is a sequence number for state-breaking change of the module. It should be incremented on each consensus-breaking change introduced by the module. To avoid wrong/empty versions, the initial version should be set to 1 +func (AppModule) ConsensusVersion() uint64 { return 1 } + +// BeginBlock contains the logic that is automatically triggered at the beginning of each block +func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock contains the logic that is automatically triggered at the end of each block +func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} diff --git a/x/btclightclient/module_simulation.go b/x/btclightclient/module_simulation.go new file mode 100644 index 00000000..71f492f8 --- /dev/null +++ b/x/btclightclient/module_simulation.go @@ -0,0 +1 @@ +package btclightclient diff --git a/x/btclightclient/types/codec.go b/x/btclightclient/types/codec.go new file mode 100644 index 00000000..31febfa6 --- /dev/null +++ b/x/btclightclient/types/codec.go @@ -0,0 +1,31 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +func RegisterCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgSubmitBlockHeaderRequest{}, "btclightclient/MsgSubmitBlockHeaderRequest", nil) + cdc.RegisterConcrete(&MsgSubmitBlockHeadersResponse{}, "btclightclient/MsgSubmitBlockHeadersResponse", nil) + cdc.RegisterConcrete(&MsgUpdateSendersRequest{}, "btclightclient/MsgUpdateSendersRequest", nil) + cdc.RegisterConcrete(&MsgUpdateSendersResponse{}, "btclightclient/MsgUpdateSendersResponse", nil) + // this line is used by starport scaffolding # 2 +} + +func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSubmitBlockHeaderRequest{}) + registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSubmitBlockHeadersResponse{}) + registry.RegisterImplementations((*sdk.Msg)(nil), &MsgUpdateSendersRequest{}) + registry.RegisterImplementations((*sdk.Msg)(nil), &MsgUpdateSendersResponse{}) + // this line is used by starport scaffolding # 3 + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + Amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) diff --git a/x/btclightclient/types/errors.go b/x/btclightclient/types/errors.go new file mode 100644 index 00000000..abf396db --- /dev/null +++ b/x/btclightclient/types/errors.go @@ -0,0 +1,17 @@ +package types + +// DONTCOVER + +import ( + errorsmod "cosmossdk.io/errors" +) + +// x/yield module sentinel errors +var ( + ErrSenderAddressNotAuthorized = errorsmod.Register(ModuleName, 1000, "sender address not authorized") + ErrInvalidHeader = errorsmod.Register(ModuleName, 1100, "invalid block header") + ErrReorgFailed = errorsmod.Register(ModuleName, 1101, "failed to reorg chain") + ErrForkedBlockHeader = errorsmod.Register(ModuleName, 1102, "Invalid forked block header") + + ErrInvalidSenders = errorsmod.Register(ModuleName, 2100, "invalid allowed senders") +) diff --git a/x/btclightclient/types/expected_keepers.go b/x/btclightclient/types/expected_keepers.go new file mode 100644 index 00000000..20eea16d --- /dev/null +++ b/x/btclightclient/types/expected_keepers.go @@ -0,0 +1,12 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/types" +) + +// AccountKeeper defines the expected account keeper used for simulations (noalias) +type AccountKeeper interface { + GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + // Methods imported from account should be defined here +} diff --git a/x/btclightclient/types/genesis.go b/x/btclightclient/types/genesis.go new file mode 100644 index 00000000..1289d5f3 --- /dev/null +++ b/x/btclightclient/types/genesis.go @@ -0,0 +1,21 @@ +package types + +// this line is used by starport scaffolding # genesis/types/import + +// DefaultGenesis returns the default genesis state +func DefaultGenesis() *GenesisState { + return &GenesisState{ + // this line is used by starport scaffolding # genesis/types/default + Params: DefaultParams(), + BestBlockHeader: &BlockHeader{}, + BlockHeaders: []*BlockHeader{}, + } +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (gs GenesisState) Validate() error { + // this line is used by starport scaffolding # genesis/types/validate + + return gs.Params.Validate() +} diff --git a/x/btclightclient/types/genesis.pb.go b/x/btclightclient/types/genesis.pb.go index 5e95a166..4056abdd 100644 --- a/x/btclightclient/types/genesis.pb.go +++ b/x/btclightclient/types/genesis.pb.go @@ -25,8 +25,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the btc light client module's genesis state. type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - BlockHeaders []*BlockHeader `protobuf:"bytes,2,rep,name=block_headers,json=blockHeaders,proto3" json:"block_headers,omitempty"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + // the chain tip of the bitcoin chain + BestBlockHeader *BlockHeader `protobuf:"bytes,2,opt,name=best_block_header,json=bestBlockHeader,proto3" json:"best_block_header,omitempty"` + BlockHeaders []*BlockHeader `protobuf:"bytes,3,rep,name=block_headers,json=blockHeaders,proto3" json:"block_headers,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -69,6 +71,13 @@ func (m *GenesisState) GetParams() Params { return Params{} } +func (m *GenesisState) GetBestBlockHeader() *BlockHeader { + if m != nil { + return m.BestBlockHeader + } + return nil +} + func (m *GenesisState) GetBlockHeaders() []*BlockHeader { if m != nil { return m.BlockHeaders @@ -83,22 +92,23 @@ func init() { func init() { proto.RegisterFile("side/btclightclient/genesis.proto", fileDescriptor_84e124efbd6ad9f4) } var fileDescriptor_84e124efbd6ad9f4 = []byte{ - // 235 bytes of a gzipped FileDescriptorProto + // 255 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2c, 0xce, 0x4c, 0x49, 0xd5, 0x4f, 0x2a, 0x49, 0xce, 0xc9, 0x4c, 0xcf, 0x00, 0x91, 0xa9, 0x79, 0x25, 0xfa, 0xe9, 0xa9, 0x79, 0xa9, 0xc5, 0x99, 0xc5, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0xc2, 0x20, 0x25, 0x7a, 0xa8, 0x4a, 0xa4, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0xf2, 0xfa, 0x20, 0x16, 0x44, 0xa9, 0x94, - 0x02, 0x36, 0xd3, 0x0a, 0x12, 0x8b, 0x12, 0x73, 0xa1, 0x86, 0x29, 0x4d, 0x60, 0xe4, 0xe2, 0x71, + 0x02, 0x36, 0xd3, 0x0a, 0x12, 0x8b, 0x12, 0x73, 0xa1, 0x86, 0x29, 0xdd, 0x63, 0xe4, 0xe2, 0x71, 0x87, 0x18, 0x1f, 0x5c, 0x92, 0x58, 0x92, 0x2a, 0x64, 0xc9, 0xc5, 0x06, 0x51, 0x20, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xad, 0x87, 0xc5, 0x3a, 0xbd, 0x00, 0xb0, 0x12, 0x27, 0x96, 0x13, - 0xf7, 0xe4, 0x19, 0x82, 0xa0, 0x1a, 0x84, 0x5c, 0xb9, 0x78, 0x93, 0x72, 0xf2, 0x93, 0xb3, 0xe3, - 0x33, 0x52, 0x13, 0x53, 0x52, 0x8b, 0x8a, 0x25, 0x98, 0x14, 0x98, 0x35, 0xb8, 0x8d, 0x14, 0xb0, - 0x9a, 0xe0, 0x04, 0x52, 0xe9, 0x01, 0x56, 0x18, 0xc4, 0x93, 0x84, 0xe0, 0x14, 0x3b, 0xf9, 0x9e, - 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, - 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x71, 0x7a, 0x66, 0x49, 0x46, 0x69, - 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x3e, 0xc8, 0x4c, 0xb0, 0x17, 0x92, 0xf3, 0x73, 0xc0, 0x1c, 0xfd, - 0x0a, 0x74, 0x8f, 0x96, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x55, 0x19, 0x03, 0x02, 0x00, - 0x00, 0xff, 0xff, 0x7b, 0xe8, 0x2f, 0x7a, 0x5a, 0x01, 0x00, 0x00, + 0xf7, 0xe4, 0x19, 0x82, 0xa0, 0x1a, 0x84, 0x7c, 0xb8, 0x04, 0x93, 0x52, 0x8b, 0x4b, 0xe2, 0x93, + 0x72, 0xf2, 0x93, 0xb3, 0xe3, 0x33, 0x52, 0x13, 0x53, 0x52, 0x8b, 0x24, 0x98, 0xc0, 0xa6, 0x28, + 0x60, 0x35, 0xc5, 0x09, 0xa4, 0xd0, 0x03, 0xac, 0x2e, 0x88, 0x1f, 0xa4, 0x15, 0x49, 0x40, 0xc8, + 0x95, 0x8b, 0x17, 0xd9, 0xa0, 0x62, 0x09, 0x66, 0x05, 0x66, 0xa2, 0x4c, 0xe2, 0x49, 0x42, 0x70, + 0x8a, 0x9d, 0x7c, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, + 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x38, 0x3d, + 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0x64, 0x26, 0x38, 0x40, 0x92, 0xf3, + 0x73, 0xc0, 0x1c, 0xfd, 0x0a, 0xf4, 0x60, 0x2b, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0xab, + 0x32, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xf5, 0xf9, 0x10, 0x25, 0xa8, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -132,9 +142,21 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a } } + if m.BestBlockHeader != nil { + { + size, err := m.BestBlockHeader.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } { size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -167,6 +189,10 @@ func (m *GenesisState) Size() (n int) { _ = l l = m.Params.Size() n += 1 + l + sovGenesis(uint64(l)) + if m.BestBlockHeader != nil { + l = m.BestBlockHeader.Size() + n += 1 + l + sovGenesis(uint64(l)) + } if len(m.BlockHeaders) > 0 { for _, e := range m.BlockHeaders { l = e.Size() @@ -245,6 +271,42 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BestBlockHeader", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.BestBlockHeader == nil { + m.BestBlockHeader = &BlockHeader{} + } + if err := m.BestBlockHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field BlockHeaders", wireType) } diff --git a/x/btclightclient/types/keys.go b/x/btclightclient/types/keys.go new file mode 100644 index 00000000..94adc542 --- /dev/null +++ b/x/btclightclient/types/keys.go @@ -0,0 +1,43 @@ +package types + +import ( + "math/big" +) + +const ( + // ModuleName defines the module name + ModuleName = "btclightclient" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey defines the module's message routing key + RouterKey = ModuleName +) + +func KeyPrefix(p string) []byte { + return []byte(p) +} + +var ( + ParamsStoreKey = []byte{0x1} + // Host chain keys prefix the HostChain structs + BtcBlockHeaderHashPrefix = []byte{0x11} // prefix for each key to a block header, for a hash + BtcBlockHeaderHeightPrefix = []byte{0x12} // prefix for each key to a block hash, for a height + BtcBestBlockHeaderKey = []byte{0x13} // key for the best block height + +) + +func Int64ToBytes(number uint64) []byte { + big := new(big.Int) + big.SetUint64(number) + return big.Bytes() +} + +func BtcBlockHeaderHashKey(hash string) []byte { + return append(BtcBlockHeaderHashPrefix, []byte(hash)...) +} + +func BtcBlockHeaderHeightKey(height uint64) []byte { + return append(BtcBlockHeaderHashPrefix, Int64ToBytes(height)...) +} diff --git a/x/btclightclient/types/message_submit_headers.go b/x/btclightclient/types/message_submit_headers.go new file mode 100644 index 00000000..df1f28b4 --- /dev/null +++ b/x/btclightclient/types/message_submit_headers.go @@ -0,0 +1,52 @@ +package types + +import ( + sdkerrors "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const TypeMsgSubmitBlockHeader = "submit_block_header" + +func NewMsgSubmitBlockHeaderRequest( + sender string, + headers []*BlockHeader, +) *MsgSubmitBlockHeaderRequest { + return &MsgSubmitBlockHeaderRequest{ + Sender: sender, + BlockHeaders: headers, + } +} + +func (msg *MsgSubmitBlockHeaderRequest) Route() string { + return RouterKey +} + +func (msg *MsgSubmitBlockHeaderRequest) Type() string { + return TypeMsgSubmitBlockHeader +} + +func (msg *MsgSubmitBlockHeaderRequest) GetSigners() []sdk.AccAddress { + Sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{Sender} +} + +func (msg *MsgSubmitBlockHeaderRequest) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgSubmitBlockHeaderRequest) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return sdkerrors.Wrapf(err, "invalid Sender address (%s)", err) + } + + if len(msg.BlockHeaders) == 0 { + return sdkerrors.Wrap(ErrInvalidHeader, "block headers cannot be empty") + } + + return nil +} diff --git a/x/btclightclient/types/message_update_senders.go b/x/btclightclient/types/message_update_senders.go new file mode 100644 index 00000000..b6e451fc --- /dev/null +++ b/x/btclightclient/types/message_update_senders.go @@ -0,0 +1,59 @@ +package types + +import ( + sdkerrors "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const TypeMsgUpdateSenders = "update_senders" + +func NewMsgUpdateSendersRequest( + sender string, + senders []string, +) *MsgUpdateSendersRequest { + return &MsgUpdateSendersRequest{ + Sender: sender, + Senders: senders, + } +} + +func (msg *MsgUpdateSendersRequest) Route() string { + return RouterKey +} + +func (msg *MsgUpdateSendersRequest) Type() string { + return TypeMsgUpdateSenders +} + +func (msg *MsgUpdateSendersRequest) GetSigners() []sdk.AccAddress { + Sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{Sender} +} + +func (msg *MsgUpdateSendersRequest) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgUpdateSendersRequest) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return sdkerrors.Wrapf(err, "invalid Sender address (%s)", err) + } + + if len(msg.Senders) == 0 { + return sdkerrors.Wrap(ErrInvalidSenders, "senders cannot be empty") + } + + for _, sender := range msg.Senders { + _, err := sdk.AccAddressFromBech32(sender) + if err != nil { + return sdkerrors.Wrapf(ErrInvalidSenders, "address (%s) is invalid", sender) + } + } + + return nil +} diff --git a/x/btclightclient/types/params.go b/x/btclightclient/types/params.go new file mode 100644 index 00000000..94ef8642 --- /dev/null +++ b/x/btclightclient/types/params.go @@ -0,0 +1,36 @@ +package types + +import sdk "github.com/cosmos/cosmos-sdk/types" + +// NewParams creates a new Params instance +func NewParams(senders []string) Params { + return Params{ + Senders: senders, + } +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return NewParams([]string{"bc1quq8hw0763rkqqeuarznh9nd6esrnl4684apaqr"}) +} + +// Validate validates the set of params +func (p Params) Validate() error { + for _, sender := range p.Senders { + _, err := sdk.AccAddressFromBech32(sender) + if err != nil { + return err + } + } + return nil +} + +// checks if the given address is an authorized sender +func (p Params) IsAuthorizedSender(sender string) bool { + for _, s := range p.Senders { + if s == sender { + return true + } + } + return false +} diff --git a/x/btclightclient/types/params.pb.go b/x/btclightclient/types/params.pb.go index 0751ab0b..2bc9feca 100644 --- a/x/btclightclient/types/params.pb.go +++ b/x/btclightclient/types/params.pb.go @@ -71,14 +71,15 @@ func (m *Params) GetSenders() []string { // Bitcoin Block Header type BlockHeader struct { - Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` - Height uint64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` - PreviousBlockHash string `protobuf:"bytes,3,opt,name=previous_block_hash,json=previousBlockHash,proto3" json:"previous_block_hash,omitempty"` - MerkleRoot string `protobuf:"bytes,4,opt,name=merkle_root,json=merkleRoot,proto3" json:"merkle_root,omitempty"` - Nonce uint64 `protobuf:"varint,5,opt,name=nonce,proto3" json:"nonce,omitempty"` - Bits string `protobuf:"bytes,6,opt,name=bits,proto3" json:"bits,omitempty"` - Time uint64 `protobuf:"varint,7,opt,name=time,proto3" json:"time,omitempty"` - Ntx uint64 `protobuf:"varint,8,opt,name=ntx,proto3" json:"ntx,omitempty"` + Version uint64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` + Hash string `protobuf:"bytes,2,opt,name=hash,proto3" json:"hash,omitempty"` + Height uint64 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` + PreviousBlockHash string `protobuf:"bytes,4,opt,name=previous_block_hash,json=previousBlockHash,proto3" json:"previous_block_hash,omitempty"` + MerkleRoot string `protobuf:"bytes,5,opt,name=merkle_root,json=merkleRoot,proto3" json:"merkle_root,omitempty"` + Nonce uint64 `protobuf:"varint,6,opt,name=nonce,proto3" json:"nonce,omitempty"` + Bits string `protobuf:"bytes,7,opt,name=bits,proto3" json:"bits,omitempty"` + Time uint64 `protobuf:"varint,8,opt,name=time,proto3" json:"time,omitempty"` + Ntx uint64 `protobuf:"varint,9,opt,name=ntx,proto3" json:"ntx,omitempty"` } func (m *BlockHeader) Reset() { *m = BlockHeader{} } @@ -114,6 +115,13 @@ func (m *BlockHeader) XXX_DiscardUnknown() { var xxx_messageInfo_BlockHeader proto.InternalMessageInfo +func (m *BlockHeader) GetVersion() uint64 { + if m != nil { + return m.Version + } + return 0 +} + func (m *BlockHeader) GetHash() string { if m != nil { return m.Hash @@ -178,27 +186,27 @@ func init() { func init() { proto.RegisterFile("side/btclightclient/params.proto", fileDescriptor_3b47f8b78acf6f6e) } var fileDescriptor_3b47f8b78acf6f6e = []byte{ - // 305 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x91, 0xbf, 0x4e, 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, 0x4e, 0x8e, 0x88, 0xe3, 0x7d, 0x28, 0x41, 0x74, 0x62, 0xc1, 0xc7, - 0x0d, 0x36, 0x39, 0xc8, 0x31, 0xcd, 0xe9, 0x8d, 0x5f, 0x29, 0xd3, 0xce, 0xca, 0xa0, 0x5f, 0xc9, - 0x6b, 0x1f, 0x73, 0xba, 0x06, 0x39, 0x21, 0x90, 0xb4, 0xb8, 0xe1, 0xc3, 0xc6, 0x1d, 0xe5, 0x35, - 0x85, 0xbc, 0xdc, 0x3c, 0x7d, 0x9c, 0x15, 0x3b, 0x9d, 0x15, 0xfb, 0x3e, 0x2b, 0xf6, 0xde, 0xa9, - 0xc1, 0xa9, 0x53, 0x83, 0xcf, 0x4e, 0x0d, 0x5e, 0xd6, 0x85, 0x76, 0xe5, 0x21, 0x8b, 0x72, 0xac, - 0x63, 0x7f, 0x50, 0x3a, 0x58, 0x8e, 0x15, 0x99, 0xf8, 0xf8, 0xff, 0x07, 0xdc, 0x5b, 0x0b, 0x36, - 0x0b, 0x88, 0x5a, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x15, 0xd9, 0x5f, 0x9d, 0xa5, 0x01, 0x00, - 0x00, + // 318 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x91, 0xbf, 0x6e, 0xfa, 0x30, + 0x10, 0xc7, 0xf1, 0x0f, 0x08, 0x3f, 0xcc, 0xd2, 0x1a, 0x54, 0x59, 0x1d, 0xd2, 0x88, 0x89, 0x29, + 0x19, 0x78, 0x03, 0xa6, 0x2e, 0x95, 0xaa, 0x8c, 0x5d, 0x50, 0x12, 0x4e, 0x89, 0x45, 0xe2, 0x8b, + 0x6c, 0x83, 0xe8, 0x5b, 0xf4, 0xb1, 0x3a, 0x32, 0x76, 0xac, 0xe0, 0x15, 0xfa, 0x00, 0x95, 0x2f, + 0xcd, 0xd0, 0x2e, 0xd6, 0xf7, 0x7b,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x90, 0x97, 0x9b, 0xa7, + 0xf7, 0x4b, 0xc8, 0xce, 0x97, 0x90, 0x7d, 0x5e, 0x42, 0xf6, 0x76, 0x0d, 0x07, 0xe7, 0x6b, 0x38, + 0xf8, 0xb8, 0x86, 0x83, 0x97, 0x75, 0xa9, 0x5c, 0x75, 0xc8, 0xe3, 0x02, 0x9b, 0xc4, 0x9f, 0x9a, + 0x4e, 0x59, 0x60, 0x4d, 0x26, 0x39, 0xfd, 0xfd, 0x1b, 0xf7, 0xda, 0x82, 0xcd, 0x03, 0xa2, 0xd6, + 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xef, 0x0a, 0xe2, 0x23, 0xbf, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -256,50 +264,55 @@ func (m *BlockHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.Ntx != 0 { i = encodeVarintParams(dAtA, i, uint64(m.Ntx)) i-- - dAtA[i] = 0x40 + dAtA[i] = 0x48 } if m.Time != 0 { i = encodeVarintParams(dAtA, i, uint64(m.Time)) i-- - dAtA[i] = 0x38 + dAtA[i] = 0x40 } if len(m.Bits) > 0 { i -= len(m.Bits) copy(dAtA[i:], m.Bits) i = encodeVarintParams(dAtA, i, uint64(len(m.Bits))) i-- - dAtA[i] = 0x32 + dAtA[i] = 0x3a } if m.Nonce != 0 { i = encodeVarintParams(dAtA, i, uint64(m.Nonce)) i-- - dAtA[i] = 0x28 + dAtA[i] = 0x30 } if len(m.MerkleRoot) > 0 { i -= len(m.MerkleRoot) copy(dAtA[i:], m.MerkleRoot) i = encodeVarintParams(dAtA, i, uint64(len(m.MerkleRoot))) i-- - dAtA[i] = 0x22 + dAtA[i] = 0x2a } if len(m.PreviousBlockHash) > 0 { i -= len(m.PreviousBlockHash) copy(dAtA[i:], m.PreviousBlockHash) i = encodeVarintParams(dAtA, i, uint64(len(m.PreviousBlockHash))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x22 } if m.Height != 0 { i = encodeVarintParams(dAtA, i, uint64(m.Height)) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x18 } if len(m.Hash) > 0 { i -= len(m.Hash) copy(dAtA[i:], m.Hash) i = encodeVarintParams(dAtA, i, uint64(len(m.Hash))) i-- - dAtA[i] = 0xa + dAtA[i] = 0x12 + } + if m.Version != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.Version)) + i-- + dAtA[i] = 0x8 } return len(dAtA) - i, nil } @@ -336,6 +349,9 @@ func (m *BlockHeader) Size() (n int) { } var l int _ = l + if m.Version != 0 { + n += 1 + sovParams(uint64(m.Version)) + } l = len(m.Hash) if l > 0 { n += 1 + l + sovParams(uint64(l)) @@ -485,6 +501,25 @@ func (m *BlockHeader) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + m.Version = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Version |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) } @@ -516,7 +551,7 @@ func (m *BlockHeader) Unmarshal(dAtA []byte) error { } m.Hash = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 3: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) } @@ -535,7 +570,7 @@ func (m *BlockHeader) Unmarshal(dAtA []byte) error { break } } - case 3: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PreviousBlockHash", wireType) } @@ -567,7 +602,7 @@ func (m *BlockHeader) Unmarshal(dAtA []byte) error { } m.PreviousBlockHash = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 4: + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field MerkleRoot", wireType) } @@ -599,7 +634,7 @@ func (m *BlockHeader) Unmarshal(dAtA []byte) error { } m.MerkleRoot = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 5: + case 6: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Nonce", wireType) } @@ -618,7 +653,7 @@ func (m *BlockHeader) Unmarshal(dAtA []byte) error { break } } - case 6: + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Bits", wireType) } @@ -650,7 +685,7 @@ func (m *BlockHeader) Unmarshal(dAtA []byte) error { } m.Bits = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 7: + case 8: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Time", wireType) } @@ -669,7 +704,7 @@ func (m *BlockHeader) Unmarshal(dAtA []byte) error { break } } - case 8: + case 9: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Ntx", wireType) } diff --git a/x/btclightclient/types/query.pb.go b/x/btclightclient/types/query.pb.go index 9208a1d5..7c7226e8 100644 --- a/x/btclightclient/types/query.pb.go +++ b/x/btclightclient/types/query.pb.go @@ -113,7 +113,7 @@ func (m *QueryParamsResponse) GetParams() Params { return Params{} } -// QueryChainTipRequest is request type for the Query/GetChainTip RPC method. +// QueryChainTipRequest is request type for the Query/ChainTip RPC method. type QueryChainTipRequest struct { } @@ -150,24 +150,24 @@ func (m *QueryChainTipRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryChainTipRequest proto.InternalMessageInfo -// QueryChainTipResponse is response type for the Query/GetChainTip RPC method. -type GetChainTipResponse struct { +// QueryChainTipResponse is response type for the Query/ChainTip RPC method. +type QueryChainTipResponse struct { Hash string `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` - Height int64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` + Height uint64 `protobuf:"varint,2,opt,name=height,proto3" json:"height,omitempty"` } -func (m *GetChainTipResponse) Reset() { *m = GetChainTipResponse{} } -func (m *GetChainTipResponse) String() string { return proto.CompactTextString(m) } -func (*GetChainTipResponse) ProtoMessage() {} -func (*GetChainTipResponse) Descriptor() ([]byte, []int) { +func (m *QueryChainTipResponse) Reset() { *m = QueryChainTipResponse{} } +func (m *QueryChainTipResponse) String() string { return proto.CompactTextString(m) } +func (*QueryChainTipResponse) ProtoMessage() {} +func (*QueryChainTipResponse) Descriptor() ([]byte, []int) { return fileDescriptor_f299b49d16182dbc, []int{3} } -func (m *GetChainTipResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryChainTipResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *GetChainTipResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryChainTipResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_GetChainTipResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryChainTipResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -177,26 +177,26 @@ func (m *GetChainTipResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *GetChainTipResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetChainTipResponse.Merge(m, src) +func (m *QueryChainTipResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryChainTipResponse.Merge(m, src) } -func (m *GetChainTipResponse) XXX_Size() int { +func (m *QueryChainTipResponse) XXX_Size() int { return m.Size() } -func (m *GetChainTipResponse) XXX_DiscardUnknown() { - xxx_messageInfo_GetChainTipResponse.DiscardUnknown(m) +func (m *QueryChainTipResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryChainTipResponse.DiscardUnknown(m) } -var xxx_messageInfo_GetChainTipResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryChainTipResponse proto.InternalMessageInfo -func (m *GetChainTipResponse) GetHash() string { +func (m *QueryChainTipResponse) GetHash() string { if m != nil { return m.Hash } return "" } -func (m *GetChainTipResponse) GetHeight() int64 { +func (m *QueryChainTipResponse) GetHeight() uint64 { if m != nil { return m.Height } @@ -205,7 +205,7 @@ func (m *GetChainTipResponse) GetHeight() int64 { // QueryBlockHeaderByHeightRequest is the request type for the Query/BlockHeaderByHeight RPC method. type QueryBlockHeaderByHeightRequest struct { - Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` + Height uint64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` } func (m *QueryBlockHeaderByHeightRequest) Reset() { *m = QueryBlockHeaderByHeightRequest{} } @@ -241,30 +241,30 @@ func (m *QueryBlockHeaderByHeightRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryBlockHeaderByHeightRequest proto.InternalMessageInfo -func (m *QueryBlockHeaderByHeightRequest) GetHeight() int64 { +func (m *QueryBlockHeaderByHeightRequest) GetHeight() uint64 { if m != nil { return m.Height } return 0 } -// GetBlockHeaderByHeightResponse is the response type for the Query/BlockHeaderByHeight RPC method. -type GetBlockHeaderByHeightResponse struct { +// QueryBlockHeaderByHeightResponse is the response type for the Query/BlockHeaderByHeight RPC method. +type QueryBlockHeaderByHeightResponse struct { BlockHeader *BlockHeader `protobuf:"bytes,1,opt,name=block_header,json=blockHeader,proto3" json:"block_header,omitempty"` } -func (m *GetBlockHeaderByHeightResponse) Reset() { *m = GetBlockHeaderByHeightResponse{} } -func (m *GetBlockHeaderByHeightResponse) String() string { return proto.CompactTextString(m) } -func (*GetBlockHeaderByHeightResponse) ProtoMessage() {} -func (*GetBlockHeaderByHeightResponse) Descriptor() ([]byte, []int) { +func (m *QueryBlockHeaderByHeightResponse) Reset() { *m = QueryBlockHeaderByHeightResponse{} } +func (m *QueryBlockHeaderByHeightResponse) String() string { return proto.CompactTextString(m) } +func (*QueryBlockHeaderByHeightResponse) ProtoMessage() {} +func (*QueryBlockHeaderByHeightResponse) Descriptor() ([]byte, []int) { return fileDescriptor_f299b49d16182dbc, []int{5} } -func (m *GetBlockHeaderByHeightResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryBlockHeaderByHeightResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *GetBlockHeaderByHeightResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryBlockHeaderByHeightResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_GetBlockHeaderByHeightResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryBlockHeaderByHeightResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -274,19 +274,19 @@ func (m *GetBlockHeaderByHeightResponse) XXX_Marshal(b []byte, deterministic boo return b[:n], nil } } -func (m *GetBlockHeaderByHeightResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetBlockHeaderByHeightResponse.Merge(m, src) +func (m *QueryBlockHeaderByHeightResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBlockHeaderByHeightResponse.Merge(m, src) } -func (m *GetBlockHeaderByHeightResponse) XXX_Size() int { +func (m *QueryBlockHeaderByHeightResponse) XXX_Size() int { return m.Size() } -func (m *GetBlockHeaderByHeightResponse) XXX_DiscardUnknown() { - xxx_messageInfo_GetBlockHeaderByHeightResponse.DiscardUnknown(m) +func (m *QueryBlockHeaderByHeightResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBlockHeaderByHeightResponse.DiscardUnknown(m) } -var xxx_messageInfo_GetBlockHeaderByHeightResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryBlockHeaderByHeightResponse proto.InternalMessageInfo -func (m *GetBlockHeaderByHeightResponse) GetBlockHeader() *BlockHeader { +func (m *QueryBlockHeaderByHeightResponse) GetBlockHeader() *BlockHeader { if m != nil { return m.BlockHeader } @@ -338,23 +338,23 @@ func (m *QueryBlockHeaderByHashRequest) GetHash() string { return "" } -// GetBlockHeaderByHashResponse is the response type for the Query/BlockHeaderByHash RPC method. -type GetBlockHeaderByHashResponse struct { +// QueryBlockHeaderByHashResponse is the response type for the Query/BlockHeaderByHash RPC method. +type QueryBlockHeaderByHashResponse struct { BlockHeader *BlockHeader `protobuf:"bytes,1,opt,name=block_header,json=blockHeader,proto3" json:"block_header,omitempty"` } -func (m *GetBlockHeaderByHashResponse) Reset() { *m = GetBlockHeaderByHashResponse{} } -func (m *GetBlockHeaderByHashResponse) String() string { return proto.CompactTextString(m) } -func (*GetBlockHeaderByHashResponse) ProtoMessage() {} -func (*GetBlockHeaderByHashResponse) Descriptor() ([]byte, []int) { +func (m *QueryBlockHeaderByHashResponse) Reset() { *m = QueryBlockHeaderByHashResponse{} } +func (m *QueryBlockHeaderByHashResponse) String() string { return proto.CompactTextString(m) } +func (*QueryBlockHeaderByHashResponse) ProtoMessage() {} +func (*QueryBlockHeaderByHashResponse) Descriptor() ([]byte, []int) { return fileDescriptor_f299b49d16182dbc, []int{7} } -func (m *GetBlockHeaderByHashResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryBlockHeaderByHashResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *GetBlockHeaderByHashResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryBlockHeaderByHashResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_GetBlockHeaderByHashResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryBlockHeaderByHashResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -364,19 +364,19 @@ func (m *GetBlockHeaderByHashResponse) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *GetBlockHeaderByHashResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_GetBlockHeaderByHashResponse.Merge(m, src) +func (m *QueryBlockHeaderByHashResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryBlockHeaderByHashResponse.Merge(m, src) } -func (m *GetBlockHeaderByHashResponse) XXX_Size() int { +func (m *QueryBlockHeaderByHashResponse) XXX_Size() int { return m.Size() } -func (m *GetBlockHeaderByHashResponse) XXX_DiscardUnknown() { - xxx_messageInfo_GetBlockHeaderByHashResponse.DiscardUnknown(m) +func (m *QueryBlockHeaderByHashResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryBlockHeaderByHashResponse.DiscardUnknown(m) } -var xxx_messageInfo_GetBlockHeaderByHashResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryBlockHeaderByHashResponse proto.InternalMessageInfo -func (m *GetBlockHeaderByHashResponse) GetBlockHeader() *BlockHeader { +func (m *QueryBlockHeaderByHashResponse) GetBlockHeader() *BlockHeader { if m != nil { return m.BlockHeader } @@ -387,51 +387,51 @@ func init() { proto.RegisterType((*QueryParamsRequest)(nil), "side.btclightclient.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "side.btclightclient.QueryParamsResponse") proto.RegisterType((*QueryChainTipRequest)(nil), "side.btclightclient.QueryChainTipRequest") - proto.RegisterType((*GetChainTipResponse)(nil), "side.btclightclient.GetChainTipResponse") + proto.RegisterType((*QueryChainTipResponse)(nil), "side.btclightclient.QueryChainTipResponse") proto.RegisterType((*QueryBlockHeaderByHeightRequest)(nil), "side.btclightclient.QueryBlockHeaderByHeightRequest") - proto.RegisterType((*GetBlockHeaderByHeightResponse)(nil), "side.btclightclient.GetBlockHeaderByHeightResponse") + proto.RegisterType((*QueryBlockHeaderByHeightResponse)(nil), "side.btclightclient.QueryBlockHeaderByHeightResponse") proto.RegisterType((*QueryBlockHeaderByHashRequest)(nil), "side.btclightclient.QueryBlockHeaderByHashRequest") - proto.RegisterType((*GetBlockHeaderByHashResponse)(nil), "side.btclightclient.GetBlockHeaderByHashResponse") + proto.RegisterType((*QueryBlockHeaderByHashResponse)(nil), "side.btclightclient.QueryBlockHeaderByHashResponse") } func init() { proto.RegisterFile("side/btclightclient/query.proto", fileDescriptor_f299b49d16182dbc) } var fileDescriptor_f299b49d16182dbc = []byte{ - // 540 bytes of a gzipped FileDescriptorProto + // 531 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x92, 0x3f, 0x6f, 0xd3, 0x40, - 0x18, 0xc6, 0x73, 0xa5, 0x8d, 0xc4, 0x5b, 0xa6, 0x4b, 0x14, 0x55, 0xa6, 0x38, 0xd1, 0x49, 0xa8, - 0xa1, 0x52, 0x7d, 0x24, 0x86, 0x21, 0x23, 0xe9, 0xd0, 0x2e, 0x48, 0xc5, 0x62, 0x62, 0x41, 0x67, - 0xf7, 0x64, 0x5b, 0x24, 0x3e, 0x37, 0x77, 0x41, 0x44, 0x55, 0x17, 0x76, 0x24, 0x10, 0x1f, 0x81, - 0xaf, 0xc0, 0xcc, 0xdc, 0xb1, 0x12, 0x0b, 0x13, 0x42, 0x09, 0x1f, 0x04, 0xf9, 0xec, 0x2a, 0x09, - 0x39, 0x93, 0x0c, 0x2c, 0xfe, 0x73, 0xef, 0xfb, 0xbc, 0xcf, 0xef, 0xd5, 0x3d, 0xd0, 0x94, 0xf1, - 0x39, 0xa7, 0xbe, 0x0a, 0x06, 0x71, 0x18, 0x65, 0x4f, 0x9e, 0x28, 0x7a, 0x31, 0xe6, 0xa3, 0x89, - 0x93, 0x8e, 0x84, 0x12, 0xb8, 0x96, 0x35, 0x38, 0xcb, 0x0d, 0x56, 0x3d, 0x14, 0xa1, 0xd0, 0x75, - 0x9a, 0x7d, 0xe5, 0xad, 0xd6, 0x7e, 0x28, 0x44, 0x38, 0xe0, 0x94, 0xa5, 0x31, 0x65, 0x49, 0x22, - 0x14, 0x53, 0xb1, 0x48, 0x64, 0x51, 0x3d, 0x0c, 0x84, 0x1c, 0x0a, 0x49, 0x7d, 0x26, 0x79, 0xee, - 0x40, 0xdf, 0x76, 0x7c, 0xae, 0x58, 0x87, 0xa6, 0x2c, 0x8c, 0x13, 0xdd, 0x5c, 0xf4, 0xb6, 0x4c, -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x7e, 0x73, 0xf8, 0xc0, 0x38, 0x63, 0x35, 0x26, 0x56, 0x7b, 0x7d, - 0x63, 0x0e, 0x4b, 0x1e, 0xbf, 0xff, 0xfe, 0xfb, 0xf3, 0xd6, 0x21, 0x6e, 0xd3, 0x4c, 0xa1, 0xa3, - 0x17, 0x88, 0x01, 0x2d, 0x8f, 0x27, 0xfe, 0x84, 0x60, 0x77, 0x21, 0x19, 0xf8, 0x51, 0xb9, 0xd7, - 0x5f, 0x99, 0x2a, 0xc1, 0x32, 0xc4, 0x8c, 0x1c, 0x69, 0xac, 0x03, 0xfc, 0x70, 0x3d, 0x96, 0x8a, - 0x53, 0xfc, 0x0d, 0x41, 0xc3, 0x9c, 0x17, 0xfc, 0xa4, 0x1c, 0xaf, 0x3c, 0x97, 0x96, 0x5b, 0x46, - 0xfa, 0x8f, 0x48, 0x92, 0x9e, 0x86, 0x76, 0x71, 0x67, 0x3d, 0x74, 0x1e, 0x73, 0x7a, 0x99, 0xbf, - 0xaf, 0xf0, 0x57, 0x04, 0x75, 0x53, 0xa8, 0x70, 0x77, 0x53, 0xfc, 0x79, 0x68, 0xad, 0xce, 0x66, - 0xf0, 0x0b, 0x99, 0x25, 0x4f, 0x35, 0x3a, 0xc5, 0x47, 0x1b, 0xa0, 0x33, 0x19, 0xd1, 0xcb, 0xec, - 0x79, 0xd5, 0x7f, 0x7e, 0x3d, 0xb5, 0xd1, 0xcd, 0xd4, 0x46, 0xbf, 0xa6, 0x36, 0xfa, 0x38, 0xb3, - 0x2b, 0x37, 0x33, 0xbb, 0xf2, 0x63, 0x66, 0x57, 0x5e, 0xb9, 0x61, 0xac, 0xa2, 0xb1, 0xef, 0x04, - 0x62, 0x68, 0x18, 0xf9, 0x6e, 0xe5, 0x12, 0x27, 0x29, 0x97, 0x7e, 0x55, 0x77, 0xb9, 0x7f, 0x02, - 0x00, 0x00, 0xff, 0xff, 0x41, 0xdf, 0x19, 0xc1, 0xb4, 0x05, 0x00, 0x00, + 0x18, 0xc6, 0x73, 0x55, 0x1a, 0x89, 0x37, 0xb0, 0x5c, 0x43, 0x14, 0x19, 0x70, 0x2c, 0x4b, 0xa8, + 0x21, 0x52, 0x7d, 0x24, 0xa6, 0x43, 0xd6, 0x64, 0xe9, 0x82, 0x54, 0x2c, 0x26, 0x16, 0x74, 0x76, + 0x4f, 0xb6, 0x45, 0xe2, 0x73, 0x73, 0x17, 0x44, 0x54, 0x75, 0xe1, 0x13, 0x20, 0x10, 0xdf, 0x84, + 0x81, 0x99, 0xa9, 0x63, 0x25, 0x16, 0x26, 0x84, 0x12, 0x3e, 0x08, 0xf2, 0xf9, 0xaa, 0x26, 0xad, + 0xad, 0xa4, 0x12, 0x8b, 0xff, 0xdc, 0xfb, 0x3e, 0xef, 0xf3, 0x7b, 0x75, 0x0f, 0xb4, 0x45, 0x7c, + 0xc2, 0x88, 0x2f, 0x83, 0x71, 0x1c, 0x46, 0xd9, 0x93, 0x25, 0x92, 0x9c, 0xce, 0xd8, 0x74, 0xee, + 0xa4, 0x53, 0x2e, 0x39, 0xde, 0xcb, 0x1a, 0x9c, 0xf5, 0x06, 0xa3, 0x11, 0xf2, 0x90, 0xab, 0x3a, + 0xc9, 0xbe, 0xf2, 0x56, 0xe3, 0x71, 0xc8, 0x79, 0x38, 0x66, 0x84, 0xa6, 0x31, 0xa1, 0x49, 0xc2, + 0x25, 0x95, 0x31, 0x4f, 0x84, 0xae, 0x76, 0x03, 0x2e, 0x26, 0x5c, 0x10, 0x9f, 0x0a, 0x96, 0x3b, + 0x90, 0xf7, 0x3d, 0x9f, 0x49, 0xda, 0x23, 0x29, 0x0d, 0xe3, 0x44, 0x35, 0xeb, 0x5e, 0xab, 0x88, + 0x2a, 0xa5, 0x53, 0x3a, 0xd1, 0xd3, 0xec, 0x06, 0xe0, 0x57, 0xd9, 0x8c, 0x63, 0x75, 0xe8, 0xb1, + 0xd3, 0x19, 0x13, 0xd2, 0x3e, 0x86, 0xbd, 0xb5, 0x53, 0x91, 0xf2, 0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 0x15, 0xc1, 0x83, 0xb5, 0x90, 0xe0, 0x67, 0xe5, 0x6e, 0x37, 0x02, 0x66, 0x74, 0xb7, 0x69, 0xd5, + 0x68, 0x07, 0x0a, 0x6d, 0x1f, 0x3f, 0xdd, 0x8c, 0x26, 0xe3, 0x14, 0xff, 0x40, 0xd0, 0x2a, 0x0b, + 0x0f, 0x7e, 0x51, 0xee, 0x5b, 0x1e, 0x53, 0xe3, 0xf0, 0x8e, 0x2a, 0x0d, 0x3e, 0x50, 0xe0, 0x2e, + 0xee, 0x6d, 0x06, 0xcf, 0x73, 0x4f, 0xce, 0xf2, 0xf7, 0x39, 0xfe, 0x8e, 0xa0, 0x59, 0x9c, 0x31, + 0xdc, 0xdf, 0x16, 0xe6, 0x3a, 0xc5, 0x86, 0x7b, 0x27, 0x8d, 0xc6, 0x3f, 0x54, 0xf8, 0x04, 0x1f, + 0x6c, 0x81, 0x4f, 0x45, 0x44, 0xce, 0xb2, 0xe7, 0xf9, 0xf0, 0xe5, 0xc5, 0xc2, 0x44, 0x97, 0x0b, + 0x13, 0xfd, 0x59, 0x98, 0xe8, 0xd3, 0xd2, 0xac, 0x5c, 0x2e, 0xcd, 0xca, 0xaf, 0xa5, 0x59, 0x79, + 0xe3, 0x86, 0xb1, 0x8c, 0x66, 0xbe, 0x13, 0xf0, 0x49, 0xc1, 0xc8, 0x0f, 0xb7, 0x2e, 0x73, 0x9e, + 0x32, 0xe1, 0xd7, 0x54, 0x97, 0xfb, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xd4, 0xa0, 0x84, 0x5a, 0xcb, + 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -447,13 +447,13 @@ const _ = grpc.SupportPackageIsVersion4 // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type QueryClient interface { // Parameters queries the parameters of the module. - Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + QueryParams(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) // ChainTip queries the chain tip of the module. - GetChainTip(ctx context.Context, in *QueryChainTipRequest, opts ...grpc.CallOption) (*GetChainTipResponse, error) + QueryChainTip(ctx context.Context, in *QueryChainTipRequest, opts ...grpc.CallOption) (*QueryChainTipResponse, error) // BlockHeaderByHeight queries the block header by height. - GetBlockHeaderByHeight(ctx context.Context, in *QueryBlockHeaderByHeightRequest, opts ...grpc.CallOption) (*GetBlockHeaderByHeightResponse, error) + QueryBlockHeaderByHeight(ctx context.Context, in *QueryBlockHeaderByHeightRequest, opts ...grpc.CallOption) (*QueryBlockHeaderByHeightResponse, error) // BlockHeaderByHash queries the block header by hash. - GetBlockHeaderByHash(ctx context.Context, in *QueryBlockHeaderByHashRequest, opts ...grpc.CallOption) (*GetBlockHeaderByHashResponse, error) + QueryBlockHeaderByHash(ctx context.Context, in *QueryBlockHeaderByHashRequest, opts ...grpc.CallOption) (*QueryBlockHeaderByHashResponse, error) } type queryClient struct { @@ -464,36 +464,36 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { return &queryClient{cc} } -func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { +func (c *queryClient) QueryParams(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { out := new(QueryParamsResponse) - err := c.cc.Invoke(ctx, "/side.btclightclient.Query/Params", in, out, opts...) + err := c.cc.Invoke(ctx, "/side.btclightclient.Query/QueryParams", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *queryClient) GetChainTip(ctx context.Context, in *QueryChainTipRequest, opts ...grpc.CallOption) (*GetChainTipResponse, error) { - out := new(GetChainTipResponse) - err := c.cc.Invoke(ctx, "/side.btclightclient.Query/GetChainTip", in, out, opts...) +func (c *queryClient) QueryChainTip(ctx context.Context, in *QueryChainTipRequest, opts ...grpc.CallOption) (*QueryChainTipResponse, error) { + out := new(QueryChainTipResponse) + err := c.cc.Invoke(ctx, "/side.btclightclient.Query/QueryChainTip", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *queryClient) GetBlockHeaderByHeight(ctx context.Context, in *QueryBlockHeaderByHeightRequest, opts ...grpc.CallOption) (*GetBlockHeaderByHeightResponse, error) { - out := new(GetBlockHeaderByHeightResponse) - err := c.cc.Invoke(ctx, "/side.btclightclient.Query/GetBlockHeaderByHeight", in, out, opts...) +func (c *queryClient) QueryBlockHeaderByHeight(ctx context.Context, in *QueryBlockHeaderByHeightRequest, opts ...grpc.CallOption) (*QueryBlockHeaderByHeightResponse, error) { + out := new(QueryBlockHeaderByHeightResponse) + err := c.cc.Invoke(ctx, "/side.btclightclient.Query/QueryBlockHeaderByHeight", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *queryClient) GetBlockHeaderByHash(ctx context.Context, in *QueryBlockHeaderByHashRequest, opts ...grpc.CallOption) (*GetBlockHeaderByHashResponse, error) { - out := new(GetBlockHeaderByHashResponse) - err := c.cc.Invoke(ctx, "/side.btclightclient.Query/GetBlockHeaderByHash", in, out, opts...) +func (c *queryClient) QueryBlockHeaderByHash(ctx context.Context, in *QueryBlockHeaderByHashRequest, opts ...grpc.CallOption) (*QueryBlockHeaderByHashResponse, error) { + out := new(QueryBlockHeaderByHashResponse) + err := c.cc.Invoke(ctx, "/side.btclightclient.Query/QueryBlockHeaderByHash", in, out, opts...) if err != nil { return nil, err } @@ -503,104 +503,104 @@ func (c *queryClient) GetBlockHeaderByHash(ctx context.Context, in *QueryBlockHe // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. - Params(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) + QueryParams(context.Context, *QueryParamsRequest) (*QueryParamsResponse, error) // ChainTip queries the chain tip of the module. - GetChainTip(context.Context, *QueryChainTipRequest) (*GetChainTipResponse, error) + QueryChainTip(context.Context, *QueryChainTipRequest) (*QueryChainTipResponse, error) // BlockHeaderByHeight queries the block header by height. - GetBlockHeaderByHeight(context.Context, *QueryBlockHeaderByHeightRequest) (*GetBlockHeaderByHeightResponse, error) + QueryBlockHeaderByHeight(context.Context, *QueryBlockHeaderByHeightRequest) (*QueryBlockHeaderByHeightResponse, error) // BlockHeaderByHash queries the block header by hash. - GetBlockHeaderByHash(context.Context, *QueryBlockHeaderByHashRequest) (*GetBlockHeaderByHashResponse, error) + QueryBlockHeaderByHash(context.Context, *QueryBlockHeaderByHashRequest) (*QueryBlockHeaderByHashResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. type UnimplementedQueryServer struct { } -func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") +func (*UnimplementedQueryServer) QueryParams(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryParams not implemented") } -func (*UnimplementedQueryServer) GetChainTip(ctx context.Context, req *QueryChainTipRequest) (*GetChainTipResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetChainTip not implemented") +func (*UnimplementedQueryServer) QueryChainTip(ctx context.Context, req *QueryChainTipRequest) (*QueryChainTipResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryChainTip not implemented") } -func (*UnimplementedQueryServer) GetBlockHeaderByHeight(ctx context.Context, req *QueryBlockHeaderByHeightRequest) (*GetBlockHeaderByHeightResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetBlockHeaderByHeight not implemented") +func (*UnimplementedQueryServer) QueryBlockHeaderByHeight(ctx context.Context, req *QueryBlockHeaderByHeightRequest) (*QueryBlockHeaderByHeightResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryBlockHeaderByHeight not implemented") } -func (*UnimplementedQueryServer) GetBlockHeaderByHash(ctx context.Context, req *QueryBlockHeaderByHashRequest) (*GetBlockHeaderByHashResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method GetBlockHeaderByHash not implemented") +func (*UnimplementedQueryServer) QueryBlockHeaderByHash(ctx context.Context, req *QueryBlockHeaderByHashRequest) (*QueryBlockHeaderByHashResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryBlockHeaderByHash not implemented") } func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) } -func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Query_QueryParams_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryParamsRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).Params(ctx, in) + return srv.(QueryServer).QueryParams(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/side.btclightclient.Query/Params", + FullMethod: "/side.btclightclient.Query/QueryParams", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Params(ctx, req.(*QueryParamsRequest)) + return srv.(QueryServer).QueryParams(ctx, req.(*QueryParamsRequest)) } return interceptor(ctx, in, info, handler) } -func _Query_GetChainTip_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Query_QueryChainTip_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryChainTipRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).GetChainTip(ctx, in) + return srv.(QueryServer).QueryChainTip(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/side.btclightclient.Query/GetChainTip", + FullMethod: "/side.btclightclient.Query/QueryChainTip", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GetChainTip(ctx, req.(*QueryChainTipRequest)) + return srv.(QueryServer).QueryChainTip(ctx, req.(*QueryChainTipRequest)) } return interceptor(ctx, in, info, handler) } -func _Query_GetBlockHeaderByHeight_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Query_QueryBlockHeaderByHeight_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryBlockHeaderByHeightRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).GetBlockHeaderByHeight(ctx, in) + return srv.(QueryServer).QueryBlockHeaderByHeight(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/side.btclightclient.Query/GetBlockHeaderByHeight", + FullMethod: "/side.btclightclient.Query/QueryBlockHeaderByHeight", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GetBlockHeaderByHeight(ctx, req.(*QueryBlockHeaderByHeightRequest)) + return srv.(QueryServer).QueryBlockHeaderByHeight(ctx, req.(*QueryBlockHeaderByHeightRequest)) } return interceptor(ctx, in, info, handler) } -func _Query_GetBlockHeaderByHash_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { +func _Query_QueryBlockHeaderByHash_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(QueryBlockHeaderByHashRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).GetBlockHeaderByHash(ctx, in) + return srv.(QueryServer).QueryBlockHeaderByHash(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/side.btclightclient.Query/GetBlockHeaderByHash", + FullMethod: "/side.btclightclient.Query/QueryBlockHeaderByHash", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).GetBlockHeaderByHash(ctx, req.(*QueryBlockHeaderByHashRequest)) + return srv.(QueryServer).QueryBlockHeaderByHash(ctx, req.(*QueryBlockHeaderByHashRequest)) } return interceptor(ctx, in, info, handler) } @@ -610,20 +610,20 @@ var _Query_serviceDesc = grpc.ServiceDesc{ HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "Params", - Handler: _Query_Params_Handler, + MethodName: "QueryParams", + Handler: _Query_QueryParams_Handler, }, { - MethodName: "GetChainTip", - Handler: _Query_GetChainTip_Handler, + MethodName: "QueryChainTip", + Handler: _Query_QueryChainTip_Handler, }, { - MethodName: "GetBlockHeaderByHeight", - Handler: _Query_GetBlockHeaderByHeight_Handler, + MethodName: "QueryBlockHeaderByHeight", + Handler: _Query_QueryBlockHeaderByHeight_Handler, }, { - MethodName: "GetBlockHeaderByHash", - Handler: _Query_GetBlockHeaderByHash_Handler, + MethodName: "QueryBlockHeaderByHash", + Handler: _Query_QueryBlockHeaderByHash_Handler, }, }, Streams: []grpc.StreamDesc{}, @@ -709,7 +709,7 @@ func (m *QueryChainTipRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *GetChainTipResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryChainTipResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -719,12 +719,12 @@ func (m *GetChainTipResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *GetChainTipResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryChainTipResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *GetChainTipResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryChainTipResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -772,7 +772,7 @@ func (m *QueryBlockHeaderByHeightRequest) MarshalToSizedBuffer(dAtA []byte) (int return len(dAtA) - i, nil } -func (m *GetBlockHeaderByHeightResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryBlockHeaderByHeightResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -782,12 +782,12 @@ func (m *GetBlockHeaderByHeightResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *GetBlockHeaderByHeightResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryBlockHeaderByHeightResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *GetBlockHeaderByHeightResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryBlockHeaderByHeightResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -837,7 +837,7 @@ func (m *QueryBlockHeaderByHashRequest) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } -func (m *GetBlockHeaderByHashResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryBlockHeaderByHashResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -847,12 +847,12 @@ func (m *GetBlockHeaderByHashResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *GetBlockHeaderByHashResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryBlockHeaderByHashResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *GetBlockHeaderByHashResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryBlockHeaderByHashResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -912,7 +912,7 @@ func (m *QueryChainTipRequest) Size() (n int) { return n } -func (m *GetChainTipResponse) Size() (n int) { +func (m *QueryChainTipResponse) Size() (n int) { if m == nil { return 0 } @@ -940,7 +940,7 @@ func (m *QueryBlockHeaderByHeightRequest) Size() (n int) { return n } -func (m *GetBlockHeaderByHeightResponse) Size() (n int) { +func (m *QueryBlockHeaderByHeightResponse) Size() (n int) { if m == nil { return 0 } @@ -966,7 +966,7 @@ func (m *QueryBlockHeaderByHashRequest) Size() (n int) { return n } -func (m *GetBlockHeaderByHashResponse) Size() (n int) { +func (m *QueryBlockHeaderByHashResponse) Size() (n int) { if m == nil { return 0 } @@ -1168,7 +1168,7 @@ func (m *QueryChainTipRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *GetChainTipResponse) Unmarshal(dAtA []byte) error { +func (m *QueryChainTipResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1191,10 +1191,10 @@ func (m *GetChainTipResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: GetChainTipResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryChainTipResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: GetChainTipResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryChainTipResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1243,7 +1243,7 @@ func (m *GetChainTipResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Height |= int64(b&0x7F) << shift + m.Height |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -1312,7 +1312,7 @@ func (m *QueryBlockHeaderByHeightRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Height |= int64(b&0x7F) << shift + m.Height |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -1338,7 +1338,7 @@ func (m *QueryBlockHeaderByHeightRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *GetBlockHeaderByHeightResponse) Unmarshal(dAtA []byte) error { +func (m *QueryBlockHeaderByHeightResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1361,10 +1361,10 @@ func (m *GetBlockHeaderByHeightResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: GetBlockHeaderByHeightResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryBlockHeaderByHeightResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: GetBlockHeaderByHeightResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryBlockHeaderByHeightResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1506,7 +1506,7 @@ func (m *QueryBlockHeaderByHashRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *GetBlockHeaderByHashResponse) Unmarshal(dAtA []byte) error { +func (m *QueryBlockHeaderByHashResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1529,10 +1529,10 @@ func (m *GetBlockHeaderByHashResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: GetBlockHeaderByHashResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryBlockHeaderByHashResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: GetBlockHeaderByHashResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryBlockHeaderByHashResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: diff --git a/x/btclightclient/types/query.pb.gw.go b/x/btclightclient/types/query.pb.gw.go index 0317933c..d27b5688 100644 --- a/x/btclightclient/types/query.pb.gw.go +++ b/x/btclightclient/types/query.pb.gw.go @@ -33,43 +33,43 @@ var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage var _ = metadata.Join -func request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_Query_QueryParams_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryParamsRequest var metadata runtime.ServerMetadata - msg, err := client.Params(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.QueryParams(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_Query_QueryParams_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryParamsRequest var metadata runtime.ServerMetadata - msg, err := server.Params(ctx, &protoReq) + msg, err := server.QueryParams(ctx, &protoReq) return msg, metadata, err } -func request_Query_GetChainTip_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_Query_QueryChainTip_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryChainTipRequest var metadata runtime.ServerMetadata - msg, err := client.GetChainTip(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.QueryChainTip(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_GetChainTip_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_Query_QueryChainTip_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryChainTipRequest var metadata runtime.ServerMetadata - msg, err := server.GetChainTip(ctx, &protoReq) + msg, err := server.QueryChainTip(ctx, &protoReq) return msg, metadata, err } -func request_Query_GetBlockHeaderByHeight_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_Query_QueryBlockHeaderByHeight_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryBlockHeaderByHeightRequest var metadata runtime.ServerMetadata @@ -85,18 +85,18 @@ func request_Query_GetBlockHeaderByHeight_0(ctx context.Context, marshaler runti return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") } - protoReq.Height, err = runtime.Int64(val) + protoReq.Height, err = runtime.Uint64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) } - msg, err := client.GetBlockHeaderByHeight(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.QueryBlockHeaderByHeight(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_GetBlockHeaderByHeight_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_Query_QueryBlockHeaderByHeight_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryBlockHeaderByHeightRequest var metadata runtime.ServerMetadata @@ -112,18 +112,18 @@ func local_request_Query_GetBlockHeaderByHeight_0(ctx context.Context, marshaler return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "height") } - protoReq.Height, err = runtime.Int64(val) + protoReq.Height, err = runtime.Uint64(val) if err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "height", err) } - msg, err := server.GetBlockHeaderByHeight(ctx, &protoReq) + msg, err := server.QueryBlockHeaderByHeight(ctx, &protoReq) return msg, metadata, err } -func request_Query_GetBlockHeaderByHash_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func request_Query_QueryBlockHeaderByHash_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryBlockHeaderByHashRequest var metadata runtime.ServerMetadata @@ -145,12 +145,12 @@ func request_Query_GetBlockHeaderByHash_0(ctx context.Context, marshaler runtime return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "hash", err) } - msg, err := client.GetBlockHeaderByHash(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.QueryBlockHeaderByHash(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_GetBlockHeaderByHash_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { +func local_request_Query_QueryBlockHeaderByHash_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryBlockHeaderByHashRequest var metadata runtime.ServerMetadata @@ -172,7 +172,7 @@ func local_request_Query_GetBlockHeaderByHash_0(ctx context.Context, marshaler r return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "hash", err) } - msg, err := server.GetBlockHeaderByHash(ctx, &protoReq) + msg, err := server.QueryBlockHeaderByHash(ctx, &protoReq) return msg, metadata, err } @@ -183,7 +183,7 @@ func local_request_Query_GetBlockHeaderByHash_0(ctx context.Context, marshaler r // Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_QueryParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -194,7 +194,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_QueryParams_0(rctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -202,11 +202,11 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_QueryParams_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_GetChainTip_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_QueryChainTip_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -217,7 +217,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_GetChainTip_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_QueryChainTip_0(rctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -225,11 +225,11 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_GetChainTip_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_QueryChainTip_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_GetBlockHeaderByHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_QueryBlockHeaderByHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -240,7 +240,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_GetBlockHeaderByHeight_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_QueryBlockHeaderByHeight_0(rctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -248,11 +248,11 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_GetBlockHeaderByHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_QueryBlockHeaderByHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_GetBlockHeaderByHash_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_QueryBlockHeaderByHash_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() var stream runtime.ServerTransportStream @@ -263,7 +263,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_GetBlockHeaderByHash_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_QueryBlockHeaderByHash_0(rctx, inboundMarshaler, server, req, pathParams) md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { @@ -271,7 +271,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } - forward_Query_GetBlockHeaderByHash_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_QueryBlockHeaderByHash_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -316,7 +316,7 @@ func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc // "QueryClient" to call the correct interceptors. func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_QueryParams_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -325,18 +325,18 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_Params_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_QueryParams_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_Params_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_QueryParams_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_GetChainTip_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_QueryChainTip_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -345,18 +345,18 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_GetChainTip_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_QueryChainTip_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_GetChainTip_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_QueryChainTip_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_GetBlockHeaderByHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_QueryBlockHeaderByHeight_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -365,18 +365,18 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_GetBlockHeaderByHeight_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_QueryBlockHeaderByHeight_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_GetBlockHeaderByHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_QueryBlockHeaderByHeight_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) - mux.Handle("GET", pattern_Query_GetBlockHeaderByHash_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_QueryBlockHeaderByHash_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -385,14 +385,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_GetBlockHeaderByHash_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_QueryBlockHeaderByHash_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_GetBlockHeaderByHash_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_QueryBlockHeaderByHash_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -400,21 +400,21 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sideprotocol", "side", "btclightclient", "params"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_QueryParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sideprotocol", "side", "btclightclient", "params"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_GetChainTip_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sideprotocol", "side", "btclightclient", "tip"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_QueryChainTip_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sideprotocol", "side", "btclightclient", "tip"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_GetBlockHeaderByHeight_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 3}, []string{"sideprotocol", "side", "btclightclient", "height"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_QueryBlockHeaderByHeight_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 3}, []string{"sideprotocol", "side", "btclightclient", "height"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_GetBlockHeaderByHash_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 3}, []string{"sideprotocol", "side", "btclightclient", "hash"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_QueryBlockHeaderByHash_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 3}, []string{"sideprotocol", "side", "btclightclient", "hash"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( - forward_Query_Params_0 = runtime.ForwardResponseMessage + forward_Query_QueryParams_0 = runtime.ForwardResponseMessage - forward_Query_GetChainTip_0 = runtime.ForwardResponseMessage + forward_Query_QueryChainTip_0 = runtime.ForwardResponseMessage - forward_Query_GetBlockHeaderByHeight_0 = runtime.ForwardResponseMessage + forward_Query_QueryBlockHeaderByHeight_0 = runtime.ForwardResponseMessage - forward_Query_GetBlockHeaderByHash_0 = runtime.ForwardResponseMessage + forward_Query_QueryBlockHeaderByHash_0 = runtime.ForwardResponseMessage ) diff --git a/x/btclightclient/types/tx.pb.go b/x/btclightclient/types/tx.pb.go index ad2d1645..fee160a2 100644 --- a/x/btclightclient/types/tx.pb.go +++ b/x/btclightclient/types/tx.pb.go @@ -29,23 +29,23 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // MsgBlockHeaderRequest defines the Msg/SubmitBlockHeaders request type. -type MsgBlockHeaderRequest struct { +type MsgSubmitBlockHeaderRequest struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` BlockHeaders []*BlockHeader `protobuf:"bytes,2,rep,name=block_headers,json=blockHeaders,proto3" json:"block_headers,omitempty"` } -func (m *MsgBlockHeaderRequest) Reset() { *m = MsgBlockHeaderRequest{} } -func (m *MsgBlockHeaderRequest) String() string { return proto.CompactTextString(m) } -func (*MsgBlockHeaderRequest) ProtoMessage() {} -func (*MsgBlockHeaderRequest) Descriptor() ([]byte, []int) { +func (m *MsgSubmitBlockHeaderRequest) Reset() { *m = MsgSubmitBlockHeaderRequest{} } +func (m *MsgSubmitBlockHeaderRequest) String() string { return proto.CompactTextString(m) } +func (*MsgSubmitBlockHeaderRequest) ProtoMessage() {} +func (*MsgSubmitBlockHeaderRequest) Descriptor() ([]byte, []int) { return fileDescriptor_4df07798138ba91c, []int{0} } -func (m *MsgBlockHeaderRequest) XXX_Unmarshal(b []byte) error { +func (m *MsgSubmitBlockHeaderRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgBlockHeaderRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgSubmitBlockHeaderRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgBlockHeaderRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgSubmitBlockHeaderRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -55,26 +55,26 @@ func (m *MsgBlockHeaderRequest) XXX_Marshal(b []byte, deterministic bool) ([]byt return b[:n], nil } } -func (m *MsgBlockHeaderRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgBlockHeaderRequest.Merge(m, src) +func (m *MsgSubmitBlockHeaderRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSubmitBlockHeaderRequest.Merge(m, src) } -func (m *MsgBlockHeaderRequest) XXX_Size() int { +func (m *MsgSubmitBlockHeaderRequest) XXX_Size() int { return m.Size() } -func (m *MsgBlockHeaderRequest) XXX_DiscardUnknown() { - xxx_messageInfo_MsgBlockHeaderRequest.DiscardUnknown(m) +func (m *MsgSubmitBlockHeaderRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSubmitBlockHeaderRequest.DiscardUnknown(m) } -var xxx_messageInfo_MsgBlockHeaderRequest proto.InternalMessageInfo +var xxx_messageInfo_MsgSubmitBlockHeaderRequest proto.InternalMessageInfo -func (m *MsgBlockHeaderRequest) GetSender() string { +func (m *MsgSubmitBlockHeaderRequest) GetSender() string { if m != nil { return m.Sender } return "" } -func (m *MsgBlockHeaderRequest) GetBlockHeaders() []*BlockHeader { +func (m *MsgSubmitBlockHeaderRequest) GetBlockHeaders() []*BlockHeader { if m != nil { return m.BlockHeaders } @@ -119,24 +119,24 @@ func (m *MsgSubmitBlockHeadersResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSubmitBlockHeadersResponse proto.InternalMessageInfo // Msg defines the MsgUpdateSender service. -type MsgUpdateSenderRequest struct { +type MsgUpdateSendersRequest struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` // update senders who can send block headers to the side chain Senders []string `protobuf:"bytes,2,rep,name=senders,proto3" json:"senders,omitempty"` } -func (m *MsgUpdateSenderRequest) Reset() { *m = MsgUpdateSenderRequest{} } -func (m *MsgUpdateSenderRequest) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateSenderRequest) ProtoMessage() {} -func (*MsgUpdateSenderRequest) Descriptor() ([]byte, []int) { +func (m *MsgUpdateSendersRequest) Reset() { *m = MsgUpdateSendersRequest{} } +func (m *MsgUpdateSendersRequest) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateSendersRequest) ProtoMessage() {} +func (*MsgUpdateSendersRequest) Descriptor() ([]byte, []int) { return fileDescriptor_4df07798138ba91c, []int{2} } -func (m *MsgUpdateSenderRequest) XXX_Unmarshal(b []byte) error { +func (m *MsgUpdateSendersRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgUpdateSenderRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgUpdateSendersRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgUpdateSenderRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgUpdateSendersRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -146,26 +146,26 @@ func (m *MsgUpdateSenderRequest) XXX_Marshal(b []byte, deterministic bool) ([]by return b[:n], nil } } -func (m *MsgUpdateSenderRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateSenderRequest.Merge(m, src) +func (m *MsgUpdateSendersRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateSendersRequest.Merge(m, src) } -func (m *MsgUpdateSenderRequest) XXX_Size() int { +func (m *MsgUpdateSendersRequest) XXX_Size() int { return m.Size() } -func (m *MsgUpdateSenderRequest) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateSenderRequest.DiscardUnknown(m) +func (m *MsgUpdateSendersRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateSendersRequest.DiscardUnknown(m) } -var xxx_messageInfo_MsgUpdateSenderRequest proto.InternalMessageInfo +var xxx_messageInfo_MsgUpdateSendersRequest proto.InternalMessageInfo -func (m *MsgUpdateSenderRequest) GetSender() string { +func (m *MsgUpdateSendersRequest) GetSender() string { if m != nil { return m.Sender } return "" } -func (m *MsgUpdateSenderRequest) GetSenders() []string { +func (m *MsgUpdateSendersRequest) GetSenders() []string { if m != nil { return m.Senders } @@ -210,37 +210,37 @@ func (m *MsgUpdateSendersResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateSendersResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgBlockHeaderRequest)(nil), "side.btclightclient.MsgBlockHeaderRequest") + proto.RegisterType((*MsgSubmitBlockHeaderRequest)(nil), "side.btclightclient.MsgSubmitBlockHeaderRequest") proto.RegisterType((*MsgSubmitBlockHeadersResponse)(nil), "side.btclightclient.MsgSubmitBlockHeadersResponse") - proto.RegisterType((*MsgUpdateSenderRequest)(nil), "side.btclightclient.MsgUpdateSenderRequest") + proto.RegisterType((*MsgUpdateSendersRequest)(nil), "side.btclightclient.MsgUpdateSendersRequest") proto.RegisterType((*MsgUpdateSendersResponse)(nil), "side.btclightclient.MsgUpdateSendersResponse") } func init() { proto.RegisterFile("side/btclightclient/tx.proto", fileDescriptor_4df07798138ba91c) } var fileDescriptor_4df07798138ba91c = []byte{ - // 330 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0xcf, 0x4a, 0xc3, 0x40, - 0x10, 0xc6, 0x1b, 0x0b, 0x95, 0xae, 0xf6, 0xb2, 0x6a, 0x09, 0x41, 0xd7, 0x90, 0x53, 0x51, 0x4c, - 0xa0, 0x7d, 0x83, 0x82, 0x20, 0x42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x45, 0xcc, 0x5f, - 0x5e, 0xeb, 0x3e, 0xdd, 0x0f, 0x83, 0xd4, 0x7d, 0x14, 0x54, 0x11, 0xba, 0x9b, 0x86, 0x5e, 0x94, - 0x8e, 0x55, 0xba, 0x31, 0xab, 0x5b, 0xc5, 0x56, 0x4f, 0x49, 0x47, 0xa4, 0xb5, 0x15, 0x8b, 0x5e, - 0x56, 0x99, 0x94, 0x6c, 0xc2, 0xba, 0xfa, 0x0f, 0xbc, 0x6e, 0xd6, 0xf7, 0x5f, 0x97, 0xcc, 0x58, - 0x2c, 0x99, 0xf1, 0xbe, 0x64, 0xc6, 0xcb, 0x8a, 0xd5, 0x16, 0x2b, 0x56, 0x7b, 0x5b, 0xb1, 0xda, - 0x7d, 0x4f, 0x24, 0x6a, 0x38, 0xe3, 0x6e, 0x24, 0x27, 0x5e, 0x6e, 0xa9, 0x6f, 0x23, 0x92, 0x63, - 0x2d, 0xbc, 0xf9, 0xce, 0x29, 0x3e, 0xa7, 0x80, 0xbc, 0xa1, 0xa9, 0xde, 0x67, 0x00, 0x00, 0x00, - 0xff, 0xff, 0xe7, 0x2a, 0x56, 0x30, 0xae, 0x02, 0x00, 0x00, + // 329 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0xcd, 0x4a, 0xc3, 0x40, + 0x18, 0x6c, 0x2c, 0x54, 0xba, 0xda, 0xcb, 0x2a, 0x1a, 0xa2, 0xc6, 0x90, 0x53, 0x0f, 0x9a, 0x48, + 0xfb, 0x06, 0x05, 0x41, 0x90, 0x5c, 0x52, 0xbc, 0x78, 0x91, 0x6c, 0xf2, 0xb1, 0x0d, 0xa6, 0xdd, + 0x98, 0x6f, 0x0b, 0x55, 0x7c, 0x08, 0x1f, 0xcb, 0x63, 0x8f, 0x1e, 0xa5, 0x7d, 0x00, 0x5f, 0x41, + 0xb2, 0xeb, 0x5f, 0x49, 0xd4, 0x5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0x72, 0xf4, 0xe4, + 0x37, 0x93, 0xba, 0x85, 0x58, 0xa7, 0x6b, 0xaa, 0x75, 0xda, 0x20, 0x78, 0x5e, 0xd8, 0xc6, 0x7c, + 0x61, 0x1b, 0xaf, 0x0b, 0xdb, 0x78, 0x5a, 0xda, 0x8d, 0xf9, 0xd2, 0x6e, 0xbc, 0x2c, 0xed, 0xc6, + 0x75, 0x9f, 0xa7, 0x72, 0x34, 0x65, 0x5e, 0x2c, 0xc6, 0x7e, 0x69, 0xa9, 0x2e, 0x25, 0x16, 0x99, + 0x02, 0xfe, 0xac, 0x72, 0x98, 0xf7, 0x39, 0x20, 0x6b, 0x29, 0x55, 0xff, 0x3d, 0x00, 0x00, 0xff, + 0xff, 0x52, 0x8a, 0xda, 0x6b, 0xbc, 0x02, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -256,9 +256,9 @@ const _ = grpc.SupportPackageIsVersion4 // 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 { // SubmitBlockHeaders submits bitcoin block headers to the side chain. - SubmitBlockHeaders(ctx context.Context, in *MsgBlockHeaderRequest, opts ...grpc.CallOption) (*MsgSubmitBlockHeadersResponse, error) + SubmitBlockHeaders(ctx context.Context, in *MsgSubmitBlockHeaderRequest, opts ...grpc.CallOption) (*MsgSubmitBlockHeadersResponse, error) // UpdateSenders updates the senders of the side chain. - UpdateSenders(ctx context.Context, in *MsgUpdateSenderRequest, opts ...grpc.CallOption) (*MsgUpdateSendersResponse, error) + UpdateSenders(ctx context.Context, in *MsgUpdateSendersRequest, opts ...grpc.CallOption) (*MsgUpdateSendersResponse, error) } type msgClient struct { @@ -269,7 +269,7 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } -func (c *msgClient) SubmitBlockHeaders(ctx context.Context, in *MsgBlockHeaderRequest, opts ...grpc.CallOption) (*MsgSubmitBlockHeadersResponse, error) { +func (c *msgClient) SubmitBlockHeaders(ctx context.Context, in *MsgSubmitBlockHeaderRequest, opts ...grpc.CallOption) (*MsgSubmitBlockHeadersResponse, error) { out := new(MsgSubmitBlockHeadersResponse) err := c.cc.Invoke(ctx, "/side.btclightclient.Msg/SubmitBlockHeaders", in, out, opts...) if err != nil { @@ -278,7 +278,7 @@ func (c *msgClient) SubmitBlockHeaders(ctx context.Context, in *MsgBlockHeaderRe return out, nil } -func (c *msgClient) UpdateSenders(ctx context.Context, in *MsgUpdateSenderRequest, opts ...grpc.CallOption) (*MsgUpdateSendersResponse, error) { +func (c *msgClient) UpdateSenders(ctx context.Context, in *MsgUpdateSendersRequest, opts ...grpc.CallOption) (*MsgUpdateSendersResponse, error) { out := new(MsgUpdateSendersResponse) err := c.cc.Invoke(ctx, "/side.btclightclient.Msg/UpdateSenders", in, out, opts...) if err != nil { @@ -290,19 +290,19 @@ func (c *msgClient) UpdateSenders(ctx context.Context, in *MsgUpdateSenderReques // MsgServer is the server API for Msg service. type MsgServer interface { // SubmitBlockHeaders submits bitcoin block headers to the side chain. - SubmitBlockHeaders(context.Context, *MsgBlockHeaderRequest) (*MsgSubmitBlockHeadersResponse, error) + SubmitBlockHeaders(context.Context, *MsgSubmitBlockHeaderRequest) (*MsgSubmitBlockHeadersResponse, error) // UpdateSenders updates the senders of the side chain. - UpdateSenders(context.Context, *MsgUpdateSenderRequest) (*MsgUpdateSendersResponse, error) + UpdateSenders(context.Context, *MsgUpdateSendersRequest) (*MsgUpdateSendersResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. type UnimplementedMsgServer struct { } -func (*UnimplementedMsgServer) SubmitBlockHeaders(ctx context.Context, req *MsgBlockHeaderRequest) (*MsgSubmitBlockHeadersResponse, error) { +func (*UnimplementedMsgServer) SubmitBlockHeaders(ctx context.Context, req *MsgSubmitBlockHeaderRequest) (*MsgSubmitBlockHeadersResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SubmitBlockHeaders not implemented") } -func (*UnimplementedMsgServer) UpdateSenders(ctx context.Context, req *MsgUpdateSenderRequest) (*MsgUpdateSendersResponse, error) { +func (*UnimplementedMsgServer) UpdateSenders(ctx context.Context, req *MsgUpdateSendersRequest) (*MsgUpdateSendersResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateSenders not implemented") } @@ -311,7 +311,7 @@ func RegisterMsgServer(s grpc1.Server, srv MsgServer) { } func _Msg_SubmitBlockHeaders_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgBlockHeaderRequest) + in := new(MsgSubmitBlockHeaderRequest) if err := dec(in); err != nil { return nil, err } @@ -323,13 +323,13 @@ func _Msg_SubmitBlockHeaders_Handler(srv interface{}, ctx context.Context, dec f FullMethod: "/side.btclightclient.Msg/SubmitBlockHeaders", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).SubmitBlockHeaders(ctx, req.(*MsgBlockHeaderRequest)) + return srv.(MsgServer).SubmitBlockHeaders(ctx, req.(*MsgSubmitBlockHeaderRequest)) } return interceptor(ctx, in, info, handler) } func _Msg_UpdateSenders_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateSenderRequest) + in := new(MsgUpdateSendersRequest) if err := dec(in); err != nil { return nil, err } @@ -341,7 +341,7 @@ func _Msg_UpdateSenders_Handler(srv interface{}, ctx context.Context, dec func(i FullMethod: "/side.btclightclient.Msg/UpdateSenders", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateSenders(ctx, req.(*MsgUpdateSenderRequest)) + return srv.(MsgServer).UpdateSenders(ctx, req.(*MsgUpdateSendersRequest)) } return interceptor(ctx, in, info, handler) } @@ -363,7 +363,7 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Metadata: "side/btclightclient/tx.proto", } -func (m *MsgBlockHeaderRequest) Marshal() (dAtA []byte, err error) { +func (m *MsgSubmitBlockHeaderRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -373,12 +373,12 @@ func (m *MsgBlockHeaderRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgBlockHeaderRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgSubmitBlockHeaderRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgBlockHeaderRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgSubmitBlockHeaderRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -430,7 +430,7 @@ func (m *MsgSubmitBlockHeadersResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } -func (m *MsgUpdateSenderRequest) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdateSendersRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -440,12 +440,12 @@ func (m *MsgUpdateSenderRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgUpdateSenderRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateSendersRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdateSenderRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateSendersRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -503,7 +503,7 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *MsgBlockHeaderRequest) Size() (n int) { +func (m *MsgSubmitBlockHeaderRequest) Size() (n int) { if m == nil { return 0 } @@ -531,7 +531,7 @@ func (m *MsgSubmitBlockHeadersResponse) Size() (n int) { return n } -func (m *MsgUpdateSenderRequest) Size() (n int) { +func (m *MsgUpdateSendersRequest) Size() (n int) { if m == nil { return 0 } @@ -565,7 +565,7 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *MsgBlockHeaderRequest) Unmarshal(dAtA []byte) error { +func (m *MsgSubmitBlockHeaderRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -588,10 +588,10 @@ func (m *MsgBlockHeaderRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgBlockHeaderRequest: wiretype end group for non-group") + return fmt.Errorf("proto: MsgSubmitBlockHeaderRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgBlockHeaderRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgSubmitBlockHeaderRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -731,7 +731,7 @@ func (m *MsgSubmitBlockHeadersResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateSenderRequest) Unmarshal(dAtA []byte) error { +func (m *MsgUpdateSendersRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -754,10 +754,10 @@ func (m *MsgUpdateSenderRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateSenderRequest: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdateSendersRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateSenderRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdateSendersRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: From fa76f87f72b3d6fe966e9be66160c2f49fc91310 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Mon, 13 May 2024 12:59:10 +0800 Subject: [PATCH 06/71] add module integration --- app/app.go | 2 ++ app/keepers/keepers.go | 13 ++++++++++++- app/keepers/modules.go | 2 ++ app/modules.go | 7 +++++++ x/btclightclient/client/cli/query.go | 1 + x/btclightclient/client/cli/tx.go | 3 +++ x/btclightclient/genesis_test.go | 4 ++++ x/btclightclient/keeper/keeper.go | 6 +++--- x/btclightclient/keeper/queries.go | 4 ++++ x/btclightclient/types/codec.go | 8 ++++---- x/btclightclient/types/genesis.go | 22 ++++++++++++++++++++-- x/btclightclient/types/params.go | 2 +- 12 files changed, 63 insertions(+), 11 deletions(-) diff --git a/app/app.go b/app/app.go index 61087881..d14095ce 100644 --- a/app/app.go +++ b/app/app.go @@ -60,6 +60,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/spf13/cast" + btclightclienttypes "github.com/sideprotocol/side/x/btclightclient/types" gmmmoduletypes "github.com/sideprotocol/side/x/gmm/types" yieldmoduletypes "github.com/sideprotocol/side/x/yield/types" @@ -270,6 +271,7 @@ func New( wasmTypes.ModuleName, gmmmoduletypes.ModuleName, yieldmoduletypes.ModuleName, + btclightclienttypes.ModuleName, // this line is used by starport scaffolding # stargate/app/initGenesis } app.mm.SetOrderInitGenesis(OrderInitGenesis()...) diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 525f8b4b..44a73be6 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -73,6 +73,9 @@ import ( yieldmodulekeeper "github.com/sideprotocol/side/x/yield/keeper" yieldmoduletypes "github.com/sideprotocol/side/x/yield/types" + btclightclientkeeper "github.com/sideprotocol/side/x/btclightclient/keeper" + btclightclienttypes "github.com/sideprotocol/side/x/btclightclient/types" + // this line is used by starport scaffolding # stargate/app/moduleImport appparams "github.com/sideprotocol/side/app/params" @@ -128,7 +131,8 @@ type AppKeepers struct { GmmKeeper gmmmodulekeeper.Keeper - YieldKeeper yieldmodulekeeper.Keeper + YieldKeeper yieldmodulekeeper.Keeper + BtcLightClientKeeper btclightclientkeeper.Keeper // keys to access the substores keys map[string]*storetypes.KVStoreKey @@ -389,6 +393,12 @@ func (appKeepers *AppKeepers) InitNormalKeepers( appKeepers.IcacallbacksKeeper, ) + appKeepers.BtcLightClientKeeper = *btclightclientkeeper.NewKeeper( + appCodec, + appKeepers.keys[btclightclienttypes.StoreKey], + appKeepers.keys[btclightclienttypes.StoreKey], + ) + // The last arguments can contain custom message handlers, and custom query handlers, // if we want to allow any custom callbacks supportedFeatures := "iterator,staking,stargate,side,cosmwasm_1_1,cosmwasm_1_2,cosmwasm_1_4" @@ -493,6 +503,7 @@ func KVStoreKeys() []string { ibcfeetypes.StoreKey, gmmmoduletypes.StoreKey, yieldmoduletypes.StoreKey, + btclightclienttypes.StoreKey, } } diff --git a/app/keepers/modules.go b/app/keepers/modules.go index 5e5a6255..c4f007f3 100644 --- a/app/keepers/modules.go +++ b/app/keepers/modules.go @@ -38,6 +38,7 @@ import ( yieldmodule "github.com/sideprotocol/side/x/yield" + btcmodule "github.com/sideprotocol/side/x/btclightclient" // this line is used by starport scaffolding # stargate/app/moduleImport // wasmd module integrate @@ -74,6 +75,7 @@ var AppModuleBasics = module.NewBasicManager( wasm.AppModuleBasic{}, gmmmodule.AppModuleBasic{}, yieldmodule.AppModuleBasic{}, + btcmodule.AppModuleBasic{}, ) func getGovProposalHandlers() []govclient.ProposalHandler { diff --git a/app/modules.go b/app/modules.go index 30d761a3..b4b061af 100644 --- a/app/modules.go +++ b/app/modules.go @@ -67,6 +67,9 @@ import ( yieldmodule "github.com/sideprotocol/side/x/yield" yieldmoduletypes "github.com/sideprotocol/side/x/yield/types" + "github.com/sideprotocol/side/x/btclightclient" + btclightclienttypes "github.com/sideprotocol/side/x/btclightclient/types" + // this line is used by starport scaffolding # stargate/app/moduleImport appparams "github.com/sideprotocol/side/app/params" @@ -138,6 +141,7 @@ func appModules( icaModule, gmmModule, yieldModule, + btclightclient.NewAppModule(appCodec, app.BtcLightClientKeeper), // this line is used by starport scaffolding # stargate/app/appModule crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), // always be last to make sure that it checks for all invariants and not only part of them @@ -173,6 +177,7 @@ func orderBeginBlockers() []string { wasmTypes.ModuleName, gmmmoduletypes.ModuleName, yieldmoduletypes.ModuleName, + btclightclienttypes.ModuleName, } return ord } @@ -205,6 +210,7 @@ func OrderEndBlockers() []string { wasmTypes.ModuleName, gmmmoduletypes.ModuleName, yieldmoduletypes.ModuleName, + btclightclienttypes.ModuleName, } return ord } @@ -242,6 +248,7 @@ func OrderInitGenesis() []string { wasmTypes.ModuleName, gmmmoduletypes.ModuleName, yieldmoduletypes.ModuleName, + btclightclienttypes.ModuleName, } } diff --git a/x/btclightclient/client/cli/query.go b/x/btclightclient/client/cli/query.go index f0c51ec8..63f48604 100644 --- a/x/btclightclient/client/cli/query.go +++ b/x/btclightclient/client/cli/query.go @@ -27,6 +27,7 @@ func GetQueryCmd(_ string) *cobra.Command { } cmd.AddCommand(CmdQueryParams()) + cmd.AddCommand(CmdBestBlock()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/btclightclient/client/cli/tx.go b/x/btclightclient/client/cli/tx.go index 4441e91b..17440ce8 100644 --- a/x/btclightclient/client/cli/tx.go +++ b/x/btclightclient/client/cli/tx.go @@ -103,6 +103,9 @@ func CmdUpdateSenders() *cobra.Command { return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) }, } + + flags.AddTxFlagsToCmd(cmd) + return cmd } diff --git a/x/btclightclient/genesis_test.go b/x/btclightclient/genesis_test.go index de3ff5f9..9df8b423 100644 --- a/x/btclightclient/genesis_test.go +++ b/x/btclightclient/genesis_test.go @@ -11,6 +11,10 @@ import ( ) func TestGenesis(t *testing.T) { + + mnemonic := "sunny bamboo garlic fold reopen exile letter addict forest vessel square lunar shell number deliver cruise calm artist fire just kangaroo suit wheel extend" + println(mnemonic) + genesisState := types.GenesisState{ Params: types.DefaultParams(), diff --git a/x/btclightclient/keeper/keeper.go b/x/btclightclient/keeper/keeper.go index 5dfa6153..491f368f 100644 --- a/x/btclightclient/keeper/keeper.go +++ b/x/btclightclient/keeper/keeper.go @@ -52,10 +52,10 @@ func (k Keeper) GetParams(ctx sdk.Context) types.Params { func (k Keeper) GetBestBlockHeader(ctx sdk.Context) *types.BlockHeader { store := ctx.KVStore(k.storeKey) - var blockHeader *types.BlockHeader + var blockHeader types.BlockHeader bz := store.Get(types.BtcBestBlockHeaderKey) - k.cdc.MustUnmarshal(bz, blockHeader) - return blockHeader + k.cdc.MustUnmarshal(bz, &blockHeader) + return &blockHeader } func (k Keeper) SetBestBlockHeader(ctx sdk.Context, header *types.BlockHeader) { diff --git a/x/btclightclient/keeper/queries.go b/x/btclightclient/keeper/queries.go index 9471b9ae..6ab1da71 100644 --- a/x/btclightclient/keeper/queries.go +++ b/x/btclightclient/keeper/queries.go @@ -28,6 +28,10 @@ func (k Keeper) QueryChainTip(goCtx context.Context, req *types.QueryChainTipReq best := k.GetBestBlockHeader(ctx) + println("============================================") + println("best", best) + println("============================================") + return &types.QueryChainTipResponse{ Hash: best.Hash, Height: best.Height, diff --git a/x/btclightclient/types/codec.go b/x/btclightclient/types/codec.go index 31febfa6..3fb14daa 100644 --- a/x/btclightclient/types/codec.go +++ b/x/btclightclient/types/codec.go @@ -9,17 +9,17 @@ import ( func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgSubmitBlockHeaderRequest{}, "btclightclient/MsgSubmitBlockHeaderRequest", nil) - cdc.RegisterConcrete(&MsgSubmitBlockHeadersResponse{}, "btclightclient/MsgSubmitBlockHeadersResponse", nil) + // cdc.RegisterConcrete(&MsgSubmitBlockHeadersResponse{}, "btclightclient/MsgSubmitBlockHeadersResponse", nil) cdc.RegisterConcrete(&MsgUpdateSendersRequest{}, "btclightclient/MsgUpdateSendersRequest", nil) - cdc.RegisterConcrete(&MsgUpdateSendersResponse{}, "btclightclient/MsgUpdateSendersResponse", nil) + // cdc.RegisterConcrete(&MsgUpdateSendersResponse{}, "btclightclient/MsgUpdateSendersResponse", nil) // this line is used by starport scaffolding # 2 } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSubmitBlockHeaderRequest{}) - registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSubmitBlockHeadersResponse{}) + // registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSubmitBlockHeadersResponse{}) registry.RegisterImplementations((*sdk.Msg)(nil), &MsgUpdateSendersRequest{}) - registry.RegisterImplementations((*sdk.Msg)(nil), &MsgUpdateSendersResponse{}) + // registry.RegisterImplementations((*sdk.Msg)(nil), &MsgUpdateSendersResponse{}) // this line is used by starport scaffolding # 3 msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/btclightclient/types/genesis.go b/x/btclightclient/types/genesis.go index 1289d5f3..dd03237c 100644 --- a/x/btclightclient/types/genesis.go +++ b/x/btclightclient/types/genesis.go @@ -2,12 +2,27 @@ package types // this line is used by starport scaffolding # genesis/types/import +func DefaultBestBlockHeader() *BlockHeader { + // testnet3 block 2815023 + return &BlockHeader{ + Version: 667459584, + Hash: "0000000000000009fb68da72e8994f014fafb455c72978233b94580b12af778c", + Height: 2815023, + PreviousBlockHash: "0000000000000004a29c20eb32532718de8072665620edb4c657b22b4d463967", + MerkleRoot: "9e219423eadce80e882cdff04b3026c9bbc994fd08a774f34a705ca3e710a332", + Time: 1715566066, + Bits: "191881b8", + Nonce: 3913166971, + Ntx: 6236, + } +} + // DefaultGenesis returns the default genesis state func DefaultGenesis() *GenesisState { return &GenesisState{ // this line is used by starport scaffolding # genesis/types/default Params: DefaultParams(), - BestBlockHeader: &BlockHeader{}, + BestBlockHeader: DefaultBestBlockHeader(), BlockHeaders: []*BlockHeader{}, } } @@ -16,6 +31,9 @@ func DefaultGenesis() *GenesisState { // failure. func (gs GenesisState) Validate() error { // this line is used by starport scaffolding # genesis/types/validate - + // need to be improved by checking the block headers & best block header + if gs.BestBlockHeader == nil || gs.BestBlockHeader.Hash == "" || gs.BestBlockHeader.PreviousBlockHash == "" || gs.BestBlockHeader.MerkleRoot == "" { + return ErrInvalidHeader + } return gs.Params.Validate() } diff --git a/x/btclightclient/types/params.go b/x/btclightclient/types/params.go index 94ef8642..e6b552de 100644 --- a/x/btclightclient/types/params.go +++ b/x/btclightclient/types/params.go @@ -11,7 +11,7 @@ func NewParams(senders []string) Params { // DefaultParams returns a default set of parameters func DefaultParams() Params { - return NewParams([]string{"bc1quq8hw0763rkqqeuarznh9nd6esrnl4684apaqr"}) + return NewParams([]string{"bc1qtxqfntu4340j3vhasnrrnm8tvf2t3z7gu9dysz"}) } // Validate validates the set of params From cde3180bf0aa1616247fdc121fd4fe35295179a3 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Tue, 14 May 2024 21:59:27 +0800 Subject: [PATCH 07/71] remove debug --- x/btclightclient/keeper/queries.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/x/btclightclient/keeper/queries.go b/x/btclightclient/keeper/queries.go index 6ab1da71..9471b9ae 100644 --- a/x/btclightclient/keeper/queries.go +++ b/x/btclightclient/keeper/queries.go @@ -28,10 +28,6 @@ func (k Keeper) QueryChainTip(goCtx context.Context, req *types.QueryChainTipReq best := k.GetBestBlockHeader(ctx) - println("============================================") - println("best", best) - println("============================================") - return &types.QueryChainTipResponse{ Hash: best.Hash, Height: best.Height, From 22727df9223cf1176cf355e8c58b58d4da91ecef Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Wed, 15 May 2024 16:04:57 +0800 Subject: [PATCH 08/71] add version to header --- x/btclightclient/keeper/util.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/btclightclient/keeper/util.go b/x/btclightclient/keeper/util.go index 989c2a7b..8f3706de 100644 --- a/x/btclightclient/keeper/util.go +++ b/x/btclightclient/keeper/util.go @@ -15,7 +15,7 @@ func HeaderConvert(header *types.BlockHeader) *wire.BlockHeader { n := new(big.Int) n.SetString(header.Bits, 16) return &wire.BlockHeader{ - Version: 0, + Version: int32(header.Version), PrevBlock: *prehash, MerkleRoot: *root, Timestamp: time.Unix(int64(header.Time), 0), From 423f2cb70c8c9ae7da0ee023d42826c7654b1f91 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Wed, 15 May 2024 16:05:19 +0800 Subject: [PATCH 09/71] add parameters --- proto/side/btclightclient/params.proto | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/proto/side/btclightclient/params.proto b/proto/side/btclightclient/params.proto index 5914b3a0..4433e1fa 100644 --- a/proto/side/btclightclient/params.proto +++ b/proto/side/btclightclient/params.proto @@ -9,6 +9,12 @@ option go_package = "github.com/sideprotocol/side/x/btclightclient/types"; message Params { // Only accept blocks sending from these addresses repeated string senders = 1; + // The minimum number of confirmations required for a block to be accepted + int32 confirmations = 2; + // Indicates the maximum depth or distance from the latest block up to which transactions are considered for acceptance. + uint64 max_acceptable_block_depth = 3; + // the denomanation of the voucher + string btc_voucher_denom = 4; } // Bitcoin Block Header From 0955b91644b3f9d93d5e5db609a92f8c7c96dd0f Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Fri, 17 May 2024 16:30:35 +0800 Subject: [PATCH 10/71] add btc transaction --- proto/side/btclightclient/tx.proto | 13 + x/btclightclient/keeper/keeper.go | 38 ++ x/btclightclient/keeper/msg_server.go | 21 + x/btclightclient/types/errors.go | 4 + .../types/message_submit_transaction.go | 58 +++ x/btclightclient/types/params.go | 5 +- x/btclightclient/types/params.pb.go | 172 ++++++- x/btclightclient/types/tx.pb.go | 483 +++++++++++++++++- 8 files changed, 748 insertions(+), 46 deletions(-) create mode 100644 x/btclightclient/types/message_submit_transaction.go diff --git a/proto/side/btclightclient/tx.proto b/proto/side/btclightclient/tx.proto index 22237dd0..5113f98e 100644 --- a/proto/side/btclightclient/tx.proto +++ b/proto/side/btclightclient/tx.proto @@ -11,6 +11,8 @@ option go_package = "github.com/sideprotocol/side/x/btclightclient/types"; service Msg { // SubmitBlockHeaders submits bitcoin block headers to the side chain. rpc SubmitBlockHeaders (MsgSubmitBlockHeaderRequest) returns (MsgSubmitBlockHeadersResponse); + // SubmitTransaction submits bitcoin transaction to the side chain. + rpc SubmitTransaction (MsgSubmitTransactionRequest) returns (MsgSubmitTransactionResponse); // UpdateSenders updates the senders of the side chain. rpc UpdateSenders (MsgUpdateSendersRequest) returns (MsgUpdateSendersResponse); } @@ -25,6 +27,17 @@ message MsgSubmitBlockHeaderRequest { message MsgSubmitBlockHeadersResponse { } +// MsgSubmitTransactionRequest defines the Msg/SubmitTransaction request type. +message MsgSubmitTransactionRequest { + string sender = 1; + string tx = 2; + string proof = 3; +} + +// MsgSubmitTransactionResponse defines the Msg/SubmitTransaction response type. +message MsgSubmitTransactionResponse { +} + // Msg defines the MsgUpdateSender service. message MsgUpdateSendersRequest { string sender = 1; diff --git a/x/btclightclient/keeper/keeper.go b/x/btclightclient/keeper/keeper.go index 491f368f..941b0276 100644 --- a/x/btclightclient/keeper/keeper.go +++ b/x/btclightclient/keeper/keeper.go @@ -1,10 +1,13 @@ package keeper import ( + "bytes" + "encoding/hex" "fmt" "github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/wire" "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -124,6 +127,41 @@ func (k Keeper) SetBlockHeaders(ctx sdk.Context, blockHeader []*types.BlockHeade return nil } +// Process Bitcoin Transaction +func (k Keeper) ProcessBitcoinTransaction(ctx sdk.Context, txHexByte, proof string) error { + + // Decode the hexadecimal transaction + txBytes, err := hex.DecodeString(txHexByte) + if err != nil { + fmt.Println("Error decoding hex:", err) + return err + } + + // Create a new transaction + var tx wire.MsgTx + err = tx.Deserialize(bytes.NewReader(txBytes)) + if err != nil { + fmt.Println("Error deserializing transaction:", err) + return err + } + + // Validate the transaction + // cfg := &chaincfg.MainNetParams // Use MainNetParams or TestNet3Params as per your network + if err := blockchain.CheckTransactionSanity(&tx); err != nil { + fmt.Println("Transaction is not valid:", err) + return err + } + if err != nil { + return err + } + + ctx.Logger().Debug("Processing Transaction", tx) + + // transaction.MsgTx(). + + return nil +} + func (k Keeper) GetBlockHeader(ctx sdk.Context, hash string) *types.BlockHeader { store := ctx.KVStore(k.storeKey) var blockHeader *types.BlockHeader diff --git a/x/btclightclient/keeper/msg_server.go b/x/btclightclient/keeper/msg_server.go index 81c2f37e..ba05da68 100644 --- a/x/btclightclient/keeper/msg_server.go +++ b/x/btclightclient/keeper/msg_server.go @@ -42,6 +42,27 @@ func (m msgServer) SubmitBlockHeaders(goCtx context.Context, msg *types.MsgSubmi return &types.MsgSubmitBlockHeadersResponse{}, nil } +// SubmitBtcTransaction implements types.MsgServer. +// No Permission check required for this message +// Since everyone can submit a transaction to mint voucher tokens +// This message is usually sent by relayers +func (m msgServer) SubmitBtcTransaction(goCtx context.Context, msg *types.MsgSubmitTransactionRequest) (*types.MsgSubmitTransactionResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if err := msg.ValidateBasic(); err != nil { + return nil, err + } + + if err := m.ProcessBitcoinTransaction(ctx, msg.Tx, msg.Proof); err != nil { + return nil, err + } + + // Emit Events + + return &types.MsgSubmitTransactionResponse{}, nil + +} + // UpdateSenders implements types.MsgServer. func (m msgServer) UpdateSenders(goCtx context.Context, msg *types.MsgUpdateSendersRequest) (*types.MsgUpdateSendersResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) diff --git a/x/btclightclient/types/errors.go b/x/btclightclient/types/errors.go index abf396db..fe2f825a 100644 --- a/x/btclightclient/types/errors.go +++ b/x/btclightclient/types/errors.go @@ -14,4 +14,8 @@ var ( ErrForkedBlockHeader = errorsmod.Register(ModuleName, 1102, "Invalid forked block header") ErrInvalidSenders = errorsmod.Register(ModuleName, 2100, "invalid allowed senders") + + ErrInvalidBtcTransaction = errorsmod.Register(ModuleName, 3100, "invalid bitcoin transaction") + ErrNotConfirmed = errorsmod.Register(ModuleName, 3200, "transaction not confirmed") + ErrExceedMaxAcceptanceDepth = errorsmod.Register(ModuleName, 3201, "exceed max acceptance block depth") ) diff --git a/x/btclightclient/types/message_submit_transaction.go b/x/btclightclient/types/message_submit_transaction.go new file mode 100644 index 00000000..6173e524 --- /dev/null +++ b/x/btclightclient/types/message_submit_transaction.go @@ -0,0 +1,58 @@ +package types + +import ( + sdkerrors "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const TypeMsgSubmitTransaction = "submit_transaction" + +func NewMsgSubmitTransactionRequest( + sender string, + transaction string, + proof string, +) *MsgSubmitTransactionRequest { + return &MsgSubmitTransactionRequest{ + Sender: sender, + Tx: transaction, + Proof: proof, + } +} + +func (msg *MsgSubmitTransactionRequest) Route() string { + return RouterKey +} + +func (msg *MsgSubmitTransactionRequest) Type() string { + return TypeMsgSubmitTransaction +} + +func (msg *MsgSubmitTransactionRequest) GetSigners() []sdk.AccAddress { + Sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{Sender} +} + +func (msg *MsgSubmitTransactionRequest) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgSubmitTransactionRequest) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return sdkerrors.Wrapf(err, "invalid Sender address (%s)", err) + } + + if len(msg.Tx) == 0 { + return sdkerrors.Wrap(ErrInvalidBtcTransaction, "transaction cannot be empty") + } + + if len(msg.Proof) == 0 { + return sdkerrors.Wrap(ErrInvalidBtcTransaction, "proof cannot be empty") + } + + return nil +} diff --git a/x/btclightclient/types/params.go b/x/btclightclient/types/params.go index e6b552de..0f5fdd9a 100644 --- a/x/btclightclient/types/params.go +++ b/x/btclightclient/types/params.go @@ -5,7 +5,10 @@ import sdk "github.com/cosmos/cosmos-sdk/types" // NewParams creates a new Params instance func NewParams(senders []string) Params { return Params{ - Senders: senders, + Senders: senders, + Confirmations: 2, + MaxAcceptableBlockDepth: 100, + BtcVoucherDenom: "sat", } } diff --git a/x/btclightclient/types/params.pb.go b/x/btclightclient/types/params.pb.go index 2bc9feca..51f8e801 100644 --- a/x/btclightclient/types/params.pb.go +++ b/x/btclightclient/types/params.pb.go @@ -27,6 +27,12 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Params struct { // Only accept blocks sending from these addresses Senders []string `protobuf:"bytes,1,rep,name=senders,proto3" json:"senders,omitempty"` + // The minimum number of confirmations required for a block to be accepted + Confirmations int32 `protobuf:"varint,2,opt,name=confirmations,proto3" json:"confirmations,omitempty"` + // Indicates the maximum depth or distance from the latest block up to which transactions are considered for acceptance. + MaxAcceptableBlockDepth uint64 `protobuf:"varint,3,opt,name=max_acceptable_block_depth,json=maxAcceptableBlockDepth,proto3" json:"max_acceptable_block_depth,omitempty"` + // the denomanation of the voucher + BtcVoucherDenom string `protobuf:"bytes,4,opt,name=btc_voucher_denom,json=btcVoucherDenom,proto3" json:"btc_voucher_denom,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -69,6 +75,27 @@ func (m *Params) GetSenders() []string { return nil } +func (m *Params) GetConfirmations() int32 { + if m != nil { + return m.Confirmations + } + return 0 +} + +func (m *Params) GetMaxAcceptableBlockDepth() uint64 { + if m != nil { + return m.MaxAcceptableBlockDepth + } + return 0 +} + +func (m *Params) GetBtcVoucherDenom() string { + if m != nil { + return m.BtcVoucherDenom + } + return "" +} + // Bitcoin Block Header type BlockHeader struct { Version uint64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` @@ -186,27 +213,33 @@ func init() { func init() { proto.RegisterFile("side/btclightclient/params.proto", fileDescriptor_3b47f8b78acf6f6e) } var fileDescriptor_3b47f8b78acf6f6e = []byte{ - // 318 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x91, 0xbf, 0x6e, 0xfa, 0x30, - 0x10, 0xc7, 0xf1, 0x0f, 0x08, 0x3f, 0xcc, 0xd2, 0x1a, 0x54, 0x59, 0x1d, 0xd2, 0x88, 0x89, 0x29, - 0x19, 0x78, 0x03, 0xa6, 0x2e, 0x95, 0xaa, 0x8c, 0x5d, 0x50, 0x12, 0x4e, 0x89, 0x45, 0xe2, 0x8b, - 0x6c, 0x83, 0xe8, 0x5b, 0xf4, 0xb1, 0x3a, 0x32, 0x76, 0xac, 0xe0, 0x15, 0xfa, 0x00, 0x95, 0x2f, - 0xcd, 0xd0, 0x2e, 0xd6, 0xf7, 0x7b, 0xf7, 0xb9, 0x3f, 0x3a, 0xf3, 0xc8, 0xaa, 0x1d, 0x24, 0xb9, - 0x2b, 0x6a, 0x55, 0x56, 0xfe, 0x05, 0xed, 0x92, 0x36, 0x33, 0x59, 0x63, 0xe3, 0xd6, 0xa0, 0x43, - 0x31, 0xf7, 0x44, 0xfc, 0x9b, 0xb8, 0x5f, 0x94, 0x58, 0x22, 0xe5, 0x13, 0xaf, 0x3a, 0x74, 0xb9, - 0xe4, 0xc1, 0x33, 0x95, 0x0a, 0xc9, 0x27, 0x16, 0xf4, 0x0e, 0x8c, 0x95, 0x2c, 0x1a, 0xae, 0xa6, - 0x69, 0x6f, 0x97, 0x5f, 0x8c, 0xcf, 0x36, 0x35, 0x16, 0xfb, 0x47, 0xc8, 0x76, 0x60, 0x3c, 0x79, - 0x04, 0x63, 0x15, 0x6a, 0xc9, 0x22, 0xb6, 0x1a, 0xa5, 0xbd, 0x15, 0x82, 0x8f, 0xaa, 0xcc, 0x56, - 0xf2, 0x5f, 0xc4, 0x56, 0xd3, 0x94, 0xb4, 0xb8, 0xe3, 0x41, 0x05, 0x7e, 0x0f, 0x39, 0x24, 0xf8, - 0xc7, 0x89, 0x98, 0xcf, 0x5b, 0x03, 0x47, 0x85, 0x07, 0xbb, 0xcd, 0x7d, 0xf7, 0x2d, 0x95, 0x8e, - 0xa8, 0xf4, 0xb6, 0x4f, 0x75, 0x73, 0x7d, 0x9f, 0x07, 0x3e, 0x6b, 0xc0, 0xec, 0x6b, 0xd8, 0x1a, - 0x44, 0x27, 0xc7, 0xc4, 0xf1, 0x2e, 0x94, 0x22, 0x3a, 0xb1, 0xe0, 0x63, 0x8d, 0xba, 0x00, 0x19, - 0xd0, 0x9c, 0xce, 0xf8, 0x95, 0x72, 0xe5, 0xac, 0x9c, 0x74, 0x2b, 0x79, 0xed, 0x63, 0x4e, 0x35, - 0x20, 0xff, 0x13, 0x48, 0x5a, 0xdc, 0xf0, 0xa1, 0x76, 0x27, 0x39, 0xa5, 0x90, 0x97, 0x9b, 0xa7, - 0xf7, 0x4b, 0xc8, 0xce, 0x97, 0x90, 0x7d, 0x5e, 0x42, 0xf6, 0x76, 0x0d, 0x07, 0xe7, 0x6b, 0x38, - 0xf8, 0xb8, 0x86, 0x83, 0x97, 0x75, 0xa9, 0x5c, 0x75, 0xc8, 0xe3, 0x02, 0x9b, 0xc4, 0x9f, 0x9a, - 0x4e, 0x59, 0x60, 0x4d, 0x26, 0x39, 0xfd, 0xfd, 0x1b, 0xf7, 0xda, 0x82, 0xcd, 0x03, 0xa2, 0xd6, - 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xef, 0x0a, 0xe2, 0x23, 0xbf, 0x01, 0x00, 0x00, + // 404 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x52, 0x3d, 0x8e, 0xd4, 0x30, + 0x14, 0x1e, 0x33, 0x3f, 0xcb, 0x78, 0x85, 0x60, 0xbd, 0x2b, 0xb0, 0xb6, 0x08, 0xd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 0xff, 0xff, 0x08, 0x42, 0x8d, 0x83, + 0x4f, 0x02, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -229,6 +262,23 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.BtcVoucherDenom) > 0 { + i -= len(m.BtcVoucherDenom) + copy(dAtA[i:], m.BtcVoucherDenom) + i = encodeVarintParams(dAtA, i, uint64(len(m.BtcVoucherDenom))) + i-- + dAtA[i] = 0x22 + } + if m.MaxAcceptableBlockDepth != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.MaxAcceptableBlockDepth)) + i-- + dAtA[i] = 0x18 + } + if m.Confirmations != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.Confirmations)) + i-- + dAtA[i] = 0x10 + } if len(m.Senders) > 0 { for iNdEx := len(m.Senders) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.Senders[iNdEx]) @@ -340,6 +390,16 @@ func (m *Params) Size() (n int) { n += 1 + l + sovParams(uint64(l)) } } + if m.Confirmations != 0 { + n += 1 + sovParams(uint64(m.Confirmations)) + } + if m.MaxAcceptableBlockDepth != 0 { + n += 1 + sovParams(uint64(m.MaxAcceptableBlockDepth)) + } + l = len(m.BtcVoucherDenom) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } return n } @@ -450,6 +510,76 @@ func (m *Params) Unmarshal(dAtA []byte) error { } m.Senders = append(m.Senders, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Confirmations", wireType) + } + m.Confirmations = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Confirmations |= int32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MaxAcceptableBlockDepth", wireType) + } + m.MaxAcceptableBlockDepth = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MaxAcceptableBlockDepth |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BtcVoucherDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BtcVoucherDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/btclightclient/types/tx.pb.go b/x/btclightclient/types/tx.pb.go index fee160a2..7c3c3971 100644 --- a/x/btclightclient/types/tx.pb.go +++ b/x/btclightclient/types/tx.pb.go @@ -118,6 +118,104 @@ func (m *MsgSubmitBlockHeadersResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSubmitBlockHeadersResponse proto.InternalMessageInfo +// MsgSubmitTransactionRequest defines the Msg/SubmitTransaction request type. +type MsgSubmitTransactionRequest struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Tx string `protobuf:"bytes,2,opt,name=tx,proto3" json:"tx,omitempty"` + Proof string `protobuf:"bytes,3,opt,name=proof,proto3" json:"proof,omitempty"` +} + +func (m *MsgSubmitTransactionRequest) Reset() { *m = MsgSubmitTransactionRequest{} } +func (m *MsgSubmitTransactionRequest) String() string { return proto.CompactTextString(m) } +func (*MsgSubmitTransactionRequest) ProtoMessage() {} +func (*MsgSubmitTransactionRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4df07798138ba91c, []int{2} +} +func (m *MsgSubmitTransactionRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSubmitTransactionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSubmitTransactionRequest.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 *MsgSubmitTransactionRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSubmitTransactionRequest.Merge(m, src) +} +func (m *MsgSubmitTransactionRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgSubmitTransactionRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSubmitTransactionRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSubmitTransactionRequest proto.InternalMessageInfo + +func (m *MsgSubmitTransactionRequest) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgSubmitTransactionRequest) GetTx() string { + if m != nil { + return m.Tx + } + return "" +} + +func (m *MsgSubmitTransactionRequest) GetProof() string { + if m != nil { + return m.Proof + } + return "" +} + +// MsgSubmitTransactionResponse defines the Msg/SubmitTransaction response type. +type MsgSubmitTransactionResponse struct { +} + +func (m *MsgSubmitTransactionResponse) Reset() { *m = MsgSubmitTransactionResponse{} } +func (m *MsgSubmitTransactionResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSubmitTransactionResponse) ProtoMessage() {} +func (*MsgSubmitTransactionResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4df07798138ba91c, []int{3} +} +func (m *MsgSubmitTransactionResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSubmitTransactionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSubmitTransactionResponse.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 *MsgSubmitTransactionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSubmitTransactionResponse.Merge(m, src) +} +func (m *MsgSubmitTransactionResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSubmitTransactionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSubmitTransactionResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSubmitTransactionResponse proto.InternalMessageInfo + // Msg defines the MsgUpdateSender service. type MsgUpdateSendersRequest struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` @@ -129,7 +227,7 @@ func (m *MsgUpdateSendersRequest) Reset() { *m = MsgUpdateSendersRequest func (m *MsgUpdateSendersRequest) String() string { return proto.CompactTextString(m) } func (*MsgUpdateSendersRequest) ProtoMessage() {} func (*MsgUpdateSendersRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_4df07798138ba91c, []int{2} + return fileDescriptor_4df07798138ba91c, []int{4} } func (m *MsgUpdateSendersRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -180,7 +278,7 @@ func (m *MsgUpdateSendersResponse) Reset() { *m = MsgUpdateSendersRespon func (m *MsgUpdateSendersResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateSendersResponse) ProtoMessage() {} func (*MsgUpdateSendersResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4df07798138ba91c, []int{3} + return fileDescriptor_4df07798138ba91c, []int{5} } func (m *MsgUpdateSendersResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -212,6 +310,8 @@ var xxx_messageInfo_MsgUpdateSendersResponse proto.InternalMessageInfo func init() { proto.RegisterType((*MsgSubmitBlockHeaderRequest)(nil), "side.btclightclient.MsgSubmitBlockHeaderRequest") proto.RegisterType((*MsgSubmitBlockHeadersResponse)(nil), "side.btclightclient.MsgSubmitBlockHeadersResponse") + proto.RegisterType((*MsgSubmitTransactionRequest)(nil), "side.btclightclient.MsgSubmitTransactionRequest") + proto.RegisterType((*MsgSubmitTransactionResponse)(nil), "side.btclightclient.MsgSubmitTransactionResponse") proto.RegisterType((*MsgUpdateSendersRequest)(nil), "side.btclightclient.MsgUpdateSendersRequest") proto.RegisterType((*MsgUpdateSendersResponse)(nil), "side.btclightclient.MsgUpdateSendersResponse") } @@ -219,28 +319,32 @@ func init() { func init() { proto.RegisterFile("side/btclightclient/tx.proto", fileDescriptor_4df07798138ba91c) } var fileDescriptor_4df07798138ba91c = []byte{ - // 329 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0xcd, 0x4a, 0xc3, 0x40, - 0x18, 0x6c, 0x2c, 0x54, 0xba, 0xda, 0xcb, 0x2a, 0x1a, 0xa2, 0xc6, 0x90, 0x53, 0x0f, 0x9a, 0x48, - 0xfb, 0x06, 0x05, 0x41, 0x90, 0x5c, 0x52, 0xbc, 0x78, 0x91, 0x6c, 0xf2, 0xb1, 0x0d, 0xa6, 0xdd, - 0x98, 0x6f, 0x0b, 0x55, 0x7c, 0x08, 0x1f, 0xcb, 0x63, 0x8f, 0x1e, 0xa5, 0x7d, 0x00, 0x5f, 0x41, - 0xb2, 0xeb, 0x5f, 0x49, 0xd4, 0x5e, 0xc2, 0x37, 0xcc, 0x64, 0x66, 0xf6, 0xe3, 0x23, 0x87, 0x98, - 0x26, 0xe0, 0x33, 0x19, 0x67, 0x29, 0x1f, 0x95, 0x5f, 0x98, 0x48, 0x5f, 0xce, 0xbc, 0xbc, 0x10, - 0x52, 0xd0, 0x9d, 0x92, 0xf5, 0x56, 0x59, 0x6b, 0x97, 0x0b, 0x2e, 0x14, 0xef, 0x97, 0x93, 0x96, - 0x5a, 0x4e, 0x9d, 0x51,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 0x69, 0xa9, 0x2e, 0x25, 0x16, 0x99, - 0x02, 0xfe, 0xac, 0x72, 0x98, 0xf7, 0x39, 0x20, 0x6b, 0x29, 0x55, 0xff, 0x3d, 0x00, 0x00, 0xff, - 0xff, 0x52, 0x8a, 0xda, 0x6b, 0xbc, 0x02, 0x00, 0x00, + // 389 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x4d, 0x4b, 0xc3, 0x40, + 0x10, 0x6d, 0x52, 0xac, 0x74, 0xb5, 0x82, 0x6b, 0xd1, 0x10, 0x6b, 0x0c, 0x39, 0xf5, 0xa0, 0x89, + 0xb6, 0xff, 0xa0, 0x20, 0x08, 0x92, 0x4b, 0xaa, 0x17, 0x3d, 0x48, 0x3e, 0xd6, 0x34, 0x98, 0x66, + 0x63, 0x66, 0x0b, 0x51, 0xfc, 0x11, 0xfe, 0x2c, 0x8f, 0x3d, 0x7a, 0x94, 0xf6, 0xe4, 0xbf, 0x90, + 0x6c, 0xaa, 0xb6, 0x24, 0xda, 0x7a, 0x59, 0xf6, 0xed, 0xbc, 0x7d, 0x6f, 0x78, 0xc3, 0xa0, 0x16, + 0x04, 0x1e, 0x31, 0x1c, 0xe6, 0x86, 0x81, 0x3f, 0xc8, 0x4e, 0x12, 0x31, 0x83, 0xa5, 0x7a, 0x9c, + 0x50, 0x46, 0xf1, 0x4e, 0x56, 0xd5, 0x17, 0xab, 0x72, 0xd3, 0xa7, 0x3e, 0xe5, 0x75, 0x23, 0xbb, + 0xe5, 0x54, 0x59, 0x2d, 0x13, 0x8a, 0xed, 0xc4, 0x1e, 0x42, 0xce, 0xd0, 0x9e, 0xd1, 0xbe, 0x09, + 0x7e, 0x7f, 0xe4, 0x0c, 0x03, 0xd6, 0x0b, 0xa9, 0x7b, 0x7f, 0x4e, 0x6c, 0x8f, 0x24, 0x16, 0x79, + 0x18, 0x11, 0x60, 0x78, 0x17, 0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 0xe1, 0x7d, 0xa2, + 0x08, 0x2f, 0x53, 0xa5, 0x32, 0x9e, 0x2a, 0x95, 0xb7, 0xa9, 0x52, 0xb9, 0xee, 0xfa, 0x01, 0x1b, + 0x8c, 0x1c, 0xdd, 0xa5, 0x43, 0x23, 0x93, 0xe4, 0x0b, 0xe2, 0xd2, 0x90, 0x03, 0x23, 0x2d, 0xec, + 0xe3, 0x63, 0x4c, 0xc0, 0xa9, 0x71, 0x56, 0xf7, 0x33, 0x00, 0x00, 0xff, 0xff, 0x08, 0x0a, 0x8e, + 0x18, 0xb3, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -257,6 +361,8 @@ const _ = grpc.SupportPackageIsVersion4 type MsgClient interface { // SubmitBlockHeaders submits bitcoin block headers to the side chain. SubmitBlockHeaders(ctx context.Context, in *MsgSubmitBlockHeaderRequest, opts ...grpc.CallOption) (*MsgSubmitBlockHeadersResponse, error) + // SubmitTransaction submits bitcoin transaction to the side chain. + SubmitTransaction(ctx context.Context, in *MsgSubmitTransactionRequest, opts ...grpc.CallOption) (*MsgSubmitTransactionResponse, error) // UpdateSenders updates the senders of the side chain. UpdateSenders(ctx context.Context, in *MsgUpdateSendersRequest, opts ...grpc.CallOption) (*MsgUpdateSendersResponse, error) } @@ -278,6 +384,15 @@ func (c *msgClient) SubmitBlockHeaders(ctx context.Context, in *MsgSubmitBlockHe return out, nil } +func (c *msgClient) SubmitTransaction(ctx context.Context, in *MsgSubmitTransactionRequest, opts ...grpc.CallOption) (*MsgSubmitTransactionResponse, error) { + out := new(MsgSubmitTransactionResponse) + err := c.cc.Invoke(ctx, "/side.btclightclient.Msg/SubmitTransaction", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) UpdateSenders(ctx context.Context, in *MsgUpdateSendersRequest, opts ...grpc.CallOption) (*MsgUpdateSendersResponse, error) { out := new(MsgUpdateSendersResponse) err := c.cc.Invoke(ctx, "/side.btclightclient.Msg/UpdateSenders", in, out, opts...) @@ -291,6 +406,8 @@ func (c *msgClient) UpdateSenders(ctx context.Context, in *MsgUpdateSendersReque type MsgServer interface { // SubmitBlockHeaders submits bitcoin block headers to the side chain. SubmitBlockHeaders(context.Context, *MsgSubmitBlockHeaderRequest) (*MsgSubmitBlockHeadersResponse, error) + // SubmitTransaction submits bitcoin transaction to the side chain. + SubmitTransaction(context.Context, *MsgSubmitTransactionRequest) (*MsgSubmitTransactionResponse, error) // UpdateSenders updates the senders of the side chain. UpdateSenders(context.Context, *MsgUpdateSendersRequest) (*MsgUpdateSendersResponse, error) } @@ -302,6 +419,9 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) SubmitBlockHeaders(ctx context.Context, req *MsgSubmitBlockHeaderRequest) (*MsgSubmitBlockHeadersResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SubmitBlockHeaders not implemented") } +func (*UnimplementedMsgServer) SubmitTransaction(ctx context.Context, req *MsgSubmitTransactionRequest) (*MsgSubmitTransactionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SubmitTransaction not implemented") +} func (*UnimplementedMsgServer) UpdateSenders(ctx context.Context, req *MsgUpdateSendersRequest) (*MsgUpdateSendersResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateSenders not implemented") } @@ -328,6 +448,24 @@ func _Msg_SubmitBlockHeaders_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } +func _Msg_SubmitTransaction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSubmitTransactionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SubmitTransaction(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/side.btclightclient.Msg/SubmitTransaction", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SubmitTransaction(ctx, req.(*MsgSubmitTransactionRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_UpdateSenders_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgUpdateSendersRequest) if err := dec(in); err != nil { @@ -354,6 +492,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "SubmitBlockHeaders", Handler: _Msg_SubmitBlockHeaders_Handler, }, + { + MethodName: "SubmitTransaction", + Handler: _Msg_SubmitTransaction_Handler, + }, { MethodName: "UpdateSenders", Handler: _Msg_UpdateSenders_Handler, @@ -430,6 +572,73 @@ func (m *MsgSubmitBlockHeadersResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *MsgSubmitTransactionRequest) 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 *MsgSubmitTransactionRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSubmitTransactionRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Proof) > 0 { + i -= len(m.Proof) + copy(dAtA[i:], m.Proof) + i = encodeVarintTx(dAtA, i, uint64(len(m.Proof))) + i-- + dAtA[i] = 0x1a + } + if len(m.Tx) > 0 { + i -= len(m.Tx) + copy(dAtA[i:], m.Tx) + i = encodeVarintTx(dAtA, i, uint64(len(m.Tx))) + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSubmitTransactionResponse) 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 *MsgSubmitTransactionResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSubmitTransactionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func (m *MsgUpdateSendersRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -531,6 +740,36 @@ func (m *MsgSubmitBlockHeadersResponse) Size() (n int) { return n } +func (m *MsgSubmitTransactionRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Tx) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Proof) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgSubmitTransactionResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func (m *MsgUpdateSendersRequest) Size() (n int) { if m == nil { return 0 @@ -731,6 +970,202 @@ func (m *MsgSubmitBlockHeadersResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgSubmitTransactionRequest) 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: MsgSubmitTransactionRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSubmitTransactionRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Tx", 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.Tx = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", 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.Proof = 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 *MsgSubmitTransactionResponse) 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: MsgSubmitTransactionResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSubmitTransactionResponse: 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 (m *MsgUpdateSendersRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 From 3062f2b201f2c0f3c5393385491eda39a4373f0e Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Fri, 24 May 2024 09:33:29 +0800 Subject: [PATCH 11/71] completed mint --- app/app.go | 7 +- app/keepers/keepers.go | 1 + cmd/sided/cmd/config.go | 12 +- go.mod | 6 +- go.sum | 2 - local_node.sh | 16 +- proto/side/btclightclient/params.proto | 2 + proto/side/btclightclient/tx.proto | 9 +- testutil/keeper/btc_light_client.go | 6 +- x/btclightclient/client/cli/query.go | 6 +- x/btclightclient/keeper/keeper.go | 122 +++++++++-- x/btclightclient/keeper/msg_server.go | 6 +- x/btclightclient/types/codec.go | 6 +- x/btclightclient/types/errors.go | 2 + x/btclightclient/types/expected_keepers.go | 20 ++ x/btclightclient/types/keys.go | 3 + x/btclightclient/types/merkle_proof.go | 39 ++++ .../types/message_submit_transaction.go | 20 +- x/btclightclient/types/params.pb.go | 111 +++++++--- x/btclightclient/types/tx.pb.go | 202 ++++++++++++++---- 20 files changed, 477 insertions(+), 121 deletions(-) create mode 100644 x/btclightclient/types/merkle_proof.go diff --git a/app/app.go b/app/app.go index d14095ce..59fecd38 100644 --- a/app/app.go +++ b/app/app.go @@ -9,6 +9,7 @@ import ( autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" + "github.com/btcsuite/btcd/chaincfg" dbm "github.com/cometbft/cometbft-db" abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/libs/log" @@ -85,8 +86,8 @@ import ( ) const ( - AccountAddressPrefix = "bc" - Name = "side" + // AccountAddressPrefix = "bc" + Name = "side" ) var Upgrades = []upgrades.Upgrade{v1.Upgrade, v2.Upgrade} @@ -102,6 +103,8 @@ var ( // and genesis verification. ModuleBasics = keepers.AppModuleBasics + BitcoinChainCfg = chaincfg.MainNetParams + // module account permissions ) diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 44a73be6..4ed09599 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -397,6 +397,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers( appCodec, appKeepers.keys[btclightclienttypes.StoreKey], appKeepers.keys[btclightclienttypes.StoreKey], + appKeepers.BankKeeper, ) // The last arguments can contain custom message handlers, and custom query handlers, diff --git a/cmd/sided/cmd/config.go b/cmd/sided/cmd/config.go index aba94a3a..14f80879 100644 --- a/cmd/sided/cmd/config.go +++ b/cmd/sided/cmd/config.go @@ -8,15 +8,15 @@ import ( func initSDKConfig() { // Set prefixes - accountPubKeyPrefix := app.AccountAddressPrefix + "pub" - validatorAddressPrefix := app.AccountAddressPrefix + "valoper" - validatorPubKeyPrefix := app.AccountAddressPrefix + "valoperpub" - consNodeAddressPrefix := app.AccountAddressPrefix + "valcons" - consNodePubKeyPrefix := app.AccountAddressPrefix + "valconspub" + accountPubKeyPrefix := app.BitcoinChainCfg.Bech32HRPSegwit + "pub" + validatorAddressPrefix := app.BitcoinChainCfg.Bech32HRPSegwit + "valoper" + validatorPubKeyPrefix := app.BitcoinChainCfg.Bech32HRPSegwit + "valoperpub" + consNodeAddressPrefix := app.BitcoinChainCfg.Bech32HRPSegwit + "valcons" + consNodePubKeyPrefix := app.BitcoinChainCfg.Bech32HRPSegwit + "valconspub" // Set and seal config config := sdk.GetConfig() - config.SetBech32PrefixForAccount(app.AccountAddressPrefix, accountPubKeyPrefix) + config.SetBech32PrefixForAccount(app.BitcoinChainCfg.Bech32HRPSegwit, accountPubKeyPrefix) config.SetBech32PrefixForValidator(validatorAddressPrefix, validatorPubKeyPrefix) config.SetBech32PrefixForConsensusNode(consNodeAddressPrefix, consNodePubKeyPrefix) diff --git a/go.mod b/go.mod index 96b995bc..0da0cb9e 100644 --- a/go.mod +++ b/go.mod @@ -41,7 +41,6 @@ require ( github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect - github.com/btcsuite/btcd/btcutil v1.1.5 // indirect github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f // indirect github.com/bufbuild/connect-go v1.0.0 // indirect github.com/bufbuild/protocompile v0.8.0 // indirect @@ -215,6 +214,7 @@ require ( github.com/CosmWasm/wasmvm v1.5.2 github.com/Stride-Labs/stride/v16 v16.0.0 github.com/btcsuite/btcd v0.24.1-0.20240318151728-2fc99e0496d2 + github.com/btcsuite/btcd/btcutil v1.1.5 github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 github.com/bufbuild/buf v1.7.0 github.com/cosmos/cosmos-proto v1.0.0-beta.4 @@ -230,8 +230,8 @@ require ( ) replace ( - github.com/cosmos/cosmos-sdk => github.com/sideprotocol/cosmos-sdk v0.47.116 - // github.com/cosmos/cosmos-sdk => ../cosmos-sdk + // github.com/cosmos/cosmos-sdk => github.com/sideprotocol/cosmos-sdk v0.47.116 + github.com/cosmos/cosmos-sdk => ../cosmos-sdk github.com/cosmos/interchain-security/v3 => github.com/Stride-Labs/interchain-security/v3 v3.1.0-remove-validation-bug-7d3d9d github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 diff --git a/go.sum b/go.sum index f8f4e1b5..fdac66a0 100644 --- a/go.sum +++ b/go.sum @@ -973,8 +973,6 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/sideprotocol/cosmos-sdk v0.47.116 h1:9qXEko5qj+RVHR5a01dheCjqzw5MlnYqxu36fqJm5MU= -github.com/sideprotocol/cosmos-sdk v0.47.116/go.mod h1:Ql8d4j8oRXssuNQfVIaa6LRo7VsFMJgSy2Qckd/dcr0= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= diff --git a/local_node.sh b/local_node.sh index 520198e3..0ac139e5 100755 --- a/local_node.sh +++ b/local_node.sh @@ -5,14 +5,14 @@ CHAINID="S2-testnet-1" MONIKER="Side Labs" BINARY="$HOME/go/bin/sided" DENOM_STR="uside,ubtct,uusdc,uusdc.axl,uusdc.noble,uusdt,uusdt.kava,uusdt.axl,uwbtc.axl,uwbtc.osmo,uwbtc" - +INITIAL_ACCOUNT_STR="bc1q4h88d5xg2cxxcm2kaej32lx6gkdfrxslfaxm8n" set -f IFS=, DENOMS=($DENOM_STR) +INITIAL_ACCOUNTS=($INITIAL_ACCOUNT_STR) IFS=";" - INITIAL_SUPPLY="500000000000000" BLOCK_GAS=10000000 MAX_GAS=10000000000 @@ -103,6 +103,18 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then $BINARY add-genesis-account "$KEY" ${BALANCES:1} --keyring-backend $KEYRING --home "$HOMEDIR" done + # Allocate genesis accounts (cosmos formatted addresses) + for ADDR in "${INITIAL_ACCOUNTS[@]}"; do + BALANCES="" + for key in "${!DENOMS[@]}"; do + BALANCES+=",${INITIAL_SUPPLY}${DENOMS[$key]}" + done + echo ${BALANCES:1} + $BINARY add-genesis-account "$ADDR" ${BALANCES:1} --home "$HOMEDIR" + done + + + # Sign genesis transaction echo $INITIAL_SUPPLY${DENOMS[0]} $BINARY gentx "${KEYS[0]}" $INITIAL_SUPPLY${DENOMS[0]} --keyring-backend $KEYRING --chain-id $CHAINID --identity "666AC57CC678BEC4" --website="https://side.one" --home "$HOMEDIR" diff --git a/proto/side/btclightclient/params.proto b/proto/side/btclightclient/params.proto index 4433e1fa..2ec5f322 100644 --- a/proto/side/btclightclient/params.proto +++ b/proto/side/btclightclient/params.proto @@ -15,6 +15,8 @@ message Params { uint64 max_acceptable_block_depth = 3; // the denomanation of the voucher string btc_voucher_denom = 4; + // the address to which the voucher is sent + repeated string btc_voucher_address = 5; } // Bitcoin Block Header diff --git a/proto/side/btclightclient/tx.proto b/proto/side/btclightclient/tx.proto index 5113f98e..8a57b832 100644 --- a/proto/side/btclightclient/tx.proto +++ b/proto/side/btclightclient/tx.proto @@ -30,8 +30,13 @@ message MsgSubmitBlockHeadersResponse { // MsgSubmitTransactionRequest defines the Msg/SubmitTransaction request type. message MsgSubmitTransactionRequest { string sender = 1; - string tx = 2; - string proof = 3; + string blockhash = 2; + // the tx bytes in base64 format + // used for parsing the sender of the transaction + string prev_tx_bytes = 3; + // the tx bytes in base64 format + string tx_bytes = 4; + repeated string proof = 5; } // MsgSubmitTransactionResponse defines the Msg/SubmitTransaction response type. diff --git a/testutil/keeper/btc_light_client.go b/testutil/keeper/btc_light_client.go index 5b5e5a6a..fb57d765 100644 --- a/testutil/keeper/btc_light_client.go +++ b/testutil/keeper/btc_light_client.go @@ -11,16 +11,17 @@ import ( "github.com/cosmos/cosmos-sdk/store" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/sideprotocol/side/app" "github.com/sideprotocol/side/x/btclightclient/keeper" "github.com/sideprotocol/side/x/btclightclient/types" "github.com/stretchr/testify/require" ) func BtcLightClientKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { - // app := app.InitSideTestApp(false) + app := app.InitSideTestApp(false) storeKey := sdk.NewKVStoreKey(types.StoreKey) - memStoreKey := storetypes.NewMemoryStoreKey(types.StoreKey) + memStoreKey := storetypes.NewMemoryStoreKey(types.ModuleName) db := tmdb.NewMemDB() stateStore := store.NewCommitMultiStore(db) @@ -35,6 +36,7 @@ func BtcLightClientKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { cdc, storeKey, memStoreKey, + app.BankKeeper, ) ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) diff --git a/x/btclightclient/client/cli/query.go b/x/btclightclient/client/cli/query.go index 63f48604..e831815c 100644 --- a/x/btclightclient/client/cli/query.go +++ b/x/btclightclient/client/cli/query.go @@ -4,15 +4,11 @@ import ( "fmt" // "strings" + "github.com/sideprotocol/side/x/btclightclient/types" "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - - // "github.com/cosmos/cosmos-sdk/client/flags" - // sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/sideprotocol/side/x/btclightclient/types" ) // GetQueryCmd returns the cli query commands for this module diff --git a/x/btclightclient/keeper/keeper.go b/x/btclightclient/keeper/keeper.go index 941b0276..cb9d9dbb 100644 --- a/x/btclightclient/keeper/keeper.go +++ b/x/btclightclient/keeper/keeper.go @@ -2,11 +2,15 @@ package keeper import ( "bytes" - "encoding/hex" + "encoding/base64" "fmt" + "slices" "github.com/btcsuite/btcd/blockchain" + "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" @@ -20,6 +24,8 @@ type ( cdc codec.BinaryCodec storeKey storetypes.StoreKey memKey storetypes.StoreKey + + bankKeeper types.BankKeeper } ) @@ -27,11 +33,14 @@ func NewKeeper( cdc codec.BinaryCodec, storeKey, memKey storetypes.StoreKey, + + bankKeeper types.BankKeeper, ) *Keeper { return &Keeper{ - cdc: cdc, - storeKey: storeKey, - memKey: memKey, + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + bankKeeper: bankKeeper, } } @@ -127,13 +136,32 @@ func (k Keeper) SetBlockHeaders(ctx sdk.Context, blockHeader []*types.BlockHeade return nil } -// Process Bitcoin Transaction -func (k Keeper) ProcessBitcoinTransaction(ctx sdk.Context, txHexByte, proof string) error { +// Process Bitcoin Deposit Transaction +func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.MsgSubmitTransactionRequest) error { + + ctx.Logger().Debug("Processing Transaction in block: ", msg.Blockhash) + + param := k.GetParams(ctx) + header := k.GetBlockHeader(ctx, msg.Blockhash) + // Check if block confirmed + if header == nil { + return types.ErrBlockNotFound + } + + best := k.GetBestBlockHeader(ctx) + // Check if the block is confirmed + if best.Height-header.Height < uint64(param.Confirmations) { + return types.ErrNotConfirmed + } + // Check if the block is within the acceptable depth + if best.Height-header.Height > param.MaxAcceptableBlockDepth { + return types.ErrExceedMaxAcceptanceDepth + } - // Decode the hexadecimal transaction - txBytes, err := hex.DecodeString(txHexByte) + // Decode the base64 transaction + txBytes, err := base64.StdEncoding.DecodeString(msg.TxBytes) if err != nil { - fmt.Println("Error decoding hex:", err) + fmt.Println("Error decoding transaction from base64:", err) return err } @@ -144,20 +172,88 @@ func (k Keeper) ProcessBitcoinTransaction(ctx sdk.Context, txHexByte, proof stri fmt.Println("Error deserializing transaction:", err) return err } + uTx := btcutil.NewTx(&tx) + if len(uTx.MsgTx().TxIn) < 1 { + return types.ErrInvalidBtcTransaction + } // Validate the transaction - // cfg := &chaincfg.MainNetParams // Use MainNetParams or TestNet3Params as per your network - if err := blockchain.CheckTransactionSanity(&tx); err != nil { + if err := blockchain.CheckTransactionSanity(uTx); err != nil { fmt.Println("Transaction is not valid:", err) return err } + + // extract senders from the previous transaction + prevTxBytes, err := base64.StdEncoding.DecodeString(msg.PrevTxBytes) if err != nil { + fmt.Println("Error decoding transaction from base64:", err) return err } - ctx.Logger().Debug("Processing Transaction", tx) + // Create a new transaction + var prevMsgTx wire.MsgTx + err = prevMsgTx.Deserialize(bytes.NewReader(prevTxBytes)) + if err != nil { + fmt.Println("Error deserializing transaction:", err) + return err + } - // transaction.MsgTx(). + prevTx := btcutil.NewTx(&prevMsgTx) + if len(prevTx.MsgTx().TxOut) < 1 { + return types.ErrInvalidBtcTransaction + } + // Validate the transaction + if err := blockchain.CheckTransactionSanity(prevTx); err != nil { + fmt.Println("Transaction is not valid:", err) + return err + } + + // check if the output is a valid address + // if there are multiple inputs, then the first input is considered as the sender + // assumpe all inputs are from the same sender + out := prevTx.MsgTx().TxOut[tx.TxIn[0].PreviousOutPoint.Index] + // check if the output is a valid address + pk, err := txscript.ParsePkScript(out.PkScript) + if err != nil { + return err + } + sender, err := pk.Address(types.ChainCfg) + if err != nil { + return err + } + + // check if the proof is valid + root, err := chainhash.NewHashFromStr(header.MerkleRoot) + if err != nil { + return err + } + if !types.VerifyMerkleProof(msg.Proof, uTx.Hash(), root) { + return types.ErrTransactionNotIncluded + } + + for _, out := range uTx.MsgTx().TxOut { + // check if the output is a valid address + pk, err := txscript.ParsePkScript(out.PkScript) + if err != nil { + return err + } + addr, err := pk.Address(types.ChainCfg) + if err != nil { + return err + } + + if slices.Contains(param.BtcVoucherAddress, addr.EncodeAddress()) { + // mint the voucher token + coins := sdk.NewCoins(sdk.NewCoin(param.BtcVoucherDenom, sdk.NewInt(int64(out.Value)))) + senderAddr, err := sdk.AccAddressFromBech32(sender.EncodeAddress()) + if err != nil { + return err + } + k.bankKeeper.MintCoins(ctx, types.ModuleName, coins) + k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, senderAddr, coins) + } + + } return nil } diff --git a/x/btclightclient/keeper/msg_server.go b/x/btclightclient/keeper/msg_server.go index ba05da68..e8801693 100644 --- a/x/btclightclient/keeper/msg_server.go +++ b/x/btclightclient/keeper/msg_server.go @@ -42,18 +42,18 @@ func (m msgServer) SubmitBlockHeaders(goCtx context.Context, msg *types.MsgSubmi return &types.MsgSubmitBlockHeadersResponse{}, nil } -// SubmitBtcTransaction implements types.MsgServer. +// SubmitTransaction implements types.MsgServer. // No Permission check required for this message // Since everyone can submit a transaction to mint voucher tokens // This message is usually sent by relayers -func (m msgServer) SubmitBtcTransaction(goCtx context.Context, msg *types.MsgSubmitTransactionRequest) (*types.MsgSubmitTransactionResponse, error) { +func (m msgServer) SubmitTransaction(goCtx context.Context, msg *types.MsgSubmitTransactionRequest) (*types.MsgSubmitTransactionResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) if err := msg.ValidateBasic(); err != nil { return nil, err } - if err := m.ProcessBitcoinTransaction(ctx, msg.Tx, msg.Proof); err != nil { + if err := m.ProcessBitcoinDepositTransaction(ctx, msg); err != nil { return nil, err } diff --git a/x/btclightclient/types/codec.go b/x/btclightclient/types/codec.go index 3fb14daa..7c4cfced 100644 --- a/x/btclightclient/types/codec.go +++ b/x/btclightclient/types/codec.go @@ -9,17 +9,15 @@ import ( func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgSubmitBlockHeaderRequest{}, "btclightclient/MsgSubmitBlockHeaderRequest", nil) - // cdc.RegisterConcrete(&MsgSubmitBlockHeadersResponse{}, "btclightclient/MsgSubmitBlockHeadersResponse", nil) cdc.RegisterConcrete(&MsgUpdateSendersRequest{}, "btclightclient/MsgUpdateSendersRequest", nil) - // cdc.RegisterConcrete(&MsgUpdateSendersResponse{}, "btclightclient/MsgUpdateSendersResponse", nil) + cdc.RegisterConcrete(&MsgSubmitTransactionRequest{}, "btclightclient/MsgSubmitTransactionRequest", nil) // this line is used by starport scaffolding # 2 } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSubmitBlockHeaderRequest{}) - // registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSubmitBlockHeadersResponse{}) registry.RegisterImplementations((*sdk.Msg)(nil), &MsgUpdateSendersRequest{}) - // registry.RegisterImplementations((*sdk.Msg)(nil), &MsgUpdateSendersResponse{}) + registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSubmitTransactionRequest{}) // this line is used by starport scaffolding # 3 msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/btclightclient/types/errors.go b/x/btclightclient/types/errors.go index fe2f825a..9f751bea 100644 --- a/x/btclightclient/types/errors.go +++ b/x/btclightclient/types/errors.go @@ -16,6 +16,8 @@ var ( ErrInvalidSenders = errorsmod.Register(ModuleName, 2100, "invalid allowed senders") ErrInvalidBtcTransaction = errorsmod.Register(ModuleName, 3100, "invalid bitcoin transaction") + ErrBlockNotFound = errorsmod.Register(ModuleName, 3101, "block not found") + ErrTransactionNotIncluded = errorsmod.Register(ModuleName, 3101, "transaction not included in block") ErrNotConfirmed = errorsmod.Register(ModuleName, 3200, "transaction not confirmed") ErrExceedMaxAcceptanceDepth = errorsmod.Register(ModuleName, 3201, "exceed max acceptance block depth") ) diff --git a/x/btclightclient/types/expected_keepers.go b/x/btclightclient/types/expected_keepers.go index 20eea16d..c3387102 100644 --- a/x/btclightclient/types/expected_keepers.go +++ b/x/btclightclient/types/expected_keepers.go @@ -3,6 +3,7 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" + banktype "github.com/cosmos/cosmos-sdk/x/bank/types" ) // AccountKeeper defines the expected account keeper used for simulations (noalias) @@ -10,3 +11,22 @@ type AccountKeeper interface { GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI // Methods imported from account should be defined here } + +// BankKeeper defines the expected interface needed to retrieve account balances. +type BankKeeper interface { + SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + // Methods imported from bank should be defined here + + SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + + SendCoinsFromModuleToModule(ctx sdk.Context, senderModule, recipientModule string, amt sdk.Coins) error + SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error + SendCoins(ctx sdk.Context, fromAddr sdk.AccAddress, toAddr sdk.AccAddress, amt sdk.Coins) error + SetDenomMetaData(ctx sdk.Context, denomMetaData banktype.Metadata) + + MintCoins(ctx sdk.Context, moduleName string, amounts sdk.Coins) error + BurnCoins(ctx sdk.Context, moduleName string, amounts sdk.Coins) error + + HasSupply(ctx sdk.Context, denom string) bool + GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin +} diff --git a/x/btclightclient/types/keys.go b/x/btclightclient/types/keys.go index 94adc542..cde6daa9 100644 --- a/x/btclightclient/types/keys.go +++ b/x/btclightclient/types/keys.go @@ -2,6 +2,8 @@ package types import ( "math/big" + + "github.com/btcsuite/btcd/chaincfg" ) const ( @@ -26,6 +28,7 @@ var ( BtcBlockHeaderHeightPrefix = []byte{0x12} // prefix for each key to a block hash, for a height BtcBestBlockHeaderKey = []byte{0x13} // key for the best block height + ChainCfg = &chaincfg.MainNetParams ) func Int64ToBytes(number uint64) []byte { diff --git a/x/btclightclient/types/merkle_proof.go b/x/btclightclient/types/merkle_proof.go new file mode 100644 index 00000000..26f6c8ef --- /dev/null +++ b/x/btclightclient/types/merkle_proof.go @@ -0,0 +1,39 @@ +package types + +import ( + "encoding/base64" + + "github.com/btcsuite/btcd/blockchain" + "github.com/btcsuite/btcd/chaincfg/chainhash" +) + +// VerifyMerkleProof verifies a Merkle proof +func VerifyMerkleProof(proofs []string, hn, root *chainhash.Hash) bool { + current := hn + for _, proof := range proofs { + + bytes, err := base64.StdEncoding.DecodeString(proof) + if err != nil { + return false + } + position := bytes[0] + p := current + if len(bytes) > 1 { + p, err = chainhash.NewHash(bytes[1:]) + if err != nil { + return false + } + } + + var temp chainhash.Hash + if position == 0 { + temp = blockchain.HashMerkleBranches(current, p) + } else { + temp = blockchain.HashMerkleBranches(p, current) + } + current = &temp + } + + return current.IsEqual(root) + +} diff --git a/x/btclightclient/types/message_submit_transaction.go b/x/btclightclient/types/message_submit_transaction.go index 6173e524..7bd5ca3f 100644 --- a/x/btclightclient/types/message_submit_transaction.go +++ b/x/btclightclient/types/message_submit_transaction.go @@ -9,13 +9,15 @@ const TypeMsgSubmitTransaction = "submit_transaction" func NewMsgSubmitTransactionRequest( sender string, + blockhash string, transaction string, - proof string, + proof []string, ) *MsgSubmitTransactionRequest { return &MsgSubmitTransactionRequest{ - Sender: sender, - Tx: transaction, - Proof: proof, + Sender: sender, + Blockhash: blockhash, + TxBytes: transaction, + Proof: proof, } } @@ -46,7 +48,15 @@ func (msg *MsgSubmitTransactionRequest) ValidateBasic() error { return sdkerrors.Wrapf(err, "invalid Sender address (%s)", err) } - if len(msg.Tx) == 0 { + if len(msg.Blockhash) == 0 { + return sdkerrors.Wrap(ErrInvalidBtcTransaction, "blockhash cannot be empty") + } + + if len(msg.PrevTxBytes) == 0 { + return sdkerrors.Wrap(ErrInvalidBtcTransaction, "transaction cannot be empty") + } + + if len(msg.TxBytes) == 0 { return sdkerrors.Wrap(ErrInvalidBtcTransaction, "transaction cannot be empty") } diff --git a/x/btclightclient/types/params.pb.go b/x/btclightclient/types/params.pb.go index 51f8e801..3600bb94 100644 --- a/x/btclightclient/types/params.pb.go +++ b/x/btclightclient/types/params.pb.go @@ -33,6 +33,8 @@ type Params struct { MaxAcceptableBlockDepth uint64 `protobuf:"varint,3,opt,name=max_acceptable_block_depth,json=maxAcceptableBlockDepth,proto3" json:"max_acceptable_block_depth,omitempty"` // the denomanation of the voucher BtcVoucherDenom string `protobuf:"bytes,4,opt,name=btc_voucher_denom,json=btcVoucherDenom,proto3" json:"btc_voucher_denom,omitempty"` + // the address to which the voucher is sent + BtcVoucherAddress []string `protobuf:"bytes,5,rep,name=btc_voucher_address,json=btcVoucherAddress,proto3" json:"btc_voucher_address,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -96,6 +98,13 @@ func (m *Params) GetBtcVoucherDenom() string { return "" } +func (m *Params) GetBtcVoucherAddress() []string { + if m != nil { + return m.BtcVoucherAddress + } + return nil +} + // Bitcoin Block Header type BlockHeader struct { Version uint64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` @@ -213,33 +222,34 @@ func init() { func init() { proto.RegisterFile("side/btclightclient/params.proto", fileDescriptor_3b47f8b78acf6f6e) } var fileDescriptor_3b47f8b78acf6f6e = []byte{ - // 404 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 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0x29, 0xe2, 0xe9, 0xd3, 0x69, 0x15, 0x76, 0x89, 0x14, 0xc3, 0xff, 0xff, 0x4a, 0xf8, - 0xd6, 0x83, 0x97, 0x8b, 0x94, 0xba, 0xfd, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x08, 0x42, 0x8d, 0x83, - 0x4f, 0x02, 0x00, 0x00, + // 421 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x52, 0x3f, 0x6f, 0xd3, 0x40, + 0x14, 0xcf, 0x91, 0x3f, 0x25, 0x57, 0x21, 0xc8, 0xb5, 0x82, 0x53, 0x07, 0x63, 0x55, 0x0c, 0x11, + 0x43, 0x3c, 0x74, 0x64, 0x6a, 0xd5, 0x81, 0x05, 0x09, 0x79, 0x60, 0x60, 0xb1, 0xce, 0xe7, 0x47, + 0x7c, 0xaa, 0x7d, 0xcf, 0xba, 0xbb, 0x44, 0xe6, 0x5b, 0xf0, 0xb1, 0x18, 0x3b, 0x32, 0x42, 0xf2, + 0x15, 0xf8, 0x00, 0xe8, 0x9e, 0x13, 0xa0, 0x5d, 0xa2, 0xdf, 0xbf, 0xcb, 0xfb, 0x3d, 0xeb, 0xf1, + 0xd4, 0x9b, 0x0a, 0xb2, 0x32, 0xe8, 0xc6, 0xac, 0xeb, 0xf8, 0x0b, 0x36, 0x64, 0x9d, 0x72, 0xaa, + 0xf5, 0xab, 0xce, 0x61, 0x40, 0x71, 0x16, 0x13, 0xab, 0x87, 0x89, 0x8b, 0xf3, 0x35, 0xae, 0x91, + 0xfc, 0x2c, 0xa2, 0x21, 0x7a, 0xf9, 0x8b, 0xf1, 0xd9, 0x47, 0x7a, 0x2b, 0x24, 0x3f, 0xf1, 0x60, + 0x2b, 0x70, 0x5e, 0xb2, 0x74, 0xbc, 0x9c, 0xe7, 0x47, 0x2a, 0xde, 0xf0, 0x67, 0x1a, 0xed, 0x17, + 0xe3, 0x5a, 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0x34, 0x67, 0x20, 0xb1, 0x52, 0x69, 0x82, 0x97, 0x27, 0x43, + 0xa5, 0x88, 0xa3, 0x16, 0x4c, 0x0b, 0xf2, 0x29, 0x05, 0x09, 0x8b, 0x17, 0x7c, 0x6c, 0x43, 0x2f, + 0xe7, 0x24, 0x45, 0x78, 0xf3, 0xe1, 0xfb, 0x2e, 0x61, 0xf7, 0xbb, 0x84, 0xfd, 0xdc, 0x25, 0xec, + 0xdb, 0x3e, 0x19, 0xdd, 0xef, 0x93, 0xd1, 0x8f, 0x7d, 0x32, 0xfa, 0x7c, 0xb5, 0x36, 0xa1, 0xde, + 0x94, 0x2b, 0x8d, 0x6d, 0x16, 0x4f, 0x85, 0x4e, 0x41, 0x63, 0x43, 0x24, 0xeb, 0x1f, 0xdf, 0x56, + 0xf8, 0xda, 0x81, 0x2f, 0x67, 0x94, 0xba, 0xfa, 0x13, 0x00, 0x00, 0xff, 0xff, 0x68, 0x1a, 0xad, + 0x49, 0x7f, 0x02, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -262,6 +272,15 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.BtcVoucherAddress) > 0 { + for iNdEx := len(m.BtcVoucherAddress) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.BtcVoucherAddress[iNdEx]) + copy(dAtA[i:], m.BtcVoucherAddress[iNdEx]) + i = encodeVarintParams(dAtA, i, uint64(len(m.BtcVoucherAddress[iNdEx]))) + i-- + dAtA[i] = 0x2a + } + } if len(m.BtcVoucherDenom) > 0 { i -= len(m.BtcVoucherDenom) copy(dAtA[i:], m.BtcVoucherDenom) @@ -400,6 +419,12 @@ func (m *Params) Size() (n int) { if l > 0 { n += 1 + l + sovParams(uint64(l)) } + if len(m.BtcVoucherAddress) > 0 { + for _, s := range m.BtcVoucherAddress { + l = len(s) + n += 1 + l + sovParams(uint64(l)) + } + } return n } @@ -580,6 +605,38 @@ func (m *Params) Unmarshal(dAtA []byte) error { } m.BtcVoucherDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BtcVoucherAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BtcVoucherAddress = append(m.BtcVoucherAddress, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/btclightclient/types/tx.pb.go b/x/btclightclient/types/tx.pb.go index 7c3c3971..8da3a195 100644 --- a/x/btclightclient/types/tx.pb.go +++ b/x/btclightclient/types/tx.pb.go @@ -120,9 +120,14 @@ var xxx_messageInfo_MsgSubmitBlockHeadersResponse proto.InternalMessageInfo // MsgSubmitTransactionRequest defines the Msg/SubmitTransaction request type. type MsgSubmitTransactionRequest struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - Tx string `protobuf:"bytes,2,opt,name=tx,proto3" json:"tx,omitempty"` - Proof string `protobuf:"bytes,3,opt,name=proof,proto3" json:"proof,omitempty"` + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Blockhash string `protobuf:"bytes,2,opt,name=blockhash,proto3" json:"blockhash,omitempty"` + // the tx bytes in base64 format + // used for parsing the sender of the transaction + PrevTxBytes string `protobuf:"bytes,3,opt,name=prev_tx_bytes,json=prevTxBytes,proto3" json:"prev_tx_bytes,omitempty"` + // the tx bytes in base64 format + TxBytes string `protobuf:"bytes,4,opt,name=tx_bytes,json=txBytes,proto3" json:"tx_bytes,omitempty"` + Proof []string `protobuf:"bytes,5,rep,name=proof,proto3" json:"proof,omitempty"` } func (m *MsgSubmitTransactionRequest) Reset() { *m = MsgSubmitTransactionRequest{} } @@ -165,20 +170,34 @@ func (m *MsgSubmitTransactionRequest) GetSender() string { return "" } -func (m *MsgSubmitTransactionRequest) GetTx() string { +func (m *MsgSubmitTransactionRequest) GetBlockhash() string { if m != nil { - return m.Tx + return m.Blockhash } return "" } -func (m *MsgSubmitTransactionRequest) GetProof() string { +func (m *MsgSubmitTransactionRequest) GetPrevTxBytes() string { if m != nil { - return m.Proof + return m.PrevTxBytes } return "" } +func (m *MsgSubmitTransactionRequest) GetTxBytes() string { + if m != nil { + return m.TxBytes + } + return "" +} + +func (m *MsgSubmitTransactionRequest) GetProof() []string { + if m != nil { + return m.Proof + } + return nil +} + // MsgSubmitTransactionResponse defines the Msg/SubmitTransaction response type. type MsgSubmitTransactionResponse struct { } @@ -319,32 +338,35 @@ func init() { func init() { proto.RegisterFile("side/btclightclient/tx.proto", fileDescriptor_4df07798138ba91c) } var fileDescriptor_4df07798138ba91c = []byte{ - // 389 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x4d, 0x4b, 0xc3, 0x40, - 0x10, 0x6d, 0x52, 0xac, 0x74, 0xb5, 0x82, 0x6b, 0xd1, 0x10, 0x6b, 0x0c, 0x39, 0xf5, 0xa0, 0x89, - 0xb6, 0xff, 0xa0, 0x20, 0x08, 0x92, 0x4b, 0xaa, 0x17, 0x3d, 0x48, 0x3e, 0xd6, 0x34, 0x98, 0x66, - 0x63, 0x66, 0x0b, 0x51, 0xfc, 0x11, 0xfe, 0x2c, 0x8f, 0x3d, 0x7a, 0x94, 0xf6, 0xe4, 0xbf, 0x90, - 0x6c, 0xaa, 0xb6, 0x24, 0xda, 0x7a, 0x59, 0xf6, 0xed, 0xbc, 0x7d, 0x6f, 0x78, 0xc3, 0xa0, 0x16, - 0x04, 0x1e, 0x31, 0x1c, 0xe6, 0x86, 0x81, 0x3f, 0xc8, 0x4e, 0x12, 0x31, 0x83, 0xa5, 0x7a, 0x9c, - 0x50, 0x46, 0xf1, 0x4e, 0x56, 0xd5, 0x17, 0xab, 0x72, 0xd3, 0xa7, 0x3e, 0xe5, 0x75, 0x23, 0xbb, - 0xe5, 0x54, 0x59, 0x2d, 0x13, 0x8a, 0xed, 0xc4, 0x1e, 0x42, 0xce, 0xd0, 0x9e, 0xd1, 0xbe, 0x09, - 0x7e, 0x7f, 0xe4, 0x0c, 0x03, 0xd6, 0x0b, 0xa9, 0x7b, 0x7f, 0x4e, 0x6c, 0x8f, 0x24, 0x16, 0x79, - 0x18, 0x11, 0x60, 0x78, 0x17, 0xd5, 0x80, 0x44, 0x1e, 0x49, 0x24, 0x41, 0x15, 0xda, 0x75, 0x6b, - 0x86, 0xf0, 0x19, 0x6a, 0x38, 0x19, 0xfb, 0x76, 0xc0, 0xe9, 0x20, 0x89, 0x6a, 0xb5, 0xbd, 0xd1, - 0x51, 0xf5, 0x92, 0xde, 0xf4, 0x79, 0xdd, 0x4d, 0xe7, 0x07, 0x80, 0x76, 0x88, 0x0e, 0xca, 0xdc, - 0xc1, 0x22, 0x10, 0xd3, 0x08, 0x88, 0x76, 0x33, 0xd7, 0xde, 0x65, 0x62, 0x47, 0x60, 0xbb, 0x2c, - 0xa0, 0xd1, 0xb2, 0xf6, 0xb6, 0x90, 0xc8, 0x52, 0x49, 0xe4, 0x6f, 0x22, 0x4b, 0x71, 0x13, 0xad, - 0xc5, 0x09, 0xa5, 0x77, 0x52, 0x95, 0x3f, 0xe5, 0x40, 0x53, 0x50, 0xab, 0x5c, 0x7c, 0x66, 0x7e, - 0x81, 0xf6, 0x4c, 0xf0, 0xaf, 0x62, 0xcf, 0x66, 0xa4, 0xcf, 0x85, 0x61, 0x99, 0xb1, 0x84, 0xd6, - 0xf3, 0x5b, 0x9e, 0x48, 0xdd, 0xfa, 0x82, 0x9a, 0x8c, 0xa4, 0xa2, 0x58, 0x6e, 0xd4, 0xf9, 0x10, - 0x51, 0xd5, 0x04, 0x1f, 0x3f, 0x21, 0x5c, 0xcc, 0x02, 0x9f, 0x94, 0x86, 0xfa, 0xc7, 0xd4, 0xe4, - 0xce, 0xca, 0x3f, 0xbe, 0x7b, 0xc0, 0x29, 0xda, 0x2e, 0x24, 0xb1, 0xcc, 0xba, 0x38, 0x11, 0xf9, - 0xf4, 0x1f, 0x3f, 0x66, 0xce, 0x21, 0x6a, 0x2c, 0xc4, 0x82, 0x8f, 0x7e, 0xd3, 0x28, 0x1b, 0x85, - 0x7c, 0xbc, 0x22, 0x3b, 0x77, 0xeb, 0x99, 0xaf, 0x13, 0x45, 0x18, 0x4f, 0x14, 0xe1, 0x7d, 0xa2, - 0x08, 0x2f, 0x53, 0xa5, 0x32, 0x9e, 0x2a, 0x95, 0xb7, 0xa9, 0x52, 0xb9, 0xee, 0xfa, 0x01, 0x1b, - 0x8c, 0x1c, 0xdd, 0xa5, 0x43, 0x23, 0x93, 0xe4, 0x0b, 0xe2, 0xd2, 0x90, 0x03, 0x23, 0x2d, 0xec, - 0xe3, 0x63, 0x4c, 0xc0, 0xa9, 0x71, 0x56, 0xf7, 0x33, 0x00, 0x00, 0xff, 0xff, 0x08, 0x0a, 0x8e, - 0x18, 0xb3, 0x03, 0x00, 0x00, + // 435 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0xcd, 0xae, 0x93, 0x40, + 0x14, 0x2e, 0xc5, 0x7b, 0xaf, 0x9c, 0x6b, 0x17, 0x8e, 0x37, 0x8a, 0x58, 0x91, 0xb0, 0xea, 0x42, + 0x41, 0x7b, 0xdf, 0xa0, 0x89, 0x89, 0x89, 0x61, 0xc3, 0xad, 0x1b, 0x37, 0x0d, 0x3f, 0x23,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b, 0x45, 0x61, 0x97, 0xad, 0xd7, 0xbd, 0xcc, + 0x29, 0xfa, 0xe7, 0x82, 0x75, 0xfd, 0x27, 0x00, 0x00, 0xff, 0xff, 0xf1, 0xe7, 0x80, 0xd3, 0x01, + 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -593,16 +615,32 @@ func (m *MsgSubmitTransactionRequest) MarshalToSizedBuffer(dAtA []byte) (int, er var l int _ = l if len(m.Proof) > 0 { - i -= len(m.Proof) - copy(dAtA[i:], m.Proof) - i = encodeVarintTx(dAtA, i, uint64(len(m.Proof))) + for iNdEx := len(m.Proof) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Proof[iNdEx]) + copy(dAtA[i:], m.Proof[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Proof[iNdEx]))) + i-- + dAtA[i] = 0x2a + } + } + if len(m.TxBytes) > 0 { + i -= len(m.TxBytes) + copy(dAtA[i:], m.TxBytes) + i = encodeVarintTx(dAtA, i, uint64(len(m.TxBytes))) + i-- + dAtA[i] = 0x22 + } + if len(m.PrevTxBytes) > 0 { + i -= len(m.PrevTxBytes) + copy(dAtA[i:], m.PrevTxBytes) + i = encodeVarintTx(dAtA, i, uint64(len(m.PrevTxBytes))) i-- dAtA[i] = 0x1a } - if len(m.Tx) > 0 { - i -= len(m.Tx) - copy(dAtA[i:], m.Tx) - i = encodeVarintTx(dAtA, i, uint64(len(m.Tx))) + if len(m.Blockhash) > 0 { + i -= len(m.Blockhash) + copy(dAtA[i:], m.Blockhash) + i = encodeVarintTx(dAtA, i, uint64(len(m.Blockhash))) i-- dAtA[i] = 0x12 } @@ -750,14 +788,24 @@ func (m *MsgSubmitTransactionRequest) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.Tx) + l = len(m.Blockhash) if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.Proof) + l = len(m.PrevTxBytes) if l > 0 { n += 1 + l + sovTx(uint64(l)) } + l = len(m.TxBytes) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Proof) > 0 { + for _, s := range m.Proof { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } return n } @@ -1033,7 +1081,7 @@ func (m *MsgSubmitTransactionRequest) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Tx", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Blockhash", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1061,9 +1109,73 @@ func (m *MsgSubmitTransactionRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Tx = string(dAtA[iNdEx:postIndex]) + m.Blockhash = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrevTxBytes", 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.PrevTxBytes = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TxBytes", 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.TxBytes = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) } @@ -1093,7 +1205,7 @@ func (m *MsgSubmitTransactionRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Proof = string(dAtA[iNdEx:postIndex]) + m.Proof = append(m.Proof, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex default: iNdEx = preIndex From 0ff99bad61be29dc308b755775001e6f2edf9b20 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Fri, 24 May 2024 21:38:53 +0800 Subject: [PATCH 12/71] complete bitcoin deposit --- app/modules.go | 1 + x/btclightclient/client/cli/query.go | 42 ++++++++++++++++++++++ x/btclightclient/genesis_test.go | 50 ++++++++++++++++++++++++++ x/btclightclient/keeper/keeper.go | 27 +++++++++----- x/btclightclient/keeper/keeper_test.go | 1 + x/btclightclient/keeper/msg_server.go | 6 ++++ x/btclightclient/types/errors.go | 3 +- 7 files changed, 121 insertions(+), 9 deletions(-) create mode 100644 x/btclightclient/keeper/keeper_test.go diff --git a/app/modules.go b/app/modules.go index b4b061af..541f6011 100644 --- a/app/modules.go +++ b/app/modules.go @@ -95,6 +95,7 @@ var moduleAccountPermissions = map[string][]string{ wasmTypes.ModuleName: {authtypes.Burner}, gmmmoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner, authtypes.Staking}, yieldmoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner, authtypes.Staking}, + btclightclienttypes.ModuleName: {authtypes.Minter, authtypes.Burner}, } // appModules return modules to initialize module manager. diff --git a/x/btclightclient/client/cli/query.go b/x/btclightclient/client/cli/query.go index e831815c..849a8c9a 100644 --- a/x/btclightclient/client/cli/query.go +++ b/x/btclightclient/client/cli/query.go @@ -2,6 +2,8 @@ package cli import ( "fmt" + "strconv" + // "strings" "github.com/sideprotocol/side/x/btclightclient/types" @@ -24,6 +26,7 @@ func GetQueryCmd(_ string) *cobra.Command { cmd.AddCommand(CmdQueryParams()) cmd.AddCommand(CmdBestBlock()) + cmd.AddCommand(CmdQueryBlock()) // this line is used by starport scaffolding # 1 return cmd @@ -82,3 +85,42 @@ func CmdBestBlock() *cobra.Command { return cmd } + +// CmdQueryBlock returns the command to query the heights of the light client +func CmdQueryBlock() *cobra.Command { + cmd := &cobra.Command{ + Use: "block [hash or height]", + Short: "Query block by hash or height", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + height, err := strconv.ParseUint(args[0], 10, 64) + + if err != nil { + res, err := queryClient.QueryBlockHeaderByHash(cmd.Context(), &types.QueryBlockHeaderByHashRequest{Hash: args[0]}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + } + + res, err := queryClient.QueryBlockHeaderByHeight(cmd.Context(), &types.QueryBlockHeaderByHeightRequest{Height: height}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/btclightclient/genesis_test.go b/x/btclightclient/genesis_test.go index 9df8b423..9f5e3e96 100644 --- a/x/btclightclient/genesis_test.go +++ b/x/btclightclient/genesis_test.go @@ -1,8 +1,14 @@ package btclightclient_test +// Path: x/btclightclient/genesis_test.go + import ( + "bytes" + "encoding/hex" "testing" + "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/wire" keepertest "github.com/sideprotocol/side/testutil/keeper" "github.com/sideprotocol/side/testutil/nullify" "github.com/sideprotocol/side/x/btclightclient" @@ -31,3 +37,47 @@ func TestGenesis(t *testing.T) { // this line is used by starport scaffolding # genesis/test/assert } + +// TestSubmitTx tests the SubmitTx function +// func TestSubmitTx(t *testing.T) { + +// // test tx: https://blockchain.info/tx/b657e22827039461a9493ede7bdf55b01579254c1630b0bfc9185ec564fc05ab?format=json + +// k, ctx := keepertest.BtcLightClientKeeper(t) + +// txHex := "02000000000101e5df234dbeff74d6da14754ebeea8ab0e2f60b1884566846cf6b36e8ceb5f5350100000000fdffffff02f0490200000000001600142ac13073e8d491428790481321a636696d00107681d7e205000000001600142bf3aa186cbdcbe88b70a67edcd5a32ce5e8e6d8024730440220081ee61d749ce8cedcf6eedde885579af2eb65ca67d29e6ae2c37109d81cbbb202203a1891ce45f91f159ccf04348ef37a3d1a12d89e5e01426e061326057e6c128d012103036bbdd77c9a932f37bd66175967c7fb7eb75ece06b87c1ad1716770cb3ca4ee79fc2a00" +// prevTxHex := "0200000000010183372652f2af9ab34b3a003efada6b054c75583185ac130de72599dfdf4e462b0100000000fdffffff02f0490200000000001600142ac13073e8d491428790481321a636696d001076a64ee50500000000160014a03614eef338681373de94a2dc2574de55da1980024730440220274250f6036bea0947daf4455ab4976f81721257d163fd952fb5b0c70470edc602202fba816be260219bbc40a8983c459cf05cf2209bf1e62e7ccbf78aec54db607f0121031cee21ef69fe68b240c3032616fa310c6a60a856c0a7e0c1298815c92fb2c61788fb2a00" + +// msg := &types.MsgSubmitTransactionRequest{ +// Sender: "", +// Blockhash: "000000000d73ecf25d3bf8e6ae65c35aa2a90e3271edff8bab90d87ed875f13b", +// TxBytes: "0100000001b3f7", +// PrevTxBytes: "0100000001b3f7", +// Proof: []string{"0100000001b3f7"}, +// } +// // this line is used by starport scaffolding # handler/test/submit +// err := k.ProcessBitcoinDepositTransaction(ctx, msg) +// require.NoError(t, err) +// } + +// Decode transaction +func TestDecodeTransaction(t *testing.T) { + hexStr := "02000000000101e5df234dbeff74d6da14754ebeea8ab0e2f60b1884566846cf6b36e8ceb5f5350100000000fdffffff02f0490200000000001600142ac13073e8d491428790481321a636696d00107681d7e205000000001600142bf3aa186cbdcbe88b70a67edcd5a32ce5e8e6d8024730440220081ee61d749ce8cedcf6eedde885579af2eb65ca67d29e6ae2c37109d81cbbb202203a1891ce45f91f159ccf04348ef37a3d1a12d89e5e01426e061326057e6c128d012103036bbdd77c9a932f37bd66175967c7fb7eb75ece06b87c1ad1716770cb3ca4ee79fc2a00" + + // Decode the hex string to transaction + txBytes, err := hex.DecodeString(hexStr) + require.NoError(t, err) + + // Create a new transaction + var tx wire.MsgTx + err = tx.Deserialize(bytes.NewReader(txBytes)) + require.NoError(t, err) + + uTx := btcutil.NewTx(&tx) + + for _, input := range uTx.MsgTx().TxIn { + t.Log(input.PreviousOutPoint.String()) + } + + require.GreaterOrEqual(t, len(uTx.MsgTx().TxIn), 1) +} diff --git a/x/btclightclient/keeper/keeper.go b/x/btclightclient/keeper/keeper.go index cb9d9dbb..2581c3c2 100644 --- a/x/btclightclient/keeper/keeper.go +++ b/x/btclightclient/keeper/keeper.go @@ -113,6 +113,7 @@ func (k Keeper) SetBlockHeaders(ctx sdk.Context, blockHeader []*types.BlockHeade // remove the block headers after the forked block header // and consider the forked block header as the best block header for i := header.Height; i <= best.Height; i++ { + ctx.Logger().Info("Removing block header: ", i) thash := k.GetBlockHashByHeight(ctx, i) store.Delete(types.BtcBlockHeaderHashKey(thash)) store.Delete(types.BtcBlockHeaderHeightKey(i)) @@ -139,7 +140,7 @@ func (k Keeper) SetBlockHeaders(ctx sdk.Context, blockHeader []*types.BlockHeade // Process Bitcoin Deposit Transaction func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.MsgSubmitTransactionRequest) error { - ctx.Logger().Debug("Processing Transaction in block: ", msg.Blockhash) + ctx.Logger().Info("accept bitcoin deposit tx", "blockhash", msg.Blockhash) param := k.GetParams(ctx) header := k.GetBlockHeader(ctx, msg.Blockhash) @@ -217,11 +218,17 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg if err != nil { return err } + sender, err := pk.Address(types.ChainCfg) if err != nil { return err } + // if pk.Class() != txscript.WitnessV1TaprootTy || pk.Class() != txscript.WitnessV0PubKeyHashTy || pk.Class() != txscript.WitnessV0ScriptHashTy { + // ctx.Logger().Error("Unsupported script type", "script", pk.Class(), "address", sender.EncodeAddress()) + // return types.ErrUnsupportedScriptType + // } + // check if the proof is valid root, err := chainhash.NewHashFromStr(header.MerkleRoot) if err != nil { @@ -233,24 +240,28 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg for _, out := range uTx.MsgTx().TxOut { // check if the output is a valid address - pk, err := txscript.ParsePkScript(out.PkScript) + pks, err := txscript.ParsePkScript(out.PkScript) if err != nil { return err } - addr, err := pk.Address(types.ChainCfg) + addr, err := pks.Address(types.ChainCfg) if err != nil { return err } - if slices.Contains(param.BtcVoucherAddress, addr.EncodeAddress()) { + // TODO remove the true + // check if the receiver is one of the voucher addresses + if true || slices.Contains(param.BtcVoucherAddress, addr.EncodeAddress()) { // mint the voucher token - coins := sdk.NewCoins(sdk.NewCoin(param.BtcVoucherDenom, sdk.NewInt(int64(out.Value)))) + coins := sdk.NewCoins(sdk.NewCoin(param.BtcVoucherDenom, sdk.NewInt(out.Value))) senderAddr, err := sdk.AccAddressFromBech32(sender.EncodeAddress()) if err != nil { return err } k.bankKeeper.MintCoins(ctx, types.ModuleName, coins) k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, senderAddr, coins) + + ctx.Logger().Info("Voucher token minted", "address", senderAddr.String(), "amount", coins.String()) } } @@ -260,10 +271,10 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg func (k Keeper) GetBlockHeader(ctx sdk.Context, hash string) *types.BlockHeader { store := ctx.KVStore(k.storeKey) - var blockHeader *types.BlockHeader + var blockHeader types.BlockHeader bz := store.Get(types.BtcBlockHeaderHashKey(hash)) - k.cdc.MustUnmarshal(bz, blockHeader) - return blockHeader + k.cdc.MustUnmarshal(bz, &blockHeader) + return &blockHeader } func (k Keeper) GetBlockHashByHeight(ctx sdk.Context, height uint64) string { diff --git a/x/btclightclient/keeper/keeper_test.go b/x/btclightclient/keeper/keeper_test.go new file mode 100644 index 00000000..94292649 --- /dev/null +++ b/x/btclightclient/keeper/keeper_test.go @@ -0,0 +1 @@ +package keeper_test diff --git a/x/btclightclient/keeper/msg_server.go b/x/btclightclient/keeper/msg_server.go index e8801693..1d365d66 100644 --- a/x/btclightclient/keeper/msg_server.go +++ b/x/btclightclient/keeper/msg_server.go @@ -50,14 +50,20 @@ func (m msgServer) SubmitTransaction(goCtx context.Context, msg *types.MsgSubmit ctx := sdk.UnwrapSDKContext(goCtx) if err := msg.ValidateBasic(); err != nil { + ctx.Logger().Error("Error validating basic", "error", err) return nil, err } if err := m.ProcessBitcoinDepositTransaction(ctx, msg); err != nil { + ctx.Logger().Error("Error processing bitcoin deposit transaction", "error", err) return nil, err } // Emit Events + m.EmitEvent(ctx, msg.Sender, + sdk.NewAttribute("blockhash", msg.Blockhash), + sdk.NewAttribute("txBytes", msg.TxBytes), + ) return &types.MsgSubmitTransactionResponse{}, nil diff --git a/x/btclightclient/types/errors.go b/x/btclightclient/types/errors.go index 9f751bea..d09956b5 100644 --- a/x/btclightclient/types/errors.go +++ b/x/btclightclient/types/errors.go @@ -17,7 +17,8 @@ var ( ErrInvalidBtcTransaction = errorsmod.Register(ModuleName, 3100, "invalid bitcoin transaction") ErrBlockNotFound = errorsmod.Register(ModuleName, 3101, "block not found") - ErrTransactionNotIncluded = errorsmod.Register(ModuleName, 3101, "transaction not included in block") + ErrTransactionNotIncluded = errorsmod.Register(ModuleName, 3102, "transaction not included in block") ErrNotConfirmed = errorsmod.Register(ModuleName, 3200, "transaction not confirmed") ErrExceedMaxAcceptanceDepth = errorsmod.Register(ModuleName, 3201, "exceed max acceptance block depth") + ErrUnsupportedScriptType = errorsmod.Register(ModuleName, 3202, "unsupported script type") ) From 1979e74673efddfda07ec9048767f2728d6ce66a Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Fri, 24 May 2024 21:39:08 +0800 Subject: [PATCH 13/71] add withdraw msg --- proto/side/btclightclient/tx.proto | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/proto/side/btclightclient/tx.proto b/proto/side/btclightclient/tx.proto index 8a57b832..96478066 100644 --- a/proto/side/btclightclient/tx.proto +++ b/proto/side/btclightclient/tx.proto @@ -15,6 +15,10 @@ service Msg { rpc SubmitTransaction (MsgSubmitTransactionRequest) returns (MsgSubmitTransactionResponse); // UpdateSenders updates the senders of the side chain. rpc UpdateSenders (MsgUpdateSendersRequest) returns (MsgUpdateSendersResponse); + // WithdrawBitcoin withdraws the bitcoin from the side chain. + rpc WithdrawBitcoin (MsgWithdrawBitcoinRequest) returns (MsgWithdrawBitcoinResponse); + // SubmitWithdrawSignatures submits the signatures of the withdraw transaction. + rpc SubmitWithdrawSignatures (MsgSubmitWithdrawSignaturesRequest) returns (MsgSubmitWithdrawSignaturesResponse); } // MsgBlockHeaderRequest defines the Msg/SubmitBlockHeaders request type. @@ -54,5 +58,24 @@ message MsgUpdateSendersRequest { message MsgUpdateSendersResponse { } +// MsgWithdrawBitcoinRequest defines the Msg/WithdrawBitcoin request type. +message MsgWithdrawBitcoinRequest { + string sender = 1; + uint64 amount = 2; +} + +// MsgWithdrawBitcoinResponse defines the Msg/WithdrawBitcoin response type. +message MsgWithdrawBitcoinResponse { +} +// MsgSubmitWithdrawSignaturesRequest defines the Msg/SubmitWithdrawSignatures request type. +message MsgSubmitWithdrawSignaturesRequest { + string sender = 1; + string txid = 2; + repeated string signatures = 3; +} + +// MsgSubmitWithdrawSignaturesResponse defines the Msg/SubmitWithdrawSignatures response type. +message MsgSubmitWithdrawSignaturesResponse { +} From c1915b1cdde30222f97182aea04020cefb604bc7 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Wed, 29 May 2024 09:55:34 +0800 Subject: [PATCH 14/71] added withdraw logic --- proto/side/btclightclient/bitcoin.proto | 47 + proto/side/btclightclient/genesis.proto | 1 + proto/side/btclightclient/params.proto | 12 - proto/side/btclightclient/query.proto | 18 + proto/side/btclightclient/tx.proto | 4 +- x/btclightclient/keeper/keeper_test.go | 13 + x/btclightclient/keeper/keeper_withdraw.go | 81 ++ x/btclightclient/keeper/msg_server.go | 45 + x/btclightclient/keeper/queries.go | 16 + x/btclightclient/types/bitcoin.pb.go | 1055 ++++++++++++++++ x/btclightclient/types/errors.go | 3 + x/btclightclient/types/genesis.pb.go | 27 +- x/btclightclient/types/keys.go | 7 + .../types/message_submit_signature.go | 65 + .../types/message_withdraw_bitcoin.go | 52 + x/btclightclient/types/params.pb.go | 547 +------- x/btclightclient/types/query.pb.go | 592 ++++++++- x/btclightclient/types/query.pb.gw.go | 83 ++ x/btclightclient/types/signature.go | 5 + x/btclightclient/types/tx.pb.go | 1118 ++++++++++++++--- 20 files changed, 3047 insertions(+), 744 deletions(-) create mode 100644 proto/side/btclightclient/bitcoin.proto create mode 100644 x/btclightclient/keeper/keeper_withdraw.go create mode 100644 x/btclightclient/types/bitcoin.pb.go create mode 100644 x/btclightclient/types/message_submit_signature.go create mode 100644 x/btclightclient/types/message_withdraw_bitcoin.go create mode 100644 x/btclightclient/types/signature.go diff --git a/proto/side/btclightclient/bitcoin.proto b/proto/side/btclightclient/bitcoin.proto new file mode 100644 index 00000000..9a532863 --- /dev/null +++ b/proto/side/btclightclient/bitcoin.proto @@ -0,0 +1,47 @@ +syntax = "proto3"; +package side.btclightclient; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/sideprotocol/side/x/btclightclient/types"; + +// Bitcoin Block Header +message BlockHeader { + uint64 version = 1; + string hash = 2; + uint64 height = 3; + string previous_block_hash = 4; + string merkle_root = 5; + uint64 nonce = 6; + string bits = 7; + uint64 time = 8; + uint64 ntx = 9; +} + +// Bitcoin Signing Status +enum SigningStatus { + // SIGNING_STATUS_UNSPECIFIED - Default value, should not be used + SIGNING_STATUS_UNSPECIFIED = 0; + // SIGNING_STATUS_CREATED - The signing request is created + SIGNING_STATUS_CREATED = 1; + // SIGNING_STATUS_SIGNED - The signing request is signed + SIGNING_STATUS_SIGNED = 2; + // SIGNING_STATUS_BROADCASTED - The signing request is broadcasted + SIGNING_STATUS_BROADCASTED = 3; + // SIGNING_STATUS_CONFIRMED - The signing request is confirmed + SIGNING_STATUS_CONFIRMED = 4; + // SIGNING_STATUS_REJECTED - The signing request is rejected + SIGNING_STATUS_REJECTED = 5; +} + +// Bitcoin Signing Request +message BitcoinSigningRequest { + string address = 1; + string tx_bytes = 2; + SigningStatus status = 3; + uint64 sequence = 4; + + // The vault address that the request is associated with + string vault_address = 5; +} + diff --git a/proto/side/btclightclient/genesis.proto b/proto/side/btclightclient/genesis.proto index 0253649e..3793c359 100644 --- a/proto/side/btclightclient/genesis.proto +++ b/proto/side/btclightclient/genesis.proto @@ -3,6 +3,7 @@ package side.btclightclient; import "gogoproto/gogo.proto"; import "side/btclightclient/params.proto"; +import "side/btclightclient/bitcoin.proto"; option go_package = "github.com/sideprotocol/side/x/btclightclient/types"; diff --git a/proto/side/btclightclient/params.proto b/proto/side/btclightclient/params.proto index 2ec5f322..0bb695ee 100644 --- a/proto/side/btclightclient/params.proto +++ b/proto/side/btclightclient/params.proto @@ -19,15 +19,3 @@ message Params { repeated string btc_voucher_address = 5; } -// Bitcoin Block Header -message BlockHeader { - uint64 version = 1; - string hash = 2; - uint64 height = 3; - string previous_block_hash = 4; - string merkle_root = 5; - uint64 nonce = 6; - string bits = 7; - uint64 time = 8; - uint64 ntx = 9; -} diff --git a/proto/side/btclightclient/query.proto b/proto/side/btclightclient/query.proto index 991567d1..006e0166 100644 --- a/proto/side/btclightclient/query.proto +++ b/proto/side/btclightclient/query.proto @@ -5,6 +5,7 @@ import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; import "side/btclightclient/params.proto"; +import "side/btclightclient/bitcoin.proto"; option go_package = "github.com/sideprotocol/side/x/btclightclient/types"; @@ -26,6 +27,23 @@ service Query { rpc QueryBlockHeaderByHash(QueryBlockHeaderByHashRequest) returns (QueryBlockHeaderByHashResponse) { option (google.api.http).get = "/sideprotocol/side/btclightclient/hash/{hash}"; } + // QuerySigningRequest queries the request to sign. + rpc QuerySigningRequest(QuerySigningRequestRequest) returns (QuerySigningRequestResponse) { + option (google.api.http).get = "/sideprotocol/side/btclightclient/signing/request"; + } + +} + +// QuerySigningRequestRequest is request type for the Query/SigningRequest RPC method. +message QuerySigningRequestRequest { + SigningStatus status = 1; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QuerySigningRequestResponse is response type for the Query/SigningRequest RPC method. +message QuerySigningRequestResponse { + repeated BitcoinSigningRequest requests = 1; + cosmos.base.query.v1beta1.PageResponse pagination = 2; } // QueryParamsRequest is request type for the Query/Params RPC method. diff --git a/proto/side/btclightclient/tx.proto b/proto/side/btclightclient/tx.proto index 96478066..99f5eaee 100644 --- a/proto/side/btclightclient/tx.proto +++ b/proto/side/btclightclient/tx.proto @@ -4,6 +4,7 @@ package side.btclightclient; import "gogoproto/gogo.proto"; import "side/btclightclient/params.proto"; +import "side/btclightclient/bitcoin.proto"; option go_package = "github.com/sideprotocol/side/x/btclightclient/types"; @@ -61,7 +62,8 @@ message MsgUpdateSendersResponse { // MsgWithdrawBitcoinRequest defines the Msg/WithdrawBitcoin request type. message MsgWithdrawBitcoinRequest { string sender = 1; - uint64 amount = 2; + // withdraw amount in satoshi, etc: 100000000sat = 1btc + string amount = 2; } // MsgWithdrawBitcoinResponse defines the Msg/WithdrawBitcoin response type. diff --git a/x/btclightclient/keeper/keeper_test.go b/x/btclightclient/keeper/keeper_test.go index 94292649..970bc76d 100644 --- a/x/btclightclient/keeper/keeper_test.go +++ b/x/btclightclient/keeper/keeper_test.go @@ -1 +1,14 @@ package keeper_test + +import ( + "testing" +) + +func TestCreatePsbt(t *testing.T) { + // create BitCoin Transaction + + // use btcwallet to create a transaction + // use btcwallet to create a psbt + + // pbst := txauthor.NewUnsignedTransaction() +} diff --git a/x/btclightclient/keeper/keeper_withdraw.go b/x/btclightclient/keeper/keeper_withdraw.go new file mode 100644 index 00000000..ad515900 --- /dev/null +++ b/x/btclightclient/keeper/keeper_withdraw.go @@ -0,0 +1,81 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/sideprotocol/side/x/btclightclient/types" +) + +// GetRequestSeqence returns the request sequence +func (k Keeper) GetRequestSeqence(ctx sdk.Context) uint64 { + store := ctx.KVStore(k.storeKey) + bz := store.Get(types.SequenceKey) + if bz == nil { + return 0 + } + return sdk.BigEndianToUint64(bz) +} + +// IncrementRequestSequence increments the request sequence and returns the new sequence +func (k Keeper) IncrementRequestSequence(ctx sdk.Context) uint64 { + store := ctx.KVStore(k.storeKey) + seq := k.GetRequestSeqence(ctx) + 1 + store.Set(types.SequenceKey, sdk.Uint64ToBigEndian(seq)) + return seq +} + +// New signing request +func (k Keeper) NewSigningRequest(ctx sdk.Context, sender string, txBytes string) *types.BitcoinSigningRequest { + signingRequest := &types.BitcoinSigningRequest{ + Address: sender, + TxBytes: txBytes, + Status: types.SigningStatus_SIGNING_STATUS_CREATED, + Sequence: k.IncrementRequestSequence(ctx), + } + return signingRequest +} + +// GetSigningRequest returns the signing request +func (k Keeper) GetSigningRequest(ctx sdk.Context, hash string) *types.BitcoinSigningRequest { + store := ctx.KVStore(k.storeKey) + var signingRequest types.BitcoinSigningRequest + bz := store.Get(types.BtcBlockHeaderHashKey(hash)) + k.cdc.MustUnmarshal(bz, &signingRequest) + return &signingRequest +} + +// SetSigningRequest sets the signing request +func (k Keeper) SetSigningRequest(ctx sdk.Context, txHash string, signingRequest *types.BitcoinSigningRequest) { + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(signingRequest) + store.Set(types.BtcSigningRequestKey(txHash), bz) +} + +// IterateSigningRequests iterates through all signing requests +func (k Keeper) IterateSigningRequests(ctx sdk.Context, process func(signingRequest types.BitcoinSigningRequest) (stop bool)) { + store := ctx.KVStore(k.storeKey) + iterator := sdk.KVStorePrefixIterator(store, types.BtcSigningRequestPrefix) + defer iterator.Close() + for ; iterator.Valid(); iterator.Next() { + var signingRequest types.BitcoinSigningRequest + k.cdc.MustUnmarshal(iterator.Value(), &signingRequest) + if process(signingRequest) { + break + } + } +} + +// filter SigningRequest by status with pagination +func (k Keeper) FilterSigningRequestsByStatus(ctx sdk.Context, req *types.QuerySigningRequestRequest) []*types.BitcoinSigningRequest { + var signingRequests []*types.BitcoinSigningRequest + k.IterateSigningRequests(ctx, func(signingRequest types.BitcoinSigningRequest) (stop bool) { + if signingRequest.Status == req.Status { + signingRequests = append(signingRequests, &signingRequest) + } + // pagination TODO: limit the number of signing requests + if len(signingRequests) >= 100 { + return true + } + return false + }) + return signingRequests +} diff --git a/x/btclightclient/keeper/msg_server.go b/x/btclightclient/keeper/msg_server.go index 1d365d66..39e97a7f 100644 --- a/x/btclightclient/keeper/msg_server.go +++ b/x/btclightclient/keeper/msg_server.go @@ -90,6 +90,51 @@ func (m msgServer) UpdateSenders(goCtx context.Context, msg *types.MsgUpdateSend return &types.MsgUpdateSendersResponse{}, nil } +func (m msgServer) WithdrawBitcoin(goCtx context.Context, msg *types.MsgWithdrawBitcoinRequest) (*types.MsgWithdrawBitcoinResponse, error) { + if err := msg.ValidateBasic(); err != nil { + return nil, err + } + ctx := sdk.UnwrapSDKContext(goCtx) + + sender := sdk.AccAddress(msg.Sender) + + coin, err := sdk.ParseCoinNormalized(msg.Amount) + if err != nil { + return nil, err + } + + balance := m.bankKeeper.GetBalance(ctx, sender, coin.Denom) + + if balance.Amount.LT(coin.Amount) { + return nil, types.ErrInsufficientBalance + } + + m.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, types.ModuleName, sdk.NewCoins(coin)) + + // Emit events + m.EmitEvent(ctx, msg.Sender, + sdk.NewAttribute("withdraw", msg.Amount), + ) + + return &types.MsgWithdrawBitcoinResponse{}, nil +} + +// SubmitWithdrawSignatures submits the signatures of the withdraw transaction. +func (m msgServer) SubmitWithdrawSignatures(goCtx context.Context, msg *types.MsgSubmitWithdrawSignaturesRequest) (*types.MsgSubmitWithdrawSignaturesResponse, error) { + if err := msg.ValidateBasic(); err != nil { + return nil, err + } + ctx := sdk.UnwrapSDKContext(goCtx) + request := m.GetSigningRequest(ctx, msg.Txid) + // request. + if ok := request.ValidateSignatures(msg.Signatures); !ok { + return nil, types.ErrInvalidSignatures + + } + return &types.MsgSubmitWithdrawSignaturesResponse{}, nil + +} + // NewMsgServerImpl returns an implementation of the MsgServer interface // for the provided Keeper. func NewMsgServerImpl(keeper Keeper) types.MsgServer { diff --git a/x/btclightclient/keeper/queries.go b/x/btclightclient/keeper/queries.go index 9471b9ae..47590e50 100644 --- a/x/btclightclient/keeper/queries.go +++ b/x/btclightclient/keeper/queries.go @@ -62,3 +62,19 @@ func (k Keeper) QueryBlockHeaderByHeight(goCtx context.Context, req *types.Query return &types.QueryBlockHeaderByHeightResponse{BlockHeader: header}, nil } + +func (k Keeper) QuerySigningRequest(goCtx context.Context, req *types.QuerySigningRequestRequest) (*types.QuerySigningRequestResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + if req.Status == types.SigningStatus_SIGNING_STATUS_UNSPECIFIED { + return nil, status.Error(codes.InvalidArgument, "invalid status") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + requests := k.FilterSigningRequestsByStatus(ctx, req) + + return &types.QuerySigningRequestResponse{Requests: requests}, nil + +} diff --git a/x/btclightclient/types/bitcoin.pb.go b/x/btclightclient/types/bitcoin.pb.go new file mode 100644 index 00000000..fd19d1da --- /dev/null +++ b/x/btclightclient/types/bitcoin.pb.go @@ -0,0 +1,1055 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: side/btclightclient/bitcoin.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// Bitcoin Signing Status +type SigningStatus int32 + +const ( + // SIGNING_STATUS_UNSPECIFIED - Default value, should not be used + SigningStatus_SIGNING_STATUS_UNSPECIFIED SigningStatus = 0 + // SIGNING_STATUS_CREATED - The signing request is created + SigningStatus_SIGNING_STATUS_CREATED SigningStatus = 1 + // SIGNING_STATUS_SIGNED - The signing request is signed + SigningStatus_SIGNING_STATUS_SIGNED SigningStatus = 2 + // SIGNING_STATUS_BROADCASTED - The signing request is broadcasted + SigningStatus_SIGNING_STATUS_BROADCASTED SigningStatus = 3 + // SIGNING_STATUS_CONFIRMED - The signing request is confirmed + SigningStatus_SIGNING_STATUS_CONFIRMED SigningStatus = 4 + // SIGNING_STATUS_REJECTED - The signing request is rejected + SigningStatus_SIGNING_STATUS_REJECTED SigningStatus = 5 +) + +var SigningStatus_name = map[int32]string{ + 0: "SIGNING_STATUS_UNSPECIFIED", + 1: "SIGNING_STATUS_CREATED", + 2: "SIGNING_STATUS_SIGNED", + 3: "SIGNING_STATUS_BROADCASTED", + 4: "SIGNING_STATUS_CONFIRMED", + 5: "SIGNING_STATUS_REJECTED", +} + +var SigningStatus_value = map[string]int32{ + "SIGNING_STATUS_UNSPECIFIED": 0, + "SIGNING_STATUS_CREATED": 1, + "SIGNING_STATUS_SIGNED": 2, + "SIGNING_STATUS_BROADCASTED": 3, + "SIGNING_STATUS_CONFIRMED": 4, + "SIGNING_STATUS_REJECTED": 5, +} + +func (x SigningStatus) String() string { + return proto.EnumName(SigningStatus_name, int32(x)) +} + +func (SigningStatus) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_d7dee3af17ecec77, []int{0} +} + +// Bitcoin Block Header +type BlockHeader struct { + Version uint64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` + Hash string `protobuf:"bytes,2,opt,name=hash,proto3" json:"hash,omitempty"` + Height uint64 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` + PreviousBlockHash string `protobuf:"bytes,4,opt,name=previous_block_hash,json=previousBlockHash,proto3" json:"previous_block_hash,omitempty"` + MerkleRoot string `protobuf:"bytes,5,opt,name=merkle_root,json=merkleRoot,proto3" json:"merkle_root,omitempty"` + Nonce uint64 `protobuf:"varint,6,opt,name=nonce,proto3" json:"nonce,omitempty"` + Bits string `protobuf:"bytes,7,opt,name=bits,proto3" json:"bits,omitempty"` + Time uint64 `protobuf:"varint,8,opt,name=time,proto3" json:"time,omitempty"` + Ntx uint64 `protobuf:"varint,9,opt,name=ntx,proto3" json:"ntx,omitempty"` +} + +func (m *BlockHeader) Reset() { *m = BlockHeader{} } +func (m *BlockHeader) String() string { return proto.CompactTextString(m) } +func (*BlockHeader) ProtoMessage() {} +func (*BlockHeader) Descriptor() ([]byte, []int) { + return fileDescriptor_d7dee3af17ecec77, []int{0} +} +func (m *BlockHeader) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BlockHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BlockHeader.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 *BlockHeader) XXX_Merge(src proto.Message) { + xxx_messageInfo_BlockHeader.Merge(m, src) +} +func (m *BlockHeader) XXX_Size() int { + return m.Size() +} +func (m *BlockHeader) XXX_DiscardUnknown() { + xxx_messageInfo_BlockHeader.DiscardUnknown(m) +} + +var xxx_messageInfo_BlockHeader proto.InternalMessageInfo + +func (m *BlockHeader) GetVersion() uint64 { + if m != nil { + return m.Version + } + return 0 +} + +func (m *BlockHeader) GetHash() string { + if m != nil { + return m.Hash + } + return "" +} + +func (m *BlockHeader) GetHeight() uint64 { + if m != nil { + return m.Height + } + return 0 +} + +func (m *BlockHeader) GetPreviousBlockHash() string { + if m != nil { + return m.PreviousBlockHash + } + return "" +} + +func (m *BlockHeader) GetMerkleRoot() string { + if m != nil { + return m.MerkleRoot + } + return "" +} + +func (m *BlockHeader) GetNonce() uint64 { + if m != nil { + return m.Nonce + } + return 0 +} + +func (m *BlockHeader) GetBits() string { + if m != nil { + return m.Bits + } + return "" +} + +func (m *BlockHeader) GetTime() uint64 { + if m != nil { + return m.Time + } + return 0 +} + +func (m *BlockHeader) GetNtx() uint64 { + if m != nil { + return m.Ntx + } + return 0 +} + +// Bitcoin Signing Request +type BitcoinSigningRequest struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + TxBytes string `protobuf:"bytes,2,opt,name=tx_bytes,json=txBytes,proto3" json:"tx_bytes,omitempty"` + Status SigningStatus `protobuf:"varint,3,opt,name=status,proto3,enum=side.btclightclient.SigningStatus" json:"status,omitempty"` + Sequence uint64 `protobuf:"varint,4,opt,name=sequence,proto3" json:"sequence,omitempty"` + // The vault address that the request is associated with + VaultAddress string `protobuf:"bytes,5,opt,name=vault_address,json=vaultAddress,proto3" json:"vault_address,omitempty"` +} + +func (m *BitcoinSigningRequest) Reset() { *m = BitcoinSigningRequest{} } +func (m *BitcoinSigningRequest) String() string { return proto.CompactTextString(m) } +func (*BitcoinSigningRequest) ProtoMessage() {} +func (*BitcoinSigningRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_d7dee3af17ecec77, []int{1} +} +func (m *BitcoinSigningRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *BitcoinSigningRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_BitcoinSigningRequest.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 *BitcoinSigningRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_BitcoinSigningRequest.Merge(m, src) +} +func (m *BitcoinSigningRequest) XXX_Size() int { + return m.Size() +} +func (m *BitcoinSigningRequest) XXX_DiscardUnknown() { + xxx_messageInfo_BitcoinSigningRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_BitcoinSigningRequest proto.InternalMessageInfo + +func (m *BitcoinSigningRequest) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *BitcoinSigningRequest) GetTxBytes() string { + if m != nil { + return m.TxBytes + } + return "" +} + +func (m *BitcoinSigningRequest) GetStatus() SigningStatus { + if m != nil { + return m.Status + } + return SigningStatus_SIGNING_STATUS_UNSPECIFIED +} + +func (m *BitcoinSigningRequest) GetSequence() uint64 { + if m != nil { + return m.Sequence + } + return 0 +} + +func (m *BitcoinSigningRequest) GetVaultAddress() string { + if m != nil { + return m.VaultAddress + } + return "" +} + +func init() { + proto.RegisterEnum("side.btclightclient.SigningStatus", SigningStatus_name, SigningStatus_value) + proto.RegisterType((*BlockHeader)(nil), "side.btclightclient.BlockHeader") + proto.RegisterType((*BitcoinSigningRequest)(nil), "side.btclightclient.BitcoinSigningRequest") +} + +func init() { proto.RegisterFile("side/btclightclient/bitcoin.proto", fileDescriptor_d7dee3af17ecec77) } + +var fileDescriptor_d7dee3af17ecec77 = []byte{ + // 508 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x53, 0xcb, 0x6e, 0xd3, 0x40, + 0x14, 0xcd, 0x34, 0xef, 0x5b, 0x8a, 0xc2, 0xf4, 0xc1, 0x34, 0x20, 0x53, 0xc2, 0xa6, 0x62, 0xe1, + 0x48, 0x74, 0xc7, 0x2e, 0x0f, 0xb7, 0x04, 0xa9, 0x29, 0x1a, 0xa7, 0x1b, 0x36, 0x56, 0xec, 0x8c, + 0xec, 0x51, 0x1d, 0x4f, 0xf0, 0x8c, 0xa3, 0xf4, 0x2f, 0xf8, 0x25, 0x76, 0xb0, 0xeb, 0x92, 0x25, + 0x4a, 0x7e, 0x81, 0x0f, 0x40, 0x33, 0x4e, 0x90, 0x6a, 0x75, 0x13, 0xdd, 0x73, 0xef, 0xb9, 0xe7, + 0xdc, 0x1c, 0xdb, 0xf0, 0x56, 0xf2, 0x19, 0xeb, 0xfa, 0x2a, 0x88, 0x79, 0x18, 0xe9, 0x5f, 0x96, + 0xa8, 0xae, 0xcf, 0x55, 0x20, 0x78, 0x62, 0x2f, 0x52, 0xa1, 0x04, 0x3e, 0xd4, 0x14, 0xfb, 0x31, + 0xa5, 0x7d, 0x14, 0x8a, 0x50, 0x98, 0x79, 0x57, 0x57, 0x39, 0xb5, 0xf3, 0x17, 0xc1, 0x7e, 0x3f, + 0x16, 0xc1, 0xdd, 0x27, 0x36, 0x9d, 0xb1, 0x14, 0x13, 0xa8, 0x2f, 0x59, 0x2a, 0xb9, 0x48, 0x08, + 0x3a, 0x43, 0xe7, 0x15, 0xba, 0x83, 0x18, 0x43, 0x25, 0x9a, 0xca, 0x88, 0xec, 0x9d, 0xa1, 0xf3, + 0x26, 0x35, 0x35, 0x3e, 0x81, 0x5a, 0xc4, 0xb4, 0x07, 0x29, 0x1b, 0xf2, 0x16, 0x61, 0x1b, 0x0e, + 0x17, 0x29, 0x5b, 0x72, 0x91, 0x49, 0xcf, 0xd7, 0xea, 0x9e, 0x59, 0xad, 0x98, 0xd5, 0x17, 0xbb, + 0x51, 0xee, 0xab, 0x75, 0xde, 0xc0, 0xfe, 0x9c, 0xa5, 0x77, 0x31, 0xf3, 0x52, 0x21, 0x14, 0xa9, + 0x1a, 0x1e, 0xe4, 0x2d, 0x2a, 0x84, 0xc2, 0x47, 0x50, 0x4d, 0x44, 0x12, 0x30, 0x52, 0x33, 0x3e, + 0x39, 0xd0, 0x27, 0xf9, 0x5c, 0x49, 0x52, 0xcf, 0x4f, 0xd2, 0xb5, 0xee, 0x29, 0x3e, 0x67, 0xa4, + 0x61, 0x88, 0xa6, 0xc6, 0x2d, 0x28, 0x27, 0x6a, 0x45, 0x9a,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0x05, + 0x2f, 0x0b, 0x53, 0xea, 0x7c, 0x76, 0x06, 0x7a, 0xb5, 0xda, 0xbf, 0xfe, 0xb9, 0xb6, 0xd0, 0xc3, + 0xda, 0x42, 0x7f, 0xd6, 0x16, 0xfa, 0xbe, 0xb1, 0x4a, 0x0f, 0x1b, 0xab, 0xf4, 0x7b, 0x63, 0x95, + 0xbe, 0x5e, 0x84, 0x5c, 0x45, 0x99, 0x6f, 0x07, 0x62, 0xde, 0xd5, 0xa1, 0x9a, 0xd7, 0x36, 0x10, + 0xb1, 0x01, 0xdd, 0x55, 0xf1, 0x43, 0x50, 0xf7, 0x0b, 0x26, 0xfd, 0x9a, 0x61, 0x5d, 0xfc, 0x0b, + 0x00, 0x00, 0xff, 0xff, 0x2c, 0x90, 0x12, 0x79, 0x2c, 0x03, 0x00, 0x00, +} + +func (m *BlockHeader) 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 *BlockHeader) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BlockHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Ntx != 0 { + i = encodeVarintBitcoin(dAtA, i, uint64(m.Ntx)) + i-- + dAtA[i] = 0x48 + } + if m.Time != 0 { + i = encodeVarintBitcoin(dAtA, i, uint64(m.Time)) + i-- + dAtA[i] = 0x40 + } + if len(m.Bits) > 0 { + i -= len(m.Bits) + copy(dAtA[i:], m.Bits) + i = encodeVarintBitcoin(dAtA, i, uint64(len(m.Bits))) + i-- + dAtA[i] = 0x3a + } + if m.Nonce != 0 { + i = encodeVarintBitcoin(dAtA, i, uint64(m.Nonce)) + i-- + dAtA[i] = 0x30 + } + if len(m.MerkleRoot) > 0 { + i -= len(m.MerkleRoot) + copy(dAtA[i:], m.MerkleRoot) + i = encodeVarintBitcoin(dAtA, i, uint64(len(m.MerkleRoot))) + i-- + dAtA[i] = 0x2a + } + if len(m.PreviousBlockHash) > 0 { + i -= len(m.PreviousBlockHash) + copy(dAtA[i:], m.PreviousBlockHash) + i = encodeVarintBitcoin(dAtA, i, uint64(len(m.PreviousBlockHash))) + i-- + dAtA[i] = 0x22 + } + if m.Height != 0 { + i = encodeVarintBitcoin(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x18 + } + if len(m.Hash) > 0 { + i -= len(m.Hash) + copy(dAtA[i:], m.Hash) + i = encodeVarintBitcoin(dAtA, i, uint64(len(m.Hash))) + i-- + dAtA[i] = 0x12 + } + if m.Version != 0 { + i = encodeVarintBitcoin(dAtA, i, uint64(m.Version)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *BitcoinSigningRequest) 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 *BitcoinSigningRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *BitcoinSigningRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.VaultAddress) > 0 { + i -= len(m.VaultAddress) + copy(dAtA[i:], m.VaultAddress) + i = encodeVarintBitcoin(dAtA, i, uint64(len(m.VaultAddress))) + i-- + dAtA[i] = 0x2a + } + if m.Sequence != 0 { + i = encodeVarintBitcoin(dAtA, i, uint64(m.Sequence)) + i-- + dAtA[i] = 0x20 + } + if m.Status != 0 { + i = encodeVarintBitcoin(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x18 + } + if len(m.TxBytes) > 0 { + i -= len(m.TxBytes) + copy(dAtA[i:], m.TxBytes) + i = encodeVarintBitcoin(dAtA, i, uint64(len(m.TxBytes))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintBitcoin(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintBitcoin(dAtA []byte, offset int, v uint64) int { + offset -= sovBitcoin(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *BlockHeader) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Version != 0 { + n += 1 + sovBitcoin(uint64(m.Version)) + } + l = len(m.Hash) + if l > 0 { + n += 1 + l + sovBitcoin(uint64(l)) + } + if m.Height != 0 { + n += 1 + sovBitcoin(uint64(m.Height)) + } + l = len(m.PreviousBlockHash) + if l > 0 { + n += 1 + l + sovBitcoin(uint64(l)) + } + l = len(m.MerkleRoot) + if l > 0 { + n += 1 + l + sovBitcoin(uint64(l)) + } + if m.Nonce != 0 { + n += 1 + sovBitcoin(uint64(m.Nonce)) + } + l = len(m.Bits) + if l > 0 { + n += 1 + l + sovBitcoin(uint64(l)) + } + if m.Time != 0 { + n += 1 + sovBitcoin(uint64(m.Time)) + } + if m.Ntx != 0 { + n += 1 + sovBitcoin(uint64(m.Ntx)) + } + return n +} + +func (m *BitcoinSigningRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovBitcoin(uint64(l)) + } + l = len(m.TxBytes) + if l > 0 { + n += 1 + l + sovBitcoin(uint64(l)) + } + if m.Status != 0 { + n += 1 + sovBitcoin(uint64(m.Status)) + } + if m.Sequence != 0 { + n += 1 + sovBitcoin(uint64(m.Sequence)) + } + l = len(m.VaultAddress) + if l > 0 { + n += 1 + l + sovBitcoin(uint64(l)) + } + return n +} + +func sovBitcoin(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozBitcoin(x uint64) (n int) { + return sovBitcoin(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *BlockHeader) 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 ErrIntOverflowBitcoin + } + 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: BlockHeader: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BlockHeader: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) + } + m.Version = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBitcoin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Version |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBitcoin + } + 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 ErrInvalidLengthBitcoin + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBitcoin + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Hash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBitcoin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PreviousBlockHash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBitcoin + } + 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 ErrInvalidLengthBitcoin + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBitcoin + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PreviousBlockHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MerkleRoot", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBitcoin + } + 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 ErrInvalidLengthBitcoin + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBitcoin + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MerkleRoot = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Nonce", wireType) + } + m.Nonce = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBitcoin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Nonce |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Bits", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBitcoin + } + 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 ErrInvalidLengthBitcoin + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBitcoin + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Bits = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Time", wireType) + } + m.Time = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBitcoin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Time |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Ntx", wireType) + } + m.Ntx = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBitcoin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Ntx |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipBitcoin(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthBitcoin + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *BitcoinSigningRequest) 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 ErrIntOverflowBitcoin + } + 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: BitcoinSigningRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: BitcoinSigningRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBitcoin + } + 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 ErrInvalidLengthBitcoin + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBitcoin + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TxBytes", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBitcoin + } + 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 ErrInvalidLengthBitcoin + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBitcoin + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TxBytes = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBitcoin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= SigningStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) + } + m.Sequence = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBitcoin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Sequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field VaultAddress", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBitcoin + } + 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 ErrInvalidLengthBitcoin + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBitcoin + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.VaultAddress = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipBitcoin(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthBitcoin + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipBitcoin(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowBitcoin + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowBitcoin + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowBitcoin + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthBitcoin + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupBitcoin + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthBitcoin + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthBitcoin = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowBitcoin = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupBitcoin = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/btclightclient/types/errors.go b/x/btclightclient/types/errors.go index d09956b5..b55b4573 100644 --- a/x/btclightclient/types/errors.go +++ b/x/btclightclient/types/errors.go @@ -21,4 +21,7 @@ var ( ErrNotConfirmed = errorsmod.Register(ModuleName, 3200, "transaction not confirmed") ErrExceedMaxAcceptanceDepth = errorsmod.Register(ModuleName, 3201, "exceed max acceptance block depth") ErrUnsupportedScriptType = errorsmod.Register(ModuleName, 3202, "unsupported script type") + + ErrInvalidSignatures = errorsmod.Register(ModuleName, 4200, "invalid signatures") + ErrInsufficientBalance = errorsmod.Register(ModuleName, 4201, "insufficient balance") ) diff --git a/x/btclightclient/types/genesis.pb.go b/x/btclightclient/types/genesis.pb.go index 4056abdd..2df0fdf4 100644 --- a/x/btclightclient/types/genesis.pb.go +++ b/x/btclightclient/types/genesis.pb.go @@ -92,23 +92,24 @@ func init() { func init() { proto.RegisterFile("side/btclightclient/genesis.proto", fileDescriptor_84e124efbd6ad9f4) } var fileDescriptor_84e124efbd6ad9f4 = []byte{ - // 255 bytes of a gzipped FileDescriptorProto + // 268 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2c, 0xce, 0x4c, 0x49, 0xd5, 0x4f, 0x2a, 0x49, 0xce, 0xc9, 0x4c, 0xcf, 0x00, 0x91, 0xa9, 0x79, 0x25, 0xfa, 0xe9, 0xa9, 0x79, 0xa9, 0xc5, 0x99, 0xc5, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0xc2, 0x20, 0x25, 0x7a, 0xa8, 0x4a, 0xa4, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0xf2, 0xfa, 0x20, 0x16, 0x44, 0xa9, 0x94, - 0x02, 0x36, 0xd3, 0x0a, 0x12, 0x8b, 0x12, 0x73, 0xa1, 0x86, 0x29, 0xdd, 0x63, 0xe4, 0xe2, 0x71, - 0x87, 0x18, 0x1f, 0x5c, 0x92, 0x58, 0x92, 0x2a, 0x64, 0xc9, 0xc5, 0x06, 0x51, 0x20, 0xc1, 0xa8, - 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xad, 0x87, 0xc5, 0x3a, 0xbd, 0x00, 0xb0, 0x12, 0x27, 0x96, 0x13, - 0xf7, 0xe4, 0x19, 0x82, 0xa0, 0x1a, 0x84, 0x7c, 0xb8, 0x04, 0x93, 0x52, 0x8b, 0x4b, 0xe2, 0x93, - 0x72, 0xf2, 0x93, 0xb3, 0xe3, 0x33, 0x52, 0x13, 0x53, 0x52, 0x8b, 0x24, 0x98, 0xc0, 0xa6, 0x28, - 0x60, 0x35, 0xc5, 0x09, 0xa4, 0xd0, 0x03, 0xac, 0x2e, 0x88, 0x1f, 0xa4, 0x15, 0x49, 0x40, 0xc8, - 0x95, 0x8b, 0x17, 0xd9, 0xa0, 0x62, 0x09, 0x66, 0x05, 0x66, 0xa2, 0x4c, 0xe2, 0x49, 0x42, 0x70, - 0x8a, 0x9d, 0x7c, 0x4f, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, - 0x09, 0x8f, 0xe5, 0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0xca, 0x38, 0x3d, - 0xb3, 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x1f, 0x64, 0x26, 0x38, 0x40, 0x92, 0xf3, - 0x73, 0xc0, 0x1c, 0xfd, 0x0a, 0xf4, 0x60, 0x2b, 0xa9, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0xab, - 0x32, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xf5, 0xf9, 0x10, 0x25, 0xa8, 0x01, 0x00, 0x00, + 0x02, 0x36, 0xd3, 0x0a, 0x12, 0x8b, 0x12, 0x73, 0xa1, 0x86, 0x49, 0x61, 0xb5, 0x2f, 0x29, 0xb3, + 0x24, 0x39, 0x3f, 0x33, 0x0f, 0xa2, 0x44, 0xe9, 0x1e, 0x23, 0x17, 0x8f, 0x3b, 0xc4, 0x05, 0xc1, + 0x25, 0x89, 0x25, 0xa9, 0x42, 0x96, 0x5c, 0x6c, 0x10, 0x33, 0x24, 0x18, 0x15, 0x18, 0x35, 0xb8, + 0x8d, 0xa4, 0xf5, 0xb0, 0xb8, 0x48, 0x2f, 0x00, 0xac, 0xc4, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, + 0x20, 0xa8, 0x06, 0x21, 0x1f, 0x2e, 0xc1, 0xa4, 0xd4, 0xe2, 0x92, 0xf8, 0xa4, 0x9c, 0xfc, 0xe4, + 0xec, 0xf8, 0x8c, 0xd4, 0xc4, 0x94, 0xd4, 0x22, 0x09, 0x26, 0xb0, 0x29, 0x0a, 0x58, 0x4d, 0x71, + 0x02, 0x29, 0xf4, 0x00, 0xab, 0x0b, 0xe2, 0x07, 0x69, 0x45, 0x12, 0x10, 0x72, 0xe5, 0xe2, 0x45, + 0x36, 0xa8, 0x58, 0x82, 0x59, 0x81, 0x99, 0x28, 0x93, 0x78, 0x92, 0x10, 0x9c, 0x62, 0x27, 0xdf, + 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, + 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x32, 0x4e, 0xcf, 0x2c, 0xc9, 0x28, + 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x07, 0x99, 0x09, 0x0e, 0x90, 0xe4, 0xfc, 0x1c, 0x30, 0x47, + 0xbf, 0x02, 0x3d, 0xdc, 0x4a, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0xaa, 0x8c, 0x01, 0x01, + 0x00, 0x00, 0xff, 0xff, 0x3f, 0x41, 0x33, 0x45, 0xcb, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/btclightclient/types/keys.go b/x/btclightclient/types/keys.go index cde6daa9..ef5fc549 100644 --- a/x/btclightclient/types/keys.go +++ b/x/btclightclient/types/keys.go @@ -23,10 +23,13 @@ func KeyPrefix(p string) []byte { var ( ParamsStoreKey = []byte{0x1} + SequenceKey = []byte{0x2} + // Host chain keys prefix the HostChain structs BtcBlockHeaderHashPrefix = []byte{0x11} // prefix for each key to a block header, for a hash BtcBlockHeaderHeightPrefix = []byte{0x12} // prefix for each key to a block hash, for a height BtcBestBlockHeaderKey = []byte{0x13} // key for the best block height + BtcSigningRequestPrefix = []byte{0x14} // prefix for each key to a signing request ChainCfg = &chaincfg.MainNetParams ) @@ -44,3 +47,7 @@ func BtcBlockHeaderHashKey(hash string) []byte { func BtcBlockHeaderHeightKey(height uint64) []byte { return append(BtcBlockHeaderHashPrefix, Int64ToBytes(height)...) } + +func BtcSigningRequestKey(hash string) []byte { + return append(BtcBlockHeaderHashPrefix, []byte(hash)...) +} diff --git a/x/btclightclient/types/message_submit_signature.go b/x/btclightclient/types/message_submit_signature.go new file mode 100644 index 00000000..23c72ec1 --- /dev/null +++ b/x/btclightclient/types/message_submit_signature.go @@ -0,0 +1,65 @@ +package types + +import ( + sdkerrors "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const TypeMsgSubmitSignature = "submit_signature" + +func NewMsgSubmitWithdrawSignaturesRequest( + sender string, + txid string, + signatures []string, +) *MsgSubmitWithdrawSignaturesRequest { + return &MsgSubmitWithdrawSignaturesRequest{ + Sender: sender, + Txid: txid, + Signatures: signatures, + } +} + +func (msg *MsgSubmitWithdrawSignaturesRequest) Route() string { + return RouterKey +} + +func (msg *MsgSubmitWithdrawSignaturesRequest) Type() string { + return TypeMsgSubmitSignature +} + +func (msg *MsgSubmitWithdrawSignaturesRequest) GetSigners() []sdk.AccAddress { + Sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{Sender} +} + +func (msg *MsgSubmitWithdrawSignaturesRequest) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgSubmitWithdrawSignaturesRequest) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return sdkerrors.Wrapf(err, "invalid Sender address (%s)", err) + } + + if len(msg.Txid) == 0 { + return sdkerrors.Wrap(ErrInvalidSignatures, "txid cannot be empty") + } + + if len(msg.Signatures) == 0 { + return sdkerrors.Wrap(ErrInvalidSignatures, "sigatures cannot be empty") + } + + for _, signature := range msg.Signatures { + if len(signature) == 0 { + return sdkerrors.Wrap(ErrInvalidSignatures, "signature cannot be empty") + + } + } + + return nil +} diff --git a/x/btclightclient/types/message_withdraw_bitcoin.go b/x/btclightclient/types/message_withdraw_bitcoin.go new file mode 100644 index 00000000..a0609415 --- /dev/null +++ b/x/btclightclient/types/message_withdraw_bitcoin.go @@ -0,0 +1,52 @@ +package types + +import ( + sdkerrors "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const TypeMsgWithdrawBitcoin = "withdraw_bitcoin" + +func NewMsgWithdrawBitcoinRequest( + sender string, + amount string, +) *MsgWithdrawBitcoinRequest { + return &MsgWithdrawBitcoinRequest{ + Sender: sender, + Amount: amount, + } +} + +func (msg *MsgWithdrawBitcoinRequest) Route() string { + return RouterKey +} + +func (msg *MsgWithdrawBitcoinRequest) Type() string { + return TypeMsgWithdrawBitcoin +} + +func (msg *MsgWithdrawBitcoinRequest) GetSigners() []sdk.AccAddress { + Sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{Sender} +} + +func (msg *MsgWithdrawBitcoinRequest) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgWithdrawBitcoinRequest) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return sdkerrors.Wrapf(err, "invalid Sender address (%s)", err) + } + + if len(msg.Amount) == 0 { + return sdkerrors.Wrap(sdk.ErrInvalidLengthCoin, "amount cannot be empty") + } + + return nil +} diff --git a/x/btclightclient/types/params.pb.go b/x/btclightclient/types/params.pb.go index 3600bb94..27760ed9 100644 --- a/x/btclightclient/types/params.pb.go +++ b/x/btclightclient/types/params.pb.go @@ -105,151 +105,33 @@ func (m *Params) GetBtcVoucherAddress() []string { return nil } -// Bitcoin Block Header -type BlockHeader struct { - Version uint64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` - Hash string `protobuf:"bytes,2,opt,name=hash,proto3" json:"hash,omitempty"` - Height uint64 `protobuf:"varint,3,opt,name=height,proto3" json:"height,omitempty"` - PreviousBlockHash string `protobuf:"bytes,4,opt,name=previous_block_hash,json=previousBlockHash,proto3" json:"previous_block_hash,omitempty"` - MerkleRoot string `protobuf:"bytes,5,opt,name=merkle_root,json=merkleRoot,proto3" json:"merkle_root,omitempty"` - Nonce uint64 `protobuf:"varint,6,opt,name=nonce,proto3" json:"nonce,omitempty"` - Bits string `protobuf:"bytes,7,opt,name=bits,proto3" json:"bits,omitempty"` - Time uint64 `protobuf:"varint,8,opt,name=time,proto3" json:"time,omitempty"` - Ntx uint64 `protobuf:"varint,9,opt,name=ntx,proto3" json:"ntx,omitempty"` -} - -func (m *BlockHeader) Reset() { *m = BlockHeader{} } -func (m *BlockHeader) String() string { return proto.CompactTextString(m) } -func (*BlockHeader) ProtoMessage() {} -func (*BlockHeader) Descriptor() ([]byte, []int) { - return fileDescriptor_3b47f8b78acf6f6e, []int{1} -} -func (m *BlockHeader) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *BlockHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_BlockHeader.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 *BlockHeader) XXX_Merge(src proto.Message) { - xxx_messageInfo_BlockHeader.Merge(m, src) -} -func (m *BlockHeader) XXX_Size() int { - return m.Size() -} -func (m *BlockHeader) XXX_DiscardUnknown() { - xxx_messageInfo_BlockHeader.DiscardUnknown(m) -} - -var xxx_messageInfo_BlockHeader proto.InternalMessageInfo - -func (m *BlockHeader) GetVersion() uint64 { - if m != nil { - return m.Version - } - return 0 -} - -func (m *BlockHeader) GetHash() string { - if m != nil { - return m.Hash - } - return "" -} - -func (m *BlockHeader) GetHeight() uint64 { - if m != nil { - return m.Height - } - return 0 -} - -func (m *BlockHeader) GetPreviousBlockHash() string { - if m != nil { - return m.PreviousBlockHash - } - return "" -} - -func (m *BlockHeader) GetMerkleRoot() string { - if m != nil { - return m.MerkleRoot - } - return "" -} - -func (m *BlockHeader) GetNonce() uint64 { - if m != nil { - return m.Nonce - } - return 0 -} - -func (m *BlockHeader) GetBits() string { - if m != nil { - return m.Bits - } - return "" -} - -func (m *BlockHeader) GetTime() uint64 { - if m != nil { - return m.Time - } - return 0 -} - -func (m *BlockHeader) GetNtx() uint64 { - if m != nil { - return m.Ntx - } - return 0 -} - func init() { proto.RegisterType((*Params)(nil), "side.btclightclient.Params") - proto.RegisterType((*BlockHeader)(nil), "side.btclightclient.BlockHeader") } func init() { proto.RegisterFile("side/btclightclient/params.proto", fileDescriptor_3b47f8b78acf6f6e) } var fileDescriptor_3b47f8b78acf6f6e = []byte{ - // 421 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x52, 0x3f, 0x6f, 0xd3, 0x40, - 0x14, 0xcf, 0x91, 0x3f, 0x25, 0x57, 0x21, 0xc8, 0xb5, 0x82, 0x53, 0x07, 0x63, 0x55, 0x0c, 0x11, - 0x43, 0x3c, 0x74, 0x64, 0x6a, 0xd5, 0x81, 0x05, 0x09, 0x79, 0x60, 0x60, 0xb1, 0xce, 0xe7, 0x47, - 0x7c, 0xaa, 0x7d, 0xcf, 0xba, 0xbb, 0x44, 0xe6, 0x5b, 0xf0, 0xb1, 0x18, 0x3b, 0x32, 0x42, 0xf2, - 0x15, 0xf8, 0x00, 0xe8, 0x9e, 0x13, 0xa0, 0x5d, 0xa2, 0xdf, 0xbf, 0xcb, 0xfb, 0x3d, 0xeb, 0xf1, - 0xd4, 0x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 0x08, 0x3e, 0xa9, 0x95, 0xaf, 0x69, 0xbf, 0x79, 0x4e, 0x58, - 0xbc, 0xe4, 0xb3, 0x1a, 0xe2, 0x77, 0x3c, 0xac, 0x70, 0x60, 0xb1, 0x45, 0xe7, 0x60, 0x6b, 0x70, - 0xe3, 0x0f, 0x8b, 0xd2, 0xd3, 0xa1, 0xf3, 0xe2, 0x68, 0x0d, 0x73, 0xe3, 0xff, 0xbc, 0xe6, 0xa7, - 0x2d, 0xb8, 0xbb, 0x06, 0x0a, 0x87, 0x18, 0xe4, 0x94, 0x72, 0x7c, 0x90, 0x72, 0xc4, 0x20, 0xce, - 0xf9, 0xd4, 0xa2, 0xd5, 0x20, 0x67, 0x34, 0x67, 0x20, 0xb1, 0x52, 0x69, 0x82, 0x97, 0x27, 0x43, - 0xa5, 0x88, 0xa3, 0x16, 0x4c, 0x0b, 0xf2, 0x29, 0x05, 0x09, 0x8b, 0x17, 0x7c, 0x6c, 0x43, 0x2f, - 0xe7, 0x24, 0x45, 0x78, 0xf3, 0xe1, 0xfb, 0x2e, 0x61, 0xf7, 0xbb, 0x84, 0xfd, 0xdc, 0x25, 0xec, - 0xdb, 0x3e, 0x19, 0xdd, 0xef, 0x93, 0xd1, 0x8f, 0x7d, 0x32, 0xfa, 0x7c, 0xb5, 0x36, 0xa1, 0xde, - 0x94, 0x2b, 0x8d, 0x6d, 0x16, 0x4f, 0x85, 0x4e, 0x41, 0x63, 0x43, 0x24, 0xeb, 0x1f, 0xdf, 0x56, - 0xf8, 0xda, 0x81, 0x2f, 0x67, 0x94, 0xba, 0xfa, 0x13, 0x00, 0x00, 0xff, 0xff, 0x68, 0x1a, 0xad, - 0x49, 0x7f, 0x02, 0x00, 0x00, + // 295 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x90, 0xbb, 0x6a, 0xf3, 0x30, + 0x00, 0x85, 0xa3, 0x3f, 0x97, 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0x8a, 0x40, 0x3c, 0xcd, 0x4e, + 0x99, 0xe3, 0x77, 0x7d, 0xbf, 0xf1, 0x35, 0x4a, 0xe0, 0xfc, 0xb7, 0x4b, 0x85, 0x30, 0xd2, 0x5a, + 0x3c, 0x0e, 0x9f, 0x9e, 0xfd, 0xd8, 0xab, 0x1e, 0xac, 0x6f, 0x5e, 0x0f, 0x04, 0xec, 0x0f, 0x04, + 0xbc, 0x1f, 0x08, 0x78, 0xe9, 0xc8, 0x60, 0xdf, 0x91, 0xc1, 0x5b, 0x47, 0x06, 0xf7, 0xcb, 0xa2, + 0x72, 0xe5, 0x96, 0x25, 0x5c, 0xab, 0xd4, 0x6f, 0x16, 0x36, 0xe1, 0xba, 0x0e, 0x21, 0xdd, 0xfd, + 0x1d, 0xd9, 0x3d, 0xb7, 0xd2, 0xb2, 0x49, 0xb0, 0x96, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xce, + 0x86, 0x0b, 0x4d, 0x88, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -310,82 +192,6 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *BlockHeader) 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 *BlockHeader) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *BlockHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Ntx != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.Ntx)) - i-- - dAtA[i] = 0x48 - } - if m.Time != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.Time)) - i-- - dAtA[i] = 0x40 - } - if len(m.Bits) > 0 { - i -= len(m.Bits) - copy(dAtA[i:], m.Bits) - i = encodeVarintParams(dAtA, i, uint64(len(m.Bits))) - i-- - dAtA[i] = 0x3a - } - if m.Nonce != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.Nonce)) - i-- - dAtA[i] = 0x30 - } - if len(m.MerkleRoot) > 0 { - i -= len(m.MerkleRoot) - copy(dAtA[i:], m.MerkleRoot) - i = encodeVarintParams(dAtA, i, uint64(len(m.MerkleRoot))) - i-- - dAtA[i] = 0x2a - } - if len(m.PreviousBlockHash) > 0 { - i -= len(m.PreviousBlockHash) - copy(dAtA[i:], m.PreviousBlockHash) - i = encodeVarintParams(dAtA, i, uint64(len(m.PreviousBlockHash))) - i-- - dAtA[i] = 0x22 - } - if m.Height != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x18 - } - if len(m.Hash) > 0 { - i -= len(m.Hash) - copy(dAtA[i:], m.Hash) - i = encodeVarintParams(dAtA, i, uint64(len(m.Hash))) - i-- - dAtA[i] = 0x12 - } - if m.Version != 0 { - i = encodeVarintParams(dAtA, i, uint64(m.Version)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - func encodeVarintParams(dAtA []byte, offset int, v uint64) int { offset -= sovParams(v) base := offset @@ -428,46 +234,6 @@ func (m *Params) Size() (n int) { return n } -func (m *BlockHeader) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Version != 0 { - n += 1 + sovParams(uint64(m.Version)) - } - l = len(m.Hash) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) - } - if m.Height != 0 { - n += 1 + sovParams(uint64(m.Height)) - } - l = len(m.PreviousBlockHash) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) - } - l = len(m.MerkleRoot) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) - } - if m.Nonce != 0 { - n += 1 + sovParams(uint64(m.Nonce)) - } - l = len(m.Bits) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) - } - if m.Time != 0 { - n += 1 + sovParams(uint64(m.Time)) - } - if m.Ntx != 0 { - n += 1 + sovParams(uint64(m.Ntx)) - } - return n -} - func sovParams(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -658,279 +424,6 @@ func (m *Params) Unmarshal(dAtA []byte) error { } return nil } -func (m *BlockHeader) 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 ErrIntOverflowParams - } - 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: BlockHeader: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: BlockHeader: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) - } - m.Version = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Version |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - 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 ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Hash = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) - } - m.Height = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Height |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PreviousBlockHash", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - 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 ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PreviousBlockHash = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MerkleRoot", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - 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 ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.MerkleRoot = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Nonce", wireType) - } - m.Nonce = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Nonce |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Bits", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - 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 ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Bits = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 8: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Time", wireType) - } - m.Time = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Time |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 9: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Ntx", wireType) - } - m.Ntx = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Ntx |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipParams(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipParams(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/btclightclient/types/query.pb.go b/x/btclightclient/types/query.pb.go index 7c7226e8..95123eca 100644 --- a/x/btclightclient/types/query.pb.go +++ b/x/btclightclient/types/query.pb.go @@ -6,7 +6,7 @@ package types import ( context "context" fmt "fmt" - _ "github.com/cosmos/cosmos-sdk/types/query" + query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/cosmos/gogoproto/gogoproto" grpc1 "github.com/cosmos/gogoproto/grpc" proto "github.com/cosmos/gogoproto/proto" @@ -30,6 +30,112 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// QuerySigningRequestRequest is request type for the Query/SigningRequest RPC method. +type QuerySigningRequestRequest struct { + Status SigningStatus `protobuf:"varint,1,opt,name=status,proto3,enum=side.btclightclient.SigningStatus" json:"status,omitempty"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QuerySigningRequestRequest) Reset() { *m = QuerySigningRequestRequest{} } +func (m *QuerySigningRequestRequest) String() string { return proto.CompactTextString(m) } +func (*QuerySigningRequestRequest) ProtoMessage() {} +func (*QuerySigningRequestRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_f299b49d16182dbc, []int{0} +} +func (m *QuerySigningRequestRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySigningRequestRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySigningRequestRequest.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 *QuerySigningRequestRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySigningRequestRequest.Merge(m, src) +} +func (m *QuerySigningRequestRequest) XXX_Size() int { + return m.Size() +} +func (m *QuerySigningRequestRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySigningRequestRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySigningRequestRequest proto.InternalMessageInfo + +func (m *QuerySigningRequestRequest) GetStatus() SigningStatus { + if m != nil { + return m.Status + } + return SigningStatus_SIGNING_STATUS_UNSPECIFIED +} + +func (m *QuerySigningRequestRequest) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +// QuerySigningRequestResponse is response type for the Query/SigningRequest RPC method. +type QuerySigningRequestResponse struct { + Requests []*BitcoinSigningRequest `protobuf:"bytes,1,rep,name=requests,proto3" json:"requests,omitempty"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QuerySigningRequestResponse) Reset() { *m = QuerySigningRequestResponse{} } +func (m *QuerySigningRequestResponse) String() string { return proto.CompactTextString(m) } +func (*QuerySigningRequestResponse) ProtoMessage() {} +func (*QuerySigningRequestResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f299b49d16182dbc, []int{1} +} +func (m *QuerySigningRequestResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QuerySigningRequestResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QuerySigningRequestResponse.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 *QuerySigningRequestResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QuerySigningRequestResponse.Merge(m, src) +} +func (m *QuerySigningRequestResponse) XXX_Size() int { + return m.Size() +} +func (m *QuerySigningRequestResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QuerySigningRequestResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QuerySigningRequestResponse proto.InternalMessageInfo + +func (m *QuerySigningRequestResponse) GetRequests() []*BitcoinSigningRequest { + if m != nil { + return m.Requests + } + return nil +} + +func (m *QuerySigningRequestResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + // QueryParamsRequest is request type for the Query/Params RPC method. type QueryParamsRequest struct { } @@ -38,7 +144,7 @@ func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } func (*QueryParamsRequest) ProtoMessage() {} func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f299b49d16182dbc, []int{0} + return fileDescriptor_f299b49d16182dbc, []int{2} } func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -77,7 +183,7 @@ func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } func (*QueryParamsResponse) ProtoMessage() {} func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f299b49d16182dbc, []int{1} + return fileDescriptor_f299b49d16182dbc, []int{3} } func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -121,7 +227,7 @@ func (m *QueryChainTipRequest) Reset() { *m = QueryChainTipRequest{} } func (m *QueryChainTipRequest) String() string { return proto.CompactTextString(m) } func (*QueryChainTipRequest) ProtoMessage() {} func (*QueryChainTipRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f299b49d16182dbc, []int{2} + return fileDescriptor_f299b49d16182dbc, []int{4} } func (m *QueryChainTipRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -160,7 +266,7 @@ func (m *QueryChainTipResponse) Reset() { *m = QueryChainTipResponse{} } func (m *QueryChainTipResponse) String() string { return proto.CompactTextString(m) } func (*QueryChainTipResponse) ProtoMessage() {} func (*QueryChainTipResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f299b49d16182dbc, []int{3} + return fileDescriptor_f299b49d16182dbc, []int{5} } func (m *QueryChainTipResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -212,7 +318,7 @@ func (m *QueryBlockHeaderByHeightRequest) Reset() { *m = QueryBlockHeade func (m *QueryBlockHeaderByHeightRequest) String() string { return proto.CompactTextString(m) } func (*QueryBlockHeaderByHeightRequest) ProtoMessage() {} func (*QueryBlockHeaderByHeightRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f299b49d16182dbc, []int{4} + return fileDescriptor_f299b49d16182dbc, []int{6} } func (m *QueryBlockHeaderByHeightRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -257,7 +363,7 @@ func (m *QueryBlockHeaderByHeightResponse) Reset() { *m = QueryBlockHead func (m *QueryBlockHeaderByHeightResponse) String() string { return proto.CompactTextString(m) } func (*QueryBlockHeaderByHeightResponse) ProtoMessage() {} func (*QueryBlockHeaderByHeightResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f299b49d16182dbc, []int{5} + return fileDescriptor_f299b49d16182dbc, []int{7} } func (m *QueryBlockHeaderByHeightResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -302,7 +408,7 @@ func (m *QueryBlockHeaderByHashRequest) Reset() { *m = QueryBlockHeaderB func (m *QueryBlockHeaderByHashRequest) String() string { return proto.CompactTextString(m) } func (*QueryBlockHeaderByHashRequest) ProtoMessage() {} func (*QueryBlockHeaderByHashRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f299b49d16182dbc, []int{6} + return fileDescriptor_f299b49d16182dbc, []int{8} } func (m *QueryBlockHeaderByHashRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -347,7 +453,7 @@ func (m *QueryBlockHeaderByHashResponse) Reset() { *m = QueryBlockHeader func (m *QueryBlockHeaderByHashResponse) String() string { return proto.CompactTextString(m) } func (*QueryBlockHeaderByHashResponse) ProtoMessage() {} func (*QueryBlockHeaderByHashResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f299b49d16182dbc, []int{7} + return fileDescriptor_f299b49d16182dbc, []int{9} } func (m *QueryBlockHeaderByHashResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -384,6 +490,8 @@ func (m *QueryBlockHeaderByHashResponse) GetBlockHeader() *BlockHeader { } func init() { + proto.RegisterType((*QuerySigningRequestRequest)(nil), "side.btclightclient.QuerySigningRequestRequest") + proto.RegisterType((*QuerySigningRequestResponse)(nil), "side.btclightclient.QuerySigningRequestResponse") proto.RegisterType((*QueryParamsRequest)(nil), "side.btclightclient.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "side.btclightclient.QueryParamsResponse") proto.RegisterType((*QueryChainTipRequest)(nil), "side.btclightclient.QueryChainTipRequest") @@ -397,41 +505,50 @@ func init() { func init() { proto.RegisterFile("side/btclightclient/query.proto", fileDescriptor_f299b49d16182dbc) } var fileDescriptor_f299b49d16182dbc = []byte{ - // 531 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x92, 0x3f, 0x6f, 0xd3, 0x40, - 0x18, 0xc6, 0x73, 0x55, 0x1a, 0x89, 0x37, 0xb0, 0x5c, 0x43, 0x14, 0x19, 0x70, 0x2c, 0x4b, 0xa8, - 0x21, 0x52, 0x7d, 0x24, 0xa6, 0x43, 0xd6, 0x64, 0xe9, 0x82, 0x54, 0x2c, 0x26, 0x16, 0x74, 0x76, - 0x4f, 0xb6, 0x45, 0xe2, 0x73, 0x73, 0x17, 0x44, 0x54, 0x75, 0xe1, 0x13, 0x20, 0x10, 0xdf, 0x84, - 0x81, 0x99, 0xa9, 0x63, 0x25, 0x16, 0x26, 0x84, 0x12, 0x3e, 0x08, 0xf2, 0xf9, 0xaa, 0x26, 0xad, - 0xad, 0xa4, 0x12, 0x8b, 0xff, 0xdc, 0xfb, 0x3e, 0xef, 0xf3, 0x7b, 0x75, 0x0f, 0xb4, 0x45, 0x7c, - 0xc2, 0x88, 0x2f, 0x83, 0x71, 0x1c, 0x46, 0xd9, 0x93, 0x25, 0x92, 0x9c, 0xce, 0xd8, 0x74, 0xee, - 0xa4, 0x53, 0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0x44, 0x97, 0x0b, - 0x13, 0xfd, 0x59, 0x98, 0xe8, 0xd3, 0xd2, 0xac, 0x5c, 0x2e, 0xcd, 0xca, 0xaf, 0xa5, 0x59, 0x79, - 0xe3, 0x86, 0xb1, 0x8c, 0x66, 0xbe, 0x13, 0xf0, 0x49, 0xc1, 0xc8, 0x0f, 0xb7, 0x2e, 0x73, 0x9e, - 0x32, 0xe1, 0xd7, 0x54, 0x97, 0xfb, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xd4, 0xa0, 0x84, 0x5a, 0xcb, - 0x05, 0x00, 0x00, + // 674 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0x4f, 0x4f, 0x13, 0x4f, + 0x18, 0xc7, 0x3b, 0xfc, 0xf8, 0x35, 0xfa, 0x54, 0x3d, 0x0c, 0x48, 0xc8, 0xa2, 0x4b, 0xdd, 0xc4, + 0x50, 0x9b, 0xb0, 0x03, 0xad, 0x1c, 0xf0, 0x58, 0x12, 0xe5, 0x62, 0x82, 0x8b, 0x27, 0x2f, 0x66, + 0x76, 0x99, 0xec, 0x4e, 0x2c, 0x3b, 0x4b, 0x67, 0x6b, 0x24, 0x84, 0x8b, 0xaf, 0xc0, 0x68, 0x7c, + 0x01, 0xbe, 0x01, 0x2f, 0x5e, 0x3c, 0x7b, 0xe2, 0x48, 0xe2, 0xc5, 0x93, 0x31, 0xe0, 0xc9, 0x57, + 0x61, 0x76, 0x66, 0x6a, 0x29, 0xcc, 0x86, 0x36, 0xe1, 0xb2, 0xff, 0x9e, 0xe7, 0xfb, 0x7c, 0x3f, + 0xcf, 0xcc, 0xd3, 0x29, 0x2c, 0x4a, 0xbe, 0xc3, 0x48, 0x98, 0x47, 0x5d, 0x1e, 0x27, 0xc5, 0x95, + 0xa5, 0x39, 0xd9, 0xeb, 0xb3, 0xde, 0xbe, 0x9f, 0xf5, 0x44, 0x2e, 0xf0,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07, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -454,6 +571,8 @@ type QueryClient interface { QueryBlockHeaderByHeight(ctx context.Context, in *QueryBlockHeaderByHeightRequest, opts ...grpc.CallOption) (*QueryBlockHeaderByHeightResponse, error) // BlockHeaderByHash queries the block header by hash. QueryBlockHeaderByHash(ctx context.Context, in *QueryBlockHeaderByHashRequest, opts ...grpc.CallOption) (*QueryBlockHeaderByHashResponse, error) + // QuerySigningRequest queries the request to sign. + QuerySigningRequest(ctx context.Context, in *QuerySigningRequestRequest, opts ...grpc.CallOption) (*QuerySigningRequestResponse, error) } type queryClient struct { @@ -500,6 +619,15 @@ func (c *queryClient) QueryBlockHeaderByHash(ctx context.Context, in *QueryBlock return out, nil } +func (c *queryClient) QuerySigningRequest(ctx context.Context, in *QuerySigningRequestRequest, opts ...grpc.CallOption) (*QuerySigningRequestResponse, error) { + out := new(QuerySigningRequestResponse) + err := c.cc.Invoke(ctx, "/side.btclightclient.Query/QuerySigningRequest", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. @@ -510,6 +638,8 @@ type QueryServer interface { QueryBlockHeaderByHeight(context.Context, *QueryBlockHeaderByHeightRequest) (*QueryBlockHeaderByHeightResponse, error) // BlockHeaderByHash queries the block header by hash. QueryBlockHeaderByHash(context.Context, *QueryBlockHeaderByHashRequest) (*QueryBlockHeaderByHashResponse, error) + // QuerySigningRequest queries the request to sign. + QuerySigningRequest(context.Context, *QuerySigningRequestRequest) (*QuerySigningRequestResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -528,6 +658,9 @@ func (*UnimplementedQueryServer) QueryBlockHeaderByHeight(ctx context.Context, r func (*UnimplementedQueryServer) QueryBlockHeaderByHash(ctx context.Context, req *QueryBlockHeaderByHashRequest) (*QueryBlockHeaderByHashResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QueryBlockHeaderByHash not implemented") } +func (*UnimplementedQueryServer) QuerySigningRequest(ctx context.Context, req *QuerySigningRequestRequest) (*QuerySigningRequestResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QuerySigningRequest not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -605,6 +738,24 @@ func _Query_QueryBlockHeaderByHash_Handler(srv interface{}, ctx context.Context, return interceptor(ctx, in, info, handler) } +func _Query_QuerySigningRequest_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QuerySigningRequestRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QuerySigningRequest(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/side.btclightclient.Query/QuerySigningRequest", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QuerySigningRequest(ctx, req.(*QuerySigningRequestRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "side.btclightclient.Query", HandlerType: (*QueryServer)(nil), @@ -625,11 +776,104 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "QueryBlockHeaderByHash", Handler: _Query_QueryBlockHeaderByHash_Handler, }, + { + MethodName: "QuerySigningRequest", + Handler: _Query_QuerySigningRequest_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "side/btclightclient/query.proto", } +func (m *QuerySigningRequestRequest) 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 *QuerySigningRequestRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySigningRequestRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if m.Status != 0 { + i = encodeVarintQuery(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + +func (m *QuerySigningRequestResponse) 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 *QuerySigningRequestResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QuerySigningRequestResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Requests) > 0 { + for iNdEx := len(m.Requests) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Requests[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func (m *QueryParamsRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -883,6 +1127,41 @@ func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *QuerySigningRequestRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Status != 0 { + n += 1 + sovQuery(uint64(m.Status)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QuerySigningRequestResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Requests) > 0 { + for _, e := range m.Requests { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func (m *QueryParamsRequest) Size() (n int) { if m == nil { return 0 @@ -985,6 +1264,231 @@ func sovQuery(x uint64) (n int) { func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *QuerySigningRequestRequest) 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 ErrIntOverflowQuery + } + 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: QuerySigningRequestRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuerySigningRequestRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= SigningStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QuerySigningRequestResponse) 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 ErrIntOverflowQuery + } + 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: QuerySigningRequestResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QuerySigningRequestResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Requests", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Requests = append(m.Requests, &BitcoinSigningRequest{}) + if err := m.Requests[len(m.Requests)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/x/btclightclient/types/query.pb.gw.go b/x/btclightclient/types/query.pb.gw.go index d27b5688..b3039755 100644 --- a/x/btclightclient/types/query.pb.gw.go +++ b/x/btclightclient/types/query.pb.gw.go @@ -177,6 +177,42 @@ func local_request_Query_QueryBlockHeaderByHash_0(ctx context.Context, marshaler } +var ( + filter_Query_QuerySigningRequest_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_QuerySigningRequest_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySigningRequestRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QuerySigningRequest_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.QuerySigningRequest(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QuerySigningRequest_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QuerySigningRequestRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_QuerySigningRequest_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.QuerySigningRequest(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -275,6 +311,29 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_QuerySigningRequest_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_QuerySigningRequest_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QuerySigningRequest_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -396,6 +455,26 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_QuerySigningRequest_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_QuerySigningRequest_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QuerySigningRequest_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -407,6 +486,8 @@ var ( pattern_Query_QueryBlockHeaderByHeight_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 3}, []string{"sideprotocol", "side", "btclightclient", "height"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_QueryBlockHeaderByHash_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 3}, []string{"sideprotocol", "side", "btclightclient", "hash"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_QuerySigningRequest_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"sideprotocol", "side", "btclightclient", "signing", "request"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -417,4 +498,6 @@ var ( forward_Query_QueryBlockHeaderByHeight_0 = runtime.ForwardResponseMessage forward_Query_QueryBlockHeaderByHash_0 = runtime.ForwardResponseMessage + + forward_Query_QuerySigningRequest_0 = runtime.ForwardResponseMessage ) diff --git a/x/btclightclient/types/signature.go b/x/btclightclient/types/signature.go new file mode 100644 index 00000000..17b18a6a --- /dev/null +++ b/x/btclightclient/types/signature.go @@ -0,0 +1,5 @@ +package types + +func (m *BitcoinSigningRequest) ValidateSignatures(sigs []string) bool { + return false +} diff --git a/x/btclightclient/types/tx.pb.go b/x/btclightclient/types/tx.pb.go index 8da3a195..5342e7f2 100644 --- a/x/btclightclient/types/tx.pb.go +++ b/x/btclightclient/types/tx.pb.go @@ -326,6 +326,195 @@ func (m *MsgUpdateSendersResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateSendersResponse proto.InternalMessageInfo +// MsgWithdrawBitcoinRequest defines the Msg/WithdrawBitcoin request type. +type MsgWithdrawBitcoinRequest struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + // withdraw amount in satoshi, etc: 100000000sat = 1btc + Amount string `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (m *MsgWithdrawBitcoinRequest) Reset() { *m = MsgWithdrawBitcoinRequest{} } +func (m *MsgWithdrawBitcoinRequest) String() string { return proto.CompactTextString(m) } +func (*MsgWithdrawBitcoinRequest) ProtoMessage() {} +func (*MsgWithdrawBitcoinRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4df07798138ba91c, []int{6} +} +func (m *MsgWithdrawBitcoinRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgWithdrawBitcoinRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgWithdrawBitcoinRequest.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 *MsgWithdrawBitcoinRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgWithdrawBitcoinRequest.Merge(m, src) +} +func (m *MsgWithdrawBitcoinRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgWithdrawBitcoinRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgWithdrawBitcoinRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgWithdrawBitcoinRequest proto.InternalMessageInfo + +func (m *MsgWithdrawBitcoinRequest) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgWithdrawBitcoinRequest) GetAmount() string { + if m != nil { + return m.Amount + } + return "" +} + +// MsgWithdrawBitcoinResponse defines the Msg/WithdrawBitcoin response type. +type MsgWithdrawBitcoinResponse struct { +} + +func (m *MsgWithdrawBitcoinResponse) Reset() { *m = MsgWithdrawBitcoinResponse{} } +func (m *MsgWithdrawBitcoinResponse) String() string { return proto.CompactTextString(m) } +func (*MsgWithdrawBitcoinResponse) ProtoMessage() {} +func (*MsgWithdrawBitcoinResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4df07798138ba91c, []int{7} +} +func (m *MsgWithdrawBitcoinResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgWithdrawBitcoinResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgWithdrawBitcoinResponse.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 *MsgWithdrawBitcoinResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgWithdrawBitcoinResponse.Merge(m, src) +} +func (m *MsgWithdrawBitcoinResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgWithdrawBitcoinResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgWithdrawBitcoinResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgWithdrawBitcoinResponse proto.InternalMessageInfo + +// MsgSubmitWithdrawSignaturesRequest defines the Msg/SubmitWithdrawSignatures request type. +type MsgSubmitWithdrawSignaturesRequest struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Txid string `protobuf:"bytes,2,opt,name=txid,proto3" json:"txid,omitempty"` + Signatures []string `protobuf:"bytes,3,rep,name=signatures,proto3" json:"signatures,omitempty"` +} + +func (m *MsgSubmitWithdrawSignaturesRequest) Reset() { *m = MsgSubmitWithdrawSignaturesRequest{} } +func (m *MsgSubmitWithdrawSignaturesRequest) String() string { return proto.CompactTextString(m) } +func (*MsgSubmitWithdrawSignaturesRequest) ProtoMessage() {} +func (*MsgSubmitWithdrawSignaturesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_4df07798138ba91c, []int{8} +} +func (m *MsgSubmitWithdrawSignaturesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSubmitWithdrawSignaturesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSubmitWithdrawSignaturesRequest.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 *MsgSubmitWithdrawSignaturesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSubmitWithdrawSignaturesRequest.Merge(m, src) +} +func (m *MsgSubmitWithdrawSignaturesRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgSubmitWithdrawSignaturesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSubmitWithdrawSignaturesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSubmitWithdrawSignaturesRequest proto.InternalMessageInfo + +func (m *MsgSubmitWithdrawSignaturesRequest) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgSubmitWithdrawSignaturesRequest) GetTxid() string { + if m != nil { + return m.Txid + } + return "" +} + +func (m *MsgSubmitWithdrawSignaturesRequest) GetSignatures() []string { + if m != nil { + return m.Signatures + } + return nil +} + +// MsgSubmitWithdrawSignaturesResponse defines the Msg/SubmitWithdrawSignatures response type. +type MsgSubmitWithdrawSignaturesResponse struct { +} + +func (m *MsgSubmitWithdrawSignaturesResponse) Reset() { *m = MsgSubmitWithdrawSignaturesResponse{} } +func (m *MsgSubmitWithdrawSignaturesResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSubmitWithdrawSignaturesResponse) ProtoMessage() {} +func (*MsgSubmitWithdrawSignaturesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4df07798138ba91c, []int{9} +} +func (m *MsgSubmitWithdrawSignaturesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSubmitWithdrawSignaturesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSubmitWithdrawSignaturesResponse.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 *MsgSubmitWithdrawSignaturesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSubmitWithdrawSignaturesResponse.Merge(m, src) +} +func (m *MsgSubmitWithdrawSignaturesResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSubmitWithdrawSignaturesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSubmitWithdrawSignaturesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSubmitWithdrawSignaturesResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgSubmitBlockHeaderRequest)(nil), "side.btclightclient.MsgSubmitBlockHeaderRequest") proto.RegisterType((*MsgSubmitBlockHeadersResponse)(nil), "side.btclightclient.MsgSubmitBlockHeadersResponse") @@ -333,40 +522,52 @@ func init() { proto.RegisterType((*MsgSubmitTransactionResponse)(nil), "side.btclightclient.MsgSubmitTransactionResponse") proto.RegisterType((*MsgUpdateSendersRequest)(nil), "side.btclightclient.MsgUpdateSendersRequest") proto.RegisterType((*MsgUpdateSendersResponse)(nil), "side.btclightclient.MsgUpdateSendersResponse") + proto.RegisterType((*MsgWithdrawBitcoinRequest)(nil), "side.btclightclient.MsgWithdrawBitcoinRequest") + proto.RegisterType((*MsgWithdrawBitcoinResponse)(nil), "side.btclightclient.MsgWithdrawBitcoinResponse") + proto.RegisterType((*MsgSubmitWithdrawSignaturesRequest)(nil), "side.btclightclient.MsgSubmitWithdrawSignaturesRequest") + proto.RegisterType((*MsgSubmitWithdrawSignaturesResponse)(nil), "side.btclightclient.MsgSubmitWithdrawSignaturesResponse") } func init() { proto.RegisterFile("side/btclightclient/tx.proto", fileDescriptor_4df07798138ba91c) } var fileDescriptor_4df07798138ba91c = []byte{ - // 435 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0xcd, 0xae, 0x93, 0x40, - 0x14, 0x2e, 0xc5, 0x7b, 0xaf, 0x9c, 0x6b, 0x17, 0x8e, 0x37, 0x8a, 0x58, 0x91, 0xb0, 0xea, 0x42, - 0x41, 0x7b, 0xdf, 0xa0, 0x89, 0x89, 0x89, 0x61, 0xc3, 0xad, 0x1b, 0x37, 0x0d, 0x3f, 0x23, 0x10, - 0x29, 0x83, 0x9c, 0xa9, 0xa1, 0xc6, 0x87, 0xf0, 0x31, 0x7c, 0x14, 0x97, 0x5d, 0xba, 0x34, 0xed, - 0xca, 0xb7, 0x30, 0x0c, 0xd8, 0x9f, 0x80, 0xb6, 0x77, 0x43, 0xe6, 0xcc, 0xf7, 0xcd, 0xf7, 0x7d, - 0x73, 0x0e, 0x03, 0x43, 0x4c, 0x42, 0x6a, 0xfb, 0x3c, 0x48, 0x93, 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- 0x14, 0xb7, 0x2e, 0x4c, 0x1d, 0x86, 0xdd, 0x49, 0x9b, 0xab, 0xbc, 0x85, 0x47, 0x0e, 0x46, 0xef, - 0xf2, 0xd0, 0xe3, 0xf4, 0x46, 0xa4, 0xc4, 0x63, 0xb7, 0x50, 0xe1, 0xa2, 0x5e, 0xd5, 0xfd, 0x55, - 0xdc, 0xbf, 0xa5, 0xa9, 0x81, 0xda, 0x16, 0xab, 0x8d, 0xc6, 0xbf, 0xfb, 0x20, 0x3b, 0x18, 0x91, - 0x2f, 0x40, 0xda, 0x9d, 0x25, 0x2f, 0x3b, 0x47, 0xf4, 0x9f, 0x7f, 0x40, 0x1b, 0x9f, 0x7c, 0x62, - 0x9b, 0x81, 0x94, 0x70, 0xbf, 0xd5, 0x89, 0x63, 0xd6, 0xed, 0xf1, 0x6a, 0xaf, 0x6e, 0x71, 0xa2, - 0x71, 0x4e, 0x61, 0x70, 0xd0, 0x16, 0xf2, 0xfc, 0x5f, 0x1a, 0x5d, 0xa3, 0xd0, 0x5e, 0x9c, 0xc8, - 0xae, 0xdd, 0x26, 0xce, 0x8f, 0xb5, 0x2e, 0xad, 0xd6, 0xba, 0xf4, 0x6b, 0xad, 0x4b, 0xdf, 0x36, - 0x7a, 0x6f, 0xb5, 0xd1, 0x7b, 0x3f, 0x37, 0x7a, 0xef, 0xfd, 0x75, 0x94, 0xf0, 0x78, 0xe1, 0x5b, - 0x01, 0x9b, 0xdb, 0x95, 0xa4, 0x78, 0x6e, 0x01, 0x4b, 0x45, 0x61, 0x97, 0xad, 0xd7, 0xbd, 0xcc, - 0x29, 0xfa, 0xe7, 0x82, 0x75, 0xfd, 0x27, 0x00, 0x00, 0xff, 0xff, 0xf1, 0xe7, 0x80, 0xd3, 0x01, - 0x04, 0x00, 0x00, + // 562 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0x4f, 0x6f, 0xd3,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9, 0x25, 0xf6, 0xdd, 0x45, 0xde, 0x9b, 0xfe, 0x65, 0x21, 0x9c, + 0x07, 0x70, 0xbf, 0x4c, 0x5d, 0xf4, 0x89, 0x48, 0x59, 0x22, 0x88, 0xf3, 0xd3, 0x58, 0xf0, 0x77, + 0xca, 0x71, 0x22, 0x70, 0x20, 0x29, 0x4b, 0x36, 0xf9, 0x6b, 0x42, 0x5d, 0x09, 0xc5, 0x58, 0xc4, + 0xe6, 0xae, 0x6a, 0x5d, 0x6e, 0x20, 0x07, 0x1a, 0x29, 0x27, 0x9f, 0x87, 0x32, 0x1b, 0xfa, 0x67, + 0x92, 0x08, 0xb3, 0xa2, 0x10, 0x07, 0xf9, 0xe6, 0x69, 0xd6, 0xcd, 0xb7, 0xd0, 0x31, 0xdc, 0x98, + 0xb7, 0xab, 0xaa, 0xbd, 0x2f, 0x75, 0xeb, 0x10, 0xf6, 0x52, 0xce, 0xd8, 0x07, 0x73, 0xaf, 0x55, + 0x69, 0xd7, 0xfb, 0x45, 0xe1, 0xd8, 0xd0, 0x2c, 0x77, 0xaa, 0x47, 0x79, 0x03, 0x77, 0x7b, 0x22, + 0x7a, 0x9b, 0x86, 0x58, 0x92, 0x81, 0x72, 0x29, 0x36, 0x4d, 0x61, 0xc2, 0x7e, 0xb1, 0x2a, 0xee, + 0xb7, 0xde, 0xbf, 0x28, 0x1d, 0x0b, 0xcc, 0x65, 0xb2, 0xb9, 0xd0, 0x71, 0x4f, 0x44, 0xef, 0xa8, + 0x8c, 0x43, 0x8e, 0xbf, 0x74, 0x8b, 0xbf, 0x7b, 0x93, 0xd4, 0x11, 0xd4, 0xf0, 0x98, 0x4d, 0x12, + 0xa9, 0x6f, 0x4b, 0x57, 0x4e, 0x13, 0xac, 0x32, 0x32, 0x2d, 0x95, 0x82, 0x33, 0x9f, 0xf9, 0x02, + 0x33, 0xa0, 0x51, 0x82, 0xe5, 0x84, 0x93, 0x8d, 0xe3, 0x21, 0xa8, 0xca, 0x8c, 0x86,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Reference imports to suppress errors if they are not otherwise used. @@ -387,6 +588,10 @@ type MsgClient interface { SubmitTransaction(ctx context.Context, in *MsgSubmitTransactionRequest, opts ...grpc.CallOption) (*MsgSubmitTransactionResponse, error) // UpdateSenders updates the senders of the side chain. UpdateSenders(ctx context.Context, in *MsgUpdateSendersRequest, opts ...grpc.CallOption) (*MsgUpdateSendersResponse, error) + // WithdrawBitcoin withdraws the bitcoin from the side chain. + WithdrawBitcoin(ctx context.Context, in *MsgWithdrawBitcoinRequest, opts ...grpc.CallOption) (*MsgWithdrawBitcoinResponse, error) + // SubmitWithdrawSignatures submits the signatures of the withdraw transaction. + SubmitWithdrawSignatures(ctx context.Context, in *MsgSubmitWithdrawSignaturesRequest, opts ...grpc.CallOption) (*MsgSubmitWithdrawSignaturesResponse, error) } type msgClient struct { @@ -424,6 +629,24 @@ func (c *msgClient) UpdateSenders(ctx context.Context, in *MsgUpdateSendersReque return out, nil } +func (c *msgClient) WithdrawBitcoin(ctx context.Context, in *MsgWithdrawBitcoinRequest, opts ...grpc.CallOption) (*MsgWithdrawBitcoinResponse, error) { + out := new(MsgWithdrawBitcoinResponse) + err := c.cc.Invoke(ctx, "/side.btclightclient.Msg/WithdrawBitcoin", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) SubmitWithdrawSignatures(ctx context.Context, in *MsgSubmitWithdrawSignaturesRequest, opts ...grpc.CallOption) (*MsgSubmitWithdrawSignaturesResponse, error) { + out := new(MsgSubmitWithdrawSignaturesResponse) + err := c.cc.Invoke(ctx, "/side.btclightclient.Msg/SubmitWithdrawSignatures", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // SubmitBlockHeaders submits bitcoin block headers to the side chain. @@ -432,6 +655,10 @@ type MsgServer interface { SubmitTransaction(context.Context, *MsgSubmitTransactionRequest) (*MsgSubmitTransactionResponse, error) // UpdateSenders updates the senders of the side chain. UpdateSenders(context.Context, *MsgUpdateSendersRequest) (*MsgUpdateSendersResponse, error) + // WithdrawBitcoin withdraws the bitcoin from the side chain. + WithdrawBitcoin(context.Context, *MsgWithdrawBitcoinRequest) (*MsgWithdrawBitcoinResponse, error) + // SubmitWithdrawSignatures submits the signatures of the withdraw transaction. + SubmitWithdrawSignatures(context.Context, *MsgSubmitWithdrawSignaturesRequest) (*MsgSubmitWithdrawSignaturesResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -447,6 +674,12 @@ func (*UnimplementedMsgServer) SubmitTransaction(ctx context.Context, req *MsgSu func (*UnimplementedMsgServer) UpdateSenders(ctx context.Context, req *MsgUpdateSendersRequest) (*MsgUpdateSendersResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateSenders not implemented") } +func (*UnimplementedMsgServer) WithdrawBitcoin(ctx context.Context, req *MsgWithdrawBitcoinRequest) (*MsgWithdrawBitcoinResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method WithdrawBitcoin not implemented") +} +func (*UnimplementedMsgServer) SubmitWithdrawSignatures(ctx context.Context, req *MsgSubmitWithdrawSignaturesRequest) (*MsgSubmitWithdrawSignaturesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SubmitWithdrawSignatures not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -506,6 +739,42 @@ func _Msg_UpdateSenders_Handler(srv interface{}, ctx context.Context, dec func(i return interceptor(ctx, in, info, handler) } +func _Msg_WithdrawBitcoin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgWithdrawBitcoinRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).WithdrawBitcoin(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/side.btclightclient.Msg/WithdrawBitcoin", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).WithdrawBitcoin(ctx, req.(*MsgWithdrawBitcoinRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_SubmitWithdrawSignatures_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSubmitWithdrawSignaturesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SubmitWithdrawSignatures(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/side.btclightclient.Msg/SubmitWithdrawSignatures", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SubmitWithdrawSignatures(ctx, req.(*MsgSubmitWithdrawSignaturesRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "side.btclightclient.Msg", HandlerType: (*MsgServer)(nil), @@ -522,6 +791,14 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "UpdateSenders", Handler: _Msg_UpdateSenders_Handler, }, + { + MethodName: "WithdrawBitcoin", + Handler: _Msg_WithdrawBitcoin_Handler, + }, + { + MethodName: "SubmitWithdrawSignatures", + Handler: _Msg_SubmitWithdrawSignatures_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "side/btclightclient/tx.proto", @@ -739,64 +1016,193 @@ func (m *MsgUpdateSendersResponse) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } -func encodeVarintTx(dAtA []byte, offset int, v uint64) int { - offset -= sovTx(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +func (m *MsgWithdrawBitcoinRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil } -func (m *MsgSubmitBlockHeaderRequest) Size() (n int) { - if m == nil { - return 0 - } + +func (m *MsgWithdrawBitcoinRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgWithdrawBitcoinRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovTx(uint64(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] = 0x12 } - if len(m.BlockHeaders) > 0 { - for _, e := range m.BlockHeaders { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa } - return n + return len(dAtA) - i, nil } -func (m *MsgSubmitBlockHeadersResponse) Size() (n int) { - if m == nil { - return 0 +func (m *MsgWithdrawBitcoinResponse) 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 *MsgWithdrawBitcoinResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgWithdrawBitcoinResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - return n + return len(dAtA) - i, nil } -func (m *MsgSubmitTransactionRequest) Size() (n int) { - if m == nil { - return 0 +func (m *MsgSubmitWithdrawSignaturesRequest) 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 *MsgSubmitWithdrawSignaturesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSubmitWithdrawSignaturesRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if len(m.Signatures) > 0 { + for iNdEx := len(m.Signatures) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Signatures[iNdEx]) + copy(dAtA[i:], m.Signatures[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Signatures[iNdEx]))) + i-- + dAtA[i] = 0x1a + } } - l = len(m.Blockhash) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if len(m.Txid) > 0 { + i -= len(m.Txid) + copy(dAtA[i:], m.Txid) + i = encodeVarintTx(dAtA, i, uint64(len(m.Txid))) + i-- + dAtA[i] = 0x12 } - l = len(m.PrevTxBytes) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa } - l = len(m.TxBytes) + return len(dAtA) - i, nil +} + +func (m *MsgSubmitWithdrawSignaturesResponse) 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 *MsgSubmitWithdrawSignaturesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSubmitWithdrawSignaturesResponse) 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 + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgSubmitBlockHeaderRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.BlockHeaders) > 0 { + for _, e := range m.BlockHeaders { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgSubmitBlockHeadersResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgSubmitTransactionRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Blockhash) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.PrevTxBytes) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.TxBytes) if l > 0 { n += 1 + l + sovTx(uint64(l)) } @@ -846,6 +1252,64 @@ func (m *MsgUpdateSendersResponse) Size() (n int) { return n } +func (m *MsgWithdrawBitcoinRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + 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 *MsgWithdrawBitcoinResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgSubmitWithdrawSignaturesRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Txid) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Signatures) > 0 { + for _, s := range m.Signatures { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgSubmitWithdrawSignaturesResponse) 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 } @@ -862,28 +1326,258 @@ func (m *MsgSubmitBlockHeaderRequest) Unmarshal(dAtA []byte) error { if shift >= 64 { return ErrIntOverflowTx } - if iNdEx >= l { + 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: MsgSubmitBlockHeaderRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSubmitBlockHeaderRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field BlockHeaders", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.BlockHeaders = append(m.BlockHeaders, &BlockHeader{}) + if err := m.BlockHeaders[len(m.BlockHeaders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + 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 *MsgSubmitBlockHeadersResponse) 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: MsgSubmitBlockHeadersResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSubmitBlockHeadersResponse: 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 (m *MsgSubmitTransactionRequest) 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: MsgSubmitTransactionRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSubmitTransactionRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Blockhash", 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 } - 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: MsgSubmitBlockHeaderRequest: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSubmitBlockHeaderRequest: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + m.Blockhash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field PrevTxBytes", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -911,13 +1605,13 @@ func (m *MsgSubmitBlockHeaderRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Sender = string(dAtA[iNdEx:postIndex]) + m.PrevTxBytes = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 2: + case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BlockHeaders", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TxBytes", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -927,25 +1621,55 @@ func (m *MsgSubmitBlockHeaderRequest) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - m.BlockHeaders = append(m.BlockHeaders, &BlockHeader{}) - if err := m.BlockHeaders[len(m.BlockHeaders)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err + m.TxBytes = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", 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.Proof = append(m.Proof, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex default: iNdEx = preIndex @@ -968,7 +1692,7 @@ func (m *MsgSubmitBlockHeaderRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgSubmitBlockHeadersResponse) Unmarshal(dAtA []byte) error { +func (m *MsgSubmitTransactionResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -991,10 +1715,10 @@ func (m *MsgSubmitBlockHeadersResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgSubmitBlockHeadersResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgSubmitTransactionResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSubmitBlockHeadersResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgSubmitTransactionResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -1018,7 +1742,7 @@ func (m *MsgSubmitBlockHeadersResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgSubmitTransactionRequest) Unmarshal(dAtA []byte) error { +func (m *MsgUpdateSendersRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1041,10 +1765,10 @@ func (m *MsgSubmitTransactionRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgSubmitTransactionRequest: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdateSendersRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSubmitTransactionRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdateSendersRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1081,7 +1805,7 @@ func (m *MsgSubmitTransactionRequest) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Blockhash", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Senders", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1109,43 +1833,111 @@ func (m *MsgSubmitTransactionRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Blockhash = string(dAtA[iNdEx:postIndex]) + m.Senders = append(m.Senders, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PrevTxBytes", 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 - } + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err } - intStringLen := int(stringLen) - if intStringLen < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen - if postIndex < 0 { + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateSendersResponse) 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: MsgUpdateSendersResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateSendersResponse: 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 postIndex > l { + if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF } - m.PrevTxBytes = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgWithdrawBitcoinRequest) 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: MsgWithdrawBitcoinRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgWithdrawBitcoinRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TxBytes", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1173,11 +1965,11 @@ func (m *MsgSubmitTransactionRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.TxBytes = string(dAtA[iNdEx:postIndex]) + m.Sender = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 5: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Proof", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1205,7 +1997,7 @@ func (m *MsgSubmitTransactionRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Proof = append(m.Proof, string(dAtA[iNdEx:postIndex])) + m.Amount = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -1228,7 +2020,7 @@ func (m *MsgSubmitTransactionRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgSubmitTransactionResponse) Unmarshal(dAtA []byte) error { +func (m *MsgWithdrawBitcoinResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1251,10 +2043,10 @@ func (m *MsgSubmitTransactionResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgSubmitTransactionResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgWithdrawBitcoinResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSubmitTransactionResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgWithdrawBitcoinResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -1278,7 +2070,7 @@ func (m *MsgSubmitTransactionResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateSendersRequest) Unmarshal(dAtA []byte) error { +func (m *MsgSubmitWithdrawSignaturesRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1301,10 +2093,10 @@ func (m *MsgUpdateSendersRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateSendersRequest: wiretype end group for non-group") + return fmt.Errorf("proto: MsgSubmitWithdrawSignaturesRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateSendersRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgSubmitWithdrawSignaturesRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1341,7 +2133,7 @@ func (m *MsgUpdateSendersRequest) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Senders", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Txid", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1369,7 +2161,39 @@ func (m *MsgUpdateSendersRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Senders = append(m.Senders, string(dAtA[iNdEx:postIndex])) + m.Txid = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signatures", 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.Signatures = append(m.Signatures, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex default: iNdEx = preIndex @@ -1392,7 +2216,7 @@ func (m *MsgUpdateSendersRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateSendersResponse) Unmarshal(dAtA []byte) error { +func (m *MsgSubmitWithdrawSignaturesResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1415,10 +2239,10 @@ func (m *MsgUpdateSendersResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateSendersResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgSubmitWithdrawSignaturesResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateSendersResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgSubmitWithdrawSignaturesResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: From 40c0f4fa6f80c3e43eadf86ef4d11b05bbb0baac Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Wed, 29 May 2024 09:55:47 +0800 Subject: [PATCH 15/71] remove unfinished code --- x/btclightclient/keeper/msg_server.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x/btclightclient/keeper/msg_server.go b/x/btclightclient/keeper/msg_server.go index 39e97a7f..acc49f3c 100644 --- a/x/btclightclient/keeper/msg_server.go +++ b/x/btclightclient/keeper/msg_server.go @@ -111,6 +111,8 @@ func (m msgServer) WithdrawBitcoin(goCtx context.Context, msg *types.MsgWithdraw m.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, types.ModuleName, sdk.NewCoins(coin)) + //request := types.BitcoinSigningRequest(sender, coin) + // Emit events m.EmitEvent(ctx, msg.Sender, sdk.NewAttribute("withdraw", msg.Amount), From d28422cd0cb9ed1e374e4ddcd86b941b0cbda54b Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Sat, 8 Jun 2024 21:35:54 +0800 Subject: [PATCH 16/71] add utxo --- proto/side/btclightclient/bitcoin.proto | 22 +- x/btclightclient/keeper/keeper.go | 24 +- x/btclightclient/keeper/keeper_withdraw.go | 32 +- x/btclightclient/keeper/utxo.go | 29 + x/btclightclient/types/bitcoin.pb.go | 608 +++++++++++++++++++-- x/btclightclient/types/keys.go | 9 +- 6 files changed, 666 insertions(+), 58 deletions(-) create mode 100644 x/btclightclient/keeper/utxo.go diff --git a/proto/side/btclightclient/bitcoin.proto b/proto/side/btclightclient/bitcoin.proto index 9a532863..9c38d152 100644 --- a/proto/side/btclightclient/bitcoin.proto +++ b/proto/side/btclightclient/bitcoin.proto @@ -37,11 +37,25 @@ enum SigningStatus { // Bitcoin Signing Request message BitcoinSigningRequest { string address = 1; - string tx_bytes = 2; - SigningStatus status = 3; - uint64 sequence = 4; + string txid = 2; + string tx_bytes = 3; + SigningStatus status = 4; + uint64 sequence = 5; // The vault address that the request is associated with - string vault_address = 5; + string vault_address = 6; +} + +// Bitcoin UTXO +message UTXO { + string txid = 1; + uint64 vout = 2; + string address = 3; + uint64 amount = 4; + // height is used for calculating confirmations + uint64 height = 5; + bytes pub_key_script = 6; + bool is_coinbase = 7; + bool is_locked = 8; } diff --git a/x/btclightclient/keeper/keeper.go b/x/btclightclient/keeper/keeper.go index 2581c3c2..03f6e128 100644 --- a/x/btclightclient/keeper/keeper.go +++ b/x/btclightclient/keeper/keeper.go @@ -238,7 +238,7 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg return types.ErrTransactionNotIncluded } - for _, out := range uTx.MsgTx().TxOut { + for i, out := range uTx.MsgTx().TxOut { // check if the output is a valid address pks, err := txscript.ParsePkScript(out.PkScript) if err != nil { @@ -261,7 +261,21 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg k.bankKeeper.MintCoins(ctx, types.ModuleName, coins) k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, senderAddr, coins) - ctx.Logger().Info("Voucher token minted", "address", senderAddr.String(), "amount", coins.String()) + utxo := types.UTXO{ + Txid: uTx.Hash().String(), + Vout: uint64(i), + Amount: uint64(out.Value), + PubKeyScript: out.PkScript, + Height: header.Height, + Address: addr.EncodeAddress(), + IsCoinbase: false, + IsLocked: false, + } + + println("save utxo", utxo.Txid, utxo.Vout) + + ctx.Logger().Info("Minted Bitcoin Voucher", "index", i, "address", addr.EncodeAddress(), "amount", out.Value, "sender", sender.EncodeAddress(), "senderAddr", senderAddr.String(), "coins", coins.String()) + } } @@ -269,6 +283,12 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg return nil } +func (k Keeper) SetUtxo(ctx sdk.Context, utxo types.UTXO) { + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(&utxo) + store.Set(types.BtcUtxoKey(utxo.Txid, utxo.Vout), bz) +} + func (k Keeper) GetBlockHeader(ctx sdk.Context, hash string) *types.BlockHeader { store := ctx.KVStore(k.storeKey) var blockHeader types.BlockHeader diff --git a/x/btclightclient/keeper/keeper_withdraw.go b/x/btclightclient/keeper/keeper_withdraw.go index ad515900..eaa3ff88 100644 --- a/x/btclightclient/keeper/keeper_withdraw.go +++ b/x/btclightclient/keeper/keeper_withdraw.go @@ -24,13 +24,29 @@ func (k Keeper) IncrementRequestSequence(ctx sdk.Context) uint64 { } // New signing request -func (k Keeper) NewSigningRequest(ctx sdk.Context, sender string, txBytes string) *types.BitcoinSigningRequest { +// sender: the address of the sender +// txBytes: the transaction bytes +// vault: the address of the vault, default is empty. +// If empty, the vault will be Bitcoin vault, otherwise it will be Ordinals or Runes vault +func (k Keeper) NewSigningRequest(ctx sdk.Context, sender string, coin sdk.Coin, vault string) *types.BitcoinSigningRequest { + + // create a new bitcoin transaction + // tx := wire.NewMsgTx(wire.TxVersion) + + // outScript, err := txscript.PayToAddrScript(sender) + signingRequest := &types.BitcoinSigningRequest{ - Address: sender, - TxBytes: txBytes, - Status: types.SigningStatus_SIGNING_STATUS_CREATED, - Sequence: k.IncrementRequestSequence(ctx), + Address: sender, + TxBytes: "", + Status: types.SigningStatus_SIGNING_STATUS_CREATED, + Sequence: k.IncrementRequestSequence(ctx), + VaultAddress: vault, } + + store := ctx.KVStore(k.storeKey) + bz := k.cdc.MustMarshal(signingRequest) + store.Set(types.BtcSigningRequestKey(signingRequest.Sequence), bz) + return signingRequest } @@ -38,7 +54,8 @@ func (k Keeper) NewSigningRequest(ctx sdk.Context, sender string, txBytes string func (k Keeper) GetSigningRequest(ctx sdk.Context, hash string) *types.BitcoinSigningRequest { store := ctx.KVStore(k.storeKey) var signingRequest types.BitcoinSigningRequest - bz := store.Get(types.BtcBlockHeaderHashKey(hash)) + // TODO replace the key with the hash + bz := store.Get(types.BtcSigningRequestKey(1)) k.cdc.MustUnmarshal(bz, &signingRequest) return &signingRequest } @@ -47,7 +64,8 @@ func (k Keeper) GetSigningRequest(ctx sdk.Context, hash string) *types.BitcoinSi func (k Keeper) SetSigningRequest(ctx sdk.Context, txHash string, signingRequest *types.BitcoinSigningRequest) { store := ctx.KVStore(k.storeKey) bz := k.cdc.MustMarshal(signingRequest) - store.Set(types.BtcSigningRequestKey(txHash), bz) + // TODO replace the key with the hash + store.Set(types.BtcSigningRequestKey(1), bz) } // IterateSigningRequests iterates through all signing requests diff --git a/x/btclightclient/keeper/utxo.go b/x/btclightclient/keeper/utxo.go new file mode 100644 index 00000000..93cc78f3 --- /dev/null +++ b/x/btclightclient/keeper/utxo.go @@ -0,0 +1,29 @@ +package keeper + +import ( + "cosmossdk.io/collections" + "cosmossdk.io/math" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type UTXOViewKeeper interface { +} + +type UTXOKeeper interface { + UTXOViewKeeper +} + +var _ UTXOKeeper = (*BaseUTXOKeeper)(nil) + +type BaseUTXOViewKeeper struct { + UTXOs *collections.IndexedMap[collections.Pair[sdk.AccAddress, string], math.Int, BalancesIndexes] +} + +func NewBaseUTXOViewKeeper() *BaseUTXOViewKeeper { + return &BaseUTXOViewKeeper{ + UTXOs: &collections.NewIndexedMap(sb, types.BalancesPrefix, "utxos", collections.PairKeyCodec(sdk.AccAddressKey, collections.StringKey), types.BalanceValueCodec, newBalancesIndexes(sb)), + } +} + +type BaseUTXOKeeper struct { +} diff --git a/x/btclightclient/types/bitcoin.pb.go b/x/btclightclient/types/bitcoin.pb.go index fd19d1da..247eceab 100644 --- a/x/btclightclient/types/bitcoin.pb.go +++ b/x/btclightclient/types/bitcoin.pb.go @@ -179,11 +179,12 @@ func (m *BlockHeader) GetNtx() uint64 { // Bitcoin Signing Request type BitcoinSigningRequest struct { Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` - TxBytes string `protobuf:"bytes,2,opt,name=tx_bytes,json=txBytes,proto3" json:"tx_bytes,omitempty"` - Status SigningStatus `protobuf:"varint,3,opt,name=status,proto3,enum=side.btclightclient.SigningStatus" json:"status,omitempty"` - Sequence uint64 `protobuf:"varint,4,opt,name=sequence,proto3" json:"sequence,omitempty"` + Txid string `protobuf:"bytes,2,opt,name=txid,proto3" json:"txid,omitempty"` + TxBytes string `protobuf:"bytes,3,opt,name=tx_bytes,json=txBytes,proto3" json:"tx_bytes,omitempty"` + Status SigningStatus `protobuf:"varint,4,opt,name=status,proto3,enum=side.btclightclient.SigningStatus" json:"status,omitempty"` + Sequence uint64 `protobuf:"varint,5,opt,name=sequence,proto3" json:"sequence,omitempty"` // The vault address that the request is associated with - VaultAddress string `protobuf:"bytes,5,opt,name=vault_address,json=vaultAddress,proto3" json:"vault_address,omitempty"` + VaultAddress string `protobuf:"bytes,6,opt,name=vault_address,json=vaultAddress,proto3" json:"vault_address,omitempty"` } func (m *BitcoinSigningRequest) Reset() { *m = BitcoinSigningRequest{} } @@ -226,6 +227,13 @@ func (m *BitcoinSigningRequest) GetAddress() string { return "" } +func (m *BitcoinSigningRequest) GetTxid() string { + if m != nil { + return m.Txid + } + return "" +} + func (m *BitcoinSigningRequest) GetTxBytes() string { if m != nil { return m.TxBytes @@ -254,48 +262,159 @@ func (m *BitcoinSigningRequest) GetVaultAddress() string { return "" } +// Bitcoin UTXO +type UTXO struct { + Txid string `protobuf:"bytes,1,opt,name=txid,proto3" json:"txid,omitempty"` + Vout uint64 `protobuf:"varint,2,opt,name=vout,proto3" json:"vout,omitempty"` + Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"` + Amount uint64 `protobuf:"varint,4,opt,name=amount,proto3" json:"amount,omitempty"` + // height is used for calculating confirmations + Height uint64 `protobuf:"varint,5,opt,name=height,proto3" json:"height,omitempty"` + PubKeyScript []byte `protobuf:"bytes,6,opt,name=pub_key_script,json=pubKeyScript,proto3" json:"pub_key_script,omitempty"` + IsCoinbase bool `protobuf:"varint,7,opt,name=is_coinbase,json=isCoinbase,proto3" json:"is_coinbase,omitempty"` + IsLocked bool `protobuf:"varint,8,opt,name=is_locked,json=isLocked,proto3" json:"is_locked,omitempty"` +} + +func (m *UTXO) Reset() { *m = UTXO{} } +func (m *UTXO) String() string { return proto.CompactTextString(m) } +func (*UTXO) ProtoMessage() {} +func (*UTXO) Descriptor() ([]byte, []int) { + return fileDescriptor_d7dee3af17ecec77, []int{2} +} +func (m *UTXO) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *UTXO) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_UTXO.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 *UTXO) XXX_Merge(src proto.Message) { + xxx_messageInfo_UTXO.Merge(m, src) +} +func (m *UTXO) XXX_Size() int { + return m.Size() +} +func (m *UTXO) XXX_DiscardUnknown() { + xxx_messageInfo_UTXO.DiscardUnknown(m) +} + +var xxx_messageInfo_UTXO proto.InternalMessageInfo + +func (m *UTXO) GetTxid() string { + if m != nil { + return m.Txid + } + return "" +} + +func (m *UTXO) GetVout() uint64 { + if m != nil { + return m.Vout + } + return 0 +} + +func (m *UTXO) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *UTXO) GetAmount() uint64 { + if m != nil { + return m.Amount + } + return 0 +} + +func (m *UTXO) GetHeight() uint64 { + if m != nil { + return m.Height + } + return 0 +} + +func (m *UTXO) GetPubKeyScript() []byte { + if m != nil { + return m.PubKeyScript + } + return nil +} + +func (m *UTXO) GetIsCoinbase() bool { + if m != nil { + return m.IsCoinbase + } + return false +} + +func (m *UTXO) GetIsLocked() bool { + if m != nil { + return m.IsLocked + } + return false +} + func init() { proto.RegisterEnum("side.btclightclient.SigningStatus", SigningStatus_name, SigningStatus_value) proto.RegisterType((*BlockHeader)(nil), "side.btclightclient.BlockHeader") proto.RegisterType((*BitcoinSigningRequest)(nil), "side.btclightclient.BitcoinSigningRequest") + proto.RegisterType((*UTXO)(nil), "side.btclightclient.UTXO") } func init() { proto.RegisterFile("side/btclightclient/bitcoin.proto", fileDescriptor_d7dee3af17ecec77) } var fileDescriptor_d7dee3af17ecec77 = []byte{ - // 508 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x53, 0xcb, 0x6e, 0xd3, 0x40, - 0x14, 0xcd, 0x34, 0xef, 0x5b, 0x8a, 0xc2, 0xf4, 0xc1, 0x34, 0x20, 0x53, 0xc2, 0xa6, 0x62, 0xe1, - 0x48, 0x74, 0xc7, 0x2e, 0x0f, 0xb7, 0x04, 0xa9, 0x29, 0x1a, 0xa7, 0x1b, 0x36, 0x56, 0xec, 0x8c, - 0xec, 0x51, 0x1d, 0x4f, 0xf0, 0x8c, 0xa3, 0xf4, 0x2f, 0xf8, 0x25, 0x76, 0xb0, 0xeb, 0x92, 0x25, - 0x4a, 0x7e, 0x81, 0x0f, 0x40, 0x33, 0x4e, 0x90, 0x6a, 0x75, 0x13, 0xdd, 0x73, 0xef, 0xb9, 0xe7, - 0xdc, 0x1c, 0xdb, 0xf0, 0x56, 0xf2, 0x19, 0xeb, 0xfa, 0x2a, 0x88, 0x79, 0x18, 0xe9, 0x5f, 0x96, - 0xa8, 0xae, 0xcf, 0x55, 0x20, 0x78, 0x62, 0x2f, 0x52, 0xa1, 0x04, 0x3e, 0xd4, 0x14, 0xfb, 0x31, - 0xa5, 0x7d, 0x14, 0x8a, 0x50, 0x98, 0x79, 0x57, 0x57, 0x39, 0xb5, 0xf3, 0x17, 0xc1, 0x7e, 0x3f, - 0x16, 0xc1, 0xdd, 0x27, 0x36, 0x9d, 0xb1, 0x14, 0x13, 0xa8, 0x2f, 0x59, 0x2a, 0xb9, 0x48, 0x08, - 0x3a, 0x43, 0xe7, 0x15, 0xba, 0x83, 0x18, 0x43, 0x25, 0x9a, 0xca, 0x88, 0xec, 0x9d, 0xa1, 0xf3, - 0x26, 0x35, 0x35, 0x3e, 0x81, 0x5a, 0xc4, 0xb4, 0x07, 0x29, 0x1b, 0xf2, 0x16, 0x61, 0x1b, 0x0e, - 0x17, 0x29, 0x5b, 0x72, 0x91, 0x49, 0xcf, 0xd7, 0xea, 0x9e, 0x59, 0xad, 0x98, 0xd5, 0x17, 0xbb, - 0x51, 0xee, 0xab, 0x75, 0xde, 0xc0, 0xfe, 0x9c, 0xa5, 0x77, 0x31, 0xf3, 0x52, 0x21, 0x14, 0xa9, - 0x1a, 0x1e, 0xe4, 0x2d, 0x2a, 0x84, 0xc2, 0x47, 0x50, 0x4d, 0x44, 0x12, 0x30, 0x52, 0x33, 0x3e, - 0x39, 0xd0, 0x27, 0xf9, 0x5c, 0x49, 0x52, 0xcf, 0x4f, 0xd2, 0xb5, 0xee, 0x29, 0x3e, 0x67, 0xa4, - 0x61, 0x88, 0xa6, 0xc6, 0x2d, 0x28, 0x27, 0x6a, 0x45, 0x9a, 0xa6, 0xa5, 0xcb, 0xce, 0x2f, 0x04, - 0xc7, 0xfd, 0x3c, 0x33, 0x97, 0x87, 0x09, 0x4f, 0x42, 0xca, 0xbe, 0x65, 0x4c, 0x2a, 0x1d, 0xc0, - 0x74, 0x36, 0x4b, 0x99, 0x94, 0x26, 0x80, 0x26, 0xdd, 0x41, 0x7c, 0x0a, 0x0d, 0xb5,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0x84, 0x5c, 0x45, 0x99, 0x6f, 0x07, 0x62, 0xde, 0xd5, 0xa1, 0x9a, 0xd7, 0x36, 0x10, - 0xb1, 0x01, 0xdd, 0x55, 0xf1, 0x43, 0x50, 0xf7, 0x0b, 0x26, 0xfd, 0x9a, 0x61, 0x5d, 0xfc, 0x0b, - 0x00, 0x00, 0xff, 0xff, 0x2c, 0x90, 0x12, 0x79, 0x2c, 0x03, 0x00, 0x00, + // 627 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x53, 0x4d, 0x6f, 0xda, 0x4c, + 0x10, 0xc6, 0xc1, 0x10, 0x98, 0x7c, 0x88, 0x77, 0xf3, 0xf1, 0x3a, 0xa4, 0x72, 0x53, 0xda, 0x43, + 0xd4, 0x03, 0x48, 0xcd, 0xad, 0x37, 0x3e, 0x9c, 0x94, 0xb6, 0x21, 0xd5, 0x9a, 0x48, 0x55, 0x2f, + 0x96, 0x6d, 0x56, 0xb0, 0x0a, 0x78, 0x5d, 0xef, 0x1a, 0xc1, 0xbf, 0xe8, 0x5f, 0xea, 0xad, 0xc7, + 0x1c, 0x7b, 0x68, 0xa5, 0x2a, 0xf9, 0x0b, 0xfd, 0x01, 0xd5, 0x8e, 0x21, 0x0a, 0x28, 0x17, 0x6b, + 0x9e, 0x99, 0x67, 0x66, 0x9e, 0x99, 0xf1, 0xc2, 0x0b, 0xc9, 0x07, 0xac, 0x11, 0xa8, 0x70, 0xcc, + 0x87, 0x23, 0xfd, 0x65, 0x91, 0x6a, 0x04, 0x5c, 0x85, 0x82, 0x47, 0xf5, 0x38, 0x11, 0x4a, 0x90, + 0x3d, 0x4d, 0xa9, 0xaf, 0x52, 0xaa, 0xfb, 0x43, 0x31, 0x14, 0x18, 0x6f, 0x68, 0x2b, 0xa3, 0xd6, + 0xfe, 0x1a, 0xb0, 0xd5, 0x1a, 0x8b, 0xf0, 0xe6, 0x1d, 0xf3, 0x07, 0x2c, 0x21, 0x16, 0x6c, 0x4e, + 0x59, 0x22, 0xb9, 0x88, 0x2c, 0xe3, 0xc4, 0x38, 0x35, 0xe9, 0x12, 0x12, 0x02, 0xe6, 0xc8, 0x97, + 0x23, 0x6b, 0xe3, 0xc4, 0x38, 0x2d, 0x53, 0xb4, 0xc9, 0x21, 0x14, 0x47, 0x4c, 0xf7, 0xb0, 0xf2, + 0x48, 0x5e, 0x20, 0x52, 0x87, 0xbd, 0x38, 0x61, 0x53, 0x2e, 0x52, 0xe9, 0x05, 0xba, 0xba, 0x87, + 0xa9, 0x26, 0xa6, 0xfe, 0xb7, 0x0c, 0x65, 0x7d, 0x75, 0x9d, 0xe7, 0xb0, 0x35, 0x61, 0xc9, 0xcd, + 0x98, 0x79, 0x89, 0x10, 0xca, 0x2a, 0x20, 0x0f, 0x32, 0x17, 0x15, 0x42, 0x91, 0x7d, 0x28, 0x44, + 0x22, 0x0a, 0x99, 0x55, 0xc4, 0x3e, 0x19, 0xd0, 0x92, 0x02, 0xae, 0xa4, 0xb5, 0x99, 0x49, 0xd2, + 0xb6, 0xf6, 0x29, 0x3e, 0x61, 0x56, 0x09, 0x89, 0x68, 0x93, 0x0a, 0xe4, 0x23, 0x35, 0xb3, 0xca, + 0xe8, 0xd2, 0x66, 0xed, 0xb7, 0x01, 0x07, 0xad, 0x6c, 0x67, 0x2e, 0x1f, 0x46, 0x3c, 0x1a, 0x52, + 0xf6, 0x35, 0x65, 0x52, 0xe9, 0x05, 0xf8, 0x83, 0x41, 0xc2, 0xa4, 0xc4, 0x05, 0x94, 0xe9, 0x12, + 0x62, 0xe5, 0x19, 0x1f, 0x2c, 0x17, 0xa0, 0x6d, 0x72, 0x04, 0x25, 0x35, 0xf3, 0x82, 0xb9, 0x62, + 0x12, 0x57, 0x50, 0xa6, 0x9b, 0x6a, 0xd6, 0xd2, 0x90, 0xbc, 0x85, 0xa2, 0x54, 0xbe, 0x4a, 0x25, + 0x8e, 0xbd, 0xfb,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xae, 0xc5, 0xdb, 0xd4, 0x69, 0xf6, 0x9d, 0x4e, 0xc5, + 0x20, 0x47, 0x70, 0xb0, 0x16, 0xd3, 0xd0, 0xe9, 0x54, 0x36, 0x9e, 0x28, 0xdb, 0xa2, 0x57, 0xcd, + 0x4e, 0xbb, 0xe9, 0xea, 0xd4, 0x3c, 0x79, 0x06, 0xd6, 0x7a, 0xd9, 0xab, 0xde, 0x79, 0x97, 0x5e, + 0x3a, 0x9d, 0x8a, 0x49, 0x8e, 0xe1, 0xff, 0xb5, 0x28, 0x75, 0xde, 0x3b, 0x6d, 0x9d, 0x5a, 0x68, + 0x5d, 0xfe, 0xb8, 0xb3, 0x8d, 0xdb, 0x3b, 0xdb, 0xf8, 0x73, 0x67, 0x1b, 0xdf, 0xee, 0xed, 0xdc, + 0xed, 0xbd, 0x9d, 0xfb, 0x79, 0x6f, 0xe7, 0xbe, 0x9c, 0x0d, 0xb9, 0x1a, 0xa5, 0x41, 0x3d, 0x14, + 0x93, 0x86, 0xfe, 0x67, 0xf0, 0xa5, 0x86, 0x62, 0x8c, 0xa0, 0x31, 0x5b, 0x7f, 0xfb, 0x6a, 0x1e, + 0x33, 0x19, 0x14, 0x91, 0x75, 0xf6, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xb1, 0xe6, 0x7c, 0xd1, 0x1f, + 0x04, 0x00, 0x00, } func (m *BlockHeader) Marshal() (dAtA []byte, err error) { @@ -399,23 +518,30 @@ func (m *BitcoinSigningRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.VaultAddress) i = encodeVarintBitcoin(dAtA, i, uint64(len(m.VaultAddress))) i-- - dAtA[i] = 0x2a + dAtA[i] = 0x32 } if m.Sequence != 0 { i = encodeVarintBitcoin(dAtA, i, uint64(m.Sequence)) i-- - dAtA[i] = 0x20 + dAtA[i] = 0x28 } if m.Status != 0 { i = encodeVarintBitcoin(dAtA, i, uint64(m.Status)) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x20 } if len(m.TxBytes) > 0 { i -= len(m.TxBytes) copy(dAtA[i:], m.TxBytes) i = encodeVarintBitcoin(dAtA, i, uint64(len(m.TxBytes))) i-- + dAtA[i] = 0x1a + } + if len(m.Txid) > 0 { + i -= len(m.Txid) + copy(dAtA[i:], m.Txid) + i = encodeVarintBitcoin(dAtA, i, uint64(len(m.Txid))) + i-- dAtA[i] = 0x12 } if len(m.Address) > 0 { @@ -428,6 +554,85 @@ func (m *BitcoinSigningRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *UTXO) 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 *UTXO) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *UTXO) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.IsLocked { + i-- + if m.IsLocked { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x40 + } + if m.IsCoinbase { + i-- + if m.IsCoinbase { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x38 + } + if len(m.PubKeyScript) > 0 { + i -= len(m.PubKeyScript) + copy(dAtA[i:], m.PubKeyScript) + i = encodeVarintBitcoin(dAtA, i, uint64(len(m.PubKeyScript))) + i-- + dAtA[i] = 0x32 + } + if m.Height != 0 { + i = encodeVarintBitcoin(dAtA, i, uint64(m.Height)) + i-- + dAtA[i] = 0x28 + } + if m.Amount != 0 { + i = encodeVarintBitcoin(dAtA, i, uint64(m.Amount)) + i-- + dAtA[i] = 0x20 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintBitcoin(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x1a + } + if m.Vout != 0 { + i = encodeVarintBitcoin(dAtA, i, uint64(m.Vout)) + i-- + dAtA[i] = 0x10 + } + if len(m.Txid) > 0 { + i -= len(m.Txid) + copy(dAtA[i:], m.Txid) + i = encodeVarintBitcoin(dAtA, i, uint64(len(m.Txid))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintBitcoin(dAtA []byte, offset int, v uint64) int { offset -= sovBitcoin(v) base := offset @@ -489,6 +694,10 @@ func (m *BitcoinSigningRequest) Size() (n int) { if l > 0 { n += 1 + l + sovBitcoin(uint64(l)) } + l = len(m.Txid) + if l > 0 { + n += 1 + l + sovBitcoin(uint64(l)) + } l = len(m.TxBytes) if l > 0 { n += 1 + l + sovBitcoin(uint64(l)) @@ -506,6 +715,42 @@ func (m *BitcoinSigningRequest) Size() (n int) { return n } +func (m *UTXO) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Txid) + if l > 0 { + n += 1 + l + sovBitcoin(uint64(l)) + } + if m.Vout != 0 { + n += 1 + sovBitcoin(uint64(m.Vout)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovBitcoin(uint64(l)) + } + if m.Amount != 0 { + n += 1 + sovBitcoin(uint64(m.Amount)) + } + if m.Height != 0 { + n += 1 + sovBitcoin(uint64(m.Height)) + } + l = len(m.PubKeyScript) + if l > 0 { + n += 1 + l + sovBitcoin(uint64(l)) + } + if m.IsCoinbase { + n += 2 + } + if m.IsLocked { + n += 2 + } + return n +} + func sovBitcoin(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -847,6 +1092,38 @@ func (m *BitcoinSigningRequest) Unmarshal(dAtA []byte) error { m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Txid", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBitcoin + } + 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 ErrInvalidLengthBitcoin + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBitcoin + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Txid = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field TxBytes", wireType) } @@ -878,7 +1155,7 @@ func (m *BitcoinSigningRequest) Unmarshal(dAtA []byte) error { } m.TxBytes = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) } @@ -897,7 +1174,7 @@ func (m *BitcoinSigningRequest) Unmarshal(dAtA []byte) error { break } } - case 4: + case 5: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) } @@ -916,7 +1193,7 @@ func (m *BitcoinSigningRequest) Unmarshal(dAtA []byte) error { break } } - case 5: + case 6: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field VaultAddress", wireType) } @@ -969,6 +1246,251 @@ func (m *BitcoinSigningRequest) Unmarshal(dAtA []byte) error { } return nil } +func (m *UTXO) 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 ErrIntOverflowBitcoin + } + 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: UTXO: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: UTXO: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Txid", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBitcoin + } + 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 ErrInvalidLengthBitcoin + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBitcoin + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Txid = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Vout", wireType) + } + m.Vout = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBitcoin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Vout |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBitcoin + } + 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 ErrInvalidLengthBitcoin + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthBitcoin + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + m.Amount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBitcoin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Amount |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) + } + m.Height = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBitcoin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Height |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PubKeyScript", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBitcoin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthBitcoin + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthBitcoin + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PubKeyScript = append(m.PubKeyScript[:0], dAtA[iNdEx:postIndex]...) + if m.PubKeyScript == nil { + m.PubKeyScript = []byte{} + } + iNdEx = postIndex + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsCoinbase", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBitcoin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsCoinbase = bool(v != 0) + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsLocked", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowBitcoin + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsLocked = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipBitcoin(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthBitcoin + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipBitcoin(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/btclightclient/types/keys.go b/x/btclightclient/types/keys.go index ef5fc549..eafb2abd 100644 --- a/x/btclightclient/types/keys.go +++ b/x/btclightclient/types/keys.go @@ -30,6 +30,7 @@ var ( BtcBlockHeaderHeightPrefix = []byte{0x12} // prefix for each key to a block hash, for a height BtcBestBlockHeaderKey = []byte{0x13} // key for the best block height BtcSigningRequestPrefix = []byte{0x14} // prefix for each key to a signing request + BtcUtxoKeyPrefix = []byte{0x15} // prefix for each key to a utxo ChainCfg = &chaincfg.MainNetParams ) @@ -40,6 +41,10 @@ func Int64ToBytes(number uint64) []byte { return big.Bytes() } +func BtcUtxoKey(hash string, vout uint64) []byte { + return append(BtcBlockHeaderHashPrefix, []byte(hash)...) +} + func BtcBlockHeaderHashKey(hash string) []byte { return append(BtcBlockHeaderHashPrefix, []byte(hash)...) } @@ -48,6 +53,6 @@ func BtcBlockHeaderHeightKey(height uint64) []byte { return append(BtcBlockHeaderHashPrefix, Int64ToBytes(height)...) } -func BtcSigningRequestKey(hash string) []byte { - return append(BtcBlockHeaderHashPrefix, []byte(hash)...) +func BtcSigningRequestKey(sequence uint64) []byte { + return append(BtcSigningRequestPrefix, Int64ToBytes(sequence)...) } From 30992320d9ddfd2a2afee16d45e952e4bd4c8ad8 Mon Sep 17 00:00:00 2001 From: sufay Date: Wed, 12 Jun 2024 23:51:16 +0800 Subject: [PATCH 17/71] store utxo --- x/btclightclient/keeper/keeper.go | 8 +++++++- x/btclightclient/keeper/utxo.go | 11 +---------- x/btclightclient/types/keys.go | 20 +++++++++++++++++--- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/x/btclightclient/keeper/keeper.go b/x/btclightclient/keeper/keeper.go index 03f6e128..ba013434 100644 --- a/x/btclightclient/keeper/keeper.go +++ b/x/btclightclient/keeper/keeper.go @@ -272,7 +272,8 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg IsLocked: false, } - println("save utxo", utxo.Txid, utxo.Vout) + k.SetUtxo(ctx, utxo) + k.SetOwnerUtxo(ctx, utxo) ctx.Logger().Info("Minted Bitcoin Voucher", "index", i, "address", addr.EncodeAddress(), "amount", out.Value, "sender", sender.EncodeAddress(), "senderAddr", senderAddr.String(), "coins", coins.String()) @@ -289,6 +290,11 @@ func (k Keeper) SetUtxo(ctx sdk.Context, utxo types.UTXO) { store.Set(types.BtcUtxoKey(utxo.Txid, utxo.Vout), bz) } +func (k Keeper) SetOwnerUtxo(ctx sdk.Context, utxo types.UTXO) { + store := ctx.KVStore(k.storeKey) + store.Set(types.BtcOwnerUtxoKey(utxo.Address, utxo.Txid, utxo.Vout), nil) +} + func (k Keeper) GetBlockHeader(ctx sdk.Context, hash string) *types.BlockHeader { store := ctx.KVStore(k.storeKey) var blockHeader types.BlockHeader diff --git a/x/btclightclient/keeper/utxo.go b/x/btclightclient/keeper/utxo.go index 93cc78f3..2834afbf 100644 --- a/x/btclightclient/keeper/utxo.go +++ b/x/btclightclient/keeper/utxo.go @@ -1,11 +1,5 @@ package keeper -import ( - "cosmossdk.io/collections" - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" -) - type UTXOViewKeeper interface { } @@ -16,13 +10,10 @@ type UTXOKeeper interface { var _ UTXOKeeper = (*BaseUTXOKeeper)(nil) type BaseUTXOViewKeeper struct { - UTXOs *collections.IndexedMap[collections.Pair[sdk.AccAddress, string], math.Int, BalancesIndexes] } func NewBaseUTXOViewKeeper() *BaseUTXOViewKeeper { - return &BaseUTXOViewKeeper{ - UTXOs: &collections.NewIndexedMap(sb, types.BalancesPrefix, "utxos", collections.PairKeyCodec(sdk.AccAddressKey, collections.StringKey), types.BalanceValueCodec, newBalancesIndexes(sb)), - } + return &BaseUTXOViewKeeper{} } type BaseUTXOKeeper struct { diff --git a/x/btclightclient/types/keys.go b/x/btclightclient/types/keys.go index eafb2abd..82702e5e 100644 --- a/x/btclightclient/types/keys.go +++ b/x/btclightclient/types/keys.go @@ -22,6 +22,10 @@ func KeyPrefix(p string) []byte { } var ( + // key separator + // only used when the separated keys do not contain the separator + KeySeparator = []byte{0x0} + ParamsStoreKey = []byte{0x1} SequenceKey = []byte{0x2} @@ -30,7 +34,9 @@ var ( BtcBlockHeaderHeightPrefix = []byte{0x12} // prefix for each key to a block hash, for a height BtcBestBlockHeaderKey = []byte{0x13} // key for the best block height BtcSigningRequestPrefix = []byte{0x14} // prefix for each key to a signing request - BtcUtxoKeyPrefix = []byte{0x15} // prefix for each key to a utxo + + BtcUtxoKeyPrefix = []byte{0x15} // prefix for each key to a utxo + BtcOwnerUtxoKeyPrefix = []byte{0x16} // prefix for each key to an owned utxo ChainCfg = &chaincfg.MainNetParams ) @@ -42,7 +48,15 @@ func Int64ToBytes(number uint64) []byte { } func BtcUtxoKey(hash string, vout uint64) []byte { - return append(BtcBlockHeaderHashPrefix, []byte(hash)...) + return append(append(BtcUtxoKeyPrefix, []byte(hash)...), Int64ToBytes(vout)...) +} + +func BtcOwnerUtxoKey(owner string, hash string, vout uint64) []byte { + key := append(BtcOwnerUtxoKeyPrefix, []byte(owner)...) + key = append(key, KeySeparator...) + key = append(key, []byte(hash)...) + + return append(key, Int64ToBytes(vout)...) } func BtcBlockHeaderHashKey(hash string) []byte { @@ -50,7 +64,7 @@ func BtcBlockHeaderHashKey(hash string) []byte { } func BtcBlockHeaderHeightKey(height uint64) []byte { - return append(BtcBlockHeaderHashPrefix, Int64ToBytes(height)...) + return append(BtcBlockHeaderHeightPrefix, Int64ToBytes(height)...) } func BtcSigningRequestKey(sequence uint64) []byte { From fff5b812dca71df0716f14f7c758ac5d6b72a985 Mon Sep 17 00:00:00 2001 From: sufay Date: Thu, 13 Jun 2024 00:57:00 +0800 Subject: [PATCH 18/71] add utxo keeper interfaces --- x/btclightclient/keeper/utxo.go | 61 +++++++++++++++++++++++++++++++-- 1 file changed, 59 insertions(+), 2 deletions(-) diff --git a/x/btclightclient/keeper/utxo.go b/x/btclightclient/keeper/utxo.go index 2834afbf..2423e3df 100644 --- a/x/btclightclient/keeper/utxo.go +++ b/x/btclightclient/keeper/utxo.go @@ -1,20 +1,77 @@ package keeper +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/sideprotocol/side/x/btclightclient/types" +) + type UTXOViewKeeper interface { + HasUTXO(ctx sdk.Context, hash string, vout uint64) bool + IsUTXOLocked(ctx sdk.Context, hash string, vout uint64) bool + + GetAllUTXOs(ctx sdk.Context) []*types.UTXO + + GetUTXOsByAddr(ctx sdk.Context, addr string) []*types.UTXO + GetOrderedUTXOsByAddr(ctx sdk.Context, addr string) []*types.UTXO } type UTXOKeeper interface { UTXOViewKeeper + + LockUTXO(ctx sdk.Context, hash string, vout uint64) + SpendUTXO(ctx sdk.Context, hash string, vout uint64) } var _ UTXOKeeper = (*BaseUTXOKeeper)(nil) type BaseUTXOViewKeeper struct { + k Keeper +} + +func NewBaseUTXOViewKeeper(k Keeper) *BaseUTXOViewKeeper { + return &BaseUTXOViewKeeper{k} +} + +func (bvk *BaseUTXOViewKeeper) HasUTXO(ctx sdk.Context, hash string, vout uint64) bool { + // TODO + return true +} + +func (bvk *BaseUTXOViewKeeper) IsUTXOLocked(ctx sdk.Context, hash string, vout uint64) bool { + // TODO + return true } -func NewBaseUTXOViewKeeper() *BaseUTXOViewKeeper { - return &BaseUTXOViewKeeper{} +func (bvk *BaseUTXOViewKeeper) GetAllUTXOs(ctx sdk.Context) []*types.UTXO { + // TODO + return nil +} + +func (bvk *BaseUTXOViewKeeper) GetUTXOsByAddr(ctx sdk.Context, addr string) []*types.UTXO { + // TODO + return nil +} + +func (bvk *BaseUTXOViewKeeper) GetOrderedUTXOsByAddr(ctx sdk.Context, addr string) []*types.UTXO { + // TODO + return nil } type BaseUTXOKeeper struct { + BaseUTXOViewKeeper + + k Keeper +} + +func NewBaseUTXOKeeper(k Keeper) *BaseUTXOKeeper { + return &BaseUTXOKeeper{BaseUTXOViewKeeper: *NewBaseUTXOViewKeeper(k), k: k} +} + +func (bk *BaseUTXOKeeper) LockUTXO(ctx sdk.Context, hash string, vout uint64) { + // TODO +} + +func (bk *BaseUTXOKeeper) SpendUTXO(ctx sdk.Context, hash string, vout uint64) { + // TODO } From 6fa2f9d080e08129c2240748cd4aed7f8c7fde6e Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Thu, 13 Jun 2024 11:50:50 +0800 Subject: [PATCH 19/71] separate bitcoin prefix and side. --- app/app.go | 3 -- app/test_setup.go | 6 +-- cmd/sided/cmd/config.go | 17 +++++---- local_node_test.sh | 64 +++++++++++++++++++++++--------- x/btclightclient/types/params.go | 2 +- 5 files changed, 60 insertions(+), 32 deletions(-) mode change 100644 => 100755 local_node_test.sh diff --git a/app/app.go b/app/app.go index 59fecd38..9467865b 100644 --- a/app/app.go +++ b/app/app.go @@ -9,7 +9,6 @@ import ( autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1" - "github.com/btcsuite/btcd/chaincfg" dbm "github.com/cometbft/cometbft-db" abci "github.com/cometbft/cometbft/abci/types" "github.com/cometbft/cometbft/libs/log" @@ -103,8 +102,6 @@ var ( // and genesis verification. ModuleBasics = keepers.AppModuleBasics - BitcoinChainCfg = chaincfg.MainNetParams - // module account permissions ) diff --git a/app/test_setup.go b/app/test_setup.go index 499b5ba0..c257c4b5 100644 --- a/app/test_setup.go +++ b/app/test_setup.go @@ -27,7 +27,7 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) -const Bech32Prefix = "cosmos" +const bech32Prefix = "cosmos" func init() { SetupConfig() @@ -37,8 +37,8 @@ func SetupConfig() { config := sdk.GetConfig() valoper := sdk.PrefixValidator + sdk.PrefixOperator valoperpub := sdk.PrefixValidator + sdk.PrefixOperator + sdk.PrefixPublic - config.SetBech32PrefixForAccount(Bech32Prefix, Bech32Prefix+sdk.PrefixPublic) - config.SetBech32PrefixForValidator(Bech32Prefix+valoper, Bech32Prefix+valoperpub) + config.SetBech32PrefixForAccount(bech32Prefix, bech32Prefix+sdk.PrefixPublic) + config.SetBech32PrefixForValidator(bech32Prefix+valoper, bech32Prefix+valoperpub) config.SetCoinType(84) // use the same coin type as bitcoin diff --git a/cmd/sided/cmd/config.go b/cmd/sided/cmd/config.go index 14f80879..8b0e2de3 100644 --- a/cmd/sided/cmd/config.go +++ b/cmd/sided/cmd/config.go @@ -1,24 +1,25 @@ package cmd import ( + "github.com/btcsuite/btcd/chaincfg" sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/sideprotocol/side/app" ) func initSDKConfig() { // Set prefixes - accountPubKeyPrefix := app.BitcoinChainCfg.Bech32HRPSegwit + "pub" - validatorAddressPrefix := app.BitcoinChainCfg.Bech32HRPSegwit + "valoper" - validatorPubKeyPrefix := app.BitcoinChainCfg.Bech32HRPSegwit + "valoperpub" - consNodeAddressPrefix := app.BitcoinChainCfg.Bech32HRPSegwit + "valcons" - consNodePubKeyPrefix := app.BitcoinChainCfg.Bech32HRPSegwit + "valconspub" + bech32Prefix := "side" + accountPubKeyPrefix := bech32Prefix + "pub" + validatorAddressPrefix := bech32Prefix + "valoper" + validatorPubKeyPrefix := bech32Prefix + "valoperpub" + consNodeAddressPrefix := bech32Prefix + "valcons" + consNodePubKeyPrefix := bech32Prefix + "valconspub" // Set and seal config config := sdk.GetConfig() - config.SetBech32PrefixForAccount(app.BitcoinChainCfg.Bech32HRPSegwit, accountPubKeyPrefix) + config.SetBech32PrefixForAccount(bech32Prefix, accountPubKeyPrefix) config.SetBech32PrefixForValidator(validatorAddressPrefix, validatorPubKeyPrefix) config.SetBech32PrefixForConsensusNode(consNodeAddressPrefix, consNodePubKeyPrefix) + config.SetBtcChainCfg(&chaincfg.SigNetParams) config.Seal() } diff --git a/local_node_test.sh b/local_node_test.sh old mode 100644 new mode 100755 index 2c70a752..16afd436 --- a/local_node_test.sh +++ b/local_node_test.sh @@ -1,11 +1,19 @@ #!/bin/bash -KEYS=("dev0" "dev1" "dev2") -CHAINID="side-testnet-1" -MONIKER="freebird" -BINARY="sided" -DENOMS=("uside" "uusdc") -INITIAL_SUPPLY="100000000000000000000" +KEYS=("dev0" "dev1") +CHAINID="S2-testnet-1" +MONIKER="Side Labs" +BINARY="$HOME/go/bin/sided" +DENOM_STR="uside" +INITIAL_ACCOUNT_STR="" +set -f +IFS=, +DENOMS=($DENOM_STR) +INITIAL_ACCOUNTS=($INITIAL_ACCOUNT_STR) + +IFS=";" + +INITIAL_SUPPLY="500000000000000" BLOCK_GAS=10000000 MAX_GAS=10000000000 @@ -13,6 +21,7 @@ MAX_GAS=10000000000 # otherwise your balance will be wiped quickly # The keyring test does not require private key to steal tokens from you KEYRING="test" +#KEYALGO="secp256k1" KEYALGO="segwit" LOGLEVEL="info" # Set dedicated home directory for the $BINARY instance @@ -59,16 +68,25 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then for KEY in "${KEYS[@]}"; do $BINARY keys add "$KEY" --keyring-backend $KEYRING --algo $KEYALGO --home "$HOMEDIR" done + # for KEY in "${KEYS[@]}"; do + # # Add the --recover flag to initiate recovery mode + # $BINARY keys add "$KEY" --keyring-backend $KEYRING --algo $KEYALGO --recover --home "$HOMEDIR" + # done # Set moniker and chain-id for Cascadia (Moniker can be anything, chain-id must be an integer) $BINARY init $MONIKER -o --chain-id $CHAINID --home "$HOMEDIR" jq --arg denom "${DENOMS[0]}" '.app_state["staking"]["params"]["bond_denom"]=$denom' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq --arg denom "${DENOMS[0]}" '.app_state["mint"]["params"]["mint_denom"]=$denom' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq --arg denom "${DENOMS[0]}" '.app_state["crisis"]["constant_fee"]["denom"]=$denom' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq --arg denom "${DENOMS[0]}" '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]=$denom' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq --arg denom "${DENOMS[0]}" '.app_state["gov"]["params"]["min_deposit"][0]["denom"]=$denom' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq --arg gas "$BLOCK_GAS" '.app_state["feemarket"]["block_gas"]=$gas' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" # Set gas limit in genesis jq --arg max_gas "$MAX_GAS" '.consensus_params["block"]["max_gas"]=$max_gas' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + + + # set custom pruning settings sed -i.bak 's/pruning = "default"/pruning = "custom"/g' "$APP_TOML" sed -i.bak 's/pruning-keep-recent = "0"/pruning-keep-recent = "2"/g' "$APP_TOML" @@ -81,22 +99,32 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then # Allocate genesis accounts (cosmos formatted addresses) for KEY in "${KEYS[@]}"; do BALANCES="" - for DENOM in "${DENOMS[@]}"; do - BALANCES+=",${INITIAL_SUPPLY}$DENOM" + for key in "${!DENOMS[@]}"; do + BALANCES+=",${INITIAL_SUPPLY}${DENOMS[$key]}" done + echo ${BALANCES:1} $BINARY add-genesis-account "$KEY" ${BALANCES:1} --keyring-backend $KEYRING --home "$HOMEDIR" done - # Adjust total supply - for DENOM in "${DENOMS[@]}"; do - total_supply=$(echo "${#KEYS[@]} * $INITIAL_SUPPLY" | bc) - if ! jq -e --arg denom "$DENOM" '.app_state["bank"]["supply"] | any(.denom == $denom)' "$GENESIS" >/dev/null; then - jq -r --arg total_supply "$total_supply" --arg denom "$DENOM" '.app_state["bank"]["supply"] += [{"denom": $denom, "amount": $total_supply}]' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - fi + echo "Genesis accounts allocated for local accounts" + + # Allocate genesis accounts (cosmos formatted addresses) + for ADDR in "${INITIAL_ACCOUNTS[@]}"; do + BALANCES="" + for key in "${!DENOMS[@]}"; do + BALANCES+=",${INITIAL_SUPPLY}${DENOMS[$key]}" + done + echo ${BALANCES:1} + $BINARY add-genesis-account "$ADDR" ${BALANCES:1} --home "$HOMEDIR" done - + echo "Genesis accounts allocated for initial accounts" + + + # Sign genesis transaction - $BINARY gentx "${KEYS[0]}" ${INITIAL_SUPPLY}${DENOMS[0]} --keyring-backend $KEYRING --chain-id $CHAINID --home "$HOMEDIR" + # echo $INITIAL_SUPPLY${DENOMS[0]} + $BINARY gentx "${KEYS[0]}" $INITIAL_SUPPLY${DENOMS[0]} --keyring-backend $KEYRING --chain-id $CHAINID --identity "666AC57CC678BEC4" --website="https://side.one" --home "$HOMEDIR" + echo "Genesis transaction signed" ## In case you want to create multiple validators at genesis ## 1. Back to `$BINARY keys add` step, init more keys @@ -107,9 +135,11 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then # Collect genesis tx $BINARY collect-gentxs --home "$HOMEDIR" + echo "Genesis transactions collected" # Run this to ensure everything worked and that the genesis file is setup correctly $BINARY validate-genesis --home "$HOMEDIR" + echo "Genesis file validated" if [[ $1 == "pending" ]]; then echo "pending mode is on, please wait for the first block committed." @@ -118,4 +148,4 @@ fi # Start the node (remove the --pruning=nothing flag if historical queries are not needed) -$BINARY start --log_level info --minimum-gas-prices=0.0001${DENOMS[0]} \ No newline at end of file +$BINARY start --log_level info --minimum-gas-prices=0.0001${DENOMS[0]} diff --git a/x/btclightclient/types/params.go b/x/btclightclient/types/params.go index 0f5fdd9a..20d41e24 100644 --- a/x/btclightclient/types/params.go +++ b/x/btclightclient/types/params.go @@ -14,7 +14,7 @@ func NewParams(senders []string) Params { // DefaultParams returns a default set of parameters func DefaultParams() Params { - return NewParams([]string{"bc1qtxqfntu4340j3vhasnrrnm8tvf2t3z7gu9dysz"}) + return NewParams([]string{}) } // Validate validates the set of params From 32c558ee4ed722988eec0e435d901575ee848145 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Thu, 13 Jun 2024 11:51:04 +0800 Subject: [PATCH 20/71] disable utxo for now --- x/btclightclient/keeper/utxo.go | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/x/btclightclient/keeper/utxo.go b/x/btclightclient/keeper/utxo.go index 93cc78f3..e930db34 100644 --- a/x/btclightclient/keeper/utxo.go +++ b/x/btclightclient/keeper/utxo.go @@ -1,11 +1,5 @@ package keeper -import ( - "cosmossdk.io/collections" - "cosmossdk.io/math" - sdk "github.com/cosmos/cosmos-sdk/types" -) - type UTXOViewKeeper interface { } @@ -13,17 +7,18 @@ type UTXOKeeper interface { UTXOViewKeeper } -var _ UTXOKeeper = (*BaseUTXOKeeper)(nil) +// var _ UTXOKeeper = (*BaseUTXOKeeper)(nil) -type BaseUTXOViewKeeper struct { - UTXOs *collections.IndexedMap[collections.Pair[sdk.AccAddress, string], math.Int, BalancesIndexes] -} +// type BaseUTXOViewKeeper struct { +// UTXOs *collections.IndexedMap[collections.Pair[sdk.AccAddress, string], math.Int, BalancesIndexes] +// } -func NewBaseUTXOViewKeeper() *BaseUTXOViewKeeper { - return &BaseUTXOViewKeeper{ - UTXOs: &collections.NewIndexedMap(sb, types.BalancesPrefix, "utxos", collections.PairKeyCodec(sdk.AccAddressKey, collections.StringKey), types.BalanceValueCodec, newBalancesIndexes(sb)), - } -} +// func NewBaseUTXOViewKeeper() *BaseUTXOViewKeeper { +// // return &BaseUTXOViewKeeper{ +// // UTXOs: &collections.NewIndexedMap(sb, types.BalancesPrefix, "utxos", collections.PairKeyCodec(sdk.AccAddressKey, collections.StringKey), types.BalanceValueCodec, newBalancesIndexes(sb)), +// // } +// return nil +// } -type BaseUTXOKeeper struct { -} +// type BaseUTXOKeeper struct { +// } From c7ee6888e81e7f0f17c9f92a571eeb4225658f9e Mon Sep 17 00:00:00 2001 From: sufay Date: Thu, 13 Jun 2024 19:41:24 +0800 Subject: [PATCH 21/71] implement utxo keeper --- x/btclightclient/keeper/keeper.go | 26 ++-- x/btclightclient/keeper/utxo.go | 248 +++++++++++++++++++++++++++--- x/btclightclient/types/errors.go | 4 + x/btclightclient/types/keys.go | 5 - 4 files changed, 237 insertions(+), 46 deletions(-) diff --git a/x/btclightclient/keeper/keeper.go b/x/btclightclient/keeper/keeper.go index ba013434..9160bcc2 100644 --- a/x/btclightclient/keeper/keeper.go +++ b/x/btclightclient/keeper/keeper.go @@ -21,6 +21,8 @@ import ( type ( Keeper struct { + BaseUTXOKeeper + cdc codec.BinaryCodec storeKey storetypes.StoreKey memKey storetypes.StoreKey @@ -37,10 +39,11 @@ func NewKeeper( bankKeeper types.BankKeeper, ) *Keeper { return &Keeper{ - cdc: cdc, - storeKey: storeKey, - memKey: memKey, - bankKeeper: bankKeeper, + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + bankKeeper: bankKeeper, + BaseUTXOKeeper: *NewBaseUTXOKeeper(cdc, storeKey), } } @@ -272,8 +275,8 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg IsLocked: false, } - k.SetUtxo(ctx, utxo) - k.SetOwnerUtxo(ctx, utxo) + k.SetUTXO(ctx, &utxo) + k.SetOwnerUTXO(ctx, &utxo) ctx.Logger().Info("Minted Bitcoin Voucher", "index", i, "address", addr.EncodeAddress(), "amount", out.Value, "sender", sender.EncodeAddress(), "senderAddr", senderAddr.String(), "coins", coins.String()) @@ -284,17 +287,6 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg return nil } -func (k Keeper) SetUtxo(ctx sdk.Context, utxo types.UTXO) { - store := ctx.KVStore(k.storeKey) - bz := k.cdc.MustMarshal(&utxo) - store.Set(types.BtcUtxoKey(utxo.Txid, utxo.Vout), bz) -} - -func (k Keeper) SetOwnerUtxo(ctx sdk.Context, utxo types.UTXO) { - store := ctx.KVStore(k.storeKey) - store.Set(types.BtcOwnerUtxoKey(utxo.Address, utxo.Txid, utxo.Vout), nil) -} - func (k Keeper) GetBlockHeader(ctx sdk.Context, hash string) *types.BlockHeader { store := ctx.KVStore(k.storeKey) var blockHeader types.BlockHeader diff --git a/x/btclightclient/keeper/utxo.go b/x/btclightclient/keeper/utxo.go index 2423e3df..9c4110dc 100644 --- a/x/btclightclient/keeper/utxo.go +++ b/x/btclightclient/keeper/utxo.go @@ -1,6 +1,11 @@ package keeper import ( + "math/big" + "sort" + + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/sideprotocol/side/x/btclightclient/types" @@ -8,70 +13,265 @@ import ( type UTXOViewKeeper interface { HasUTXO(ctx sdk.Context, hash string, vout uint64) bool - IsUTXOLocked(ctx sdk.Context, hash string, vout uint64) bool + IsUTXOLocked(ctx sdk.Context, hash string, vout uint64) (bool, error) + GetUTXO(ctx sdk.Context, hash string, vout uint64) *types.UTXO GetAllUTXOs(ctx sdk.Context) []*types.UTXO GetUTXOsByAddr(ctx sdk.Context, addr string) []*types.UTXO + GetUnlockedUTXOsByAddr(ctx sdk.Context, addr string) []*types.UTXO GetOrderedUTXOsByAddr(ctx sdk.Context, addr string) []*types.UTXO + + IterateAllUTXOs(ctx sdk.Context, cb func(utxo *types.UTXO) (stop bool)) + IterateUTXOsByAddr(ctx sdk.Context, addr string, cb func(addr string, utxo *types.UTXO) (stop bool)) } type UTXOKeeper interface { UTXOViewKeeper - LockUTXO(ctx sdk.Context, hash string, vout uint64) - SpendUTXO(ctx sdk.Context, hash string, vout uint64) + LockUTXO(ctx sdk.Context, hash string, vout uint64) error + LockUTXOs(ctx sdk.Context, utxos []*types.UTXO) error + + UnlockUTXO(ctx sdk.Context, hash string, vout uint64) error + UnlockUTXOs(ctx sdk.Context, utxos []*types.UTXO) error + + SpendUTXO(ctx sdk.Context, hash string, vout uint64) error + SpendUTXOs(ctx sdk.Context, utxos []*types.UTXO) error } var _ UTXOKeeper = (*BaseUTXOKeeper)(nil) type BaseUTXOViewKeeper struct { - k Keeper + cdc codec.BinaryCodec + storeKey storetypes.StoreKey } -func NewBaseUTXOViewKeeper(k Keeper) *BaseUTXOViewKeeper { - return &BaseUTXOViewKeeper{k} +func NewBaseUTXOViewKeeper(cdc codec.BinaryCodec, storeKey storetypes.StoreKey) *BaseUTXOViewKeeper { + return &BaseUTXOViewKeeper{ + cdc, + storeKey, + } } func (bvk *BaseUTXOViewKeeper) HasUTXO(ctx sdk.Context, hash string, vout uint64) bool { - // TODO - return true + store := ctx.KVStore(bvk.storeKey) + return store.Has(types.BtcUtxoKey(hash, vout)) } -func (bvk *BaseUTXOViewKeeper) IsUTXOLocked(ctx sdk.Context, hash string, vout uint64) bool { - // TODO - return true +func (bvk *BaseUTXOViewKeeper) IsUTXOLocked(ctx sdk.Context, hash string, vout uint64) (bool, error) { + if !bvk.HasUTXO(ctx, hash, vout) { + return false, types.ErrUTXODoesNotExist + } + + utxo := bvk.GetUTXO(ctx, hash, vout) + + return utxo.IsLocked, nil +} + +func (bvk *BaseUTXOViewKeeper) GetUTXO(ctx sdk.Context, hash string, vout uint64) *types.UTXO { + store := ctx.KVStore(bvk.storeKey) + + var utxo types.UTXO + bz := store.Get(types.BtcUtxoKey(hash, vout)) + bvk.cdc.MustUnmarshal(bz, &utxo) + + return &utxo } func (bvk *BaseUTXOViewKeeper) GetAllUTXOs(ctx sdk.Context) []*types.UTXO { - // TODO - return nil + utxos := make([]*types.UTXO, 0) + + bvk.IterateAllUTXOs(ctx, func(utxo *types.UTXO) (stop bool) { + utxos = append(utxos, utxo) + return false + }) + + return utxos } func (bvk *BaseUTXOViewKeeper) GetUTXOsByAddr(ctx sdk.Context, addr string) []*types.UTXO { - // TODO - return nil + utxos := make([]*types.UTXO, 0) + + bvk.IterateUTXOsByAddr(ctx, addr, func(addr string, utxo *types.UTXO) (stop bool) { + utxos = append(utxos, utxo) + return false + }) + + return utxos +} + +func (bvk *BaseUTXOViewKeeper) GetUnlockedUTXOsByAddr(ctx sdk.Context, addr string) []*types.UTXO { + utxos := make([]*types.UTXO, 0) + + bvk.IterateUTXOsByAddr(ctx, addr, func(addr string, utxo *types.UTXO) (stop bool) { + if !utxo.IsLocked { + utxos = append(utxos, utxo) + } + + return false + }) + + return utxos } +// GetOrderedUTXOsByAddr gets all unlocked utxos of the given address in the descending order by amount func (bvk *BaseUTXOViewKeeper) GetOrderedUTXOsByAddr(ctx sdk.Context, addr string) []*types.UTXO { - // TODO - return nil + utxos := make([]*types.UTXO, 0) + + bvk.IterateUTXOsByAddr(ctx, addr, func(addr string, utxo *types.UTXO) (stop bool) { + if !utxo.IsLocked { + utxos = append(utxos, utxo) + } + + return false + }) + + // sort utoxs in the descending order + sort.SliceStable(utxos, func(i int, j int) bool { + return utxos[i].Amount > utxos[j].Amount + }) + + return utxos +} + +func (bvk *BaseUTXOViewKeeper) IterateAllUTXOs(ctx sdk.Context, cb func(utxo *types.UTXO) (stop bool)) { + store := ctx.KVStore(bvk.storeKey) + + iterator := sdk.KVStorePrefixIterator(store, types.BtcUtxoKeyPrefix) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var utxo types.UTXO + bvk.cdc.MustUnmarshal(iterator.Value(), &utxo) + + if cb(&utxo) { + break + } + } +} + +func (bvk *BaseUTXOViewKeeper) IterateUTXOsByAddr(ctx sdk.Context, addr string, cb func(addr string, utxo *types.UTXO) (stop bool)) { + store := ctx.KVStore(bvk.storeKey) + + keyPrefix := append(types.BtcOwnerUtxoKeyPrefix, []byte(addr)...) + iterator := sdk.KVStorePrefixIterator(store, keyPrefix) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + key := iterator.Key() + + hash := key[1+len(addr) : 1+len(addr)+64] + vout := key[1+len(addr)+64:] + + utxo := bvk.GetUTXO(ctx, string(hash), new(big.Int).SetBytes(vout).Uint64()) + if cb(addr, utxo) { + break + } + } } type BaseUTXOKeeper struct { BaseUTXOViewKeeper - k Keeper + cdc codec.BinaryCodec + storeKey storetypes.StoreKey +} + +func NewBaseUTXOKeeper(cdc codec.BinaryCodec, storeKey storetypes.StoreKey) *BaseUTXOKeeper { + return &BaseUTXOKeeper{ + BaseUTXOViewKeeper: *NewBaseUTXOViewKeeper(cdc, storeKey), + cdc: cdc, + storeKey: storeKey, + } +} + +func (bk *BaseUTXOKeeper) SetUTXO(ctx sdk.Context, utxo *types.UTXO) { + store := ctx.KVStore(bk.storeKey) + + bz := bk.cdc.MustMarshal(utxo) + store.Set(types.BtcUtxoKey(utxo.Txid, utxo.Vout), bz) +} + +func (bk *BaseUTXOKeeper) SetOwnerUTXO(ctx sdk.Context, utxo *types.UTXO) { + store := ctx.KVStore(bk.storeKey) + + store.Set(types.BtcOwnerUtxoKey(utxo.Address, utxo.Txid, utxo.Vout), nil) } -func NewBaseUTXOKeeper(k Keeper) *BaseUTXOKeeper { - return &BaseUTXOKeeper{BaseUTXOViewKeeper: *NewBaseUTXOViewKeeper(k), k: k} +func (bk *BaseUTXOKeeper) LockUTXO(ctx sdk.Context, hash string, vout uint64) error { + if !bk.HasUTXO(ctx, hash, vout) { + return types.ErrUTXODoesNotExist + } + + utxo := bk.GetUTXO(ctx, hash, vout) + if utxo.IsLocked { + return types.ErrUTXOLocked + } + + utxo.IsLocked = true + bk.SetUTXO(ctx, utxo) + + return nil } -func (bk *BaseUTXOKeeper) LockUTXO(ctx sdk.Context, hash string, vout uint64) { - // TODO +func (bk *BaseUTXOKeeper) LockUTXOs(ctx sdk.Context, utxos []*types.UTXO) error { + for _, utxo := range utxos { + if err := bk.LockUTXO(ctx, utxo.Txid, utxo.Vout); err != nil { + return err + } + } + + return nil } -func (bk *BaseUTXOKeeper) SpendUTXO(ctx sdk.Context, hash string, vout uint64) { - // TODO +func (bk *BaseUTXOKeeper) UnlockUTXO(ctx sdk.Context, hash string, vout uint64) error { + if !bk.HasUTXO(ctx, hash, vout) { + return types.ErrUTXODoesNotExist + } + + utxo := bk.GetUTXO(ctx, hash, vout) + if !utxo.IsLocked { + return types.ErrUTXOUnlocked + } + + utxo.IsLocked = false + bk.SetUTXO(ctx, utxo) + + return nil +} + +func (bk *BaseUTXOKeeper) UnlockUTXOs(ctx sdk.Context, utxos []*types.UTXO) error { + for _, utxo := range utxos { + if err := bk.UnlockUTXO(ctx, utxo.Txid, utxo.Vout); err != nil { + return err + } + } + + return nil +} + +func (bk *BaseUTXOKeeper) SpendUTXO(ctx sdk.Context, hash string, vout uint64) error { + if !bk.HasUTXO(ctx, hash, vout) { + return types.ErrUTXODoesNotExist + } + + bk.removeUTXO(ctx, hash, vout) + + return nil +} + +func (bk *BaseUTXOKeeper) SpendUTXOs(ctx sdk.Context, utxos []*types.UTXO) error { + for _, utxo := range utxos { + if err := bk.SpendUTXO(ctx, utxo.Txid, utxo.Vout); err != nil { + return err + } + } + + return nil +} + +func (bk *BaseUTXOKeeper) removeUTXO(ctx sdk.Context, hash string, vout uint64) { + store := ctx.KVStore(bk.storeKey) + + store.Delete(types.BtcUtxoKey(hash, vout)) } diff --git a/x/btclightclient/types/errors.go b/x/btclightclient/types/errors.go index b55b4573..41bee256 100644 --- a/x/btclightclient/types/errors.go +++ b/x/btclightclient/types/errors.go @@ -24,4 +24,8 @@ var ( ErrInvalidSignatures = errorsmod.Register(ModuleName, 4200, "invalid signatures") ErrInsufficientBalance = errorsmod.Register(ModuleName, 4201, "insufficient balance") + + ErrUTXODoesNotExist = errorsmod.Register(ModuleName, 5100, "utxo does not exist") + ErrUTXOLocked = errorsmod.Register(ModuleName, 5101, "utxo locked") + ErrUTXOUnlocked = errorsmod.Register(ModuleName, 5102, "utxo unlocked") ) diff --git a/x/btclightclient/types/keys.go b/x/btclightclient/types/keys.go index 82702e5e..3e66d3fd 100644 --- a/x/btclightclient/types/keys.go +++ b/x/btclightclient/types/keys.go @@ -22,10 +22,6 @@ func KeyPrefix(p string) []byte { } var ( - // key separator - // only used when the separated keys do not contain the separator - KeySeparator = []byte{0x0} - ParamsStoreKey = []byte{0x1} SequenceKey = []byte{0x2} @@ -53,7 +49,6 @@ func BtcUtxoKey(hash string, vout uint64) []byte { func BtcOwnerUtxoKey(owner string, hash string, vout uint64) []byte { key := append(BtcOwnerUtxoKeyPrefix, []byte(owner)...) - key = append(key, KeySeparator...) key = append(key, []byte(hash)...) return append(key, Int64ToBytes(vout)...) From 82cf5df420ef8b22485ebbeb72fbbd5f026939f5 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Fri, 14 Jun 2024 13:22:13 +0800 Subject: [PATCH 22/71] rename field of signing request, use psbt instead of rawTransaction --- proto/side/btclightclient/bitcoin.proto | 2 +- signet.block | 11 +++ x/btclightclient/types/bitcoin.pb.go | 101 ++++++++++++------------ 3 files changed, 62 insertions(+), 52 deletions(-) create mode 100644 signet.block diff --git a/proto/side/btclightclient/bitcoin.proto b/proto/side/btclightclient/bitcoin.proto index 9c38d152..39ce6b3a 100644 --- a/proto/side/btclightclient/bitcoin.proto +++ b/proto/side/btclightclient/bitcoin.proto @@ -38,7 +38,7 @@ enum SigningStatus { message BitcoinSigningRequest { string address = 1; string txid = 2; - string tx_bytes = 3; + string psbt = 3; SigningStatus status = 4; uint64 sequence = 5; diff --git a/signet.block b/signet.block new file mode 100644 index 00000000..a2a3140e --- /dev/null +++ b/signet.block @@ -0,0 +1,11 @@ +"best_block_header": { + "version": "667459584", + "hash": "0000000000000009fb68da72e8994f014fafb455c72978233b94580b12af778c", + "height": "2815023", + "previous_block_hash": "0000000000000004a29c20eb32532718de8072665620edb4c657b22b4d463967", + "merkle_root": "9e219423eadce80e882cdff04b3026c9bbc994fd08a774f34a705ca3e710a332", + "nonce": "3913166971", + "bits": "191881b8", + "time": "1715566066", + "ntx": "6236" + } diff --git a/x/btclightclient/types/bitcoin.pb.go b/x/btclightclient/types/bitcoin.pb.go index 247eceab..86555dda 100644 --- a/x/btclightclient/types/bitcoin.pb.go +++ b/x/btclightclient/types/bitcoin.pb.go @@ -180,7 +180,7 @@ func (m *BlockHeader) GetNtx() uint64 { type BitcoinSigningRequest struct { Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` Txid string `protobuf:"bytes,2,opt,name=txid,proto3" json:"txid,omitempty"` - TxBytes string `protobuf:"bytes,3,opt,name=tx_bytes,json=txBytes,proto3" json:"tx_bytes,omitempty"` + Psbt string `protobuf:"bytes,3,opt,name=psbt,proto3" json:"psbt,omitempty"` Status SigningStatus `protobuf:"varint,4,opt,name=status,proto3,enum=side.btclightclient.SigningStatus" json:"status,omitempty"` Sequence uint64 `protobuf:"varint,5,opt,name=sequence,proto3" json:"sequence,omitempty"` // The vault address that the request is associated with @@ -234,9 +234,9 @@ func (m *BitcoinSigningRequest) GetTxid() string { return "" } -func (m *BitcoinSigningRequest) GetTxBytes() string { +func (m *BitcoinSigningRequest) GetPsbt() string { if m != nil { - return m.TxBytes + return m.Psbt } return "" } @@ -374,47 +374,46 @@ func init() { func init() { proto.RegisterFile("side/btclightclient/bitcoin.proto", fileDescriptor_d7dee3af17ecec77) } var fileDescriptor_d7dee3af17ecec77 = []byte{ - // 627 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x53, 0x4d, 0x6f, 0xda, 0x4c, - 0x10, 0xc6, 0xc1, 0x10, 0x98, 0x7c, 0x88, 0x77, 0xf3, 0xf1, 0x3a, 0xa4, 0x72, 0x53, 0xda, 0x43, - 0xd4, 0x03, 0x48, 0xcd, 0xad, 0x37, 0x3e, 0x9c, 0x94, 0xb6, 0x21, 0xd5, 0x9a, 0x48, 0x55, 0x2f, - 0x96, 0x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x67, 0xf0, 0xa5, 0x86, 0x62, 0x8c, 0xa0, 0x31, 0x5b, 0x7f, 0xfb, 0x6a, 0x1e, - 0x33, 0x19, 0x14, 0x91, 0x75, 0xf6, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xb1, 0xe6, 0x7c, 0xd1, 0x1f, - 0x04, 0x00, 0x00, + // 616 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x53, 0xcd, 0x6e, 0xd3, 0x40, + 0x10, 0x8e, 0x1b, 0x27, 0x4d, 0xa6, 0x3f, 0x0a, 0xdb, 0x1f, 0x4c, 0x8a, 0x4c, 0x09, 0x1c, 0x2a, + 0x0e, 0x89, 0x44, 0x6f, 0xdc, 0xf2, 0xe3, 0x96, 0x00, 0x4d, 0xd1, 0x3a, 0x95, 0x10, 0x17, 0xcb, + 0x76, 0x56, 0xce, 0xaa, 0x89, 0xd7, 0x78, 0xd7, 0x51, 0xfb, 0x16, 0xbc, 0x12, 0x37, 0x8e, 0x3d, + 0x21, 0x0e, 0x1c, 0x50, 0xfb, 0x0a, 0x3c, 0x00, 0xda, 0x71, 0x52, 0x35, 0x51, 0x2f, 0xd6, 0x7c, + 0x33, 0xdf, 0xcc, 0x7c, 0x33, 0xe3, 0x85, 0x97, 0x92, 0x8f, 0x58, 0x2b, 0x50, 0xe1, 0x84, 0x47, + 0x63, 0xfd, 0x65, 0xb1, 0x6a, 0x05, 0x5c, 0x85, 0x82, 0xc7, 0xcd, 0x24, 0x15, 0x4a, 0x90, 0x1d, + 0x4d, 0x69, 0x2e, 0x53, 0xea, 0xbb, 0x91, 0x88, 0x04, 0xc6, 0x5b, 0xda, 0xca, 0xa9, 0x8d, 0x7f, + 0x06, 0x6c, 0x74, 0x26, 0x22, 0xbc, 0x7c, 0xcf, 0xfc, 0x11, 0x4b, 0x89, 0x05, 0xeb, 0x33, 0x96, + 0x4a, 0x2e, 0x62, 0xcb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23, + 0x65, 0x3b, 0xf4, 0xbc, 0xdd, 0xeb, 0xb6, 0x5d, 0x9d, 0x5a, 0x24, 0xcf, 0xc1, 0x5a, 0x2d, 0x7b, + 0x3e, 0x38, 0xe9, 0xd3, 0x33, 0xa7, 0x57, 0x33, 0xc9, 0x01, 0x3c, 0x5d, 0x89, 0x52, 0xe7, 0x83, + 0xd3, 0xd5, 0xa9, 0xa5, 0xce, 0xd9, 0xcf, 0x5b, 0xdb, 0xb8, 0xb9, 0xb5, 0x8d, 0xbf, 0xb7, 0xb6, + 0xf1, 0xfd, 0xce, 0x2e, 0xdc, 0xdc, 0xd9, 0x85, 0xdf, 0x77, 0x76, 0xe1, 0xeb, 0x71, 0xc4, 0xd5, + 0x38, 0x0b, 0x9a, 0xa1, 0x98, 0xb6, 0xf4, 0x3f, 0x83, 0x4f, 0x34, 0x14, 0x13, 0x04, 0xad, 0xab, + 0xd5, 0x47, 0xaf, 0xae, 0x13, 0x26, 0x83, 0x32, 0xb2, 0x8e, 0xff, 0x07, 0x00, 0x00, 0xff, 0xff, + 0x0d, 0x49, 0xc5, 0x05, 0x18, 0x04, 0x00, 0x00, } func (m *BlockHeader) Marshal() (dAtA []byte, err error) { @@ -530,10 +529,10 @@ func (m *BitcoinSigningRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x20 } - if len(m.TxBytes) > 0 { - i -= len(m.TxBytes) - copy(dAtA[i:], m.TxBytes) - i = encodeVarintBitcoin(dAtA, i, uint64(len(m.TxBytes))) + if len(m.Psbt) > 0 { + i -= len(m.Psbt) + copy(dAtA[i:], m.Psbt) + i = encodeVarintBitcoin(dAtA, i, uint64(len(m.Psbt))) i-- dAtA[i] = 0x1a } @@ -698,7 +697,7 @@ func (m *BitcoinSigningRequest) Size() (n int) { if l > 0 { n += 1 + l + sovBitcoin(uint64(l)) } - l = len(m.TxBytes) + l = len(m.Psbt) if l > 0 { n += 1 + l + sovBitcoin(uint64(l)) } @@ -1125,7 +1124,7 @@ func (m *BitcoinSigningRequest) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TxBytes", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Psbt", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1153,7 +1152,7 @@ func (m *BitcoinSigningRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.TxBytes = string(dAtA[iNdEx:postIndex]) + m.Psbt = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: if wireType != 0 { From 7c746854785b667905036653d98b0e74cc09e2c5 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Fri, 14 Jun 2024 13:34:52 +0800 Subject: [PATCH 23/71] rename module to btcbridge --- app/app.go | 4 ++-- app/keepers/keepers.go | 4 ++-- app/keepers/modules.go | 2 +- app/modules.go | 4 ++-- .../bitcoin.proto | 4 ++-- .../genesis.proto | 8 ++++---- .../{btclightclient => btcbridge}/params.proto | 4 ++-- .../{btclightclient => btcbridge}/query.proto | 18 +++++++++--------- .../{btclightclient => btcbridge}/tx.proto | 8 ++++---- testutil/keeper/btc_light_client.go | 4 ++-- .../client/cli/query.go | 2 +- .../client/cli/tx.go | 2 +- x/{btclightclient => btcbridge}/genesis.go | 4 ++-- .../genesis_test.go | 4 ++-- .../keeper/event.go | 2 +- .../keeper/keeper.go | 2 +- .../keeper/keeper_test.go | 0 .../keeper/keeper_withdraw.go | 4 ++-- .../keeper/msg_server.go | 2 +- .../keeper/queries.go | 2 +- x/{btclightclient => btcbridge}/keeper/util.go | 2 +- x/{btclightclient => btcbridge}/keeper/utxo.go | 0 x/{btclightclient => btcbridge}/module.go | 6 +++--- .../module_simulation.go | 0 .../types/bitcoin.pb.go | 0 x/{btclightclient => btcbridge}/types/codec.go | 0 .../types/errors.go | 0 .../types/expected_keepers.go | 0 .../types/genesis.go | 0 .../types/genesis.pb.go | 0 x/{btclightclient => btcbridge}/types/keys.go | 0 .../types/merkle_proof.go | 0 .../types/message_submit_headers.go | 0 .../types/message_submit_signature.go | 0 .../types/message_submit_transaction.go | 0 .../types/message_update_senders.go | 0 .../types/message_withdraw_bitcoin.go | 0 .../types/params.go | 0 .../types/params.pb.go | 0 .../types/query.pb.go | 0 .../types/query.pb.gw.go | 0 .../types/signature.go | 1 + x/{btclightclient => btcbridge}/types/tx.pb.go | 0 43 files changed, 47 insertions(+), 46 deletions(-) rename proto/side/{btclightclient => btcbridge}/bitcoin.proto (93%) rename proto/side/{btclightclient => btcbridge}/genesis.proto (62%) rename proto/side/{btclightclient => btcbridge}/params.proto (85%) rename proto/side/{btclightclient => btcbridge}/query.proto (81%) rename proto/side/{btclightclient => btcbridge}/tx.proto (93%) rename x/{btclightclient => btcbridge}/client/cli/query.go (98%) rename x/{btclightclient => btcbridge}/client/cli/tx.go (98%) rename x/{btclightclient => btcbridge}/genesis.go (88%) rename x/{btclightclient => btcbridge}/genesis_test.go (97%) rename x/{btclightclient => btcbridge}/keeper/event.go (87%) rename x/{btclightclient => btcbridge}/keeper/keeper.go (99%) rename x/{btclightclient => btcbridge}/keeper/keeper_test.go (100%) rename x/{btclightclient => btcbridge}/keeper/keeper_withdraw.go (97%) rename x/{btclightclient => btcbridge}/keeper/msg_server.go (98%) rename x/{btclightclient => btcbridge}/keeper/queries.go (97%) rename x/{btclightclient => btcbridge}/keeper/util.go (93%) rename x/{btclightclient => btcbridge}/keeper/utxo.go (100%) rename x/{btclightclient => btcbridge}/module.go (97%) rename x/{btclightclient => btcbridge}/module_simulation.go (100%) rename x/{btclightclient => btcbridge}/types/bitcoin.pb.go (100%) rename x/{btclightclient => btcbridge}/types/codec.go (100%) rename x/{btclightclient => btcbridge}/types/errors.go (100%) rename x/{btclightclient => btcbridge}/types/expected_keepers.go (100%) rename x/{btclightclient => btcbridge}/types/genesis.go (100%) rename x/{btclightclient => btcbridge}/types/genesis.pb.go (100%) rename x/{btclightclient => btcbridge}/types/keys.go (100%) rename x/{btclightclient => btcbridge}/types/merkle_proof.go (100%) rename x/{btclightclient => btcbridge}/types/message_submit_headers.go (100%) rename x/{btclightclient => btcbridge}/types/message_submit_signature.go (100%) rename x/{btclightclient => btcbridge}/types/message_submit_transaction.go (100%) rename x/{btclightclient => btcbridge}/types/message_update_senders.go (100%) rename x/{btclightclient => btcbridge}/types/message_withdraw_bitcoin.go (100%) rename x/{btclightclient => btcbridge}/types/params.go (100%) rename x/{btclightclient => btcbridge}/types/params.pb.go (100%) rename x/{btclightclient => btcbridge}/types/query.pb.go (100%) rename x/{btclightclient => btcbridge}/types/query.pb.gw.go (100%) rename x/{btclightclient => btcbridge}/types/signature.go (99%) rename x/{btclightclient => btcbridge}/types/tx.pb.go (100%) diff --git a/app/app.go b/app/app.go index 9467865b..59b099d2 100644 --- a/app/app.go +++ b/app/app.go @@ -60,7 +60,7 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/spf13/cast" - btclightclienttypes "github.com/sideprotocol/side/x/btclightclient/types" + btcbridgetypes "github.com/sideprotocol/side/x/btcbridge/types" gmmmoduletypes "github.com/sideprotocol/side/x/gmm/types" yieldmoduletypes "github.com/sideprotocol/side/x/yield/types" @@ -271,7 +271,7 @@ func New( wasmTypes.ModuleName, gmmmoduletypes.ModuleName, yieldmoduletypes.ModuleName, - btclightclienttypes.ModuleName, + btcbridgetypes.ModuleName, // this line is used by starport scaffolding # stargate/app/initGenesis } app.mm.SetOrderInitGenesis(OrderInitGenesis()...) diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 4ed09599..1c8725c6 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -73,8 +73,8 @@ import ( yieldmodulekeeper "github.com/sideprotocol/side/x/yield/keeper" yieldmoduletypes "github.com/sideprotocol/side/x/yield/types" - btclightclientkeeper "github.com/sideprotocol/side/x/btclightclient/keeper" - btclightclienttypes "github.com/sideprotocol/side/x/btclightclient/types" + btclightclientkeeper "github.com/sideprotocol/side/x/btcbridge/keeper" + btclightclienttypes "github.com/sideprotocol/side/x/btcbridge/types" // this line is used by starport scaffolding # stargate/app/moduleImport diff --git a/app/keepers/modules.go b/app/keepers/modules.go index c4f007f3..222d7e36 100644 --- a/app/keepers/modules.go +++ b/app/keepers/modules.go @@ -38,7 +38,7 @@ import ( yieldmodule "github.com/sideprotocol/side/x/yield" - btcmodule "github.com/sideprotocol/side/x/btclightclient" + btcmodule "github.com/sideprotocol/side/x/btcbridge" // this line is used by starport scaffolding # stargate/app/moduleImport // wasmd module integrate diff --git a/app/modules.go b/app/modules.go index 541f6011..a35f324b 100644 --- a/app/modules.go +++ b/app/modules.go @@ -67,8 +67,8 @@ import ( yieldmodule "github.com/sideprotocol/side/x/yield" yieldmoduletypes "github.com/sideprotocol/side/x/yield/types" - "github.com/sideprotocol/side/x/btclightclient" - btclightclienttypes "github.com/sideprotocol/side/x/btclightclient/types" + btclightclient "github.com/sideprotocol/side/x/btcbridge" + btclightclienttypes "github.com/sideprotocol/side/x/btcbridge/types" // this line is used by starport scaffolding # stargate/app/moduleImport diff --git a/proto/side/btclightclient/bitcoin.proto b/proto/side/btcbridge/bitcoin.proto similarity index 93% rename from proto/side/btclightclient/bitcoin.proto rename to proto/side/btcbridge/bitcoin.proto index 39ce6b3a..3ecbc150 100644 --- a/proto/side/btclightclient/bitcoin.proto +++ b/proto/side/btcbridge/bitcoin.proto @@ -1,9 +1,9 @@ syntax = "proto3"; -package side.btclightclient; +package side.btcbridge; import "gogoproto/gogo.proto"; -option go_package = "github.com/sideprotocol/side/x/btclightclient/types"; +option go_package = "github.com/sideprotocol/side/x/btcbridge/types"; // Bitcoin Block Header message BlockHeader { diff --git a/proto/side/btclightclient/genesis.proto b/proto/side/btcbridge/genesis.proto similarity index 62% rename from proto/side/btclightclient/genesis.proto rename to proto/side/btcbridge/genesis.proto index 3793c359..16674512 100644 --- a/proto/side/btclightclient/genesis.proto +++ b/proto/side/btcbridge/genesis.proto @@ -1,11 +1,11 @@ syntax = "proto3"; -package side.btclightclient; +package side.btcbridge; import "gogoproto/gogo.proto"; -import "side/btclightclient/params.proto"; -import "side/btclightclient/bitcoin.proto"; +import "side/btcbridge/params.proto"; +import "side/btcbridge/bitcoin.proto"; -option go_package = "github.com/sideprotocol/side/x/btclightclient/types"; +option go_package = "github.com/sideprotocol/side/x/btcbridge/types"; // GenesisState defines the btc light client module's genesis state. message GenesisState { diff --git a/proto/side/btclightclient/params.proto b/proto/side/btcbridge/params.proto similarity index 85% rename from proto/side/btclightclient/params.proto rename to proto/side/btcbridge/params.proto index 0bb695ee..d1a66469 100644 --- a/proto/side/btclightclient/params.proto +++ b/proto/side/btcbridge/params.proto @@ -1,9 +1,9 @@ syntax = "proto3"; -package side.btclightclient; +package side.btcbridge; import "gogoproto/gogo.proto"; -option go_package = "github.com/sideprotocol/side/x/btclightclient/types"; +option go_package = "github.com/sideprotocol/side/x/btcbridge/types"; // Params defines the parameters for the module. message Params { diff --git a/proto/side/btclightclient/query.proto b/proto/side/btcbridge/query.proto similarity index 81% rename from proto/side/btclightclient/query.proto rename to proto/side/btcbridge/query.proto index 006e0166..0563d8da 100644 --- a/proto/side/btclightclient/query.proto +++ b/proto/side/btcbridge/query.proto @@ -1,35 +1,35 @@ syntax = "proto3"; -package side.btclightclient; +package side.btcbridge; import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; -import "side/btclightclient/params.proto"; -import "side/btclightclient/bitcoin.proto"; +import "side/btcbridge/params.proto"; +import "side/btcbridge/bitcoin.proto"; -option go_package = "github.com/sideprotocol/side/x/btclightclient/types"; +option go_package = "github.com/sideprotocol/side/x/btcbridge/types"; // Query defines the gRPC querier service. service Query { // Parameters queries the parameters of the module. rpc QueryParams(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/sideprotocol/side/btclightclient/params"; + option (google.api.http).get = "/sideprotocol/side/btcbridge/params"; } // ChainTip queries the chain tip of the module. rpc QueryChainTip(QueryChainTipRequest) returns (QueryChainTipResponse) { - option (google.api.http).get = "/sideprotocol/side/btclightclient/tip"; + option (google.api.http).get = "/sideprotocol/side/btcbridge/tip"; } // BlockHeaderByHeight queries the block header by height. rpc QueryBlockHeaderByHeight(QueryBlockHeaderByHeightRequest) returns (QueryBlockHeaderByHeightResponse) { - option (google.api.http).get = "/sideprotocol/side/btclightclient/height/{height}"; + option (google.api.http).get = "/sideprotocol/side/btcbridge/height/{height}"; } // BlockHeaderByHash queries the block header by hash. rpc QueryBlockHeaderByHash(QueryBlockHeaderByHashRequest) returns (QueryBlockHeaderByHashResponse) { - option (google.api.http).get = "/sideprotocol/side/btclightclient/hash/{hash}"; + option (google.api.http).get = "/sideprotocol/side/btcbridge/hash/{hash}"; } // QuerySigningRequest queries the request to sign. rpc QuerySigningRequest(QuerySigningRequestRequest) returns (QuerySigningRequestResponse) { - option (google.api.http).get = "/sideprotocol/side/btclightclient/signing/request"; + option (google.api.http).get = "/sideprotocol/side/btcbridge/signing/request"; } } diff --git a/proto/side/btclightclient/tx.proto b/proto/side/btcbridge/tx.proto similarity index 93% rename from proto/side/btclightclient/tx.proto rename to proto/side/btcbridge/tx.proto index 99f5eaee..539e7b91 100644 --- a/proto/side/btclightclient/tx.proto +++ b/proto/side/btcbridge/tx.proto @@ -1,12 +1,12 @@ syntax = "proto3"; -package side.btclightclient; +package side.btcbridge; import "gogoproto/gogo.proto"; -import "side/btclightclient/params.proto"; -import "side/btclightclient/bitcoin.proto"; +import "side/btcbridge/params.proto"; +import "side/btcbridge/bitcoin.proto"; -option go_package = "github.com/sideprotocol/side/x/btclightclient/types"; +option go_package = "github.com/sideprotocol/side/x/btcbridge/types"; // Msg defines the Msg service. service Msg { diff --git a/testutil/keeper/btc_light_client.go b/testutil/keeper/btc_light_client.go index fb57d765..00bd0b94 100644 --- a/testutil/keeper/btc_light_client.go +++ b/testutil/keeper/btc_light_client.go @@ -12,8 +12,8 @@ import ( storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/sideprotocol/side/app" - "github.com/sideprotocol/side/x/btclightclient/keeper" - "github.com/sideprotocol/side/x/btclightclient/types" + "github.com/sideprotocol/side/x/btcbridge/keeper" + "github.com/sideprotocol/side/x/btcbridge/types" "github.com/stretchr/testify/require" ) diff --git a/x/btclightclient/client/cli/query.go b/x/btcbridge/client/cli/query.go similarity index 98% rename from x/btclightclient/client/cli/query.go rename to x/btcbridge/client/cli/query.go index 849a8c9a..0faddbec 100644 --- a/x/btclightclient/client/cli/query.go +++ b/x/btcbridge/client/cli/query.go @@ -6,7 +6,7 @@ import ( // "strings" - "github.com/sideprotocol/side/x/btclightclient/types" + "github.com/sideprotocol/side/x/btcbridge/types" "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" diff --git a/x/btclightclient/client/cli/tx.go b/x/btcbridge/client/cli/tx.go similarity index 98% rename from x/btclightclient/client/cli/tx.go rename to x/btcbridge/client/cli/tx.go index 17440ce8..0643cc87 100644 --- a/x/btclightclient/client/cli/tx.go +++ b/x/btcbridge/client/cli/tx.go @@ -14,7 +14,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/tx" // "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/sideprotocol/side/x/btclightclient/types" + "github.com/sideprotocol/side/x/btcbridge/types" ) var DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) diff --git a/x/btclightclient/genesis.go b/x/btcbridge/genesis.go similarity index 88% rename from x/btclightclient/genesis.go rename to x/btcbridge/genesis.go index 4b8c5604..6e5726a4 100644 --- a/x/btclightclient/genesis.go +++ b/x/btcbridge/genesis.go @@ -2,8 +2,8 @@ package btclightclient import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/sideprotocol/side/x/btclightclient/keeper" - "github.com/sideprotocol/side/x/btclightclient/types" + "github.com/sideprotocol/side/x/btcbridge/keeper" + "github.com/sideprotocol/side/x/btcbridge/types" ) // InitGenesis initializes the module's state from a provided genesis state. diff --git a/x/btclightclient/genesis_test.go b/x/btcbridge/genesis_test.go similarity index 97% rename from x/btclightclient/genesis_test.go rename to x/btcbridge/genesis_test.go index 9f5e3e96..bd8071aa 100644 --- a/x/btclightclient/genesis_test.go +++ b/x/btcbridge/genesis_test.go @@ -11,8 +11,8 @@ import ( "github.com/btcsuite/btcd/wire" keepertest "github.com/sideprotocol/side/testutil/keeper" "github.com/sideprotocol/side/testutil/nullify" - "github.com/sideprotocol/side/x/btclightclient" - "github.com/sideprotocol/side/x/btclightclient/types" + btclightclient "github.com/sideprotocol/side/x/btcbridge" + "github.com/sideprotocol/side/x/btcbridge/types" "github.com/stretchr/testify/require" ) diff --git a/x/btclightclient/keeper/event.go b/x/btcbridge/keeper/event.go similarity index 87% rename from x/btclightclient/keeper/event.go rename to x/btcbridge/keeper/event.go index e4219c0e..597e8cbd 100644 --- a/x/btclightclient/keeper/event.go +++ b/x/btcbridge/keeper/event.go @@ -2,7 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/sideprotocol/side/x/btclightclient/types" + "github.com/sideprotocol/side/x/btcbridge/types" ) func (k Keeper) EmitEvent(ctx sdk.Context, sender string, attr ...sdk.Attribute) { diff --git a/x/btclightclient/keeper/keeper.go b/x/btcbridge/keeper/keeper.go similarity index 99% rename from x/btclightclient/keeper/keeper.go rename to x/btcbridge/keeper/keeper.go index 03f6e128..a46f9a34 100644 --- a/x/btclightclient/keeper/keeper.go +++ b/x/btcbridge/keeper/keeper.go @@ -16,7 +16,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/sideprotocol/side/x/btclightclient/types" + "github.com/sideprotocol/side/x/btcbridge/types" ) type ( diff --git a/x/btclightclient/keeper/keeper_test.go b/x/btcbridge/keeper/keeper_test.go similarity index 100% rename from x/btclightclient/keeper/keeper_test.go rename to x/btcbridge/keeper/keeper_test.go diff --git a/x/btclightclient/keeper/keeper_withdraw.go b/x/btcbridge/keeper/keeper_withdraw.go similarity index 97% rename from x/btclightclient/keeper/keeper_withdraw.go rename to x/btcbridge/keeper/keeper_withdraw.go index eaa3ff88..a2a3749b 100644 --- a/x/btclightclient/keeper/keeper_withdraw.go +++ b/x/btcbridge/keeper/keeper_withdraw.go @@ -2,7 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/sideprotocol/side/x/btclightclient/types" + "github.com/sideprotocol/side/x/btcbridge/types" ) // GetRequestSeqence returns the request sequence @@ -37,7 +37,7 @@ func (k Keeper) NewSigningRequest(ctx sdk.Context, sender string, coin sdk.Coin, signingRequest := &types.BitcoinSigningRequest{ Address: sender, - TxBytes: "", + Psbt: "", Status: types.SigningStatus_SIGNING_STATUS_CREATED, Sequence: k.IncrementRequestSequence(ctx), VaultAddress: vault, diff --git a/x/btclightclient/keeper/msg_server.go b/x/btcbridge/keeper/msg_server.go similarity index 98% rename from x/btclightclient/keeper/msg_server.go rename to x/btcbridge/keeper/msg_server.go index acc49f3c..cb2a0c54 100644 --- a/x/btclightclient/keeper/msg_server.go +++ b/x/btcbridge/keeper/msg_server.go @@ -4,7 +4,7 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/sideprotocol/side/x/btclightclient/types" + "github.com/sideprotocol/side/x/btcbridge/types" ) type msgServer struct { diff --git a/x/btclightclient/keeper/queries.go b/x/btcbridge/keeper/queries.go similarity index 97% rename from x/btclightclient/keeper/queries.go rename to x/btcbridge/keeper/queries.go index 47590e50..36b74a77 100644 --- a/x/btclightclient/keeper/queries.go +++ b/x/btcbridge/keeper/queries.go @@ -4,7 +4,7 @@ import ( "context" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/sideprotocol/side/x/btclightclient/types" + "github.com/sideprotocol/side/x/btcbridge/types" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" ) diff --git a/x/btclightclient/keeper/util.go b/x/btcbridge/keeper/util.go similarity index 93% rename from x/btclightclient/keeper/util.go rename to x/btcbridge/keeper/util.go index 8f3706de..56739bdb 100644 --- a/x/btclightclient/keeper/util.go +++ b/x/btcbridge/keeper/util.go @@ -6,7 +6,7 @@ import ( "github.com/btcsuite/btcd/chaincfg/chainhash" "github.com/btcsuite/btcd/wire" - "github.com/sideprotocol/side/x/btclightclient/types" + "github.com/sideprotocol/side/x/btcbridge/types" ) func HeaderConvert(header *types.BlockHeader) *wire.BlockHeader { diff --git a/x/btclightclient/keeper/utxo.go b/x/btcbridge/keeper/utxo.go similarity index 100% rename from x/btclightclient/keeper/utxo.go rename to x/btcbridge/keeper/utxo.go diff --git a/x/btclightclient/module.go b/x/btcbridge/module.go similarity index 97% rename from x/btclightclient/module.go rename to x/btcbridge/module.go index 25d70519..759e0b50 100644 --- a/x/btclightclient/module.go +++ b/x/btcbridge/module.go @@ -17,9 +17,9 @@ import ( cdctypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" - "github.com/sideprotocol/side/x/btclightclient/client/cli" - "github.com/sideprotocol/side/x/btclightclient/keeper" - "github.com/sideprotocol/side/x/btclightclient/types" + "github.com/sideprotocol/side/x/btcbridge/client/cli" + "github.com/sideprotocol/side/x/btcbridge/keeper" + "github.com/sideprotocol/side/x/btcbridge/types" ) var ( diff --git a/x/btclightclient/module_simulation.go b/x/btcbridge/module_simulation.go similarity index 100% rename from x/btclightclient/module_simulation.go rename to x/btcbridge/module_simulation.go diff --git a/x/btclightclient/types/bitcoin.pb.go b/x/btcbridge/types/bitcoin.pb.go similarity index 100% rename from x/btclightclient/types/bitcoin.pb.go rename to x/btcbridge/types/bitcoin.pb.go diff --git a/x/btclightclient/types/codec.go b/x/btcbridge/types/codec.go similarity index 100% rename from x/btclightclient/types/codec.go rename to x/btcbridge/types/codec.go diff --git a/x/btclightclient/types/errors.go b/x/btcbridge/types/errors.go similarity index 100% rename from x/btclightclient/types/errors.go rename to x/btcbridge/types/errors.go diff --git a/x/btclightclient/types/expected_keepers.go b/x/btcbridge/types/expected_keepers.go similarity index 100% rename from x/btclightclient/types/expected_keepers.go rename to x/btcbridge/types/expected_keepers.go diff --git a/x/btclightclient/types/genesis.go b/x/btcbridge/types/genesis.go similarity index 100% rename from x/btclightclient/types/genesis.go rename to x/btcbridge/types/genesis.go diff --git a/x/btclightclient/types/genesis.pb.go b/x/btcbridge/types/genesis.pb.go similarity index 100% rename from x/btclightclient/types/genesis.pb.go rename to x/btcbridge/types/genesis.pb.go diff --git a/x/btclightclient/types/keys.go b/x/btcbridge/types/keys.go similarity index 100% rename from x/btclightclient/types/keys.go rename to x/btcbridge/types/keys.go diff --git a/x/btclightclient/types/merkle_proof.go b/x/btcbridge/types/merkle_proof.go similarity index 100% rename from x/btclightclient/types/merkle_proof.go rename to x/btcbridge/types/merkle_proof.go diff --git a/x/btclightclient/types/message_submit_headers.go b/x/btcbridge/types/message_submit_headers.go similarity index 100% rename from x/btclightclient/types/message_submit_headers.go rename to x/btcbridge/types/message_submit_headers.go diff --git a/x/btclightclient/types/message_submit_signature.go b/x/btcbridge/types/message_submit_signature.go similarity index 100% rename from x/btclightclient/types/message_submit_signature.go rename to x/btcbridge/types/message_submit_signature.go diff --git a/x/btclightclient/types/message_submit_transaction.go b/x/btcbridge/types/message_submit_transaction.go similarity index 100% rename from x/btclightclient/types/message_submit_transaction.go rename to x/btcbridge/types/message_submit_transaction.go diff --git a/x/btclightclient/types/message_update_senders.go b/x/btcbridge/types/message_update_senders.go similarity index 100% rename from x/btclightclient/types/message_update_senders.go rename to x/btcbridge/types/message_update_senders.go diff --git a/x/btclightclient/types/message_withdraw_bitcoin.go b/x/btcbridge/types/message_withdraw_bitcoin.go similarity index 100% rename from x/btclightclient/types/message_withdraw_bitcoin.go rename to x/btcbridge/types/message_withdraw_bitcoin.go diff --git a/x/btclightclient/types/params.go b/x/btcbridge/types/params.go similarity index 100% rename from x/btclightclient/types/params.go rename to x/btcbridge/types/params.go diff --git a/x/btclightclient/types/params.pb.go b/x/btcbridge/types/params.pb.go similarity index 100% rename from x/btclightclient/types/params.pb.go rename to x/btcbridge/types/params.pb.go diff --git a/x/btclightclient/types/query.pb.go b/x/btcbridge/types/query.pb.go similarity index 100% rename from x/btclightclient/types/query.pb.go rename to x/btcbridge/types/query.pb.go diff --git a/x/btclightclient/types/query.pb.gw.go b/x/btcbridge/types/query.pb.gw.go similarity index 100% rename from x/btclightclient/types/query.pb.gw.go rename to x/btcbridge/types/query.pb.gw.go diff --git a/x/btclightclient/types/signature.go b/x/btcbridge/types/signature.go similarity index 99% rename from x/btclightclient/types/signature.go rename to x/btcbridge/types/signature.go index 17b18a6a..de9e436d 100644 --- a/x/btclightclient/types/signature.go +++ b/x/btcbridge/types/signature.go @@ -1,5 +1,6 @@ package types func (m *BitcoinSigningRequest) ValidateSignatures(sigs []string) bool { + return false } diff --git a/x/btclightclient/types/tx.pb.go b/x/btcbridge/types/tx.pb.go similarity index 100% rename from x/btclightclient/types/tx.pb.go rename to x/btcbridge/types/tx.pb.go From 9d843c692d1d4d4628ad3c2d3e88f9357321fd8c Mon Sep 17 00:00:00 2001 From: sufay Date: Sat, 15 Jun 2024 00:30:18 +0800 Subject: [PATCH 24/71] complete btc withdrawal --- go.mod | 4 + go.sum | 4 + proto/side/btclightclient/tx.proto | 2 + x/btclightclient/keeper/keeper_withdraw.go | 31 +++- x/btclightclient/keeper/msg_server.go | 5 +- x/btclightclient/types/bitcoin_transaction.go | 169 ++++++++++++++++++ x/btclightclient/types/errors.go | 6 + .../types/message_withdraw_bitcoin.go | 10 +- x/btclightclient/types/tx.pb.go | 111 ++++++++---- 9 files changed, 296 insertions(+), 46 deletions(-) create mode 100644 x/btclightclient/types/bitcoin_transaction.go diff --git a/go.mod b/go.mod index 0da0cb9e..df8c84f1 100644 --- a/go.mod +++ b/go.mod @@ -35,6 +35,7 @@ require ( github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/aead/siphash v1.0.1 // indirect github.com/armon/go-metrics v0.4.1 // indirect github.com/aws/aws-sdk-go v1.44.203 // indirect github.com/beorn7/perks v1.0.1 // indirect @@ -128,6 +129,7 @@ require ( github.com/jhump/protoreflect v1.15.6 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jmhodges/levigo v1.0.0 // indirect + github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 // indirect github.com/klauspost/compress v1.16.7 // indirect github.com/klauspost/pgzip v1.2.5 // indirect github.com/kr/pretty v0.3.1 // indirect @@ -171,6 +173,7 @@ require ( github.com/spf13/afero v1.9.5 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/viper v1.16.0 // indirect + github.com/stretchr/objx v0.5.0 // indirect github.com/subosito/gotenv v1.4.2 // indirect github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect github.com/tendermint/go-amino v0.16.0 // indirect @@ -215,6 +218,7 @@ require ( github.com/Stride-Labs/stride/v16 v16.0.0 github.com/btcsuite/btcd v0.24.1-0.20240318151728-2fc99e0496d2 github.com/btcsuite/btcd/btcutil v1.1.5 + github.com/btcsuite/btcd/btcutil/psbt v1.1.9 github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 github.com/bufbuild/buf v1.7.0 github.com/cosmos/cosmos-proto v1.0.0-beta.4 diff --git a/go.sum b/go.sum index fdac66a0..a203d034 100644 --- a/go.sum +++ b/go.sum @@ -235,6 +235,7 @@ github.com/Stride-Labs/stride/v16 v16.0.0/go.mod h1:0I+YGZ6EiuN8XCbeg+KHpo+gge+R github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I= +github.com/aead/siphash v1.0.1 h1:FwHfE/T45KPKYuuSAKyyvE+oPWcaQ+CUmFW0bPlM+kg= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -281,6 +282,8 @@ github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9Ur github.com/btcsuite/btcd/btcutil v1.1.0/go.mod h1:5OapHB7A2hBBWLm48mmw4MOHNJCcUBTwmWH/0Jn8VHE= github.com/btcsuite/btcd/btcutil v1.1.5 h1:+wER79R5670vs/ZusMTF1yTcRYE5GUsFbdjdisflzM8= github.com/btcsuite/btcd/btcutil v1.1.5/go.mod h1:PSZZ4UitpLBWzxGd5VGOrLnmOjtPP/a6HaFo12zMs00= +github.com/btcsuite/btcd/btcutil/psbt v1.1.9 h1:UmfOIiWMZcVMOLaN+lxbbLSuoINGS1WmK1TZNI0b4yk= +github.com/btcsuite/btcd/btcutil/psbt v1.1.9/go.mod h1:ehBEvU91lxSlXtA+zZz3iFYx7Yq9eqnKx4/kSrnsvMY= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 h1:59Kx4K6lzOW5w6nFlA0v5+lk/6sjybR934QNHSJZPTQ= @@ -754,6 +757,7 @@ github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7V github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 h1:FOOIBWrEkLgmlgGfMuZT83xIwfPDxEI2OHu6xUmJMFE= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= diff --git a/proto/side/btclightclient/tx.proto b/proto/side/btclightclient/tx.proto index 99f5eaee..a99337b9 100644 --- a/proto/side/btclightclient/tx.proto +++ b/proto/side/btclightclient/tx.proto @@ -64,6 +64,8 @@ message MsgWithdrawBitcoinRequest { string sender = 1; // withdraw amount in satoshi, etc: 100000000sat = 1btc string amount = 2; + // fee rate in sats/vB + int64 fee_rate = 3; } // MsgWithdrawBitcoinResponse defines the Msg/WithdrawBitcoin response type. diff --git a/x/btclightclient/keeper/keeper_withdraw.go b/x/btclightclient/keeper/keeper_withdraw.go index eaa3ff88..e1307d35 100644 --- a/x/btclightclient/keeper/keeper_withdraw.go +++ b/x/btclightclient/keeper/keeper_withdraw.go @@ -28,16 +28,35 @@ func (k Keeper) IncrementRequestSequence(ctx sdk.Context) uint64 { // txBytes: the transaction bytes // vault: the address of the vault, default is empty. // If empty, the vault will be Bitcoin vault, otherwise it will be Ordinals or Runes vault -func (k Keeper) NewSigningRequest(ctx sdk.Context, sender string, coin sdk.Coin, vault string) *types.BitcoinSigningRequest { +func (k Keeper) NewSigningRequest(ctx sdk.Context, sender string, coin sdk.Coin, feeRate int64, vault string) (*types.BitcoinSigningRequest, error) { + if len(vault) == 0 { + // default to the first vault in the params for now + // TODO: select an appropriate vault according to the utxos + vault = k.GetParams(ctx).Senders[0] + } + + utxos := k.GetOrderedUTXOsByAddr(ctx, vault) + if len(utxos) == 0 { + return nil, types.ErrInsufficientUTXOs + } - // create a new bitcoin transaction - // tx := wire.NewMsgTx(wire.TxVersion) + psbt, selectedUTXOs, err := types.BuildPsbt(utxos, sender, coin.Amount.Int64(), feeRate, vault) + if err != nil { + return nil, types.ErrFailToBuildTransaction + } + + psbtB64, err := psbt.B64Encode() + if err != nil { + return nil, types.ErrFailToSerializePsbt + } - // outScript, err := txscript.PayToAddrScript(sender) + // lock the selected utxos + k.LockUTXOs(ctx, selectedUTXOs) signingRequest := &types.BitcoinSigningRequest{ Address: sender, - TxBytes: "", + Txid: psbt.UnsignedTx.TxHash().String(), + TxBytes: psbtB64, Status: types.SigningStatus_SIGNING_STATUS_CREATED, Sequence: k.IncrementRequestSequence(ctx), VaultAddress: vault, @@ -47,7 +66,7 @@ func (k Keeper) NewSigningRequest(ctx sdk.Context, sender string, coin sdk.Coin, bz := k.cdc.MustMarshal(signingRequest) store.Set(types.BtcSigningRequestKey(signingRequest.Sequence), bz) - return signingRequest + return signingRequest, nil } // GetSigningRequest returns the signing request diff --git a/x/btclightclient/keeper/msg_server.go b/x/btclightclient/keeper/msg_server.go index acc49f3c..d6767f7a 100644 --- a/x/btclightclient/keeper/msg_server.go +++ b/x/btclightclient/keeper/msg_server.go @@ -111,7 +111,10 @@ func (m msgServer) WithdrawBitcoin(goCtx context.Context, msg *types.MsgWithdraw m.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, types.ModuleName, sdk.NewCoins(coin)) - //request := types.BitcoinSigningRequest(sender, coin) + _, err = m.Keeper.NewSigningRequest(ctx, msg.Sender, coin, msg.FeeRate, "") + if err != nil { + return nil, err + } // Emit events m.EmitEvent(ctx, msg.Sender, diff --git a/x/btclightclient/types/bitcoin_transaction.go b/x/btclightclient/types/bitcoin_transaction.go new file mode 100644 index 00000000..72e55ef2 --- /dev/null +++ b/x/btclightclient/types/bitcoin_transaction.go @@ -0,0 +1,169 @@ +package types + +import ( + "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/btcutil/psbt" + "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/mempool" + "github.com/btcsuite/btcd/txscript" + "github.com/btcsuite/btcd/wire" +) + +const ( + // default tx version + TxVersion = 2 + + // default minimum relay fee + MinRelayFee = 1000 +) + +// BuildPsbt builds a bitcoin psbt from the given params. +// Assume that the utxo script type is witness. +func BuildPsbt(utxos []*UTXO, recipient string, amount int64, feeRate int64, change string) (*psbt.Packet, []*UTXO, error) { + recipientAddr, err := btcutil.DecodeAddress(recipient, ChainCfg) + if err != nil { + return nil, nil, err + } + + recipientPkScript, err := txscript.PayToAddrScript(recipientAddr) + if err != nil { + return nil, nil, err + } + + changeAddr, err := btcutil.DecodeAddress(change, ChainCfg) + if err != nil { + return nil, nil, err + } + + txOuts := make([]*wire.TxOut, 0) + txOuts = append(txOuts, wire.NewTxOut(amount, recipientPkScript)) + + unsignedTx, selectedUTXOs, err := BuildUnsignedTransaction(utxos, txOuts, feeRate, changeAddr) + if err != nil { + return nil, nil, err + } + + p, err := psbt.NewFromUnsignedTx(unsignedTx) + if err != nil { + return nil, nil, err + } + + for i, utxo := range selectedUTXOs { + p.Inputs[i].SighashType = txscript.SigHashAll + p.Inputs[i].WitnessUtxo = wire.NewTxOut(int64(utxo.Amount), utxo.PubKeyScript) + } + + return p, selectedUTXOs, nil +} + +// BuildUnsignedTransaction builds an unsigned tx from the given params. +func BuildUnsignedTransaction(utxos []*UTXO, txOuts []*wire.TxOut, feeRate int64, change btcutil.Address) (*wire.MsgTx, []*UTXO, error) { + tx := wire.NewMsgTx(TxVersion) + + outAmount := int64(0) + for _, txOut := range txOuts { + if mempool.IsDust(txOut, MinRelayFee) { + return nil, nil, ErrDustOutput + } + + tx.AddTxOut(txOut) + outAmount += txOut.Value + } + + changePkScript, err := txscript.PayToAddrScript(change) + if err != nil { + return nil, nil, err + } + + changeOut := wire.NewTxOut(0, changePkScript) + + selectedUTXOs, err := AddUTXOsToTx(tx, utxos, outAmount, changeOut, feeRate) + if err != nil { + return nil, nil, err + } + + return tx, selectedUTXOs, nil +} + +// AddUTXOsToTx adds the given utxos to the tx. +func AddUTXOsToTx(tx *wire.MsgTx, utxos []*UTXO, outAmount int64, changeOut *wire.TxOut, feeRate int64) ([]*UTXO, error) { + selectedUTXOs := make([]*UTXO, 0) + inputAmount := int64(0) + + for _, utxo := range utxos { + txIn := new(wire.TxIn) + + hash, err := chainhash.NewHashFromStr(utxo.Txid) + if err != nil { + return nil, err + } + + txIn.PreviousOutPoint = *wire.NewOutPoint(hash, uint32(utxo.Vout)) + + tx.AddTxIn(txIn) + tx.AddTxOut(changeOut) + + selectedUTXOs = append(selectedUTXOs, utxo) + + inputAmount += int64(utxo.Amount) + fee := GetTxVirtualSize(tx, utxos) * feeRate + + changeValue := inputAmount - outAmount - fee + if changeValue > 0 { + tx.TxOut[len(tx.TxOut)-1].Value = changeValue + if mempool.IsDust(tx.TxOut[len(tx.TxOut)-1], btcutil.Amount(MinRelayFee)) { + tx.TxOut = tx.TxOut[0 : len(tx.TxOut)-1] + } + + return selectedUTXOs, nil + } else { + tx.TxOut = tx.TxOut[0 : len(tx.TxOut)-1] + + if changeValue == 0 { + return selectedUTXOs, nil + } + + if changeValue < 0 { + feeWithoutChange := GetTxVirtualSize(tx, selectedUTXOs) * feeRate + if inputAmount-outAmount-feeWithoutChange >= 0 { + return selectedUTXOs, nil + } + } + } + } + + return nil, ErrInsufficientUTXOs +} + +// GetTxVirtualSize gets the virtual size of the given tx. +// Assume that the utxo script type is p2tr, p2wpkh, p2sh-p2wpkh or p2pkh. +func GetTxVirtualSize(tx *wire.MsgTx, utxos []*UTXO) int64 { + newTx := tx.Copy() + + for i, txIn := range newTx.TxIn { + var dummySigScript []byte + var dummyWitness []byte + + switch txscript.GetScriptClass(utxos[i].PubKeyScript) { + case txscript.WitnessV1TaprootTy: + dummyWitness = make([]byte, 64) + + case txscript.WitnessV0PubKeyHashTy: + dummyWitness = make([]byte, 72+33) + + case txscript.ScriptHashTy: + dummySigScript = make([]byte, 1+1+1+20) + dummyWitness = make([]byte, 72+33) + + case txscript.PubKeyHashTy: + dummySigScript = make([]byte, 1+72+1+33) + + default: + } + + txIn.SignatureScript = dummySigScript + txIn.Witness = wire.TxWitness{dummyWitness} + } + + return mempool.GetTxVirtualSize(btcutil.NewTx(newTx)) +} diff --git a/x/btclightclient/types/errors.go b/x/btclightclient/types/errors.go index 41bee256..f44591ce 100644 --- a/x/btclightclient/types/errors.go +++ b/x/btclightclient/types/errors.go @@ -28,4 +28,10 @@ var ( ErrUTXODoesNotExist = errorsmod.Register(ModuleName, 5100, "utxo does not exist") ErrUTXOLocked = errorsmod.Register(ModuleName, 5101, "utxo locked") ErrUTXOUnlocked = errorsmod.Register(ModuleName, 5102, "utxo unlocked") + + ErrInvalidFeeRate = errorsmod.Register(ModuleName, 6100, "invalid fee rate") + ErrDustOutput = errorsmod.Register(ModuleName, 6101, "dust output value") + ErrInsufficientUTXOs = errorsmod.Register(ModuleName, 6102, "insufficient utxos") + ErrFailToBuildTransaction = errorsmod.Register(ModuleName, 6103, "failed to build transaction") + ErrFailToSerializePsbt = errorsmod.Register(ModuleName, 6104, "failed to serialize psbt") ) diff --git a/x/btclightclient/types/message_withdraw_bitcoin.go b/x/btclightclient/types/message_withdraw_bitcoin.go index a0609415..49a01611 100644 --- a/x/btclightclient/types/message_withdraw_bitcoin.go +++ b/x/btclightclient/types/message_withdraw_bitcoin.go @@ -10,10 +10,12 @@ const TypeMsgWithdrawBitcoin = "withdraw_bitcoin" func NewMsgWithdrawBitcoinRequest( sender string, amount string, + feeRate int64, ) *MsgWithdrawBitcoinRequest { return &MsgWithdrawBitcoinRequest{ - Sender: sender, - Amount: amount, + Sender: sender, + Amount: amount, + FeeRate: feeRate, } } @@ -48,5 +50,9 @@ func (msg *MsgWithdrawBitcoinRequest) ValidateBasic() error { return sdkerrors.Wrap(sdk.ErrInvalidLengthCoin, "amount cannot be empty") } + if msg.FeeRate <= 0 { + return sdkerrors.Wrap(ErrInvalidFeeRate, "fee rate must be greater than zero") + } + return nil } diff --git a/x/btclightclient/types/tx.pb.go b/x/btclightclient/types/tx.pb.go index 5342e7f2..b42953f6 100644 --- a/x/btclightclient/types/tx.pb.go +++ b/x/btclightclient/types/tx.pb.go @@ -331,6 +331,8 @@ type MsgWithdrawBitcoinRequest struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` // withdraw amount in satoshi, etc: 100000000sat = 1btc Amount string `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount,omitempty"` + // fee rate in sats/vB + FeeRate int64 `protobuf:"varint,3,opt,name=fee_rate,json=feeRate,proto3" json:"fee_rate,omitempty"` } func (m *MsgWithdrawBitcoinRequest) Reset() { *m = MsgWithdrawBitcoinRequest{} } @@ -380,6 +382,13 @@ func (m *MsgWithdrawBitcoinRequest) GetAmount() string { return "" } +func (m *MsgWithdrawBitcoinRequest) GetFeeRate() int64 { + if m != nil { + return m.FeeRate + } + return 0 +} + // MsgWithdrawBitcoinResponse defines the Msg/WithdrawBitcoin response type. type MsgWithdrawBitcoinResponse struct { } @@ -531,43 +540,44 @@ func init() { func init() { proto.RegisterFile("side/btclightclient/tx.proto", fileDescriptor_4df07798138ba91c) } var fileDescriptor_4df07798138ba91c = []byte{ - // 562 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94,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5, 0x7d, 0xd0, 0x69, 0xb9, 0x25, 0xf6, 0xdd, 0x45, 0xde, 0x9b, 0xfe, 0x65, 0x21, 0x9c, - 0x07, 0x70, 0xbf, 0x4c, 0x5d, 0xf4, 0x89, 0x48, 0x59, 0x22, 0x88, 0xf3, 0xd3, 0x58, 0xf0, 0x77, - 0xca, 0x71, 0x22, 0x70, 0x20, 0x29, 0x4b, 0x36, 0xf9, 0x6b, 0x42, 0x5d, 0x09, 0xc5, 0x58, 0xc4, - 0xe6, 0xae, 0x6a, 0x5d, 0x6e, 0x20, 0x07, 0x1a, 0x29, 0x27, 0x9f, 0x87, 0x32, 0x1b, 0xfa, 0x67, - 0x92, 0x08, 0xb3, 0xa2, 0x10, 0x07, 0xf9, 0xe6, 0x69, 0xd6, 0xcd, 0xb7, 0xd0, 0x31, 0xdc, 0x98, - 0xb7, 0xab, 0xaa, 0xbd, 0x2f, 0x75, 0xeb, 0x10, 0xf6, 0x52, 0xce, 0xd8, 0x07, 0x73, 0xaf, 0x55, - 0x69, 0xd7, 0xfb, 0x45, 0xe1, 0xd8, 0xd0, 0x2c, 0x77, 0xaa, 0x47, 0x79, 0x03, 0x77, 0x7b, 0x22, - 0x7a, 0x9b, 0x86, 0x58, 0x92, 0x81, 0x72, 0x29, 0x36, 0x4d, 0x61, 0xc2, 0x7e, 0xb1, 0x2a, 0xee, - 0xb7, 0xde, 0xbf, 0x28, 0x1d, 0x0b, 0xcc, 0x65, 0xb2, 0xb9, 0xd0, 0x71, 0x4f, 0x44, 0xef, 0xa8, - 0x8c, 0x43, 0x8e, 0xbf, 0x74, 0x8b, 0xbf, 0x7b, 0x93, 0xd4, 0x11, 0xd4, 0xf0, 0x98, 0x4d, 0x12, - 0xa9, 0x6f, 0x4b, 0x57, 0x4e, 0x13, 0xac, 0x32, 0x32, 0x2d, 0x95, 0x82, 0x33, 0x9f, 0xf9, 0x02, - 0x33, 0xa0, 0x51, 0x82, 0xe5, 0x84, 0x93, 0x8d, 0xe3, 0x21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0x2c, 0x06, - 0x00, 0x00, + // 581 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0xcd, 0x6e, 0xd3, 0x40, + 0x18, 0x8c, 0xeb, 0x34, 0x21, 0x5f, 0x89, 0x10, 0x4b, 0x55, 0x5c, 0x13, 0x4c, 0x30, 0x42, 0xca, + 0x01, 0x6c, 0x48, 0x0f, 0x70, 0x8e, 0x84, 0x84, 0x84, 0x72, 0x71, 0x8a, 0x90, 0xb8, 0x44, 0x6b, + 0x7b, 0x63, 0x5b, 0x24, 0x5e, 0xe3, 0xdd, 0x80, 0x8b, 0x78, 0x05, 0x24, 0x1e, 0x83, 0x47, 0xe1, + 0xd8, 0x23, 0x47, 0x94, 0x9c, 0x79, 0x07, 0xe4, 0xf5, 0x36, 0x4d, 0x1b, 0xe7, 0xa7, 0x97, 0x68, + 0xbf, 0xfd, 0x66, 0xbf, 0x99, 0x9d, 0x8c, 0x6d, 0x68, 0xb1, 0xc8, 0x27, 0xb6, 0xcb, 0xbd, 0x71, + 0x14, 0x84, 0xf9, 0x2f, 0x89, 0xb9, 0xcd, 0x33, 0x2b, 0x49, 0x29, 0xa7, 0xe8, 0x5e, 0xde, 0xb5, + 0xae, 0x76, 0xf5, 0xc3, 0x80, 0x06, 0x54, 0xf4, 0xed, 0x7c, 0x55, 0x40, 0xf5, 0x76, 0xd9, 0xa0, + 0x04, 0xa7, 0x78, 0xc2, 0x24, 0xe2, 0x71, 0x19, 0xc2, 0x8d, 0xb8, 0x47, 0xa3, 0xb8, 0x80, 0x98, + 0xdf, 0xe1, 0x41, 0x9f, 0x05, 0x83, 0xa9, 0x3b, 0x89, 0x78, 0x6f, 0x4c, 0xbd, 0x4f, 0x6f, 0x09, + 0xf6, 0x49, 0xea, 0x90, 0xcf, 0x53, 0xc2, 0x38, 0x3a, 0x82, 0x1a, 0x23, 0xb1, 0x4f, 0x52, 0x4d, + 0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1, 0xd4, 0xb5, + 0x3c, 0x3a, 0xb1, 0xf3, 0xe9, 0xe2, 0x8d, 0xec, 0xd1, 0xb1, 0x28, 0xec, 0x6c, 0xe5, 0x1b, 0x71, + 0x96, 0x10, 0xe6, 0xd6, 0x04, 0xea, 0xe4, 0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x22, 0x54, 0x79, + 0xb7, 0x47, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1036,6 +1046,11 @@ func (m *MsgWithdrawBitcoinRequest) MarshalToSizedBuffer(dAtA []byte) (int, erro _ = i var l int _ = l + if m.FeeRate != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.FeeRate)) + i-- + dAtA[i] = 0x18 + } if len(m.Amount) > 0 { i -= len(m.Amount) copy(dAtA[i:], m.Amount) @@ -1266,6 +1281,9 @@ func (m *MsgWithdrawBitcoinRequest) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } + if m.FeeRate != 0 { + n += 1 + sovTx(uint64(m.FeeRate)) + } return n } @@ -1999,6 +2017,25 @@ func (m *MsgWithdrawBitcoinRequest) Unmarshal(dAtA []byte) error { } m.Amount = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field FeeRate", wireType) + } + m.FeeRate = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.FeeRate |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) From 9955bdc4de898c64d6bbdda4832b75867991933d Mon Sep 17 00:00:00 2001 From: sufay Date: Sat, 15 Jun 2024 01:27:59 +0800 Subject: [PATCH 25/71] optimize btc deposit --- x/btclightclient/keeper/keeper.go | 14 +++++++++++--- x/btclightclient/keeper/utxo.go | 12 +++++++----- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/x/btclightclient/keeper/keeper.go b/x/btclightclient/keeper/keeper.go index 9160bcc2..42791e18 100644 --- a/x/btclightclient/keeper/keeper.go +++ b/x/btclightclient/keeper/keeper.go @@ -241,6 +241,7 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg return types.ErrTransactionNotIncluded } + // mint voucher token and save utxo if the receiver is a vault address for i, out := range uTx.MsgTx().TxOut { // check if the output is a valid address pks, err := txscript.ParsePkScript(out.PkScript) @@ -252,9 +253,8 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg return err } - // TODO remove the true // check if the receiver is one of the voucher addresses - if true || slices.Contains(param.BtcVoucherAddress, addr.EncodeAddress()) { + if slices.Contains(param.BtcVoucherAddress, addr.EncodeAddress()) { // mint the voucher token coins := sdk.NewCoins(sdk.NewCoin(param.BtcVoucherDenom, sdk.NewInt(out.Value))) senderAddr, err := sdk.AccAddressFromBech32(sender.EncodeAddress()) @@ -279,9 +279,17 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg k.SetOwnerUTXO(ctx, &utxo) ctx.Logger().Info("Minted Bitcoin Voucher", "index", i, "address", addr.EncodeAddress(), "amount", out.Value, "sender", sender.EncodeAddress(), "senderAddr", senderAddr.String(), "coins", coins.String()) - } + } + // spend locked utxos + for _, in := range uTx.MsgTx().TxIn { + hash := in.PreviousOutPoint.Hash.String() + vout := in.PreviousOutPoint.Index + + if k.IsUTXOLocked(ctx, hash, uint64(vout)) { + k.SpendUTXO(ctx, hash, uint64(vout)) + } } return nil diff --git a/x/btclightclient/keeper/utxo.go b/x/btclightclient/keeper/utxo.go index 9c4110dc..fd701012 100644 --- a/x/btclightclient/keeper/utxo.go +++ b/x/btclightclient/keeper/utxo.go @@ -13,7 +13,7 @@ import ( type UTXOViewKeeper interface { HasUTXO(ctx sdk.Context, hash string, vout uint64) bool - IsUTXOLocked(ctx sdk.Context, hash string, vout uint64) (bool, error) + IsUTXOLocked(ctx sdk.Context, hash string, vout uint64) bool GetUTXO(ctx sdk.Context, hash string, vout uint64) *types.UTXO GetAllUTXOs(ctx sdk.Context) []*types.UTXO @@ -58,14 +58,16 @@ func (bvk *BaseUTXOViewKeeper) HasUTXO(ctx sdk.Context, hash string, vout uint64 return store.Has(types.BtcUtxoKey(hash, vout)) } -func (bvk *BaseUTXOViewKeeper) IsUTXOLocked(ctx sdk.Context, hash string, vout uint64) (bool, error) { +// IsUTXOLocked returns true if the given utxo is locked, false otherwise. +// Note: it returns false if the given utxo does not exist. +func (bvk *BaseUTXOViewKeeper) IsUTXOLocked(ctx sdk.Context, hash string, vout uint64) bool { if !bvk.HasUTXO(ctx, hash, vout) { - return false, types.ErrUTXODoesNotExist + return false } utxo := bvk.GetUTXO(ctx, hash, vout) - return utxo.IsLocked, nil + return utxo.IsLocked } func (bvk *BaseUTXOViewKeeper) GetUTXO(ctx sdk.Context, hash string, vout uint64) *types.UTXO { @@ -126,7 +128,7 @@ func (bvk *BaseUTXOViewKeeper) GetOrderedUTXOsByAddr(ctx sdk.Context, addr strin return false }) - // sort utoxs in the descending order + // sort utxos in the descending order sort.SliceStable(utxos, func(i int, j int) bool { return utxos[i].Amount > utxos[j].Amount }) From 9aadd2360207be394cb44c1064aa1bef701b4037 Mon Sep 17 00:00:00 2001 From: sufay Date: Sat, 15 Jun 2024 02:14:53 +0800 Subject: [PATCH 26/71] comment out SetBtcChainCfg for now --- cmd/sided/cmd/config.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/sided/cmd/config.go b/cmd/sided/cmd/config.go index 8b0e2de3..614391c7 100644 --- a/cmd/sided/cmd/config.go +++ b/cmd/sided/cmd/config.go @@ -1,7 +1,6 @@ package cmd import ( - "github.com/btcsuite/btcd/chaincfg" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -19,7 +18,7 @@ func initSDKConfig() { config.SetBech32PrefixForAccount(bech32Prefix, accountPubKeyPrefix) config.SetBech32PrefixForValidator(validatorAddressPrefix, validatorPubKeyPrefix) config.SetBech32PrefixForConsensusNode(consNodeAddressPrefix, consNodePubKeyPrefix) - config.SetBtcChainCfg(&chaincfg.SigNetParams) + // config.SetBtcChainCfg(&chaincfg.SigNetParams) config.Seal() } From 662da08fb83190faa9658e4b2861a2a33cd09a00 Mon Sep 17 00:00:00 2001 From: sufay Date: Sat, 15 Jun 2024 11:26:49 +0800 Subject: [PATCH 27/71] improve utxos spending logic --- x/btcbridge/keeper/keeper.go | 16 +++++++++------- x/btcbridge/keeper/utxo.go | 3 +++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/x/btcbridge/keeper/keeper.go b/x/btcbridge/keeper/keeper.go index 9e05033d..66be1bf0 100644 --- a/x/btcbridge/keeper/keeper.go +++ b/x/btcbridge/keeper/keeper.go @@ -282,13 +282,15 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg } } - // spend locked utxos - for _, in := range uTx.MsgTx().TxIn { - hash := in.PreviousOutPoint.Hash.String() - vout := in.PreviousOutPoint.Index - - if k.IsUTXOLocked(ctx, hash, uint64(vout)) { - k.SpendUTXO(ctx, hash, uint64(vout)) + // spend locked utxos if the sender is a vault address + if slices.Contains(param.BtcVoucherAddress, sender.EncodeAddress()) { + for _, in := range uTx.MsgTx().TxIn { + hash := in.PreviousOutPoint.Hash.String() + vout := in.PreviousOutPoint.Index + + if k.IsUTXOLocked(ctx, hash, uint64(vout)) { + k.SpendUTXO(ctx, hash, uint64(vout)) + } } } diff --git a/x/btcbridge/keeper/utxo.go b/x/btcbridge/keeper/utxo.go index add5ca8a..c1c61e7b 100644 --- a/x/btcbridge/keeper/utxo.go +++ b/x/btcbridge/keeper/utxo.go @@ -272,8 +272,11 @@ func (bk *BaseUTXOKeeper) SpendUTXOs(ctx sdk.Context, utxos []*types.UTXO) error return nil } +// removeUTXO deletes the given utxo which is assumed to exist. func (bk *BaseUTXOKeeper) removeUTXO(ctx sdk.Context, hash string, vout uint64) { store := ctx.KVStore(bk.storeKey) + utxo := bk.GetUTXO(ctx, hash, vout) store.Delete(types.BtcUtxoKey(hash, vout)) + store.Delete(types.BtcOwnerUtxoKey(utxo.Address, hash, vout)) } From d1b9f2ab7eaff0e35e4399d83413e4552c7acde0 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Sun, 16 Jun 2024 10:25:37 +0800 Subject: [PATCH 28/71] use pbst instead rawtransaction --- proto/side/btcbridge/tx.proto | 2 +- x/btcbridge/keeper/keeper_withdraw.go | 12 +- x/btcbridge/keeper/msg_server.go | 30 ++- x/btcbridge/types/bitcoin.pb.go | 102 +++++----- x/btcbridge/types/errors.go | 5 +- x/btcbridge/types/genesis.pb.go | 46 ++--- x/btcbridge/types/keys.go | 5 + x/btcbridge/types/message_submit_signature.go | 17 +- x/btcbridge/types/params.pb.go | 50 ++--- x/btcbridge/types/query.pb.go | 165 ++++++++------- x/btcbridge/types/query.pb.gw.go | 12 +- x/btcbridge/types/tx.pb.go | 189 +++++++++--------- 12 files changed, 329 insertions(+), 306 deletions(-) diff --git a/proto/side/btcbridge/tx.proto b/proto/side/btcbridge/tx.proto index 4f3ec9be..0b022d5e 100644 --- a/proto/side/btcbridge/tx.proto +++ b/proto/side/btcbridge/tx.proto @@ -76,7 +76,7 @@ message MsgWithdrawBitcoinResponse { message MsgSubmitWithdrawSignaturesRequest { string sender = 1; string txid = 2; - repeated string signatures = 3; + string psbt = 3; } // MsgSubmitWithdrawSignaturesResponse defines the Msg/SubmitWithdrawSignatures response type. diff --git a/x/btcbridge/keeper/keeper_withdraw.go b/x/btcbridge/keeper/keeper_withdraw.go index 11f65865..b31fdae2 100644 --- a/x/btcbridge/keeper/keeper_withdraw.go +++ b/x/btcbridge/keeper/keeper_withdraw.go @@ -69,22 +69,28 @@ func (k Keeper) NewSigningRequest(ctx sdk.Context, sender string, coin sdk.Coin, return signingRequest, nil } +// GetSigningRequest returns the signing request +func (k Keeper) HasSigningRequest(ctx sdk.Context, hash string) bool { + store := ctx.KVStore(k.storeKey) + return store.Has(types.BtcSigningRequestHashKey(hash)) +} + // GetSigningRequest returns the signing request func (k Keeper) GetSigningRequest(ctx sdk.Context, hash string) *types.BitcoinSigningRequest { store := ctx.KVStore(k.storeKey) var signingRequest types.BitcoinSigningRequest // TODO replace the key with the hash - bz := store.Get(types.BtcSigningRequestKey(1)) + bz := store.Get(types.BtcSigningRequestHashKey(hash)) k.cdc.MustUnmarshal(bz, &signingRequest) return &signingRequest } // SetSigningRequest sets the signing request -func (k Keeper) SetSigningRequest(ctx sdk.Context, txHash string, signingRequest *types.BitcoinSigningRequest) { +func (k Keeper) SetSigningRequest(ctx sdk.Context, signingRequest *types.BitcoinSigningRequest) { store := ctx.KVStore(k.storeKey) bz := k.cdc.MustMarshal(signingRequest) // TODO replace the key with the hash - store.Set(types.BtcSigningRequestKey(1), bz) + store.Set(types.BtcSigningRequestHashKey(signingRequest.Txid), bz) } // IterateSigningRequests iterates through all signing requests diff --git a/x/btcbridge/keeper/msg_server.go b/x/btcbridge/keeper/msg_server.go index 710234a6..53246b5f 100644 --- a/x/btcbridge/keeper/msg_server.go +++ b/x/btcbridge/keeper/msg_server.go @@ -1,8 +1,11 @@ package keeper import ( + "bytes" "context" + "encoding/base64" + "github.com/btcsuite/btcd/btcutil/psbt" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/sideprotocol/side/x/btcbridge/types" ) @@ -130,12 +133,33 @@ func (m msgServer) SubmitWithdrawSignatures(goCtx context.Context, msg *types.Ms return nil, err } ctx := sdk.UnwrapSDKContext(goCtx) - request := m.GetSigningRequest(ctx, msg.Txid) - // request. - if ok := request.ValidateSignatures(msg.Signatures); !ok { + exist := m.HasSigningRequest(ctx, msg.Txid) + if !exist { + return nil, types.ErrSigningRequestNotExist + } + + b, err := base64.StdEncoding.DecodeString(msg.Psbt) + if err != nil { return nil, types.ErrInvalidSignatures + } + packet, err := psbt.NewFromRawBytes(bytes.NewReader(b), false) + if err != nil { + return nil, err } + if err = packet.SanityCheck(); err != nil { + return nil, err + } + if !packet.IsComplete() { + return nil, types.ErrInvalidSignatures + } + + // Set the signing request status to signed + request := m.GetSigningRequest(ctx, msg.Txid) + request.Psbt = msg.Psbt + request.Status = types.SigningStatus_SIGNING_STATUS_SIGNED + m.SetSigningRequest(ctx, request) + return &types.MsgSubmitWithdrawSignaturesResponse{}, nil } diff --git a/x/btcbridge/types/bitcoin.pb.go b/x/btcbridge/types/bitcoin.pb.go index 86555dda..5bc6120f 100644 --- a/x/btcbridge/types/bitcoin.pb.go +++ b/x/btcbridge/types/bitcoin.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: side/btclightclient/bitcoin.proto +// source: side/btcbridge/bitcoin.proto package types @@ -64,7 +64,7 @@ func (x SigningStatus) String() string { } func (SigningStatus) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_d7dee3af17ecec77, []int{0} + return fileDescriptor_b004a69efe3c7d84, []int{0} } // Bitcoin Block Header @@ -84,7 +84,7 @@ func (m *BlockHeader) Reset() { *m = BlockHeader{} } func (m *BlockHeader) String() string { return proto.CompactTextString(m) } func (*BlockHeader) ProtoMessage() {} func (*BlockHeader) Descriptor() ([]byte, []int) { - return fileDescriptor_d7dee3af17ecec77, []int{0} + return fileDescriptor_b004a69efe3c7d84, []int{0} } func (m *BlockHeader) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -181,7 +181,7 @@ type BitcoinSigningRequest struct { Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` Txid string `protobuf:"bytes,2,opt,name=txid,proto3" json:"txid,omitempty"` Psbt string `protobuf:"bytes,3,opt,name=psbt,proto3" json:"psbt,omitempty"` - Status SigningStatus `protobuf:"varint,4,opt,name=status,proto3,enum=side.btclightclient.SigningStatus" json:"status,omitempty"` + Status SigningStatus `protobuf:"varint,4,opt,name=status,proto3,enum=side.btcbridge.SigningStatus" json:"status,omitempty"` Sequence uint64 `protobuf:"varint,5,opt,name=sequence,proto3" json:"sequence,omitempty"` // The vault address that the request is associated with VaultAddress string `protobuf:"bytes,6,opt,name=vault_address,json=vaultAddress,proto3" json:"vault_address,omitempty"` @@ -191,7 +191,7 @@ func (m *BitcoinSigningRequest) Reset() { *m = BitcoinSigningRequest{} } func (m *BitcoinSigningRequest) String() string { return proto.CompactTextString(m) } func (*BitcoinSigningRequest) ProtoMessage() {} func (*BitcoinSigningRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_d7dee3af17ecec77, []int{1} + return fileDescriptor_b004a69efe3c7d84, []int{1} } func (m *BitcoinSigningRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -279,7 +279,7 @@ func (m *UTXO) Reset() { *m = UTXO{} } func (m *UTXO) String() string { return proto.CompactTextString(m) } func (*UTXO) ProtoMessage() {} func (*UTXO) Descriptor() ([]byte, []int) { - return fileDescriptor_d7dee3af17ecec77, []int{2} + return fileDescriptor_b004a69efe3c7d84, []int{2} } func (m *UTXO) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -365,55 +365,55 @@ func (m *UTXO) GetIsLocked() bool { } func init() { - proto.RegisterEnum("side.btclightclient.SigningStatus", SigningStatus_name, SigningStatus_value) - proto.RegisterType((*BlockHeader)(nil), "side.btclightclient.BlockHeader") - proto.RegisterType((*BitcoinSigningRequest)(nil), "side.btclightclient.BitcoinSigningRequest") - proto.RegisterType((*UTXO)(nil), "side.btclightclient.UTXO") + proto.RegisterEnum("side.btcbridge.SigningStatus", SigningStatus_name, SigningStatus_value) + proto.RegisterType((*BlockHeader)(nil), "side.btcbridge.BlockHeader") + proto.RegisterType((*BitcoinSigningRequest)(nil), "side.btcbridge.BitcoinSigningRequest") + proto.RegisterType((*UTXO)(nil), "side.btcbridge.UTXO") } -func init() { proto.RegisterFile("side/btclightclient/bitcoin.proto", fileDescriptor_d7dee3af17ecec77) } +func init() { proto.RegisterFile("side/btcbridge/bitcoin.proto", fileDescriptor_b004a69efe3c7d84) } -var fileDescriptor_d7dee3af17ecec77 = []byte{ - // 616 bytes of a gzipped FileDescriptorProto +var fileDescriptor_b004a69efe3c7d84 = []byte{ + // 613 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x53, 0xcd, 0x6e, 0xd3, 0x40, - 0x10, 0x8e, 0x1b, 0x27, 0x4d, 0xa6, 0x3f, 0x0a, 0xdb, 0x1f, 0x4c, 0x8a, 0x4c, 0x09, 0x1c, 0x2a, - 0x0e, 0x89, 0x44, 0x6f, 0xdc, 0xf2, 0xe3, 0x96, 0x00, 0x4d, 0xd1, 0x3a, 0x95, 0x10, 0x17, 0xcb, - 0x76, 0x56, 0xce, 0xaa, 0x89, 0xd7, 0x78, 0xd7, 0x51, 0xfb, 0x16, 0xbc, 0x12, 0x37, 0x8e, 0x3d, - 0x21, 0x0e, 0x1c, 0x50, 0xfb, 0x0a, 0x3c, 0x00, 0xda, 0x71, 0x52, 0x35, 0x51, 0x2f, 0xd6, 0x7c, - 0x33, 0xdf, 0xcc, 0x7c, 0x33, 0xe3, 0x85, 0x97, 0x92, 0x8f, 0x58, 0x2b, 0x50, 0xe1, 0x84, 0x47, - 0x63, 0xfd, 0x65, 0xb1, 0x6a, 0x05, 0x5c, 0x85, 0x82, 0xc7, 0xcd, 0x24, 0x15, 0x4a, 0x90, 0x1d, - 0x4d, 0x69, 0x2e, 0x53, 0xea, 0xbb, 0x91, 0x88, 0x04, 0xc6, 0x5b, 0xda, 0xca, 0xa9, 0x8d, 0x7f, - 0x06, 0x6c, 0x74, 0x26, 0x22, 0xbc, 0x7c, 0xcf, 0xfc, 0x11, 0x4b, 0x89, 0x05, 0xeb, 0x33, 0x96, - 0x4a, 0x2e, 0x62, 0xcb, 0x38, 0x34, 0x8e, 0x4c, 0xba, 0x80, 0x84, 0x80, 0x39, 0xf6, 0xe5, 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1, 0xa9, 0xe7, 0x8e, 0x3a, 0xa3, 0x0b, 0xd7, 0xbb, 0x18, 0xba, 0x9f, 0x9c, 0xde, 0xe0, + 0x64, 0xe0, 0xf4, 0x9b, 0x25, 0xd2, 0x82, 0xbd, 0x95, 0x78, 0x8f, 0x3a, 0x9d, 0x91, 0xd3, 0x6f, + 0x1a, 0xe4, 0x29, 0xec, 0xae, 0xc4, 0x34, 0x75, 0xfa, 0xcd, 0xb5, 0xff, 0x94, 0xed, 0xd2, 0xf3, + 0x4e, 0xbf, 0xd7, 0x71, 0xf5, 0xd3, 0x32, 0x39, 0x00, 0x73, 0xb5, 0xec, 0xf9, 0xf0, 0x64, 0x40, + 0x3f, 0x3a, 0xfd, 0x66, 0x85, 0xec, 0xc3, 0x93, 0x95, 0x28, 0x75, 0xde, 0x39, 0x3d, 0xfd, 0xb4, + 0xda, 0x3d, 0xfb, 0x71, 0x6b, 0x19, 0x37, 0xb7, 0x96, 0xf1, 0xe7, 0xd6, 0x32, 0xbe, 0xdd, 0x59, + 0xa5, 0x9b, 0x3b, 0xab, 0xf4, 0xeb, 0xce, 0x2a, 0x7d, 0xb1, 0x63, 0xae, 0xc6, 0x79, 0x60, 0x87, + 0x62, 0xda, 0xd6, 0x9f, 0x0b, 0xfe, 0x9d, 0xa1, 0x98, 0x20, 0x69, 0x5f, 0x3d, 0xf8, 0xcb, 0xd5, + 0x75, 0xca, 0x64, 0x50, 0xc3, 0x84, 0x37, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0x8b, 0x6e, 0xf2, + 0x5a, 0x04, 0x04, 0x00, 0x00, } func (m *BlockHeader) Marshal() (dAtA []byte, err error) { diff --git a/x/btcbridge/types/errors.go b/x/btcbridge/types/errors.go index f44591ce..0cd2863d 100644 --- a/x/btcbridge/types/errors.go +++ b/x/btcbridge/types/errors.go @@ -22,8 +22,9 @@ var ( ErrExceedMaxAcceptanceDepth = errorsmod.Register(ModuleName, 3201, "exceed max acceptance block depth") ErrUnsupportedScriptType = errorsmod.Register(ModuleName, 3202, "unsupported script type") - ErrInvalidSignatures = errorsmod.Register(ModuleName, 4200, "invalid signatures") - ErrInsufficientBalance = errorsmod.Register(ModuleName, 4201, "insufficient balance") + ErrInvalidSignatures = errorsmod.Register(ModuleName, 4200, "invalid signatures") + ErrInsufficientBalance = errorsmod.Register(ModuleName, 4201, "insufficient balance") + ErrSigningRequestNotExist = errorsmod.Register(ModuleName, 4202, "signing request does not exist") ErrUTXODoesNotExist = errorsmod.Register(ModuleName, 5100, "utxo does not exist") ErrUTXOLocked = errorsmod.Register(ModuleName, 5101, "utxo locked") diff --git a/x/btcbridge/types/genesis.pb.go b/x/btcbridge/types/genesis.pb.go index 2df0fdf4..af319567 100644 --- a/x/btcbridge/types/genesis.pb.go +++ b/x/btcbridge/types/genesis.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: side/btclightclient/genesis.proto +// source: side/btcbridge/genesis.proto package types @@ -35,7 +35,7 @@ func (m *GenesisState) Reset() { *m = GenesisState{} } func (m *GenesisState) String() string { return proto.CompactTextString(m) } func (*GenesisState) ProtoMessage() {} func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_84e124efbd6ad9f4, []int{0} + return fileDescriptor_37c22954cf4a954b, []int{0} } func (m *GenesisState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -86,30 +86,30 @@ func (m *GenesisState) GetBlockHeaders() []*BlockHeader { } func init() { - proto.RegisterType((*GenesisState)(nil), "side.btclightclient.GenesisState") + proto.RegisterType((*GenesisState)(nil), "side.btcbridge.GenesisState") } -func init() { proto.RegisterFile("side/btclightclient/genesis.proto", fileDescriptor_84e124efbd6ad9f4) } +func init() { proto.RegisterFile("side/btcbridge/genesis.proto", fileDescriptor_37c22954cf4a954b) } -var fileDescriptor_84e124efbd6ad9f4 = []byte{ - // 268 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2c, 0xce, 0x4c, 0x49, - 0xd5, 0x4f, 0x2a, 0x49, 0xce, 0xc9, 0x4c, 0xcf, 0x00, 0x91, 0xa9, 0x79, 0x25, 0xfa, 0xe9, 0xa9, - 0x79, 0xa9, 0xc5, 0x99, 0xc5, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0xc2, 0x20, 0x25, 0x7a, - 0xa8, 0x4a, 0xa4, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0xf2, 0xfa, 0x20, 0x16, 0x44, 0xa9, 0x94, - 0x02, 0x36, 0xd3, 0x0a, 0x12, 0x8b, 0x12, 0x73, 0xa1, 0x86, 0x49, 0x61, 0xb5, 0x2f, 0x29, 0xb3, - 0x24, 0x39, 0x3f, 0x33, 0x0f, 0xa2, 0x44, 0xe9, 0x1e, 0x23, 0x17, 0x8f, 0x3b, 0xc4, 0x05, 0xc1, - 0x25, 0x89, 0x25, 0xa9, 0x42, 0x96, 0x5c, 0x6c, 0x10, 0x33, 0x24, 0x18, 0x15, 0x18, 0x35, 0xb8, - 0x8d, 0xa4, 0xf5, 0xb0, 0xb8, 0x48, 0x2f, 0x00, 0xac, 0xc4, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, - 0x20, 0xa8, 0x06, 0x21, 0x1f, 0x2e, 0xc1, 0xa4, 0xd4, 0xe2, 0x92, 0xf8, 0xa4, 0x9c, 0xfc, 0xe4, - 0xec, 0xf8, 0x8c, 0xd4, 0xc4, 0x94, 0xd4, 0x22, 0x09, 0x26, 0xb0, 0x29, 0x0a, 0x58, 0x4d, 0x71, - 0x02, 0x29, 0xf4, 0x00, 0xab, 0x0b, 0xe2, 0x07, 0x69, 0x45, 0x12, 0x10, 0x72, 0xe5, 0xe2, 0x45, - 0x36, 0xa8, 0x58, 0x82, 0x59, 0x81, 0x99, 0x28, 0x93, 0x78, 0x92, 0x10, 0x9c, 0x62, 0x27, 0xdf, - 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, - 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x32, 0x4e, 0xcf, 0x2c, 0xc9, 0x28, - 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x07, 0x99, 0x09, 0x0e, 0x90, 0xe4, 0xfc, 0x1c, 0x30, 0x47, - 0xbf, 0x02, 0x3d, 0xdc, 0x4a, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0xaa, 0x8c, 0x01, 0x01, - 0x00, 0x00, 0xff, 0xff, 0x3f, 0x41, 0x33, 0x45, 0xcb, 0x01, 0x00, 0x00, +var fileDescriptor_37c22954cf4a954b = []byte{ + // 264 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x29, 0xce, 0x4c, 0x49, + 0xd5, 0x4f, 0x2a, 0x49, 0x4e, 0x2a, 0xca, 0x4c, 0x49, 0x4f, 0xd5, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, + 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x03, 0xc9, 0xea, 0xc1, 0x65, 0xa5, + 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x52, 0xfa, 0x20, 0x16, 0x44, 0x95, 0x94, 0x34, 0x9a, 0x19, + 0x05, 0x89, 0x45, 0x89, 0xb9, 0x50, 0x23, 0xa4, 0xd0, 0x2d, 0x48, 0xca, 0x2c, 0x49, 0xce, 0xcf, + 0xcc, 0x83, 0xc8, 0x2a, 0x9d, 0x67, 0xe4, 0xe2, 0x71, 0x87, 0x58, 0x19, 0x5c, 0x92, 0x58, 0x92, + 0x2a, 0x64, 0xc2, 0xc5, 0x06, 0xd1, 0x2e, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xa6, 0x87, + 0xea, 0x04, 0xbd, 0x00, 0xb0, 0xac, 0x13, 0xcb, 0x89, 0x7b, 0xf2, 0x0c, 0x41, 0x50, 0xb5, 0x42, + 0xee, 0x5c, 0x82, 0x49, 0xa9, 0xc5, 0x25, 0xf1, 0x49, 0x39, 0xf9, 0xc9, 0xd9, 0xf1, 0x19, 0xa9, + 0x89, 0x29, 0xa9, 0x45, 0x12, 0x4c, 0x60, 0x03, 0xa4, 0xd1, 0x0d, 0x70, 0x02, 0xa9, 0xf1, 0x00, + 0x2b, 0x09, 0xe2, 0x07, 0xe9, 0x42, 0x12, 0x10, 0x72, 0xe0, 0xe2, 0x45, 0x36, 0xa3, 0x58, 0x82, + 0x59, 0x81, 0x99, 0x90, 0x21, 0x3c, 0x49, 0x08, 0x4e, 0xb1, 0x93, 0xc7, 0x89, 0x47, 0x72, 0x8c, + 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, + 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xe9, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, + 0xe7, 0xea, 0x83, 0x8c, 0x03, 0x87, 0x40, 0x72, 0x7e, 0x0e, 0x98, 0xa3, 0x5f, 0x81, 0x14, 0x46, + 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0x05, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, + 0x89, 0x77, 0xfa, 0xdb, 0xa3, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { diff --git a/x/btcbridge/types/keys.go b/x/btcbridge/types/keys.go index 3e66d3fd..134ddcda 100644 --- a/x/btcbridge/types/keys.go +++ b/x/btcbridge/types/keys.go @@ -62,6 +62,11 @@ func BtcBlockHeaderHeightKey(height uint64) []byte { return append(BtcBlockHeaderHeightPrefix, Int64ToBytes(height)...) } +// @deprecated, use BtcSigningRequestHashKey instead func BtcSigningRequestKey(sequence uint64) []byte { return append(BtcSigningRequestPrefix, Int64ToBytes(sequence)...) } + +func BtcSigningRequestHashKey(txid string) []byte { + return append(BtcSigningRequestPrefix, []byte(txid)...) +} diff --git a/x/btcbridge/types/message_submit_signature.go b/x/btcbridge/types/message_submit_signature.go index 23c72ec1..caf736c8 100644 --- a/x/btcbridge/types/message_submit_signature.go +++ b/x/btcbridge/types/message_submit_signature.go @@ -10,12 +10,12 @@ const TypeMsgSubmitSignature = "submit_signature" func NewMsgSubmitWithdrawSignaturesRequest( sender string, txid string, - signatures []string, + pbst string, ) *MsgSubmitWithdrawSignaturesRequest { return &MsgSubmitWithdrawSignaturesRequest{ - Sender: sender, - Txid: txid, - Signatures: signatures, + Sender: sender, + Txid: txid, + Psbt: pbst, } } @@ -50,16 +50,9 @@ func (msg *MsgSubmitWithdrawSignaturesRequest) ValidateBasic() error { return sdkerrors.Wrap(ErrInvalidSignatures, "txid cannot be empty") } - if len(msg.Signatures) == 0 { + if len(msg.Psbt) == 0 { return sdkerrors.Wrap(ErrInvalidSignatures, "sigatures cannot be empty") } - for _, signature := range msg.Signatures { - if len(signature) == 0 { - return sdkerrors.Wrap(ErrInvalidSignatures, "signature cannot be empty") - - } - } - return nil } diff --git a/x/btcbridge/types/params.pb.go b/x/btcbridge/types/params.pb.go index 27760ed9..3366f111 100644 --- a/x/btcbridge/types/params.pb.go +++ b/x/btcbridge/types/params.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: side/btclightclient/params.proto +// source: side/btcbridge/params.proto package types @@ -41,7 +41,7 @@ func (m *Params) Reset() { *m = Params{} } func (m *Params) String() string { return proto.CompactTextString(m) } func (*Params) ProtoMessage() {} func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_3b47f8b78acf6f6e, []int{0} + return fileDescriptor_f1d33573cda8a6d2, []int{0} } func (m *Params) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -106,32 +106,32 @@ func (m *Params) GetBtcVoucherAddress() []string { } func init() { - proto.RegisterType((*Params)(nil), "side.btclightclient.Params") + proto.RegisterType((*Params)(nil), "side.btcbridge.Params") } -func init() { proto.RegisterFile("side/btclightclient/params.proto", fileDescriptor_3b47f8b78acf6f6e) } +func init() { proto.RegisterFile("side/btcbridge/params.proto", fileDescriptor_f1d33573cda8a6d2) } -var fileDescriptor_3b47f8b78acf6f6e = []byte{ - // 295 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x90, 0xbb, 0x6a, 0xf3, 0x30, - 0x00, 0x85, 0xa3, 0x3f, 0x97, 0x9f, 0x08, 0x4a, 0x89, 0x52, 0xa8, 0xc8, 0x20, 0x4c, 0xe9, 0x60, - 0x3a, 0xd8, 0x43, 0xc6, 0x4e, 0x09, 0x59, 0x0b, 0xc5, 0x43, 0x87, 0x2e, 0x46, 0xb7, 0xda, 0xa6, - 0x96, 0x65, 0x24, 0xa5, 0xa4, 0x6f, 0xd1, 0xc7, 0xea, 0x98, 0xb1, 0x63, 0x1b, 0xbf, 0x48, 0x91, - 0x4c, 0x2f, 0xe9, 0x22, 0x74, 0xce, 0xf7, 0x09, 0xc4, 0x81, 0x91, 0xad, 0x84, 0x4c, 0x99, 0xe3, - 0x75, 0x55, 0x94, 0xfe, 0x94, 0x8d, 0x4b, 0x5b, 0x6a, 0xa8, 0xb2, 0x49, 0x6b, 0xb4, 0xd3, 0x68, - 0xee, 0x8d, 0xe4, 0xd8, 0x58, 0x9c, 0x15, 0xba, 0xd0, 0x81, 0xa7, 0xfe, 0xd6, 0xab, 0x17, 0x1f, - 0x00, 0x4e, 0x6e, 0xc3, 0x5b, 0x84, 0xe1, 0x7f, 0x2b, 0x1b, 0x21, 0x8d, 0xc5, 0x20, 0x1a, 0xc6, - 0xd3, 0xec, 0x2b, 0xa2, 0x4b, 0x78, 0xc2, 0x75, 0xf3, 0x50, 0x19, 0x45, 0x5d, 0xa5, 0x1b, 0x8b, - 0xff, 0x45, 0x20, 0x1e, 0x67, 0xc7, 0x25, 0xba, 0x86, 0x0b, 0x45, 0x77, 0x39, 0xe5, 0x5c, 0xb6, - 0x8e, 0xb2, 0x5a, 0xe6, 0xac, 0xd6, 0xfc, 0x31, 0x17, 0xb2, 0x75, 0x25, 0x1e, 0x46, 0x20, 0x1e, - 0x65, 0xe7, 0x8a, 0xee, 0x56, 0xdf, 0xc2, 0xda, 0xf3, 0x8d, 0xc7, 0xe8, 0x0a, 0xce, 0x98, 0xe3, - 0xf9, 0x93, 0xde, 0xf2, 0x52, 0x9a, 0x5c, 0xc8, 0x46, 0x2b, 0x3c, 0x8a, 0x40, 0x3c, 0xcd, 0x4e, - 0x99, 0xe3, 0x77, 0x7d, 0xbf, 0xf1, 0x35, 0x4a, 0xe0, 0xfc, 0xb7, 0x4b, 0x85, 0x30, 0xd2, 0x5a, - 0x3c, 0x0e, 0x9f, 0x9e, 0xfd, 0xd8, 0xab, 0x1e, 0xac, 0x6f, 0x5e, 0x0f, 0x04, 0xec, 0x0f, 0x04, - 0xbc, 0x1f, 0x08, 0x78, 0xe9, 0xc8, 0x60, 0xdf, 0x91, 0xc1, 0x5b, 0x47, 0x06, 0xf7, 0xcb, 0xa2, - 0x72, 0xe5, 0x96, 0x25, 0x5c, 0xab, 0xd4, 0x6f, 0x16, 0x36, 0xe1, 0xba, 0x0e, 0x21, 0xdd, 0xfd, - 0x1d, 0xd9, 0x3d, 0xb7, 0xd2, 0xb2, 0x49, 0xb0, 0x96, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0xce, - 0x86, 0x0b, 0x4d, 0x88, 0x01, 0x00, 0x00, +var fileDescriptor_f1d33573cda8a6d2 = []byte{ + // 292 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x90, 0xbd, 0x4e, 0xf3, 0x30, + 0x18, 0x85, 0xeb, 0xaf, 0x3f, 0x9f, 0x6a, 0x09, 0x50, 0x0d, 0x12, 0x56, 0x91, 0xac, 0x08, 0x31, + 0x44, 0x0c, 0xc9, 0xc0, 0xc8, 0xd4, 0xaa, 0x03, 0x23, 0xca, 0xc0, 0xc0, 0x12, 0xf9, 0x8f, 0x34, + 0xa2, 0x8e, 0x23, 0xdb, 0x45, 0xe1, 0x2e, 0xb8, 0x2c, 0xc6, 0x8e, 0x8c, 0x90, 0xdc, 0x08, 0xb2, + 0x23, 0x4a, 0xd9, 0x7c, 0xce, 0xf3, 0x58, 0x7a, 0x75, 0xe0, 0x85, 0x2d, 0x85, 0x4c, 0x99, 0xe3, + 0xcc, 0x94, 0xa2, 0x90, 0x69, 0x4d, 0x0d, 0x55, 0x36, 0xa9, 0x8d, 0x76, 0x1a, 0x1d, 0x7b, 0x98, + 0xec, 0xe1, 0xfc, 0xac, 0xd0, 0x85, 0x0e, 0x28, 0xf5, 0xaf, 0xde, 0xba, 0xfc, 0x02, 0x70, 0x72, + 0x1f, 0xbe, 0x21, 0x0c, 0xff, 0x5b, 0x59, 0x09, 0x69, 0x2c, 0x06, 0xd1, 0x30, 0x9e, 0x66, 0x3f, + 0x11, 0x5d, 0xc1, 0x23, 0xae, 0xab, 0xa7, 0xd2, 0x28, 0xea, 0x4a, 0x5d, 0x59, 0xfc, 0x2f, 0x02, + 0xf1, 0x38, 0xfb, 0x5b, 0xa2, 0x5b, 0x38, 0x57, 0xb4, 0xc9, 0x29, 0xe7, 0xb2, 0x76, 0x94, 0x6d, + 0x64, 0xce, 0x36, 0x9a, 0x3f, 0xe7, 0x42, 0xd6, 0x6e, 0x8d, 0x87, 0x11, 0x88, 0x47, 0xd9, 0xb9, + 0xa2, 0xcd, 0x62, 0x2f, 0x2c, 0x3d, 0x5f, 0x79, 0x8c, 0xae, 0xe1, 0x8c, 0x39, 0x9e, 0xbf, 0xe8, + 0x2d, 0x5f, 0x4b, 0x93, 0x0b, 0x59, 0x69, 0x85, 0x47, 0x11, 0x88, 0xa7, 0xd9, 0x09, 0x73, 0xfc, + 0xa1, 0xef, 0x57, 0xbe, 0x46, 0x09, 0x3c, 0x3d, 0x74, 0xa9, 0x10, 0x46, 0x5a, 0x8b, 0xc7, 0xe1, + 0xe8, 0xd9, 0xaf, 0xbd, 0xe8, 0xc1, 0xf2, 0xee, 0xbd, 0x25, 0x60, 0xd7, 0x12, 0xf0, 0xd9, 0x12, + 0xf0, 0xd6, 0x91, 0xc1, 0xae, 0x23, 0x83, 0x8f, 0x8e, 0x0c, 0x1e, 0x93, 0xa2, 0x74, 0xeb, 0x2d, + 0x4b, 0xb8, 0x56, 0xa9, 0x9f, 0x2b, 0x6c, 0xc2, 0xf5, 0x26, 0x84, 0xb4, 0x39, 0x98, 0xd6, 0xbd, + 0xd6, 0xd2, 0xb2, 0x49, 0x10, 0x6e, 0xbe, 0x03, 0x00, 0x00, 0xff, 0xff, 0xfa, 0x67, 0x7f, 0x23, + 0x79, 0x01, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { diff --git a/x/btcbridge/types/query.pb.go b/x/btcbridge/types/query.pb.go index 95123eca..f96008d8 100644 --- a/x/btcbridge/types/query.pb.go +++ b/x/btcbridge/types/query.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: side/btclightclient/query.proto +// source: side/btcbridge/query.proto package types @@ -32,7 +32,7 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // QuerySigningRequestRequest is request type for the Query/SigningRequest RPC method. type QuerySigningRequestRequest struct { - Status SigningStatus `protobuf:"varint,1,opt,name=status,proto3,enum=side.btclightclient.SigningStatus" json:"status,omitempty"` + Status SigningStatus `protobuf:"varint,1,opt,name=status,proto3,enum=side.btcbridge.SigningStatus" json:"status,omitempty"` Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } @@ -40,7 +40,7 @@ func (m *QuerySigningRequestRequest) Reset() { *m = QuerySigningRequestR func (m *QuerySigningRequestRequest) String() string { return proto.CompactTextString(m) } func (*QuerySigningRequestRequest) ProtoMessage() {} func (*QuerySigningRequestRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f299b49d16182dbc, []int{0} + return fileDescriptor_fb547edb49d5502d, []int{0} } func (m *QuerySigningRequestRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -93,7 +93,7 @@ func (m *QuerySigningRequestResponse) Reset() { *m = QuerySigningRequest func (m *QuerySigningRequestResponse) String() string { return proto.CompactTextString(m) } func (*QuerySigningRequestResponse) ProtoMessage() {} func (*QuerySigningRequestResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f299b49d16182dbc, []int{1} + return fileDescriptor_fb547edb49d5502d, []int{1} } func (m *QuerySigningRequestResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -144,7 +144,7 @@ func (m *QueryParamsRequest) Reset() { *m = QueryParamsRequest{} } func (m *QueryParamsRequest) String() string { return proto.CompactTextString(m) } func (*QueryParamsRequest) ProtoMessage() {} func (*QueryParamsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f299b49d16182dbc, []int{2} + return fileDescriptor_fb547edb49d5502d, []int{2} } func (m *QueryParamsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -183,7 +183,7 @@ func (m *QueryParamsResponse) Reset() { *m = QueryParamsResponse{} } func (m *QueryParamsResponse) String() string { return proto.CompactTextString(m) } func (*QueryParamsResponse) ProtoMessage() {} func (*QueryParamsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f299b49d16182dbc, []int{3} + return fileDescriptor_fb547edb49d5502d, []int{3} } func (m *QueryParamsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -227,7 +227,7 @@ func (m *QueryChainTipRequest) Reset() { *m = QueryChainTipRequest{} } func (m *QueryChainTipRequest) String() string { return proto.CompactTextString(m) } func (*QueryChainTipRequest) ProtoMessage() {} func (*QueryChainTipRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f299b49d16182dbc, []int{4} + return fileDescriptor_fb547edb49d5502d, []int{4} } func (m *QueryChainTipRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -266,7 +266,7 @@ func (m *QueryChainTipResponse) Reset() { *m = QueryChainTipResponse{} } func (m *QueryChainTipResponse) String() string { return proto.CompactTextString(m) } func (*QueryChainTipResponse) ProtoMessage() {} func (*QueryChainTipResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f299b49d16182dbc, []int{5} + return fileDescriptor_fb547edb49d5502d, []int{5} } func (m *QueryChainTipResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -318,7 +318,7 @@ func (m *QueryBlockHeaderByHeightRequest) Reset() { *m = QueryBlockHeade func (m *QueryBlockHeaderByHeightRequest) String() string { return proto.CompactTextString(m) } func (*QueryBlockHeaderByHeightRequest) ProtoMessage() {} func (*QueryBlockHeaderByHeightRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f299b49d16182dbc, []int{6} + return fileDescriptor_fb547edb49d5502d, []int{6} } func (m *QueryBlockHeaderByHeightRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -363,7 +363,7 @@ func (m *QueryBlockHeaderByHeightResponse) Reset() { *m = QueryBlockHead func (m *QueryBlockHeaderByHeightResponse) String() string { return proto.CompactTextString(m) } func (*QueryBlockHeaderByHeightResponse) ProtoMessage() {} func (*QueryBlockHeaderByHeightResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f299b49d16182dbc, []int{7} + return fileDescriptor_fb547edb49d5502d, []int{7} } func (m *QueryBlockHeaderByHeightResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -408,7 +408,7 @@ func (m *QueryBlockHeaderByHashRequest) Reset() { *m = QueryBlockHeaderB func (m *QueryBlockHeaderByHashRequest) String() string { return proto.CompactTextString(m) } func (*QueryBlockHeaderByHashRequest) ProtoMessage() {} func (*QueryBlockHeaderByHashRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_f299b49d16182dbc, []int{8} + return fileDescriptor_fb547edb49d5502d, []int{8} } func (m *QueryBlockHeaderByHashRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -453,7 +453,7 @@ func (m *QueryBlockHeaderByHashResponse) Reset() { *m = QueryBlockHeader func (m *QueryBlockHeaderByHashResponse) String() string { return proto.CompactTextString(m) } func (*QueryBlockHeaderByHashResponse) ProtoMessage() {} func (*QueryBlockHeaderByHashResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f299b49d16182dbc, []int{9} + return fileDescriptor_fb547edb49d5502d, []int{9} } func (m *QueryBlockHeaderByHashResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -490,65 +490,64 @@ func (m *QueryBlockHeaderByHashResponse) GetBlockHeader() *BlockHeader { } func init() { - proto.RegisterType((*QuerySigningRequestRequest)(nil), "side.btclightclient.QuerySigningRequestRequest") - proto.RegisterType((*QuerySigningRequestResponse)(nil), "side.btclightclient.QuerySigningRequestResponse") - proto.RegisterType((*QueryParamsRequest)(nil), "side.btclightclient.QueryParamsRequest") - proto.RegisterType((*QueryParamsResponse)(nil), "side.btclightclient.QueryParamsResponse") - proto.RegisterType((*QueryChainTipRequest)(nil), "side.btclightclient.QueryChainTipRequest") - proto.RegisterType((*QueryChainTipResponse)(nil), "side.btclightclient.QueryChainTipResponse") - proto.RegisterType((*QueryBlockHeaderByHeightRequest)(nil), "side.btclightclient.QueryBlockHeaderByHeightRequest") - proto.RegisterType((*QueryBlockHeaderByHeightResponse)(nil), "side.btclightclient.QueryBlockHeaderByHeightResponse") - proto.RegisterType((*QueryBlockHeaderByHashRequest)(nil), "side.btclightclient.QueryBlockHeaderByHashRequest") - proto.RegisterType((*QueryBlockHeaderByHashResponse)(nil), "side.btclightclient.QueryBlockHeaderByHashResponse") -} - -func init() { proto.RegisterFile("side/btclightclient/query.proto", fileDescriptor_f299b49d16182dbc) } - -var fileDescriptor_f299b49d16182dbc = []byte{ - // 674 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0x4f, 0x4f, 0x13, 0x4f, - 0x18, 0xc7, 0x3b, 0xfc, 0xf8, 0x35, 0xfa, 0x54, 0x3d, 0x0c, 0x48, 0xc8, 0xa2, 0x4b, 0xdd, 0xc4, - 0x50, 0x9b, 0xb0, 0x03, 0xad, 0x1c, 0xf0, 0x58, 0x12, 0xe5, 0x62, 0x82, 0x8b, 0x27, 0x2f, 0x66, - 0x76, 0x99, 0xec, 0x4e, 0x2c, 0x3b, 0x4b, 0x67, 0x6b, 0x24, 0x84, 0x8b, 0xaf, 0xc0, 0x68, 0x7c, - 0x01, 0xbe, 0x01, 0x2f, 0x5e, 0x3c, 0x7b, 0xe2, 0x48, 0xe2, 0xc5, 0x93, 0x31, 0xe0, 0xc9, 0x57, - 0x61, 0x76, 0x66, 0x6a, 0x29, 0xcc, 0x86, 0x36, 0xe1, 0xb2, 0xff, 0x9e, 0xe7, 0xfb, 0x7c, 0x3f, - 0xcf, 0xcc, 0xd3, 0x29, 0x2c, 0x4a, 0xbe, 0xc3, 0x48, 0x98, 0x47, 0x5d, 0x1e, 0x27, 0xc5, 0x95, - 0xa5, 0x39, 0xd9, 0xeb, 0xb3, 0xde, 0xbe, 0x9f, 0xf5, 0x44, 0x2e, 0xf0, 0x4c, 0x91, 0xe0, 0x8f, - 0x26, 0x38, 0xb3, 0xb1, 0x88, 0x85, 0x8a, 0x93, 0xe2, 0x49, 0xa7, 0x3a, 0x77, 0x62, 0x21, 0xe2, - 0x2e, 0x23, 0x34, 0xe3, 0x84, 0xa6, 0xa9, 0xc8, 0x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d0, 0x96, 0xf0, 0xfd, 0xcb, 0xd1, 0x72, 0x9e, 0xe1, 0x6f, 0x08, - 0xe6, 0xcb, 0x86, 0x07, 0x3f, 0x2c, 0xf7, 0x2d, 0x1f, 0x53, 0x67, 0x6d, 0x42, 0x95, 0x01, 0x5f, - 0x57, 0xe0, 0x6d, 0xbc, 0x7a, 0x39, 0xb8, 0x9e, 0x7b, 0x72, 0xa0, 0xef, 0x87, 0xf8, 0x2b, 0x82, - 0x39, 0xfb, 0x8c, 0xe1, 0xd6, 0xb8, 0x30, 0xc3, 0x29, 0x76, 0xda, 0x13, 0x69, 0x0c, 0xfe, 0x9a, - 0xc2, 0x27, 0x78, 0x79, 0x0c, 0x7c, 0x2a, 0x13, 0x72, 0x50, 0x5c, 0x0f, 0xf1, 0x17, 0x64, 0x8e, - 0xa9, 0xd1, 0x63, 0x12, 0x93, 0x72, 0x06, 0xeb, 0x5f, 0x87, 0xb3, 0x32, 0xbe, 0x60, 0xf2, 0x05, - 0x97, 0xba, 0x02, 0x31, 0x67, 0x77, 0xe7, 0xe9, 0xd1, 0x89, 0x8b, 0x8e, 0x4f, 0x5c, 0xf4, 0xeb, - 0xc4, 0x45, 0xef, 0x4e, 0xdd, 0xca, 0xf1, 0xa9, 0x5b, 0xf9, 0x71, 0xea, 0x56, 0x5e, 0xb4, 0x63, - 0x9e, 0x27, 0xfd, 0xd0, 0x8f, 0xc4, 0xae, 0xa5, 0xec, 0x9b, 0x0b, 0x23, 0xb8, 0x9f, 0x31, 0x19, - 0x56, 0x55, 0x56, 0xfb, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x4f, 0x57, 0x9b, 0x0e, 0xf9, 0x07, - 0x00, 0x00, + proto.RegisterType((*QuerySigningRequestRequest)(nil), "side.btcbridge.QuerySigningRequestRequest") + proto.RegisterType((*QuerySigningRequestResponse)(nil), "side.btcbridge.QuerySigningRequestResponse") + proto.RegisterType((*QueryParamsRequest)(nil), "side.btcbridge.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "side.btcbridge.QueryParamsResponse") + proto.RegisterType((*QueryChainTipRequest)(nil), "side.btcbridge.QueryChainTipRequest") + proto.RegisterType((*QueryChainTipResponse)(nil), "side.btcbridge.QueryChainTipResponse") + proto.RegisterType((*QueryBlockHeaderByHeightRequest)(nil), "side.btcbridge.QueryBlockHeaderByHeightRequest") + proto.RegisterType((*QueryBlockHeaderByHeightResponse)(nil), "side.btcbridge.QueryBlockHeaderByHeightResponse") + proto.RegisterType((*QueryBlockHeaderByHashRequest)(nil), "side.btcbridge.QueryBlockHeaderByHashRequest") + proto.RegisterType((*QueryBlockHeaderByHashResponse)(nil), "side.btcbridge.QueryBlockHeaderByHashResponse") +} + +func init() { proto.RegisterFile("side/btcbridge/query.proto", fileDescriptor_fb547edb49d5502d) } + +var fileDescriptor_fb547edb49d5502d = []byte{ + // 670 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xc1, 0x4f, 0x13, 0x4f, + 0x14, 0xc7, 0x3b, 0xfc, 0xf8, 0x35, 0xfa, 0xaa, 0x1c, 0x46, 0x6c, 0xc8, 0x02, 0x4b, 0xb3, 0x48, + 0x6c, 0x40, 0x77, 0xa0, 0xe0, 0xc1, 0x8b, 0x89, 0xe5, 0x20, 0x89, 0x17, 0x5c, 0x3c, 0x79, 0xd1, + 0xd9, 0x32, 0xd9, 0x9d, 0x08, 0x3b, 0x4b, 0x67, 0x6a, 0x24, 0x84, 0x8b, 0x26, 0x9e, 0x4d, 0xbc, + 0x9a, 0x78, 0xf1, 0xc2, 0xd9, 0x7f, 0x82, 0x23, 0x89, 0x17, 0x4f, 0xc6, 0x80, 0x7f, 0x88, 0xd9, + 0x99, 0x29, 0xa5, 0xcb, 0xb6, 0xd6, 0x84, 0x4b, 0xbb, 0x3b, 0xef, 0xfb, 0xde, 0xfb, 0xbc, 0x99, + 0xef, 0x0e, 0x38, 0x92, 0x6f, 0x33, 0x12, 0xaa, 0x56, 0xd8, 0xe6, 0xdb, 0x11, 0x23, 0x7b, 0x1d, + 0xd6, 0xde, 0xf7, 0xd3, 0xb6, 0x50, 0x02, 0x4f, 0x64, 0x31, 0xff, 0x3c, 0xe6, 0x4c, 0x46, 0x22, + 0x12, 0x3a, 0x44, 0xb2, 0x27, 0xa3, 0x72, 0x66, 0x22, 0x21, 0xa2, 0x1d, 0x46, 0x68, 0xca, 0x09, + 0x4d, 0x12, 0xa1, 0xa8, 0xe2, 0x22, 0x91, 0x36, 0xba, 0xd8, 0x12, 0x72, 0x57, 0x48, 0x12, 0x52, + 0x69, 0x8b, 0x93, 0x37, 0x2b, 0x21, 0x53, 0x74, 0x85, 0xa4, 0x34, 0xe2, 0x89, 0x16, 0x5b, 0xed, + 0x74, 0x8e, 0x25, 0xa5, 0x6d, 0xba, 0xdb, 0x2d, 0x34, 0x93, 0x0b, 0x86, 0x5c, 0xb5, 0x04, 0xb7, + 0xa9, 0xde, 0x67, 0x04, 0xce, 0xb3, 0xac, 0xfa, 0x16, 0x8f, 0x12, 0x9e, 0x44, 0x01, 0xdb, 0xeb, + 0x30, 0xa9, 0xec, 0x1f, 0x7e, 0x00, 0x65, 0xa9, 0xa8, 0xea, 0xc8, 0x29, 0x54, 0x43, 0xf5, 0x89, + 0xc6, 0xac, 0xdf, 0x3f, 0x9a, 0x6f, 0xd3, 0xb6, 0xb4, 0x28, 0xb0, 0x62, 0xfc, 0x04, 0xa0, 0x07, + 0x39, 0x35, 0x56, 0x43, 0xf5, 0x4a, 0xe3, 0xae, 0x6f, 0x26, 0xf2, 0xb3, 0x89, 0x7c, 0xb3, 0x5d, + 0x76, 0x22, 0x7f, 0x93, 0x46, 0x2c, 0x60, 0x32, 0x15, 0x89, 0x64, 0xc1, 0x85, 0x54, 0xef, 0x08, + 0xc1, 0x74, 0x21, 0x9e, 0xd1, 0xe2, 0xc7, 0x70, 0xad, 0x6d, 0x96, 0x32, 0x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xb7, 0x17, 0x0d, 0xb5, 0x9f, 0x32, 0x19, 0x96, 0xb5, 0x60, 0xf5, + 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x14, 0x9a, 0x8c, 0x99, 0x7c, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -585,7 +584,7 @@ func NewQueryClient(cc grpc1.ClientConn) QueryClient { func (c *queryClient) QueryParams(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) { out := new(QueryParamsResponse) - err := c.cc.Invoke(ctx, "/side.btclightclient.Query/QueryParams", in, out, opts...) + err := c.cc.Invoke(ctx, "/side.btcbridge.Query/QueryParams", in, out, opts...) if err != nil { return nil, err } @@ -594,7 +593,7 @@ func (c *queryClient) QueryParams(ctx context.Context, in *QueryParamsRequest, o func (c *queryClient) QueryChainTip(ctx context.Context, in *QueryChainTipRequest, opts ...grpc.CallOption) (*QueryChainTipResponse, error) { out := new(QueryChainTipResponse) - err := c.cc.Invoke(ctx, "/side.btclightclient.Query/QueryChainTip", in, out, opts...) + err := c.cc.Invoke(ctx, "/side.btcbridge.Query/QueryChainTip", in, out, opts...) if err != nil { return nil, err } @@ -603,7 +602,7 @@ func (c *queryClient) QueryChainTip(ctx context.Context, in *QueryChainTipReques func (c *queryClient) QueryBlockHeaderByHeight(ctx context.Context, in *QueryBlockHeaderByHeightRequest, opts ...grpc.CallOption) (*QueryBlockHeaderByHeightResponse, error) { out := new(QueryBlockHeaderByHeightResponse) - err := c.cc.Invoke(ctx, "/side.btclightclient.Query/QueryBlockHeaderByHeight", in, out, opts...) + err := c.cc.Invoke(ctx, "/side.btcbridge.Query/QueryBlockHeaderByHeight", in, out, opts...) if err != nil { return nil, err } @@ -612,7 +611,7 @@ func (c *queryClient) QueryBlockHeaderByHeight(ctx context.Context, in *QueryBlo func (c *queryClient) QueryBlockHeaderByHash(ctx context.Context, in *QueryBlockHeaderByHashRequest, opts ...grpc.CallOption) (*QueryBlockHeaderByHashResponse, error) { out := new(QueryBlockHeaderByHashResponse) - err := c.cc.Invoke(ctx, "/side.btclightclient.Query/QueryBlockHeaderByHash", in, out, opts...) + err := c.cc.Invoke(ctx, "/side.btcbridge.Query/QueryBlockHeaderByHash", in, out, opts...) if err != nil { return nil, err } @@ -621,7 +620,7 @@ func (c *queryClient) QueryBlockHeaderByHash(ctx context.Context, in *QueryBlock func (c *queryClient) QuerySigningRequest(ctx context.Context, in *QuerySigningRequestRequest, opts ...grpc.CallOption) (*QuerySigningRequestResponse, error) { out := new(QuerySigningRequestResponse) - err := c.cc.Invoke(ctx, "/side.btclightclient.Query/QuerySigningRequest", in, out, opts...) + err := c.cc.Invoke(ctx, "/side.btcbridge.Query/QuerySigningRequest", in, out, opts...) if err != nil { return nil, err } @@ -676,7 +675,7 @@ func _Query_QueryParams_Handler(srv interface{}, ctx context.Context, dec func(i } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/side.btclightclient.Query/QueryParams", + FullMethod: "/side.btcbridge.Query/QueryParams", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).QueryParams(ctx, req.(*QueryParamsRequest)) @@ -694,7 +693,7 @@ func _Query_QueryChainTip_Handler(srv interface{}, ctx context.Context, dec func } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/side.btclightclient.Query/QueryChainTip", + FullMethod: "/side.btcbridge.Query/QueryChainTip", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).QueryChainTip(ctx, req.(*QueryChainTipRequest)) @@ -712,7 +711,7 @@ func _Query_QueryBlockHeaderByHeight_Handler(srv interface{}, ctx context.Contex } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/side.btclightclient.Query/QueryBlockHeaderByHeight", + FullMethod: "/side.btcbridge.Query/QueryBlockHeaderByHeight", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).QueryBlockHeaderByHeight(ctx, req.(*QueryBlockHeaderByHeightRequest)) @@ -730,7 +729,7 @@ func _Query_QueryBlockHeaderByHash_Handler(srv interface{}, ctx context.Context, } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/side.btclightclient.Query/QueryBlockHeaderByHash", + FullMethod: "/side.btcbridge.Query/QueryBlockHeaderByHash", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).QueryBlockHeaderByHash(ctx, req.(*QueryBlockHeaderByHashRequest)) @@ -748,7 +747,7 @@ func _Query_QuerySigningRequest_Handler(srv interface{}, ctx context.Context, de } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/side.btclightclient.Query/QuerySigningRequest", + FullMethod: "/side.btcbridge.Query/QuerySigningRequest", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(QueryServer).QuerySigningRequest(ctx, req.(*QuerySigningRequestRequest)) @@ -757,7 +756,7 @@ func _Query_QuerySigningRequest_Handler(srv interface{}, ctx context.Context, de } var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "side.btclightclient.Query", + ServiceName: "side.btcbridge.Query", HandlerType: (*QueryServer)(nil), Methods: []grpc.MethodDesc{ { @@ -782,7 +781,7 @@ var _Query_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "side/btclightclient/query.proto", + Metadata: "side/btcbridge/query.proto", } func (m *QuerySigningRequestRequest) Marshal() (dAtA []byte, err error) { diff --git a/x/btcbridge/types/query.pb.gw.go b/x/btcbridge/types/query.pb.gw.go index b3039755..3ee46d41 100644 --- a/x/btcbridge/types/query.pb.gw.go +++ b/x/btcbridge/types/query.pb.gw.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: side/btclightclient/query.proto +// source: side/btcbridge/query.proto /* Package types is a reverse proxy. @@ -479,15 +479,15 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_QueryParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sideprotocol", "side", "btclightclient", "params"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_QueryParams_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sideprotocol", "side", "btcbridge", "params"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_QueryChainTip_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sideprotocol", "side", "btclightclient", "tip"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_QueryChainTip_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sideprotocol", "side", "btcbridge", "tip"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_QueryBlockHeaderByHeight_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 3}, []string{"sideprotocol", "side", "btclightclient", "height"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_QueryBlockHeaderByHeight_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 3}, []string{"sideprotocol", "side", "btcbridge", "height"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_QueryBlockHeaderByHash_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 3}, []string{"sideprotocol", "side", "btclightclient", "hash"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_QueryBlockHeaderByHash_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 3}, []string{"sideprotocol", "side", "btcbridge", "hash"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_QuerySigningRequest_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"sideprotocol", "side", "btclightclient", "signing", "request"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_QuerySigningRequest_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"sideprotocol", "side", "btcbridge", "signing", "request"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( diff --git a/x/btcbridge/types/tx.pb.go b/x/btcbridge/types/tx.pb.go index b42953f6..cde68829 100644 --- a/x/btcbridge/types/tx.pb.go +++ b/x/btcbridge/types/tx.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: side/btclightclient/tx.proto +// source: side/btcbridge/tx.proto package types @@ -38,7 +38,7 @@ func (m *MsgSubmitBlockHeaderRequest) Reset() { *m = MsgSubmitBlockHeade func (m *MsgSubmitBlockHeaderRequest) String() string { return proto.CompactTextString(m) } func (*MsgSubmitBlockHeaderRequest) ProtoMessage() {} func (*MsgSubmitBlockHeaderRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_4df07798138ba91c, []int{0} + return fileDescriptor_785ca8e1e4227068, []int{0} } func (m *MsgSubmitBlockHeaderRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -89,7 +89,7 @@ func (m *MsgSubmitBlockHeadersResponse) Reset() { *m = MsgSubmitBlockHea func (m *MsgSubmitBlockHeadersResponse) String() string { return proto.CompactTextString(m) } func (*MsgSubmitBlockHeadersResponse) ProtoMessage() {} func (*MsgSubmitBlockHeadersResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4df07798138ba91c, []int{1} + return fileDescriptor_785ca8e1e4227068, []int{1} } func (m *MsgSubmitBlockHeadersResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -134,7 +134,7 @@ func (m *MsgSubmitTransactionRequest) Reset() { *m = MsgSubmitTransactio func (m *MsgSubmitTransactionRequest) String() string { return proto.CompactTextString(m) } func (*MsgSubmitTransactionRequest) ProtoMessage() {} func (*MsgSubmitTransactionRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_4df07798138ba91c, []int{2} + return fileDescriptor_785ca8e1e4227068, []int{2} } func (m *MsgSubmitTransactionRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -206,7 +206,7 @@ func (m *MsgSubmitTransactionResponse) Reset() { *m = MsgSubmitTransacti func (m *MsgSubmitTransactionResponse) String() string { return proto.CompactTextString(m) } func (*MsgSubmitTransactionResponse) ProtoMessage() {} func (*MsgSubmitTransactionResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4df07798138ba91c, []int{3} + return fileDescriptor_785ca8e1e4227068, []int{3} } func (m *MsgSubmitTransactionResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -246,7 +246,7 @@ func (m *MsgUpdateSendersRequest) Reset() { *m = MsgUpdateSendersRequest func (m *MsgUpdateSendersRequest) String() string { return proto.CompactTextString(m) } func (*MsgUpdateSendersRequest) ProtoMessage() {} func (*MsgUpdateSendersRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_4df07798138ba91c, []int{4} + return fileDescriptor_785ca8e1e4227068, []int{4} } func (m *MsgUpdateSendersRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -297,7 +297,7 @@ func (m *MsgUpdateSendersResponse) Reset() { *m = MsgUpdateSendersRespon func (m *MsgUpdateSendersResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateSendersResponse) ProtoMessage() {} func (*MsgUpdateSendersResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4df07798138ba91c, []int{5} + return fileDescriptor_785ca8e1e4227068, []int{5} } func (m *MsgUpdateSendersResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -339,7 +339,7 @@ func (m *MsgWithdrawBitcoinRequest) Reset() { *m = MsgWithdrawBitcoinReq func (m *MsgWithdrawBitcoinRequest) String() string { return proto.CompactTextString(m) } func (*MsgWithdrawBitcoinRequest) ProtoMessage() {} func (*MsgWithdrawBitcoinRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_4df07798138ba91c, []int{6} + return fileDescriptor_785ca8e1e4227068, []int{6} } func (m *MsgWithdrawBitcoinRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -397,7 +397,7 @@ func (m *MsgWithdrawBitcoinResponse) Reset() { *m = MsgWithdrawBitcoinRe func (m *MsgWithdrawBitcoinResponse) String() string { return proto.CompactTextString(m) } func (*MsgWithdrawBitcoinResponse) ProtoMessage() {} func (*MsgWithdrawBitcoinResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4df07798138ba91c, []int{7} + return fileDescriptor_785ca8e1e4227068, []int{7} } func (m *MsgWithdrawBitcoinResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -428,16 +428,16 @@ var xxx_messageInfo_MsgWithdrawBitcoinResponse proto.InternalMessageInfo // MsgSubmitWithdrawSignaturesRequest defines the Msg/SubmitWithdrawSignatures request type. type MsgSubmitWithdrawSignaturesRequest struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - Txid string `protobuf:"bytes,2,opt,name=txid,proto3" json:"txid,omitempty"` - Signatures []string `protobuf:"bytes,3,rep,name=signatures,proto3" json:"signatures,omitempty"` + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Txid string `protobuf:"bytes,2,opt,name=txid,proto3" json:"txid,omitempty"` + Psbt string `protobuf:"bytes,3,opt,name=psbt,proto3" json:"psbt,omitempty"` } func (m *MsgSubmitWithdrawSignaturesRequest) Reset() { *m = MsgSubmitWithdrawSignaturesRequest{} } func (m *MsgSubmitWithdrawSignaturesRequest) String() string { return proto.CompactTextString(m) } func (*MsgSubmitWithdrawSignaturesRequest) ProtoMessage() {} func (*MsgSubmitWithdrawSignaturesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_4df07798138ba91c, []int{8} + return fileDescriptor_785ca8e1e4227068, []int{8} } func (m *MsgSubmitWithdrawSignaturesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -480,11 +480,11 @@ func (m *MsgSubmitWithdrawSignaturesRequest) GetTxid() string { return "" } -func (m *MsgSubmitWithdrawSignaturesRequest) GetSignatures() []string { +func (m *MsgSubmitWithdrawSignaturesRequest) GetPsbt() string { if m != nil { - return m.Signatures + return m.Psbt } - return nil + return "" } // MsgSubmitWithdrawSignaturesResponse defines the Msg/SubmitWithdrawSignatures response type. @@ -495,7 +495,7 @@ func (m *MsgSubmitWithdrawSignaturesResponse) Reset() { *m = MsgSubmitWi func (m *MsgSubmitWithdrawSignaturesResponse) String() string { return proto.CompactTextString(m) } func (*MsgSubmitWithdrawSignaturesResponse) ProtoMessage() {} func (*MsgSubmitWithdrawSignaturesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4df07798138ba91c, []int{9} + return fileDescriptor_785ca8e1e4227068, []int{9} } func (m *MsgSubmitWithdrawSignaturesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -525,59 +525,58 @@ func (m *MsgSubmitWithdrawSignaturesResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSubmitWithdrawSignaturesResponse proto.InternalMessageInfo func init() { - proto.RegisterType((*MsgSubmitBlockHeaderRequest)(nil), "side.btclightclient.MsgSubmitBlockHeaderRequest") - proto.RegisterType((*MsgSubmitBlockHeadersResponse)(nil), "side.btclightclient.MsgSubmitBlockHeadersResponse") - proto.RegisterType((*MsgSubmitTransactionRequest)(nil), "side.btclightclient.MsgSubmitTransactionRequest") - proto.RegisterType((*MsgSubmitTransactionResponse)(nil), "side.btclightclient.MsgSubmitTransactionResponse") - proto.RegisterType((*MsgUpdateSendersRequest)(nil), "side.btclightclient.MsgUpdateSendersRequest") - proto.RegisterType((*MsgUpdateSendersResponse)(nil), "side.btclightclient.MsgUpdateSendersResponse") - proto.RegisterType((*MsgWithdrawBitcoinRequest)(nil), "side.btclightclient.MsgWithdrawBitcoinRequest") - proto.RegisterType((*MsgWithdrawBitcoinResponse)(nil), "side.btclightclient.MsgWithdrawBitcoinResponse") - proto.RegisterType((*MsgSubmitWithdrawSignaturesRequest)(nil), "side.btclightclient.MsgSubmitWithdrawSignaturesRequest") - proto.RegisterType((*MsgSubmitWithdrawSignaturesResponse)(nil), "side.btclightclient.MsgSubmitWithdrawSignaturesResponse") -} - -func init() { proto.RegisterFile("side/btclightclient/tx.proto", fileDescriptor_4df07798138ba91c) } - -var fileDescriptor_4df07798138ba91c = []byte{ - // 581 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0xcd, 0x6e, 0xd3, 0x40, - 0x18, 0x8c, 0xeb, 0x34, 0x21, 0x5f, 0x89, 0x10, 0x4b, 0x55, 0x5c, 0x13, 0x4c, 0x30, 0x42, 0xca, - 0x01, 0x6c, 0x48, 0x0f, 0x70, 0x8e, 0x84, 0x84, 0x84, 0x72, 0x71, 0x8a, 0x90, 0xb8, 0x44, 0x6b, - 0x7b, 0x63, 0x5b, 0x24, 0x5e, 0xe3, 0xdd, 0x80, 0x8b, 0x78, 0x05, 0x24, 0x1e, 0x83, 0x47, 0xe1, - 0xd8, 0x23, 0x47, 0x94, 0x9c, 0x79, 0x07, 0xe4, 0xf5, 0x36, 0x4d, 0x1b, 0xe7, 0xa7, 0x97, 0x68, - 0xbf, 0xfd, 0x66, 0xbf, 0x99, 0x9d, 0x8c, 0x6d, 0x68, 0xb1, 0xc8, 0x27, 0xb6, 0xcb, 0xbd, 0x71, - 0x14, 0x84, 0xf9, 0x2f, 0x89, 0xb9, 0xcd, 0x33, 0x2b, 0x49, 0x29, 0xa7, 0xe8, 0x5e, 0xde, 0xb5, - 0xae, 0x76, 0xf5, 0xc3, 0x80, 0x06, 0x54, 0xf4, 0xed, 0x7c, 0x55, 0x40, 0xf5, 0x76, 0x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, 0x67, 0xbc, 0xe4, 0xfc, - 0xa1, 0x80, 0xb6, 0x2e, 0x04, 0xe8, 0xd5, 0x66, 0xc7, 0xd6, 0x06, 0x55, 0x7f, 0x7d, 0xf3, 0x83, - 0x85, 0x9e, 0x5e, 0xff, 0xf7, 0xcc, 0x50, 0xce, 0x67, 0x86, 0xf2, 0x77, 0x66, 0x28, 0x3f, 0xe7, - 0x46, 0xe5, 0x7c, 0x6e, 0x54, 0xfe, 0xcc, 0x8d, 0xca, 0xc7, 0x93, 0x20, 0xe2, 0xe1, 0xd4, 0xb5, - 0x3c, 0x3a, 0xb1, 0xf3, 0xe9, 0xe2, 0x8d, 0xec, 0xd1, 0xb1, 0x28, 0xec, 0x6c, 0xe5, 0x1b, 0x71, - 0x96, 0x10, 0xe6, 0xd6, 0x04, 0xea, 0xe4, 0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x22, 0x54, 0x79, - 0xb7, 0x47, 0x06, 0x00, 0x00, + proto.RegisterType((*MsgSubmitBlockHeaderRequest)(nil), "side.btcbridge.MsgSubmitBlockHeaderRequest") + proto.RegisterType((*MsgSubmitBlockHeadersResponse)(nil), "side.btcbridge.MsgSubmitBlockHeadersResponse") + proto.RegisterType((*MsgSubmitTransactionRequest)(nil), "side.btcbridge.MsgSubmitTransactionRequest") + proto.RegisterType((*MsgSubmitTransactionResponse)(nil), "side.btcbridge.MsgSubmitTransactionResponse") + proto.RegisterType((*MsgUpdateSendersRequest)(nil), "side.btcbridge.MsgUpdateSendersRequest") + proto.RegisterType((*MsgUpdateSendersResponse)(nil), "side.btcbridge.MsgUpdateSendersResponse") + proto.RegisterType((*MsgWithdrawBitcoinRequest)(nil), "side.btcbridge.MsgWithdrawBitcoinRequest") + proto.RegisterType((*MsgWithdrawBitcoinResponse)(nil), "side.btcbridge.MsgWithdrawBitcoinResponse") + proto.RegisterType((*MsgSubmitWithdrawSignaturesRequest)(nil), "side.btcbridge.MsgSubmitWithdrawSignaturesRequest") + proto.RegisterType((*MsgSubmitWithdrawSignaturesResponse)(nil), "side.btcbridge.MsgSubmitWithdrawSignaturesResponse") +} + +func init() { proto.RegisterFile("side/btcbridge/tx.proto", fileDescriptor_785ca8e1e4227068) } + +var fileDescriptor_785ca8e1e4227068 = []byte{ + // 572 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xdd, 0x6e, 0xd3, 0x30, + 0x18, 0x5d, 0xd6, 0x6d, 0xa5, 0xdf, 0x28, 0x08, 0x6b, 0xda, 0xb2, 0xb4, 0x84, 0x2a, 0x08, 0x51, + 0xfe, 0x52, 0xa9, 0x7b, 0x01, 0xd4, 0xab, 0x49, 0xa8, 0x37, 0xe9, 0x10, 0x12, 0x37, 0x95, 0x9d, + 0xb8, 0x49, 0xc4, 0x1a, 0x07, 0xdb, 0x65, 0xdd, 0x35, 0x2f, 0xc0, 0x63, 0xf0, 0x0e, 0xbc, 0x00, + 0x97, 0xbb, 0xe4, 0x12, 0xb5, 0x2f, 0x82, 0xe2, 0x78, 0x5d, 0xd7, 0xa6, 0x3f, 0xdc, 0xf9, 0xf3, + 0x39, 0xf6, 0x39, 0xfe, 0xbe, 0x93, 0xc0, 0x89, 0x88, 0x03, 0xda, 0x22, 0xd2, 0x27, 0x3c, 0x0e, + 0x42, 0xda, 0x92, 0x63, 0x37, 0xe5, 0x4c, 0x32, 0xf4, 0x28, 0x03, 0xdc, 0x19, 0x60, 0x1d, 0x85, + 0x2c, 0x64, 0x0a, 0x6a, 0x65, 0xab, 0x9c, 0x65, 0xd5, 0x16, 0x8e, 0xa7, 0x98, 0xe3, 0xa1, 0xd0, + 0x60, 0x7d, 0x01, 0x24, 0xb1, 0xf4, 0x59, 0x9c, 0xe4, 0xa8, 0x73, 0x05, 0xb5, 0xae, 0x08, 0x7b, + 0x23, 0x32, 0x8c, 0x65, 0xe7, 0x92, 0xf9, 0x5f, 0xce, 0x29, 0x0e, 0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 0x4c, 0xed, 0x9d, 0x3f, 0x53, 0x7b, 0xe7, + 0xb3, 0x1b, 0xc6, 0x32, 0x1a, 0x11, 0xd7, 0x67, 0xc3, 0x56, 0x76, 0xb1, 0xfa, 0x9d, 0xfa, 0xec, + 0x52, 0x15, 0xad, 0xf1, 0xfc, 0xcf, 0xfc, 0x3a, 0xa5, 0x82, 0x1c, 0x28, 0xc2, 0xd9, 0xbf, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x51, 0x15, 0x68, 0x74, 0xeb, 0x05, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -614,7 +613,7 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { func (c *msgClient) SubmitBlockHeaders(ctx context.Context, in *MsgSubmitBlockHeaderRequest, opts ...grpc.CallOption) (*MsgSubmitBlockHeadersResponse, error) { out := new(MsgSubmitBlockHeadersResponse) - err := c.cc.Invoke(ctx, "/side.btclightclient.Msg/SubmitBlockHeaders", in, out, opts...) + err := c.cc.Invoke(ctx, "/side.btcbridge.Msg/SubmitBlockHeaders", in, out, opts...) if err != nil { return nil, err } @@ -623,7 +622,7 @@ func (c *msgClient) SubmitBlockHeaders(ctx context.Context, in *MsgSubmitBlockHe func (c *msgClient) SubmitTransaction(ctx context.Context, in *MsgSubmitTransactionRequest, opts ...grpc.CallOption) (*MsgSubmitTransactionResponse, error) { out := new(MsgSubmitTransactionResponse) - err := c.cc.Invoke(ctx, "/side.btclightclient.Msg/SubmitTransaction", in, out, opts...) + err := c.cc.Invoke(ctx, "/side.btcbridge.Msg/SubmitTransaction", in, out, opts...) if err != nil { return nil, err } @@ -632,7 +631,7 @@ func (c *msgClient) SubmitTransaction(ctx context.Context, in *MsgSubmitTransact func (c *msgClient) UpdateSenders(ctx context.Context, in *MsgUpdateSendersRequest, opts ...grpc.CallOption) (*MsgUpdateSendersResponse, error) { out := new(MsgUpdateSendersResponse) - err := c.cc.Invoke(ctx, "/side.btclightclient.Msg/UpdateSenders", in, out, opts...) + err := c.cc.Invoke(ctx, "/side.btcbridge.Msg/UpdateSenders", in, out, opts...) if err != nil { return nil, err } @@ -641,7 +640,7 @@ func (c *msgClient) UpdateSenders(ctx context.Context, in *MsgUpdateSendersReque func (c *msgClient) WithdrawBitcoin(ctx context.Context, in *MsgWithdrawBitcoinRequest, opts ...grpc.CallOption) (*MsgWithdrawBitcoinResponse, error) { out := new(MsgWithdrawBitcoinResponse) - err := c.cc.Invoke(ctx, "/side.btclightclient.Msg/WithdrawBitcoin", in, out, opts...) + err := c.cc.Invoke(ctx, "/side.btcbridge.Msg/WithdrawBitcoin", in, out, opts...) if err != nil { return nil, err } @@ -650,7 +649,7 @@ func (c *msgClient) WithdrawBitcoin(ctx context.Context, in *MsgWithdrawBitcoinR func (c *msgClient) SubmitWithdrawSignatures(ctx context.Context, in *MsgSubmitWithdrawSignaturesRequest, opts ...grpc.CallOption) (*MsgSubmitWithdrawSignaturesResponse, error) { out := new(MsgSubmitWithdrawSignaturesResponse) - err := c.cc.Invoke(ctx, "/side.btclightclient.Msg/SubmitWithdrawSignatures", in, out, opts...) + err := c.cc.Invoke(ctx, "/side.btcbridge.Msg/SubmitWithdrawSignatures", in, out, opts...) if err != nil { return nil, err } @@ -705,7 +704,7 @@ func _Msg_SubmitBlockHeaders_Handler(srv interface{}, ctx context.Context, dec f } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/side.btclightclient.Msg/SubmitBlockHeaders", + FullMethod: "/side.btcbridge.Msg/SubmitBlockHeaders", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).SubmitBlockHeaders(ctx, req.(*MsgSubmitBlockHeaderRequest)) @@ -723,7 +722,7 @@ func _Msg_SubmitTransaction_Handler(srv interface{}, ctx context.Context, dec fu } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/side.btclightclient.Msg/SubmitTransaction", + FullMethod: "/side.btcbridge.Msg/SubmitTransaction", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).SubmitTransaction(ctx, req.(*MsgSubmitTransactionRequest)) @@ -741,7 +740,7 @@ func _Msg_UpdateSenders_Handler(srv interface{}, ctx context.Context, dec func(i } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/side.btclightclient.Msg/UpdateSenders", + FullMethod: "/side.btcbridge.Msg/UpdateSenders", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).UpdateSenders(ctx, req.(*MsgUpdateSendersRequest)) @@ -759,7 +758,7 @@ func _Msg_WithdrawBitcoin_Handler(srv interface{}, ctx context.Context, dec func } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/side.btclightclient.Msg/WithdrawBitcoin", + FullMethod: "/side.btcbridge.Msg/WithdrawBitcoin", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).WithdrawBitcoin(ctx, req.(*MsgWithdrawBitcoinRequest)) @@ -777,7 +776,7 @@ func _Msg_SubmitWithdrawSignatures_Handler(srv interface{}, ctx context.Context, } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/side.btclightclient.Msg/SubmitWithdrawSignatures", + FullMethod: "/side.btcbridge.Msg/SubmitWithdrawSignatures", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).SubmitWithdrawSignatures(ctx, req.(*MsgSubmitWithdrawSignaturesRequest)) @@ -786,7 +785,7 @@ func _Msg_SubmitWithdrawSignatures_Handler(srv interface{}, ctx context.Context, } var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "side.btclightclient.Msg", + ServiceName: "side.btcbridge.Msg", HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { @@ -811,7 +810,7 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ }, }, Streams: []grpc.StreamDesc{}, - Metadata: "side/btclightclient/tx.proto", + Metadata: "side/btcbridge/tx.proto", } func (m *MsgSubmitBlockHeaderRequest) Marshal() (dAtA []byte, err error) { @@ -1111,14 +1110,12 @@ func (m *MsgSubmitWithdrawSignaturesRequest) MarshalToSizedBuffer(dAtA []byte) ( _ = i var l int _ = l - if len(m.Signatures) > 0 { - for iNdEx := len(m.Signatures) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Signatures[iNdEx]) - copy(dAtA[i:], m.Signatures[iNdEx]) - i = encodeVarintTx(dAtA, i, uint64(len(m.Signatures[iNdEx]))) - i-- - dAtA[i] = 0x1a - } + if len(m.Psbt) > 0 { + i -= len(m.Psbt) + copy(dAtA[i:], m.Psbt) + i = encodeVarintTx(dAtA, i, uint64(len(m.Psbt))) + i-- + dAtA[i] = 0x1a } if len(m.Txid) > 0 { i -= len(m.Txid) @@ -1310,11 +1307,9 @@ func (m *MsgSubmitWithdrawSignaturesRequest) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if len(m.Signatures) > 0 { - for _, s := range m.Signatures { - l = len(s) - n += 1 + l + sovTx(uint64(l)) - } + l = len(m.Psbt) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } return n } @@ -2202,7 +2197,7 @@ func (m *MsgSubmitWithdrawSignaturesRequest) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signatures", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Psbt", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2230,7 +2225,7 @@ func (m *MsgSubmitWithdrawSignaturesRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Signatures = append(m.Signatures, string(dAtA[iNdEx:postIndex])) + m.Psbt = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex From 778a35b853af8d3b2410425b88eaa788abbed796 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Mon, 17 Jun 2024 15:46:18 +0800 Subject: [PATCH 29/71] refactor process transaction and vaults --- proto/side/btcbridge/bitcoin.proto | 1 - proto/side/btcbridge/params.proto | 24 +- proto/side/btcbridge/tx.proto | 35 +- x/btcbridge/keeper/keeper.go | 164 ---- x/btcbridge/keeper/keeper_deposit.go | 178 ++++ x/btcbridge/keeper/keeper_withdraw.go | 94 +- x/btcbridge/keeper/msg_server.go | 37 +- x/btcbridge/types/codec.go | 14 +- ... => message_submit_deposit_transaction.go} | 18 +- .../message_submit_withdraw_transaction.go | 68 ++ x/btcbridge/types/message_update_senders.go | 30 +- x/btcbridge/types/params.go | 22 +- x/btcbridge/types/params.pb.go | 354 ++++++- x/btcbridge/types/tx.pb.go | 902 ++++++++++++++---- 14 files changed, 1501 insertions(+), 440 deletions(-) create mode 100644 x/btcbridge/keeper/keeper_deposit.go rename x/btcbridge/types/{message_submit_transaction.go => message_submit_deposit_transaction.go} (67%) create mode 100644 x/btcbridge/types/message_submit_withdraw_transaction.go diff --git a/proto/side/btcbridge/bitcoin.proto b/proto/side/btcbridge/bitcoin.proto index 3ecbc150..775eb904 100644 --- a/proto/side/btcbridge/bitcoin.proto +++ b/proto/side/btcbridge/bitcoin.proto @@ -41,7 +41,6 @@ message BitcoinSigningRequest { string psbt = 3; SigningStatus status = 4; uint64 sequence = 5; - // The vault address that the request is associated with string vault_address = 6; } diff --git a/proto/side/btcbridge/params.proto b/proto/side/btcbridge/params.proto index d1a66469..7fb7ffbe 100644 --- a/proto/side/btcbridge/params.proto +++ b/proto/side/btcbridge/params.proto @@ -8,14 +8,34 @@ option go_package = "github.com/sideprotocol/side/x/btcbridge/types"; // Params defines the parameters for the module. message Params { // Only accept blocks sending from these addresses - repeated string senders = 1; + repeated string qualified_relayers = 1; // The minimum number of confirmations required for a block to be accepted int32 confirmations = 2; // Indicates the maximum depth or distance from the latest block up to which transactions are considered for acceptance. uint64 max_acceptable_block_depth = 3; // the denomanation of the voucher string btc_voucher_denom = 4; + repeated Vault vaults = 5; +} + +// AssetType defines the type of asset +enum AssetType { + // Unspecified asset type + ASSET_TYPE_UNSPECIFIED = 0; + // BTC + ASSET_TYPE_BTC = 1; + // BRC20: ordi, sats + ASSET_TYPE_BRC20 = 2; + // RUNE, dog*go*to*the*moon + ASSET_TYPE_RUNE = 3; +} + +// Vault defines the parameters for the module. +message Vault { + // the depositor should send their btc to this address + string address_on_bitcoin = 1; // the address to which the voucher is sent - repeated string btc_voucher_address = 5; + AssetType asset_type = 2; + } diff --git a/proto/side/btcbridge/tx.proto b/proto/side/btcbridge/tx.proto index 0b022d5e..295f0f49 100644 --- a/proto/side/btcbridge/tx.proto +++ b/proto/side/btcbridge/tx.proto @@ -12,14 +12,17 @@ option go_package = "github.com/sideprotocol/side/x/btcbridge/types"; service Msg { // SubmitBlockHeaders submits bitcoin block headers to the side chain. rpc SubmitBlockHeaders (MsgSubmitBlockHeaderRequest) returns (MsgSubmitBlockHeadersResponse); - // SubmitTransaction submits bitcoin transaction to the side chain. - rpc SubmitTransaction (MsgSubmitTransactionRequest) returns (MsgSubmitTransactionResponse); + // SubmitDepositTransaction submits bitcoin transaction to the side chain. + rpc SubmitDepositTransaction (MsgSubmitDepositTransactionRequest) returns (MsgSubmitDepositTransactionResponse); + // SubmitWithdrawalTransaction submits bitcoin transaction to the side chain. + rpc SubmitWithdrawTransaction (MsgSubmitWithdrawTransactionRequest) returns (MsgSubmitWithdrawTransactionResponse); // UpdateSenders updates the senders of the side chain. - rpc UpdateSenders (MsgUpdateSendersRequest) returns (MsgUpdateSendersResponse); + rpc UpdateQualifiedRelayers (MsgUpdateQualifiedRelayersRequest) returns (MsgUpdateQualifiedRelayersResponse); // WithdrawBitcoin withdraws the bitcoin from the side chain. rpc WithdrawBitcoin (MsgWithdrawBitcoinRequest) returns (MsgWithdrawBitcoinResponse); // SubmitWithdrawSignatures submits the signatures of the withdraw transaction. rpc SubmitWithdrawSignatures (MsgSubmitWithdrawSignaturesRequest) returns (MsgSubmitWithdrawSignaturesResponse); + } // MsgBlockHeaderRequest defines the Msg/SubmitBlockHeaders request type. @@ -33,7 +36,23 @@ message MsgSubmitBlockHeadersResponse { } // MsgSubmitTransactionRequest defines the Msg/SubmitTransaction request type. -message MsgSubmitTransactionRequest { +message MsgSubmitDepositTransactionRequest { + string sender = 1; + string blockhash = 2; + // the tx bytes in base64 format + // used for parsing the sender of the transaction + string prev_tx_bytes = 3; + // the tx bytes in base64 format + string tx_bytes = 4; + repeated string proof = 5; +} + +// MsgSubmitTransactionResponse defines the Msg/SubmitTransaction response type. +message MsgSubmitDepositTransactionResponse { +} + +// MsgSubmitTransactionRequest defines the Msg/SubmitTransaction request type. +message MsgSubmitWithdrawTransactionRequest { string sender = 1; string blockhash = 2; // the tx bytes in base64 format @@ -45,18 +64,18 @@ message MsgSubmitTransactionRequest { } // MsgSubmitTransactionResponse defines the Msg/SubmitTransaction response type. -message MsgSubmitTransactionResponse { +message MsgSubmitWithdrawTransactionResponse { } // Msg defines the MsgUpdateSender service. -message MsgUpdateSendersRequest { +message MsgUpdateQualifiedRelayersRequest { string sender = 1; // update senders who can send block headers to the side chain - repeated string senders = 2; + repeated string relayers = 2; } // MsgUpdateSenderResponse defines the Msg/UpdateSender response type. -message MsgUpdateSendersResponse { +message MsgUpdateQualifiedRelayersResponse { } // MsgWithdrawBitcoinRequest defines the Msg/WithdrawBitcoin request type. diff --git a/x/btcbridge/keeper/keeper.go b/x/btcbridge/keeper/keeper.go index 66be1bf0..2852c429 100644 --- a/x/btcbridge/keeper/keeper.go +++ b/x/btcbridge/keeper/keeper.go @@ -1,17 +1,10 @@ package keeper import ( - "bytes" - "encoding/base64" "fmt" - "slices" "github.com/btcsuite/btcd/blockchain" - "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg" - "github.com/btcsuite/btcd/chaincfg/chainhash" - "github.com/btcsuite/btcd/txscript" - "github.com/btcsuite/btcd/wire" "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -140,163 +133,6 @@ func (k Keeper) SetBlockHeaders(ctx sdk.Context, blockHeader []*types.BlockHeade return nil } -// Process Bitcoin Deposit Transaction -func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.MsgSubmitTransactionRequest) error { - - ctx.Logger().Info("accept bitcoin deposit tx", "blockhash", msg.Blockhash) - - param := k.GetParams(ctx) - header := k.GetBlockHeader(ctx, msg.Blockhash) - // Check if block confirmed - if header == nil { - return types.ErrBlockNotFound - } - - best := k.GetBestBlockHeader(ctx) - // Check if the block is confirmed - if best.Height-header.Height < uint64(param.Confirmations) { - return types.ErrNotConfirmed - } - // Check if the block is within the acceptable depth - if best.Height-header.Height > param.MaxAcceptableBlockDepth { - return types.ErrExceedMaxAcceptanceDepth - } - - // Decode the base64 transaction - txBytes, err := base64.StdEncoding.DecodeString(msg.TxBytes) - if err != nil { - fmt.Println("Error decoding transaction from base64:", err) - return err - } - - // Create a new transaction - var tx wire.MsgTx - err = tx.Deserialize(bytes.NewReader(txBytes)) - if err != nil { - fmt.Println("Error deserializing transaction:", err) - return err - } - uTx := btcutil.NewTx(&tx) - if len(uTx.MsgTx().TxIn) < 1 { - return types.ErrInvalidBtcTransaction - } - - // Validate the transaction - if err := blockchain.CheckTransactionSanity(uTx); err != nil { - fmt.Println("Transaction is not valid:", err) - return err - } - - // extract senders from the previous transaction - prevTxBytes, err := base64.StdEncoding.DecodeString(msg.PrevTxBytes) - if err != nil { - fmt.Println("Error decoding transaction from base64:", err) - return err - } - - // Create a new transaction - var prevMsgTx wire.MsgTx - err = prevMsgTx.Deserialize(bytes.NewReader(prevTxBytes)) - if err != nil { - fmt.Println("Error deserializing transaction:", err) - return err - } - - prevTx := btcutil.NewTx(&prevMsgTx) - if len(prevTx.MsgTx().TxOut) < 1 { - return types.ErrInvalidBtcTransaction - } - // Validate the transaction - if err := blockchain.CheckTransactionSanity(prevTx); err != nil { - fmt.Println("Transaction is not valid:", err) - return err - } - - // check if the output is a valid address - // if there are multiple inputs, then the first input is considered as the sender - // assumpe all inputs are from the same sender - out := prevTx.MsgTx().TxOut[tx.TxIn[0].PreviousOutPoint.Index] - // check if the output is a valid address - pk, err := txscript.ParsePkScript(out.PkScript) - if err != nil { - return err - } - - sender, err := pk.Address(types.ChainCfg) - if err != nil { - return err - } - - // if pk.Class() != txscript.WitnessV1TaprootTy || pk.Class() != txscript.WitnessV0PubKeyHashTy || pk.Class() != txscript.WitnessV0ScriptHashTy { - // ctx.Logger().Error("Unsupported script type", "script", pk.Class(), "address", sender.EncodeAddress()) - // return types.ErrUnsupportedScriptType - // } - - // check if the proof is valid - root, err := chainhash.NewHashFromStr(header.MerkleRoot) - if err != nil { - return err - } - if !types.VerifyMerkleProof(msg.Proof, uTx.Hash(), root) { - return types.ErrTransactionNotIncluded - } - - // mint voucher token and save utxo if the receiver is a vault address - for i, out := range uTx.MsgTx().TxOut { - // check if the output is a valid address - pks, err := txscript.ParsePkScript(out.PkScript) - if err != nil { - return err - } - addr, err := pks.Address(types.ChainCfg) - if err != nil { - return err - } - - // check if the receiver is one of the voucher addresses - if slices.Contains(param.BtcVoucherAddress, addr.EncodeAddress()) { - // mint the voucher token - coins := sdk.NewCoins(sdk.NewCoin(param.BtcVoucherDenom, sdk.NewInt(out.Value))) - senderAddr, err := sdk.AccAddressFromBech32(sender.EncodeAddress()) - if err != nil { - return err - } - k.bankKeeper.MintCoins(ctx, types.ModuleName, coins) - k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, senderAddr, coins) - - utxo := types.UTXO{ - Txid: uTx.Hash().String(), - Vout: uint64(i), - Amount: uint64(out.Value), - PubKeyScript: out.PkScript, - Height: header.Height, - Address: addr.EncodeAddress(), - IsCoinbase: false, - IsLocked: false, - } - - k.SetUTXO(ctx, &utxo) - k.SetOwnerUTXO(ctx, &utxo) - - ctx.Logger().Info("Minted Bitcoin Voucher", "index", i, "address", addr.EncodeAddress(), "amount", out.Value, "sender", sender.EncodeAddress(), "senderAddr", senderAddr.String(), "coins", coins.String()) - } - } - - // spend locked utxos if the sender is a vault address - if slices.Contains(param.BtcVoucherAddress, sender.EncodeAddress()) { - for _, in := range uTx.MsgTx().TxIn { - hash := in.PreviousOutPoint.Hash.String() - vout := in.PreviousOutPoint.Index - - if k.IsUTXOLocked(ctx, hash, uint64(vout)) { - k.SpendUTXO(ctx, hash, uint64(vout)) - } - } - } - - return nil -} - func (k Keeper) GetBlockHeader(ctx sdk.Context, hash string) *types.BlockHeader { store := ctx.KVStore(k.storeKey) var blockHeader types.BlockHeader diff --git a/x/btcbridge/keeper/keeper_deposit.go b/x/btcbridge/keeper/keeper_deposit.go new file mode 100644 index 00000000..cdb637dd --- /dev/null +++ b/x/btcbridge/keeper/keeper_deposit.go @@ -0,0 +1,178 @@ +package keeper + +import ( + "bytes" + "encoding/base64" + "fmt" + + "github.com/btcsuite/btcd/blockchain" + "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/chaincfg/chainhash" + "github.com/btcsuite/btcd/txscript" + "github.com/btcsuite/btcd/wire" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/sideprotocol/side/x/btcbridge/types" +) + +// Process Bitcoin Deposit Transaction +func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.MsgSubmitDepositTransactionRequest) error { + + ctx.Logger().Info("accept bitcoin deposit tx", "blockhash", msg.Blockhash) + + param := k.GetParams(ctx) + header := k.GetBlockHeader(ctx, msg.Blockhash) + // Check if block confirmed + if header == nil { + return types.ErrBlockNotFound + } + + best := k.GetBestBlockHeader(ctx) + // Check if the block is confirmed + if best.Height-header.Height < uint64(param.Confirmations) { + return types.ErrNotConfirmed + } + // Check if the block is within the acceptable depth + if best.Height-header.Height > param.MaxAcceptableBlockDepth { + return types.ErrExceedMaxAcceptanceDepth + } + + // Decode the base64 transaction + txBytes, err := base64.StdEncoding.DecodeString(msg.TxBytes) + if err != nil { + fmt.Println("Error decoding transaction from base64:", err) + return err + } + + // Create a new transaction + var tx wire.MsgTx + err = tx.Deserialize(bytes.NewReader(txBytes)) + if err != nil { + fmt.Println("Error deserializing transaction:", err) + return err + } + uTx := btcutil.NewTx(&tx) + if len(uTx.MsgTx().TxIn) < 1 { + return types.ErrInvalidBtcTransaction + } + + // Validate the transaction + if err := blockchain.CheckTransactionSanity(uTx); err != nil { + fmt.Println("Transaction is not valid:", err) + return err + } + + // extract senders from the previous transaction + prevTxBytes, err := base64.StdEncoding.DecodeString(msg.PrevTxBytes) + if err != nil { + fmt.Println("Error decoding transaction from base64:", err) + return err + } + + // Create a new transaction + var prevMsgTx wire.MsgTx + err = prevMsgTx.Deserialize(bytes.NewReader(prevTxBytes)) + if err != nil { + fmt.Println("Error deserializing transaction:", err) + return err + } + + prevTx := btcutil.NewTx(&prevMsgTx) + if len(prevTx.MsgTx().TxOut) < 1 { + return types.ErrInvalidBtcTransaction + } + // Validate the transaction + if err := blockchain.CheckTransactionSanity(prevTx); err != nil { + fmt.Println("Transaction is not valid:", err) + return err + } + + if uTx.MsgTx().TxIn[0].PreviousOutPoint.Hash.String() != prevTx.Hash().String() { + return types.ErrInvalidBtcTransaction + } + + // check if the output is a valid address + // if there are multiple inputs, then the first input is considered as the sender + // assumpe all inputs are from the same sender + out := prevTx.MsgTx().TxOut[tx.TxIn[0].PreviousOutPoint.Index] + // check if the output is a valid address + pk, err := txscript.ParsePkScript(out.PkScript) + if err != nil { + return err + } + + sender, err := pk.Address(types.ChainCfg) + if err != nil { + return err + } + + // if pk.Class() != txscript.WitnessV1TaprootTy || pk.Class() != txscript.WitnessV0PubKeyHashTy || pk.Class() != txscript.WitnessV0ScriptHashTy { + // ctx.Logger().Error("Unsupported script type", "script", pk.Class(), "address", sender.EncodeAddress()) + // return types.ErrUnsupportedScriptType + // } + + // check if the proof is valid + root, err := chainhash.NewHashFromStr(header.MerkleRoot) + if err != nil { + return err + } + if !types.VerifyMerkleProof(msg.Proof, uTx.Hash(), root) { + return types.ErrTransactionNotIncluded + } + + // mint voucher token and save utxo if the receiver is a vault address + for i, out := range uTx.MsgTx().TxOut { + // check if the output is a valid address + pks, err := txscript.ParsePkScript(out.PkScript) + if err != nil { + return err + } + addr, err := pks.Address(types.ChainCfg) + if err != nil { + return err + } + // check if the receiver is one of the voucher addresses + vault := types.SelectVaultByBitcoinAddress(param.Vaults, addr.EncodeAddress()) + if vault == nil { + continue + } + + // mint the voucher token by asset type and save utxos + // skip if the asset type of the sender address is unspecified + switch vault.AssetType { + case types.AssetType_ASSET_TYPE_BTC: + k.minBTC(ctx, uTx, header.Height, sender.EncodeAddress(), vault, out, i, param.BtcVoucherDenom) + break + case types.AssetType_ASSET_TYPE_RUNE: + + } + } + + return nil +} + +func (k Keeper) minBTC(ctx sdk.Context, uTx *btcutil.Tx, height uint64, sender string, vault *types.Vault, out *wire.TxOut, vout int, denom string) { + // mint the voucher token + coins := sdk.NewCoins(sdk.NewCoin(denom, sdk.NewInt(out.Value))) + + receipient, err := sdk.AccAddressFromBech32(sender) + if err != nil { + return + } + + k.bankKeeper.MintCoins(ctx, types.ModuleName, coins) + k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, receipient, coins) + + utxo := types.UTXO{ + Txid: uTx.Hash().String(), + Vout: uint64(vout), + Amount: uint64(out.Value), + PubKeyScript: out.PkScript, + Height: height, + Address: vault.GetAddressOnBitcoin(), + IsCoinbase: false, + IsLocked: false, + } + + k.SetUTXO(ctx, &utxo) + k.SetOwnerUTXO(ctx, &utxo) +} diff --git a/x/btcbridge/keeper/keeper_withdraw.go b/x/btcbridge/keeper/keeper_withdraw.go index b31fdae2..e0bec635 100644 --- a/x/btcbridge/keeper/keeper_withdraw.go +++ b/x/btcbridge/keeper/keeper_withdraw.go @@ -1,6 +1,13 @@ package keeper import ( + "bytes" + "encoding/base64" + "fmt" + + "github.com/btcsuite/btcd/blockchain" + "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/wire" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/sideprotocol/side/x/btcbridge/types" ) @@ -32,7 +39,13 @@ func (k Keeper) NewSigningRequest(ctx sdk.Context, sender string, coin sdk.Coin, if len(vault) == 0 { // default to the first vault in the params for now // TODO: select an appropriate vault according to the utxos - vault = k.GetParams(ctx).Senders[0] + p := k.GetParams(ctx) + for i, v := range p.Vaults { + if v.AssetType == types.AssetType_ASSET_TYPE_BTC { + vault = p.Vaults[i].AddressOnBitcoin + break + } + } } utxos := k.GetOrderedUTXOsByAddr(ctx, vault) @@ -122,3 +135,82 @@ func (k Keeper) FilterSigningRequestsByStatus(ctx sdk.Context, req *types.QueryS }) return signingRequests } + +// Process Bitcoin Withdraw Transaction +func (k Keeper) ProcessBitcoinWithdrawTransaction(ctx sdk.Context, msg *types.MsgSubmitWithdrawTransactionRequest) error { + + ctx.Logger().Info("accept bitcoin deposit tx", "blockhash", msg.Blockhash) + + param := k.GetParams(ctx) + header := k.GetBlockHeader(ctx, msg.Blockhash) + // Check if block confirmed + if header == nil { + return types.ErrBlockNotFound + } + + best := k.GetBestBlockHeader(ctx) + // Check if the block is confirmed + if best.Height-header.Height < uint64(param.Confirmations) { + return types.ErrNotConfirmed + } + // Check if the block is within the acceptable depth + if best.Height-header.Height > param.MaxAcceptableBlockDepth { + return types.ErrExceedMaxAcceptanceDepth + } + + // Decode the base64 transaction + txBytes, err := base64.StdEncoding.DecodeString(msg.TxBytes) + if err != nil { + fmt.Println("Error decoding transaction from base64:", err) + return err + } + + // Create a new transaction + var tx wire.MsgTx + err = tx.Deserialize(bytes.NewReader(txBytes)) + if err != nil { + fmt.Println("Error deserializing transaction:", err) + return err + } + uTx := btcutil.NewTx(&tx) + if len(uTx.MsgTx().TxIn) < 1 { + return types.ErrInvalidBtcTransaction + } + + // Validate the transaction + if err := blockchain.CheckTransactionSanity(uTx); err != nil { + fmt.Println("Transaction is not valid:", err) + return err + } + + // extract senders from the previous transaction + prevTxBytes, err := base64.StdEncoding.DecodeString(msg.PrevTxBytes) + if err != nil { + fmt.Println("Error decoding transaction from base64:", err) + return err + } + + // Create a new transaction + var prevMsgTx wire.MsgTx + err = prevMsgTx.Deserialize(bytes.NewReader(prevTxBytes)) + if err != nil { + fmt.Println("Error deserializing transaction:", err) + return err + } + + prevTx := btcutil.NewTx(&prevMsgTx) + if len(prevTx.MsgTx().TxOut) < 1 { + return types.ErrInvalidBtcTransaction + } + // Validate the transaction + if err := blockchain.CheckTransactionSanity(prevTx); err != nil { + fmt.Println("Transaction is not valid:", err) + return err + } + + if uTx.MsgTx().TxIn[0].PreviousOutPoint.Hash.String() != prevTx.Hash().String() { + return types.ErrInvalidBtcTransaction + } + + return nil +} diff --git a/x/btcbridge/keeper/msg_server.go b/x/btcbridge/keeper/msg_server.go index 53246b5f..c4b92434 100644 --- a/x/btcbridge/keeper/msg_server.go +++ b/x/btcbridge/keeper/msg_server.go @@ -49,7 +49,7 @@ func (m msgServer) SubmitBlockHeaders(goCtx context.Context, msg *types.MsgSubmi // No Permission check required for this message // Since everyone can submit a transaction to mint voucher tokens // This message is usually sent by relayers -func (m msgServer) SubmitTransaction(goCtx context.Context, msg *types.MsgSubmitTransactionRequest) (*types.MsgSubmitTransactionResponse, error) { +func (m msgServer) SubmitDepositTransaction(goCtx context.Context, msg *types.MsgSubmitDepositTransactionRequest) (*types.MsgSubmitDepositTransactionResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) if err := msg.ValidateBasic(); err != nil { @@ -68,12 +68,39 @@ func (m msgServer) SubmitTransaction(goCtx context.Context, msg *types.MsgSubmit sdk.NewAttribute("txBytes", msg.TxBytes), ) - return &types.MsgSubmitTransactionResponse{}, nil + return &types.MsgSubmitDepositTransactionResponse{}, nil + +} + +// SubmitTransaction implements types.MsgServer. +// No Permission check required for this message +// Since everyone can submit a transaction to mint voucher tokens +// This message is usually sent by relayers +func (m msgServer) SubmitWithdrawTransaction(goCtx context.Context, msg *types.MsgSubmitWithdrawTransactionRequest) (*types.MsgSubmitWithdrawTransactionResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + + if err := msg.ValidateBasic(); err != nil { + ctx.Logger().Error("Error validating basic", "error", err) + return nil, err + } + + if err := m.ProcessBitcoinWithdrawTransaction(ctx, msg); err != nil { + ctx.Logger().Error("Error processing bitcoin deposit transaction", "error", err) + return nil, err + } + + // Emit Events + m.EmitEvent(ctx, msg.Sender, + sdk.NewAttribute("blockhash", msg.Blockhash), + sdk.NewAttribute("txBytes", msg.TxBytes), + ) + + return &types.MsgSubmitWithdrawTransactionResponse{}, nil } // UpdateSenders implements types.MsgServer. -func (m msgServer) UpdateSenders(goCtx context.Context, msg *types.MsgUpdateSendersRequest) (*types.MsgUpdateSendersResponse, error) { +func (m msgServer) UpdateQualifiedRelayers(goCtx context.Context, msg *types.MsgUpdateQualifiedRelayersRequest) (*types.MsgUpdateQualifiedRelayersResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) if err := msg.ValidateBasic(); err != nil { return nil, err @@ -86,11 +113,11 @@ func (m msgServer) UpdateSenders(goCtx context.Context, msg *types.MsgUpdateSend } // Set block headers - m.SetParams(ctx, types.NewParams(msg.Senders)) + m.SetParams(ctx, types.NewParams(msg.Relayers)) // Emit events - return &types.MsgUpdateSendersResponse{}, nil + return &types.MsgUpdateQualifiedRelayersResponse{}, nil } func (m msgServer) WithdrawBitcoin(goCtx context.Context, msg *types.MsgWithdrawBitcoinRequest) (*types.MsgWithdrawBitcoinResponse, error) { diff --git a/x/btcbridge/types/codec.go b/x/btcbridge/types/codec.go index 7c4cfced..c569eb31 100644 --- a/x/btcbridge/types/codec.go +++ b/x/btcbridge/types/codec.go @@ -8,16 +8,20 @@ import ( ) func RegisterCodec(cdc *codec.LegacyAmino) { - cdc.RegisterConcrete(&MsgSubmitBlockHeaderRequest{}, "btclightclient/MsgSubmitBlockHeaderRequest", nil) - cdc.RegisterConcrete(&MsgUpdateSendersRequest{}, "btclightclient/MsgUpdateSendersRequest", nil) - cdc.RegisterConcrete(&MsgSubmitTransactionRequest{}, "btclightclient/MsgSubmitTransactionRequest", nil) + cdc.RegisterConcrete(&MsgSubmitBlockHeaderRequest{}, "btcbridge/MsgSubmitBlockHeaderRequest", nil) + cdc.RegisterConcrete(&MsgUpdateQualifiedRelayersRequest{}, "btcbridge/MsgUpdateQualifiedRelayersRequest", nil) + cdc.RegisterConcrete(&MsgSubmitDepositTransactionRequest{}, "btcbridge/MsgSubmitDepositTransactionRequest", nil) + cdc.RegisterConcrete(&MsgSubmitWithdrawSignaturesRequest{}, "btcbridge/MsgSubmitWithdrawSignaturesRequest", nil) + cdc.RegisterConcrete(&MsgSubmitWithdrawTransactionRequest{}, "btcbridge/MsgSubmitWithdrawTransactionRequest", nil) // this line is used by starport scaffolding # 2 } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSubmitBlockHeaderRequest{}) - registry.RegisterImplementations((*sdk.Msg)(nil), &MsgUpdateSendersRequest{}) - registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSubmitTransactionRequest{}) + registry.RegisterImplementations((*sdk.Msg)(nil), &MsgUpdateQualifiedRelayersRequest{}) + registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSubmitDepositTransactionRequest{}) + registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSubmitWithdrawSignaturesRequest{}) + registry.RegisterImplementations((*sdk.Msg)(nil), &MsgSubmitWithdrawTransactionRequest{}) // this line is used by starport scaffolding # 3 msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/btcbridge/types/message_submit_transaction.go b/x/btcbridge/types/message_submit_deposit_transaction.go similarity index 67% rename from x/btcbridge/types/message_submit_transaction.go rename to x/btcbridge/types/message_submit_deposit_transaction.go index 7bd5ca3f..cc9e03ec 100644 --- a/x/btcbridge/types/message_submit_transaction.go +++ b/x/btcbridge/types/message_submit_deposit_transaction.go @@ -5,15 +5,15 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -const TypeMsgSubmitTransaction = "submit_transaction" +const TypeMsgSubmitDepositTransaction = "submit_deposit_transaction" func NewMsgSubmitTransactionRequest( sender string, blockhash string, transaction string, proof []string, -) *MsgSubmitTransactionRequest { - return &MsgSubmitTransactionRequest{ +) *MsgSubmitDepositTransactionRequest { + return &MsgSubmitDepositTransactionRequest{ Sender: sender, Blockhash: blockhash, TxBytes: transaction, @@ -21,15 +21,15 @@ func NewMsgSubmitTransactionRequest( } } -func (msg *MsgSubmitTransactionRequest) Route() string { +func (msg *MsgSubmitDepositTransactionRequest) Route() string { return RouterKey } -func (msg *MsgSubmitTransactionRequest) Type() string { - return TypeMsgSubmitTransaction +func (msg *MsgSubmitDepositTransactionRequest) Type() string { + return TypeMsgSubmitDepositTransaction } -func (msg *MsgSubmitTransactionRequest) GetSigners() []sdk.AccAddress { +func (msg *MsgSubmitDepositTransactionRequest) GetSigners() []sdk.AccAddress { Sender, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { panic(err) @@ -37,12 +37,12 @@ func (msg *MsgSubmitTransactionRequest) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{Sender} } -func (msg *MsgSubmitTransactionRequest) GetSignBytes() []byte { +func (msg *MsgSubmitDepositTransactionRequest) GetSignBytes() []byte { bz := ModuleCdc.MustMarshalJSON(msg) return sdk.MustSortJSON(bz) } -func (msg *MsgSubmitTransactionRequest) ValidateBasic() error { +func (msg *MsgSubmitDepositTransactionRequest) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { return sdkerrors.Wrapf(err, "invalid Sender address (%s)", err) diff --git a/x/btcbridge/types/message_submit_withdraw_transaction.go b/x/btcbridge/types/message_submit_withdraw_transaction.go new file mode 100644 index 00000000..26ffb346 --- /dev/null +++ b/x/btcbridge/types/message_submit_withdraw_transaction.go @@ -0,0 +1,68 @@ +package types + +import ( + sdkerrors "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const TypeMsgSubmitWithdrawTransaction = "submit_withdraw_transaction" + +func NewMsgSubmitWithdrawTransactionRequest( + sender string, + blockhash string, + transaction string, + proof []string, +) *MsgSubmitWithdrawTransactionRequest { + return &MsgSubmitWithdrawTransactionRequest{ + Sender: sender, + Blockhash: blockhash, + TxBytes: transaction, + Proof: proof, + } +} + +func (msg *MsgSubmitWithdrawTransactionRequest) Route() string { + return RouterKey +} + +func (msg *MsgSubmitWithdrawTransactionRequest) Type() string { + return TypeMsgSubmitDepositTransaction +} + +func (msg *MsgSubmitWithdrawTransactionRequest) GetSigners() []sdk.AccAddress { + Sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{Sender} +} + +func (msg *MsgSubmitWithdrawTransactionRequest) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgSubmitWithdrawTransactionRequest) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return sdkerrors.Wrapf(err, "invalid Sender address (%s)", err) + } + + if len(msg.Blockhash) == 0 { + return sdkerrors.Wrap(ErrInvalidBtcTransaction, "blockhash cannot be empty") + } + + if len(msg.PrevTxBytes) == 0 { + return sdkerrors.Wrap(ErrInvalidBtcTransaction, "transaction cannot be empty") + } + + if len(msg.TxBytes) == 0 { + return sdkerrors.Wrap(ErrInvalidBtcTransaction, "transaction cannot be empty") + } + + if len(msg.Proof) == 0 { + return sdkerrors.Wrap(ErrInvalidBtcTransaction, "proof cannot be empty") + } + + return nil +} diff --git a/x/btcbridge/types/message_update_senders.go b/x/btcbridge/types/message_update_senders.go index b6e451fc..2fb949fb 100644 --- a/x/btcbridge/types/message_update_senders.go +++ b/x/btcbridge/types/message_update_senders.go @@ -5,27 +5,27 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -const TypeMsgUpdateSenders = "update_senders" +const TypeMsgUpdateSenders = "update_qualifed_relayers" func NewMsgUpdateSendersRequest( sender string, - senders []string, -) *MsgUpdateSendersRequest { - return &MsgUpdateSendersRequest{ - Sender: sender, - Senders: senders, + relayers []string, +) *MsgUpdateQualifiedRelayersRequest { + return &MsgUpdateQualifiedRelayersRequest{ + Sender: sender, + Relayers: relayers, } } -func (msg *MsgUpdateSendersRequest) Route() string { +func (msg *MsgUpdateQualifiedRelayersRequest) Route() string { return RouterKey } -func (msg *MsgUpdateSendersRequest) Type() string { +func (msg *MsgUpdateQualifiedRelayersRequest) Type() string { return TypeMsgUpdateSenders } -func (msg *MsgUpdateSendersRequest) GetSigners() []sdk.AccAddress { +func (msg *MsgUpdateQualifiedRelayersRequest) GetSigners() []sdk.AccAddress { Sender, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { panic(err) @@ -33,22 +33,22 @@ func (msg *MsgUpdateSendersRequest) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{Sender} } -func (msg *MsgUpdateSendersRequest) GetSignBytes() []byte { +func (msg *MsgUpdateQualifiedRelayersRequest) GetSignBytes() []byte { bz := ModuleCdc.MustMarshalJSON(msg) return sdk.MustSortJSON(bz) } -func (msg *MsgUpdateSendersRequest) ValidateBasic() error { +func (msg *MsgUpdateQualifiedRelayersRequest) ValidateBasic() error { _, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { - return sdkerrors.Wrapf(err, "invalid Sender address (%s)", err) + return sdkerrors.Wrapf(err, "invalid sender address (%s)", err) } - if len(msg.Senders) == 0 { - return sdkerrors.Wrap(ErrInvalidSenders, "senders cannot be empty") + if len(msg.Relayers) == 0 { + return sdkerrors.Wrap(ErrInvalidSenders, "relayers cannot be empty") } - for _, sender := range msg.Senders { + for _, sender := range msg.Relayers { _, err := sdk.AccAddressFromBech32(sender) if err != nil { return sdkerrors.Wrapf(ErrInvalidSenders, "address (%s) is invalid", sender) diff --git a/x/btcbridge/types/params.go b/x/btcbridge/types/params.go index 20d41e24..892d8342 100644 --- a/x/btcbridge/types/params.go +++ b/x/btcbridge/types/params.go @@ -5,10 +5,13 @@ import sdk "github.com/cosmos/cosmos-sdk/types" // NewParams creates a new Params instance func NewParams(senders []string) Params { return Params{ - Senders: senders, + QualifiedRelayers: senders, Confirmations: 2, MaxAcceptableBlockDepth: 100, - BtcVoucherDenom: "sat", + Vaults: []*Vault{{ + AddressOnBitcoin: "", + AssetType: AssetType_ASSET_TYPE_BTC, + }}, } } @@ -19,7 +22,7 @@ func DefaultParams() Params { // Validate validates the set of params func (p Params) Validate() error { - for _, sender := range p.Senders { + for _, sender := range p.QualifiedRelayers { _, err := sdk.AccAddressFromBech32(sender) if err != nil { return err @@ -30,10 +33,21 @@ func (p Params) Validate() error { // checks if the given address is an authorized sender func (p Params) IsAuthorizedSender(sender string) bool { - for _, s := range p.Senders { + for _, s := range p.QualifiedRelayers { if s == sender { return true } } return false } + +// SelectVaultByBitcoinAddress returns the vault if the address is found +// returns the vault if the address is found +func SelectVaultByBitcoinAddress(vaults []*Vault, address string) *Vault { + for _, v := range vaults { + if v.AddressOnBitcoin == address { + return v + } + } + return nil +} diff --git a/x/btcbridge/types/params.pb.go b/x/btcbridge/types/params.pb.go index 3366f111..4559e2da 100644 --- a/x/btcbridge/types/params.pb.go +++ b/x/btcbridge/types/params.pb.go @@ -23,18 +23,53 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// AssetType defines the type of asset +type AssetType int32 + +const ( + // Unspecified asset type + AssetType_ASSET_TYPE_UNSPECIFIED AssetType = 0 + // BTC + AssetType_ASSET_TYPE_BTC AssetType = 1 + // BRC20: ordi, sats + AssetType_ASSET_TYPE_BRC20 AssetType = 2 + // RUNE, dog*go*to*the*moon + AssetType_ASSET_TYPE_RUNE AssetType = 3 +) + +var AssetType_name = map[int32]string{ + 0: "ASSET_TYPE_UNSPECIFIED", + 1: "ASSET_TYPE_BTC", + 2: "ASSET_TYPE_BRC20", + 3: "ASSET_TYPE_RUNE", +} + +var AssetType_value = map[string]int32{ + "ASSET_TYPE_UNSPECIFIED": 0, + "ASSET_TYPE_BTC": 1, + "ASSET_TYPE_BRC20": 2, + "ASSET_TYPE_RUNE": 3, +} + +func (x AssetType) String() string { + return proto.EnumName(AssetType_name, int32(x)) +} + +func (AssetType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_f1d33573cda8a6d2, []int{0} +} + // Params defines the parameters for the module. type Params struct { // Only accept blocks sending from these addresses - Senders []string `protobuf:"bytes,1,rep,name=senders,proto3" json:"senders,omitempty"` + QualifiedRelayers []string `protobuf:"bytes,1,rep,name=qualified_relayers,json=qualifiedRelayers,proto3" json:"qualified_relayers,omitempty"` // The minimum number of confirmations required for a block to be accepted Confirmations int32 `protobuf:"varint,2,opt,name=confirmations,proto3" json:"confirmations,omitempty"` // Indicates the maximum depth or distance from the latest block up to which transactions are considered for acceptance. MaxAcceptableBlockDepth uint64 `protobuf:"varint,3,opt,name=max_acceptable_block_depth,json=maxAcceptableBlockDepth,proto3" json:"max_acceptable_block_depth,omitempty"` // the denomanation of the voucher - BtcVoucherDenom string `protobuf:"bytes,4,opt,name=btc_voucher_denom,json=btcVoucherDenom,proto3" json:"btc_voucher_denom,omitempty"` - // the address to which the voucher is sent - BtcVoucherAddress []string `protobuf:"bytes,5,rep,name=btc_voucher_address,json=btcVoucherAddress,proto3" json:"btc_voucher_address,omitempty"` + BtcVoucherDenom string `protobuf:"bytes,4,opt,name=btc_voucher_denom,json=btcVoucherDenom,proto3" json:"btc_voucher_denom,omitempty"` + Vaults []*Vault `protobuf:"bytes,5,rep,name=vaults,proto3" json:"vaults,omitempty"` } func (m *Params) Reset() { *m = Params{} } @@ -70,9 +105,9 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo -func (m *Params) GetSenders() []string { +func (m *Params) GetQualifiedRelayers() []string { if m != nil { - return m.Senders + return m.QualifiedRelayers } return nil } @@ -98,40 +133,106 @@ func (m *Params) GetBtcVoucherDenom() string { return "" } -func (m *Params) GetBtcVoucherAddress() []string { +func (m *Params) GetVaults() []*Vault { if m != nil { - return m.BtcVoucherAddress + return m.Vaults } return nil } +// Vault defines the parameters for the module. +type Vault struct { + // the depositor should send their btc to this address + AddressOnBitcoin string `protobuf:"bytes,1,opt,name=address_on_bitcoin,json=addressOnBitcoin,proto3" json:"address_on_bitcoin,omitempty"` + // the address to which the voucher is sent + AssetType AssetType `protobuf:"varint,2,opt,name=asset_type,json=assetType,proto3,enum=side.btcbridge.AssetType" json:"asset_type,omitempty"` +} + +func (m *Vault) Reset() { *m = Vault{} } +func (m *Vault) String() string { return proto.CompactTextString(m) } +func (*Vault) ProtoMessage() {} +func (*Vault) Descriptor() ([]byte, []int) { + return fileDescriptor_f1d33573cda8a6d2, []int{1} +} +func (m *Vault) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Vault) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Vault.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 *Vault) XXX_Merge(src proto.Message) { + xxx_messageInfo_Vault.Merge(m, src) +} +func (m *Vault) XXX_Size() int { + return m.Size() +} +func (m *Vault) XXX_DiscardUnknown() { + xxx_messageInfo_Vault.DiscardUnknown(m) +} + +var xxx_messageInfo_Vault proto.InternalMessageInfo + +func (m *Vault) GetAddressOnBitcoin() string { + if m != nil { + return m.AddressOnBitcoin + } + return "" +} + +func (m *Vault) GetAssetType() AssetType { + if m != nil { + return m.AssetType + } + return AssetType_ASSET_TYPE_UNSPECIFIED +} + func init() { + proto.RegisterEnum("side.btcbridge.AssetType", AssetType_name, AssetType_value) proto.RegisterType((*Params)(nil), "side.btcbridge.Params") + proto.RegisterType((*Vault)(nil), "side.btcbridge.Vault") } func init() { proto.RegisterFile("side/btcbridge/params.proto", fileDescriptor_f1d33573cda8a6d2) } var fileDescriptor_f1d33573cda8a6d2 = []byte{ - // 292 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x54, 0x90, 0xbd, 0x4e, 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 0x0b, 0x59, 0x69, 0x85, 0x47, 0x11, 0x88, 0xa7, 0xd9, 0x09, 0x73, 0xfc, - 0xa1, 0xef, 0x57, 0xbe, 0x46, 0x09, 0x3c, 0x3d, 0x74, 0xa9, 0x10, 0x46, 0x5a, 0x8b, 0xc7, 0xe1, - 0xe8, 0xd9, 0xaf, 0xbd, 0xe8, 0xc1, 0xf2, 0xee, 0xbd, 0x25, 0x60, 0xd7, 0x12, 0xf0, 0xd9, 0x12, - 0xf0, 0xd6, 0x91, 0xc1, 0xae, 0x23, 0x83, 0x8f, 0x8e, 0x0c, 0x1e, 0x93, 0xa2, 0x74, 0xeb, 0x2d, - 0x4b, 0xb8, 0x56, 0xa9, 0x9f, 0x2b, 0x6c, 0xc2, 0xf5, 0x26, 0x84, 0xb4, 0x39, 0x98, 0xd6, 0xbd, - 0xd6, 0xd2, 0xb2, 0x49, 0x10, 0x6e, 0xbe, 0x03, 0x00, 0x00, 0xff, 0xff, 0xfa, 0x67, 0x7f, 0x23, - 0x79, 0x01, 0x00, 0x00, + // 436 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x92, 0x4f, 0x6f, 0xd3, 0x30, + 0x18, 0xc6, 0xeb, 0x75, 0xad, 0x54, 0x23, 0xba, 0xcc, 0x0c, 0x08, 0x45, 0x8a, 0xa2, 0x89, 0x43, + 0x34, 0xb1, 0x04, 0x95, 0x0b, 0x12, 0xa7, 0xfe, 0x09, 0x62, 0x97, 0x51, 0xb9, 0xdd, 0x24, 0xb8, + 0x58, 0xb6, 0xe3, 0xb6, 0x16, 0x49, 0x1c, 0x62, 0x77, 0x6a, 0xbf, 0x05, 0x1f, 0x8b, 0xe3, 0x8e, + 0x1c, 0x51, 0xfb, 0x19, 0xb8, 0x23, 0xa7, 0xa5, 0xea, 0x76, 0x7b, 0xf3, 0xfb, 0x3d, 0xd1, 0xeb, + 0x47, 0x7a, 0xe1,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0x26, 0x49, 0x29, 0xb4, 0x26, 0x2a, + 0x27, 0x4c, 0x1a, 0xae, 0x64, 0xee, 0x82, 0x6a, 0x89, 0xb3, 0x33, 0x5f, 0xf2, 0xfe, 0x96, 0xa3, + 0x0f, 0x10, 0x52, 0xad, 0x85, 0x21, 0x66, 0x55, 0x88, 0xaa, 0x71, 0xbb, 0xfb, 0xea, 0xf1, 0xa6, + 0x9e, 0x4d, 0x4c, 0x56, 0x85, 0xc0, 0x2d, 0xfa, 0x7f, 0xbc, 0x98, 0xc2, 0xd6, 0x9e, 0xa3, 0x0e, + 0x7c, 0xd1, 0x1b, 0x8f, 0xe3, 0x09, 0x99, 0x7c, 0x1d, 0xc5, 0xe4, 0xe6, 0x7a, 0x3c, 0x8a, 0x07, + 0x57, 0x9f, 0xae, 0xe2, 0xa1, 0x53, 0x43, 0x08, 0xb6, 0x0f, 0x5c, 0x7f, 0x32, 0x70, 0x00, 0x3a, + 0x83, 0xce, 0x21, 0xc3, 0x83, 0xee, 0x3b, 0xe7, 0x08, 0x3d, 0x83, 0x27, 0x07, 0x14, 0xdf, 0x5c, + 0xc7, 0x4e, 0xbd, 0xff, 0xf9, 0xd7, 0xda, 0x03, 0xf7, 0x6b, 0x0f, 0xfc, 0x59, 0x7b, 0xe0, 0xe7, + 0xc6, 0xab, 0xdd, 0x6f, 0xbc, 0xda, 0xef, 0x8d, 0x57, 0xfb, 0x16, 0xce, 0xa4, 0x99, 0x2f, 0x58, + 0xc8, 0x55, 0x16, 0xd9, 0x17, 0x57, 0x07, 0xc0, 0x55, 0x5a, 0x7d, 0x44, 0xcb, 0x83, 0x3b, 0xb2, + 0xe5, 0x34, 0x6b, 0x56, 0x81, 0xf7, 0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0x9c, 0xa6, 0x2d, 0x5f, + 0x66, 0x02, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -154,11 +255,16 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.BtcVoucherAddress) > 0 { - for iNdEx := len(m.BtcVoucherAddress) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.BtcVoucherAddress[iNdEx]) - copy(dAtA[i:], m.BtcVoucherAddress[iNdEx]) - i = encodeVarintParams(dAtA, i, uint64(len(m.BtcVoucherAddress[iNdEx]))) + if len(m.Vaults) > 0 { + for iNdEx := len(m.Vaults) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Vaults[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintParams(dAtA, i, uint64(size)) + } i-- dAtA[i] = 0x2a } @@ -180,11 +286,11 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x10 } - if len(m.Senders) > 0 { - for iNdEx := len(m.Senders) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Senders[iNdEx]) - copy(dAtA[i:], m.Senders[iNdEx]) - i = encodeVarintParams(dAtA, i, uint64(len(m.Senders[iNdEx]))) + if len(m.QualifiedRelayers) > 0 { + for iNdEx := len(m.QualifiedRelayers) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.QualifiedRelayers[iNdEx]) + copy(dAtA[i:], m.QualifiedRelayers[iNdEx]) + i = encodeVarintParams(dAtA, i, uint64(len(m.QualifiedRelayers[iNdEx]))) i-- dAtA[i] = 0xa } @@ -192,6 +298,41 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *Vault) 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 *Vault) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Vault) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.AssetType != 0 { + i = encodeVarintParams(dAtA, i, uint64(m.AssetType)) + i-- + dAtA[i] = 0x10 + } + if len(m.AddressOnBitcoin) > 0 { + i -= len(m.AddressOnBitcoin) + copy(dAtA[i:], m.AddressOnBitcoin) + i = encodeVarintParams(dAtA, i, uint64(len(m.AddressOnBitcoin))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintParams(dAtA []byte, offset int, v uint64) int { offset -= sovParams(v) base := offset @@ -209,8 +350,8 @@ func (m *Params) Size() (n int) { } var l int _ = l - if len(m.Senders) > 0 { - for _, s := range m.Senders { + if len(m.QualifiedRelayers) > 0 { + for _, s := range m.QualifiedRelayers { l = len(s) n += 1 + l + sovParams(uint64(l)) } @@ -225,15 +366,31 @@ func (m *Params) Size() (n int) { if l > 0 { n += 1 + l + sovParams(uint64(l)) } - if len(m.BtcVoucherAddress) > 0 { - for _, s := range m.BtcVoucherAddress { - l = len(s) + if len(m.Vaults) > 0 { + for _, e := range m.Vaults { + l = e.Size() n += 1 + l + sovParams(uint64(l)) } } return n } +func (m *Vault) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.AddressOnBitcoin) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + if m.AssetType != 0 { + n += 1 + sovParams(uint64(m.AssetType)) + } + return n +} + func sovParams(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -271,7 +428,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Senders", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field QualifiedRelayers", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -299,7 +456,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Senders = append(m.Senders, string(dAtA[iNdEx:postIndex])) + m.QualifiedRelayers = append(m.QualifiedRelayers, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex case 2: if wireType != 0 { @@ -373,7 +530,91 @@ func (m *Params) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field BtcVoucherAddress", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Vaults", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthParams + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Vaults = append(m.Vaults, &Vault{}) + if err := m.Vaults[len(m.Vaults)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipParams(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthParams + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Vault) 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 ErrIntOverflowParams + } + 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: Vault: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Vault: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AddressOnBitcoin", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -401,8 +642,27 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.BtcVoucherAddress = append(m.BtcVoucherAddress, string(dAtA[iNdEx:postIndex])) + m.AddressOnBitcoin = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field AssetType", wireType) + } + m.AssetType = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.AssetType |= AssetType(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipParams(dAtA[iNdEx:]) diff --git a/x/btcbridge/types/tx.pb.go b/x/btcbridge/types/tx.pb.go index cde68829..75f0bfd3 100644 --- a/x/btcbridge/types/tx.pb.go +++ b/x/btcbridge/types/tx.pb.go @@ -119,7 +119,7 @@ func (m *MsgSubmitBlockHeadersResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSubmitBlockHeadersResponse proto.InternalMessageInfo // MsgSubmitTransactionRequest defines the Msg/SubmitTransaction request type. -type MsgSubmitTransactionRequest struct { +type MsgSubmitDepositTransactionRequest struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` Blockhash string `protobuf:"bytes,2,opt,name=blockhash,proto3" json:"blockhash,omitempty"` // the tx bytes in base64 format @@ -130,18 +130,18 @@ type MsgSubmitTransactionRequest struct { Proof []string `protobuf:"bytes,5,rep,name=proof,proto3" json:"proof,omitempty"` } -func (m *MsgSubmitTransactionRequest) Reset() { *m = MsgSubmitTransactionRequest{} } -func (m *MsgSubmitTransactionRequest) String() string { return proto.CompactTextString(m) } -func (*MsgSubmitTransactionRequest) ProtoMessage() {} -func (*MsgSubmitTransactionRequest) Descriptor() ([]byte, []int) { +func (m *MsgSubmitDepositTransactionRequest) Reset() { *m = MsgSubmitDepositTransactionRequest{} } +func (m *MsgSubmitDepositTransactionRequest) String() string { return proto.CompactTextString(m) } +func (*MsgSubmitDepositTransactionRequest) ProtoMessage() {} +func (*MsgSubmitDepositTransactionRequest) Descriptor() ([]byte, []int) { return fileDescriptor_785ca8e1e4227068, []int{2} } -func (m *MsgSubmitTransactionRequest) XXX_Unmarshal(b []byte) error { +func (m *MsgSubmitDepositTransactionRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgSubmitTransactionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgSubmitDepositTransactionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgSubmitTransactionRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgSubmitDepositTransactionRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -151,47 +151,47 @@ func (m *MsgSubmitTransactionRequest) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *MsgSubmitTransactionRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSubmitTransactionRequest.Merge(m, src) +func (m *MsgSubmitDepositTransactionRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSubmitDepositTransactionRequest.Merge(m, src) } -func (m *MsgSubmitTransactionRequest) XXX_Size() int { +func (m *MsgSubmitDepositTransactionRequest) XXX_Size() int { return m.Size() } -func (m *MsgSubmitTransactionRequest) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSubmitTransactionRequest.DiscardUnknown(m) +func (m *MsgSubmitDepositTransactionRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSubmitDepositTransactionRequest.DiscardUnknown(m) } -var xxx_messageInfo_MsgSubmitTransactionRequest proto.InternalMessageInfo +var xxx_messageInfo_MsgSubmitDepositTransactionRequest proto.InternalMessageInfo -func (m *MsgSubmitTransactionRequest) GetSender() string { +func (m *MsgSubmitDepositTransactionRequest) GetSender() string { if m != nil { return m.Sender } return "" } -func (m *MsgSubmitTransactionRequest) GetBlockhash() string { +func (m *MsgSubmitDepositTransactionRequest) GetBlockhash() string { if m != nil { return m.Blockhash } return "" } -func (m *MsgSubmitTransactionRequest) GetPrevTxBytes() string { +func (m *MsgSubmitDepositTransactionRequest) GetPrevTxBytes() string { if m != nil { return m.PrevTxBytes } return "" } -func (m *MsgSubmitTransactionRequest) GetTxBytes() string { +func (m *MsgSubmitDepositTransactionRequest) GetTxBytes() string { if m != nil { return m.TxBytes } return "" } -func (m *MsgSubmitTransactionRequest) GetProof() []string { +func (m *MsgSubmitDepositTransactionRequest) GetProof() []string { if m != nil { return m.Proof } @@ -199,21 +199,21 @@ func (m *MsgSubmitTransactionRequest) GetProof() []string { } // MsgSubmitTransactionResponse defines the Msg/SubmitTransaction response type. -type MsgSubmitTransactionResponse struct { +type MsgSubmitDepositTransactionResponse struct { } -func (m *MsgSubmitTransactionResponse) Reset() { *m = MsgSubmitTransactionResponse{} } -func (m *MsgSubmitTransactionResponse) String() string { return proto.CompactTextString(m) } -func (*MsgSubmitTransactionResponse) ProtoMessage() {} -func (*MsgSubmitTransactionResponse) Descriptor() ([]byte, []int) { +func (m *MsgSubmitDepositTransactionResponse) Reset() { *m = MsgSubmitDepositTransactionResponse{} } +func (m *MsgSubmitDepositTransactionResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSubmitDepositTransactionResponse) ProtoMessage() {} +func (*MsgSubmitDepositTransactionResponse) Descriptor() ([]byte, []int) { return fileDescriptor_785ca8e1e4227068, []int{3} } -func (m *MsgSubmitTransactionResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgSubmitDepositTransactionResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgSubmitTransactionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgSubmitDepositTransactionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgSubmitTransactionResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgSubmitDepositTransactionResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -223,37 +223,154 @@ func (m *MsgSubmitTransactionResponse) XXX_Marshal(b []byte, deterministic bool) return b[:n], nil } } -func (m *MsgSubmitTransactionResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSubmitTransactionResponse.Merge(m, src) +func (m *MsgSubmitDepositTransactionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSubmitDepositTransactionResponse.Merge(m, src) } -func (m *MsgSubmitTransactionResponse) XXX_Size() int { +func (m *MsgSubmitDepositTransactionResponse) XXX_Size() int { return m.Size() } -func (m *MsgSubmitTransactionResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSubmitTransactionResponse.DiscardUnknown(m) +func (m *MsgSubmitDepositTransactionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSubmitDepositTransactionResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgSubmitTransactionResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgSubmitDepositTransactionResponse proto.InternalMessageInfo + +// MsgSubmitTransactionRequest defines the Msg/SubmitTransaction request type. +type MsgSubmitWithdrawTransactionRequest struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Blockhash string `protobuf:"bytes,2,opt,name=blockhash,proto3" json:"blockhash,omitempty"` + // the tx bytes in base64 format + // used for parsing the sender of the transaction + PrevTxBytes string `protobuf:"bytes,3,opt,name=prev_tx_bytes,json=prevTxBytes,proto3" json:"prev_tx_bytes,omitempty"` + // the tx bytes in base64 format + TxBytes string `protobuf:"bytes,4,opt,name=tx_bytes,json=txBytes,proto3" json:"tx_bytes,omitempty"` + Proof []string `protobuf:"bytes,5,rep,name=proof,proto3" json:"proof,omitempty"` +} + +func (m *MsgSubmitWithdrawTransactionRequest) Reset() { *m = MsgSubmitWithdrawTransactionRequest{} } +func (m *MsgSubmitWithdrawTransactionRequest) String() string { return proto.CompactTextString(m) } +func (*MsgSubmitWithdrawTransactionRequest) ProtoMessage() {} +func (*MsgSubmitWithdrawTransactionRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_785ca8e1e4227068, []int{4} +} +func (m *MsgSubmitWithdrawTransactionRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSubmitWithdrawTransactionRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSubmitWithdrawTransactionRequest.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 *MsgSubmitWithdrawTransactionRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSubmitWithdrawTransactionRequest.Merge(m, src) +} +func (m *MsgSubmitWithdrawTransactionRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgSubmitWithdrawTransactionRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSubmitWithdrawTransactionRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSubmitWithdrawTransactionRequest proto.InternalMessageInfo + +func (m *MsgSubmitWithdrawTransactionRequest) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgSubmitWithdrawTransactionRequest) GetBlockhash() string { + if m != nil { + return m.Blockhash + } + return "" +} + +func (m *MsgSubmitWithdrawTransactionRequest) GetPrevTxBytes() string { + if m != nil { + return m.PrevTxBytes + } + return "" +} + +func (m *MsgSubmitWithdrawTransactionRequest) GetTxBytes() string { + if m != nil { + return m.TxBytes + } + return "" +} + +func (m *MsgSubmitWithdrawTransactionRequest) GetProof() []string { + if m != nil { + return m.Proof + } + return nil +} + +// MsgSubmitTransactionResponse defines the Msg/SubmitTransaction response type. +type MsgSubmitWithdrawTransactionResponse struct { +} + +func (m *MsgSubmitWithdrawTransactionResponse) Reset() { *m = MsgSubmitWithdrawTransactionResponse{} } +func (m *MsgSubmitWithdrawTransactionResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSubmitWithdrawTransactionResponse) ProtoMessage() {} +func (*MsgSubmitWithdrawTransactionResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_785ca8e1e4227068, []int{5} +} +func (m *MsgSubmitWithdrawTransactionResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSubmitWithdrawTransactionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSubmitWithdrawTransactionResponse.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 *MsgSubmitWithdrawTransactionResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSubmitWithdrawTransactionResponse.Merge(m, src) +} +func (m *MsgSubmitWithdrawTransactionResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSubmitWithdrawTransactionResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSubmitWithdrawTransactionResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSubmitWithdrawTransactionResponse proto.InternalMessageInfo // Msg defines the MsgUpdateSender service. -type MsgUpdateSendersRequest struct { +type MsgUpdateQualifiedRelayersRequest struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` // update senders who can send block headers to the side chain - Senders []string `protobuf:"bytes,2,rep,name=senders,proto3" json:"senders,omitempty"` + Relayers []string `protobuf:"bytes,2,rep,name=relayers,proto3" json:"relayers,omitempty"` } -func (m *MsgUpdateSendersRequest) Reset() { *m = MsgUpdateSendersRequest{} } -func (m *MsgUpdateSendersRequest) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateSendersRequest) ProtoMessage() {} -func (*MsgUpdateSendersRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_785ca8e1e4227068, []int{4} +func (m *MsgUpdateQualifiedRelayersRequest) Reset() { *m = MsgUpdateQualifiedRelayersRequest{} } +func (m *MsgUpdateQualifiedRelayersRequest) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateQualifiedRelayersRequest) ProtoMessage() {} +func (*MsgUpdateQualifiedRelayersRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_785ca8e1e4227068, []int{6} } -func (m *MsgUpdateSendersRequest) XXX_Unmarshal(b []byte) error { +func (m *MsgUpdateQualifiedRelayersRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgUpdateSendersRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgUpdateQualifiedRelayersRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgUpdateSendersRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgUpdateQualifiedRelayersRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -263,48 +380,48 @@ func (m *MsgUpdateSendersRequest) XXX_Marshal(b []byte, deterministic bool) ([]b return b[:n], nil } } -func (m *MsgUpdateSendersRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateSendersRequest.Merge(m, src) +func (m *MsgUpdateQualifiedRelayersRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateQualifiedRelayersRequest.Merge(m, src) } -func (m *MsgUpdateSendersRequest) XXX_Size() int { +func (m *MsgUpdateQualifiedRelayersRequest) XXX_Size() int { return m.Size() } -func (m *MsgUpdateSendersRequest) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateSendersRequest.DiscardUnknown(m) +func (m *MsgUpdateQualifiedRelayersRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateQualifiedRelayersRequest.DiscardUnknown(m) } -var xxx_messageInfo_MsgUpdateSendersRequest proto.InternalMessageInfo +var xxx_messageInfo_MsgUpdateQualifiedRelayersRequest proto.InternalMessageInfo -func (m *MsgUpdateSendersRequest) GetSender() string { +func (m *MsgUpdateQualifiedRelayersRequest) GetSender() string { if m != nil { return m.Sender } return "" } -func (m *MsgUpdateSendersRequest) GetSenders() []string { +func (m *MsgUpdateQualifiedRelayersRequest) GetRelayers() []string { if m != nil { - return m.Senders + return m.Relayers } return nil } // MsgUpdateSenderResponse defines the Msg/UpdateSender response type. -type MsgUpdateSendersResponse struct { +type MsgUpdateQualifiedRelayersResponse struct { } -func (m *MsgUpdateSendersResponse) Reset() { *m = MsgUpdateSendersResponse{} } -func (m *MsgUpdateSendersResponse) String() string { return proto.CompactTextString(m) } -func (*MsgUpdateSendersResponse) ProtoMessage() {} -func (*MsgUpdateSendersResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_785ca8e1e4227068, []int{5} +func (m *MsgUpdateQualifiedRelayersResponse) Reset() { *m = MsgUpdateQualifiedRelayersResponse{} } +func (m *MsgUpdateQualifiedRelayersResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateQualifiedRelayersResponse) ProtoMessage() {} +func (*MsgUpdateQualifiedRelayersResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_785ca8e1e4227068, []int{7} } -func (m *MsgUpdateSendersResponse) XXX_Unmarshal(b []byte) error { +func (m *MsgUpdateQualifiedRelayersResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *MsgUpdateSendersResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *MsgUpdateQualifiedRelayersResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_MsgUpdateSendersResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_MsgUpdateQualifiedRelayersResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -314,17 +431,17 @@ func (m *MsgUpdateSendersResponse) XXX_Marshal(b []byte, deterministic bool) ([] return b[:n], nil } } -func (m *MsgUpdateSendersResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgUpdateSendersResponse.Merge(m, src) +func (m *MsgUpdateQualifiedRelayersResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateQualifiedRelayersResponse.Merge(m, src) } -func (m *MsgUpdateSendersResponse) XXX_Size() int { +func (m *MsgUpdateQualifiedRelayersResponse) XXX_Size() int { return m.Size() } -func (m *MsgUpdateSendersResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgUpdateSendersResponse.DiscardUnknown(m) +func (m *MsgUpdateQualifiedRelayersResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateQualifiedRelayersResponse.DiscardUnknown(m) } -var xxx_messageInfo_MsgUpdateSendersResponse proto.InternalMessageInfo +var xxx_messageInfo_MsgUpdateQualifiedRelayersResponse proto.InternalMessageInfo // MsgWithdrawBitcoinRequest defines the Msg/WithdrawBitcoin request type. type MsgWithdrawBitcoinRequest struct { @@ -339,7 +456,7 @@ func (m *MsgWithdrawBitcoinRequest) Reset() { *m = MsgWithdrawBitcoinReq func (m *MsgWithdrawBitcoinRequest) String() string { return proto.CompactTextString(m) } func (*MsgWithdrawBitcoinRequest) ProtoMessage() {} func (*MsgWithdrawBitcoinRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_785ca8e1e4227068, []int{6} + return fileDescriptor_785ca8e1e4227068, []int{8} } func (m *MsgWithdrawBitcoinRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -397,7 +514,7 @@ func (m *MsgWithdrawBitcoinResponse) Reset() { *m = MsgWithdrawBitcoinRe func (m *MsgWithdrawBitcoinResponse) String() string { return proto.CompactTextString(m) } func (*MsgWithdrawBitcoinResponse) ProtoMessage() {} func (*MsgWithdrawBitcoinResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_785ca8e1e4227068, []int{7} + return fileDescriptor_785ca8e1e4227068, []int{9} } func (m *MsgWithdrawBitcoinResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -437,7 +554,7 @@ func (m *MsgSubmitWithdrawSignaturesRequest) Reset() { *m = MsgSubmitWit func (m *MsgSubmitWithdrawSignaturesRequest) String() string { return proto.CompactTextString(m) } func (*MsgSubmitWithdrawSignaturesRequest) ProtoMessage() {} func (*MsgSubmitWithdrawSignaturesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_785ca8e1e4227068, []int{8} + return fileDescriptor_785ca8e1e4227068, []int{10} } func (m *MsgSubmitWithdrawSignaturesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -495,7 +612,7 @@ func (m *MsgSubmitWithdrawSignaturesResponse) Reset() { *m = MsgSubmitWi func (m *MsgSubmitWithdrawSignaturesResponse) String() string { return proto.CompactTextString(m) } func (*MsgSubmitWithdrawSignaturesResponse) ProtoMessage() {} func (*MsgSubmitWithdrawSignaturesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_785ca8e1e4227068, []int{9} + return fileDescriptor_785ca8e1e4227068, []int{11} } func (m *MsgSubmitWithdrawSignaturesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -527,10 +644,12 @@ var xxx_messageInfo_MsgSubmitWithdrawSignaturesResponse proto.InternalMessageInf func init() { proto.RegisterType((*MsgSubmitBlockHeaderRequest)(nil), "side.btcbridge.MsgSubmitBlockHeaderRequest") proto.RegisterType((*MsgSubmitBlockHeadersResponse)(nil), "side.btcbridge.MsgSubmitBlockHeadersResponse") - proto.RegisterType((*MsgSubmitTransactionRequest)(nil), "side.btcbridge.MsgSubmitTransactionRequest") - proto.RegisterType((*MsgSubmitTransactionResponse)(nil), "side.btcbridge.MsgSubmitTransactionResponse") - proto.RegisterType((*MsgUpdateSendersRequest)(nil), "side.btcbridge.MsgUpdateSendersRequest") - proto.RegisterType((*MsgUpdateSendersResponse)(nil), "side.btcbridge.MsgUpdateSendersResponse") + proto.RegisterType((*MsgSubmitDepositTransactionRequest)(nil), "side.btcbridge.MsgSubmitDepositTransactionRequest") + proto.RegisterType((*MsgSubmitDepositTransactionResponse)(nil), "side.btcbridge.MsgSubmitDepositTransactionResponse") + proto.RegisterType((*MsgSubmitWithdrawTransactionRequest)(nil), "side.btcbridge.MsgSubmitWithdrawTransactionRequest") + proto.RegisterType((*MsgSubmitWithdrawTransactionResponse)(nil), "side.btcbridge.MsgSubmitWithdrawTransactionResponse") + proto.RegisterType((*MsgUpdateQualifiedRelayersRequest)(nil), "side.btcbridge.MsgUpdateQualifiedRelayersRequest") + proto.RegisterType((*MsgUpdateQualifiedRelayersResponse)(nil), "side.btcbridge.MsgUpdateQualifiedRelayersResponse") proto.RegisterType((*MsgWithdrawBitcoinRequest)(nil), "side.btcbridge.MsgWithdrawBitcoinRequest") proto.RegisterType((*MsgWithdrawBitcoinResponse)(nil), "side.btcbridge.MsgWithdrawBitcoinResponse") proto.RegisterType((*MsgSubmitWithdrawSignaturesRequest)(nil), "side.btcbridge.MsgSubmitWithdrawSignaturesRequest") @@ -540,43 +659,47 @@ func init() { func init() { proto.RegisterFile("side/btcbridge/tx.proto", fileDescriptor_785ca8e1e4227068) } var fileDescriptor_785ca8e1e4227068 = []byte{ - // 572 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0xdd, 0x6e, 0xd3, 0x30, - 0x18, 0x5d, 0xd6, 0x6d, 0xa5, 0xdf, 0x28, 0x08, 0x6b, 0xda, 0xb2, 0xb4, 0x84, 0x2a, 0x08, 0x51, - 0xfe, 0x52, 0xa9, 0x7b, 0x01, 0xd4, 0xab, 0x49, 0xa8, 0x37, 0xe9, 0x10, 0x12, 0x37, 0x95, 0x9d, - 0xb8, 0x49, 0xc4, 0x1a, 0x07, 0xdb, 0x65, 0xdd, 0x35, 0x2f, 0xc0, 0x63, 0xf0, 0x0e, 0xbc, 0x00, - 0x97, 0xbb, 0xe4, 0x12, 0xb5, 0x2f, 0x82, 0xe2, 0x78, 0x5d, 0xd7, 0xa6, 0x3f, 0xdc, 0xf9, 0xf3, - 0x39, 0xf6, 0x39, 0xfe, 0xbe, 0x93, 0xc0, 0x89, 0x88, 0x03, 0xda, 0x22, 0xd2, 0x27, 0x3c, 0x0e, - 0x42, 0xda, 0x92, 0x63, 0x37, 0xe5, 0x4c, 0x32, 0xf4, 0x28, 0x03, 0xdc, 0x19, 0x60, 0x1d, 0x85, - 0x2c, 0x64, 0x0a, 0x6a, 0x65, 0xab, 0x9c, 0x65, 0xd5, 0x16, 0x8e, 0xa7, 0x98, 0xe3, 0xa1, 0xd0, - 0x60, 0x7d, 0x01, 0x24, 0xb1, 0xf4, 0x59, 0x9c, 0xe4, 0xa8, 0x73, 0x05, 0xb5, 0xae, 0x08, 0x7b, - 0x23, 0x32, 0x8c, 0x65, 0xe7, 0x92, 0xf9, 0x5f, 0xce, 0x29, 0x0e, 0x28, 0xf7, 0xe8, 0xd7, 0x11, - 0x15, 0x12, 0x1d, 0xc3, 0x81, 0xa0, 0x49, 0x40, 0xb9, 0x69, 0x34, 0x8c, 0x66, 0xc5, 0xd3, 0x15, - 0x7a, 0x0f, 0x55, 0x92, 0xb1, 0xfb, 0x91, 0xa2, 0x0b, 0x73, 0xb7, 0x51, 0x6a, 0x1e, 0xb6, 0x6b, - 0xee, 0x7d, 0xbf, 0xee, 0xfc, 0x95, 0x0f, 0xc9, 0x5d, 0x21, 0x9c, 0x67, 0xf0, 0xb4, 0x48, 0x58, - 0x78, 0x54, 0xa4, 0x2c, 0x11, 0xd4, 0xf9, 0x69, 0xcc, 0x59, 0xbb, 0xe0, 0x38, 0x11, 0xd8, 0x97, - 0x31, 0x4b, 0x36, 0x59, 0xab, 0x43, 0x45, 0x09, 0x45, 0x58, 0x44, 0xe6, 0xae, 0x82, 0xee, 0x36, - 0x90, 0x03, 0x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36, 0xf4, 0x66, 0x31, 0xb0, 0x6b, 0x3e, 0x06, - 0xeb, 0xdd, 0x36, 0xe4, 0x99, 0x32, 0x4a, 0xe0, 0xc9, 0x52, 0x24, 0xd6, 0x08, 0x2e, 0x47, 0xdc, - 0x7a, 0xbb, 0x1d, 0x59, 0xeb, 0x11, 0xa8, 0xde, 0x4b, 0x05, 0x7a, 0x59, 0x70, 0xbc, 0x28, 0x84, - 0x56, 0x73, 0x33, 0x51, 0x6b, 0x44, 0xf0, 0x78, 0x61, 0xea, 0xe8, 0x55, 0xc1, 0xe1, 0xe2, 0x04, - 0x5a, 0xaf, 0xb7, 0xa1, 0x6a, 0xa5, 0xef, 0x06, 0x98, 0xab, 0x86, 0x8b, 0xda, 0x2b, 0x1b, 0xb3, - 0x32, 0x6f, 0xd6, 0xd9, 0x7f, 0x9d, 0xc9, 0x5d, 0x74, 0xce, 0x7f, 0x4f, 0x6c, 0xe3, 0x66, 0x62, - 0x1b, 0x7f, 0x27, 0xb6, 0xf1, 0x63, 0x6a, 0xef, 0xdc, 0x4c, 0xed, 0x9d, 0x3f, 0x53, 0x7b, 0xe7, - 0xb3, 0x1b, 0xc6, 0x32, 0x1a, 0x11, 0xd7, 0x67, 0xc3, 0x56, 0x76, 0xb1, 0xfa, 0x9d, 0xfa, 0xec, - 0x52, 0x15, 0xad, 0xf1, 0xfc, 0xcf, 0xfc, 0x3a, 0xa5, 0x82, 0x1c, 0x28, 0xc2, 0xd9, 0xbf, 0x00, - 0x00, 0x00, 0xff, 0xff, 0x51, 0x15, 0x68, 0x74, 0xeb, 0x05, 0x00, 0x00, + // 629 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0xcf, 0x6e, 0xd3, 0x4e, + 0x10, 0xae, 0x9b, 0xfe, 0xcb, 0xf4, 0xd7, 0x1f, 0xd2, 0xaa, 0x6a, 0x53, 0xb7, 0x84, 0x62, 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xce, 0x2f, 0xab, 0x73, 0xbf, 0x2e, 0xab, 0x73, 0xef, 0x6b, 0x01, 0x53, 0xbd, 0xd8, 0xab, + 0x75, 0xf8, 0xa0, 0x9e, 0x14, 0xd6, 0xff, 0xc2, 0x0e, 0xef, 0xeb, 0xa0, 0x3e, 0x1c, 0xff, 0x13, + 0x9f, 0x45, 0x28, 0xbd, 0x25, 0x4d, 0x38, 0xf8, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x59, 0xff, 0xe8, + 0x1d, 0xa8, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -593,10 +716,12 @@ const _ = grpc.SupportPackageIsVersion4 type MsgClient interface { // SubmitBlockHeaders submits bitcoin block headers to the side chain. SubmitBlockHeaders(ctx context.Context, in *MsgSubmitBlockHeaderRequest, opts ...grpc.CallOption) (*MsgSubmitBlockHeadersResponse, error) - // SubmitTransaction submits bitcoin transaction to the side chain. - SubmitTransaction(ctx context.Context, in *MsgSubmitTransactionRequest, opts ...grpc.CallOption) (*MsgSubmitTransactionResponse, error) + // SubmitDepositTransaction submits bitcoin transaction to the side chain. + SubmitDepositTransaction(ctx context.Context, in *MsgSubmitDepositTransactionRequest, opts ...grpc.CallOption) (*MsgSubmitDepositTransactionResponse, error) + // SubmitWithdrawalTransaction submits bitcoin transaction to the side chain. + SubmitWithdrawTransaction(ctx context.Context, in *MsgSubmitWithdrawTransactionRequest, opts ...grpc.CallOption) (*MsgSubmitWithdrawTransactionResponse, error) // UpdateSenders updates the senders of the side chain. - UpdateSenders(ctx context.Context, in *MsgUpdateSendersRequest, opts ...grpc.CallOption) (*MsgUpdateSendersResponse, error) + UpdateQualifiedRelayers(ctx context.Context, in *MsgUpdateQualifiedRelayersRequest, opts ...grpc.CallOption) (*MsgUpdateQualifiedRelayersResponse, error) // WithdrawBitcoin withdraws the bitcoin from the side chain. WithdrawBitcoin(ctx context.Context, in *MsgWithdrawBitcoinRequest, opts ...grpc.CallOption) (*MsgWithdrawBitcoinResponse, error) // SubmitWithdrawSignatures submits the signatures of the withdraw transaction. @@ -620,18 +745,27 @@ func (c *msgClient) SubmitBlockHeaders(ctx context.Context, in *MsgSubmitBlockHe return out, nil } -func (c *msgClient) SubmitTransaction(ctx context.Context, in *MsgSubmitTransactionRequest, opts ...grpc.CallOption) (*MsgSubmitTransactionResponse, error) { - out := new(MsgSubmitTransactionResponse) - err := c.cc.Invoke(ctx, "/side.btcbridge.Msg/SubmitTransaction", in, out, opts...) +func (c *msgClient) SubmitDepositTransaction(ctx context.Context, in *MsgSubmitDepositTransactionRequest, opts ...grpc.CallOption) (*MsgSubmitDepositTransactionResponse, error) { + out := new(MsgSubmitDepositTransactionResponse) + err := c.cc.Invoke(ctx, "/side.btcbridge.Msg/SubmitDepositTransaction", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) SubmitWithdrawTransaction(ctx context.Context, in *MsgSubmitWithdrawTransactionRequest, opts ...grpc.CallOption) (*MsgSubmitWithdrawTransactionResponse, error) { + out := new(MsgSubmitWithdrawTransactionResponse) + err := c.cc.Invoke(ctx, "/side.btcbridge.Msg/SubmitWithdrawTransaction", in, out, opts...) if err != nil { return nil, err } return out, nil } -func (c *msgClient) UpdateSenders(ctx context.Context, in *MsgUpdateSendersRequest, opts ...grpc.CallOption) (*MsgUpdateSendersResponse, error) { - out := new(MsgUpdateSendersResponse) - err := c.cc.Invoke(ctx, "/side.btcbridge.Msg/UpdateSenders", in, out, opts...) +func (c *msgClient) UpdateQualifiedRelayers(ctx context.Context, in *MsgUpdateQualifiedRelayersRequest, opts ...grpc.CallOption) (*MsgUpdateQualifiedRelayersResponse, error) { + out := new(MsgUpdateQualifiedRelayersResponse) + err := c.cc.Invoke(ctx, "/side.btcbridge.Msg/UpdateQualifiedRelayers", in, out, opts...) if err != nil { return nil, err } @@ -660,10 +794,12 @@ func (c *msgClient) SubmitWithdrawSignatures(ctx context.Context, in *MsgSubmitW type MsgServer interface { // SubmitBlockHeaders submits bitcoin block headers to the side chain. SubmitBlockHeaders(context.Context, *MsgSubmitBlockHeaderRequest) (*MsgSubmitBlockHeadersResponse, error) - // SubmitTransaction submits bitcoin transaction to the side chain. - SubmitTransaction(context.Context, *MsgSubmitTransactionRequest) (*MsgSubmitTransactionResponse, error) + // SubmitDepositTransaction submits bitcoin transaction to the side chain. + SubmitDepositTransaction(context.Context, *MsgSubmitDepositTransactionRequest) (*MsgSubmitDepositTransactionResponse, error) + // SubmitWithdrawalTransaction submits bitcoin transaction to the side chain. + SubmitWithdrawTransaction(context.Context, *MsgSubmitWithdrawTransactionRequest) (*MsgSubmitWithdrawTransactionResponse, error) // UpdateSenders updates the senders of the side chain. - UpdateSenders(context.Context, *MsgUpdateSendersRequest) (*MsgUpdateSendersResponse, error) + UpdateQualifiedRelayers(context.Context, *MsgUpdateQualifiedRelayersRequest) (*MsgUpdateQualifiedRelayersResponse, error) // WithdrawBitcoin withdraws the bitcoin from the side chain. WithdrawBitcoin(context.Context, *MsgWithdrawBitcoinRequest) (*MsgWithdrawBitcoinResponse, error) // SubmitWithdrawSignatures submits the signatures of the withdraw transaction. @@ -677,11 +813,14 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) SubmitBlockHeaders(ctx context.Context, req *MsgSubmitBlockHeaderRequest) (*MsgSubmitBlockHeadersResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SubmitBlockHeaders not implemented") } -func (*UnimplementedMsgServer) SubmitTransaction(ctx context.Context, req *MsgSubmitTransactionRequest) (*MsgSubmitTransactionResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method SubmitTransaction not implemented") +func (*UnimplementedMsgServer) SubmitDepositTransaction(ctx context.Context, req *MsgSubmitDepositTransactionRequest) (*MsgSubmitDepositTransactionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SubmitDepositTransaction not implemented") } -func (*UnimplementedMsgServer) UpdateSenders(ctx context.Context, req *MsgUpdateSendersRequest) (*MsgUpdateSendersResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UpdateSenders not implemented") +func (*UnimplementedMsgServer) SubmitWithdrawTransaction(ctx context.Context, req *MsgSubmitWithdrawTransactionRequest) (*MsgSubmitWithdrawTransactionResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SubmitWithdrawTransaction not implemented") +} +func (*UnimplementedMsgServer) UpdateQualifiedRelayers(ctx context.Context, req *MsgUpdateQualifiedRelayersRequest) (*MsgUpdateQualifiedRelayersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateQualifiedRelayers not implemented") } func (*UnimplementedMsgServer) WithdrawBitcoin(ctx context.Context, req *MsgWithdrawBitcoinRequest) (*MsgWithdrawBitcoinResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method WithdrawBitcoin not implemented") @@ -712,38 +851,56 @@ func _Msg_SubmitBlockHeaders_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } -func _Msg_SubmitTransaction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgSubmitTransactionRequest) +func _Msg_SubmitDepositTransaction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSubmitDepositTransactionRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SubmitDepositTransaction(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/side.btcbridge.Msg/SubmitDepositTransaction", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SubmitDepositTransaction(ctx, req.(*MsgSubmitDepositTransactionRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_SubmitWithdrawTransaction_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSubmitWithdrawTransactionRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).SubmitTransaction(ctx, in) + return srv.(MsgServer).SubmitWithdrawTransaction(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/side.btcbridge.Msg/SubmitTransaction", + FullMethod: "/side.btcbridge.Msg/SubmitWithdrawTransaction", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).SubmitTransaction(ctx, req.(*MsgSubmitTransactionRequest)) + return srv.(MsgServer).SubmitWithdrawTransaction(ctx, req.(*MsgSubmitWithdrawTransactionRequest)) } return interceptor(ctx, in, info, handler) } -func _Msg_UpdateSenders_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgUpdateSendersRequest) +func _Msg_UpdateQualifiedRelayers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateQualifiedRelayersRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(MsgServer).UpdateSenders(ctx, in) + return srv.(MsgServer).UpdateQualifiedRelayers(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/side.btcbridge.Msg/UpdateSenders", + FullMethod: "/side.btcbridge.Msg/UpdateQualifiedRelayers", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).UpdateSenders(ctx, req.(*MsgUpdateSendersRequest)) + return srv.(MsgServer).UpdateQualifiedRelayers(ctx, req.(*MsgUpdateQualifiedRelayersRequest)) } return interceptor(ctx, in, info, handler) } @@ -793,12 +950,16 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Handler: _Msg_SubmitBlockHeaders_Handler, }, { - MethodName: "SubmitTransaction", - Handler: _Msg_SubmitTransaction_Handler, + MethodName: "SubmitDepositTransaction", + Handler: _Msg_SubmitDepositTransaction_Handler, }, { - MethodName: "UpdateSenders", - Handler: _Msg_UpdateSenders_Handler, + MethodName: "SubmitWithdrawTransaction", + Handler: _Msg_SubmitWithdrawTransaction_Handler, + }, + { + MethodName: "UpdateQualifiedRelayers", + Handler: _Msg_UpdateQualifiedRelayers_Handler, }, { MethodName: "WithdrawBitcoin", @@ -880,7 +1041,7 @@ func (m *MsgSubmitBlockHeadersResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } -func (m *MsgSubmitTransactionRequest) Marshal() (dAtA []byte, err error) { +func (m *MsgSubmitDepositTransactionRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -890,12 +1051,12 @@ func (m *MsgSubmitTransactionRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgSubmitTransactionRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgSubmitDepositTransactionRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgSubmitTransactionRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgSubmitDepositTransactionRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -940,7 +1101,7 @@ func (m *MsgSubmitTransactionRequest) MarshalToSizedBuffer(dAtA []byte) (int, er return len(dAtA) - i, nil } -func (m *MsgSubmitTransactionResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgSubmitDepositTransactionResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -950,12 +1111,12 @@ func (m *MsgSubmitTransactionResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgSubmitTransactionResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgSubmitDepositTransactionResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgSubmitTransactionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgSubmitDepositTransactionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -963,7 +1124,7 @@ func (m *MsgSubmitTransactionResponse) MarshalToSizedBuffer(dAtA []byte) (int, e return len(dAtA) - i, nil } -func (m *MsgUpdateSendersRequest) Marshal() (dAtA []byte, err error) { +func (m *MsgSubmitWithdrawTransactionRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -973,21 +1134,104 @@ func (m *MsgUpdateSendersRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgUpdateSendersRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgSubmitWithdrawTransactionRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdateSendersRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgSubmitWithdrawTransactionRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if len(m.Senders) > 0 { - for iNdEx := len(m.Senders) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Senders[iNdEx]) - copy(dAtA[i:], m.Senders[iNdEx]) - i = encodeVarintTx(dAtA, i, uint64(len(m.Senders[iNdEx]))) + if len(m.Proof) > 0 { + for iNdEx := len(m.Proof) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Proof[iNdEx]) + copy(dAtA[i:], m.Proof[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Proof[iNdEx]))) + i-- + dAtA[i] = 0x2a + } + } + if len(m.TxBytes) > 0 { + i -= len(m.TxBytes) + copy(dAtA[i:], m.TxBytes) + i = encodeVarintTx(dAtA, i, uint64(len(m.TxBytes))) + i-- + dAtA[i] = 0x22 + } + if len(m.PrevTxBytes) > 0 { + i -= len(m.PrevTxBytes) + copy(dAtA[i:], m.PrevTxBytes) + i = encodeVarintTx(dAtA, i, uint64(len(m.PrevTxBytes))) + i-- + dAtA[i] = 0x1a + } + if len(m.Blockhash) > 0 { + i -= len(m.Blockhash) + copy(dAtA[i:], m.Blockhash) + i = encodeVarintTx(dAtA, i, uint64(len(m.Blockhash))) + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSubmitWithdrawTransactionResponse) 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 *MsgSubmitWithdrawTransactionResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSubmitWithdrawTransactionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgUpdateQualifiedRelayersRequest) 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 *MsgUpdateQualifiedRelayersRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateQualifiedRelayersRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Relayers) > 0 { + for iNdEx := len(m.Relayers) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Relayers[iNdEx]) + copy(dAtA[i:], m.Relayers[iNdEx]) + i = encodeVarintTx(dAtA, i, uint64(len(m.Relayers[iNdEx]))) i-- dAtA[i] = 0x12 } @@ -1002,7 +1246,7 @@ func (m *MsgUpdateSendersRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *MsgUpdateSendersResponse) Marshal() (dAtA []byte, err error) { +func (m *MsgUpdateQualifiedRelayersResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1012,12 +1256,12 @@ func (m *MsgUpdateSendersResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgUpdateSendersResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgUpdateQualifiedRelayersResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgUpdateSendersResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgUpdateQualifiedRelayersResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1196,7 +1440,47 @@ func (m *MsgSubmitBlockHeadersResponse) Size() (n int) { return n } -func (m *MsgSubmitTransactionRequest) Size() (n int) { +func (m *MsgSubmitDepositTransactionRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Blockhash) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.PrevTxBytes) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.TxBytes) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if len(m.Proof) > 0 { + for _, s := range m.Proof { + l = len(s) + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + +func (m *MsgSubmitDepositTransactionResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgSubmitWithdrawTransactionRequest) Size() (n int) { if m == nil { return 0 } @@ -1227,7 +1511,7 @@ func (m *MsgSubmitTransactionRequest) Size() (n int) { return n } -func (m *MsgSubmitTransactionResponse) Size() (n int) { +func (m *MsgSubmitWithdrawTransactionResponse) Size() (n int) { if m == nil { return 0 } @@ -1236,7 +1520,7 @@ func (m *MsgSubmitTransactionResponse) Size() (n int) { return n } -func (m *MsgUpdateSendersRequest) Size() (n int) { +func (m *MsgUpdateQualifiedRelayersRequest) Size() (n int) { if m == nil { return 0 } @@ -1246,8 +1530,8 @@ func (m *MsgUpdateSendersRequest) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - if len(m.Senders) > 0 { - for _, s := range m.Senders { + if len(m.Relayers) > 0 { + for _, s := range m.Relayers { l = len(s) n += 1 + l + sovTx(uint64(l)) } @@ -1255,7 +1539,7 @@ func (m *MsgUpdateSendersRequest) Size() (n int) { return n } -func (m *MsgUpdateSendersResponse) Size() (n int) { +func (m *MsgUpdateQualifiedRelayersResponse) Size() (n int) { if m == nil { return 0 } @@ -1495,7 +1779,267 @@ func (m *MsgSubmitBlockHeadersResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgSubmitTransactionRequest) Unmarshal(dAtA []byte) error { +func (m *MsgSubmitDepositTransactionRequest) 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: MsgSubmitDepositTransactionRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSubmitDepositTransactionRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Blockhash", 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.Blockhash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrevTxBytes", 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.PrevTxBytes = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TxBytes", 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.TxBytes = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Proof", 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.Proof = append(m.Proof, 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 *MsgSubmitDepositTransactionResponse) 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: MsgSubmitDepositTransactionResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSubmitDepositTransactionResponse: 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 (m *MsgSubmitWithdrawTransactionRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1518,10 +2062,10 @@ func (m *MsgSubmitTransactionRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgSubmitTransactionRequest: wiretype end group for non-group") + return fmt.Errorf("proto: MsgSubmitWithdrawTransactionRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSubmitTransactionRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgSubmitWithdrawTransactionRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1705,7 +2249,7 @@ func (m *MsgSubmitTransactionRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgSubmitTransactionResponse) Unmarshal(dAtA []byte) error { +func (m *MsgSubmitWithdrawTransactionResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1728,10 +2272,10 @@ func (m *MsgSubmitTransactionResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgSubmitTransactionResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgSubmitWithdrawTransactionResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSubmitTransactionResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgSubmitWithdrawTransactionResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -1755,7 +2299,7 @@ func (m *MsgSubmitTransactionResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateSendersRequest) Unmarshal(dAtA []byte) error { +func (m *MsgUpdateQualifiedRelayersRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1778,10 +2322,10 @@ func (m *MsgUpdateSendersRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateSendersRequest: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdateQualifiedRelayersRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateSendersRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdateQualifiedRelayersRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1818,7 +2362,7 @@ func (m *MsgUpdateSendersRequest) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Senders", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Relayers", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1846,7 +2390,7 @@ func (m *MsgUpdateSendersRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Senders = append(m.Senders, string(dAtA[iNdEx:postIndex])) + m.Relayers = append(m.Relayers, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex default: iNdEx = preIndex @@ -1869,7 +2413,7 @@ func (m *MsgUpdateSendersRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateSendersResponse) Unmarshal(dAtA []byte) error { +func (m *MsgUpdateQualifiedRelayersResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1892,10 +2436,10 @@ func (m *MsgUpdateSendersResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateSendersResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgUpdateQualifiedRelayersResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateSendersResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgUpdateQualifiedRelayersResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: From 03ac96673f17fbffe291b83544f983b2af9c7f0a Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Mon, 17 Jun 2024 15:54:19 +0800 Subject: [PATCH 30/71] add pubkey to vault --- proto/side/btcbridge/params.proto | 4 +- x/btcbridge/keeper/keeper_withdraw.go | 29 ------- x/btcbridge/types/params.pb.go | 113 +++++++++++++++++++------- 3 files changed, 86 insertions(+), 60 deletions(-) diff --git a/proto/side/btcbridge/params.proto b/proto/side/btcbridge/params.proto index 7fb7ffbe..8fa16d85 100644 --- a/proto/side/btcbridge/params.proto +++ b/proto/side/btcbridge/params.proto @@ -34,8 +34,10 @@ enum AssetType { message Vault { // the depositor should send their btc to this address string address_on_bitcoin = 1; + // the pub key to which the voucher is sent + string pub_key = 2; // the address to which the voucher is sent - AssetType asset_type = 2; + AssetType asset_type = 3; } diff --git a/x/btcbridge/keeper/keeper_withdraw.go b/x/btcbridge/keeper/keeper_withdraw.go index e0bec635..32f8f2fa 100644 --- a/x/btcbridge/keeper/keeper_withdraw.go +++ b/x/btcbridge/keeper/keeper_withdraw.go @@ -183,34 +183,5 @@ func (k Keeper) ProcessBitcoinWithdrawTransaction(ctx sdk.Context, msg *types.Ms return err } - // extract senders from the previous transaction - prevTxBytes, err := base64.StdEncoding.DecodeString(msg.PrevTxBytes) - if err != nil { - fmt.Println("Error decoding transaction from base64:", err) - return err - } - - // Create a new transaction - var prevMsgTx wire.MsgTx - err = prevMsgTx.Deserialize(bytes.NewReader(prevTxBytes)) - if err != nil { - fmt.Println("Error deserializing transaction:", err) - return err - } - - prevTx := btcutil.NewTx(&prevMsgTx) - if len(prevTx.MsgTx().TxOut) < 1 { - return types.ErrInvalidBtcTransaction - } - // Validate the transaction - if err := blockchain.CheckTransactionSanity(prevTx); err != nil { - fmt.Println("Transaction is not valid:", err) - return err - } - - if uTx.MsgTx().TxIn[0].PreviousOutPoint.Hash.String() != prevTx.Hash().String() { - return types.ErrInvalidBtcTransaction - } - return nil } diff --git a/x/btcbridge/types/params.pb.go b/x/btcbridge/types/params.pb.go index 4559e2da..0495af37 100644 --- a/x/btcbridge/types/params.pb.go +++ b/x/btcbridge/types/params.pb.go @@ -144,8 +144,10 @@ func (m *Params) GetVaults() []*Vault { type Vault struct { // the depositor should send their btc to this address AddressOnBitcoin string `protobuf:"bytes,1,opt,name=address_on_bitcoin,json=addressOnBitcoin,proto3" json:"address_on_bitcoin,omitempty"` + // the pub key to which the voucher is sent + PubKey string `protobuf:"bytes,2,opt,name=pub_key,json=pubKey,proto3" json:"pub_key,omitempty"` // the address to which the voucher is sent - AssetType AssetType `protobuf:"varint,2,opt,name=asset_type,json=assetType,proto3,enum=side.btcbridge.AssetType" json:"asset_type,omitempty"` + AssetType AssetType `protobuf:"varint,3,opt,name=asset_type,json=assetType,proto3,enum=side.btcbridge.AssetType" json:"asset_type,omitempty"` } func (m *Vault) Reset() { *m = Vault{} } @@ -188,6 +190,13 @@ func (m *Vault) GetAddressOnBitcoin() string { return "" } +func (m *Vault) GetPubKey() string { + if m != nil { + return m.PubKey + } + return "" +} + func (m *Vault) GetAssetType() AssetType { if m != nil { return m.AssetType @@ -204,35 +213,36 @@ func init() { func init() { proto.RegisterFile("side/btcbridge/params.proto", fileDescriptor_f1d33573cda8a6d2) } var fileDescriptor_f1d33573cda8a6d2 = []byte{ - // 436 bytes of a gzipped FileDescriptorProto + // 457 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x92, 0x4f, 0x6f, 0xd3, 0x30, - 0x18, 0xc6, 0xeb, 0x75, 0xad, 0x54, 0x23, 0xba, 0xcc, 0x0c, 0x08, 0x45, 0x8a, 0xa2, 0x89, 0x43, - 0x34, 0xb1, 0x04, 0x95, 0x0b, 0x12, 0xa7, 0xfe, 0x09, 0x62, 0x97, 0x51, 0xb9, 0xdd, 0x24, 0xb8, - 0x58, 0xb6, 0xe3, 0xb6, 0x16, 0x49, 0x1c, 0x62, 0x77, 0x6a, 0xbf, 0x05, 0x1f, 0x8b, 0xe3, 0x8e, - 0x1c, 0x51, 0xfb, 0x19, 0xb8, 0x23, 0xa7, 0xa5, 0xea, 0x76, 0x7b, 0xf3, 0xfb, 0x3d, 0xd1, 0xeb, - 0x47, 0x7a, 0xe1, 0x6b, 0x2d, 0x13, 0x11, 0x31, 0xc3, 0x59, 0x29, 0x93, 0x99, 0x88, 0x0a, 0x5a, - 0xd2, 0x4c, 0x87, 0x45, 0xa9, 0x8c, 0x42, 0x6d, 0x2b, 0xc3, 0xbd, 0xec, 0x9c, 0xcd, 0xd4, 0x4c, - 0x55, 0x2a, 0xb2, 0xd3, 0x36, 0x75, 0xfe, 0x17, 0xc0, 0xe6, 0xa8, 0xfa, 0x0d, 0x5d, 0x42, 0xf4, - 0x63, 0x41, 0x53, 0x39, 0x95, 0x22, 0x21, 0xa5, 0x48, 0xe9, 0x4a, 0x94, 0xda, 0x05, 0x7e, 0x3d, - 0x68, 0xe1, 0xd3, 0xbd, 0xc1, 0x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func (m *Params) Marshal() (dAtA []byte, err error) { @@ -321,7 +331,14 @@ func (m *Vault) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.AssetType != 0 { i = encodeVarintParams(dAtA, i, uint64(m.AssetType)) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x18 + } + if len(m.PubKey) > 0 { + i -= len(m.PubKey) + copy(dAtA[i:], m.PubKey) + i = encodeVarintParams(dAtA, i, uint64(len(m.PubKey))) + i-- + dAtA[i] = 0x12 } if len(m.AddressOnBitcoin) > 0 { i -= len(m.AddressOnBitcoin) @@ -385,6 +402,10 @@ func (m *Vault) Size() (n int) { if l > 0 { n += 1 + l + sovParams(uint64(l)) } + l = len(m.PubKey) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } if m.AssetType != 0 { n += 1 + sovParams(uint64(m.AssetType)) } @@ -645,6 +666,38 @@ func (m *Vault) Unmarshal(dAtA []byte) error { m.AddressOnBitcoin = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PubKey", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PubKey = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field AssetType", wireType) } From 800cd18edaf9a0550b604906ddb5a1d3b76a4b05 Mon Sep 17 00:00:00 2001 From: sufay Date: Mon, 17 Jun 2024 16:52:11 +0800 Subject: [PATCH 31/71] check vault by pubkey --- x/btcbridge/keeper/keeper_deposit.go | 4 ++-- x/btcbridge/keeper/keeper_withdraw.go | 27 +++++++++++++++++++++++++++ x/btcbridge/types/params.go | 12 ++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/x/btcbridge/keeper/keeper_deposit.go b/x/btcbridge/keeper/keeper_deposit.go index cdb637dd..22803e03 100644 --- a/x/btcbridge/keeper/keeper_deposit.go +++ b/x/btcbridge/keeper/keeper_deposit.go @@ -140,7 +140,7 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg // skip if the asset type of the sender address is unspecified switch vault.AssetType { case types.AssetType_ASSET_TYPE_BTC: - k.minBTC(ctx, uTx, header.Height, sender.EncodeAddress(), vault, out, i, param.BtcVoucherDenom) + k.mintBTC(ctx, uTx, header.Height, sender.EncodeAddress(), vault, out, i, param.BtcVoucherDenom) break case types.AssetType_ASSET_TYPE_RUNE: @@ -150,7 +150,7 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg return nil } -func (k Keeper) minBTC(ctx sdk.Context, uTx *btcutil.Tx, height uint64, sender string, vault *types.Vault, out *wire.TxOut, vout int, denom string) { +func (k Keeper) mintBTC(ctx sdk.Context, uTx *btcutil.Tx, height uint64, sender string, vault *types.Vault, out *wire.TxOut, vout int, denom string) { // mint the voucher token coins := sdk.NewCoins(sdk.NewCoin(denom, sdk.NewInt(out.Value))) diff --git a/x/btcbridge/keeper/keeper_withdraw.go b/x/btcbridge/keeper/keeper_withdraw.go index 32f8f2fa..7ddf3f5c 100644 --- a/x/btcbridge/keeper/keeper_withdraw.go +++ b/x/btcbridge/keeper/keeper_withdraw.go @@ -3,6 +3,7 @@ package keeper import ( "bytes" "encoding/base64" + "encoding/hex" "fmt" "github.com/btcsuite/btcd/blockchain" @@ -183,5 +184,31 @@ func (k Keeper) ProcessBitcoinWithdrawTransaction(ctx sdk.Context, msg *types.Ms return err } + if len(uTx.MsgTx().TxIn[0].Witness) != 2 { + return types.ErrInvalidSenders + } + + senderPubKey := uTx.MsgTx().TxIn[0].Witness[1] + + // check if the first sender is one of the vault addresses + vault := types.SelectVaultByPubKey(param.Vaults, hex.EncodeToString(senderPubKey)) + if vault == nil { + return types.ErrInvalidSenders + } + + k.spendUTXOs(ctx, uTx) + return nil } + +// spendUTXOs spends locked utxos +func (k Keeper) spendUTXOs(ctx sdk.Context, uTx *btcutil.Tx) { + for _, in := range uTx.MsgTx().TxIn { + hash := in.PreviousOutPoint.Hash.String() + vout := in.PreviousOutPoint.Index + + if k.IsUTXOLocked(ctx, hash, uint64(vout)) { + k.SpendUTXO(ctx, hash, uint64(vout)) + } + } +} diff --git a/x/btcbridge/types/params.go b/x/btcbridge/types/params.go index 892d8342..650831df 100644 --- a/x/btcbridge/types/params.go +++ b/x/btcbridge/types/params.go @@ -51,3 +51,15 @@ func SelectVaultByBitcoinAddress(vaults []*Vault, address string) *Vault { } return nil } + +// SelectVaultByPubKey returns the vault if the public key is found +// returns the vault if the public key is found +func SelectVaultByPubKey(vaults []*Vault, pubKey string) *Vault { + for _, v := range vaults { + if v.PubKey == pubKey { + return v + } + } + + return nil +} From 495dbc97672aee652b6a9f15e64be1783197d43c Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Mon, 17 Jun 2024 19:15:31 +0800 Subject: [PATCH 32/71] add duplicated mining check --- x/btcbridge/keeper/keeper_deposit.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/x/btcbridge/keeper/keeper_deposit.go b/x/btcbridge/keeper/keeper_deposit.go index 22803e03..3fdb7770 100644 --- a/x/btcbridge/keeper/keeper_deposit.go +++ b/x/btcbridge/keeper/keeper_deposit.go @@ -141,9 +141,8 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg switch vault.AssetType { case types.AssetType_ASSET_TYPE_BTC: k.mintBTC(ctx, uTx, header.Height, sender.EncodeAddress(), vault, out, i, param.BtcVoucherDenom) - break case types.AssetType_ASSET_TYPE_RUNE: - + k.mintRUNE(ctx, uTx, header.Height, sender.EncodeAddress(), vault, out, i, "rune") } } @@ -151,6 +150,14 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg } func (k Keeper) mintBTC(ctx sdk.Context, uTx *btcutil.Tx, height uint64, sender string, vault *types.Vault, out *wire.TxOut, vout int, denom string) { + + // save the hash of the transaction to prevent double minting + // hash := uTx.Hash().String() + // if k.hasMintedTxHash(ctx, hash) { + // return + // } + // k.saveMintedTxHash(ctx, hash) + // mint the voucher token coins := sdk.NewCoins(sdk.NewCoin(denom, sdk.NewInt(out.Value))) @@ -176,3 +183,6 @@ func (k Keeper) mintBTC(ctx sdk.Context, uTx *btcutil.Tx, height uint64, sender k.SetUTXO(ctx, &utxo) k.SetOwnerUTXO(ctx, &utxo) } + +func (k Keeper) mintRUNE(ctx sdk.Context, uTx *btcutil.Tx, height uint64, sender string, vault *types.Vault, out *wire.TxOut, vout int, denom string) { +} From 61cd4c54ff2dc97e4b1d8070801e10418e53fd18 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Mon, 17 Jun 2024 19:48:38 +0800 Subject: [PATCH 33/71] remove prev transaction --- proto/side/btcbridge/tx.proto | 5 +- .../message_submit_withdraw_transaction.go | 4 - x/btcbridge/types/tx.pb.go | 133 ++++++------------ 3 files changed, 43 insertions(+), 99 deletions(-) diff --git a/proto/side/btcbridge/tx.proto b/proto/side/btcbridge/tx.proto index 295f0f49..7837db92 100644 --- a/proto/side/btcbridge/tx.proto +++ b/proto/side/btcbridge/tx.proto @@ -37,6 +37,7 @@ message MsgSubmitBlockHeadersResponse { // MsgSubmitTransactionRequest defines the Msg/SubmitTransaction request type. message MsgSubmitDepositTransactionRequest { + // this is relayer address who submit the bitcoin transaction to the side chain string sender = 1; string blockhash = 2; // the tx bytes in base64 format @@ -53,12 +54,10 @@ message MsgSubmitDepositTransactionResponse { // MsgSubmitTransactionRequest defines the Msg/SubmitTransaction request type. message MsgSubmitWithdrawTransactionRequest { + // this is relayer address who submit the bitcoin transaction to the side chain string sender = 1; string blockhash = 2; // the tx bytes in base64 format - // used for parsing the sender of the transaction - string prev_tx_bytes = 3; - // the tx bytes in base64 format string tx_bytes = 4; repeated string proof = 5; } diff --git a/x/btcbridge/types/message_submit_withdraw_transaction.go b/x/btcbridge/types/message_submit_withdraw_transaction.go index 26ffb346..44e86d4c 100644 --- a/x/btcbridge/types/message_submit_withdraw_transaction.go +++ b/x/btcbridge/types/message_submit_withdraw_transaction.go @@ -52,10 +52,6 @@ func (msg *MsgSubmitWithdrawTransactionRequest) ValidateBasic() error { return sdkerrors.Wrap(ErrInvalidBtcTransaction, "blockhash cannot be empty") } - if len(msg.PrevTxBytes) == 0 { - return sdkerrors.Wrap(ErrInvalidBtcTransaction, "transaction cannot be empty") - } - if len(msg.TxBytes) == 0 { return sdkerrors.Wrap(ErrInvalidBtcTransaction, "transaction cannot be empty") } diff --git a/x/btcbridge/types/tx.pb.go b/x/btcbridge/types/tx.pb.go index 75f0bfd3..7e2040e7 100644 --- a/x/btcbridge/types/tx.pb.go +++ b/x/btcbridge/types/tx.pb.go @@ -120,6 +120,7 @@ var xxx_messageInfo_MsgSubmitBlockHeadersResponse proto.InternalMessageInfo // MsgSubmitTransactionRequest defines the Msg/SubmitTransaction request type. type MsgSubmitDepositTransactionRequest struct { + // this is relayer address who submit the bitcoin transaction to the side chain Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` Blockhash string `protobuf:"bytes,2,opt,name=blockhash,proto3" json:"blockhash,omitempty"` // the tx bytes in base64 format @@ -237,12 +238,10 @@ var xxx_messageInfo_MsgSubmitDepositTransactionResponse proto.InternalMessageInf // MsgSubmitTransactionRequest defines the Msg/SubmitTransaction request type. type MsgSubmitWithdrawTransactionRequest struct { + // this is relayer address who submit the bitcoin transaction to the side chain Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` Blockhash string `protobuf:"bytes,2,opt,name=blockhash,proto3" json:"blockhash,omitempty"` // the tx bytes in base64 format - // used for parsing the sender of the transaction - PrevTxBytes string `protobuf:"bytes,3,opt,name=prev_tx_bytes,json=prevTxBytes,proto3" json:"prev_tx_bytes,omitempty"` - // the tx bytes in base64 format TxBytes string `protobuf:"bytes,4,opt,name=tx_bytes,json=txBytes,proto3" json:"tx_bytes,omitempty"` Proof []string `protobuf:"bytes,5,rep,name=proof,proto3" json:"proof,omitempty"` } @@ -294,13 +293,6 @@ func (m *MsgSubmitWithdrawTransactionRequest) GetBlockhash() string { return "" } -func (m *MsgSubmitWithdrawTransactionRequest) GetPrevTxBytes() string { - if m != nil { - return m.PrevTxBytes - } - return "" -} - func (m *MsgSubmitWithdrawTransactionRequest) GetTxBytes() string { if m != nil { return m.TxBytes @@ -659,47 +651,47 @@ func init() { func init() { proto.RegisterFile("side/btcbridge/tx.proto", fileDescriptor_785ca8e1e4227068) } var fileDescriptor_785ca8e1e4227068 = []byte{ - // 629 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0xcf, 0x6e, 0xd3, 0x4e, + // 631 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xcf, 0x6e, 0xd3, 0x4e, 0x10, 0xae, 0x9b, 0xfe, 0xcb, 0xf4, 0xd7, 0x1f, 0xd2, 0xaa, 0x6a, 0x53, 0xb7, 0x84, 0x62, 0x0a, 0x2a, 0x20, 0x12, 0x91, 0xf2, 0x00, 0x28, 0xe2, 0xd0, 0x4b, 0x0e, 0xb8, 0x45, 0x95, 0xb8, 0x44, - 0xeb, 0x78, 0xe2, 0xac, 0x48, 0xbc, 0x66, 0x77, 0x4d, 0xd3, 0x1b, 0x12, 0x12, 0x67, 0xde, 0x04, - 0x1e, 0x83, 0x63, 0x8f, 0x1c, 0x51, 0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0xb2, 0x3a, 0xf7, 0xeb, 0xb2, 0x3a, 0xf7, 0xbe, 0x16, 0x30, 0xd5, 0x8b, + 0xbd, 0x5a, 0x87, 0x0f, 0xea, 0x49, 0x61, 0xfd, 0x9f, 0xeb, 0xf0, 0xbe, 0x0e, 0xea, 0xc3, 0xf1, + 0xbf, 0xec, 0x59, 0x84, 0xd2, 0x5b, 0xd2, 0x84, 0x83, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xa6, + 0xc1, 0xfb, 0x2a, 0x84, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1160,13 +1152,6 @@ func (m *MsgSubmitWithdrawTransactionRequest) MarshalToSizedBuffer(dAtA []byte) i-- dAtA[i] = 0x22 } - if len(m.PrevTxBytes) > 0 { - i -= len(m.PrevTxBytes) - copy(dAtA[i:], m.PrevTxBytes) - i = encodeVarintTx(dAtA, i, uint64(len(m.PrevTxBytes))) - i-- - dAtA[i] = 0x1a - } if len(m.Blockhash) > 0 { i -= len(m.Blockhash) copy(dAtA[i:], m.Blockhash) @@ -1494,10 +1479,6 @@ func (m *MsgSubmitWithdrawTransactionRequest) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - l = len(m.PrevTxBytes) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } l = len(m.TxBytes) if l > 0 { n += 1 + l + sovTx(uint64(l)) @@ -2132,38 +2113,6 @@ func (m *MsgSubmitWithdrawTransactionRequest) Unmarshal(dAtA []byte) error { } m.Blockhash = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PrevTxBytes", 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.PrevTxBytes = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field TxBytes", wireType) From 96c96b35bc02f63e08cd13804f6257edbdda2cb6 Mon Sep 17 00:00:00 2001 From: sufay Date: Mon, 17 Jun 2024 19:49:57 +0800 Subject: [PATCH 34/71] save minted tx hash --- x/btcbridge/keeper/keeper_deposit.go | 22 +++++++++++++++++----- x/btcbridge/types/keys.go | 6 ++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/x/btcbridge/keeper/keeper_deposit.go b/x/btcbridge/keeper/keeper_deposit.go index 3fdb7770..44c339e0 100644 --- a/x/btcbridge/keeper/keeper_deposit.go +++ b/x/btcbridge/keeper/keeper_deposit.go @@ -152,11 +152,11 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg func (k Keeper) mintBTC(ctx sdk.Context, uTx *btcutil.Tx, height uint64, sender string, vault *types.Vault, out *wire.TxOut, vout int, denom string) { // save the hash of the transaction to prevent double minting - // hash := uTx.Hash().String() - // if k.hasMintedTxHash(ctx, hash) { - // return - // } - // k.saveMintedTxHash(ctx, hash) + hash := uTx.Hash().String() + if k.hasMintedTxHash(ctx, hash) { + return + } + k.saveMintedTxHash(ctx, hash) // mint the voucher token coins := sdk.NewCoins(sdk.NewCoin(denom, sdk.NewInt(out.Value))) @@ -186,3 +186,15 @@ func (k Keeper) mintBTC(ctx sdk.Context, uTx *btcutil.Tx, height uint64, sender func (k Keeper) mintRUNE(ctx sdk.Context, uTx *btcutil.Tx, height uint64, sender string, vault *types.Vault, out *wire.TxOut, vout int, denom string) { } + +func (k Keeper) hasMintedTxHash(ctx sdk.Context, txHash string) bool { + store := ctx.KVStore(k.storeKey) + + return store.Has(types.BtcMintedTxHashKey(txHash)) +} + +func (k Keeper) saveMintedTxHash(ctx sdk.Context, txHash string) { + store := ctx.KVStore(k.storeKey) + + store.Set(types.BtcMintedTxHashKey(txHash), nil) +} diff --git a/x/btcbridge/types/keys.go b/x/btcbridge/types/keys.go index 134ddcda..bfcaeac7 100644 --- a/x/btcbridge/types/keys.go +++ b/x/btcbridge/types/keys.go @@ -34,6 +34,8 @@ var ( BtcUtxoKeyPrefix = []byte{0x15} // prefix for each key to a utxo BtcOwnerUtxoKeyPrefix = []byte{0x16} // prefix for each key to an owned utxo + BtcMintedTxHashKeyPrefix = []byte{0x17} // prefix for each key to a minted tx hash + ChainCfg = &chaincfg.MainNetParams ) @@ -70,3 +72,7 @@ func BtcSigningRequestKey(sequence uint64) []byte { func BtcSigningRequestHashKey(txid string) []byte { return append(BtcSigningRequestPrefix, []byte(txid)...) } + +func BtcMintedTxHashKey(hash string) []byte { + return append(BtcMintedTxHashKeyPrefix, []byte(hash)...) +} From aac555b1f74aa53f32961326291fd4b4f551e55e Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Mon, 17 Jun 2024 20:01:07 +0800 Subject: [PATCH 35/71] add duplicating error handler --- x/btcbridge/keeper/keeper_deposit.go | 8 +++++--- x/btcbridge/types/errors.go | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/x/btcbridge/keeper/keeper_deposit.go b/x/btcbridge/keeper/keeper_deposit.go index 44c339e0..0fc2df29 100644 --- a/x/btcbridge/keeper/keeper_deposit.go +++ b/x/btcbridge/keeper/keeper_deposit.go @@ -149,12 +149,12 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg return nil } -func (k Keeper) mintBTC(ctx sdk.Context, uTx *btcutil.Tx, height uint64, sender string, vault *types.Vault, out *wire.TxOut, vout int, denom string) { +func (k Keeper) mintBTC(ctx sdk.Context, uTx *btcutil.Tx, height uint64, sender string, vault *types.Vault, out *wire.TxOut, vout int, denom string) error { // save the hash of the transaction to prevent double minting hash := uTx.Hash().String() if k.hasMintedTxHash(ctx, hash) { - return + return types.ErrTransactionAlreadyMinted } k.saveMintedTxHash(ctx, hash) @@ -163,7 +163,7 @@ func (k Keeper) mintBTC(ctx sdk.Context, uTx *btcutil.Tx, height uint64, sender receipient, err := sdk.AccAddressFromBech32(sender) if err != nil { - return + return err } k.bankKeeper.MintCoins(ctx, types.ModuleName, coins) @@ -182,6 +182,8 @@ func (k Keeper) mintBTC(ctx sdk.Context, uTx *btcutil.Tx, height uint64, sender k.SetUTXO(ctx, &utxo) k.SetOwnerUTXO(ctx, &utxo) + + return nil } func (k Keeper) mintRUNE(ctx sdk.Context, uTx *btcutil.Tx, height uint64, sender string, vault *types.Vault, out *wire.TxOut, vout int, denom string) { diff --git a/x/btcbridge/types/errors.go b/x/btcbridge/types/errors.go index 0cd2863d..cd190513 100644 --- a/x/btcbridge/types/errors.go +++ b/x/btcbridge/types/errors.go @@ -21,6 +21,7 @@ var ( ErrNotConfirmed = errorsmod.Register(ModuleName, 3200, "transaction not confirmed") ErrExceedMaxAcceptanceDepth = errorsmod.Register(ModuleName, 3201, "exceed max acceptance block depth") ErrUnsupportedScriptType = errorsmod.Register(ModuleName, 3202, "unsupported script type") + ErrTransactionAlreadyMinted = errorsmod.Register(ModuleName, 3203, "transaction already minted") ErrInvalidSignatures = errorsmod.Register(ModuleName, 4200, "invalid signatures") ErrInsufficientBalance = errorsmod.Register(ModuleName, 4201, "insufficient balance") From 8eba492cdc2008c64febdeef539f65de2f74f6ae Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Tue, 18 Jun 2024 07:19:00 +0800 Subject: [PATCH 36/71] add default blockheader for networks --- proto/side/btcbridge/genesis.proto | 1 + x/btcbridge/genesis.go | 5 ++ x/btcbridge/types/genesis.go | 47 ++++++++++++++++++ x/btcbridge/types/genesis.pb.go | 79 +++++++++++++++++++++++++++--- 4 files changed, 124 insertions(+), 8 deletions(-) diff --git a/proto/side/btcbridge/genesis.proto b/proto/side/btcbridge/genesis.proto index 16674512..3b382424 100644 --- a/proto/side/btcbridge/genesis.proto +++ b/proto/side/btcbridge/genesis.proto @@ -13,4 +13,5 @@ message GenesisState { // the chain tip of the bitcoin chain BlockHeader best_block_header = 2; repeated BlockHeader block_headers = 3; + repeated UTXO utxos = 4; } diff --git a/x/btcbridge/genesis.go b/x/btcbridge/genesis.go index 6e5726a4..c9aaaa51 100644 --- a/x/btcbridge/genesis.go +++ b/x/btcbridge/genesis.go @@ -14,6 +14,10 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) if len(genState.BlockHeaders) > 0 { k.SetBlockHeaders(ctx, genState.BlockHeaders) } + // import utxos + for _, utxo := range genState.Utxos { + k.SetUTXO(ctx, utxo) + } } @@ -23,6 +27,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis.Params = k.GetParams(ctx) genesis.BestBlockHeader = k.GetBestBlockHeader(ctx) genesis.BlockHeaders = k.GetAllBlockHeaders(ctx) + genesis.Utxos = k.GetAllUTXOs(ctx) // this line is used by starport scaffolding # genesis/module/export diff --git a/x/btcbridge/types/genesis.go b/x/btcbridge/types/genesis.go index dd03237c..824e29c4 100644 --- a/x/btcbridge/types/genesis.go +++ b/x/btcbridge/types/genesis.go @@ -1,8 +1,54 @@ package types +import ( + "github.com/btcsuite/btcd/chaincfg" + sdk "github.com/cosmos/cosmos-sdk/types" +) + // this line is used by starport scaffolding # genesis/types/import func DefaultBestBlockHeader() *BlockHeader { + config := sdk.GetConfig().GetBtcChainCfg() + switch config.Name { + case chaincfg.MainNetParams.Name: + return DefaultMainNetBestBlockHeader() + case chaincfg.SigNetParams.Name: + return DefaultSignetBestBlockHeader() + } + return DefaultTestnetBestBlockHeader() +} + +func DefaultSignetBestBlockHeader() *BlockHeader { + // testnet3 block 2815023 + return &BlockHeader{ + Version: 536870912, + Hash: "000000a7e90dc93d4671819d34bce273f65b7f911f335d829b6a6e181cda01c8", + Height: 3236, + PreviousBlockHash: "0000011e57524f2abb7054ac10833926470caefda7139059a255d25aaa306343", + MerkleRoot: "c7edd2424b9fe2776c7cacb766efa4a308c68cb45838db185dfcf817613d92a4", + Time: 1718665272, + Bits: "1e0377ae", + Nonce: 6997531, + Ntx: 1, + } +} + +func DefaultTestnetBestBlockHeader() *BlockHeader { + // testnet3 block 2815023 + return &BlockHeader{ + Version: 667459584, + Hash: "0000000000000009fb68da72e8994f014fafb455c72978233b94580b12af778c", + Height: 2815023, + PreviousBlockHash: "0000000000000004a29c20eb32532718de8072665620edb4c657b22b4d463967", + MerkleRoot: "9e219423eadce80e882cdff04b3026c9bbc994fd08a774f34a705ca3e710a332", + Time: 1715566066, + Bits: "191881b8", + Nonce: 3913166971, + Ntx: 6236, + } +} + +func DefaultMainNetBestBlockHeader() *BlockHeader { // testnet3 block 2815023 return &BlockHeader{ Version: 667459584, @@ -24,6 +70,7 @@ func DefaultGenesis() *GenesisState { Params: DefaultParams(), BestBlockHeader: DefaultBestBlockHeader(), BlockHeaders: []*BlockHeader{}, + Utxos: []*UTXO{}, } } diff --git a/x/btcbridge/types/genesis.pb.go b/x/btcbridge/types/genesis.pb.go index af319567..722e2cc0 100644 --- a/x/btcbridge/types/genesis.pb.go +++ b/x/btcbridge/types/genesis.pb.go @@ -29,6 +29,7 @@ type GenesisState struct { // the chain tip of the bitcoin chain BestBlockHeader *BlockHeader `protobuf:"bytes,2,opt,name=best_block_header,json=bestBlockHeader,proto3" json:"best_block_header,omitempty"` BlockHeaders []*BlockHeader `protobuf:"bytes,3,rep,name=block_headers,json=blockHeaders,proto3" json:"block_headers,omitempty"` + Utxos []*UTXO `protobuf:"bytes,4,rep,name=utxos,proto3" json:"utxos,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -85,6 +86,13 @@ func (m *GenesisState) GetBlockHeaders() []*BlockHeader { return nil } +func (m *GenesisState) GetUtxos() []*UTXO { + if m != nil { + return m.Utxos + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "side.btcbridge.GenesisState") } @@ -92,24 +100,25 @@ func init() { func init() { proto.RegisterFile("side/btcbridge/genesis.proto", fileDescriptor_37c22954cf4a954b) } var fileDescriptor_37c22954cf4a954b = []byte{ - // 264 bytes of a gzipped FileDescriptorProto + // 287 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x29, 0xce, 0x4c, 0x49, 0xd5, 0x4f, 0x2a, 0x49, 0x4e, 0x2a, 0xca, 0x4c, 0x49, 0x4f, 0xd5, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x03, 0xc9, 0xea, 0xc1, 0x65, 0xa5, 0x44, 0xd2, 0xf3, 0xd3, 0xf3, 0xc1, 0x52, 0xfa, 0x20, 0x16, 0x44, 0x95, 0x94, 0x34, 0x9a, 0x19, 0x05, 0x89, 0x45, 0x89, 0xb9, 0x50, 0x23, 0xa4, 0xd0, 0x2d, 0x48, 0xca, 0x2c, 0x49, 0xce, 0xcf, - 0xcc, 0x83, 0xc8, 0x2a, 0x9d, 0x67, 0xe4, 0xe2, 0x71, 0x87, 0x58, 0x19, 0x5c, 0x92, 0x58, 0x92, + 0xcc, 0x83, 0xc8, 0x2a, 0xfd, 0x66, 0xe4, 0xe2, 0x71, 0x87, 0x58, 0x19, 0x5c, 0x92, 0x58, 0x92, 0x2a, 0x64, 0xc2, 0xc5, 0x06, 0xd1, 0x2e, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xa6, 0x87, 0xea, 0x04, 0xbd, 0x00, 0xb0, 0xac, 0x13, 0xcb, 0x89, 0x7b, 0xf2, 0x0c, 0x41, 0x50, 0xb5, 0x42, 0xee, 0x5c, 0x82, 0x49, 0xa9, 0xc5, 0x25, 0xf1, 0x49, 0x39, 0xf9, 0xc9, 0xd9, 0xf1, 0x19, 0xa9, 0x89, 0x29, 0xa9, 0x45, 0x12, 0x4c, 0x60, 0x03, 0xa4, 0xd1, 0x0d, 0x70, 0x02, 0xa9, 0xf1, 0x00, 0x2b, 0x09, 0xe2, 0x07, 0xe9, 0x42, 0x12, 0x10, 0x72, 0xe0, 0xe2, 0x45, 0x36, 0xa3, 0x58, 0x82, - 0x59, 0x81, 0x99, 0x90, 0x21, 0x3c, 0x49, 0x08, 0x4e, 0xb1, 0x93, 0xc7, 0x89, 0x47, 0x72, 0x8c, - 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, - 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xe9, 0xa5, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, - 0xe7, 0xea, 0x83, 0x8c, 0x03, 0x87, 0x40, 0x72, 0x7e, 0x0e, 0x98, 0xa3, 0x5f, 0x81, 0x14, 0x46, - 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0x60, 0x05, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, - 0x89, 0x77, 0xfa, 0xdb, 0xa3, 0x01, 0x00, 0x00, + 0x59, 0x81, 0x99, 0x90, 0x21, 0x3c, 0x49, 0x08, 0x4e, 0xb1, 0x90, 0x16, 0x17, 0x6b, 0x69, 0x49, + 0x45, 0x7e, 0xb1, 0x04, 0x0b, 0x58, 0xa7, 0x08, 0xba, 0xce, 0xd0, 0x90, 0x08, 0xff, 0x20, 0x88, + 0x12, 0x27, 0x8f, 0x13, 0x8f, 0xe4, 0x18, 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, + 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0xd2, 0x4b, 0xcf, + 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x07, 0x19, 0x00, 0x0e, 0xad, 0xe4, 0xfc, + 0x1c, 0x30, 0x47, 0xbf, 0x02, 0x29, 0x3c, 0x4b, 0x2a, 0x0b, 0x52, 0x8b, 0x93, 0xd8, 0xc0, 0x0a, + 0x8c, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x8f, 0x59, 0x66, 0x3a, 0xcf, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -132,6 +141,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.Utxos) > 0 { + for iNdEx := len(m.Utxos) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Utxos[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + } if len(m.BlockHeaders) > 0 { for iNdEx := len(m.BlockHeaders) - 1; iNdEx >= 0; iNdEx-- { { @@ -200,6 +223,12 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if len(m.Utxos) > 0 { + for _, e := range m.Utxos { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -341,6 +370,40 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Utxos", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthGenesis + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthGenesis + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Utxos = append(m.Utxos, &UTXO{}) + if err := m.Utxos[len(m.Utxos)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) From 4b40b8ceb32bef4105b05490bb59d2b03676f8e6 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Tue, 18 Jun 2024 07:19:33 +0800 Subject: [PATCH 37/71] rename field --- proto/side/btcbridge/params.proto | 2 +- x/btcbridge/keeper/keeper_deposit.go | 10 ++-- x/btcbridge/types/params.go | 9 +-- x/btcbridge/types/params.pb.go | 82 ++++++++++++++-------------- 4 files changed, 53 insertions(+), 50 deletions(-) diff --git a/proto/side/btcbridge/params.proto b/proto/side/btcbridge/params.proto index 8fa16d85..27aaf38a 100644 --- a/proto/side/btcbridge/params.proto +++ b/proto/side/btcbridge/params.proto @@ -8,7 +8,7 @@ option go_package = "github.com/sideprotocol/side/x/btcbridge/types"; // Params defines the parameters for the module. message Params { // Only accept blocks sending from these addresses - repeated string qualified_relayers = 1; + repeated string authorized_relayers = 1; // The minimum number of confirmations required for a block to be accepted int32 confirmations = 2; // Indicates the maximum depth or distance from the latest block up to which transactions are considered for acceptance. diff --git a/x/btcbridge/keeper/keeper_deposit.go b/x/btcbridge/keeper/keeper_deposit.go index 0fc2df29..ab5d63c5 100644 --- a/x/btcbridge/keeper/keeper_deposit.go +++ b/x/btcbridge/keeper/keeper_deposit.go @@ -153,10 +153,10 @@ func (k Keeper) mintBTC(ctx sdk.Context, uTx *btcutil.Tx, height uint64, sender // save the hash of the transaction to prevent double minting hash := uTx.Hash().String() - if k.hasMintedTxHash(ctx, hash) { + if k.existsInHistory(ctx, hash) { return types.ErrTransactionAlreadyMinted } - k.saveMintedTxHash(ctx, hash) + k.addToMintHistory(ctx, hash) // mint the voucher token coins := sdk.NewCoins(sdk.NewCoin(denom, sdk.NewInt(out.Value))) @@ -189,14 +189,16 @@ func (k Keeper) mintBTC(ctx sdk.Context, uTx *btcutil.Tx, height uint64, sender func (k Keeper) mintRUNE(ctx sdk.Context, uTx *btcutil.Tx, height uint64, sender string, vault *types.Vault, out *wire.TxOut, vout int, denom string) { } -func (k Keeper) hasMintedTxHash(ctx sdk.Context, txHash string) bool { +func (k Keeper) existsInHistory(ctx sdk.Context, txHash string) bool { store := ctx.KVStore(k.storeKey) return store.Has(types.BtcMintedTxHashKey(txHash)) } -func (k Keeper) saveMintedTxHash(ctx sdk.Context, txHash string) { +func (k Keeper) addToMintHistory(ctx sdk.Context, txHash string) { store := ctx.KVStore(k.storeKey) store.Set(types.BtcMintedTxHashKey(txHash), nil) } + +// need a query all history for exporting diff --git a/x/btcbridge/types/params.go b/x/btcbridge/types/params.go index 650831df..b1c7831b 100644 --- a/x/btcbridge/types/params.go +++ b/x/btcbridge/types/params.go @@ -3,13 +3,14 @@ package types import sdk "github.com/cosmos/cosmos-sdk/types" // NewParams creates a new Params instance -func NewParams(senders []string) Params { +func NewParams(relayers []string) Params { return Params{ - QualifiedRelayers: senders, + AuthorizedRelayers: relayers, Confirmations: 2, MaxAcceptableBlockDepth: 100, Vaults: []*Vault{{ AddressOnBitcoin: "", + PubKey: "", AssetType: AssetType_ASSET_TYPE_BTC, }}, } @@ -22,7 +23,7 @@ func DefaultParams() Params { // Validate validates the set of params func (p Params) Validate() error { - for _, sender := range p.QualifiedRelayers { + for _, sender := range p.AuthorizedRelayers { _, err := sdk.AccAddressFromBech32(sender) if err != nil { return err @@ -33,7 +34,7 @@ func (p Params) Validate() error { // checks if the given address is an authorized sender func (p Params) IsAuthorizedSender(sender string) bool { - for _, s := range p.QualifiedRelayers { + for _, s := range p.AuthorizedRelayers { if s == sender { return true } diff --git a/x/btcbridge/types/params.pb.go b/x/btcbridge/types/params.pb.go index 0495af37..1077b042 100644 --- a/x/btcbridge/types/params.pb.go +++ b/x/btcbridge/types/params.pb.go @@ -62,7 +62,7 @@ func (AssetType) EnumDescriptor() ([]byte, []int) { // Params defines the parameters for the module. type Params struct { // Only accept blocks sending from these addresses - QualifiedRelayers []string `protobuf:"bytes,1,rep,name=qualified_relayers,json=qualifiedRelayers,proto3" json:"qualified_relayers,omitempty"` + AuthorizedRelayers []string `protobuf:"bytes,1,rep,name=authorized_relayers,json=authorizedRelayers,proto3" json:"authorized_relayers,omitempty"` // The minimum number of confirmations required for a block to be accepted Confirmations int32 `protobuf:"varint,2,opt,name=confirmations,proto3" json:"confirmations,omitempty"` // Indicates the maximum depth or distance from the latest block up to which transactions are considered for acceptance. @@ -105,9 +105,9 @@ func (m *Params) XXX_DiscardUnknown() { var xxx_messageInfo_Params proto.InternalMessageInfo -func (m *Params) GetQualifiedRelayers() []string { +func (m *Params) GetAuthorizedRelayers() []string { if m != nil { - return m.QualifiedRelayers + return m.AuthorizedRelayers } return nil } @@ -213,36 +213,36 @@ func init() { func init() { proto.RegisterFile("side/btcbridge/params.proto", fileDescriptor_f1d33573cda8a6d2) } var fileDescriptor_f1d33573cda8a6d2 = []byte{ - // 457 bytes of a gzipped FileDescriptorProto + // 458 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x92, 0x4f, 0x6f, 0xd3, 0x30, - 0x18, 0xc6, 0xeb, 0x75, 0x2d, 0x8a, 0x11, 0x5d, 0x66, 0x06, 0x0b, 0x45, 0x8a, 0xa2, 0x89, 0x43, - 0x34, 0xb1, 0x04, 0x95, 0x0b, 0x12, 0xa7, 0xfe, 0x09, 0x62, 0x42, 0x1a, 0x95, 0xdb, 0x4d, 0x82, - 0x8b, 0x65, 0x3b, 0x6e, 0x1b, 0x2d, 0x89, 0x43, 0xec, 0x4c, 0xcd, 0x37, 0xe0, 0xc8, 0xc7, 0xe2, - 0xb8, 0x23, 0x47, 0xd4, 0x7e, 0x06, 0xee, 0x28, 0x69, 0xa9, 0x3a, 0x6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, 0x82, 0x91, 0xd9, 0x40, 0x08, 0x76, 0x76, + 0xdc, 0x60, 0x3a, 0x34, 0x01, 0x3a, 0x81, 0xe6, 0x2e, 0xc3, 0xc3, 0xde, 0x6b, 0xf3, 0x00, 0x1d, + 0xc3, 0xa3, 0x1d, 0x8a, 0xaf, 0x2e, 0x03, 0xb3, 0x39, 0xf8, 0xf0, 0x63, 0x69, 0x83, 0xfb, 0xa5, + 0x0d, 0x7e, 0x2d, 0x6d, 0xf0, 0x7d, 0x65, 0x37, 0xee, 0x57, 0x76, 0xe3, 0xe7, 0xca, 0x6e, 0x7c, + 0xf1, 0x66, 0x91, 0x9e, 0x17, 0xcc, 0xe3, 0x32, 0xf1, 0xab, 0x8e, 0xeb, 0xe5, 0xe0, 0x32, 0xae, + 0x0f, 0xfe, 0x62, 0x67, 0xc7, 0xaa, 0xe1, 0x14, 0x6b, 0xd7, 0x81, 0x37, 0x7f, 0x02, 0x00, 0x00, + 0xff, 0xff, 0xd6, 0xe0, 0x2b, 0xaf, 0x82, 0x02, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -296,11 +296,11 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x10 } - if len(m.QualifiedRelayers) > 0 { - for iNdEx := len(m.QualifiedRelayers) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.QualifiedRelayers[iNdEx]) - copy(dAtA[i:], m.QualifiedRelayers[iNdEx]) - i = encodeVarintParams(dAtA, i, uint64(len(m.QualifiedRelayers[iNdEx]))) + if len(m.AuthorizedRelayers) > 0 { + for iNdEx := len(m.AuthorizedRelayers) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.AuthorizedRelayers[iNdEx]) + copy(dAtA[i:], m.AuthorizedRelayers[iNdEx]) + i = encodeVarintParams(dAtA, i, uint64(len(m.AuthorizedRelayers[iNdEx]))) i-- dAtA[i] = 0xa } @@ -367,8 +367,8 @@ func (m *Params) Size() (n int) { } var l int _ = l - if len(m.QualifiedRelayers) > 0 { - for _, s := range m.QualifiedRelayers { + if len(m.AuthorizedRelayers) > 0 { + for _, s := range m.AuthorizedRelayers { l = len(s) n += 1 + l + sovParams(uint64(l)) } @@ -449,7 +449,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field QualifiedRelayers", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AuthorizedRelayers", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -477,7 +477,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.QualifiedRelayers = append(m.QualifiedRelayers, string(dAtA[iNdEx:postIndex])) + m.AuthorizedRelayers = append(m.AuthorizedRelayers, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex case 2: if wireType != 0 { From a4b809b23258b33014feb2df2df3fa49152f41b5 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Tue, 18 Jun 2024 07:27:00 +0800 Subject: [PATCH 38/71] Enable signet for dev --- cmd/sided/cmd/config.go | 3 ++- x/btcbridge/types/params.go | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/sided/cmd/config.go b/cmd/sided/cmd/config.go index 614391c7..8b0e2de3 100644 --- a/cmd/sided/cmd/config.go +++ b/cmd/sided/cmd/config.go @@ -1,6 +1,7 @@ package cmd import ( + "github.com/btcsuite/btcd/chaincfg" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -18,7 +19,7 @@ func initSDKConfig() { config.SetBech32PrefixForAccount(bech32Prefix, accountPubKeyPrefix) config.SetBech32PrefixForValidator(validatorAddressPrefix, validatorPubKeyPrefix) config.SetBech32PrefixForConsensusNode(consNodeAddressPrefix, consNodePubKeyPrefix) - // config.SetBtcChainCfg(&chaincfg.SigNetParams) + config.SetBtcChainCfg(&chaincfg.SigNetParams) config.Seal() } diff --git a/x/btcbridge/types/params.go b/x/btcbridge/types/params.go index b1c7831b..49537ffa 100644 --- a/x/btcbridge/types/params.go +++ b/x/btcbridge/types/params.go @@ -12,6 +12,10 @@ func NewParams(relayers []string) Params { AddressOnBitcoin: "", PubKey: "", AssetType: AssetType_ASSET_TYPE_BTC, + }, { + AddressOnBitcoin: "", + PubKey: "", + AssetType: AssetType_ASSET_TYPE_RUNE, }}, } } From f76ce8d82dfaf9d733767fcf81641cf6ed5f47fd Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Tue, 18 Jun 2024 08:08:02 +0800 Subject: [PATCH 39/71] rename module name --- x/btcbridge/types/keys.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x/btcbridge/types/keys.go b/x/btcbridge/types/keys.go index bfcaeac7..a7360f11 100644 --- a/x/btcbridge/types/keys.go +++ b/x/btcbridge/types/keys.go @@ -8,7 +8,7 @@ import ( const ( // ModuleName defines the module name - ModuleName = "btclightclient" + ModuleName = "btcbridge" // StoreKey defines the primary module store key StoreKey = ModuleName From 5e986c2fb30df2b337f2cdd76bd4be3d78676814 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Tue, 18 Jun 2024 10:31:37 +0800 Subject: [PATCH 40/71] improve config --- local_node_test.sh => local_node_dev.sh | 12 ++- proto/side/btcbridge/params.proto | 6 +- x/btcbridge/keeper/keeper_deposit.go | 2 +- x/btcbridge/keeper/keeper_withdraw.go | 2 +- x/btcbridge/types/params.go | 14 +-- x/btcbridge/types/params.pb.go | 136 ++++++++++++++++-------- 6 files changed, 117 insertions(+), 55 deletions(-) rename local_node_test.sh => local_node_dev.sh (87%) diff --git a/local_node_test.sh b/local_node_dev.sh similarity index 87% rename from local_node_test.sh rename to local_node_dev.sh index 16afd436..c95f3897 100755 --- a/local_node_test.sh +++ b/local_node_dev.sh @@ -73,6 +73,10 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then # $BINARY keys add "$KEY" --keyring-backend $KEYRING --algo $KEYALGO --recover --home "$HOMEDIR" # done + echo "" + echo "☝️ Copy the above mnemonic phrases and import them to relayer! Press any key to continue..." + read -r continue + # Set moniker and chain-id for Cascadia (Moniker can be anything, chain-id must be an integer) $BINARY init $MONIKER -o --chain-id $CHAINID --home "$HOMEDIR" @@ -84,8 +88,12 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then jq --arg gas "$BLOCK_GAS" '.app_state["feemarket"]["block_gas"]=$gas' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" # Set gas limit in genesis jq --arg max_gas "$MAX_GAS" '.consensus_params["block"]["max_gas"]=$max_gas' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - - + # setup relayers + RELAYER=$($BINARY keys show "${KEYS[1]}" -a --keyring-backend $KEYRING --home "$HOMEDIR") + jq --arg relayer "$RELAYER" '.app_state["btcbridge"]["params"]["authorized_relayers"][0]=$relayer' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq --arg relayer "$RELAYER" '.app_state["btcbridge"]["params"]["vaults"][0]["address"]=$relayer' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + PUKEY=$($BINARY keys show "${KEYS[1]}" --pubkey --keyring-backend $KEYRING --home "$HOMEDIR") + jq --arg pubkey "$RELAYER" '.app_state["btcbridge"]["params"]["vaults"][0]["pubkey"]=$pubkey' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" # set custom pruning settings sed -i.bak 's/pruning = "default"/pruning = "custom"/g' "$APP_TOML" diff --git a/proto/side/btcbridge/params.proto b/proto/side/btcbridge/params.proto index 27aaf38a..983b7f80 100644 --- a/proto/side/btcbridge/params.proto +++ b/proto/side/btcbridge/params.proto @@ -33,11 +33,13 @@ enum AssetType { // Vault defines the parameters for the module. message Vault { // the depositor should send their btc to this address - string address_on_bitcoin = 1; + string address = 1; // the pub key to which the voucher is sent string pub_key = 2; + // the hex encoded pub key to which the voucher is sent + string pub_key_hex = 3; // the address to which the voucher is sent - AssetType asset_type = 3; + AssetType asset_type = 4; } diff --git a/x/btcbridge/keeper/keeper_deposit.go b/x/btcbridge/keeper/keeper_deposit.go index ab5d63c5..4a170cc5 100644 --- a/x/btcbridge/keeper/keeper_deposit.go +++ b/x/btcbridge/keeper/keeper_deposit.go @@ -175,7 +175,7 @@ func (k Keeper) mintBTC(ctx sdk.Context, uTx *btcutil.Tx, height uint64, sender Amount: uint64(out.Value), PubKeyScript: out.PkScript, Height: height, - Address: vault.GetAddressOnBitcoin(), + Address: vault.Address, IsCoinbase: false, IsLocked: false, } diff --git a/x/btcbridge/keeper/keeper_withdraw.go b/x/btcbridge/keeper/keeper_withdraw.go index 7ddf3f5c..e6b7e523 100644 --- a/x/btcbridge/keeper/keeper_withdraw.go +++ b/x/btcbridge/keeper/keeper_withdraw.go @@ -43,7 +43,7 @@ func (k Keeper) NewSigningRequest(ctx sdk.Context, sender string, coin sdk.Coin, p := k.GetParams(ctx) for i, v := range p.Vaults { if v.AssetType == types.AssetType_ASSET_TYPE_BTC { - vault = p.Vaults[i].AddressOnBitcoin + vault = p.Vaults[i].Address break } } diff --git a/x/btcbridge/types/params.go b/x/btcbridge/types/params.go index 49537ffa..f6d8dc7d 100644 --- a/x/btcbridge/types/params.go +++ b/x/btcbridge/types/params.go @@ -9,13 +9,13 @@ func NewParams(relayers []string) Params { Confirmations: 2, MaxAcceptableBlockDepth: 100, Vaults: []*Vault{{ - AddressOnBitcoin: "", - PubKey: "", - AssetType: AssetType_ASSET_TYPE_BTC, + Address: "", + PubKey: "", + AssetType: AssetType_ASSET_TYPE_BTC, }, { - AddressOnBitcoin: "", - PubKey: "", - AssetType: AssetType_ASSET_TYPE_RUNE, + Address: "", + PubKey: "", + AssetType: AssetType_ASSET_TYPE_RUNE, }}, } } @@ -50,7 +50,7 @@ func (p Params) IsAuthorizedSender(sender string) bool { // returns the vault if the address is found func SelectVaultByBitcoinAddress(vaults []*Vault, address string) *Vault { for _, v := range vaults { - if v.AddressOnBitcoin == address { + if v.Address == address { return v } } diff --git a/x/btcbridge/types/params.pb.go b/x/btcbridge/types/params.pb.go index 1077b042..3ed0c908 100644 --- a/x/btcbridge/types/params.pb.go +++ b/x/btcbridge/types/params.pb.go @@ -143,11 +143,13 @@ func (m *Params) GetVaults() []*Vault { // Vault defines the parameters for the module. type Vault struct { // the depositor should send their btc to this address - AddressOnBitcoin string `protobuf:"bytes,1,opt,name=address_on_bitcoin,json=addressOnBitcoin,proto3" json:"address_on_bitcoin,omitempty"` + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // the pub key to which the voucher is sent PubKey string `protobuf:"bytes,2,opt,name=pub_key,json=pubKey,proto3" json:"pub_key,omitempty"` + // the hex encoded pub key to which the voucher is sent + PubKeyHex string `protobuf:"bytes,3,opt,name=pub_key_hex,json=pubKeyHex,proto3" json:"pub_key_hex,omitempty"` // the address to which the voucher is sent - AssetType AssetType `protobuf:"varint,3,opt,name=asset_type,json=assetType,proto3,enum=side.btcbridge.AssetType" json:"asset_type,omitempty"` + AssetType AssetType `protobuf:"varint,4,opt,name=asset_type,json=assetType,proto3,enum=side.btcbridge.AssetType" json:"asset_type,omitempty"` } func (m *Vault) Reset() { *m = Vault{} } @@ -183,9 +185,9 @@ func (m *Vault) XXX_DiscardUnknown() { var xxx_messageInfo_Vault proto.InternalMessageInfo -func (m *Vault) GetAddressOnBitcoin() string { +func (m *Vault) GetAddress() string { if m != nil { - return m.AddressOnBitcoin + return m.Address } return "" } @@ -197,6 +199,13 @@ func (m *Vault) GetPubKey() string { return "" } +func (m *Vault) GetPubKeyHex() string { + if m != nil { + return m.PubKeyHex + } + return "" +} + func (m *Vault) GetAssetType() AssetType { if m != nil { return m.AssetType @@ -213,36 +222,36 @@ func init() { func init() { proto.RegisterFile("side/btcbridge/params.proto", fileDescriptor_f1d33573cda8a6d2) } var fileDescriptor_f1d33573cda8a6d2 = []byte{ - // 458 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x92, 0x4f, 0x6f, 0xd3, 0x30, - 0x18, 0x87, 0xeb, 0x75, 0x2d, 0x8a, 0x11, 0x5d, 0xf0, 0x06, 0x0b, 0x45, 0x8a, 0xa2, 0x89, 0x43, - 0x34, 0x41, 0x82, 0xca, 0x05, 0x89, 0x53, 0xff, 0x04, 0x31, 0x21, 0x8d, 0xca, 0xed, 0x26, 0xc1, - 0xc5, 0xb2, 0x1d, 0xaf, 0x8d, 0x96, 0xc4, 0x51, 0xec, 0x4c, 0x0d, 0x9f, 0x80, 0x23, 0x1f, 0x8b, - 0xe3, 0x8e, 0x1c, 0x51, 0xfb, 0x21, 0xb8, 0xa2, 0xa4, 0xa5, 0xb4, 0xdc, 0x5e, 0x3f, 0xcf, 0xcf, - 0xf2, 0xfb, 0x5a, 0x2f, 0x7c, 0xae, 0xa2, 0x50, 0xf8, 0x4c, 0x73, 0x96, 0x47, 0xe1, 0x4c, 0xf8, - 0x19, 0xcd, 0x69, 0xa2, 0xbc, 0x2c, 0x97, 0x5a, 0xa2, 0x4e, 0x25, 0xbd, 0xad, 0xec, 0x9e, 0xcc, - 0xe4, 0x4c, 0xd6, 0xca, 0xaf, 0xaa, 0x75, 0xea, 0xec, 0x37, 0x80, 0xed, 0x71, 0x7d, 0x0d, 0xf9, - 0xf0, 0x98, 0x16, 0x7a, 0x2e, 0xf3, 0xe8, 0xab, 0x08, 0x49, 0x2e, 0x62, 0x5a, 0x8a, 0x5c, 0x59, - 0xc0, 0x69, 0xba, 0x06, 0x46, 0xff, 0x14, 0xde, 0x18, 0xf4, 0x02, 0x3e, 0xe2, 0x32, 0xbd, 0x89, - 0xf2, 0x84, 0xea, 0x48, 0xa6, 0xca, 0x3a, 0x70, 0x80, 0xdb, 0xc2, 0xfb, 0x10, 0xbd, 0x83, 0xdd, - 0x84, 0x2e,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0x2f, 0x82, 0x91, 0xd9, 0x40, 0x08, 0x76, 0x76, - 0xdc, 0x60, 0x3a, 0x34, 0x01, 0x3a, 0x81, 0xe6, 0x2e, 0xc3, 0xc3, 0xde, 0x6b, 0xf3, 0x00, 0x1d, - 0xc3, 0xa3, 0x1d, 0x8a, 0xaf, 0x2e, 0x03, 0xb3, 0x39, 0xf8, 0xf0, 0x63, 0x69, 0x83, 0xfb, 0xa5, - 0x0d, 0x7e, 0x2d, 0x6d, 0xf0, 0x7d, 0x65, 0x37, 0xee, 0x57, 0x76, 0xe3, 0xe7, 0xca, 0x6e, 0x7c, - 0xf1, 0x66, 0x91, 0x9e, 0x17, 0xcc, 0xe3, 0x32, 0xf1, 0xab, 0x8e, 0xeb, 0xe5, 0xe0, 0x32, 0xae, - 0x0f, 0xfe, 0x62, 0x67, 0xc7, 0xaa, 0xe1, 0x14, 0x6b, 0xd7, 0x81, 0x37, 0x7f, 0x02, 0x00, 0x00, - 0xff, 0xff, 0xd6, 0xe0, 0x2b, 0xaf, 0x82, 0x02, 0x00, 0x00, + // 461 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x92, 0x4f, 0x6b, 0xdb, 0x30, + 0x18, 0xc6, 0xa3, 0xa6, 0x49, 0xb1, 0xca, 0xd2, 0x4c, 0xed, 0x56, 0x2f, 0x03, 0x63, 0xca, 0x0e, + 0xa6, 0x30, 0x7b, 0x64, 0x97, 0xc1, 0x4e, 0xf9, 0xe3, 0xd1, 0x32, 0x28, 0x41, 0x49, 0x0b, 0xdb, + 0x45, 0x48, 0xb2, 0x1a, 0x9b, 0xda, 0x91, 0xb1, 0xe5, 0x62, 0xef, 0x53, 0xec, 0xb0, 0x0f, 0xb5, + 0x63, 0x8f, 0x3b, 0x8e, 0xe4, 0x43, 0xec, 0x3a, 0xe4, 0xa4, 0x59, 0xba, 0x9b, 0xf4, 0xfb, 0x3d, + 0x36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0x00, 0xb0, 0x55, 0x13, 0x64, 0xc2, 0x03, 0x1a, 0x04, + 0x99, 0xc8, 0x75, 0x59, 0xfd, 0xeb, 0xc7, 0x2b, 0x3a, 0x85, 0x07, 0x69, 0xc1, 0xc8, 0x9d, 0xa8, + 0xea, 0x6e, 0x06, 0x6e, 0xa7, 0x05, 0xfb, 0x2c, 0x2a, 0x64, 0xc1, 0xc3, 0x8d, 0x20, 0xa1, 0x28, + 0xeb, 0x16, 0x06, 0x36, 0xd6, 0xf2, 0x42, 0x94, 0xe8, 0x03, 0x84, 0x34, 0xcf, 0x85, 0x22, 0xaa, + 0x4a, 0x45, 0x3d, 0x70, 0xa7, 0xff, 0xea, 0xff, 0x79, 0x06, 0x3a, 0x31, 0xab, 0x52, 0x81, 0x0d, + 0xfa, 0x78, 0x3c, 0xbf, 0x85, 0xc6, 0x96, 0xa3, 0x1e, 0x7c, 0x39, 0x98, 0x4e, 0xfd, 0x19, 0x99, + 0x7d, 0x99, 0xf8, 0xe4, 0xfa, 0x6a, 0x3a, 0xf1, 0x47, 0x97, 0x9f, 0x2e, 0xfd, 0x71, 0xb7, 0x81, + 0x10, 0xec, 0xec, 0xb8, 0xe1, 0x6c, 0xd4, 0x05, 0xe8, 0x04, 0x76, 0x77, 0x19, 0x1e, 0xf5, 0xdf, + 0x75, 0xf7, 0xd0, 0x31, 0x3c, 0xda, 0xa1, 0xf8, 0xfa, 0xca, 0xef, 0x36, 0x87, 0x17, 0x3f, 0x97, + 0x16, 0x78, 0x58, 0x5a, 0xe0, 0xf7, 0xd2, 0x02, 0xdf, 0x57, 0x56, 0xe3, 0x61, 0x65, 0x35, 0x7e, + 0xad, 0xac, 0xc6, 0x57, 0x77, 0x1e, 0xa9, 0xb0, 0x60, 0x2e, 0x97, 0x89, 0xa7, 0x27, 0xae, 0x17, + 0x85, 0xcb, 0xb8, 0xbe, 0x78, 0xe5, 0xce, 0xbe, 0xe9, 0x72, 0x39, 0x6b, 0xd7, 0x81, 0xf7, 0x7f, + 0x03, 0x00, 0x00, 0xff, 0xff, 0x62, 0x8c, 0x8f, 0x2a, 0x8e, 0x02, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -331,7 +340,14 @@ func (m *Vault) MarshalToSizedBuffer(dAtA []byte) (int, error) { if m.AssetType != 0 { i = encodeVarintParams(dAtA, i, uint64(m.AssetType)) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x20 + } + if len(m.PubKeyHex) > 0 { + i -= len(m.PubKeyHex) + copy(dAtA[i:], m.PubKeyHex) + i = encodeVarintParams(dAtA, i, uint64(len(m.PubKeyHex))) + i-- + dAtA[i] = 0x1a } if len(m.PubKey) > 0 { i -= len(m.PubKey) @@ -340,10 +356,10 @@ func (m *Vault) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x12 } - if len(m.AddressOnBitcoin) > 0 { - i -= len(m.AddressOnBitcoin) - copy(dAtA[i:], m.AddressOnBitcoin) - i = encodeVarintParams(dAtA, i, uint64(len(m.AddressOnBitcoin))) + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintParams(dAtA, i, uint64(len(m.Address))) i-- dAtA[i] = 0xa } @@ -398,7 +414,7 @@ func (m *Vault) Size() (n int) { } var l int _ = l - l = len(m.AddressOnBitcoin) + l = len(m.Address) if l > 0 { n += 1 + l + sovParams(uint64(l)) } @@ -406,6 +422,10 @@ func (m *Vault) Size() (n int) { if l > 0 { n += 1 + l + sovParams(uint64(l)) } + l = len(m.PubKeyHex) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } if m.AssetType != 0 { n += 1 + sovParams(uint64(m.AssetType)) } @@ -635,7 +655,7 @@ func (m *Vault) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AddressOnBitcoin", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -663,7 +683,7 @@ func (m *Vault) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.AddressOnBitcoin = string(dAtA[iNdEx:postIndex]) + m.Address = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -698,6 +718,38 @@ func (m *Vault) Unmarshal(dAtA []byte) error { m.PubKey = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PubKeyHex", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowParams + } + 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 ErrInvalidLengthParams + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthParams + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PubKeyHex = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field AssetType", wireType) } From 22ba3970b5156c21860839596cf54e8425916499 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Tue, 18 Jun 2024 10:34:35 +0800 Subject: [PATCH 41/71] fix typo --- local_node_dev.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/local_node_dev.sh b/local_node_dev.sh index c95f3897..b3cc08ec 100755 --- a/local_node_dev.sh +++ b/local_node_dev.sh @@ -93,7 +93,7 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then jq --arg relayer "$RELAYER" '.app_state["btcbridge"]["params"]["authorized_relayers"][0]=$relayer' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq --arg relayer "$RELAYER" '.app_state["btcbridge"]["params"]["vaults"][0]["address"]=$relayer' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" PUKEY=$($BINARY keys show "${KEYS[1]}" --pubkey --keyring-backend $KEYRING --home "$HOMEDIR") - jq --arg pubkey "$RELAYER" '.app_state["btcbridge"]["params"]["vaults"][0]["pubkey"]=$pubkey' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq --arg pubkey "$RELAYER" '.app_state["btcbridge"]["params"]["vaults"][0]["pub_key"]=$pubkey' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" # set custom pruning settings sed -i.bak 's/pruning = "default"/pruning = "custom"/g' "$APP_TOML" From 3fca5d2c342d802c183e23a71cede5bc31229599 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Tue, 18 Jun 2024 10:39:06 +0800 Subject: [PATCH 42/71] remove hex field --- proto/side/btcbridge/params.proto | 2 - x/btcbridge/types/params.pb.go | 111 ++++++++---------------------- 2 files changed, 29 insertions(+), 84 deletions(-) diff --git a/proto/side/btcbridge/params.proto b/proto/side/btcbridge/params.proto index 983b7f80..0f83ff0b 100644 --- a/proto/side/btcbridge/params.proto +++ b/proto/side/btcbridge/params.proto @@ -36,8 +36,6 @@ message Vault { string address = 1; // the pub key to which the voucher is sent string pub_key = 2; - // the hex encoded pub key to which the voucher is sent - string pub_key_hex = 3; // the address to which the voucher is sent AssetType asset_type = 4; diff --git a/x/btcbridge/types/params.pb.go b/x/btcbridge/types/params.pb.go index 3ed0c908..25b40878 100644 --- a/x/btcbridge/types/params.pb.go +++ b/x/btcbridge/types/params.pb.go @@ -146,8 +146,6 @@ type Vault struct { Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` // the pub key to which the voucher is sent PubKey string `protobuf:"bytes,2,opt,name=pub_key,json=pubKey,proto3" json:"pub_key,omitempty"` - // the hex encoded pub key to which the voucher is sent - PubKeyHex string `protobuf:"bytes,3,opt,name=pub_key_hex,json=pubKeyHex,proto3" json:"pub_key_hex,omitempty"` // the address to which the voucher is sent AssetType AssetType `protobuf:"varint,4,opt,name=asset_type,json=assetType,proto3,enum=side.btcbridge.AssetType" json:"asset_type,omitempty"` } @@ -199,13 +197,6 @@ func (m *Vault) GetPubKey() string { return "" } -func (m *Vault) GetPubKeyHex() string { - if m != nil { - return m.PubKeyHex - } - return "" -} - func (m *Vault) GetAssetType() AssetType { if m != nil { return m.AssetType @@ -222,36 +213,35 @@ func init() { func init() { proto.RegisterFile("side/btcbridge/params.proto", fileDescriptor_f1d33573cda8a6d2) } var fileDescriptor_f1d33573cda8a6d2 = []byte{ - // 461 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x92, 0x4f, 0x6b, 0xdb, 0x30, - 0x18, 0xc6, 0xa3, 0xa6, 0x49, 0xb1, 0xca, 0xd2, 0x4c, 0xed, 0x56, 0x2f, 0x03, 0x63, 0xca, 0x0e, - 0xa6, 0x30, 0x7b, 0x64, 0x97, 0xc1, 0x4e, 0xf9, 0xe3, 0xd1, 0x32, 0x28, 0x41, 0x49, 0x0b, 0xdb, - 0x45, 0x48, 0xb2, 0x1a, 0x9b, 0xda, 0x91, 0xb1, 0xe5, 0x62, 0xef, 0x53, 0xec, 0xb0, 0x0f, 0xb5, - 0x63, 0x8f, 0x3b, 0x8e, 0xe4, 0x43, 0xec, 0x3a, 0xe4, 0xa4, 0x59, 0xba, 0x9b, 0xf4, 0xfb, 0x3d, - 0x36, 0xef, 0x23, 0x5e, 0xf8, 0x3a, 0x8f, 0x02, 0xe1, 0x31, 0xc5, 0x59, 0x16, 0x05, 0x73, 0xe1, - 0xa5, 0x34, 0xa3, 0x49, 0xee, 0xa6, 0x99, 0x54, 0x12, 0x75, 0xb4, 0x74, 0xb7, 0xb2, 0x77, 0x32, - 0x97, 0x73, 0x59, 0x2b, 0x4f, 0x9f, 0xd6, 0xa9, 0xb3, 0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 0x28, - 0xeb, 0x16, 0x06, 0x36, 0xd6, 0xf2, 0x42, 0x94, 0xe8, 0x03, 0x84, 0x34, 0xcf, 0x85, 0x22, 0xaa, - 0x4a, 0x45, 0x3d, 0x70, 0xa7, 0xff, 0xea, 0xff, 0x79, 0x06, 0x3a, 0x31, 0xab, 0x52, 0x81, 0x0d, - 0xfa, 0x78, 0x3c, 0xbf, 0x85, 0xc6, 0x96, 0xa3, 0x1e, 0x7c, 0x39, 0x98, 0x4e, 0xfd, 0x19, 0x99, - 0x7d, 0x99, 0xf8, 0xe4, 0xfa, 0x6a, 0x3a, 0xf1, 0x47, 0x97, 0x9f, 0x2e, 0xfd, 0x71, 0xb7, 0x81, - 0x10, 0xec, 0xec, 0xb8, 0xe1, 0x6c, 0xd4, 0x05, 0xe8, 0x04, 0x76, 0x77, 0x19, 0x1e, 0xf5, 0xdf, - 0x75, 0xf7, 0xd0, 0x31, 0x3c, 0xda, 0xa1, 0xf8, 0xfa, 0xca, 0xef, 0x36, 0x87, 0x17, 0x3f, 0x97, - 0x16, 0x78, 0x58, 0x5a, 0xe0, 0xf7, 0xd2, 0x02, 0xdf, 0x57, 0x56, 0xe3, 0x61, 0x65, 0x35, 0x7e, - 0xad, 0xac, 0xc6, 0x57, 0x77, 0x1e, 0xa9, 0xb0, 0x60, 0x2e, 0x97, 0x89, 0xa7, 0x27, 0xae, 0x17, - 0x85, 0xcb, 0xb8, 0xbe, 0x78, 0xe5, 0xce, 0xbe, 0xe9, 0x72, 0x39, 0x6b, 0xd7, 0x81, 0xf7, 0x7f, - 0x03, 0x00, 0x00, 0xff, 0xff, 0x62, 0x8c, 0x8f, 0x2a, 0x8e, 0x02, 0x00, 0x00, + // 444 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x92, 0xcf, 0x6b, 0xdb, 0x30, + 0x14, 0xc7, 0xe3, 0xa6, 0x49, 0xb1, 0xc6,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, 0x67, 0xfd, 0x59, 0x79, 0xd6, 0xcf, 0xb5, 0xd7, 0xb8, 0x5b, 0x7b, 0x8d, 0xdf, 0x6b, + 0xaf, 0xf1, 0x3d, 0x9c, 0xa5, 0x7a, 0x5e, 0xd2, 0x90, 0x89, 0x3c, 0x32, 0x13, 0xd7, 0x77, 0xc0, + 0x44, 0x56, 0x37, 0xd1, 0x72, 0xeb, 0x9c, 0xcc, 0x72, 0x8a, 0xb6, 0xeb, 0xc0, 0x87, 0x7f, 0x01, + 0x00, 0x00, 0xff, 0xff, 0x87, 0xf7, 0x68, 0xef, 0x6d, 0x02, 0x00, 0x00, } func (m *Params) Marshal() (dAtA []byte, err error) { @@ -342,13 +332,6 @@ func (m *Vault) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x20 } - if len(m.PubKeyHex) > 0 { - i -= len(m.PubKeyHex) - copy(dAtA[i:], m.PubKeyHex) - i = encodeVarintParams(dAtA, i, uint64(len(m.PubKeyHex))) - i-- - dAtA[i] = 0x1a - } if len(m.PubKey) > 0 { i -= len(m.PubKey) copy(dAtA[i:], m.PubKey) @@ -422,10 +405,6 @@ func (m *Vault) Size() (n int) { if l > 0 { n += 1 + l + sovParams(uint64(l)) } - l = len(m.PubKeyHex) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) - } if m.AssetType != 0 { n += 1 + sovParams(uint64(m.AssetType)) } @@ -717,38 +696,6 @@ func (m *Vault) Unmarshal(dAtA []byte) error { } m.PubKey = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PubKeyHex", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - 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 ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PubKeyHex = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field AssetType", wireType) From e25a18e0801d03c025f86bc010e2f71e0f65801e Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Tue, 18 Jun 2024 10:39:28 +0800 Subject: [PATCH 43/71] fixed wrong pubkey --- local_node_dev.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/local_node_dev.sh b/local_node_dev.sh index b3cc08ec..6e439293 100755 --- a/local_node_dev.sh +++ b/local_node_dev.sh @@ -93,7 +93,7 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then jq --arg relayer "$RELAYER" '.app_state["btcbridge"]["params"]["authorized_relayers"][0]=$relayer' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq --arg relayer "$RELAYER" '.app_state["btcbridge"]["params"]["vaults"][0]["address"]=$relayer' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" PUKEY=$($BINARY keys show "${KEYS[1]}" --pubkey --keyring-backend $KEYRING --home "$HOMEDIR") - jq --arg pubkey "$RELAYER" '.app_state["btcbridge"]["params"]["vaults"][0]["pub_key"]=$pubkey' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" + jq --arg pubkey "$PUKEY" '.app_state["btcbridge"]["params"]["vaults"][0]["pub_key"]=$pubkey' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" # set custom pruning settings sed -i.bak 's/pruning = "default"/pruning = "custom"/g' "$APP_TOML" From 6b698f731e31bff97fdb5cc7a0526fbb404ab7d8 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Tue, 18 Jun 2024 10:47:19 +0800 Subject: [PATCH 44/71] change chain-id --- local_node_dev.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/local_node_dev.sh b/local_node_dev.sh index 6e439293..d4968483 100755 --- a/local_node_dev.sh +++ b/local_node_dev.sh @@ -1,7 +1,7 @@ #!/bin/bash KEYS=("dev0" "dev1") -CHAINID="S2-testnet-1" +CHAINID="devnet" MONIKER="Side Labs" BINARY="$HOME/go/bin/sided" DENOM_STR="uside" @@ -74,7 +74,7 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then # done echo "" - echo "☝️ Copy the above mnemonic phrases and import them to relayer! Press any key to continue..." + echo "☝️ Copy the above mnemonic phrases and import them to relayer! Press [Enter] to continue..." read -r continue # Set moniker and chain-id for Cascadia (Moniker can be anything, chain-id must be an integer) From d533029e0e7a2c86ea3d5bb969c65ab0edd4f942 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Tue, 18 Jun 2024 13:55:14 +0800 Subject: [PATCH 45/71] setup vault pubkey --- local_node_dev.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/local_node_dev.sh b/local_node_dev.sh index d4968483..5c2f62aa 100755 --- a/local_node_dev.sh +++ b/local_node_dev.sh @@ -92,7 +92,7 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then RELAYER=$($BINARY keys show "${KEYS[1]}" -a --keyring-backend $KEYRING --home "$HOMEDIR") jq --arg relayer "$RELAYER" '.app_state["btcbridge"]["params"]["authorized_relayers"][0]=$relayer' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq --arg relayer "$RELAYER" '.app_state["btcbridge"]["params"]["vaults"][0]["address"]=$relayer' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - PUKEY=$($BINARY keys show "${KEYS[1]}" --pubkey --keyring-backend $KEYRING --home "$HOMEDIR") + PUKEY=$($BINARY keys show "${KEYS[1]}" --pubkeyhex --keyring-backend $KEYRING --home "$HOMEDIR") jq --arg pubkey "$PUKEY" '.app_state["btcbridge"]["params"]["vaults"][0]["pub_key"]=$pubkey' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" # set custom pruning settings From 44ab33494b95eb64535a28fd2ecf4bc0d8abc7d7 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Tue, 18 Jun 2024 19:04:32 +0800 Subject: [PATCH 46/71] get chaincfg of current selected network --- x/btcbridge/keeper/keeper.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/x/btcbridge/keeper/keeper.go b/x/btcbridge/keeper/keeper.go index 2852c429..61ba0750 100644 --- a/x/btcbridge/keeper/keeper.go +++ b/x/btcbridge/keeper/keeper.go @@ -4,7 +4,6 @@ import ( "fmt" "github.com/btcsuite/btcd/blockchain" - "github.com/btcsuite/btcd/chaincfg" "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -81,7 +80,7 @@ func (k Keeper) SetBlockHeaders(ctx sdk.Context, blockHeader []*types.BlockHeade // check the block header sanity err := blockchain.CheckBlockHeaderSanity( HeaderConvert(header), - chaincfg.MainNetParams.PowLimit, + sdk.GetConfig().GetBtcChainCfg().PowLimit, blockchain.NewMedianTime(), blockchain.BFNone, ) From 454a2336148bfe1d409466d7bbaf535ec3e5f70a Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Wed, 19 Jun 2024 06:49:09 +0800 Subject: [PATCH 47/71] improved deposit check --- x/btcbridge/keeper/keeper_deposit.go | 13 ++++++++----- x/btcbridge/types/genesis.go | 12 ++++++------ x/btcbridge/types/merkle_proof.go | 4 ++-- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/x/btcbridge/keeper/keeper_deposit.go b/x/btcbridge/keeper/keeper_deposit.go index 4a170cc5..2668a640 100644 --- a/x/btcbridge/keeper/keeper_deposit.go +++ b/x/btcbridge/keeper/keeper_deposit.go @@ -22,7 +22,7 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg param := k.GetParams(ctx) header := k.GetBlockHeader(ctx, msg.Blockhash) // Check if block confirmed - if header == nil { + if header == nil || header.Height == 0 { return types.ErrBlockNotFound } @@ -32,9 +32,9 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg return types.ErrNotConfirmed } // Check if the block is within the acceptable depth - if best.Height-header.Height > param.MaxAcceptableBlockDepth { - return types.ErrExceedMaxAcceptanceDepth - } + // if best.Height-header.Height > param.MaxAcceptableBlockDepth { + // return types.ErrExceedMaxAcceptanceDepth + // } // Decode the base64 transaction txBytes, err := base64.StdEncoding.DecodeString(msg.TxBytes) @@ -115,7 +115,10 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg if err != nil { return err } - if !types.VerifyMerkleProof(msg.Proof, uTx.Hash(), root) { + + txhash := uTx.MsgTx().TxHash() + if !types.VerifyMerkleProof(msg.Proof, &txhash, root) { + k.Logger(ctx).Error("Invalid merkle proof", "txhash", tx, "root", root, "proof", msg.Proof) return types.ErrTransactionNotIncluded } diff --git a/x/btcbridge/types/genesis.go b/x/btcbridge/types/genesis.go index 824e29c4..1123f6d0 100644 --- a/x/btcbridge/types/genesis.go +++ b/x/btcbridge/types/genesis.go @@ -22,13 +22,13 @@ func DefaultSignetBestBlockHeader() *BlockHeader { // testnet3 block 2815023 return &BlockHeader{ Version: 536870912, - Hash: "000000a7e90dc93d4671819d34bce273f65b7f911f335d829b6a6e181cda01c8", - Height: 3236, - PreviousBlockHash: "0000011e57524f2abb7054ac10833926470caefda7139059a255d25aaa306343", - MerkleRoot: "c7edd2424b9fe2776c7cacb766efa4a308c68cb45838db185dfcf817613d92a4", - Time: 1718665272, + Hash: "0000017317a7dfa637773406765d308e93cb5a8e5e266bb21687e120bf0e13d3", + Height: 1, + PreviousBlockHash: "00000008819873e925422c1ff0f99f7cc9bbb232af63a077a480a3633bee1ef6", + MerkleRoot: "f1192075c6416b02df1487f1f302d925a875bec7e37cf38079e00b1cd831898a", + Time: 1718707794, Bits: "1e0377ae", - Nonce: 6997531, + Nonce: 13603325, Ntx: 1, } } diff --git a/x/btcbridge/types/merkle_proof.go b/x/btcbridge/types/merkle_proof.go index 26f6c8ef..44a7b295 100644 --- a/x/btcbridge/types/merkle_proof.go +++ b/x/btcbridge/types/merkle_proof.go @@ -8,8 +8,8 @@ import ( ) // VerifyMerkleProof verifies a Merkle proof -func VerifyMerkleProof(proofs []string, hn, root *chainhash.Hash) bool { - current := hn +func VerifyMerkleProof(proofs []string, txHash, root *chainhash.Hash) bool { + current := txHash for _, proof := range proofs { bytes, err := base64.StdEncoding.DecodeString(proof) From 1de67db66b66dbc33df58fa46f385f0713ad1e89 Mon Sep 17 00:00:00 2001 From: sufay Date: Wed, 19 Jun 2024 10:23:18 +0800 Subject: [PATCH 48/71] add withdraw btc cmd to cli --- x/btcbridge/client/cli/tx.go | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/x/btcbridge/client/cli/tx.go b/x/btcbridge/client/cli/tx.go index 0643cc87..0d4cee2e 100644 --- a/x/btcbridge/client/cli/tx.go +++ b/x/btcbridge/client/cli/tx.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "os" + "strconv" "strings" "time" @@ -12,6 +13,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" // "github.com/cosmos/cosmos-sdk/client/flags" "github.com/sideprotocol/side/x/btcbridge/types" @@ -38,6 +40,8 @@ func GetTxCmd() *cobra.Command { cmd.AddCommand(CmdUpdateSenders()) // this line is used by starport scaffolding # 1 + cmd.AddCommand(CmdWithdrawBitcoin()) + return cmd } @@ -109,6 +113,47 @@ func CmdUpdateSenders() *cobra.Command { return cmd } +// Withdraw Bitcoin +func CmdWithdrawBitcoin() *cobra.Command { + cmd := &cobra.Command{ + Use: "withdraw-bitcoin [sender] [amount] [fee-rate]", + Short: "Withdraw bitcoin to the given sender", + Args: cobra.ExactArgs(3), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + _, err = sdk.ParseCoinsNormalized(args[1]) + if err != nil { + return fmt.Errorf("invalid amount") + } + + feeRate, err := strconv.ParseInt(args[2], 10, 64) + if err != nil { + return fmt.Errorf("invalid fee rate") + } + + msg := types.NewMsgWithdrawBitcoinRequest( + args[0], + args[1], + feeRate, + ) + + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + // readBlockHeadersFromFile reads the block headers from the file func readBlockHeadersFromFile(filePath string) ([]*types.BlockHeader, error) { // read the file From 0eea210140d31d7802cbca73dacb94500f24f276 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Wed, 19 Jun 2024 10:54:18 +0800 Subject: [PATCH 49/71] fixed issues on deposit --- x/btcbridge/keeper/keeper_deposit.go | 25 ++++++++++++++++++------ x/btcbridge/keeper/utxo.go | 2 +- x/btcbridge/types/bitcoin_transaction.go | 6 ++++-- x/btcbridge/types/keys.go | 3 --- x/btcbridge/types/params.go | 1 + 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/x/btcbridge/keeper/keeper_deposit.go b/x/btcbridge/keeper/keeper_deposit.go index 2668a640..553558f2 100644 --- a/x/btcbridge/keeper/keeper_deposit.go +++ b/x/btcbridge/keeper/keeper_deposit.go @@ -100,7 +100,9 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg return err } - sender, err := pk.Address(types.ChainCfg) + chainCfg := sdk.GetConfig().GetBtcChainCfg() + + sender, err := pk.Address(chainCfg) if err != nil { return err } @@ -129,7 +131,7 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg if err != nil { return err } - addr, err := pks.Address(types.ChainCfg) + addr, err := pks.Address(chainCfg) if err != nil { return err } @@ -143,7 +145,10 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg // skip if the asset type of the sender address is unspecified switch vault.AssetType { case types.AssetType_ASSET_TYPE_BTC: - k.mintBTC(ctx, uTx, header.Height, sender.EncodeAddress(), vault, out, i, param.BtcVoucherDenom) + err := k.mintBTC(ctx, uTx, header.Height, sender.EncodeAddress(), vault, out, i, param.BtcVoucherDenom) + if err != nil { + return err + } case types.AssetType_ASSET_TYPE_RUNE: k.mintRUNE(ctx, uTx, header.Height, sender.EncodeAddress(), vault, out, i, "rune") } @@ -162,6 +167,9 @@ func (k Keeper) mintBTC(ctx sdk.Context, uTx *btcutil.Tx, height uint64, sender k.addToMintHistory(ctx, hash) // mint the voucher token + if len(denom) == 0 { + denom = "sat" + } coins := sdk.NewCoins(sdk.NewCoin(denom, sdk.NewInt(out.Value))) receipient, err := sdk.AccAddressFromBech32(sender) @@ -169,8 +177,13 @@ func (k Keeper) mintBTC(ctx sdk.Context, uTx *btcutil.Tx, height uint64, sender return err } - k.bankKeeper.MintCoins(ctx, types.ModuleName, coins) - k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, receipient, coins) + if err := k.bankKeeper.MintCoins(ctx, types.ModuleName, coins); err != nil { + return err + } + + if err := k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, receipient, coins); err != nil { + return err + } utxo := types.UTXO{ Txid: uTx.Hash().String(), @@ -201,7 +214,7 @@ func (k Keeper) existsInHistory(ctx sdk.Context, txHash string) bool { func (k Keeper) addToMintHistory(ctx sdk.Context, txHash string) { store := ctx.KVStore(k.storeKey) - store.Set(types.BtcMintedTxHashKey(txHash), nil) + store.Set(types.BtcMintedTxHashKey(txHash), []byte{1}) } // need a query all history for exporting diff --git a/x/btcbridge/keeper/utxo.go b/x/btcbridge/keeper/utxo.go index c1c61e7b..1e246b83 100644 --- a/x/btcbridge/keeper/utxo.go +++ b/x/btcbridge/keeper/utxo.go @@ -197,7 +197,7 @@ func (bk *BaseUTXOKeeper) SetUTXO(ctx sdk.Context, utxo *types.UTXO) { func (bk *BaseUTXOKeeper) SetOwnerUTXO(ctx sdk.Context, utxo *types.UTXO) { store := ctx.KVStore(bk.storeKey) - store.Set(types.BtcOwnerUtxoKey(utxo.Address, utxo.Txid, utxo.Vout), nil) + store.Set(types.BtcOwnerUtxoKey(utxo.Address, utxo.Txid, utxo.Vout), []byte{1}) } func (bk *BaseUTXOKeeper) LockUTXO(ctx sdk.Context, hash string, vout uint64) error { diff --git a/x/btcbridge/types/bitcoin_transaction.go b/x/btcbridge/types/bitcoin_transaction.go index 72e55ef2..b94e14ac 100644 --- a/x/btcbridge/types/bitcoin_transaction.go +++ b/x/btcbridge/types/bitcoin_transaction.go @@ -7,6 +7,7 @@ import ( "github.com/btcsuite/btcd/mempool" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" + sdk "github.com/cosmos/cosmos-sdk/types" ) const ( @@ -20,7 +21,8 @@ const ( // BuildPsbt builds a bitcoin psbt from the given params. // Assume that the utxo script type is witness. func BuildPsbt(utxos []*UTXO, recipient string, amount int64, feeRate int64, change string) (*psbt.Packet, []*UTXO, error) { - recipientAddr, err := btcutil.DecodeAddress(recipient, ChainCfg) + chaincfg := sdk.GetConfig().GetBtcChainCfg() + recipientAddr, err := btcutil.DecodeAddress(recipient, chaincfg) if err != nil { return nil, nil, err } @@ -30,7 +32,7 @@ func BuildPsbt(utxos []*UTXO, recipient string, amount int64, feeRate int64, cha return nil, nil, err } - changeAddr, err := btcutil.DecodeAddress(change, ChainCfg) + changeAddr, err := btcutil.DecodeAddress(change, chaincfg) if err != nil { return nil, nil, err } diff --git a/x/btcbridge/types/keys.go b/x/btcbridge/types/keys.go index a7360f11..ceeee42a 100644 --- a/x/btcbridge/types/keys.go +++ b/x/btcbridge/types/keys.go @@ -2,8 +2,6 @@ package types import ( "math/big" - - "github.com/btcsuite/btcd/chaincfg" ) const ( @@ -36,7 +34,6 @@ var ( BtcMintedTxHashKeyPrefix = []byte{0x17} // prefix for each key to a minted tx hash - ChainCfg = &chaincfg.MainNetParams ) func Int64ToBytes(number uint64) []byte { diff --git a/x/btcbridge/types/params.go b/x/btcbridge/types/params.go index f6d8dc7d..c6d49a6f 100644 --- a/x/btcbridge/types/params.go +++ b/x/btcbridge/types/params.go @@ -8,6 +8,7 @@ func NewParams(relayers []string) Params { AuthorizedRelayers: relayers, Confirmations: 2, MaxAcceptableBlockDepth: 100, + BtcVoucherDenom: "sat", Vaults: []*Vault{{ Address: "", PubKey: "", From 80cf31ed204b9cb71d1fe6cd63b29bf6136fc936 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Wed, 19 Jun 2024 13:35:47 +0800 Subject: [PATCH 50/71] pre-allocated sat in genesis --- local_node_dev.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/local_node_dev.sh b/local_node_dev.sh index 5c2f62aa..baf81884 100755 --- a/local_node_dev.sh +++ b/local_node_dev.sh @@ -4,7 +4,7 @@ KEYS=("dev0" "dev1") CHAINID="devnet" MONIKER="Side Labs" BINARY="$HOME/go/bin/sided" -DENOM_STR="uside" +DENOM_STR="uside;sat" INITIAL_ACCOUNT_STR="" set -f IFS=, From 7b83fb40bb2572233026330169da036c7f898d5c Mon Sep 17 00:00:00 2001 From: sufay Date: Wed, 19 Jun 2024 13:02:15 +0800 Subject: [PATCH 51/71] add utxo and signing request query cli --- proto/side/btcbridge/query.proto | 27 +- x/btcbridge/client/cli/query.go | 89 ++++ x/btcbridge/keeper/queries.go | 27 + x/btcbridge/types/query.pb.go | 829 +++++++++++++++++++++++++++++-- 4 files changed, 926 insertions(+), 46 deletions(-) diff --git a/proto/side/btcbridge/query.proto b/proto/side/btcbridge/query.proto index 0563d8da..e89c74fa 100644 --- a/proto/side/btcbridge/query.proto +++ b/proto/side/btcbridge/query.proto @@ -31,7 +31,14 @@ service Query { rpc QuerySigningRequest(QuerySigningRequestRequest) returns (QuerySigningRequestResponse) { option (google.api.http).get = "/sideprotocol/side/btcbridge/signing/request"; } - + // UTXOs queries all utxos. + rpc QueryUTXOs(QueryUTXOsRequest) returns (QueryUTXOsResponse) { + option (google.api.http).get = "/sideprotocol/side/btcbridge/utxos"; + } + // UTXOsByAddress queries the utxos of the given address. + rpc QueryUTXOsByAddress(QueryUTXOsByAddressRequest) returns (QueryUTXOsByAddressResponse) { + option (google.api.http).get = "/sideprotocol/side/btcbridge/utxos/{address}"; + } } // QuerySigningRequestRequest is request type for the Query/SigningRequest RPC method. @@ -83,3 +90,21 @@ message QueryBlockHeaderByHashRequest { message QueryBlockHeaderByHashResponse { BlockHeader block_header = 1; } + +// QueryUTXOsRequest is the request type for the Query/UTXOs RPC method. +message QueryUTXOsRequest {} + +// QueryUTXOsResponse is the response type for the Query/UTXOs RPC method. +message QueryUTXOsResponse { + repeated UTXO utxos = 1; +} + +// QueryUTXOsByAddressRequest is the request type for the Query/UTXOsByAddress RPC method. +message QueryUTXOsByAddressRequest { + string address = 1; +} + +// QueryUTXOsByAddressResponse is the response type for the Query/UTXOsByAddress RPC method. +message QueryUTXOsByAddressResponse { + repeated UTXO utxos = 1; +} diff --git a/x/btcbridge/client/cli/query.go b/x/btcbridge/client/cli/query.go index 0faddbec..fe32072e 100644 --- a/x/btcbridge/client/cli/query.go +++ b/x/btcbridge/client/cli/query.go @@ -1,6 +1,7 @@ package cli import ( + "context" "fmt" "strconv" @@ -11,6 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + sdk "github.com/cosmos/cosmos-sdk/types" ) // GetQueryCmd returns the cli query commands for this module @@ -27,6 +29,7 @@ func GetQueryCmd(_ string) *cobra.Command { cmd.AddCommand(CmdQueryParams()) cmd.AddCommand(CmdBestBlock()) cmd.AddCommand(CmdQueryBlock()) + cmd.AddCommand(CmdQueryUTXOs()) // this line is used by starport scaffolding # 1 return cmd @@ -124,3 +127,89 @@ func CmdQueryBlock() *cobra.Command { return cmd } + +// CmdQuerySigningRequest returns the command to query signing request +func CmdQuerySigningRequest() *cobra.Command { + cmd := &cobra.Command{ + Use: "signing-request [status]", + Short: "Query all signing requests", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + status, err := strconv.ParseInt(args[0], 10, 32) + if err != nil { + return err + } + + res, err := queryClient.QuerySigningRequest(cmd.Context(), &types.QuerySigningRequestRequest{Status: types.SigningStatus(status)}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdQueryUTXOs() *cobra.Command { + cmd := &cobra.Command{ + Use: "utxos [address]", + Short: "query utxos with an optional address", + Args: cobra.MaximumNArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + if len(args) == 0 { + return queryUTXOs(&clientCtx, cmd.Context()) + } + + return queryUTXOsByAddr(&clientCtx, cmd.Context(), args[0]) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func queryUTXOs(clientCtx *client.Context, cmdCtx context.Context) error { + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.QueryUTXOs(cmdCtx, &types.QueryUTXOsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) +} + +func queryUTXOsByAddr(clientCtx *client.Context, cmdCtx context.Context, addr string) error { + queryClient := types.NewQueryClient(clientCtx) + + _, err := sdk.AccAddressFromBech32(addr) + if err != nil { + return err + } + + res, err := queryClient.QueryUTXOsByAddress(cmdCtx, &types.QueryUTXOsByAddressRequest{ + Address: addr, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) +} diff --git a/x/btcbridge/keeper/queries.go b/x/btcbridge/keeper/queries.go index 36b74a77..127725c8 100644 --- a/x/btcbridge/keeper/queries.go +++ b/x/btcbridge/keeper/queries.go @@ -78,3 +78,30 @@ func (k Keeper) QuerySigningRequest(goCtx context.Context, req *types.QuerySigni return &types.QuerySigningRequestResponse{Requests: requests}, nil } + +func (k Keeper) QueryUTXOs(goCtx context.Context, req *types.QueryUTXOsRequest) (*types.QueryUTXOsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + utxos := k.GetAllUTXOs(ctx) + + return &types.QueryUTXOsResponse{Utxos: utxos}, nil +} + +func (k Keeper) QueryUTXOsByAddress(goCtx context.Context, req *types.QueryUTXOsByAddressRequest) (*types.QueryUTXOsByAddressResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + _, err := sdk.AccAddressFromBech32(req.Address) + if err != nil { + return nil, err + } + + utxos := k.GetUTXOsByAddr(ctx, req.Address) + + return &types.QueryUTXOsByAddressResponse{Utxos: utxos}, nil +} diff --git a/x/btcbridge/types/query.pb.go b/x/btcbridge/types/query.pb.go index f96008d8..06498e35 100644 --- a/x/btcbridge/types/query.pb.go +++ b/x/btcbridge/types/query.pb.go @@ -489,6 +489,178 @@ func (m *QueryBlockHeaderByHashResponse) GetBlockHeader() *BlockHeader { return nil } +// QueryUTXOsRequest is the request type for the Query/UTXOs RPC method. +type QueryUTXOsRequest struct { +} + +func (m *QueryUTXOsRequest) Reset() { *m = QueryUTXOsRequest{} } +func (m *QueryUTXOsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryUTXOsRequest) ProtoMessage() {} +func (*QueryUTXOsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_fb547edb49d5502d, []int{10} +} +func (m *QueryUTXOsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryUTXOsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryUTXOsRequest.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 *QueryUTXOsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryUTXOsRequest.Merge(m, src) +} +func (m *QueryUTXOsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryUTXOsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryUTXOsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryUTXOsRequest proto.InternalMessageInfo + +// QueryUTXOsResponse is the response type for the Query/UTXOs RPC method. +type QueryUTXOsResponse struct { + Utxos []*UTXO `protobuf:"bytes,1,rep,name=utxos,proto3" json:"utxos,omitempty"` +} + +func (m *QueryUTXOsResponse) Reset() { *m = QueryUTXOsResponse{} } +func (m *QueryUTXOsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryUTXOsResponse) ProtoMessage() {} +func (*QueryUTXOsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_fb547edb49d5502d, []int{11} +} +func (m *QueryUTXOsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryUTXOsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryUTXOsResponse.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 *QueryUTXOsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryUTXOsResponse.Merge(m, src) +} +func (m *QueryUTXOsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryUTXOsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryUTXOsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryUTXOsResponse proto.InternalMessageInfo + +func (m *QueryUTXOsResponse) GetUtxos() []*UTXO { + if m != nil { + return m.Utxos + } + return nil +} + +// QueryUTXOsByAddressRequest is the request type for the Query/UTXOsByAddress RPC method. +type QueryUTXOsByAddressRequest struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *QueryUTXOsByAddressRequest) Reset() { *m = QueryUTXOsByAddressRequest{} } +func (m *QueryUTXOsByAddressRequest) String() string { return proto.CompactTextString(m) } +func (*QueryUTXOsByAddressRequest) ProtoMessage() {} +func (*QueryUTXOsByAddressRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_fb547edb49d5502d, []int{12} +} +func (m *QueryUTXOsByAddressRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryUTXOsByAddressRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryUTXOsByAddressRequest.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 *QueryUTXOsByAddressRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryUTXOsByAddressRequest.Merge(m, src) +} +func (m *QueryUTXOsByAddressRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryUTXOsByAddressRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryUTXOsByAddressRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryUTXOsByAddressRequest proto.InternalMessageInfo + +func (m *QueryUTXOsByAddressRequest) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +// QueryUTXOsByAddressResponse is the response type for the Query/UTXOsByAddress RPC method. +type QueryUTXOsByAddressResponse struct { + Utxos []*UTXO `protobuf:"bytes,1,rep,name=utxos,proto3" json:"utxos,omitempty"` +} + +func (m *QueryUTXOsByAddressResponse) Reset() { *m = QueryUTXOsByAddressResponse{} } +func (m *QueryUTXOsByAddressResponse) String() string { return proto.CompactTextString(m) } +func (*QueryUTXOsByAddressResponse) ProtoMessage() {} +func (*QueryUTXOsByAddressResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_fb547edb49d5502d, []int{13} +} +func (m *QueryUTXOsByAddressResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryUTXOsByAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryUTXOsByAddressResponse.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 *QueryUTXOsByAddressResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryUTXOsByAddressResponse.Merge(m, src) +} +func (m *QueryUTXOsByAddressResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryUTXOsByAddressResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryUTXOsByAddressResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryUTXOsByAddressResponse proto.InternalMessageInfo + +func (m *QueryUTXOsByAddressResponse) GetUtxos() []*UTXO { + if m != nil { + return m.Utxos + } + return nil +} + func init() { proto.RegisterType((*QuerySigningRequestRequest)(nil), "side.btcbridge.QuerySigningRequestRequest") proto.RegisterType((*QuerySigningRequestResponse)(nil), "side.btcbridge.QuerySigningRequestResponse") @@ -500,54 +672,66 @@ func init() { proto.RegisterType((*QueryBlockHeaderByHeightResponse)(nil), "side.btcbridge.QueryBlockHeaderByHeightResponse") proto.RegisterType((*QueryBlockHeaderByHashRequest)(nil), "side.btcbridge.QueryBlockHeaderByHashRequest") proto.RegisterType((*QueryBlockHeaderByHashResponse)(nil), "side.btcbridge.QueryBlockHeaderByHashResponse") + proto.RegisterType((*QueryUTXOsRequest)(nil), "side.btcbridge.QueryUTXOsRequest") + proto.RegisterType((*QueryUTXOsResponse)(nil), "side.btcbridge.QueryUTXOsResponse") + proto.RegisterType((*QueryUTXOsByAddressRequest)(nil), "side.btcbridge.QueryUTXOsByAddressRequest") + proto.RegisterType((*QueryUTXOsByAddressResponse)(nil), "side.btcbridge.QueryUTXOsByAddressResponse") } func init() { proto.RegisterFile("side/btcbridge/query.proto", fileDescriptor_fb547edb49d5502d) } var fileDescriptor_fb547edb49d5502d = []byte{ - // 670 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xc1, 0x4f, 0x13, 0x4f, - 0x14, 0xc7, 0x3b, 0xfc, 0xf8, 0x35, 0xfa, 0xaa, 0x1c, 0x46, 0x6c, 0xc8, 0x02, 0x4b, 0xb3, 0x48, - 0x6c, 0x40, 0x77, 0xa0, 0xe0, 0xc1, 0x8b, 0x89, 0xe5, 0x20, 0x89, 0x17, 0x5c, 0x3c, 0x79, 0xd1, - 0xd9, 0x32, 0xd9, 0x9d, 0x08, 0x3b, 0x4b, 0x67, 0x6a, 0x24, 0x84, 0x8b, 0x26, 0x9e, 0x4d, 0xbc, - 0x9a, 0x78, 0xf1, 0xc2, 0xd9, 0x7f, 0x82, 0x23, 0x89, 0x17, 0x4f, 0xc6, 0x80, 0x7f, 0x88, 0xd9, - 0x99, 0x29, 0xa5, 0xcb, 0xb6, 0xd6, 0x84, 0x4b, 0xbb, 0x3b, 0xef, 0xfb, 0xde, 0xfb, 0xbc, 0x99, - 0xef, 0x0e, 0x38, 0x92, 0x6f, 0x33, 0x12, 0xaa, 0x56, 0xd8, 0xe6, 0xdb, 0x11, 0x23, 0x7b, 0x1d, - 0xd6, 0xde, 0xf7, 0xd3, 0xb6, 0x50, 0x02, 0x4f, 0x64, 0x31, 0xff, 0x3c, 0xe6, 0x4c, 0x46, 0x22, - 0x12, 0x3a, 0x44, 0xb2, 0x27, 0xa3, 0x72, 0x66, 0x22, 0x21, 0xa2, 0x1d, 0x46, 0x68, 0xca, 0x09, - 0x4d, 0x12, 0xa1, 0xa8, 0xe2, 0x22, 0x91, 0x36, 0xba, 0xd8, 0x12, 0x72, 0x57, 0x48, 0x12, 0x52, - 0x69, 0x8b, 0x93, 0x37, 0x2b, 0x21, 0x53, 0x74, 0x85, 0xa4, 0x34, 0xe2, 0x89, 0x16, 0x5b, 0xed, - 0x74, 0x8e, 0x25, 0xa5, 0x6d, 0xba, 0xdb, 0x2d, 0x34, 0x93, 0x0b, 0x86, 0x5c, 0xb5, 0x04, 0xb7, - 0xa9, 0xde, 0x67, 0x04, 0xce, 0xb3, 0xac, 0xfa, 0x16, 0x8f, 0x12, 0x9e, 0x44, 0x01, 0xdb, 0xeb, - 0x30, 0xa9, 0xec, 0x1f, 0x7e, 0x00, 0x65, 0xa9, 0xa8, 0xea, 0xc8, 0x29, 0x54, 0x43, 0xf5, 0x89, - 0xc6, 0xac, 0xdf, 0x3f, 0x9a, 0x6f, 0xd3, 0xb6, 0xb4, 0x28, 0xb0, 0x62, 0xfc, 0x04, 0xa0, 0x07, - 0x39, 0x35, 0x56, 0x43, 0xf5, 0x4a, 0xe3, 0xae, 0x6f, 0x26, 0xf2, 0xb3, 0x89, 0x7c, 0xb3, 0x5d, - 0x76, 0x22, 0x7f, 0x93, 0x46, 0x2c, 0x60, 0x32, 0x15, 0x89, 0x64, 0xc1, 0x85, 0x54, 0xef, 0x08, - 0xc1, 0x74, 0x21, 0x9e, 0xd1, 0xe2, 0xc7, 0x70, 0xad, 0x6d, 0x96, 0x32, 0xc2, 0xff, 0xea, 0x95, - 0xc6, 0x42, 0x9e, 0xb0, 0x69, 0xe6, 0xcd, 0x15, 0x38, 0x4f, 0xbb, 0x3a, 0xd6, 0x49, 0xc0, 0x1a, - 0x75, 0x53, 0xef, 0xbe, 0x6d, 0xe4, 0x3d, 0x85, 0x5b, 0x7d, 0xab, 0x16, 0x7c, 0x0d, 0xca, 0xe6, - 0x94, 0xf4, 0xc6, 0x56, 0x1a, 0xd5, 0x3c, 0xb6, 0xd1,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, 0xcb, - 0x52, 0xd7, 0x2c, 0x1e, 0xae, 0x0d, 0x65, 0x51, 0x3c, 0xc5, 0xdf, 0x10, 0x4c, 0x0d, 0x32, 0x05, - 0x26, 0x85, 0xdd, 0x06, 0x3b, 0xcf, 0x59, 0x1e, 0x3d, 0xc1, 0x92, 0xae, 0x69, 0x52, 0x1f, 0xdf, - 0x1b, 0x4a, 0x6a, 0x0c, 0x4c, 0x0e, 0xcc, 0xff, 0x21, 0x3e, 0x42, 0x50, 0x2d, 0x76, 0x0c, 0xbe, - 0x3f, 0x02, 0x42, 0xcf, 0x8e, 0x8e, 0x3f, 0xaa, 0xdc, 0xf2, 0x2e, 0x6b, 0xde, 0x45, 0x5c, 0x1f, - 0xce, 0x4b, 0x65, 0x4c, 0x0e, 0xb2, 0xdf, 0x43, 0xfc, 0x15, 0xd9, 0xbb, 0xa5, 0xff, 0x6e, 0xc3, - 0x8b, 0x85, 0x9d, 0x0b, 0x2f, 0x78, 0x67, 0x69, 0x24, 0xed, 0x3f, 0x6d, 0xa9, 0x34, 0xc9, 0xc4, - 0xde, 0xb0, 0xcd, 0x8d, 0xe3, 0x53, 0x17, 0x9d, 0x9c, 0xba, 0xe8, 0xd7, 0xa9, 0x8b, 0x3e, 0x9e, - 0xb9, 0xa5, 0x93, 0x33, 0xb7, 0xf4, 0xe3, 0xcc, 0x2d, 0xbd, 0xf0, 0x23, 0xae, 0xe2, 0x4e, 0xe8, - 0xb7, 0xc4, 0x6e, 0x41, 0xc5, 0xb7, 0x17, 0x0d, 0xb5, 0x9f, 0x32, 0x19, 0x96, 0xb5, 0x60, 0xf5, - 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x14, 0x9a, 0x8c, 0x99, 0x7c, 0x07, 0x00, 0x00, + // 793 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0x41, 0x4f, 0x13, 0x5b, + 0x14, 0xc7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0xa9, 0x93, 0xb3, 0x42, + 0xea, 0xfb, 0x59, 0x21, 0xf5, 0xdc, 0x74, 0xbc, 0xd0, 0x6d, 0xda, 0x66, 0x8d, 0xed, 0x26, 0x44, + 0xdc, 0xef, 0x1e, 0xbc, 0x56, 0x40, 0xb9, 0x9d, 0x16, 0x82, 0x95, 0xdf, 0x01, 0x00, 0x00, 0xff, + 0xff, 0xeb, 0x78, 0x82, 0x82, 0x7e, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -572,6 +756,10 @@ type QueryClient interface { QueryBlockHeaderByHash(ctx context.Context, in *QueryBlockHeaderByHashRequest, opts ...grpc.CallOption) (*QueryBlockHeaderByHashResponse, error) // QuerySigningRequest queries the request to sign. QuerySigningRequest(ctx context.Context, in *QuerySigningRequestRequest, opts ...grpc.CallOption) (*QuerySigningRequestResponse, error) + // UTXOs queries all utxos. + QueryUTXOs(ctx context.Context, in *QueryUTXOsRequest, opts ...grpc.CallOption) (*QueryUTXOsResponse, error) + // UTXOsByAddress queries the utxos of the given address. + QueryUTXOsByAddress(ctx context.Context, in *QueryUTXOsByAddressRequest, opts ...grpc.CallOption) (*QueryUTXOsByAddressResponse, error) } type queryClient struct { @@ -627,6 +815,24 @@ func (c *queryClient) QuerySigningRequest(ctx context.Context, in *QuerySigningR return out, nil } +func (c *queryClient) QueryUTXOs(ctx context.Context, in *QueryUTXOsRequest, opts ...grpc.CallOption) (*QueryUTXOsResponse, error) { + out := new(QueryUTXOsResponse) + err := c.cc.Invoke(ctx, "/side.btcbridge.Query/QueryUTXOs", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) QueryUTXOsByAddress(ctx context.Context, in *QueryUTXOsByAddressRequest, opts ...grpc.CallOption) (*QueryUTXOsByAddressResponse, error) { + out := new(QueryUTXOsByAddressResponse) + err := c.cc.Invoke(ctx, "/side.btcbridge.Query/QueryUTXOsByAddress", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. @@ -639,6 +845,10 @@ type QueryServer interface { QueryBlockHeaderByHash(context.Context, *QueryBlockHeaderByHashRequest) (*QueryBlockHeaderByHashResponse, error) // QuerySigningRequest queries the request to sign. QuerySigningRequest(context.Context, *QuerySigningRequestRequest) (*QuerySigningRequestResponse, error) + // UTXOs queries all utxos. + QueryUTXOs(context.Context, *QueryUTXOsRequest) (*QueryUTXOsResponse, error) + // UTXOsByAddress queries the utxos of the given address. + QueryUTXOsByAddress(context.Context, *QueryUTXOsByAddressRequest) (*QueryUTXOsByAddressResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -660,6 +870,12 @@ func (*UnimplementedQueryServer) QueryBlockHeaderByHash(ctx context.Context, req func (*UnimplementedQueryServer) QuerySigningRequest(ctx context.Context, req *QuerySigningRequestRequest) (*QuerySigningRequestResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QuerySigningRequest not implemented") } +func (*UnimplementedQueryServer) QueryUTXOs(ctx context.Context, req *QueryUTXOsRequest) (*QueryUTXOsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryUTXOs not implemented") +} +func (*UnimplementedQueryServer) QueryUTXOsByAddress(ctx context.Context, req *QueryUTXOsByAddressRequest) (*QueryUTXOsByAddressResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryUTXOsByAddress not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -755,6 +971,42 @@ func _Query_QuerySigningRequest_Handler(srv interface{}, ctx context.Context, de return interceptor(ctx, in, info, handler) } +func _Query_QueryUTXOs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryUTXOsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QueryUTXOs(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/side.btcbridge.Query/QueryUTXOs", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QueryUTXOs(ctx, req.(*QueryUTXOsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_QueryUTXOsByAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryUTXOsByAddressRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QueryUTXOsByAddress(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/side.btcbridge.Query/QueryUTXOsByAddress", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QueryUTXOsByAddress(ctx, req.(*QueryUTXOsByAddressRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "side.btcbridge.Query", HandlerType: (*QueryServer)(nil), @@ -779,6 +1031,14 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "QuerySigningRequest", Handler: _Query_QuerySigningRequest_Handler, }, + { + MethodName: "QueryUTXOs", + Handler: _Query_QueryUTXOs_Handler, + }, + { + MethodName: "QueryUTXOsByAddress", + Handler: _Query_QueryUTXOsByAddress_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "side/btcbridge/query.proto", @@ -1115,6 +1375,133 @@ func (m *QueryBlockHeaderByHashResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *QueryUTXOsRequest) 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 *QueryUTXOsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryUTXOsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryUTXOsResponse) 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 *QueryUTXOsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryUTXOsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Utxos) > 0 { + for iNdEx := len(m.Utxos) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Utxos[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryUTXOsByAddressRequest) 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 *QueryUTXOsByAddressRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryUTXOsByAddressRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryUTXOsByAddressResponse) 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 *QueryUTXOsByAddressResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryUTXOsByAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Utxos) > 0 { + for iNdEx := len(m.Utxos) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Utxos[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -1257,8 +1644,60 @@ func (m *QueryBlockHeaderByHashResponse) Size() (n int) { return n } -func sovQuery(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 +func (m *QueryUTXOsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryUTXOsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Utxos) > 0 { + for _, e := range m.Utxos { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryUTXOsByAddressRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryUTXOsByAddressResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Utxos) > 0 { + for _, e := range m.Utxos { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 } func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) @@ -2095,6 +2534,306 @@ func (m *QueryBlockHeaderByHashResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryUTXOsRequest) 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 ErrIntOverflowQuery + } + 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: QueryUTXOsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryUTXOsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryUTXOsResponse) 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 ErrIntOverflowQuery + } + 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: QueryUTXOsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryUTXOsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Utxos", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Utxos = append(m.Utxos, &UTXO{}) + if err := m.Utxos[len(m.Utxos)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryUTXOsByAddressRequest) 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 ErrIntOverflowQuery + } + 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: QueryUTXOsByAddressRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryUTXOsByAddressRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryUTXOsByAddressResponse) 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 ErrIntOverflowQuery + } + 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: QueryUTXOsByAddressResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryUTXOsByAddressResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Utxos", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Utxos = append(m.Utxos, &UTXO{}) + if err := m.Utxos[len(m.Utxos)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 From d1cd74b39b0bdeb7bf3e29abf7b4e2a2665699b8 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Wed, 19 Jun 2024 13:57:44 +0800 Subject: [PATCH 52/71] denom --- local_node_dev.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/local_node_dev.sh b/local_node_dev.sh index baf81884..8aa86113 100755 --- a/local_node_dev.sh +++ b/local_node_dev.sh @@ -1,10 +1,10 @@ #!/bin/bash -KEYS=("dev0" "dev1") +KEYS=("dev0" "dev1" "dev2") CHAINID="devnet" MONIKER="Side Labs" BINARY="$HOME/go/bin/sided" -DENOM_STR="uside;sat" +DENOM_STR="uside,sat" INITIAL_ACCOUNT_STR="" set -f IFS=, From 9b209c8f3ded7f08e8b53fe25bc903f1fcab9a61 Mon Sep 17 00:00:00 2001 From: sufay Date: Wed, 19 Jun 2024 13:02:15 +0800 Subject: [PATCH 53/71] add utxo and signing request query cli --- proto/side/btcbridge/query.proto | 27 +- x/btcbridge/client/cli/query.go | 90 ++++ x/btcbridge/keeper/queries.go | 27 + x/btcbridge/types/query.pb.go | 829 +++++++++++++++++++++++++++++-- 4 files changed, 927 insertions(+), 46 deletions(-) diff --git a/proto/side/btcbridge/query.proto b/proto/side/btcbridge/query.proto index 0563d8da..e89c74fa 100644 --- a/proto/side/btcbridge/query.proto +++ b/proto/side/btcbridge/query.proto @@ -31,7 +31,14 @@ service Query { rpc QuerySigningRequest(QuerySigningRequestRequest) returns (QuerySigningRequestResponse) { option (google.api.http).get = "/sideprotocol/side/btcbridge/signing/request"; } - + // UTXOs queries all utxos. + rpc QueryUTXOs(QueryUTXOsRequest) returns (QueryUTXOsResponse) { + option (google.api.http).get = "/sideprotocol/side/btcbridge/utxos"; + } + // UTXOsByAddress queries the utxos of the given address. + rpc QueryUTXOsByAddress(QueryUTXOsByAddressRequest) returns (QueryUTXOsByAddressResponse) { + option (google.api.http).get = "/sideprotocol/side/btcbridge/utxos/{address}"; + } } // QuerySigningRequestRequest is request type for the Query/SigningRequest RPC method. @@ -83,3 +90,21 @@ message QueryBlockHeaderByHashRequest { message QueryBlockHeaderByHashResponse { BlockHeader block_header = 1; } + +// QueryUTXOsRequest is the request type for the Query/UTXOs RPC method. +message QueryUTXOsRequest {} + +// QueryUTXOsResponse is the response type for the Query/UTXOs RPC method. +message QueryUTXOsResponse { + repeated UTXO utxos = 1; +} + +// QueryUTXOsByAddressRequest is the request type for the Query/UTXOsByAddress RPC method. +message QueryUTXOsByAddressRequest { + string address = 1; +} + +// QueryUTXOsByAddressResponse is the response type for the Query/UTXOsByAddress RPC method. +message QueryUTXOsByAddressResponse { + repeated UTXO utxos = 1; +} diff --git a/x/btcbridge/client/cli/query.go b/x/btcbridge/client/cli/query.go index 0faddbec..b58f9bf7 100644 --- a/x/btcbridge/client/cli/query.go +++ b/x/btcbridge/client/cli/query.go @@ -1,6 +1,7 @@ package cli import ( + "context" "fmt" "strconv" @@ -11,6 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" + sdk "github.com/cosmos/cosmos-sdk/types" ) // GetQueryCmd returns the cli query commands for this module @@ -27,6 +29,8 @@ func GetQueryCmd(_ string) *cobra.Command { cmd.AddCommand(CmdQueryParams()) cmd.AddCommand(CmdBestBlock()) cmd.AddCommand(CmdQueryBlock()) + cmd.AddCommand(CmdQueryUTXOs()) + cmd.AddCommand(CmdQuerySigningRequest()) // this line is used by starport scaffolding # 1 return cmd @@ -124,3 +128,89 @@ func CmdQueryBlock() *cobra.Command { return cmd } + +// CmdQuerySigningRequest returns the command to query signing request +func CmdQuerySigningRequest() *cobra.Command { + cmd := &cobra.Command{ + Use: "signing-request [status]", + Short: "Query all signing requests", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + status, err := strconv.ParseInt(args[0], 10, 32) + if err != nil { + return err + } + + res, err := queryClient.QuerySigningRequest(cmd.Context(), &types.QuerySigningRequestRequest{Status: types.SigningStatus(status)}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdQueryUTXOs() *cobra.Command { + cmd := &cobra.Command{ + Use: "utxos [address]", + Short: "query utxos with an optional address", + Args: cobra.MaximumNArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + + if len(args) == 0 { + return queryUTXOs(&clientCtx, cmd.Context()) + } + + return queryUTXOsByAddr(&clientCtx, cmd.Context(), args[0]) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func queryUTXOs(clientCtx *client.Context, cmdCtx context.Context) error { + queryClient := types.NewQueryClient(clientCtx) + + res, err := queryClient.QueryUTXOs(cmdCtx, &types.QueryUTXOsRequest{}) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) +} + +func queryUTXOsByAddr(clientCtx *client.Context, cmdCtx context.Context, addr string) error { + queryClient := types.NewQueryClient(clientCtx) + + _, err := sdk.AccAddressFromBech32(addr) + if err != nil { + return err + } + + res, err := queryClient.QueryUTXOsByAddress(cmdCtx, &types.QueryUTXOsByAddressRequest{ + Address: addr, + }) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) +} diff --git a/x/btcbridge/keeper/queries.go b/x/btcbridge/keeper/queries.go index 36b74a77..127725c8 100644 --- a/x/btcbridge/keeper/queries.go +++ b/x/btcbridge/keeper/queries.go @@ -78,3 +78,30 @@ func (k Keeper) QuerySigningRequest(goCtx context.Context, req *types.QuerySigni return &types.QuerySigningRequestResponse{Requests: requests}, nil } + +func (k Keeper) QueryUTXOs(goCtx context.Context, req *types.QueryUTXOsRequest) (*types.QueryUTXOsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + utxos := k.GetAllUTXOs(ctx) + + return &types.QueryUTXOsResponse{Utxos: utxos}, nil +} + +func (k Keeper) QueryUTXOsByAddress(goCtx context.Context, req *types.QueryUTXOsByAddressRequest) (*types.QueryUTXOsByAddressResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(goCtx) + + _, err := sdk.AccAddressFromBech32(req.Address) + if err != nil { + return nil, err + } + + utxos := k.GetUTXOsByAddr(ctx, req.Address) + + return &types.QueryUTXOsByAddressResponse{Utxos: utxos}, nil +} diff --git a/x/btcbridge/types/query.pb.go b/x/btcbridge/types/query.pb.go index f96008d8..06498e35 100644 --- a/x/btcbridge/types/query.pb.go +++ b/x/btcbridge/types/query.pb.go @@ -489,6 +489,178 @@ func (m *QueryBlockHeaderByHashResponse) GetBlockHeader() *BlockHeader { return nil } +// QueryUTXOsRequest is the request type for the Query/UTXOs RPC method. +type QueryUTXOsRequest struct { +} + +func (m *QueryUTXOsRequest) Reset() { *m = QueryUTXOsRequest{} } +func (m *QueryUTXOsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryUTXOsRequest) ProtoMessage() {} +func (*QueryUTXOsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_fb547edb49d5502d, []int{10} +} +func (m *QueryUTXOsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryUTXOsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryUTXOsRequest.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 *QueryUTXOsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryUTXOsRequest.Merge(m, src) +} +func (m *QueryUTXOsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryUTXOsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryUTXOsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryUTXOsRequest proto.InternalMessageInfo + +// QueryUTXOsResponse is the response type for the Query/UTXOs RPC method. +type QueryUTXOsResponse struct { + Utxos []*UTXO `protobuf:"bytes,1,rep,name=utxos,proto3" json:"utxos,omitempty"` +} + +func (m *QueryUTXOsResponse) Reset() { *m = QueryUTXOsResponse{} } +func (m *QueryUTXOsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryUTXOsResponse) ProtoMessage() {} +func (*QueryUTXOsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_fb547edb49d5502d, []int{11} +} +func (m *QueryUTXOsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryUTXOsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryUTXOsResponse.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 *QueryUTXOsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryUTXOsResponse.Merge(m, src) +} +func (m *QueryUTXOsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryUTXOsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryUTXOsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryUTXOsResponse proto.InternalMessageInfo + +func (m *QueryUTXOsResponse) GetUtxos() []*UTXO { + if m != nil { + return m.Utxos + } + return nil +} + +// QueryUTXOsByAddressRequest is the request type for the Query/UTXOsByAddress RPC method. +type QueryUTXOsByAddressRequest struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *QueryUTXOsByAddressRequest) Reset() { *m = QueryUTXOsByAddressRequest{} } +func (m *QueryUTXOsByAddressRequest) String() string { return proto.CompactTextString(m) } +func (*QueryUTXOsByAddressRequest) ProtoMessage() {} +func (*QueryUTXOsByAddressRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_fb547edb49d5502d, []int{12} +} +func (m *QueryUTXOsByAddressRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryUTXOsByAddressRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryUTXOsByAddressRequest.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 *QueryUTXOsByAddressRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryUTXOsByAddressRequest.Merge(m, src) +} +func (m *QueryUTXOsByAddressRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryUTXOsByAddressRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryUTXOsByAddressRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryUTXOsByAddressRequest proto.InternalMessageInfo + +func (m *QueryUTXOsByAddressRequest) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +// QueryUTXOsByAddressResponse is the response type for the Query/UTXOsByAddress RPC method. +type QueryUTXOsByAddressResponse struct { + Utxos []*UTXO `protobuf:"bytes,1,rep,name=utxos,proto3" json:"utxos,omitempty"` +} + +func (m *QueryUTXOsByAddressResponse) Reset() { *m = QueryUTXOsByAddressResponse{} } +func (m *QueryUTXOsByAddressResponse) String() string { return proto.CompactTextString(m) } +func (*QueryUTXOsByAddressResponse) ProtoMessage() {} +func (*QueryUTXOsByAddressResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_fb547edb49d5502d, []int{13} +} +func (m *QueryUTXOsByAddressResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryUTXOsByAddressResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryUTXOsByAddressResponse.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 *QueryUTXOsByAddressResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryUTXOsByAddressResponse.Merge(m, src) +} +func (m *QueryUTXOsByAddressResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryUTXOsByAddressResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryUTXOsByAddressResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryUTXOsByAddressResponse proto.InternalMessageInfo + +func (m *QueryUTXOsByAddressResponse) GetUtxos() []*UTXO { + if m != nil { + return m.Utxos + } + return nil +} + func init() { proto.RegisterType((*QuerySigningRequestRequest)(nil), "side.btcbridge.QuerySigningRequestRequest") proto.RegisterType((*QuerySigningRequestResponse)(nil), "side.btcbridge.QuerySigningRequestResponse") @@ -500,54 +672,66 @@ func init() { proto.RegisterType((*QueryBlockHeaderByHeightResponse)(nil), "side.btcbridge.QueryBlockHeaderByHeightResponse") proto.RegisterType((*QueryBlockHeaderByHashRequest)(nil), "side.btcbridge.QueryBlockHeaderByHashRequest") proto.RegisterType((*QueryBlockHeaderByHashResponse)(nil), "side.btcbridge.QueryBlockHeaderByHashResponse") + proto.RegisterType((*QueryUTXOsRequest)(nil), "side.btcbridge.QueryUTXOsRequest") + proto.RegisterType((*QueryUTXOsResponse)(nil), "side.btcbridge.QueryUTXOsResponse") + proto.RegisterType((*QueryUTXOsByAddressRequest)(nil), "side.btcbridge.QueryUTXOsByAddressRequest") + proto.RegisterType((*QueryUTXOsByAddressResponse)(nil), "side.btcbridge.QueryUTXOsByAddressResponse") } func init() { proto.RegisterFile("side/btcbridge/query.proto", fileDescriptor_fb547edb49d5502d) } var fileDescriptor_fb547edb49d5502d = []byte{ - // 670 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0xc1, 0x4f, 0x13, 0x4f, - 0x14, 0xc7, 0x3b, 0xfc, 0xf8, 0x35, 0xfa, 0xaa, 0x1c, 0x46, 0x6c, 0xc8, 0x02, 0x4b, 0xb3, 0x48, - 0x6c, 0x40, 0x77, 0xa0, 0xe0, 0xc1, 0x8b, 0x89, 0xe5, 0x20, 0x89, 0x17, 0x5c, 0x3c, 0x79, 0xd1, - 0xd9, 0x32, 0xd9, 0x9d, 0x08, 0x3b, 0x4b, 0x67, 0x6a, 0x24, 0x84, 0x8b, 0x26, 0x9e, 0x4d, 0xbc, - 0x9a, 0x78, 0xf1, 0xc2, 0xd9, 0x7f, 0x82, 0x23, 0x89, 0x17, 0x4f, 0xc6, 0x80, 0x7f, 0x88, 0xd9, - 0x99, 0x29, 0xa5, 0xcb, 0xb6, 0xd6, 0x84, 0x4b, 0xbb, 0x3b, 0xef, 0xfb, 0xde, 0xfb, 0xbc, 0x99, - 0xef, 0x0e, 0x38, 0x92, 0x6f, 0x33, 0x12, 0xaa, 0x56, 0xd8, 0xe6, 0xdb, 0x11, 0x23, 0x7b, 0x1d, - 0xd6, 0xde, 0xf7, 0xd3, 0xb6, 0x50, 0x02, 0x4f, 0x64, 0x31, 0xff, 0x3c, 0xe6, 0x4c, 0x46, 0x22, - 0x12, 0x3a, 0x44, 0xb2, 0x27, 0xa3, 0x72, 0x66, 0x22, 0x21, 0xa2, 0x1d, 0x46, 0x68, 0xca, 0x09, - 0x4d, 0x12, 0xa1, 0xa8, 0xe2, 0x22, 0x91, 0x36, 0xba, 0xd8, 0x12, 0x72, 0x57, 0x48, 0x12, 0x52, - 0x69, 0x8b, 0x93, 0x37, 0x2b, 0x21, 0x53, 0x74, 0x85, 0xa4, 0x34, 0xe2, 0x89, 0x16, 0x5b, 0xed, - 0x74, 0x8e, 0x25, 0xa5, 0x6d, 0xba, 0xdb, 0x2d, 0x34, 0x93, 0x0b, 0x86, 0x5c, 0xb5, 0x04, 0xb7, - 0xa9, 0xde, 0x67, 0x04, 0xce, 0xb3, 0xac, 0xfa, 0x16, 0x8f, 0x12, 0x9e, 0x44, 0x01, 0xdb, 0xeb, - 0x30, 0xa9, 0xec, 0x1f, 0x7e, 0x00, 0x65, 0xa9, 0xa8, 0xea, 0xc8, 0x29, 0x54, 0x43, 0xf5, 0x89, - 0xc6, 0xac, 0xdf, 0x3f, 0x9a, 0x6f, 0xd3, 0xb6, 0xb4, 0x28, 0xb0, 0x62, 0xfc, 0x04, 0xa0, 0x07, - 0x39, 0x35, 0x56, 0x43, 0xf5, 0x4a, 0xe3, 0xae, 0x6f, 0x26, 0xf2, 0xb3, 0x89, 0x7c, 0xb3, 0x5d, - 0x76, 0x22, 0x7f, 0x93, 0x46, 0x2c, 0x60, 0x32, 0x15, 0x89, 0x64, 0xc1, 0x85, 0x54, 0xef, 0x08, - 0xc1, 0x74, 0x21, 0x9e, 0xd1, 0xe2, 0xc7, 0x70, 0xad, 0x6d, 0x96, 0x32, 0xc2, 0xff, 0xea, 0x95, - 0xc6, 0x42, 0x9e, 0xb0, 0x69, 0xe6, 0xcd, 0x15, 0x38, 0x4f, 0xbb, 0x3a, 0xd6, 0x49, 0xc0, 0x1a, - 0x75, 0x53, 0xef, 0xbe, 0x6d, 0xe4, 0x3d, 0x85, 0x5b, 0x7d, 0xab, 0x16, 0x7c, 0x0d, 0xca, 0xe6, - 0x94, 0xf4, 0xc6, 0x56, 0x1a, 0xd5, 0x3c, 0xb6, 0xd1, 0x37, 0xc7, 0x8f, 0x7f, 0xce, 0x95, 0x02, - 0xab, 0xf5, 0xaa, 0x30, 0xa9, 0x8b, 0xad, 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c, 0x0d, 0x32, 0x05, - 0x26, 0x85, 0xdd, 0x06, 0x3b, 0xcf, 0x59, 0x1e, 0x3d, 0xc1, 0x92, 0xae, 0x69, 0x52, 0x1f, 0xdf, - 0x1b, 0x4a, 0x6a, 0x0c, 0x4c, 0x0e, 0xcc, 0xff, 0x21, 0x3e, 0x42, 0x50, 0x2d, 0x76, 0x0c, 0xbe, - 0x3f, 0x02, 0x42, 0xcf, 0x8e, 0x8e, 0x3f, 0xaa, 0xdc, 0xf2, 0x2e, 0x6b, 0xde, 0x45, 0x5c, 0x1f, - 0xce, 0x4b, 0x65, 0x4c, 0x0e, 0xb2, 0xdf, 0x43, 0xfc, 0x15, 0xd9, 0xbb, 0xa5, 0xff, 0x6e, 0xc3, - 0x8b, 0x85, 0x9d, 0x0b, 0x2f, 0x78, 0x67, 0x69, 0x24, 0xed, 0x3f, 0x6d, 0xa9, 0x34, 0xc9, 0xc4, - 0xde, 0xb0, 0xcd, 0x8d, 0xe3, 0x53, 0x17, 0x9d, 0x9c, 0xba, 0xe8, 0xd7, 0xa9, 0x8b, 0x3e, 0x9e, - 0xb9, 0xa5, 0x93, 0x33, 0xb7, 0xf4, 0xe3, 0xcc, 0x2d, 0xbd, 0xf0, 0x23, 0xae, 0xe2, 0x4e, 0xe8, - 0xb7, 0xc4, 0x6e, 0x41, 0xc5, 0xb7, 0x17, 0x0d, 0xb5, 0x9f, 0x32, 0x19, 0x96, 0xb5, 0x60, 0xf5, - 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x14, 0x9a, 0x8c, 0x99, 0x7c, 0x07, 0x00, 0x00, + // 793 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0x41, 0x4f, 0x13, 0x5b, + 0x14, 0xc7, 0x3b, 0x3c, 0xe8, 0xe3, 0x9d, 0xbe, 0x47, 0xf2, 0x2e, 0xb5, 0x69, 0x06, 0x28, 0x75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0xda, 0x66, 0x8d, 0xed, 0x26, 0x44, + 0xdc, 0xef, 0x1e, 0xbc, 0x56, 0x40, 0xb9, 0x9d, 0x16, 0x82, 0x95, 0xdf, 0x01, 0x00, 0x00, 0xff, + 0xff, 0xeb, 0x78, 0x82, 0x82, 0x7e, 0x09, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -572,6 +756,10 @@ type QueryClient interface { QueryBlockHeaderByHash(ctx context.Context, in *QueryBlockHeaderByHashRequest, opts ...grpc.CallOption) (*QueryBlockHeaderByHashResponse, error) // QuerySigningRequest queries the request to sign. QuerySigningRequest(ctx context.Context, in *QuerySigningRequestRequest, opts ...grpc.CallOption) (*QuerySigningRequestResponse, error) + // UTXOs queries all utxos. + QueryUTXOs(ctx context.Context, in *QueryUTXOsRequest, opts ...grpc.CallOption) (*QueryUTXOsResponse, error) + // UTXOsByAddress queries the utxos of the given address. + QueryUTXOsByAddress(ctx context.Context, in *QueryUTXOsByAddressRequest, opts ...grpc.CallOption) (*QueryUTXOsByAddressResponse, error) } type queryClient struct { @@ -627,6 +815,24 @@ func (c *queryClient) QuerySigningRequest(ctx context.Context, in *QuerySigningR return out, nil } +func (c *queryClient) QueryUTXOs(ctx context.Context, in *QueryUTXOsRequest, opts ...grpc.CallOption) (*QueryUTXOsResponse, error) { + out := new(QueryUTXOsResponse) + err := c.cc.Invoke(ctx, "/side.btcbridge.Query/QueryUTXOs", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) QueryUTXOsByAddress(ctx context.Context, in *QueryUTXOsByAddressRequest, opts ...grpc.CallOption) (*QueryUTXOsByAddressResponse, error) { + out := new(QueryUTXOsByAddressResponse) + err := c.cc.Invoke(ctx, "/side.btcbridge.Query/QueryUTXOsByAddress", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // QueryServer is the server API for Query service. type QueryServer interface { // Parameters queries the parameters of the module. @@ -639,6 +845,10 @@ type QueryServer interface { QueryBlockHeaderByHash(context.Context, *QueryBlockHeaderByHashRequest) (*QueryBlockHeaderByHashResponse, error) // QuerySigningRequest queries the request to sign. QuerySigningRequest(context.Context, *QuerySigningRequestRequest) (*QuerySigningRequestResponse, error) + // UTXOs queries all utxos. + QueryUTXOs(context.Context, *QueryUTXOsRequest) (*QueryUTXOsResponse, error) + // UTXOsByAddress queries the utxos of the given address. + QueryUTXOsByAddress(context.Context, *QueryUTXOsByAddressRequest) (*QueryUTXOsByAddressResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -660,6 +870,12 @@ func (*UnimplementedQueryServer) QueryBlockHeaderByHash(ctx context.Context, req func (*UnimplementedQueryServer) QuerySigningRequest(ctx context.Context, req *QuerySigningRequestRequest) (*QuerySigningRequestResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method QuerySigningRequest not implemented") } +func (*UnimplementedQueryServer) QueryUTXOs(ctx context.Context, req *QueryUTXOsRequest) (*QueryUTXOsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryUTXOs not implemented") +} +func (*UnimplementedQueryServer) QueryUTXOsByAddress(ctx context.Context, req *QueryUTXOsByAddressRequest) (*QueryUTXOsByAddressResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method QueryUTXOsByAddress not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -755,6 +971,42 @@ func _Query_QuerySigningRequest_Handler(srv interface{}, ctx context.Context, de return interceptor(ctx, in, info, handler) } +func _Query_QueryUTXOs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryUTXOsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QueryUTXOs(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/side.btcbridge.Query/QueryUTXOs", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QueryUTXOs(ctx, req.(*QueryUTXOsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_QueryUTXOsByAddress_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryUTXOsByAddressRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).QueryUTXOsByAddress(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/side.btcbridge.Query/QueryUTXOsByAddress", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).QueryUTXOsByAddress(ctx, req.(*QueryUTXOsByAddressRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "side.btcbridge.Query", HandlerType: (*QueryServer)(nil), @@ -779,6 +1031,14 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "QuerySigningRequest", Handler: _Query_QuerySigningRequest_Handler, }, + { + MethodName: "QueryUTXOs", + Handler: _Query_QueryUTXOs_Handler, + }, + { + MethodName: "QueryUTXOsByAddress", + Handler: _Query_QueryUTXOsByAddress_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "side/btcbridge/query.proto", @@ -1115,6 +1375,133 @@ func (m *QueryBlockHeaderByHashResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *QueryUTXOsRequest) 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 *QueryUTXOsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryUTXOsRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *QueryUTXOsResponse) 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 *QueryUTXOsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryUTXOsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Utxos) > 0 { + for iNdEx := len(m.Utxos) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Utxos[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *QueryUTXOsByAddressRequest) 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 *QueryUTXOsByAddressRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryUTXOsByAddressRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryUTXOsByAddressResponse) 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 *QueryUTXOsByAddressResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryUTXOsByAddressResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Utxos) > 0 { + for iNdEx := len(m.Utxos) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Utxos[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { offset -= sovQuery(v) base := offset @@ -1257,8 +1644,60 @@ func (m *QueryBlockHeaderByHashResponse) Size() (n int) { return n } -func sovQuery(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 +func (m *QueryUTXOsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *QueryUTXOsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Utxos) > 0 { + for _, e := range m.Utxos { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func (m *QueryUTXOsByAddressRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryUTXOsByAddressResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Utxos) > 0 { + for _, e := range m.Utxos { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + return n +} + +func sovQuery(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 } func sozQuery(x uint64) (n int) { return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) @@ -2095,6 +2534,306 @@ func (m *QueryBlockHeaderByHashResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryUTXOsRequest) 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 ErrIntOverflowQuery + } + 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: QueryUTXOsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryUTXOsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryUTXOsResponse) 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 ErrIntOverflowQuery + } + 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: QueryUTXOsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryUTXOsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Utxos", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Utxos = append(m.Utxos, &UTXO{}) + if err := m.Utxos[len(m.Utxos)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryUTXOsByAddressRequest) 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 ErrIntOverflowQuery + } + 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: QueryUTXOsByAddressRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryUTXOsByAddressRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *QueryUTXOsByAddressResponse) 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 ErrIntOverflowQuery + } + 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: QueryUTXOsByAddressResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryUTXOsByAddressResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Utxos", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Utxos = append(m.Utxos, &UTXO{}) + if err := m.Utxos[len(m.Utxos)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipQuery(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 From 6905a35ee775093280279db232081547c35e9f7e Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Wed, 19 Jun 2024 15:44:24 +0800 Subject: [PATCH 54/71] add launch --- .gitignore | 4 ++-- .vscode/launch.json | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.gitignore b/.gitignore index 60c4b451..865b55e8 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ *.swl *.swm *.swn -.vscode +# .vscode .idea *.pyc *.exe @@ -85,4 +85,4 @@ contracts/@openzeppelin/* # Ignore deploy script development/setup_testnet.sh -development/join_testnet.sh \ No newline at end of file +development/join_testnet.sh diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..dc07effa --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,33 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + + { + "name": "Query Best Block", + "type": "go", + "request": "launch", + "mode": "auto", + "args": ["q", "btclightclient", "best-block"], + "program": "cmd/sided/main.go --home ~/.side" + }, + { + "name": "Query Block", + "type": "go", + "request": "launch", + "mode": "auto", + "args": ["q", "btclightclient", "block", "000000006c52128fcccbc0e5d9311cb9ffdfd3d6655dabc63c2871718c278b5f"], + "program": "cmd/sided/main.go" + }, + { + "name": "Start Blockchain", + "type": "go", + "request": "launch", + "mode": "auto", + "args": ["start"], + "program": "cmd/sided/main.go" + } + ] +} From 44456c4d203a853cfae923e8fdb827fa42e7afe5 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Wed, 19 Jun 2024 16:28:23 +0800 Subject: [PATCH 55/71] fix address issue --- x/btcbridge/keeper/msg_server.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/x/btcbridge/keeper/msg_server.go b/x/btcbridge/keeper/msg_server.go index c4b92434..7867fada 100644 --- a/x/btcbridge/keeper/msg_server.go +++ b/x/btcbridge/keeper/msg_server.go @@ -126,21 +126,17 @@ func (m msgServer) WithdrawBitcoin(goCtx context.Context, msg *types.MsgWithdraw } ctx := sdk.UnwrapSDKContext(goCtx) - sender := sdk.AccAddress(msg.Sender) + sender := sdk.MustAccAddressFromBech32(msg.Sender) coin, err := sdk.ParseCoinNormalized(msg.Amount) if err != nil { return nil, err } - balance := m.bankKeeper.GetBalance(ctx, sender, coin.Denom) - - if balance.Amount.LT(coin.Amount) { - return nil, types.ErrInsufficientBalance + if err = m.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, types.ModuleName, sdk.NewCoins(coin)); err != nil { + return nil, err } - m.bankKeeper.SendCoinsFromAccountToModule(ctx, sender, types.ModuleName, sdk.NewCoins(coin)) - _, err = m.Keeper.NewSigningRequest(ctx, msg.Sender, coin, msg.FeeRate, "") if err != nil { return nil, err From 5a077b10c0f7dedac99f8912011cba4c9b04c5b1 Mon Sep 17 00:00:00 2001 From: sufay Date: Wed, 19 Jun 2024 17:25:45 +0800 Subject: [PATCH 56/71] add submit signed psbt cmd --- x/btcbridge/client/cli/tx.go | 54 +++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 7 deletions(-) diff --git a/x/btcbridge/client/cli/tx.go b/x/btcbridge/client/cli/tx.go index 0d4cee2e..0b6c85e6 100644 --- a/x/btcbridge/client/cli/tx.go +++ b/x/btcbridge/client/cli/tx.go @@ -8,6 +8,7 @@ import ( "strings" "time" + "github.com/btcsuite/btcd/btcutil/psbt" "github.com/spf13/cobra" "github.com/cosmos/cosmos-sdk/client" @@ -38,9 +39,8 @@ func GetTxCmd() *cobra.Command { cmd.AddCommand(CmdSubmitBlocks()) cmd.AddCommand(CmdUpdateSenders()) - // this line is used by starport scaffolding # 1 - cmd.AddCommand(CmdWithdrawBitcoin()) + cmd.AddCommand(CmdSubmitWithdrawSignatures()) return cmd } @@ -116,28 +116,28 @@ func CmdUpdateSenders() *cobra.Command { // Withdraw Bitcoin func CmdWithdrawBitcoin() *cobra.Command { cmd := &cobra.Command{ - Use: "withdraw-bitcoin [sender] [amount] [fee-rate]", + Use: "withdraw [amount] [fee-rate]", Short: "Withdraw bitcoin to the given sender", - Args: cobra.ExactArgs(3), + Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) (err error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { return err } - _, err = sdk.ParseCoinsNormalized(args[1]) + _, err = sdk.ParseCoinsNormalized(args[0]) if err != nil { return fmt.Errorf("invalid amount") } - feeRate, err := strconv.ParseInt(args[2], 10, 64) + feeRate, err := strconv.ParseInt(args[1], 10, 64) if err != nil { return fmt.Errorf("invalid fee rate") } msg := types.NewMsgWithdrawBitcoinRequest( + clientCtx.GetFromAddress().String(), args[0], - args[1], feeRate, ) @@ -154,6 +154,46 @@ func CmdWithdrawBitcoin() *cobra.Command { return cmd } +func CmdSubmitWithdrawSignatures() *cobra.Command { + cmd := &cobra.Command{ + Use: "submit-signature [psbt]", + Short: "Submit signed withdrawal psbt", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + p, err := psbt.NewFromRawBytes(strings.NewReader(args[0]), true) + if err != nil { + return fmt.Errorf("invalid psbt") + } + + signedTx, err := psbt.Extract(p) + if err != nil { + return fmt.Errorf("failed to extract tx from psbt") + } + + msg := types.NewMsgSubmitWithdrawSignaturesRequest( + clientCtx.GetFromAddress().String(), + signedTx.TxHash().String(), + args[0], + ) + + if err := msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + // readBlockHeadersFromFile reads the block headers from the file func readBlockHeadersFromFile(filePath string) ([]*types.BlockHeader, error) { // read the file From ebc4880366fd8189d0b2ab3cb3c5201e3c234378 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Wed, 19 Jun 2024 17:43:47 +0800 Subject: [PATCH 57/71] rename module --- app/keepers/keepers.go | 19 +++++++++---------- app/modules.go | 14 +++++++------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 1c8725c6..cc2587d5 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -73,8 +73,8 @@ import ( yieldmodulekeeper "github.com/sideprotocol/side/x/yield/keeper" yieldmoduletypes "github.com/sideprotocol/side/x/yield/types" - btclightclientkeeper "github.com/sideprotocol/side/x/btcbridge/keeper" - btclightclienttypes "github.com/sideprotocol/side/x/btcbridge/types" + btcbridgekeeper "github.com/sideprotocol/side/x/btcbridge/keeper" + btcbridgetypes "github.com/sideprotocol/side/x/btcbridge/types" // this line is used by starport scaffolding # stargate/app/moduleImport @@ -129,10 +129,9 @@ type AppKeepers struct { ScopedICAHostKeeper capabilitykeeper.ScopedKeeper scopedWasmKeeper capabilitykeeper.ScopedKeeper - GmmKeeper gmmmodulekeeper.Keeper - - YieldKeeper yieldmodulekeeper.Keeper - BtcLightClientKeeper btclightclientkeeper.Keeper + GmmKeeper gmmmodulekeeper.Keeper + YieldKeeper yieldmodulekeeper.Keeper + BtcBridgeKeeper btcbridgekeeper.Keeper // keys to access the substores keys map[string]*storetypes.KVStoreKey @@ -393,10 +392,10 @@ func (appKeepers *AppKeepers) InitNormalKeepers( appKeepers.IcacallbacksKeeper, ) - appKeepers.BtcLightClientKeeper = *btclightclientkeeper.NewKeeper( + appKeepers.BtcBridgeKeeper = *btcbridgekeeper.NewKeeper( appCodec, - appKeepers.keys[btclightclienttypes.StoreKey], - appKeepers.keys[btclightclienttypes.StoreKey], + appKeepers.keys[btcbridgetypes.StoreKey], + appKeepers.keys[btcbridgetypes.StoreKey], appKeepers.BankKeeper, ) @@ -504,7 +503,7 @@ func KVStoreKeys() []string { ibcfeetypes.StoreKey, gmmmoduletypes.StoreKey, yieldmoduletypes.StoreKey, - btclightclienttypes.StoreKey, + btcbridgetypes.StoreKey, } } diff --git a/app/modules.go b/app/modules.go index a35f324b..69de4f97 100644 --- a/app/modules.go +++ b/app/modules.go @@ -67,8 +67,8 @@ import ( yieldmodule "github.com/sideprotocol/side/x/yield" yieldmoduletypes "github.com/sideprotocol/side/x/yield/types" - btclightclient "github.com/sideprotocol/side/x/btcbridge" - btclightclienttypes "github.com/sideprotocol/side/x/btcbridge/types" + btcbridge "github.com/sideprotocol/side/x/btcbridge" + btcbridgetypes "github.com/sideprotocol/side/x/btcbridge/types" // this line is used by starport scaffolding # stargate/app/moduleImport @@ -95,7 +95,7 @@ var moduleAccountPermissions = map[string][]string{ wasmTypes.ModuleName: {authtypes.Burner}, gmmmoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner, authtypes.Staking}, yieldmoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner, authtypes.Staking}, - btclightclienttypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + btcbridgetypes.ModuleName: {authtypes.Minter, authtypes.Burner}, } // appModules return modules to initialize module manager. @@ -142,7 +142,7 @@ func appModules( icaModule, gmmModule, yieldModule, - btclightclient.NewAppModule(appCodec, app.BtcLightClientKeeper), + btcbridge.NewAppModule(appCodec, app.BtcBridgeKeeper), // this line is used by starport scaffolding # stargate/app/appModule crisis.NewAppModule(app.CrisisKeeper, skipGenesisInvariants, app.GetSubspace(crisistypes.ModuleName)), // always be last to make sure that it checks for all invariants and not only part of them @@ -178,7 +178,7 @@ func orderBeginBlockers() []string { wasmTypes.ModuleName, gmmmoduletypes.ModuleName, yieldmoduletypes.ModuleName, - btclightclienttypes.ModuleName, + btcbridgetypes.ModuleName, } return ord } @@ -211,7 +211,7 @@ func OrderEndBlockers() []string { wasmTypes.ModuleName, gmmmoduletypes.ModuleName, yieldmoduletypes.ModuleName, - btclightclienttypes.ModuleName, + btcbridgetypes.ModuleName, } return ord } @@ -249,7 +249,7 @@ func OrderInitGenesis() []string { wasmTypes.ModuleName, gmmmoduletypes.ModuleName, yieldmoduletypes.ModuleName, - btclightclienttypes.ModuleName, + btcbridgetypes.ModuleName, } } From 3a5962f0596e90cbcf0d60b361f1af66c050f701 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Wed, 19 Jun 2024 20:58:21 +0800 Subject: [PATCH 58/71] fixed issue --- x/btcbridge/keeper/keeper_withdraw.go | 4 +- x/btcbridge/types/query.pb.gw.go | 166 ++++++++++++++++++++++++++ 2 files changed, 167 insertions(+), 3 deletions(-) diff --git a/x/btcbridge/keeper/keeper_withdraw.go b/x/btcbridge/keeper/keeper_withdraw.go index e6b7e523..8884bd32 100644 --- a/x/btcbridge/keeper/keeper_withdraw.go +++ b/x/btcbridge/keeper/keeper_withdraw.go @@ -76,9 +76,7 @@ func (k Keeper) NewSigningRequest(ctx sdk.Context, sender string, coin sdk.Coin, VaultAddress: vault, } - store := ctx.KVStore(k.storeKey) - bz := k.cdc.MustMarshal(signingRequest) - store.Set(types.BtcSigningRequestKey(signingRequest.Sequence), bz) + k.SetSigningRequest(ctx, signingRequest) return signingRequest, nil } diff --git a/x/btcbridge/types/query.pb.gw.go b/x/btcbridge/types/query.pb.gw.go index 3ee46d41..0cece861 100644 --- a/x/btcbridge/types/query.pb.gw.go +++ b/x/btcbridge/types/query.pb.gw.go @@ -213,6 +213,78 @@ func local_request_Query_QuerySigningRequest_0(ctx context.Context, marshaler ru } +func request_Query_QueryUTXOs_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryUTXOsRequest + var metadata runtime.ServerMetadata + + msg, err := client.QueryUTXOs(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryUTXOs_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryUTXOsRequest + var metadata runtime.ServerMetadata + + msg, err := server.QueryUTXOs(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_QueryUTXOsByAddress_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryUTXOsByAddressRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + msg, err := client.QueryUTXOsByAddress(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_QueryUTXOsByAddress_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryUTXOsByAddressRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + msg, err := server.QueryUTXOsByAddress(ctx, &protoReq) + return msg, metadata, err + +} + // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. @@ -334,6 +406,52 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_QueryUTXOs_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_QueryUTXOs_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryUTXOs_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_QueryUTXOsByAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_QueryUTXOsByAddress_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryUTXOsByAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -475,6 +593,46 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_QueryUTXOs_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_QueryUTXOs_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryUTXOs_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_QueryUTXOsByAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_Query_QueryUTXOsByAddress_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_QueryUTXOsByAddress_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -488,6 +646,10 @@ var ( pattern_Query_QueryBlockHeaderByHash_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 3}, []string{"sideprotocol", "side", "btcbridge", "hash"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_QuerySigningRequest_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 2, 4}, []string{"sideprotocol", "side", "btcbridge", "signing", "request"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_QueryUTXOs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"sideprotocol", "side", "btcbridge", "utxos"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_QueryUTXOsByAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"sideprotocol", "side", "btcbridge", "utxos", "address"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -500,4 +662,8 @@ var ( forward_Query_QueryBlockHeaderByHash_0 = runtime.ForwardResponseMessage forward_Query_QuerySigningRequest_0 = runtime.ForwardResponseMessage + + forward_Query_QueryUTXOs_0 = runtime.ForwardResponseMessage + + forward_Query_QueryUTXOsByAddress_0 = runtime.ForwardResponseMessage ) From b4d9f094cb108fdc08b9e1319a2af8fdaeb8d00f Mon Sep 17 00:00:00 2001 From: sufay Date: Thu, 20 Jun 2024 00:26:24 +0800 Subject: [PATCH 59/71] optimize --- x/btcbridge/keeper/keeper_deposit.go | 22 +++------ x/btcbridge/keeper/keeper_withdraw.go | 5 +- x/btcbridge/keeper/utxo.go | 10 ++++ x/btcbridge/types/bitcoin_transaction.go | 41 +++++++++++------ x/btcbridge/types/deposit_policy.go | 58 ++++++++++++++++++++++++ x/btcbridge/types/errors.go | 15 +++--- 6 files changed, 113 insertions(+), 38 deletions(-) create mode 100644 x/btcbridge/types/deposit_policy.go diff --git a/x/btcbridge/keeper/keeper_deposit.go b/x/btcbridge/keeper/keeper_deposit.go index 553558f2..7935c5ad 100644 --- a/x/btcbridge/keeper/keeper_deposit.go +++ b/x/btcbridge/keeper/keeper_deposit.go @@ -61,7 +61,7 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg return err } - // extract senders from the previous transaction + // Decode the previous transaction prevTxBytes, err := base64.StdEncoding.DecodeString(msg.PrevTxBytes) if err != nil { fmt.Println("Error decoding transaction from base64:", err) @@ -90,19 +90,10 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg return types.ErrInvalidBtcTransaction } - // check if the output is a valid address - // if there are multiple inputs, then the first input is considered as the sender - // assumpe all inputs are from the same sender - out := prevTx.MsgTx().TxOut[tx.TxIn[0].PreviousOutPoint.Index] - // check if the output is a valid address - pk, err := txscript.ParsePkScript(out.PkScript) - if err != nil { - return err - } - chainCfg := sdk.GetConfig().GetBtcChainCfg() - sender, err := pk.Address(chainCfg) + // Extract the recipient address + recipient, err := types.ExtractRecipientAddr(&tx, &prevMsgTx, param.Vaults, chainCfg) if err != nil { return err } @@ -145,12 +136,12 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg // skip if the asset type of the sender address is unspecified switch vault.AssetType { case types.AssetType_ASSET_TYPE_BTC: - err := k.mintBTC(ctx, uTx, header.Height, sender.EncodeAddress(), vault, out, i, param.BtcVoucherDenom) + err := k.mintBTC(ctx, uTx, header.Height, recipient.EncodeAddress(), vault, out, i, param.BtcVoucherDenom) if err != nil { return err } case types.AssetType_ASSET_TYPE_RUNE: - k.mintRUNE(ctx, uTx, header.Height, sender.EncodeAddress(), vault, out, i, "rune") + k.mintRUNE(ctx, uTx, header.Height, recipient.EncodeAddress(), vault, out, i, "rune") } } @@ -196,8 +187,7 @@ func (k Keeper) mintBTC(ctx sdk.Context, uTx *btcutil.Tx, height uint64, sender IsLocked: false, } - k.SetUTXO(ctx, &utxo) - k.SetOwnerUTXO(ctx, &utxo) + k.saveUTXO(ctx, &utxo) return nil } diff --git a/x/btcbridge/keeper/keeper_withdraw.go b/x/btcbridge/keeper/keeper_withdraw.go index e6b7e523..87c051b8 100644 --- a/x/btcbridge/keeper/keeper_withdraw.go +++ b/x/btcbridge/keeper/keeper_withdraw.go @@ -54,7 +54,7 @@ func (k Keeper) NewSigningRequest(ctx sdk.Context, sender string, coin sdk.Coin, return nil, types.ErrInsufficientUTXOs } - psbt, selectedUTXOs, err := types.BuildPsbt(utxos, sender, coin.Amount.Int64(), feeRate, vault) + psbt, selectedUTXOs, changeUTXO, err := types.BuildPsbt(utxos, sender, coin.Amount.Int64(), feeRate, vault) if err != nil { return nil, types.ErrFailToBuildTransaction } @@ -67,6 +67,9 @@ func (k Keeper) NewSigningRequest(ctx sdk.Context, sender string, coin sdk.Coin, // lock the selected utxos k.LockUTXOs(ctx, selectedUTXOs) + // save the change utxo + k.saveUTXO(ctx, changeUTXO) + signingRequest := &types.BitcoinSigningRequest{ Address: sender, Txid: psbt.UnsignedTx.TxHash().String(), diff --git a/x/btcbridge/keeper/utxo.go b/x/btcbridge/keeper/utxo.go index 1e246b83..a0eb6dad 100644 --- a/x/btcbridge/keeper/utxo.go +++ b/x/btcbridge/keeper/utxo.go @@ -272,6 +272,16 @@ func (bk *BaseUTXOKeeper) SpendUTXOs(ctx sdk.Context, utxos []*types.UTXO) error return nil } +// saveUTXO saves the given utxo +func (bk *BaseUTXOKeeper) saveUTXO(ctx sdk.Context, utxo *types.UTXO) { + if bk.HasUTXO(ctx, utxo.Txid, utxo.Vout) { + return + } + + bk.SetUTXO(ctx, utxo) + bk.SetOwnerUTXO(ctx, utxo) +} + // removeUTXO deletes the given utxo which is assumed to exist. func (bk *BaseUTXOKeeper) removeUTXO(ctx sdk.Context, hash string, vout uint64) { store := ctx.KVStore(bk.storeKey) diff --git a/x/btcbridge/types/bitcoin_transaction.go b/x/btcbridge/types/bitcoin_transaction.go index b94e14ac..16d52af7 100644 --- a/x/btcbridge/types/bitcoin_transaction.go +++ b/x/btcbridge/types/bitcoin_transaction.go @@ -7,6 +7,7 @@ import ( "github.com/btcsuite/btcd/mempool" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" + sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -19,35 +20,35 @@ const ( ) // BuildPsbt builds a bitcoin psbt from the given params. -// Assume that the utxo script type is witness. -func BuildPsbt(utxos []*UTXO, recipient string, amount int64, feeRate int64, change string) (*psbt.Packet, []*UTXO, error) { +// Assume that the utxo script type is native segwit. +func BuildPsbt(utxos []*UTXO, recipient string, amount int64, feeRate int64, change string) (*psbt.Packet, []*UTXO, *UTXO, error) { chaincfg := sdk.GetConfig().GetBtcChainCfg() recipientAddr, err := btcutil.DecodeAddress(recipient, chaincfg) if err != nil { - return nil, nil, err + return nil, nil, nil, err } recipientPkScript, err := txscript.PayToAddrScript(recipientAddr) if err != nil { - return nil, nil, err + return nil, nil, nil, err } changeAddr, err := btcutil.DecodeAddress(change, chaincfg) if err != nil { - return nil, nil, err + return nil, nil, nil, err } txOuts := make([]*wire.TxOut, 0) txOuts = append(txOuts, wire.NewTxOut(amount, recipientPkScript)) - unsignedTx, selectedUTXOs, err := BuildUnsignedTransaction(utxos, txOuts, feeRate, changeAddr) + unsignedTx, selectedUTXOs, changeUTXO, err := BuildUnsignedTransaction(utxos, txOuts, feeRate, changeAddr) if err != nil { - return nil, nil, err + return nil, nil, nil, err } p, err := psbt.NewFromUnsignedTx(unsignedTx) if err != nil { - return nil, nil, err + return nil, nil, nil, err } for i, utxo := range selectedUTXOs { @@ -55,17 +56,17 @@ func BuildPsbt(utxos []*UTXO, recipient string, amount int64, feeRate int64, cha p.Inputs[i].WitnessUtxo = wire.NewTxOut(int64(utxo.Amount), utxo.PubKeyScript) } - return p, selectedUTXOs, nil + return p, selectedUTXOs, changeUTXO, nil } // BuildUnsignedTransaction builds an unsigned tx from the given params. -func BuildUnsignedTransaction(utxos []*UTXO, txOuts []*wire.TxOut, feeRate int64, change btcutil.Address) (*wire.MsgTx, []*UTXO, error) { +func BuildUnsignedTransaction(utxos []*UTXO, txOuts []*wire.TxOut, feeRate int64, change btcutil.Address) (*wire.MsgTx, []*UTXO, *UTXO, error) { tx := wire.NewMsgTx(TxVersion) outAmount := int64(0) for _, txOut := range txOuts { if mempool.IsDust(txOut, MinRelayFee) { - return nil, nil, ErrDustOutput + return nil, nil, nil, ErrDustOutput } tx.AddTxOut(txOut) @@ -74,17 +75,29 @@ func BuildUnsignedTransaction(utxos []*UTXO, txOuts []*wire.TxOut, feeRate int64 changePkScript, err := txscript.PayToAddrScript(change) if err != nil { - return nil, nil, err + return nil, nil, nil, err } changeOut := wire.NewTxOut(0, changePkScript) selectedUTXOs, err := AddUTXOsToTx(tx, utxos, outAmount, changeOut, feeRate) if err != nil { - return nil, nil, err + return nil, nil, nil, err + } + + var changeUTXO *UTXO + if len(tx.TxOut) > len(txOuts) { + changeOut := tx.TxOut[len(tx.TxOut)-1] + changeUTXO = &UTXO{ + Txid: tx.TxHash().String(), + Vout: uint64(len(tx.TxOut) - 1), + Address: change.EncodeAddress(), + Amount: uint64(changeOut.Value), + PubKeyScript: changeOut.PkScript, + } } - return tx, selectedUTXOs, nil + return tx, selectedUTXOs, changeUTXO, nil } // AddUTXOsToTx adds the given utxos to the tx. diff --git a/x/btcbridge/types/deposit_policy.go b/x/btcbridge/types/deposit_policy.go new file mode 100644 index 00000000..ad2d1e32 --- /dev/null +++ b/x/btcbridge/types/deposit_policy.go @@ -0,0 +1,58 @@ +package types + +import ( + "github.com/btcsuite/btcd/btcutil" + "github.com/btcsuite/btcd/chaincfg" + "github.com/btcsuite/btcd/txscript" + "github.com/btcsuite/btcd/wire" +) + +const ( + // maximum allowed number of the non-vault outputs for the deposit transaction + MaxNonVaultOutNum = 1 +) + +// ExtractRecipientAddr extracts the recipient address for minting voucher token. +// First, extract the recipient from the tx out which is a non-vault address; +// Then fallback to the first input +func ExtractRecipientAddr(tx *wire.MsgTx, prevTx *wire.MsgTx, vaults []*Vault, chainCfg *chaincfg.Params) (btcutil.Address, error) { + var recipient btcutil.Address + + nonVaultOutCount := 0 + + // extract from the tx out which is a non-vault address + for _, out := range tx.TxOut { + pkScript, err := txscript.ParsePkScript(out.PkScript) + if err != nil { + return nil, err + } + + addr, err := pkScript.Address(chainCfg) + if err != nil { + return nil, err + } + + vault := SelectVaultByBitcoinAddress(vaults, addr.EncodeAddress()) + if vault == nil { + recipient = addr + nonVaultOutCount++ + } + } + + // exceed allowed non vault out number + if nonVaultOutCount > MaxNonVaultOutNum { + return nil, ErrInvalidDepositTransaction + } + + if recipient != nil { + return recipient, nil + } + + // fallback to extract from the first input + pkScript, err := txscript.ParsePkScript(prevTx.TxOut[tx.TxIn[0].PreviousOutPoint.Index].PkScript) + if err != nil { + return nil, err + } + + return pkScript.Address(chainCfg) +} diff --git a/x/btcbridge/types/errors.go b/x/btcbridge/types/errors.go index cd190513..833e221b 100644 --- a/x/btcbridge/types/errors.go +++ b/x/btcbridge/types/errors.go @@ -15,13 +15,14 @@ var ( ErrInvalidSenders = errorsmod.Register(ModuleName, 2100, "invalid allowed senders") - ErrInvalidBtcTransaction = errorsmod.Register(ModuleName, 3100, "invalid bitcoin transaction") - ErrBlockNotFound = errorsmod.Register(ModuleName, 3101, "block not found") - ErrTransactionNotIncluded = errorsmod.Register(ModuleName, 3102, "transaction not included in block") - ErrNotConfirmed = errorsmod.Register(ModuleName, 3200, "transaction not confirmed") - ErrExceedMaxAcceptanceDepth = errorsmod.Register(ModuleName, 3201, "exceed max acceptance block depth") - ErrUnsupportedScriptType = errorsmod.Register(ModuleName, 3202, "unsupported script type") - ErrTransactionAlreadyMinted = errorsmod.Register(ModuleName, 3203, "transaction already minted") + ErrInvalidBtcTransaction = errorsmod.Register(ModuleName, 3100, "invalid bitcoin transaction") + ErrBlockNotFound = errorsmod.Register(ModuleName, 3101, "block not found") + ErrTransactionNotIncluded = errorsmod.Register(ModuleName, 3102, "transaction not included in block") + ErrNotConfirmed = errorsmod.Register(ModuleName, 3200, "transaction not confirmed") + ErrExceedMaxAcceptanceDepth = errorsmod.Register(ModuleName, 3201, "exceed max acceptance block depth") + ErrUnsupportedScriptType = errorsmod.Register(ModuleName, 3202, "unsupported script type") + ErrTransactionAlreadyMinted = errorsmod.Register(ModuleName, 3203, "transaction already minted") + ErrInvalidDepositTransaction = errorsmod.Register(ModuleName, 3204, "invalid deposit transaction") ErrInvalidSignatures = errorsmod.Register(ModuleName, 4200, "invalid signatures") ErrInsufficientBalance = errorsmod.Register(ModuleName, 4201, "insufficient balance") From 7de13d913e037912b23f02f099917f0599594c67 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Thu, 20 Jun 2024 09:42:11 +0800 Subject: [PATCH 60/71] used the third key as relayer --- local_node_dev.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/local_node_dev.sh b/local_node_dev.sh index 8aa86113..60933ad5 100755 --- a/local_node_dev.sh +++ b/local_node_dev.sh @@ -89,10 +89,10 @@ if [[ $overwrite == "y" || $overwrite == "Y" ]]; then # Set gas limit in genesis jq --arg max_gas "$MAX_GAS" '.consensus_params["block"]["max_gas"]=$max_gas' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" # setup relayers - RELAYER=$($BINARY keys show "${KEYS[1]}" -a --keyring-backend $KEYRING --home "$HOMEDIR") + RELAYER=$($BINARY keys show "${KEYS[2]}" -a --keyring-backend $KEYRING --home "$HOMEDIR") jq --arg relayer "$RELAYER" '.app_state["btcbridge"]["params"]["authorized_relayers"][0]=$relayer' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" jq --arg relayer "$RELAYER" '.app_state["btcbridge"]["params"]["vaults"][0]["address"]=$relayer' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" - PUKEY=$($BINARY keys show "${KEYS[1]}" --pubkeyhex --keyring-backend $KEYRING --home "$HOMEDIR") + PUKEY=$($BINARY keys show "${KEYS[2]}" --pubkeyhex --keyring-backend $KEYRING --home "$HOMEDIR") jq --arg pubkey "$PUKEY" '.app_state["btcbridge"]["params"]["vaults"][0]["pub_key"]=$pubkey' "$GENESIS" >"$TMP_GENESIS" && mv "$TMP_GENESIS" "$GENESIS" # set custom pruning settings From 626399e9af525ba84b5a8f26ba410898ce8cd047 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Thu, 20 Jun 2024 09:42:49 +0800 Subject: [PATCH 61/71] update status of withdraw: broadcasted --- proto/side/btcbridge/tx.proto | 13 + x/btcbridge/types/errors.go | 1 + .../types/message_submit_withdraw_status.go | 58 ++ x/btcbridge/types/tx.pb.go | 525 ++++++++++++++++-- 4 files changed, 544 insertions(+), 53 deletions(-) create mode 100644 x/btcbridge/types/message_submit_withdraw_status.go diff --git a/proto/side/btcbridge/tx.proto b/proto/side/btcbridge/tx.proto index 7837db92..764cfe10 100644 --- a/proto/side/btcbridge/tx.proto +++ b/proto/side/btcbridge/tx.proto @@ -22,9 +22,22 @@ service Msg { rpc WithdrawBitcoin (MsgWithdrawBitcoinRequest) returns (MsgWithdrawBitcoinResponse); // SubmitWithdrawSignatures submits the signatures of the withdraw transaction. rpc SubmitWithdrawSignatures (MsgSubmitWithdrawSignaturesRequest) returns (MsgSubmitWithdrawSignaturesResponse); + // SubmitWithdrawStatus submits the status of the withdraw transaction. + rpc SubmitWithdrawStatus (MsgSubmitWithdrawStatusRequest) returns (MsgSubmitWithdrawStatusResponse); } +// MsgSubmitWithdrawStatusRequest defines the Msg/SubmitWithdrawStatus request type. +message MsgSubmitWithdrawStatusRequest { + string sender = 1; + string txid = 2; + SigningStatus status = 3; +} + +// MsgSubmitWithdrawStatusResponse defines the Msg/SubmitWithdrawStatus response type. +message MsgSubmitWithdrawStatusResponse { +} + // MsgBlockHeaderRequest defines the Msg/SubmitBlockHeaders request type. message MsgSubmitBlockHeaderRequest { string sender = 1; diff --git a/x/btcbridge/types/errors.go b/x/btcbridge/types/errors.go index cd190513..59372478 100644 --- a/x/btcbridge/types/errors.go +++ b/x/btcbridge/types/errors.go @@ -26,6 +26,7 @@ var ( ErrInvalidSignatures = errorsmod.Register(ModuleName, 4200, "invalid signatures") ErrInsufficientBalance = errorsmod.Register(ModuleName, 4201, "insufficient balance") ErrSigningRequestNotExist = errorsmod.Register(ModuleName, 4202, "signing request does not exist") + ErrInvalidStatus = errorsmod.Register(ModuleName, 4203, "invalid status") ErrUTXODoesNotExist = errorsmod.Register(ModuleName, 5100, "utxo does not exist") ErrUTXOLocked = errorsmod.Register(ModuleName, 5101, "utxo locked") diff --git a/x/btcbridge/types/message_submit_withdraw_status.go b/x/btcbridge/types/message_submit_withdraw_status.go new file mode 100644 index 00000000..7d142339 --- /dev/null +++ b/x/btcbridge/types/message_submit_withdraw_status.go @@ -0,0 +1,58 @@ +package types + +import ( + sdkerrors "cosmossdk.io/errors" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const TypeMsgSubmitWithdrawStatus = "submit_withdraw_status" + +func NewMsgSubmitWithdrawStatusRequest( + sender string, + txid string, + status SigningStatus, +) *MsgSubmitWithdrawStatusRequest { + return &MsgSubmitWithdrawStatusRequest{ + Sender: sender, + Txid: txid, + Status: status, + } +} + +func (msg *MsgSubmitWithdrawStatusRequest) Route() string { + return RouterKey +} + +func (msg *MsgSubmitWithdrawStatusRequest) Type() string { + return TypeMsgSubmitWithdrawStatus +} + +func (msg *MsgSubmitWithdrawStatusRequest) GetSigners() []sdk.AccAddress { + Sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{Sender} +} + +func (msg *MsgSubmitWithdrawStatusRequest) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgSubmitWithdrawStatusRequest) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return sdkerrors.Wrapf(err, "invalid Sender address (%s)", err) + } + + if len(msg.Txid) == 0 { + return sdkerrors.Wrap(ErrSigningRequestNotExist, "txid cannot be empty") + } + + if msg.Status != SigningStatus_SIGNING_STATUS_BROADCASTED { + return sdkerrors.Wrap(ErrInvalidStatus, "invalid status") + } + + return nil +} diff --git a/x/btcbridge/types/tx.pb.go b/x/btcbridge/types/tx.pb.go index 7e2040e7..bd83d70e 100644 --- a/x/btcbridge/types/tx.pb.go +++ b/x/btcbridge/types/tx.pb.go @@ -28,6 +28,104 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +// MsgSubmitWithdrawStatusRequest defines the Msg/SubmitWithdrawStatus request type. +type MsgSubmitWithdrawStatusRequest struct { + Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` + Txid string `protobuf:"bytes,2,opt,name=txid,proto3" json:"txid,omitempty"` + Status SigningStatus `protobuf:"varint,3,opt,name=status,proto3,enum=side.btcbridge.SigningStatus" json:"status,omitempty"` +} + +func (m *MsgSubmitWithdrawStatusRequest) Reset() { *m = MsgSubmitWithdrawStatusRequest{} } +func (m *MsgSubmitWithdrawStatusRequest) String() string { return proto.CompactTextString(m) } +func (*MsgSubmitWithdrawStatusRequest) ProtoMessage() {} +func (*MsgSubmitWithdrawStatusRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_785ca8e1e4227068, []int{0} +} +func (m *MsgSubmitWithdrawStatusRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSubmitWithdrawStatusRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSubmitWithdrawStatusRequest.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 *MsgSubmitWithdrawStatusRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSubmitWithdrawStatusRequest.Merge(m, src) +} +func (m *MsgSubmitWithdrawStatusRequest) XXX_Size() int { + return m.Size() +} +func (m *MsgSubmitWithdrawStatusRequest) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSubmitWithdrawStatusRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSubmitWithdrawStatusRequest proto.InternalMessageInfo + +func (m *MsgSubmitWithdrawStatusRequest) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgSubmitWithdrawStatusRequest) GetTxid() string { + if m != nil { + return m.Txid + } + return "" +} + +func (m *MsgSubmitWithdrawStatusRequest) GetStatus() SigningStatus { + if m != nil { + return m.Status + } + return SigningStatus_SIGNING_STATUS_UNSPECIFIED +} + +// MsgSubmitWithdrawStatusResponse defines the Msg/SubmitWithdrawStatus response type. +type MsgSubmitWithdrawStatusResponse struct { +} + +func (m *MsgSubmitWithdrawStatusResponse) Reset() { *m = MsgSubmitWithdrawStatusResponse{} } +func (m *MsgSubmitWithdrawStatusResponse) String() string { return proto.CompactTextString(m) } +func (*MsgSubmitWithdrawStatusResponse) ProtoMessage() {} +func (*MsgSubmitWithdrawStatusResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_785ca8e1e4227068, []int{1} +} +func (m *MsgSubmitWithdrawStatusResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgSubmitWithdrawStatusResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgSubmitWithdrawStatusResponse.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 *MsgSubmitWithdrawStatusResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgSubmitWithdrawStatusResponse.Merge(m, src) +} +func (m *MsgSubmitWithdrawStatusResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgSubmitWithdrawStatusResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgSubmitWithdrawStatusResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgSubmitWithdrawStatusResponse proto.InternalMessageInfo + // MsgBlockHeaderRequest defines the Msg/SubmitBlockHeaders request type. type MsgSubmitBlockHeaderRequest struct { Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` @@ -38,7 +136,7 @@ func (m *MsgSubmitBlockHeaderRequest) Reset() { *m = MsgSubmitBlockHeade func (m *MsgSubmitBlockHeaderRequest) String() string { return proto.CompactTextString(m) } func (*MsgSubmitBlockHeaderRequest) ProtoMessage() {} func (*MsgSubmitBlockHeaderRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_785ca8e1e4227068, []int{0} + return fileDescriptor_785ca8e1e4227068, []int{2} } func (m *MsgSubmitBlockHeaderRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -89,7 +187,7 @@ func (m *MsgSubmitBlockHeadersResponse) Reset() { *m = MsgSubmitBlockHea func (m *MsgSubmitBlockHeadersResponse) String() string { return proto.CompactTextString(m) } func (*MsgSubmitBlockHeadersResponse) ProtoMessage() {} func (*MsgSubmitBlockHeadersResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_785ca8e1e4227068, []int{1} + return fileDescriptor_785ca8e1e4227068, []int{3} } func (m *MsgSubmitBlockHeadersResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -135,7 +233,7 @@ func (m *MsgSubmitDepositTransactionRequest) Reset() { *m = MsgSubmitDep func (m *MsgSubmitDepositTransactionRequest) String() string { return proto.CompactTextString(m) } func (*MsgSubmitDepositTransactionRequest) ProtoMessage() {} func (*MsgSubmitDepositTransactionRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_785ca8e1e4227068, []int{2} + return fileDescriptor_785ca8e1e4227068, []int{4} } func (m *MsgSubmitDepositTransactionRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -207,7 +305,7 @@ func (m *MsgSubmitDepositTransactionResponse) Reset() { *m = MsgSubmitDe func (m *MsgSubmitDepositTransactionResponse) String() string { return proto.CompactTextString(m) } func (*MsgSubmitDepositTransactionResponse) ProtoMessage() {} func (*MsgSubmitDepositTransactionResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_785ca8e1e4227068, []int{3} + return fileDescriptor_785ca8e1e4227068, []int{5} } func (m *MsgSubmitDepositTransactionResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -250,7 +348,7 @@ func (m *MsgSubmitWithdrawTransactionRequest) Reset() { *m = MsgSubmitWi func (m *MsgSubmitWithdrawTransactionRequest) String() string { return proto.CompactTextString(m) } func (*MsgSubmitWithdrawTransactionRequest) ProtoMessage() {} func (*MsgSubmitWithdrawTransactionRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_785ca8e1e4227068, []int{4} + return fileDescriptor_785ca8e1e4227068, []int{6} } func (m *MsgSubmitWithdrawTransactionRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -315,7 +413,7 @@ func (m *MsgSubmitWithdrawTransactionResponse) Reset() { *m = MsgSubmitW func (m *MsgSubmitWithdrawTransactionResponse) String() string { return proto.CompactTextString(m) } func (*MsgSubmitWithdrawTransactionResponse) ProtoMessage() {} func (*MsgSubmitWithdrawTransactionResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_785ca8e1e4227068, []int{5} + return fileDescriptor_785ca8e1e4227068, []int{7} } func (m *MsgSubmitWithdrawTransactionResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -355,7 +453,7 @@ func (m *MsgUpdateQualifiedRelayersRequest) Reset() { *m = MsgUpdateQual func (m *MsgUpdateQualifiedRelayersRequest) String() string { return proto.CompactTextString(m) } func (*MsgUpdateQualifiedRelayersRequest) ProtoMessage() {} func (*MsgUpdateQualifiedRelayersRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_785ca8e1e4227068, []int{6} + return fileDescriptor_785ca8e1e4227068, []int{8} } func (m *MsgUpdateQualifiedRelayersRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -406,7 +504,7 @@ func (m *MsgUpdateQualifiedRelayersResponse) Reset() { *m = MsgUpdateQua func (m *MsgUpdateQualifiedRelayersResponse) String() string { return proto.CompactTextString(m) } func (*MsgUpdateQualifiedRelayersResponse) ProtoMessage() {} func (*MsgUpdateQualifiedRelayersResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_785ca8e1e4227068, []int{7} + return fileDescriptor_785ca8e1e4227068, []int{9} } func (m *MsgUpdateQualifiedRelayersResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -448,7 +546,7 @@ func (m *MsgWithdrawBitcoinRequest) Reset() { *m = MsgWithdrawBitcoinReq func (m *MsgWithdrawBitcoinRequest) String() string { return proto.CompactTextString(m) } func (*MsgWithdrawBitcoinRequest) ProtoMessage() {} func (*MsgWithdrawBitcoinRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_785ca8e1e4227068, []int{8} + return fileDescriptor_785ca8e1e4227068, []int{10} } func (m *MsgWithdrawBitcoinRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -506,7 +604,7 @@ func (m *MsgWithdrawBitcoinResponse) Reset() { *m = MsgWithdrawBitcoinRe func (m *MsgWithdrawBitcoinResponse) String() string { return proto.CompactTextString(m) } func (*MsgWithdrawBitcoinResponse) ProtoMessage() {} func (*MsgWithdrawBitcoinResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_785ca8e1e4227068, []int{9} + return fileDescriptor_785ca8e1e4227068, []int{11} } func (m *MsgWithdrawBitcoinResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -546,7 +644,7 @@ func (m *MsgSubmitWithdrawSignaturesRequest) Reset() { *m = MsgSubmitWit func (m *MsgSubmitWithdrawSignaturesRequest) String() string { return proto.CompactTextString(m) } func (*MsgSubmitWithdrawSignaturesRequest) ProtoMessage() {} func (*MsgSubmitWithdrawSignaturesRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_785ca8e1e4227068, []int{10} + return fileDescriptor_785ca8e1e4227068, []int{12} } func (m *MsgSubmitWithdrawSignaturesRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -604,7 +702,7 @@ func (m *MsgSubmitWithdrawSignaturesResponse) Reset() { *m = MsgSubmitWi func (m *MsgSubmitWithdrawSignaturesResponse) String() string { return proto.CompactTextString(m) } func (*MsgSubmitWithdrawSignaturesResponse) ProtoMessage() {} func (*MsgSubmitWithdrawSignaturesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_785ca8e1e4227068, []int{11} + return fileDescriptor_785ca8e1e4227068, []int{13} } func (m *MsgSubmitWithdrawSignaturesResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -634,6 +732,8 @@ func (m *MsgSubmitWithdrawSignaturesResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSubmitWithdrawSignaturesResponse proto.InternalMessageInfo func init() { + proto.RegisterType((*MsgSubmitWithdrawStatusRequest)(nil), "side.btcbridge.MsgSubmitWithdrawStatusRequest") + proto.RegisterType((*MsgSubmitWithdrawStatusResponse)(nil), "side.btcbridge.MsgSubmitWithdrawStatusResponse") proto.RegisterType((*MsgSubmitBlockHeaderRequest)(nil), "side.btcbridge.MsgSubmitBlockHeaderRequest") proto.RegisterType((*MsgSubmitBlockHeadersResponse)(nil), "side.btcbridge.MsgSubmitBlockHeadersResponse") proto.RegisterType((*MsgSubmitDepositTransactionRequest)(nil), "side.btcbridge.MsgSubmitDepositTransactionRequest") @@ -651,47 +751,51 @@ func init() { func init() { proto.RegisterFile("side/btcbridge/tx.proto", fileDescriptor_785ca8e1e4227068) } var fileDescriptor_785ca8e1e4227068 = []byte{ - // 631 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xcf, 0x6e, 0xd3, 0x4e, - 0x10, 0xae, 0x9b, 0xfe, 0xcb, 0xf4, 0xd7, 0x1f, 0xd2,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0x54, 0xad, 0xdf, 0x17, 0x55, 0xeb, 0xfb, - 0x65, 0x75, 0xee, 0xfc, 0xb2, 0x3a, 0xf7, 0xeb, 0xb2, 0x3a, 0xf7, 0xbe, 0x16, 0x30, 0xd5, 0x8b, - 0xbd, 0x5a, 0x87, 0x0f, 0xea, 0x49, 0x61, 0xfd, 0x9f, 0xeb, 0xf0, 0xbe, 0x0e, 0xea, 0xc3, 0xf1, - 0xbf, 0xec, 0x59, 0x84, 0xd2, 0x5b, 0xd2, 0x84, 0x83, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xa6, - 0xc1, 0xfb, 0x2a, 0x84, 0x07, 0x00, 0x00, + // 692 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0xcd, 0x4e, 0xdb, 0x40, + 0x10, 0xc6, 0x04, 0x02, 0x19, 0x0a, 0x95, 0x56, 0x08, 0x82, 0x01, 0x13, 0x5c, 0x5a, 0xa5, 0xad, + 0xea, 0xa8, 0xa1, 0xbd, 0x57, 0x51, 0x0f, 0x5c, 0x72, 0xa8, 0xa1, 0x42, 0xea, 0x25, 0x5a, 0xc7, + 0x1b, 0x67, 0xd5, 0xc4, 0xeb, 0x7a, 0xd7, 0x25, 0xdc, 0x2a, 0x21, 0xf5, 0xd4, 0x43, 0xdf, 0xa4, + 0xaf, 0xd1, 0x23, 0xc7, 0x1e, 0x2b, 0x78, 0x83, 0x3e, 0x41, 0xe5, 0xf5, 0x62, 0x42, 0xb0, 0xf3, + 0x53, 0xf5, 0xb6, 0xb3, 0xf3, 0xcd, 0xcc, 0xb7, 0x33, 0xf3, 0xc9, 0x86, 0x4d, 0x4e, 0x5d, 0x52, + 0x73, 0x44, 0xdb, 0x09, 0xa9, 0xeb, 0x91, 0x9a, 0x18, 0x58, 0x41, 0xc8, 0x04, 0x43, 0x6b, 0xb1, + 0xc3, 0x4a, 0x1d, 0xfa, 0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x7a, 0xd2, 0xa8, 0x0d, 0x86, 0xff, 0x43, 0xce, + 0x03, 0xc2, 0x9d, 0xa2, 0x04, 0x1c, 0xfe, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xa5, 0x14, 0x51, 0xb1, + 0xa6, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -718,6 +822,8 @@ type MsgClient interface { WithdrawBitcoin(ctx context.Context, in *MsgWithdrawBitcoinRequest, opts ...grpc.CallOption) (*MsgWithdrawBitcoinResponse, error) // SubmitWithdrawSignatures submits the signatures of the withdraw transaction. SubmitWithdrawSignatures(ctx context.Context, in *MsgSubmitWithdrawSignaturesRequest, opts ...grpc.CallOption) (*MsgSubmitWithdrawSignaturesResponse, error) + // SubmitWithdrawStatus submits the status of the withdraw transaction. + SubmitWithdrawStatus(ctx context.Context, in *MsgSubmitWithdrawStatusRequest, opts ...grpc.CallOption) (*MsgSubmitWithdrawStatusResponse, error) } type msgClient struct { @@ -782,6 +888,15 @@ func (c *msgClient) SubmitWithdrawSignatures(ctx context.Context, in *MsgSubmitW return out, nil } +func (c *msgClient) SubmitWithdrawStatus(ctx context.Context, in *MsgSubmitWithdrawStatusRequest, opts ...grpc.CallOption) (*MsgSubmitWithdrawStatusResponse, error) { + out := new(MsgSubmitWithdrawStatusResponse) + err := c.cc.Invoke(ctx, "/side.btcbridge.Msg/SubmitWithdrawStatus", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { // SubmitBlockHeaders submits bitcoin block headers to the side chain. @@ -796,6 +911,8 @@ type MsgServer interface { WithdrawBitcoin(context.Context, *MsgWithdrawBitcoinRequest) (*MsgWithdrawBitcoinResponse, error) // SubmitWithdrawSignatures submits the signatures of the withdraw transaction. SubmitWithdrawSignatures(context.Context, *MsgSubmitWithdrawSignaturesRequest) (*MsgSubmitWithdrawSignaturesResponse, error) + // SubmitWithdrawStatus submits the status of the withdraw transaction. + SubmitWithdrawStatus(context.Context, *MsgSubmitWithdrawStatusRequest) (*MsgSubmitWithdrawStatusResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -820,6 +937,9 @@ func (*UnimplementedMsgServer) WithdrawBitcoin(ctx context.Context, req *MsgWith func (*UnimplementedMsgServer) SubmitWithdrawSignatures(ctx context.Context, req *MsgSubmitWithdrawSignaturesRequest) (*MsgSubmitWithdrawSignaturesResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SubmitWithdrawSignatures not implemented") } +func (*UnimplementedMsgServer) SubmitWithdrawStatus(ctx context.Context, req *MsgSubmitWithdrawStatusRequest) (*MsgSubmitWithdrawStatusResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method SubmitWithdrawStatus not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -933,6 +1053,24 @@ func _Msg_SubmitWithdrawSignatures_Handler(srv interface{}, ctx context.Context, return interceptor(ctx, in, info, handler) } +func _Msg_SubmitWithdrawStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgSubmitWithdrawStatusRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).SubmitWithdrawStatus(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/side.btcbridge.Msg/SubmitWithdrawStatus", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).SubmitWithdrawStatus(ctx, req.(*MsgSubmitWithdrawStatusRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "side.btcbridge.Msg", HandlerType: (*MsgServer)(nil), @@ -961,11 +1099,80 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "SubmitWithdrawSignatures", Handler: _Msg_SubmitWithdrawSignatures_Handler, }, + { + MethodName: "SubmitWithdrawStatus", + Handler: _Msg_SubmitWithdrawStatus_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "side/btcbridge/tx.proto", } +func (m *MsgSubmitWithdrawStatusRequest) 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 *MsgSubmitWithdrawStatusRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSubmitWithdrawStatusRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Status != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Status)) + i-- + dAtA[i] = 0x18 + } + if len(m.Txid) > 0 { + i -= len(m.Txid) + copy(dAtA[i:], m.Txid) + i = encodeVarintTx(dAtA, i, uint64(len(m.Txid))) + i-- + dAtA[i] = 0x12 + } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgSubmitWithdrawStatusResponse) 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 *MsgSubmitWithdrawStatusResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSubmitWithdrawStatusResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func (m *MsgSubmitBlockHeaderRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1397,6 +1604,35 @@ func encodeVarintTx(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *MsgSubmitWithdrawStatusRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Txid) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Status != 0 { + n += 1 + sovTx(uint64(m.Status)) + } + return n +} + +func (m *MsgSubmitWithdrawStatusResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func (m *MsgSubmitBlockHeaderRequest) Size() (n int) { if m == nil { return 0 @@ -1594,6 +1830,189 @@ func sovTx(x uint64) (n int) { func sozTx(x uint64) (n int) { return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *MsgSubmitWithdrawStatusRequest) 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: MsgSubmitWithdrawStatusRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSubmitWithdrawStatusRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", 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.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Txid", 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.Txid = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Status", wireType) + } + m.Status = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Status |= SigningStatus(b&0x7F) << shift + if b < 0x80 { + break + } + } + 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 *MsgSubmitWithdrawStatusResponse) 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: MsgSubmitWithdrawStatusResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgSubmitWithdrawStatusResponse: 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 (m *MsgSubmitBlockHeaderRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 From 063df80071c0cd44bb49a05e381e881088bb8cd8 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Thu, 20 Jun 2024 09:59:08 +0800 Subject: [PATCH 62/71] update status --- x/btcbridge/keeper/msg_server.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/x/btcbridge/keeper/msg_server.go b/x/btcbridge/keeper/msg_server.go index 7867fada..7e2c10bf 100644 --- a/x/btcbridge/keeper/msg_server.go +++ b/x/btcbridge/keeper/msg_server.go @@ -187,6 +187,23 @@ func (m msgServer) SubmitWithdrawSignatures(goCtx context.Context, msg *types.Ms } +func (m msgServer) SubmitWithdrawStatus(goCtx context.Context, msg *types.MsgSubmitWithdrawStatusRequest) (*types.MsgSubmitWithdrawStatusResponse, error) { + if err := msg.ValidateBasic(); err != nil { + return nil, err + } + ctx := sdk.UnwrapSDKContext(goCtx) + exist := m.HasSigningRequest(ctx, msg.Txid) + if !exist { + return nil, types.ErrSigningRequestNotExist + } + + request := m.GetSigningRequest(ctx, msg.Txid) + request.Status = msg.Status + m.SetSigningRequest(ctx, request) + + return &types.MsgSubmitWithdrawStatusResponse{}, nil +} + // NewMsgServerImpl returns an implementation of the MsgServer interface // for the provided Keeper. func NewMsgServerImpl(keeper Keeper) types.MsgServer { From 423982355ade3dd8d80a6eb9d5bb38afafd75e83 Mon Sep 17 00:00:00 2001 From: sufay Date: Thu, 20 Jun 2024 09:38:53 +0800 Subject: [PATCH 63/71] mark change out minted --- x/btcbridge/keeper/keeper_withdraw.go | 7 +++++-- x/btcbridge/keeper/utxo.go | 4 ---- x/btcbridge/types/bitcoin_transaction.go | 19 +++++++++++++++++++ x/btcbridge/types/errors.go | 10 +++++----- x/btcbridge/types/message_withdraw_bitcoin.go | 10 ++++++++-- 5 files changed, 37 insertions(+), 13 deletions(-) diff --git a/x/btcbridge/keeper/keeper_withdraw.go b/x/btcbridge/keeper/keeper_withdraw.go index 7f46a946..009267da 100644 --- a/x/btcbridge/keeper/keeper_withdraw.go +++ b/x/btcbridge/keeper/keeper_withdraw.go @@ -9,7 +9,9 @@ import ( "github.com/btcsuite/btcd/blockchain" "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/wire" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/sideprotocol/side/x/btcbridge/types" ) @@ -56,7 +58,7 @@ func (k Keeper) NewSigningRequest(ctx sdk.Context, sender string, coin sdk.Coin, psbt, selectedUTXOs, changeUTXO, err := types.BuildPsbt(utxos, sender, coin.Amount.Int64(), feeRate, vault) if err != nil { - return nil, types.ErrFailToBuildTransaction + return nil, err } psbtB64, err := psbt.B64Encode() @@ -67,8 +69,9 @@ func (k Keeper) NewSigningRequest(ctx sdk.Context, sender string, coin sdk.Coin, // lock the selected utxos k.LockUTXOs(ctx, selectedUTXOs) - // save the change utxo + // save the change utxo and mark minted k.saveUTXO(ctx, changeUTXO) + k.addToMintHistory(ctx, psbt.UnsignedTx.TxHash().String()) signingRequest := &types.BitcoinSigningRequest{ Address: sender, diff --git a/x/btcbridge/keeper/utxo.go b/x/btcbridge/keeper/utxo.go index a0eb6dad..9ea0c545 100644 --- a/x/btcbridge/keeper/utxo.go +++ b/x/btcbridge/keeper/utxo.go @@ -274,10 +274,6 @@ func (bk *BaseUTXOKeeper) SpendUTXOs(ctx sdk.Context, utxos []*types.UTXO) error // saveUTXO saves the given utxo func (bk *BaseUTXOKeeper) saveUTXO(ctx sdk.Context, utxo *types.UTXO) { - if bk.HasUTXO(ctx, utxo.Txid, utxo.Vout) { - return - } - bk.SetUTXO(ctx, utxo) bk.SetOwnerUTXO(ctx, utxo) } diff --git a/x/btcbridge/types/bitcoin_transaction.go b/x/btcbridge/types/bitcoin_transaction.go index 16d52af7..5d403862 100644 --- a/x/btcbridge/types/bitcoin_transaction.go +++ b/x/btcbridge/types/bitcoin_transaction.go @@ -182,3 +182,22 @@ func GetTxVirtualSize(tx *wire.MsgTx, utxos []*UTXO) int64 { return mempool.GetTxVirtualSize(btcutil.NewTx(newTx)) } + +// CheckOutput checks the given output +func CheckOutput(address string, amount int64) error { + addr, err := btcutil.DecodeAddress(address, sdk.GetConfig().GetBtcChainCfg()) + if err != nil { + return err + } + + pkScript, err := txscript.PayToAddrScript(addr) + if err != nil { + return err + } + + if mempool.IsDust(&wire.TxOut{Value: amount, PkScript: pkScript}, MinRelayFee) { + return ErrDustOutput + } + + return nil +} diff --git a/x/btcbridge/types/errors.go b/x/btcbridge/types/errors.go index 833e221b..80a67f96 100644 --- a/x/btcbridge/types/errors.go +++ b/x/btcbridge/types/errors.go @@ -32,9 +32,9 @@ var ( ErrUTXOLocked = errorsmod.Register(ModuleName, 5101, "utxo locked") ErrUTXOUnlocked = errorsmod.Register(ModuleName, 5102, "utxo unlocked") - ErrInvalidFeeRate = errorsmod.Register(ModuleName, 6100, "invalid fee rate") - ErrDustOutput = errorsmod.Register(ModuleName, 6101, "dust output value") - ErrInsufficientUTXOs = errorsmod.Register(ModuleName, 6102, "insufficient utxos") - ErrFailToBuildTransaction = errorsmod.Register(ModuleName, 6103, "failed to build transaction") - ErrFailToSerializePsbt = errorsmod.Register(ModuleName, 6104, "failed to serialize psbt") + ErrInvalidAmount = errorsmod.Register(ModuleName, 6100, "invalid amount") + ErrInvalidFeeRate = errorsmod.Register(ModuleName, 6101, "invalid fee rate") + ErrDustOutput = errorsmod.Register(ModuleName, 6102, "dust output value") + ErrInsufficientUTXOs = errorsmod.Register(ModuleName, 6103, "insufficient utxos") + ErrFailToSerializePsbt = errorsmod.Register(ModuleName, 6104, "failed to serialize psbt") ) diff --git a/x/btcbridge/types/message_withdraw_bitcoin.go b/x/btcbridge/types/message_withdraw_bitcoin.go index 49a01611..287a412a 100644 --- a/x/btcbridge/types/message_withdraw_bitcoin.go +++ b/x/btcbridge/types/message_withdraw_bitcoin.go @@ -46,8 +46,14 @@ func (msg *MsgWithdrawBitcoinRequest) ValidateBasic() error { return sdkerrors.Wrapf(err, "invalid Sender address (%s)", err) } - if len(msg.Amount) == 0 { - return sdkerrors.Wrap(sdk.ErrInvalidLengthCoin, "amount cannot be empty") + coin, err := sdk.ParseCoinNormalized(msg.Amount) + if err != nil { + return sdkerrors.Wrapf(ErrInvalidAmount, "invalid amount %s", msg.Amount) + } + + err = CheckOutput(msg.Sender, coin.Amount.Int64()) + if err != nil { + return err } if msg.FeeRate <= 0 { From 29d13c58f0535c2eb7b7edecd07f87235553e3bf Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Thu, 20 Jun 2024 11:24:20 +0800 Subject: [PATCH 64/71] update confirmed status of withdrawal --- x/btcbridge/keeper/keeper_withdraw.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/x/btcbridge/keeper/keeper_withdraw.go b/x/btcbridge/keeper/keeper_withdraw.go index 009267da..21488338 100644 --- a/x/btcbridge/keeper/keeper_withdraw.go +++ b/x/btcbridge/keeper/keeper_withdraw.go @@ -144,7 +144,7 @@ func (k Keeper) FilterSigningRequestsByStatus(ctx sdk.Context, req *types.QueryS // Process Bitcoin Withdraw Transaction func (k Keeper) ProcessBitcoinWithdrawTransaction(ctx sdk.Context, msg *types.MsgSubmitWithdrawTransactionRequest) error { - ctx.Logger().Info("accept bitcoin deposit tx", "blockhash", msg.Blockhash) + ctx.Logger().Info("accept bitcoin withdraw tx", "blockhash", msg.Blockhash) param := k.GetParams(ctx) header := k.GetBlockHeader(ctx, msg.Blockhash) @@ -182,6 +182,17 @@ func (k Keeper) ProcessBitcoinWithdrawTransaction(ctx sdk.Context, msg *types.Ms return types.ErrInvalidBtcTransaction } + if !k.HasSigningRequest(ctx, uTx.MsgTx().TxHash().String()) { + return types.ErrSigningRequestNotExist + } + + signingRequest := k.GetSigningRequest(ctx, uTx.MsgTx().TxHash().String()) + if signingRequest.Status != types.SigningStatus_SIGNING_STATUS_SIGNED { + return types.ErrInvalidStatus + } + signingRequest.Status = types.SigningStatus_SIGNING_STATUS_CONFIRMED + k.SetSigningRequest(ctx, signingRequest) + // Validate the transaction if err := blockchain.CheckTransactionSanity(uTx); err != nil { fmt.Println("Transaction is not valid:", err) From d01be7231a29ce0a111cff6fa5d8be8e0fb27dfb Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Thu, 20 Jun 2024 11:29:01 +0800 Subject: [PATCH 65/71] remove status check for now --- x/btcbridge/keeper/keeper_withdraw.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x/btcbridge/keeper/keeper_withdraw.go b/x/btcbridge/keeper/keeper_withdraw.go index 21488338..7d201b22 100644 --- a/x/btcbridge/keeper/keeper_withdraw.go +++ b/x/btcbridge/keeper/keeper_withdraw.go @@ -187,9 +187,9 @@ func (k Keeper) ProcessBitcoinWithdrawTransaction(ctx sdk.Context, msg *types.Ms } signingRequest := k.GetSigningRequest(ctx, uTx.MsgTx().TxHash().String()) - if signingRequest.Status != types.SigningStatus_SIGNING_STATUS_SIGNED { - return types.ErrInvalidStatus - } + // if signingRequest.Status != types.SigningStatus_SIGNING_STATUS_BROADCASTED || signingRequest.Status != types.SigningStatus_SIGNING_STATUS_SIGNED { + // return types.ErrInvalidStatus + // } signingRequest.Status = types.SigningStatus_SIGNING_STATUS_CONFIRMED k.SetSigningRequest(ctx, signingRequest) From ea522810a79ad27f1bd7118517258de51871ac13 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Thu, 20 Jun 2024 11:35:42 +0800 Subject: [PATCH 66/71] added permission check --- x/btcbridge/keeper/keeper_deposit.go | 5 +++++ x/btcbridge/keeper/keeper_withdraw.go | 5 +++++ x/btcbridge/keeper/msg_server.go | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/x/btcbridge/keeper/keeper_deposit.go b/x/btcbridge/keeper/keeper_deposit.go index 7935c5ad..97083376 100644 --- a/x/btcbridge/keeper/keeper_deposit.go +++ b/x/btcbridge/keeper/keeper_deposit.go @@ -20,6 +20,11 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg ctx.Logger().Info("accept bitcoin deposit tx", "blockhash", msg.Blockhash) param := k.GetParams(ctx) + + if !param.IsAuthorizedSender(msg.Sender) { + return types.ErrSenderAddressNotAuthorized + } + header := k.GetBlockHeader(ctx, msg.Blockhash) // Check if block confirmed if header == nil || header.Height == 0 { diff --git a/x/btcbridge/keeper/keeper_withdraw.go b/x/btcbridge/keeper/keeper_withdraw.go index 7d201b22..40176dbf 100644 --- a/x/btcbridge/keeper/keeper_withdraw.go +++ b/x/btcbridge/keeper/keeper_withdraw.go @@ -147,6 +147,11 @@ func (k Keeper) ProcessBitcoinWithdrawTransaction(ctx sdk.Context, msg *types.Ms ctx.Logger().Info("accept bitcoin withdraw tx", "blockhash", msg.Blockhash) param := k.GetParams(ctx) + + if !param.IsAuthorizedSender(msg.Sender) { + return types.ErrSenderAddressNotAuthorized + } + header := k.GetBlockHeader(ctx, msg.Blockhash) // Check if block confirmed if header == nil { diff --git a/x/btcbridge/keeper/msg_server.go b/x/btcbridge/keeper/msg_server.go index 7e2c10bf..b4c2b80b 100644 --- a/x/btcbridge/keeper/msg_server.go +++ b/x/btcbridge/keeper/msg_server.go @@ -191,6 +191,10 @@ func (m msgServer) SubmitWithdrawStatus(goCtx context.Context, msg *types.MsgSub if err := msg.ValidateBasic(); err != nil { return nil, err } + param := m.GetParams(sdk.UnwrapSDKContext(goCtx)) + if !param.IsAuthorizedSender(msg.Sender) { + return nil, types.ErrSenderAddressNotAuthorized + } ctx := sdk.UnwrapSDKContext(goCtx) exist := m.HasSigningRequest(ctx, msg.Txid) if !exist { From 56cdfe6ca15ede2c474d10ea6748cd752311a5f9 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Thu, 20 Jun 2024 11:44:51 +0800 Subject: [PATCH 67/71] verfiy the signature --- x/btcbridge/keeper/msg_server.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x/btcbridge/keeper/msg_server.go b/x/btcbridge/keeper/msg_server.go index b4c2b80b..e5524fe2 100644 --- a/x/btcbridge/keeper/msg_server.go +++ b/x/btcbridge/keeper/msg_server.go @@ -177,6 +177,8 @@ func (m msgServer) SubmitWithdrawSignatures(goCtx context.Context, msg *types.Ms return nil, types.ErrInvalidSignatures } + // verify the signatures + // Set the signing request status to signed request := m.GetSigningRequest(ctx, msg.Txid) request.Psbt = msg.Psbt From a4814e5ef71397a90eb7cf6a43c224220ca8dc0c Mon Sep 17 00:00:00 2001 From: sufay Date: Thu, 20 Jun 2024 14:04:30 +0800 Subject: [PATCH 68/71] add psbt signature verification --- x/btcbridge/keeper/msg_server.go | 3 ++ x/btcbridge/types/signature.go | 62 ++++++++++++++++++++++++++++++-- 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/x/btcbridge/keeper/msg_server.go b/x/btcbridge/keeper/msg_server.go index e5524fe2..c39a91d0 100644 --- a/x/btcbridge/keeper/msg_server.go +++ b/x/btcbridge/keeper/msg_server.go @@ -178,6 +178,9 @@ func (m msgServer) SubmitWithdrawSignatures(goCtx context.Context, msg *types.Ms } // verify the signatures + if !types.VerifyPsbtSignatures(packet) { + return nil, types.ErrInvalidSignatures + } // Set the signing request status to signed request := m.GetSigningRequest(ctx, msg.Txid) diff --git a/x/btcbridge/types/signature.go b/x/btcbridge/types/signature.go index de9e436d..128f14ea 100644 --- a/x/btcbridge/types/signature.go +++ b/x/btcbridge/types/signature.go @@ -1,6 +1,64 @@ package types -func (m *BitcoinSigningRequest) ValidateSignatures(sigs []string) bool { +import ( + secp256k1 "github.com/btcsuite/btcd/btcec/v2" + "github.com/btcsuite/btcd/btcec/v2/ecdsa" + "github.com/btcsuite/btcd/btcutil/psbt" + "github.com/btcsuite/btcd/txscript" +) - return false +// VerifyPsbtSignatures verifies the signatures of the given psbt +// Note: assume that the psbt is valid and all inputs are native segwit +func VerifyPsbtSignatures(p *psbt.Packet) bool { + // build previous output fetcher + prevOutputFetcher := txscript.NewMultiPrevOutFetcher(nil) + + for i, txIn := range p.UnsignedTx.TxIn { + prevOutput := p.Inputs[i].WitnessUtxo + if prevOutput == nil { + return false + } + + prevOutputFetcher.AddPrevOut(txIn.PreviousOutPoint, prevOutput) + } + + // verify signatures + for i := range p.Inputs { + output := p.Inputs[i].WitnessUtxo + hashType := p.Inputs[i].SighashType + + witness := p.Inputs[i].FinalScriptWitness + if len(witness) < 72+33 { + return false + } + + sigBytes := witness[0 : len(witness)-33] + pkBytes := witness[len(witness)-33:] + + if sigBytes[len(sigBytes)-1] != byte(hashType) { + return false + } + + sig, err := ecdsa.ParseDERSignature(sigBytes[0 : len(sigBytes)-1]) + if err != nil { + return false + } + + pk, err := secp256k1.ParsePubKey(pkBytes) + if err != nil { + return false + } + + sigHash, err := txscript.CalcWitnessSigHash(output.PkScript, txscript.NewTxSigHashes(p.UnsignedTx, prevOutputFetcher), + hashType, p.UnsignedTx, i, output.Value) + if err != nil { + return false + } + + if !sig.Verify(sigHash, pk) { + return false + } + } + + return true } From 2b42a6921673f63201f4a737607c42a354dcea94 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Thu, 20 Jun 2024 22:09:25 +0800 Subject: [PATCH 69/71] update git version --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a76bc80f..0989fb57 100755 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ #!/usr/bin/make -f PACKAGES_NOSIMULATION=$(shell go list ./... | grep -v '/simulation') -VERSION ?= $(shell echo $(shell git describe --tags --always) | sed 's/^v//') +VERSION ?= $(shell echo $(shell git tag --sort=creatordate | tail -1) | sed 's/^v//') TMVERSION := $(shell go list -m github.com/cometbft/cometbft | sed 's:.* ::') COMMIT := $(shell git log -1 --format='%H') LEDGER_ENABLED ?= true @@ -623,4 +623,4 @@ split-test-packages:$(BUILDDIR)/packages.txt $(SPLIT_CMD) -d -n l/$(NUM_SPLIT) $< $<. test-group-%:split-test-packages - cat $(BUILDDIR)/packages.txt.$* | xargs go test -mod=readonly -timeout=10m -race -coverprofile=$(BUILDDIR)/$*.profile.out \ No newline at end of file + cat $(BUILDDIR)/packages.txt.$* | xargs go test -mod=readonly -timeout=10m -race -coverprofile=$(BUILDDIR)/$*.profile.out From fd035ddbcd800011437d563af99db19f6d848739 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Thu, 20 Jun 2024 22:44:35 +0800 Subject: [PATCH 70/71] update replace --- go.mod | 6 +++--- go.sum | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index df8c84f1..df224c5a 100644 --- a/go.mod +++ b/go.mod @@ -41,7 +41,6 @@ require ( github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect - github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f // indirect github.com/bufbuild/connect-go v1.0.0 // indirect github.com/bufbuild/protocompile v0.8.0 // indirect @@ -217,6 +216,7 @@ require ( github.com/CosmWasm/wasmvm v1.5.2 github.com/Stride-Labs/stride/v16 v16.0.0 github.com/btcsuite/btcd v0.24.1-0.20240318151728-2fc99e0496d2 + github.com/btcsuite/btcd/btcec/v2 v2.3.2 github.com/btcsuite/btcd/btcutil v1.1.5 github.com/btcsuite/btcd/btcutil/psbt v1.1.9 github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0 @@ -234,8 +234,8 @@ require ( ) replace ( - // github.com/cosmos/cosmos-sdk => github.com/sideprotocol/cosmos-sdk v0.47.116 - github.com/cosmos/cosmos-sdk => ../cosmos-sdk + github.com/cosmos/cosmos-sdk => github.com/sideprotocol/cosmos-sdk v0.47.11-bc1 + // github.com/cosmos/cosmos-sdk => ../cosmos-sdk github.com/cosmos/interchain-security/v3 => github.com/Stride-Labs/interchain-security/v3 v3.1.0-remove-validation-bug-7d3d9d github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 diff --git a/go.sum b/go.sum index a203d034..3a2517b3 100644 --- a/go.sum +++ b/go.sum @@ -977,6 +977,8 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/sideprotocol/cosmos-sdk v0.47.11-bc1 h1:+tMOIB6pOm/5eU86mIoxqkpgyyNjh3Q2LWExOPJLuws= +github.com/sideprotocol/cosmos-sdk v0.47.11-bc1/go.mod h1:lZq3Vdy3Mph8+unX5Afbmf1hsvj9FaYGMLEdCGjOY6g= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= From e70c60813d481c3f383fea70006e47ece4c3d416 Mon Sep 17 00:00:00 2001 From: liangping <18786721@qq.com> Date: Fri, 21 Jun 2024 11:00:38 +0800 Subject: [PATCH 71/71] update denpendency --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index df224c5a..d4d983f1 100644 --- a/go.mod +++ b/go.mod @@ -234,7 +234,7 @@ require ( ) replace ( - github.com/cosmos/cosmos-sdk => github.com/sideprotocol/cosmos-sdk v0.47.11-bc1 + github.com/cosmos/cosmos-sdk => github.com/sideprotocol/cosmos-sdk v0.47.11-btc1 // github.com/cosmos/cosmos-sdk => ../cosmos-sdk github.com/cosmos/interchain-security/v3 => github.com/Stride-Labs/interchain-security/v3 v3.1.0-remove-validation-bug-7d3d9d github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 diff --git a/go.sum b/go.sum index 3a2517b3..a3dcade9 100644 --- a/go.sum +++ b/go.sum @@ -977,8 +977,8 @@ github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/sideprotocol/cosmos-sdk v0.47.11-bc1 h1:+tMOIB6pOm/5eU86mIoxqkpgyyNjh3Q2LWExOPJLuws= -github.com/sideprotocol/cosmos-sdk v0.47.11-bc1/go.mod h1:lZq3Vdy3Mph8+unX5Afbmf1hsvj9FaYGMLEdCGjOY6g= +github.com/sideprotocol/cosmos-sdk v0.47.11-btc1 h1:I34aYrAD/kvm6OqB7dlCterLNSLGwo0CSFzkMuQeCDA= +github.com/sideprotocol/cosmos-sdk v0.47.11-btc1/go.mod h1:lZq3Vdy3Mph8+unX5Afbmf1hsvj9FaYGMLEdCGjOY6g= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=