mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
staticaddr: expose static address to client summary
This commit is contained in:
parent
aa7afa7f73
commit
ea2b3c84f0
3 changed files with 23 additions and 6 deletions
|
|
@ -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),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue