Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (s *Client) FetchSwaps() ([]*SwapInfo, error) {
htlc, err := swap.NewHtlc(
GetHtlcScriptVersion(swp.Contract.ProtocolVersion),
swp.Contract.CltvExpiry, swp.Contract.SenderKey,
swp.Contract.ReceiverKey, nil, swp.Hash, swap.HtlcP2WSH,
swp.Contract.ReceiverKey, swp.Hash, swap.HtlcP2WSH,
s.lndServices.ChainParams,
)
if err != nil {
Expand All @@ -216,7 +216,7 @@ func (s *Client) FetchSwaps() ([]*SwapInfo, error) {
htlcNP2WSH, err := swap.NewHtlc(
GetHtlcScriptVersion(swp.Contract.ProtocolVersion),
swp.Contract.CltvExpiry, swp.Contract.SenderKey,
swp.Contract.ReceiverKey, nil, swp.Hash, swap.HtlcNP2WSH,
swp.Contract.ReceiverKey, swp.Hash, swap.HtlcNP2WSH,
s.lndServices.ChainParams,
)
if err != nil {
Expand All @@ -226,7 +226,7 @@ func (s *Client) FetchSwaps() ([]*SwapInfo, error) {
htlcP2WSH, err := swap.NewHtlc(
GetHtlcScriptVersion(swp.Contract.ProtocolVersion),
swp.Contract.CltvExpiry, swp.Contract.SenderKey,
swp.Contract.ReceiverKey, nil, swp.Hash, swap.HtlcP2WSH,
swp.Contract.ReceiverKey, swp.Hash, swap.HtlcP2WSH,
s.lndServices.ChainParams,
)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func testResume(t *testing.T, confs uint32, expired, preimageRevealed,
scriptVersion := GetHtlcScriptVersion(protocolVersion)
htlc, err := swap.NewHtlc(
scriptVersion, pendingSwap.Contract.CltvExpiry, senderKey,
receiverKey, nil, hash, swap.HtlcP2WSH, &chaincfg.TestNet3Params,
receiverKey, hash, swap.HtlcP2WSH, &chaincfg.TestNet3Params,
)
require.NoError(t, err)
require.Equal(t, htlc.PkScript, confIntent.PkScript)
Expand Down
4 changes: 2 additions & 2 deletions loopd/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func viewOut(swapClient *loop.Client, chainParams *chaincfg.Params) error {
s.Contract.CltvExpiry,
s.Contract.SenderKey,
s.Contract.ReceiverKey,
nil, s.Hash, swap.HtlcP2WSH, chainParams,
s.Hash, swap.HtlcP2WSH, chainParams,
)
if err != nil {
return err
Expand Down Expand Up @@ -106,7 +106,7 @@ func viewIn(swapClient *loop.Client, chainParams *chaincfg.Params) error {
s.Contract.CltvExpiry,
s.Contract.SenderKey,
s.Contract.ReceiverKey,
nil, s.Hash, swap.HtlcNP2WSH, chainParams,
s.Hash, swap.HtlcNP2WSH, chainParams,
)
if err != nil {
return err
Expand Down
6 changes: 5 additions & 1 deletion loopin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion loopin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ func testLoopInResume(t *testing.T, state loopdb.SwapState, expired bool,

htlc, err := swap.NewHtlc(
scriptVersion, contract.CltvExpiry, contract.SenderKey,
contract.ReceiverKey, nil, testPreimage.Hash(), swap.HtlcNP2WSH,
contract.ReceiverKey, testPreimage.Hash(), swap.HtlcNP2WSH,
cfg.lnd.ChainParams,
)
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion loopout.go
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,9 @@ func (s *loopOutSwap) sweep(ctx context.Context,
return s.htlc.GenSuccessWitness(sig, s.Preimage)
}

// Retrieve the full script required to unlock the output.
redeemScript := s.htlc.SuccessScript()

remainingBlocks := s.CltvExpiry - s.height
blocksToLastReveal := remainingBlocks - MinLoopOutPreimageRevealDelta
preimageRevealed := s.state == loopdb.StatePreimageRevealed
Expand Down Expand Up @@ -1296,7 +1299,8 @@ func (s *loopOutSwap) sweep(ctx context.Context,
// Create sweep tx.
sweepTx, err := s.sweeper.CreateSweepTx(
ctx, s.height, s.htlc.SuccessSequence(), s.htlc, htlcOutpoint,
s.ReceiverKey, witnessFunc, htlcValue, fee, s.DestAddr,
s.ReceiverKey, redeemScript, witnessFunc, htlcValue, fee,
s.DestAddr,
)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion swap.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (s *swapKit) getHtlc(outputType swap.HtlcOutputType) (*swap.Htlc, error) {
return swap.NewHtlc(
GetHtlcScriptVersion(s.contract.ProtocolVersion),
s.contract.CltvExpiry, s.contract.SenderKey,
s.contract.ReceiverKey, nil, s.hash, outputType,
s.contract.ReceiverKey, s.hash, outputType,
s.swapConfig.lnd.ChainParams,
)
}
Expand Down
Loading