diff --git a/staticaddr/address/manager.go b/staticaddr/address/manager.go index 6420db97..8932d4dd 100644 --- a/staticaddr/address/manager.go +++ b/staticaddr/address/manager.go @@ -82,7 +82,7 @@ func (m *Manager) NewAddress(ctx context.Context) (*btcutil.AddressTaproot, m.Unlock() - return m.getTaprootAddress(clientPubKey, serverPubKey, expiry) + return m.GetTaprootAddress(clientPubKey, serverPubKey, expiry) } m.Unlock() @@ -166,14 +166,15 @@ func (m *Manager) NewAddress(ctx context.Context) (*btcutil.AddressTaproot, log.Infof("Imported static address taproot script to lnd wallet: %v", addr) - return m.getTaprootAddress( + return m.GetTaprootAddress( clientPubKey.PubKey, serverPubKey, int64(serverParams.Expiry), ) } -func (m *Manager) getTaprootAddress(clientPubkey, - serverPubkey *btcec.PublicKey, expiry int64) (*btcutil.AddressTaproot, - error) { +// GetTaprootAddress returns a taproot address for the given client and server +// public keys and expiry. +func (m *Manager) GetTaprootAddress(clientPubkey, serverPubkey *btcec.PublicKey, + expiry int64) (*btcutil.AddressTaproot, error) { staticAddress, err := script.NewStaticAddress( input.MuSig2Version100RC2, expiry, clientPubkey, serverPubkey, @@ -224,7 +225,7 @@ func (m *Manager) ListUnspentRaw(ctx context.Context, minConfs, } } - taprootAddress, err := m.getTaprootAddress( + taprootAddress, err := m.GetTaprootAddress( staticAddress.ClientPubkey, staticAddress.ServerPubkey, int64(staticAddress.Expiry), ) diff --git a/staticaddr/deposit/interface.go b/staticaddr/deposit/interface.go index dc98f16d..d38cfbaa 100644 --- a/staticaddr/deposit/interface.go +++ b/staticaddr/deposit/interface.go @@ -3,6 +3,8 @@ package deposit import ( "context" + "github.com/btcsuite/btcd/btcec/v2" + "github.com/btcsuite/btcd/btcutil" "github.com/lightninglabs/loop/staticaddr/address" "github.com/lightninglabs/loop/staticaddr/script" "github.com/lightningnetwork/lnd/lnwallet" @@ -41,4 +43,8 @@ type AddressManager interface { // ListUnspent returns a list of utxos at the static address. ListUnspent(ctx context.Context, minConfs, maxConfs int32) ([]*lnwallet.Utxo, error) + + // GetTaprootAddress returns a taproot address. + GetTaprootAddress(clientPubkey, serverPubkey *btcec.PublicKey, + expiry int64) (*btcutil.AddressTaproot, error) } diff --git a/staticaddr/deposit/manager_test.go b/staticaddr/deposit/manager_test.go index eeb875f8..49c3d469 100644 --- a/staticaddr/deposit/manager_test.go +++ b/staticaddr/deposit/manager_test.go @@ -103,6 +103,16 @@ func (m *mockAddressManager) ListUnspent(ctx context.Context, args.Error(1) } +func (m *mockAddressManager) GetTaprootAddress(clientPubkey, + serverPubkey *btcec.PublicKey, expiry int64) (*btcutil.AddressTaproot, + error) { + + args := m.Called(clientPubkey, serverPubkey, expiry) + + return args.Get(0).(*btcutil.AddressTaproot), + args.Error(1) +} + type mockStore struct { mock.Mock }