libsv / go-bt

The go-to Bitcoin Transaction (BT) Go library.
https://pkg.go.dev/mod/github.com/libsv/go-bt
ISC License
66 stars 26 forks source link

[BUG] panic: index out of range when checking if script is multisig #185

Open caevv opened 10 months ago

caevv commented 10 months ago

Output 0 https://classic.whatsonchain.com/tx/6148dd49af06ecec4e0f31cf3b1c6f6bb499a8bfab267c93a8b74deb6cf838b5

panic: runtime error: index out of range [0] with length 0
goroutine 33104 [running]:
github.com/libsv/go-bt/bscript.(*Script).IsMultisigOut(0xc002b4ef18?)
    github.com/libsv/go-bt@v1.0.8/bscript/script.go:305 +0xe5

Replicate:

package main

import (
    "github.com/libsv/go-bt"
)

func main() {
    tx, err := bt.NewTxFromString(tx)
    if err != nil {
        panic(err)
    }

    print(tx.GetTxID())

    for _, output := range tx.Outputs {
        output.LockingScript.IsMultisigOut()
    }

}

var tx = "01000000022e131b16fa4d47669b8b3a3054fb0662234372124b6478b9fbcec2430ad17bba010000006a47304402206cb269cc20a402db8eefc5a3249bd86ee868331ed3bd006ecb99c56c751069fe02203536e06213f16b0febc39c7b72092732bfdf3f76a40b4a174b3d7b629ba9d8b74121026e83f3dcd977f6da9d6b349cd8928ae64cf1d5b2584b31144af80eb4e924af86ffffffff9ab6798431849f8f109e3144b6d48a267bee184b5100cca41ad17e98300aec0b000000006a47304402205ba281ed79f25a1ff9b5045b486ea7e412555802c42ea50f107143b3d4781edc02207d2ec6d42087407d072c755618b8ebb43416470261bf571d8511339e66a0a8814121026e83f3dcd977f6da9d6b349cd8928ae64cf1d5b2584b31144af80eb4e924af86ffffffff02e803000000000000084c000400d3016787dcb30100000000001976a91451015d3f83aed2d79c084877dfee20f32769229a88ac00000000"