mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
loopdb: refactor the SwapContract to hold all HTLC keys
This commit adds a new struct to hold all HTLC keys and refactors the SwapContract which is used by both loopin and loopout swaps to use this new struct. The newly added internal keys will for now hold the script keys to keep everything equivalent but are already stored and read back if the protocol version is set to MuSig2.
This commit is contained in:
parent
cc5e26b9c9
commit
da4bcbea10
11 changed files with 273 additions and 115 deletions
29
loopin.go
29
loopin.go
|
|
@ -237,16 +237,20 @@ func newLoopInSwap(globalCtx context.Context, cfg *swapConfig,
|
|||
SwapContract: loopdb.SwapContract{
|
||||
InitiationHeight: currentHeight,
|
||||
InitiationTime: initiationTime,
|
||||
ReceiverKey: swapResp.receiverKey,
|
||||
SenderKey: senderKey,
|
||||
ClientKeyLocator: keyDesc.KeyLocator,
|
||||
Preimage: swapPreimage,
|
||||
AmountRequested: request.Amount,
|
||||
CltvExpiry: swapResp.expiry,
|
||||
MaxMinerFee: request.MaxMinerFee,
|
||||
MaxSwapFee: request.MaxSwapFee,
|
||||
Label: request.Label,
|
||||
ProtocolVersion: loopdb.CurrentProtocolVersion(),
|
||||
HtlcKeys: loopdb.HtlcKeys{
|
||||
SenderScriptKey: senderKey,
|
||||
SenderInternalPubKey: senderKey,
|
||||
ReceiverScriptKey: swapResp.receiverKey,
|
||||
ReceiverInternalPubKey: swapResp.receiverKey,
|
||||
ClientScriptKeyLocator: keyDesc.KeyLocator,
|
||||
},
|
||||
Preimage: swapPreimage,
|
||||
AmountRequested: request.Amount,
|
||||
CltvExpiry: swapResp.expiry,
|
||||
MaxMinerFee: request.MaxMinerFee,
|
||||
MaxSwapFee: request.MaxSwapFee,
|
||||
Label: request.Label,
|
||||
ProtocolVersion: loopdb.CurrentProtocolVersion(),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -975,8 +979,9 @@ func (s *loopInSwap) publishTimeoutTx(ctx context.Context,
|
|||
|
||||
sequence := uint32(0)
|
||||
timeoutTx, err := s.sweeper.CreateSweepTx(
|
||||
ctx, s.height, sequence, s.htlc, *htlcOutpoint, s.SenderKey,
|
||||
redeemScript, witnessFunc, htlcValue, fee, s.timeoutAddr,
|
||||
ctx, s.height, sequence, s.htlc, *htlcOutpoint,
|
||||
s.HtlcKeys.SenderScriptKey, redeemScript, witnessFunc,
|
||||
htlcValue, fee, s.timeoutAddr,
|
||||
)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue