From 06b525f595fd6577d3db9958e453d7cf7fd5344f Mon Sep 17 00:00:00 2001 From: sufay Date: Fri, 21 Jun 2024 18:30:19 +0800 Subject: [PATCH] optimize --- x/btcbridge/keeper/keeper_withdraw.go | 6 ++++-- x/btcbridge/keeper/msg_server.go | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/x/btcbridge/keeper/keeper_withdraw.go b/x/btcbridge/keeper/keeper_withdraw.go index 40176db..fc44ec2 100644 --- a/x/btcbridge/keeper/keeper_withdraw.go +++ b/x/btcbridge/keeper/keeper_withdraw.go @@ -70,8 +70,10 @@ func (k Keeper) NewSigningRequest(ctx sdk.Context, sender string, coin sdk.Coin, k.LockUTXOs(ctx, selectedUTXOs) // save the change utxo and mark minted - k.saveUTXO(ctx, changeUTXO) - k.addToMintHistory(ctx, psbt.UnsignedTx.TxHash().String()) + if changeUTXO != nil { + k.saveUTXO(ctx, changeUTXO) + k.addToMintHistory(ctx, psbt.UnsignedTx.TxHash().String()) + } signingRequest := &types.BitcoinSigningRequest{ Address: sender, diff --git a/x/btcbridge/keeper/msg_server.go b/x/btcbridge/keeper/msg_server.go index c39a91d..1b9522f 100644 --- a/x/btcbridge/keeper/msg_server.go +++ b/x/btcbridge/keeper/msg_server.go @@ -170,6 +170,11 @@ func (m msgServer) SubmitWithdrawSignatures(goCtx context.Context, msg *types.Ms if err != nil { return nil, err } + + if packet.UnsignedTx.TxHash().String() != msg.Txid { + return nil, types.ErrInvalidSignatures + } + if err = packet.SanityCheck(); err != nil { return nil, err }