staticaddr: expose static address to client summary

This commit is contained in:
Slyghtning 2024-06-05 13:48:18 +02:00
parent aa7afa7f73
commit ea2b3c84f0
No known key found for this signature in database
GPG key ID: F82D456EA023C9BF
3 changed files with 23 additions and 6 deletions

View file

@ -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),
)

View file

@ -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)
}

View file

@ -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
}