diff --git a/proto/side/btcbridge/tx.proto b/proto/side/btcbridge/tx.proto index d858a6f0..4e166d33 100644 --- a/proto/side/btcbridge/tx.proto +++ b/proto/side/btcbridge/tx.proto @@ -71,6 +71,8 @@ message MsgSubmitWithdrawTransaction { // this is relayer address who submit the bitcoin transaction to the side chain string sender = 1; string blockhash = 2; + // the previous tx bytes in base64 format + string prev_tx_bytes = 3; // the tx bytes in base64 format string tx_bytes = 4; repeated string proof = 5; diff --git a/x/btcbridge/keeper/keeper.go b/x/btcbridge/keeper/keeper.go index 4f2cbd7c..8f0c804a 100644 --- a/x/btcbridge/keeper/keeper.go +++ b/x/btcbridge/keeper/keeper.go @@ -1,9 +1,14 @@ 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/wire" "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" @@ -175,3 +180,87 @@ func (k Keeper) IterateBlockHeaders(ctx sdk.Context, process func(header types.B } } } + +// ValidateTransaction validates the given transaction +func (k Keeper) ValidateTransaction(ctx sdk.Context, txBytes string, prevTxBytes string, blockHash string, proof []string) (*btcutil.Tx, *btcutil.Tx, error) { + params := k.GetParams(ctx) + + header := k.GetBlockHeader(ctx, blockHash) + // Check if block confirmed + if header == nil || header.Height == 0 { + return nil, nil, types.ErrBlockNotFound + } + + best := k.GetBestBlockHeader(ctx) + // Check if the block is confirmed + if best.Height-header.Height < uint64(params.Confirmations) { + return nil, nil, 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 + rawTx, err := base64.StdEncoding.DecodeString(txBytes) + if err != nil { + fmt.Println("Error decoding transaction from base64:", err) + return nil, nil, err + } + + // Create a new transaction + var tx wire.MsgTx + err = tx.Deserialize(bytes.NewReader(rawTx)) + if err != nil { + fmt.Println("Error deserializing transaction:", err) + return nil, nil, err + } + + uTx := btcutil.NewTx(&tx) + + // Validate the transaction + if err := blockchain.CheckTransactionSanity(uTx); err != nil { + fmt.Println("Transaction is not valid:", err) + return nil, nil, err + } + + // Decode the previous transaction + rawPrevTx, err := base64.StdEncoding.DecodeString(prevTxBytes) + if err != nil { + fmt.Println("Error decoding transaction from base64:", err) + return nil, nil, err + } + + // Create a new transaction + var prevMsgTx wire.MsgTx + err = prevMsgTx.Deserialize(bytes.NewReader(rawPrevTx)) + if err != nil { + fmt.Println("Error deserializing transaction:", err) + return nil, nil, err + } + + prevTx := btcutil.NewTx(&prevMsgTx) + + // Validate the transaction + if err := blockchain.CheckTransactionSanity(prevTx); err != nil { + fmt.Println("Transaction is not valid:", err) + return nil, nil, err + } + + if uTx.MsgTx().TxIn[0].PreviousOutPoint.Hash.String() != prevTx.Hash().String() { + return nil, nil, types.ErrInvalidBtcTransaction + } + + // check if the proof is valid + root, err := chainhash.NewHashFromStr(header.MerkleRoot) + if err != nil { + return nil, nil, err + } + + if !types.VerifyMerkleProof(proof, uTx.Hash(), root) { + k.Logger(ctx).Error("Invalid merkle proof", "txhash", tx, "root", root, "proof", proof) + return nil, nil, types.ErrTransactionNotIncluded + } + + return uTx, prevTx, nil +} diff --git a/x/btcbridge/keeper/keeper_deposit.go b/x/btcbridge/keeper/keeper_deposit.go index c8f5fc4d..70994f54 100644 --- a/x/btcbridge/keeper/keeper_deposit.go +++ b/x/btcbridge/keeper/keeper_deposit.go @@ -1,11 +1,6 @@ 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" @@ -20,7 +15,7 @@ import ( func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.MsgSubmitDepositTransaction) (*chainhash.Hash, btcutil.Address, error) { ctx.Logger().Info("accept bitcoin deposit tx", "blockhash", msg.Blockhash) - tx, prevTx, err := k.ValidateDepositTransaction(ctx, msg.TxBytes, msg.PrevTxBytes, msg.Blockhash, msg.Proof) + tx, prevTx, err := k.ValidateTransaction(ctx, msg.TxBytes, msg.PrevTxBytes, msg.Blockhash, msg.Proof) if err != nil { return nil, nil, err } @@ -33,90 +28,6 @@ func (k Keeper) ProcessBitcoinDepositTransaction(ctx sdk.Context, msg *types.Msg return tx.Hash(), recipient, nil } -// validateDepositTransaction validates the deposit transaction -func (k Keeper) ValidateDepositTransaction(ctx sdk.Context, txBytes string, prevTxBytes string, blockHash string, proof []string) (*btcutil.Tx, *btcutil.Tx, error) { - params := k.GetParams(ctx) - - header := k.GetBlockHeader(ctx, blockHash) - // Check if block confirmed - if header == nil || header.Height == 0 { - return nil, nil, types.ErrBlockNotFound - } - - best := k.GetBestBlockHeader(ctx) - // Check if the block is confirmed - if best.Height-header.Height < uint64(params.Confirmations) { - return nil, nil, 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 - rawTx, err := base64.StdEncoding.DecodeString(txBytes) - if err != nil { - fmt.Println("Error decoding transaction from base64:", err) - return nil, nil, err - } - - // Create a new transaction - var tx wire.MsgTx - err = tx.Deserialize(bytes.NewReader(rawTx)) - if err != nil { - fmt.Println("Error deserializing transaction:", err) - return nil, nil, err - } - - uTx := btcutil.NewTx(&tx) - - // Validate the transaction - if err := blockchain.CheckTransactionSanity(uTx); err != nil { - fmt.Println("Transaction is not valid:", err) - return nil, nil, err - } - - // Decode the previous transaction - rawPrevTx, err := base64.StdEncoding.DecodeString(prevTxBytes) - if err != nil { - fmt.Println("Error decoding transaction from base64:", err) - return nil, nil, err - } - - // Create a new transaction - var prevMsgTx wire.MsgTx - err = prevMsgTx.Deserialize(bytes.NewReader(rawPrevTx)) - if err != nil { - fmt.Println("Error deserializing transaction:", err) - return nil, nil, err - } - - prevTx := btcutil.NewTx(&prevMsgTx) - - // Validate the transaction - if err := blockchain.CheckTransactionSanity(prevTx); err != nil { - fmt.Println("Transaction is not valid:", err) - return nil, nil, err - } - - if uTx.MsgTx().TxIn[0].PreviousOutPoint.Hash.String() != prevTx.Hash().String() { - return nil, nil, types.ErrInvalidBtcTransaction - } - - // check if the proof is valid - root, err := chainhash.NewHashFromStr(header.MerkleRoot) - if err != nil { - return nil, nil, err - } - - if !types.VerifyMerkleProof(proof, uTx.Hash(), root) { - k.Logger(ctx).Error("Invalid merkle proof", "txhash", tx, "root", root, "proof", proof) - return nil, nil, types.ErrTransactionNotIncluded - } - - return uTx, prevTx, nil -} - // mint performs the minting operation of the voucher token func (k Keeper) Mint(ctx sdk.Context, tx *btcutil.Tx, prevTx *btcutil.Tx, height uint64) (btcutil.Address, error) { params := k.GetParams(ctx) diff --git a/x/btcbridge/keeper/keeper_withdraw.go b/x/btcbridge/keeper/keeper_withdraw.go index 2a452405..a4646cc1 100644 --- a/x/btcbridge/keeper/keeper_withdraw.go +++ b/x/btcbridge/keeper/keeper_withdraw.go @@ -1,14 +1,7 @@ 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/wire" sdk "github.com/cosmos/cosmos-sdk/types" @@ -159,62 +152,32 @@ func (k Keeper) FilterWithdrawRequestsByAddr(ctx sdk.Context, req *types.QueryWi func (k Keeper) ProcessBitcoinWithdrawTransaction(ctx sdk.Context, msg *types.MsgSubmitWithdrawTransaction) (*chainhash.Hash, error) { ctx.Logger().Info("accept bitcoin withdraw tx", "blockhash", msg.Blockhash) - param := k.GetParams(ctx) - - header := k.GetBlockHeader(ctx, msg.Blockhash) - // Check if block confirmed - if header == nil { - return nil, types.ErrBlockNotFound - } - - best := k.GetBestBlockHeader(ctx) - // Check if the block is confirmed - if best.Height-header.Height < uint64(param.Confirmations) { - return nil, types.ErrNotConfirmed - } - // Check if the block is within the acceptable depth - if best.Height-header.Height > param.MaxAcceptableBlockDepth { - return nil, types.ErrExceedMaxAcceptanceDepth - } - - // Decode the base64 transaction - txBytes, err := base64.StdEncoding.DecodeString(msg.TxBytes) + tx, prevTx, err := k.ValidateTransaction(ctx, msg.TxBytes, msg.PrevTxBytes, msg.Blockhash, msg.Proof) if err != nil { - fmt.Println("Error decoding transaction from base64:", err) return nil, err } - // Create a new transaction - var tx wire.MsgTx - err = tx.Deserialize(bytes.NewReader(txBytes)) + if types.SelectVaultByPkScript(k.GetParams(ctx).Vaults, prevTx.MsgTx().TxOut[tx.MsgTx().TxIn[0].PreviousOutPoint.Index].PkScript) == nil { + return nil, types.ErrInvalidWithdrawTransaction + } + + sequence, err := types.ParseSequence(tx.MsgTx()) if err != nil { - fmt.Println("Error deserializing transaction:", err) return nil, err } - uTx := btcutil.NewTx(&tx) - if len(uTx.MsgTx().TxIn) < 1 { - return nil, types.ErrInvalidBtcTransaction + if !k.HasWithdrawRequest(ctx, sequence) { + return nil, types.ErrWithdrawRequestNotExist } - txHash := uTx.MsgTx().TxHash() - - if !k.HasWithdrawRequestByTxHash(ctx, txHash.String()) { - return nil, types.ErrWithdrawRequestNotExist + withdrawRequest := k.GetWithdrawRequest(ctx, sequence) + if withdrawRequest.Status == types.WithdrawStatus_WITHDRAW_STATUS_CONFIRMED { + return nil, types.ErrWithdrawRequestConfirmed } - withdrawRequest := k.GetWithdrawRequestByTxHash(ctx, txHash.String()) - // if withdrawRequest.Status != types.WithdrawStatus_WITHDRAW_STATUS_BROADCASTED { - // return types.ErrInvalidStatus - // } + withdrawRequest.Txid = tx.Hash().String() withdrawRequest.Status = types.WithdrawStatus_WITHDRAW_STATUS_CONFIRMED k.SetWithdrawRequest(ctx, withdrawRequest) - // Validate the transaction - if err := blockchain.CheckTransactionSanity(uTx); err != nil { - fmt.Println("Transaction is not valid:", err) - return nil, err - } - - return &txHash, nil + return tx.Hash(), nil } diff --git a/x/btcbridge/types/errors.go b/x/btcbridge/types/errors.go index fbffc27f..2d9eba73 100644 --- a/x/btcbridge/types/errors.go +++ b/x/btcbridge/types/errors.go @@ -15,18 +15,20 @@ 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") - ErrInvalidDepositTransaction = errorsmod.Register(ModuleName, 3204, "invalid deposit transaction") - - ErrInsufficientBalance = errorsmod.Register(ModuleName, 4201, "insufficient balance") - ErrWithdrawRequestNotExist = errorsmod.Register(ModuleName, 4202, "withdrawal request does not exist") - ErrInvalidStatus = errorsmod.Register(ModuleName, 4203, "invalid status") + 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") + ErrInvalidWithdrawTransaction = errorsmod.Register(ModuleName, 3205, "invalid withdrawal transaction") + + ErrInsufficientBalance = errorsmod.Register(ModuleName, 4201, "insufficient balance") + ErrWithdrawRequestNotExist = errorsmod.Register(ModuleName, 4202, "withdrawal request does not exist") + ErrWithdrawRequestConfirmed = errorsmod.Register(ModuleName, 4203, "withdrawal request has been confirmed") + ErrInvalidStatus = errorsmod.Register(ModuleName, 4204, "invalid status") ErrInvalidAmount = errorsmod.Register(ModuleName, 5100, "invalid amount") ErrAssetNotSupported = errorsmod.Register(ModuleName, 5101, "asset not supported") @@ -39,4 +41,5 @@ var ( ErrInvalidDepositAmount = errorsmod.Register(ModuleName, 8100, "invalid deposit amount") ErrInvalidWithdrawAmount = errorsmod.Register(ModuleName, 8101, "invalid withdrawal amount") + ErrInvalidSequence = errorsmod.Register(ModuleName, 8102, "invalid sequence") ) diff --git a/x/btcbridge/types/deposit_policy.go b/x/btcbridge/types/policy.go similarity index 86% rename from x/btcbridge/types/deposit_policy.go rename to x/btcbridge/types/policy.go index 85dc382a..9087c4ed 100644 --- a/x/btcbridge/types/deposit_policy.go +++ b/x/btcbridge/types/policy.go @@ -1,6 +1,9 @@ package types import ( + "bytes" + "math/big" + "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/txscript" @@ -18,6 +21,11 @@ const ( RunesEdictNum = 1 ) +var ( + // withdrawal identifier which is used in the OP_RETURN script of the withdrawal tx + WithdrawIdentifier = []byte("side") +) + // ExtractRecipientAddr extracts the recipient address for minting voucher token by the type of the asset to be deposited func ExtractRecipientAddr(tx *wire.MsgTx, prevTx *wire.MsgTx, vaults []*Vault, isRunes bool, chainCfg *chaincfg.Params) (btcutil.Address, error) { if isRunes { @@ -149,3 +157,19 @@ func CheckRunesDepositTransaction(tx *wire.MsgTx, vaults []*Vault) (*Edict, erro return edicts[0], nil } + +// ParseSequence parses the sequence from the given tx +// make sure the tx is valid +func ParseSequence(tx *wire.MsgTx) (uint64, error) { + scriptBuilder := txscript.MakeScriptTokenizer(0, tx.TxOut[0].PkScript) + + if scriptBuilder.Next() && scriptBuilder.Opcode() == txscript.OP_RETURN { + if scriptBuilder.Next() && bytes.Equal(scriptBuilder.Data(), WithdrawIdentifier) { + if scriptBuilder.Next() { + return new(big.Int).SetBytes(scriptBuilder.Data()).Uint64(), nil + } + } + } + + return 0, ErrInvalidSequence +} diff --git a/x/btcbridge/types/tx.pb.go b/x/btcbridge/types/tx.pb.go index baba6ddc..a11dac9f 100644 --- a/x/btcbridge/types/tx.pb.go +++ b/x/btcbridge/types/tx.pb.go @@ -347,6 +347,8 @@ type MsgSubmitWithdrawTransaction 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 previous tx bytes in base64 format + 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"` @@ -399,6 +401,13 @@ func (m *MsgSubmitWithdrawTransaction) GetBlockhash() string { return "" } +func (m *MsgSubmitWithdrawTransaction) GetPrevTxBytes() string { + if m != nil { + return m.PrevTxBytes + } + return "" +} + func (m *MsgSubmitWithdrawTransaction) GetTxBytes() string { if m != nil { return m.TxBytes @@ -657,48 +666,48 @@ func init() { func init() { proto.RegisterFile("side/btcbridge/tx.proto", fileDescriptor_785ca8e1e4227068) } var fileDescriptor_785ca8e1e4227068 = []byte{ - // 643 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x95, 0xcb, 0x6e, 0xd3, 0x40, + // 642 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x95, 0xcb, 0x6e, 0xd3, 0x40, 0x14, 0x86, 0xe3, 0x26, 0x0d, 0xcd, 0xe9, 0x05, 0x31, 0x0a, 0xad, 0xeb, 0x16, 0x27, 0x98, 0x96, 0x46, 0xa2, 0xd8, 0x52, 0x5a, 0xb1, 0x46, 0x11, 0x42, 0xdd, 0x44, 0x42, 0x6e, 0x11, 0x88, 0x4d, - 0xe5, 0xcb, 0x60, 0x1b, 0x1a, 0x8f, 0xeb, 0x19, 0x43, 0x2a, 0x21, 0xb1, 0x62, 0xcf, 0x96, 0x07, - 0x40, 0xe2, 0x51, 0xba, 0xec, 0x92, 0x15, 0x42, 0xed, 0x8b, 0x20, 0x8f, 0xdd, 0x69, 0x9a, 0xd8, - 0xbd, 0x88, 0x9d, 0x67, 0xce, 0xe7, 0xff, 0xff, 0x8f, 0x73, 0x26, 0x03, 0x4b, 0x34, 0x70, 0xb1, - 0x61, 0x33, 0xc7, 0x8e, 0x03, 0xd7, 0xc3, 0x06, 0x1b, 0xea, 0x51, 0x4c, 0x18, 0x41, 0x0b, 0x69, - 0x41, 0x17, 0x05, 0xa5, 0xe9, 0x11, 0x8f, 0xf0, 0x92, 0x91, 0x3e, 0x65, 0x94, 0xb2, 0x32, 0xf6, - 0x7a, 0x64, 0xc5, 0xd6, 0x80, 0xe6, 0xc5, 0xd5, 0xb1, 0xa2, 0x1d, 0x30, 0x87, 0x04, 0x61, 0x56, - 0xd5, 0x7e, 0x48, 0xb0, 0xd4, 0xa7, 0xde, 0x6e, 0x62, 0x0f, 0x02, 0xf6, 0x26, 0x60, 0xbe, 0x1b, - 0x5b, 0x9f, 0x77, 0x99, 0xc5, 0x12, 0x8a, 0x16, 0xa1, 0x4e, 0x71, 0xe8, 0xe2, 0x58, 0x96, 0xda, - 0x52, 0xa7, 0x61, 0xe6,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xbe, 0x0d, 0x2d, + 0x02, 0x78, 0x70, 0x6f, 0x72, 0xb2, 0xd6, 0x0a, 0xa4, 0x26, 0x28, 0x65, 0xf3, 0x26, 0x94, 0x30, + 0x8a, 0xa0, 0x59, 0xf8, 0xd7, 0xbd, 0x71, 0x6d, 0xec, 0x0c, 0x54, 0x8c, 0x1b, 0x82, 0xc2, 0xf1, + 0x2d, 0xcc, 0x5d, 0x1a, 0xe6, 0x56, 0x81, 0xc0, 0x28, 0xa0, 0x6c, 0x5c, 0x03, 0x9c, 0x2b, 0xf7, + 0x76, 0x8e, 0x4f, 0x55, 0xe9, 0xe4, 0x54, 0x95, 0xfe, 0x9e, 0xaa, 0xd2, 0xb7, 0x33, 0xb5, 0x72, + 0x72, 0xa6, 0x56, 0x7e, 0x9f, 0xa9, 0x95, 0x77, 0xba, 0x17, 0x30, 0x3f, 0xb1, 0x75, 0x87, 0x0c, + 0x8c, 0x54, 0x8c, 0x7f, 0xba, 0x1c, 0x72, 0xc0, 0x17, 0xc6, 0x70, 0xf4, 0xc3, 0x79, 0x14, 0x61, + 0x6a, 0xd7, 0x39, 0xb0, 0xf5, 0x2f, 0x00, 0x00, 0xff, 0xff, 0x92, 0x4f, 0xf5, 0xa7, 0x57, 0x07, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1235,6 +1244,13 @@ func (m *MsgSubmitWithdrawTransaction) MarshalToSizedBuffer(dAtA []byte) (int, e 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) @@ -1523,6 +1539,10 @@ func (m *MsgSubmitWithdrawTransaction) 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)) @@ -2322,6 +2342,38 @@ func (m *MsgSubmitWithdrawTransaction) 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)