mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
multi: update sweeping to allow different sighashes and claim scripts
Taproot spends require a different sighash, so we update our HtlcScript interface to provide the appropriate sighash when sweeping. We also add distinct Timeout/Success Script functions to allow for tapleaf spends which have different locking scripts for different paths. Note that the timeout and success paths will be the same for segwit v0 htlcs, because it has a single branched script containing all spend paths. In future iterations, this differentiation of claim scripts can also be used to use musig2 to collaboratively keyspend P2TR htlcs with the server. This script can be expressed as PriorityScript (because we'll try to keyspend as a priority, and then fall back to a tap leaf spend). As we've done here, segwit v0 spends would just return their single script for PriorityScript, and the claim would be no different from our other claims.
This commit is contained in:
parent
9610becebd
commit
c7ef4297c0
5 changed files with 121 additions and 39 deletions
|
|
@ -945,14 +945,18 @@ func (s *loopInSwap) publishTimeoutTx(ctx context.Context,
|
|||
return 0, err
|
||||
}
|
||||
|
||||
// Create a function that will assemble our timeout witness.
|
||||
witnessFunc := func(sig []byte) (wire.TxWitness, error) {
|
||||
return s.htlc.GenTimeoutWitness(sig)
|
||||
}
|
||||
|
||||
// Retrieve the full script required to unlock the output.
|
||||
redeemScript := s.htlc.TimeoutScript()
|
||||
|
||||
sequence := uint32(0)
|
||||
timeoutTx, err := s.sweeper.CreateSweepTx(
|
||||
ctx, s.height, sequence, s.htlc, *htlcOutpoint, s.SenderKey,
|
||||
witnessFunc, htlcValue, fee, s.timeoutAddr,
|
||||
redeemScript, witnessFunc, htlcValue, fee, s.timeoutAddr,
|
||||
)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue