@@ -1571,6 +1571,7 @@ func encodeTaprootAuxData(w io.Writer, c *ContractResolutions) error {
15711571 })
15721572 }
15731573
1574+ htlcBlobs := newAuxHtlcBlobs ()
15741575 for _ , htlc := range c .HtlcResolutions .IncomingHTLCs {
15751576 htlc := htlc
15761577
@@ -1581,8 +1582,9 @@ func encodeTaprootAuxData(w io.Writer, c *ContractResolutions) error {
15811582 continue
15821583 }
15831584
1585+ var resID resolverID
15841586 if htlc .SignedSuccessTx != nil {
1585- resID : = newResolverID (
1587+ resID = newResolverID (
15861588 htlc .SignedSuccessTx .TxIn [0 ].PreviousOutPoint ,
15871589 )
15881590 //nolint:lll
@@ -1598,10 +1600,14 @@ func encodeTaprootAuxData(w io.Writer, c *ContractResolutions) error {
15981600 tapCase .CtrlBlocks .Val .IncomingHtlcCtrlBlocks [resID ] = bridgeCtrlBlock
15991601 }
16001602 } else {
1601- resID : = newResolverID (htlc .ClaimOutpoint )
1603+ resID = newResolverID (htlc .ClaimOutpoint )
16021604 //nolint:lll
16031605 tapCase .CtrlBlocks .Val .IncomingHtlcCtrlBlocks [resID ] = ctrlBlock
16041606 }
1607+
1608+ htlc .ResolutionBlob .WhenSome (func (b []byte ) {
1609+ htlcBlobs [resID ] = b
1610+ })
16051611 }
16061612 for _ , htlc := range c .HtlcResolutions .OutgoingHTLCs {
16071613 htlc := htlc
@@ -1613,8 +1619,9 @@ func encodeTaprootAuxData(w io.Writer, c *ContractResolutions) error {
16131619 continue
16141620 }
16151621
1622+ var resID resolverID
16161623 if htlc .SignedTimeoutTx != nil {
1617- resID : = newResolverID (
1624+ resID = newResolverID (
16181625 htlc .SignedTimeoutTx .TxIn [0 ].PreviousOutPoint ,
16191626 )
16201627 //nolint:lll
@@ -1632,17 +1639,27 @@ func encodeTaprootAuxData(w io.Writer, c *ContractResolutions) error {
16321639 tapCase .CtrlBlocks .Val .OutgoingHtlcCtrlBlocks [resID ] = bridgeCtrlBlock
16331640 }
16341641 } else {
1635- resID : = newResolverID (htlc .ClaimOutpoint )
1642+ resID = newResolverID (htlc .ClaimOutpoint )
16361643 //nolint:lll
16371644 tapCase .CtrlBlocks .Val .OutgoingHtlcCtrlBlocks [resID ] = ctrlBlock
16381645 }
1646+
1647+ htlc .ResolutionBlob .WhenSome (func (b []byte ) {
1648+ htlcBlobs [resID ] = b
1649+ })
16391650 }
16401651
16411652 if c .AnchorResolution != nil {
16421653 anchorSignDesc := c .AnchorResolution .AnchorSignDescriptor
16431654 tapCase .TapTweaks .Val .AnchorTweak = anchorSignDesc .TapTweak
16441655 }
16451656
1657+ if len (htlcBlobs ) != 0 {
1658+ tapCase .HtlcBlobs = tlv .SomeRecordT (
1659+ tlv.NewRecordT [tlv.TlvType4 ](htlcBlobs ),
1660+ )
1661+ }
1662+
16461663 return tapCase .Encode (w )
16471664}
16481665
@@ -1661,6 +1678,8 @@ func decodeTapRootAuxData(r io.Reader, c *ContractResolutions) error {
16611678 })
16621679 }
16631680
1681+ htlcBlobs := tapCase .HtlcBlobs .ValOpt ().UnwrapOr (newAuxHtlcBlobs ())
1682+
16641683 for i := range c .HtlcResolutions .IncomingHTLCs {
16651684 htlc := c .HtlcResolutions .IncomingHTLCs [i ]
16661685
@@ -1687,7 +1706,12 @@ func decodeTapRootAuxData(r io.Reader, c *ContractResolutions) error {
16871706 htlc .SweepSignDesc .ControlBlock = ctrlBlock
16881707 }
16891708
1709+ if htlcBlob , ok := htlcBlobs [resID ]; ok {
1710+ htlc .ResolutionBlob = fn .Some (htlcBlob )
1711+ }
1712+
16901713 c .HtlcResolutions .IncomingHTLCs [i ] = htlc
1714+
16911715 }
16921716 for i := range c .HtlcResolutions .OutgoingHTLCs {
16931717 htlc := c .HtlcResolutions .OutgoingHTLCs [i ]
@@ -1715,6 +1739,10 @@ func decodeTapRootAuxData(r io.Reader, c *ContractResolutions) error {
17151739 htlc .SweepSignDesc .ControlBlock = ctrlBlock
17161740 }
17171741
1742+ if htlcBlob , ok := htlcBlobs [resID ]; ok {
1743+ htlc .ResolutionBlob = fn .Some (htlcBlob )
1744+ }
1745+
17181746 c .HtlcResolutions .OutgoingHTLCs [i ] = htlc
17191747 }
17201748
0 commit comments