mirror of
https://github.com/aljazceru/ark.git
synced 2026-02-09 05:24:48 +01:00
[SDK] Export ListVtxos (#282)
This commit is contained in:
committed by
GitHub
parent
c183f99244
commit
e46f2ce392
@@ -3,6 +3,7 @@ package arksdk
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/ark-network/ark/pkg/client-sdk/client"
|
||||
"github.com/ark-network/ark/pkg/client-sdk/store"
|
||||
)
|
||||
|
||||
@@ -26,6 +27,7 @@ type ArkClient interface {
|
||||
) (string, error)
|
||||
SendAsync(ctx context.Context, withExpiryCoinselect bool, receivers []Receiver) (string, error)
|
||||
ClaimAsync(ctx context.Context) (string, error)
|
||||
ListVtxos(ctx context.Context) ([]client.Vtxo, []client.Vtxo, error)
|
||||
}
|
||||
|
||||
type Receiver interface {
|
||||
|
||||
@@ -209,6 +209,26 @@ func (a *arkClient) Receive(ctx context.Context) (string, string, error) {
|
||||
return offchainAddr, onchainAddr, nil
|
||||
}
|
||||
|
||||
func (a *arkClient) ListVtxos(
|
||||
ctx context.Context,
|
||||
) (spendableVtxos, spentVtxos []client.Vtxo, err error) {
|
||||
offchainAddrs, _, _, err := a.wallet.GetAddresses(ctx)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, addr := range offchainAddrs {
|
||||
spendable, spent, err := a.client.ListVtxos(ctx, addr)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
spendableVtxos = append(spendableVtxos, spendable...)
|
||||
spentVtxos = append(spentVtxos, spent...)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (a *arkClient) ping(
|
||||
ctx context.Context, paymentID string,
|
||||
) func() {
|
||||
|
||||
Reference in New Issue
Block a user