Skip to content

Commit

Permalink
tappsbt: replace payToTaprootScript with txscript.PayToTaprootScript
Browse files Browse the repository at this point in the history
  • Loading branch information
ffranr committed Feb 20, 2025
1 parent 9598d1f commit 01522c6
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions tappsbt/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"net/url"

"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcec/v2/schnorr"
"github.com/btcsuite/btcd/btcutil/psbt"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
Expand Down Expand Up @@ -226,7 +225,7 @@ func (o *VOutput) encode(coinType uint32) (psbt.POutput, *wire.TxOut, error) {
// Before we start with any fields that need to go into the Unknowns
// slice, we add the information that we can stuff into the wire TX or
// existing PSBT fields.
assetPkScript, err := payToTaprootScript(o.ScriptKey.PubKey)
assetPkScript, err := txscript.PayToTaprootScript(o.ScriptKey.PubKey)
if err != nil {
return pOut, nil, fmt.Errorf("error creating asset taproot "+
"script: %w", err)
Expand Down Expand Up @@ -487,16 +486,6 @@ func tapscriptPreimageEncoder(t *commitment.TapscriptPreimage) encoderFunc {
return tlvEncoder(&t, commitment.TapscriptPreimageEncoder)
}

// payToTaprootScript creates a pk script for a pay-to-taproot output key. We
// create a copy of the tapscript.PayToTaprootScript function here to avoid a
// circular dependency.
func payToTaprootScript(taprootKey *btcec.PublicKey) ([]byte, error) {
return txscript.NewScriptBuilder().
AddOp(txscript.OP_1).
AddData(schnorr.SerializePubKey(taprootKey)).
Script()
}

// vOutputTypeEncoder is a TLV encoder that encodes the given VOutputType to the
// given writer.
func vOutputTypeEncoder(w io.Writer, val any, buf *[8]byte) error {
Expand Down

0 comments on commit 01522c6

Please sign in to comment.