From ee17d0f8281255e6e875ad17dd2feeee762b1551 Mon Sep 17 00:00:00 2001 From: Lazar Date: Mon, 14 Oct 2024 12:18:15 +0200 Subject: [PATCH] fix index-out-of-range --- submitter/relayer/relayer.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/submitter/relayer/relayer.go b/submitter/relayer/relayer.go index 4481d45a..d6091999 100644 --- a/submitter/relayer/relayer.go +++ b/submitter/relayer/relayer.go @@ -514,6 +514,10 @@ func (rl *Relayer) buildTxWithData(data []byte, firstTx *wire.MsgTx) (*types.Btc return nil, err } + if len(rawTxResult.Transaction.TxOut) <= changePosition { + return nil, fmt.Errorf("transaction doesn't have change output %s", rawTxResult.Transaction.TxID()) + } + rl.logger.Debugf("Building a BTC tx using %s with data %x", rawTxResult.Transaction.TxID(), data) _, addresses, _, err := txscript.ExtractPkScriptAddrs(