Skip to content

Commit

Permalink
staticaddr/loopin: remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
sputn1ck committed Nov 7, 2024
1 parent 64303f1 commit bbff3d0
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 101 deletions.
11 changes: 0 additions & 11 deletions staticaddr/address/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) (
Expand Down
11 changes: 0 additions & 11 deletions staticaddr/deposit/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) (
Expand Down
11 changes: 0 additions & 11 deletions staticaddr/loopin/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -874,14 +874,3 @@ func byteSliceTo66ByteSlice(b []byte) ([musig2.PubNonceSize]byte, error) {

return res, nil
}

func fromNonces(nonces [][musig2.PubNonceSize]byte) [][]byte {
result := make([][]byte, 0, len(nonces))
for _, nonce := range nonces {
temp := make([]byte, musig2.PubNonceSize)
copy(temp, nonce[:])
result = append(result, temp)
}

return result
}
68 changes: 0 additions & 68 deletions staticaddr/loopin/loopin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit bbff3d0

Please sign in to comment.