@@ -99,12 +99,12 @@ type TapscriptProof struct {
9999// EncodeRecords returns the encoding records for TapscriptProof.
100100func (p TapscriptProof ) EncodeRecords () []tlv.Record {
101101 records := make ([]tlv.Record , 0 , 3 )
102- if p .TapPreimage1 != nil && len ( p .TapPreimage1 .SiblingPreimage ) > 0 {
102+ if p .TapPreimage1 != nil && ! p .TapPreimage1 .IsEmpty () {
103103 records = append (records , TapscriptProofTapPreimage1Record (
104104 & p .TapPreimage1 ,
105105 ))
106106 }
107- if p .TapPreimage2 != nil && len ( p .TapPreimage2 .SiblingPreimage ) > 0 {
107+ if p .TapPreimage2 != nil && ! p .TapPreimage2 .IsEmpty () {
108108 records = append (records , TapscriptProofTapPreimage2Record (
109109 & p .TapPreimage2 ,
110110 ))
@@ -373,81 +373,68 @@ func (p TapscriptProof) DeriveTaprootKeys(internalKey *btcec.PublicKey) (
373373 // hashes. In this case, the tapscript tree has two elements, with both
374374 // of them being leaves.
375375 case ! p .TapPreimage1 .IsEmpty () && ! p .TapPreimage2 .IsEmpty () &&
376- p .TapPreimage1 .SiblingType == commitment .LeafPreimage &&
377- p .TapPreimage2 .SiblingType == commitment .LeafPreimage :
376+ p .TapPreimage1 .Type () == commitment .LeafPreimage &&
377+ p .TapPreimage2 .Type () == commitment .LeafPreimage :
378378
379- leafHash1 , err := commitment .TapLeafHash (
380- p .TapPreimage1 .SiblingPreimage ,
381- )
379+ leafHash1 , err := p .TapPreimage1 .TapHash ()
382380 if err != nil {
383381 return nil , err
384382 }
385- leafHash2 , err := commitment .TapLeafHash (
386- p .TapPreimage2 .SiblingPreimage ,
387- )
383+
384+ leafHash2 , err := p .TapPreimage2 .TapHash ()
388385 if err != nil {
389386 return nil , err
390387 }
391388
392- rootHash := commitment .NewTapBranchHash (* leafHash1 , * leafHash2 )
389+ rootHash := asset .NewTapBranchHash (* leafHash1 , * leafHash2 )
393390 tapscriptRoot = rootHash [:]
394391
395392 // Two pre-images are specified, with both of the pre-images being a
396393 // branch. In this case, we don't know how many elements the tree has,
397394 // we just care that these are actually branches and the hash up
398395 // correctly.
399396 case ! p .TapPreimage1 .IsEmpty () && ! p .TapPreimage2 .IsEmpty () &&
400- p .TapPreimage1 .SiblingType == commitment .BranchPreimage &&
401- p .TapPreimage2 .SiblingType == commitment .BranchPreimage :
397+ p .TapPreimage1 .Type () == commitment .BranchPreimage &&
398+ p .TapPreimage2 .Type () == commitment .BranchPreimage :
402399
403- branch1 , err := commitment .TapBranchHash (
404- p .TapPreimage1 .SiblingPreimage ,
405- )
400+ branch1 , err := p .TapPreimage1 .TapHash ()
406401 if err != nil {
407402 return nil , err
408403 }
409- branch2 , err := commitment .TapBranchHash (
410- p .TapPreimage2 .SiblingPreimage ,
411- )
404+ branch2 , err := p .TapPreimage2 .TapHash ()
412405 if err != nil {
413406 return nil , err
414407 }
415408
416- rootHash := commitment .NewTapBranchHash (* branch1 , * branch2 )
409+ rootHash := asset .NewTapBranchHash (* branch1 , * branch2 )
417410 tapscriptRoot = rootHash [:]
418411
419412 // Two pre-images are specified, with one of them being a leaf and the
420413 // other being a branch. In this case, we have an un-balanced tapscript
421414 // tree. We'll verify the first sibling is a leaf, and the other is
422415 // actually a branch.
423416 case ! p .TapPreimage1 .IsEmpty () && ! p .TapPreimage2 .IsEmpty () &&
424- p .TapPreimage1 .SiblingType == commitment .LeafPreimage &&
425- p .TapPreimage2 .SiblingType == commitment .BranchPreimage :
417+ p .TapPreimage1 .Type () == commitment .LeafPreimage &&
418+ p .TapPreimage2 .Type () == commitment .BranchPreimage :
426419
427- leafHash , err := commitment .TapLeafHash (
428- p .TapPreimage1 .SiblingPreimage ,
429- )
420+ leafHash , err := p .TapPreimage1 .TapHash ()
430421 if err != nil {
431422 return nil , err
432423 }
433424
434- branchHash , err := commitment .TapBranchHash (
435- p .TapPreimage2 .SiblingPreimage ,
436- )
425+ branchHash , err := p .TapPreimage2 .TapHash ()
437426 if err != nil {
438427 return nil , err
439428 }
440429
441- rootHash := commitment .NewTapBranchHash (* leafHash , * branchHash )
430+ rootHash := asset .NewTapBranchHash (* leafHash , * branchHash )
442431 tapscriptRoot = rootHash [:]
443432
444433 // Only a single pre-image was specified, and the pre-image is a leaf.
445- case ! p .TapPreimage1 .IsEmpty () &&
446- p .TapPreimage1 .SiblingType == commitment .BranchPreimage :
434+ case ! p .TapPreimage1 .IsEmpty () && p . TapPreimage2 . IsEmpty () &&
435+ p .TapPreimage1 .Type () == commitment .LeafPreimage :
447436
448- tapHash , err := commitment .TapLeafHash (
449- p .TapPreimage1 .SiblingPreimage ,
450- )
437+ tapHash , err := p .TapPreimage1 .TapHash ()
451438 if err != nil {
452439 return nil , err
453440 }
0 commit comments