From 115558bed539e2fa38abed428a56e0fa2732ebc9 Mon Sep 17 00:00:00 2001 From: sputn1ck Date: Thu, 14 Nov 2024 15:36:03 +0100 Subject: [PATCH] staticaddr/loopin: remove unused code --- staticaddr/address/manager_test.go | 11 ----- staticaddr/deposit/manager_test.go | 11 ----- staticaddr/loopin/loopin.go | 68 ------------------------------ 3 files changed, 90 deletions(-) diff --git a/staticaddr/address/manager_test.go b/staticaddr/address/manager_test.go index 101cef58..68161050 100644 --- a/staticaddr/address/manager_test.go +++ b/staticaddr/address/manager_test.go @@ -54,17 +54,6 @@ func (m *mockStaticAddressClient) PushStaticAddressSweeplessSigs(ctx context.Con args.Error(1) } -func (m *mockStaticAddressClient) FetchSweeplessSweepTx(ctx context.Context, - in *swapserverrpc.FetchSweeplessSweepTxRequest, - opts ...grpc.CallOption) ( - *swapserverrpc.FetchSweeplessSweepTxResponse, error) { - - args := m.Called(ctx, in, opts) - - return args.Get(0).(*swapserverrpc.FetchSweeplessSweepTxResponse), - args.Error(1) -} - func (m *mockStaticAddressClient) PushStaticAddressHtlcSigs(ctx context.Context, in *swapserverrpc.PushStaticAddressHtlcSigsRequest, opts ...grpc.CallOption) ( diff --git a/staticaddr/deposit/manager_test.go b/staticaddr/deposit/manager_test.go index 009f0c4f..d943a32f 100644 --- a/staticaddr/deposit/manager_test.go +++ b/staticaddr/deposit/manager_test.go @@ -73,17 +73,6 @@ func (m *mockStaticAddressClient) PushStaticAddressSweeplessSigs(ctx context.Con args.Error(1) } -func (m *mockStaticAddressClient) FetchSweeplessSweepTx(ctx context.Context, - in *swapserverrpc.FetchSweeplessSweepTxRequest, - opts ...grpc.CallOption) ( - *swapserverrpc.FetchSweeplessSweepTxResponse, error) { - - args := m.Called(ctx, in, opts) - - return args.Get(0).(*swapserverrpc.FetchSweeplessSweepTxResponse), - args.Error(1) -} - func (m *mockStaticAddressClient) PushStaticAddressHtlcSigs(ctx context.Context, in *swapserverrpc.PushStaticAddressHtlcSigsRequest, opts ...grpc.CallOption) ( diff --git a/staticaddr/loopin/loopin.go b/staticaddr/loopin/loopin.go index 4318c4b6..aa7c3a2d 100644 --- a/staticaddr/loopin/loopin.go +++ b/staticaddr/loopin/loopin.go @@ -198,74 +198,6 @@ func (l *StaticAddressLoopIn) createMusig2Session(ctx context.Context, ) } -// createSweeplessSweepTx creates the sweepless sweep transaction that the -// server wishes to publish. It spends the deposit outpoints to a -// server-specified sweep address. -func (l *StaticAddressLoopIn) createSweeplessSweepTx(address btcutil.Address, - feeRate chainfee.SatPerKWeight) (*wire.MsgTx, error) { - // Create the tx. - msgTx := wire.NewMsgTx(2) - - // Add the deposit inputs to the transaction in the order the server - // signed them. - outpoints := l.Outpoints() - for _, outpoint := range outpoints { - msgTx.AddTxIn(&wire.TxIn{ - PreviousOutPoint: outpoint, - }) - } - - // Calculate tx fee for the server provided fee rate. - weight, err := sweeplessSweepWeight(len(outpoints), address) - if err != nil { - return nil, err - } - fee := feeRate.FeeForWeight(weight) - - pkscript, err := txscript.PayToAddrScript(address) - if err != nil { - return nil, err - } - - // Create the sweep output. - sweepOutput := &wire.TxOut{ - Value: int64(l.TotalDepositAmount()) - int64(fee), - PkScript: pkscript, - } - - msgTx.AddTxOut(sweepOutput) - - return msgTx, nil -} - -// sweeplessSweepWeight returns weight units for a sweepless sweep transaction -// with N taproot inputs and one sweep output. -func sweeplessSweepWeight(numInputs int, - sweepAddress btcutil.Address) (lntypes.WeightUnit, error) { - - var weightEstimator input.TxWeightEstimator - for i := 0; i < numInputs; i++ { - weightEstimator.AddTaprootKeySpendInput( - txscript.SigHashDefault, - ) - } - - // Get the weight of the sweep output. - switch sweepAddress.(type) { - case *btcutil.AddressWitnessPubKeyHash: - weightEstimator.AddP2WKHOutput() - - case *btcutil.AddressTaproot: - weightEstimator.AddP2TROutput() - - default: - return 0, fmt.Errorf("invalid sweep address type %T", - sweepAddress) - } - - return weightEstimator.Weight(), nil -} - // signMusig2Tx adds the server nonces to the musig2 sessions and signs the // transaction. func (l *StaticAddressLoopIn) signMusig2Tx(ctx context.Context,