mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
staticaddr: list unspent outputs in server
This commit is contained in:
parent
a1392728ba
commit
eeaf291980
1 changed files with 30 additions and 2 deletions
|
|
@ -26,10 +26,10 @@ func NewAddressServer(addressClient staticaddressrpc.StaticAddressServerClient,
|
|||
|
||||
// NewAddress is the rpc endpoint for loop clients to request a new static
|
||||
// address.
|
||||
func (r *AddressServer) NewAddress(ctx context.Context,
|
||||
func (s *AddressServer) NewAddress(ctx context.Context,
|
||||
_ *looprpc.NewAddressRequest) (*looprpc.NewAddressResponse, error) {
|
||||
|
||||
address, err := r.manager.NewAddress(ctx)
|
||||
address, err := s.manager.NewAddress(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -40,3 +40,31 @@ func (r *AddressServer) NewAddress(ctx context.Context,
|
|||
Address: address.String(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ListUnspent returns a list of utxos behind the static address.
|
||||
func (s *AddressServer) ListUnspent(ctx context.Context,
|
||||
req *looprpc.ListUnspentRequest) (*looprpc.ListUnspentResponse, error) {
|
||||
|
||||
// List all unspent utxos the wallet sees, regardless of the number of
|
||||
// confirmations.
|
||||
staticAddress, utxos, err := s.manager.ListUnspentRaw(
|
||||
ctx, req.MinConfs, req.MaxConfs,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Prepare the list response.
|
||||
var respUtxos []*looprpc.Utxo
|
||||
for _, u := range utxos {
|
||||
utxo := &looprpc.Utxo{
|
||||
StaticAddress: staticAddress.String(),
|
||||
AmountSat: int64(u.Value),
|
||||
Confirmations: u.Confirmations,
|
||||
Outpoint: u.OutPoint.String(),
|
||||
}
|
||||
respUtxos = append(respUtxos, utxo)
|
||||
}
|
||||
|
||||
return &looprpc.ListUnspentResponse{Utxos: respUtxos}, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue