Skip to content

Commit f6dd14a

Browse files
committed
address: update handling of tapscript preimages
1 parent a030f57 commit f6dd14a

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

address/address.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ func New(version Version, genesis asset.Genesis, groupKey *btcec.PublicKey,
196196
// We can only use a tapscript sibling that is not a Taproot Asset
197197
// commitment.
198198
if tapscriptSibling != nil {
199-
if err := tapscriptSibling.VerifyNoCommitment(); err != nil {
199+
if _, err := tapscriptSibling.TapHash(); err != nil {
200200
return nil, errors.New("address: tapscript sibling " +
201-
"is a Taproot Asset commitment")
201+
"is invalid")
202202
}
203203
}
204204

address/records.go

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

33
import (
4+
"bytes"
45
"net/url"
56

67
"github.com/btcsuite/btcd/btcec/v2"
@@ -86,8 +87,14 @@ func newAddressTapscriptSiblingRecord(
8687
tapscriptSibling **commitment.TapscriptPreimage) tlv.Record {
8788

8889
sizeFunc := func() uint64 {
89-
// 1 byte for the type, and then the pre-image itself.
90-
return 1 + uint64(len((*tapscriptSibling).SiblingPreimage))
90+
var buf bytes.Buffer
91+
err := commitment.TapscriptPreimageEncoder(
92+
&buf, tapscriptSibling, &[8]byte{},
93+
)
94+
if err != nil {
95+
panic(err)
96+
}
97+
return uint64(len(buf.Bytes()))
9198
}
9299
return tlv.MakeDynamicRecord(
93100
addrTapscriptSiblingType, tapscriptSibling, sizeFunc,

0 commit comments

Comments
 (0)