github.com/piotrnar/gocoin@v0.0.0-20240512203912-faa0448c5e96/lib/btc/multisig_test.go (about)

     1  package btc
     2  
     3  import (
     4  	"bytes"
     5  	"testing"
     6  	"encoding/hex"
     7  )
     8  
     9  
    10  func TestMultisigFromScript(t *testing.T) {
    11  	txt := "004730440220485ef45dd67e7e3ffee699d42cf56ec88b4162d9f373770c30efec075468281702204929343ea97b007c1fc2ed49b306355ebf6bc5fb1613f0ed51ebca44fcc2003a014c69512103af88375d5fc9230446365b7d33540a73397ab3cc1a9f3e306a26833d1bfc260f21030677e0dd58025a5404747fbc64083040083acf3b390515f71a8ede95dc9c4d8a2103af88375d5fc9230446365b7d33540a73397ab3cc1a9f3e306a26833d1bfc260f53ae"
    12  	d, _ := hex.DecodeString(txt)
    13  	s, e := NewMultiSigFromScript(d)
    14  	if e != nil {
    15  		t.Error(e.Error())
    16  	}
    17  
    18  	b := s.Bytes()
    19  	if !bytes.Equal(b, d) {
    20  		t.Error("Multisig script does not match the input\n", hex.EncodeToString(b), "\n", hex.EncodeToString(d))
    21  	}
    22  }