Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyBatchSessionOptions(opts ...BatchSessionOption) error
- func ApplyInitOptions(opts ...InitOption) error
- func ApplyWalletOptions(opts ...WalletOption) error
- type BatchSessionOption
- type InitOption
- type ListVtxosOption
- type SendOffChainOption
- type Wallet
- type WalletOption
- func WithContractHandler(t types.ContractType, h handlers.Handler) WalletOption
- func WithGapLimit(limit uint32) WalletOption
- func WithIdentity(identitySvc identity.Identity) WalletOption
- func WithRefreshDbInterval(d time.Duration) WalletOption
- func WithScheduler(svc scheduler.SchedulerService) WalletOption
- func WithVerbose() WalletOption
- func WithoutAutoSettle() WalletOption
Constants ¶
const HeaderVersion = "go-sdk/0.10.1"
Variables ¶
var ( ErrInvalidLimit = errors.New("limit must be between 1 and 1000") ErrConflictingStatusOption = errors.New( "WithSpendableOnly and WithSpentOnly are mutually exclusive", ) ErrInvalidCursor = errors.New("cursor is malformed") ErrCursorFilterMismatch = errors.New("cursor was issued under a different filter set") ErrEmptyScript = errors.New("script must not be empty") )
var ( ErrNotInitialized = fmt.Errorf("wallet not initialized") ErrIsLocked = fmt.Errorf("wallet is locked") ErrIsSyncing = fmt.Errorf("wallet is still syncing") ErrSettleInProgress = fmt.Errorf("settle in progress, retry later") )
var (
ErrNoFundsToSettle = fmt.Errorf("no funds to settle")
)
var Version = readSDKVersion()
Version reports the SDK's module version as resolved by the Go module system at build time of the importing binary. Populated from runtime/debug.ReadBuildInfo on package init:
- For a binary that imported the SDK via `go get …@vX.Y.Z`, returns "vX.Y.Z".
- For a pseudo-version (commit / branch import), returns "v0.0.0-<utc-timestamp>-<short-commit-sha>".
- For a local replace directive (or `go test ./…` inside the SDK repo itself), returns "(devel)".
- When build info is unavailable (vendored builds without modules, certain test harnesses), returns "unknown".
Wallet.Version() proxies this value, so callers can read either.
Functions ¶
func ApplyBatchSessionOptions ¶
func ApplyBatchSessionOptions(opts ...BatchSessionOption) error
ApplyBatchOptions applies the given BatchSessionOption functions to a new default batchSessionOptions struct and returns the first error encountered, if any. Exposed for use in external (arksdk_test) test packages.
func ApplyInitOptions ¶
func ApplyInitOptions(opts ...InitOption) error
ApplyInitOptions applies the given InitOption functions to a new default initOptions struct and returns the first error encountered, if any. Exposed for use in external (arksdk_test) test packages.
func ApplyWalletOptions ¶ added in v0.10.0
func ApplyWalletOptions(opts ...WalletOption) error
ApplyWalletOptions applies opts to a new default clientOptions and returns the first error encountered, if any. Exposed for use in external (arksdk_test) test packages.
Types ¶
type BatchSessionOption ¶
type BatchSessionOption func(options *batchSessionOptions) error
func WithRetries ¶
func WithRetries(num int) BatchSessionOption
type InitOption ¶
type InitOption func(options *initOptions) error
func WithExplorerURL ¶
func WithExplorerURL(explorerUrl string) InitOption
type ListVtxosOption ¶ added in v0.10.0
type ListVtxosOption func(*listVtxosOpts) error
ListVtxosOption configures a Wallet.ListVtxos call. Options are validated when applied; an invalid option causes ListVtxos to return the corresponding sentinel error.
func WithAssetID ¶ added in v0.10.0
func WithAssetID(id string) ListVtxosOption
WithAssetID restricts results to VTXOs that hold the given asset. Selected VTXOs include all their assets in the response, not just the filtered one.
func WithCursor ¶ added in v0.10.0
func WithCursor(c string) ListVtxosOption
WithCursor resumes pagination from the given opaque cursor. An empty string starts from the first page.
func WithLimit ¶ added in v0.10.0
func WithLimit(n int) ListVtxosOption
WithLimit sets the maximum number of VTXOs to return in one page. Valid range: [1, 1000]. Default and max are both 1000.
func WithScript ¶ added in v0.10.1
func WithScript(script string) ListVtxosOption
WithScript restricts results to VTXOs whose script field exactly matches the given script. An empty string is rejected.
func WithSpendableOnly ¶ added in v0.10.0
func WithSpendableOnly() ListVtxosOption
WithSpendableOnly restricts results to VTXOs with spent = false AND unrolled = false.
func WithSpentOnly ¶ added in v0.10.0
func WithSpentOnly() ListVtxosOption
WithSpentOnly restricts results to VTXOs with spent = true OR unrolled = true.
type SendOffChainOption ¶ added in v0.10.1
type SendOffChainOption = client.SendOption
SendOffChainOption configures a SendOffChain call.
func WithExtraPacket ¶ added in v0.10.1
func WithExtraPacket(packets ...extension.Packet) SendOffChainOption
WithExtraPacket appends extra extension.Packet values to the OP_RETURN extension blob written by SendOffChain. Re-exports client.WithExtraPacket so callers don't need to import client-lib directly.
type Wallet ¶ added in v0.10.0
type Wallet interface {
Version() string
Store() types.Store
Identity() identity.Identity
Explorer() explorer.Explorer
Indexer() indexer.Indexer
Client() client.Client
ContractManager() contract.Manager
Init(ctx context.Context, serverUrl, seed, password string, opts ...InitOption) error
IsLocked(ctx context.Context) bool
Unlock(ctx context.Context, password string) error
Lock(ctx context.Context) error
IsSynced(ctx context.Context) <-chan types.SyncEvent
Balance(ctx context.Context) (*types.Balance, error)
GetAddresses(ctx context.Context) (
onchainAddresses, offchainAddresses, boardingAddresses, redemptionAddresses []string,
err error,
)
NewOffchainAddress(ctx context.Context) (string, error)
NewBoardingAddress(ctx context.Context) (string, error)
NewOnchainAddress(ctx context.Context) (string, error)
IssueAsset(
ctx context.Context,
amount uint64, controlAsset clienttypes.ControlAsset, metadata []asset.Metadata,
) (string, []asset.AssetId, error)
ReissueAsset(
ctx context.Context, assetId string, amount uint64,
) (string, error)
BurnAsset(
ctx context.Context, assetID string, amount uint64,
) (string, error)
SendOffChain(
ctx context.Context, receivers []clienttypes.Receiver, opts ...SendOffChainOption,
) (string, error)
RegisterIntent(
ctx context.Context,
vtxos []clienttypes.Vtxo, boardingUtxos []clienttypes.Utxo, notes []string,
outputs []clienttypes.Receiver, cosignersPublicKeys []string,
) (intentID string, err error)
DeleteIntent(
ctx context.Context,
vtxos []clienttypes.Vtxo, boardingUtxos []clienttypes.Utxo, notes []string,
) error
Settle(ctx context.Context, opts ...BatchSessionOption) (string, error)
CollaborativeExit(
ctx context.Context, addr string, amount uint64, opts ...BatchSessionOption,
) (string, error)
Unroll(ctx context.Context) error
CompleteUnroll(ctx context.Context, to string) (string, error)
OnboardAgainAllExpiredBoardings(ctx context.Context) (string, error)
WithdrawFromAllExpiredBoardings(ctx context.Context, to string) (string, error)
// ListVtxos returns one page of wallet VTXOs plus an opaque cursor for the
// next page. The cursor is empty when there are no more results; callers
// should pass a non-empty cursor back with WithCursor without parsing it.
ListVtxos(ctx context.Context, opts ...ListVtxosOption) ([]clienttypes.Vtxo, string, error)
Dump(ctx context.Context) (seed string, err error)
GetTransactionHistory(ctx context.Context) ([]clienttypes.Transaction, error)
GetTransactionEventChannel(ctx context.Context) <-chan types.TransactionEvent
GetVtxoEventChannel(ctx context.Context) <-chan types.VtxoEvent
GetUtxoEventChannel(ctx context.Context) <-chan types.UtxoEvent
RedeemNotes(ctx context.Context, notes []string) (string, error)
SignTransaction(ctx context.Context, tx string) (string, error)
NotifyIncomingFunds(ctx context.Context, address string) ([]clienttypes.Vtxo, error)
FinalizePendingTxs(ctx context.Context, createdAfter *time.Time) ([]string, error)
Reset(ctx context.Context)
Stop()
// WhenNextSettlement returns the time at which the next automatic settlement
// is scheduled to fire. Returns the zero time.Time when auto-settle is
// disabled or no settlement is currently scheduled.
WhenNextSettlement() time.Time
}
func LoadWallet ¶ added in v0.10.0
func LoadWallet(datadir string, opts ...WalletOption) (Wallet, error)
type WalletOption ¶ added in v0.10.0
type WalletOption func(*walletOptions) error
func WithContractHandler ¶ added in v0.10.0
func WithContractHandler(t types.ContractType, h handlers.Handler) WalletOption
WithContractHandler registers a custom contract handler that the wallet's contract manager will dispatch to for the given contract type. The type must be non-empty, the handler non-nil, and must not collide with another previously registered custom handler. Collisions with a built-in type (default, boarding) are detected at Unlock time via the underlying contract.WithHandler / contract.NewManager checks. Multiple calls are allowed for different types.
func WithGapLimit ¶ added in v0.10.0
func WithGapLimit(limit uint32) WalletOption
WithGapLimit sets the HD wallet discovery gap limit used during startup recovery. Must be at least 20. Can only be set once. If not set, hdGapLimit defaults to 20.
func WithIdentity ¶ added in v0.10.0
func WithIdentity(identitySvc identity.Identity) WalletOption
WithIdentity injects a custom Identity implementation for key management. Can only be set once and must not be nil.
func WithRefreshDbInterval ¶
func WithRefreshDbInterval(d time.Duration) WalletOption
WithRefreshDbInterval sets the interval at which the local database is periodically refreshed from the server. Must be at least 30s. Can only be set once. If not set, refreshDbInterval defaults to 30s.
func WithScheduler ¶ added in v0.10.0
func WithScheduler(svc scheduler.SchedulerService) WalletOption
WithScheduler injects a custom SchedulerService implementation for task scheduling.
func WithoutAutoSettle ¶ added in v0.10.0
func WithoutAutoSettle() WalletOption
WithoutAutoSettle disables the auto-settle feature.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
api-spec
module
|
|
|
Package contract manages the lifecycle of contracts derived from an identity for a Wallet: it owns the per-type handlers, persists the contracts via a pluggable store, and rescans for not-yet tracked contracts to store.
|
Package contract manages the lifecycle of contracts derived from an identity for a Wallet: it owns the per-type handlers, persists the contracts via a pluggable store, and rescans for not-yet tracked contracts to store. |
|
Package identity provides an HD (BIP32/BIP86) implementation of the upstream client-lib identity.Identity interface, backed by a pluggable IdentityStore for persistence.
|
Package identity provides an HD (BIP32/BIP86) implementation of the upstream client-lib identity.Identity interface, backed by a pluggable IdentityStore for persistence. |
|
internal
|
|
|
Package scheduler provides a tiny "at-most-one task in flight" scheduler interface, with a gocron-backed implementation in scheduler/gocron.
|
Package scheduler provides a tiny "at-most-one task in flight" scheduler interface, with a gocron-backed implementation in scheduler/gocron. |
|
Package store is the aggregating factory for the SDK's persistence layer.
|
Package store is the aggregating factory for the SDK's persistence layer. |
|
test
|
|
|
docker
command
#nosec
|
#nosec |