Skip to content

Commit 4ddec87

Browse files
committed
staticaddr: add GetDefaultParameters to address manager
� Conflicts: � staticaddr/withdraw/interface.go
1 parent 3449b29 commit 4ddec87

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

staticaddr/address/manager.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,22 @@ func (m *Manager) GetStaticAddressParameters(ctx context.Context) (*Parameters,
364364
return params[0], nil
365365
}
366366

367+
// GetDefaultParameters returns the parameters of the static address.
368+
func (m *Manager) GetDefaultParameters(ctx context.Context) (*Parameters,
369+
error) {
370+
371+
params, err := m.cfg.Store.GetAllStaticAddresses(ctx)
372+
if err != nil {
373+
return nil, err
374+
}
375+
376+
if len(params) == 0 {
377+
return nil, fmt.Errorf("no static address parameters found")
378+
}
379+
380+
return params[0], nil
381+
}
382+
367383
func (m *Manager) GetParameters(pkScript []byte) *Parameters {
368384
return m.activeStaticAddresses[string(pkScript)]
369385
}

staticaddr/withdraw/interface.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ type AddressManager interface {
3131
// GetStaticAddress returns the deposit address for the given
3232
// client and server public keys.
3333
GetStaticAddress(ctx context.Context) (*script.StaticAddress, error)
34+
35+
// GetDefaultParameters returns the default static address parameters.
36+
// They are used when no other parameters are available, e.g. for
37+
// change outputs of swaps or withdrawals.
38+
GetDefaultParameters(ctx context.Context) (*address.Parameters, error)
3439
}
3540

3641
type DepositManager interface {

0 commit comments

Comments
 (0)