Skip to content

Commit d733b81

Browse files
committed
tapgarden: use valid PkScript for mock funded PSBT
1 parent 8cbf9aa commit d733b81

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

tapgarden/mock.go

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package tapgarden
22

33
import (
4+
"bytes"
45
"context"
56
"encoding/hex"
67
"fmt"
@@ -21,6 +22,7 @@ import (
2122
"github.com/lightninglabs/taproot-assets/asset"
2223
"github.com/lightninglabs/taproot-assets/internal/test"
2324
"github.com/lightninglabs/taproot-assets/proof"
25+
"github.com/lightninglabs/taproot-assets/tapscript"
2426
"github.com/lightningnetwork/lnd/chainntnfs"
2527
"github.com/lightningnetwork/lnd/keychain"
2628
"github.com/lightningnetwork/lnd/lnwallet"
@@ -101,17 +103,25 @@ func (m *MockWalletAnchor) FundPsbt(_ context.Context, packet *psbt.Packet,
101103
Index: rand.Uint32(),
102104
},
103105
})
104-
packet.Inputs = append(packet.Inputs, psbt.PInput{
106+
107+
// Use a P2TR input by default.
108+
anchorInput := psbt.PInput{
105109
WitnessUtxo: &wire.TxOut{
106110
Value: 100000,
107-
PkScript: []byte{0x1},
111+
PkScript: bytes.Clone(tapscript.GenesisDummyScript),
108112
},
109113
SighashType: txscript.SigHashDefault,
110-
})
111-
packet.UnsignedTx.AddTxOut(&wire.TxOut{
114+
}
115+
packet.Inputs = append(packet.Inputs, anchorInput)
116+
117+
// Use a non-P2TR change output by default so we avoid generating
118+
// exclusion proofs.
119+
changeOutput := wire.TxOut{
112120
Value: 50000,
113-
PkScript: []byte{0x2},
114-
})
121+
PkScript: bytes.Clone(tapscript.GenesisDummyScript),
122+
}
123+
changeOutput.PkScript[0] = txscript.OP_0
124+
packet.UnsignedTx.AddTxOut(&changeOutput)
115125
packet.Outputs = append(packet.Outputs, psbt.POutput{})
116126

117127
// We always have the change output be the second output, so this means

0 commit comments

Comments
 (0)