Skip to content

Commit 96c8cc3

Browse files
committed
tapscript+tapgarden: move dummy script to tapscript
1 parent 1eb01fd commit 96c8cc3

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

tapgarden/caretaker.go

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

33
import (
4-
"bytes"
54
"context"
65
"errors"
76
"fmt"
@@ -22,6 +21,7 @@ import (
2221
"github.com/lightninglabs/taproot-assets/commitment"
2322
"github.com/lightninglabs/taproot-assets/fn"
2423
"github.com/lightninglabs/taproot-assets/proof"
24+
"github.com/lightninglabs/taproot-assets/tapscript"
2525
"github.com/lightninglabs/taproot-assets/universe"
2626
"github.com/lightningnetwork/lnd/chainntnfs"
2727
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
@@ -30,17 +30,11 @@ import (
3030
)
3131

3232
var (
33-
// GenesisDummyScript is a dummy script that we'll use to fund the
34-
// initial PSBT packet that'll create initial set of assets. It's the
35-
// same size as a encoded P2TR output and has a valid P2TR prefix.
36-
GenesisDummyScript = append(
37-
[]byte{0x51, 0x20}, bytes.Repeat([]byte{0x00}, 32)...,
38-
)
3933

4034
// DummyGenesisTxOut is the dummy TxOut we'll place in the PSBt funding
4135
// request to make sure we leave enough room for change and fees.
4236
DummyGenesisTxOut = wire.TxOut{
43-
PkScript: GenesisDummyScript[:],
37+
PkScript: tapscript.GenesisDummyScript[:],
4438
Value: int64(GenesisAmtSats),
4539
}
4640

tapgarden/planter_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ func (t *mintingTestHarness) assertGenesisTxFunded() *tapgarden.FundedPsbt {
365365
if txOut.Value == int64(tapgarden.GenesisAmtSats) {
366366
isP2TR := txscript.IsPayToTaproot(txOut.PkScript)
367367
isDummyScript := bytes.Equal(
368-
txOut.PkScript, tapgarden.GenesisDummyScript[:],
368+
txOut.PkScript, tapscript.GenesisDummyScript[:],
369369
)
370370

371371
if isP2TR || isDummyScript {

tapscript/send.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
"github.com/btcsuite/btcd/btcutil"
1717
"github.com/btcsuite/btcd/btcutil/psbt"
1818
"github.com/btcsuite/btcd/chaincfg/chainhash"
19+
"github.com/btcsuite/btcd/txscript"
1920
"github.com/btcsuite/btcd/wire"
2021
"github.com/btcsuite/btclog"
2122
"github.com/lightninglabs/taproot-assets/address"
@@ -105,16 +106,23 @@ var (
105106
)
106107
)
107108

109+
var (
110+
// GenesisDummyScript is a dummy script that we'll use to fund the
111+
// initial PSBT packet that'll create initial set of assets. It's the
112+
// same size as a encoded P2TR output and has a valid P2TR prefix.
113+
GenesisDummyScript = append(
114+
[]byte{txscript.OP_1, 0x20}, bytes.Repeat([]byte{0x00}, 32)...,
115+
)
116+
)
117+
108118
// createDummyOutput creates a new Bitcoin transaction output that is later
109119
// used to embed a Taproot Asset commitment.
110120
func createDummyOutput() *wire.TxOut {
111121
// The dummy PkScript is the same size as an encoded P2TR output and has
112122
// a valid P2TR prefix.
113123
newOutput := wire.TxOut{
114-
Value: int64(DummyAmtSats),
115-
PkScript: append(
116-
[]byte{0x51, 0x20}, bytes.Repeat([]byte{0x00}, 32)...,
117-
),
124+
Value: int64(DummyAmtSats),
125+
PkScript: GenesisDummyScript,
118126
}
119127
return &newOutput
120128
}

0 commit comments

Comments
 (0)