mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
loopin: use discovered htlc value for timeout tx
This commit is contained in:
parent
edac1a4054
commit
9aaef3fd07
2 changed files with 6 additions and 9 deletions
10
loopin.go
10
loopin.go
|
|
@ -419,7 +419,7 @@ func (s *loopInSwap) publishOnChainHtlc(ctx context.Context) (bool, error) {
|
|||
// the swap invoice is either settled or canceled. If the htlc times out, the
|
||||
// timeout tx will be published.
|
||||
func (s *loopInSwap) waitForSwapComplete(ctx context.Context,
|
||||
htlc *wire.OutPoint, htlcValue btcutil.Amount) error {
|
||||
htlcOutpoint *wire.OutPoint, htlcValue btcutil.Amount) error {
|
||||
|
||||
// Register the htlc spend notification.
|
||||
rpcCtx, cancel := context.WithCancel(ctx)
|
||||
|
|
@ -445,7 +445,7 @@ func (s *loopInSwap) waitForSwapComplete(ctx context.Context,
|
|||
// checkTimeout publishes the timeout tx if the contract has expired.
|
||||
checkTimeout := func() error {
|
||||
if s.height >= s.LoopInContract.CltvExpiry {
|
||||
return s.publishTimeoutTx(ctx, htlc)
|
||||
return s.publishTimeoutTx(ctx, htlcOutpoint, htlcValue)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
|
@ -572,7 +572,7 @@ func (s *loopInSwap) processHtlcSpend(ctx context.Context,
|
|||
// publishTimeoutTx publishes a timeout tx after the on-chain htlc has expired.
|
||||
// The swap failed and we are reclaiming our funds.
|
||||
func (s *loopInSwap) publishTimeoutTx(ctx context.Context,
|
||||
htlc *wire.OutPoint) error {
|
||||
htlcOutpoint *wire.OutPoint, htlcValue btcutil.Amount) error {
|
||||
|
||||
if s.timeoutAddr == nil {
|
||||
var err error
|
||||
|
|
@ -596,8 +596,8 @@ func (s *loopInSwap) publishTimeoutTx(ctx context.Context,
|
|||
}
|
||||
|
||||
timeoutTx, err := s.sweeper.CreateSweepTx(
|
||||
ctx, s.height, s.htlc, *htlc, s.SenderKey, witnessFunc,
|
||||
s.LoopInContract.AmountRequested, fee, s.timeoutAddr,
|
||||
ctx, s.height, s.htlc, *htlcOutpoint, s.SenderKey, witnessFunc,
|
||||
htlcValue, fee, s.timeoutAddr,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -210,11 +210,8 @@ func testLoopInTimeout(t *testing.T, externalValue int64) {
|
|||
ctx.blockEpochChan <- swap.LoopInContract.CltvExpiry
|
||||
|
||||
// Expect a signing request for the htlc tx output value.
|
||||
//
|
||||
// TODO(joostjager): FIX BUG WHERE WE ALWAYS SIGN FOR THE HTLC AMOUNT.
|
||||
signReq := <-ctx.lnd.SignOutputRawChannel
|
||||
if signReq.SignDescriptors[0].Output.Value !=
|
||||
int64(testLoopInRequest.Amount) {
|
||||
if signReq.SignDescriptors[0].Output.Value != htlcTx.TxOut[0].Value {
|
||||
|
||||
t.Fatal("invalid signing amount")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue