diff --git a/itest/mint_fund_seal_test.go b/itest/mint_fund_seal_test.go index 2ee730ed8..c6db4158e 100644 --- a/itest/mint_fund_seal_test.go +++ b/itest/mint_fund_seal_test.go @@ -4,11 +4,7 @@ import ( "bytes" "context" "encoding/base64" - "encoding/binary" "encoding/hex" - "errors" - "fmt" - "log" "math" "testing" @@ -571,25 +567,16 @@ func testMintExternalGroupKeyChantools(t *harnessTest) { var genesisAssetID asset.ID copy(genesisAssetID[:], genesisAssetIDBytes) - // Extract witness from signed PSBT. - witnessStack, err := DeserializeWitnessStack( - signedPsbt.Inputs[0].FinalScriptWitness, - ) - if err != nil { - log.Fatalf("Failed to deserialize witness stack: %v", err) - } - - groupWitness := taprpc.GroupWitness{ - GenesisId: genesisAssetID[:], - Witness: witnessStack, - } - ctxt, cancel = context.WithTimeout(ctxb, defaultWaitTimeout) defer cancel() + // Encode the signed PSBT as a string. + signedPsbtStr, err := signedPsbt.B64Encode() + require.NoError(t.t, err) + sealReq := mintrpc.SealBatchRequest{ - GroupWitnesses: []*taprpc.GroupWitness{ - &groupWitness, + SignedGroupVirtualPsbts: []string{ + signedPsbtStr, }, } sealResp, err := t.tapd.SealBatch(ctxt, &sealReq) @@ -619,74 +606,6 @@ func testMintExternalGroupKeyChantools(t *harnessTest) { t.Logf("Batch assets: %v", batchAssets) } -// DeserializeWitnessStack deserializes a serialized witness stack into a -// [][]byte. -func DeserializeWitnessStack(serialized []byte) ([][]byte, error) { - var stack [][]byte - reader := bytes.NewReader(serialized) - - // Read the number of witness elements (compact size integer) - count, err := readCompactSize(reader) - if err != nil { - return nil, fmt.Errorf("failed to read witness count: %w", err) - } - - // Read each witness element - for i := uint64(0); i < count; i++ { - elementSize, err := readCompactSize(reader) - if err != nil { - return nil, fmt.Errorf("failed to read witness "+ - "element size: %w", err) - } - - // Read the witness element data - element := make([]byte, elementSize) - if _, err := reader.Read(element); err != nil { - return nil, fmt.Errorf("failed to read witness "+ - "element data: %w", err) - } - stack = append(stack, element) - } - - return stack, nil -} - -// readCompactSize reads a compact size integer from the given reader. -func readCompactSize(r *bytes.Reader) (uint64, error) { - if r.Len() == 0 { - return 0, errors.New("unexpected EOF") - } - - prefix, _ := r.ReadByte() - switch { - case prefix < 253: - return uint64(prefix), nil - case prefix == 253: - var value uint16 - err := binary.Read(r, binary.LittleEndian, &value) - if err != nil { - return 0, err - } - return uint64(value), nil - case prefix == 254: - var value uint32 - err := binary.Read(r, binary.LittleEndian, &value) - if err != nil { - return 0, err - } - return uint64(value), nil - case prefix == 255: - var value uint64 - err := binary.Read(r, binary.LittleEndian, &value) - if err != nil { - return 0, err - } - return value, nil - default: - return 0, errors.New("invalid compact size prefix") - } -} - // Derive a random key on an LND node, with a key family not matching the // Taproot Assets key family. func deriveRandomKey(t *testing.T, ctxt context.Context,