sdk

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 9, 2026 License: MIT Imports: 8 Imported by: 0

README

Peaknode Go SDK

Go client library for the Peaknode Proof of Reserves API.

Installation

go get github.com/kildall/peaknode-sdk-go

Usage

import peaknode "github.com/kildall/peaknode-sdk-go"

client := peaknode.NewClient("https://api.peaknode.io")

Documentation

See DOC.md for detailed SDK documentation.

License

MIT -- see LICENSE for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	BaseURL    string        // Required: API server URL (e.g., "http://localhost:8080")
	Token      string        // Required: Bearer token for authentication
	HTTPClient *http.Client  // Optional: defaults to &http.Client{Timeout: Timeout}
	Timeout    time.Duration // Optional: defaults to 30s when HTTPClient is nil
}

Config holds client configuration. Maps to Cobra CLI flags: --server -> BaseURL, --token -> Token.

type DoneEvent

type DoneEvent struct {
	JobID  string          `json:"job_id"`
	Status string          `json:"status"`
	Result json.RawMessage `json:"result,omitempty"`
	Error  string          `json:"error,omitempty"`
}

DoneEvent matches the server's ScanCompletedEvent format.

type PeaknodeClient

type PeaknodeClient struct {
	*gen.ClientWithResponses
	// contains filtered or unexported fields
}

PeaknodeClient wraps the generated oapi-codegen client with Bearer auth injection.

func NewClient

func NewClient(cfg Config) (*PeaknodeClient, error)

NewClient creates a PeaknodeClient that injects Bearer token auth on every request.

func (*PeaknodeClient) BaseURL

func (c *PeaknodeClient) BaseURL() string

BaseURL returns the configured server base URL.

func (*PeaknodeClient) CheckProof

func (c *PeaknodeClient) CheckProof(ctx context.Context, proofID string, proofData json.RawMessage) (json.RawMessage, error)

CheckProof verifies a Merkle or ZKP proof. Real client: POST /verify/liabilities/:proofId/check

func (*PeaknodeClient) CreateOwnershipProof

func (c *PeaknodeClient) CreateOwnershipProof(ctx context.Context, blockchain, address string) (json.RawMessage, error)

CreateOwnershipProof creates a new ownership proof challenge. Real client: POST /api/ownership

func (*PeaknodeClient) CreateProofOfFunds

func (c *PeaknodeClient) CreateProofOfFunds(ctx context.Context, name, description string) (json.RawMessage, error)

CreateProofOfFunds creates a new proof of funds. Real client: POST /api/funds

func (*PeaknodeClient) CreateProofOfLiabilities

func (c *PeaknodeClient) CreateProofOfLiabilities(ctx context.Context, name, proofMode string) (json.RawMessage, error)

CreateProofOfLiabilities creates a new proof of liabilities. Real client: POST /api/liabilities

func (*PeaknodeClient) CreateWallet

func (c *PeaknodeClient) CreateWallet(ctx context.Context, name, chainID, address string) (json.RawMessage, error)

CreateWallet registers a wallet for the organization. Real client: POST /api/wallets TUI-04 requires wallet registration as the first Funds stage step.

func (*PeaknodeClient) GenerateReport

func (c *PeaknodeClient) GenerateReport(ctx context.Context, format, name string) (json.RawMessage, error)

GenerateReport creates a new report (returns 202 Accepted). Real client: POST /api/reports

func (*PeaknodeClient) GetFundsAssets

func (c *PeaknodeClient) GetFundsAssets(ctx context.Context, proofOfFundsID string) (json.RawMessage, error)

GetFundsAssets retrieves scanned assets for a proof of funds. Real client: GET /api/funds/:id/assets

func (*PeaknodeClient) GetInclusionProof

func (c *PeaknodeClient) GetInclusionProof(ctx context.Context, proofID, userIdentifier, nonce string) (json.RawMessage, error)

GetInclusionProof retrieves a Merkle inclusion proof for a user. Real client: GET /verify/liabilities/:proofId/inclusion?user=X&nonce=Y

func (*PeaknodeClient) GetOwnershipProof

func (c *PeaknodeClient) GetOwnershipProof(ctx context.Context, proofID string) (json.RawMessage, error)

GetOwnershipProof retrieves an ownership proof by ID. Real client: GET /api/ownership/:id

func (*PeaknodeClient) GetProofOfLiabilities

func (c *PeaknodeClient) GetProofOfLiabilities(ctx context.Context, proofID string) (json.RawMessage, error)

GetProofOfLiabilities retrieves a proof of liabilities by ID. Real client: GET /api/liabilities/:id

func (*PeaknodeClient) GetReport

func (c *PeaknodeClient) GetReport(ctx context.Context, reportID string) (json.RawMessage, error)

GetReport polls report status. Real client: GET /api/reports/:id

func (*PeaknodeClient) GetReportDownloadURL

func (c *PeaknodeClient) GetReportDownloadURL(ctx context.Context, reportID string) (json.RawMessage, error)

GetReportDownloadURL retrieves a presigned download URL. Real client: GET /api/reports/:id/download

func (*PeaknodeClient) GetScanJob

func (c *PeaknodeClient) GetScanJob(ctx context.Context, jobID string) (json.RawMessage, error)

GetScanJob retrieves a scan job by ID (for polling fallback). Real client: GET /api/jobs/:id

func (*PeaknodeClient) GetZKPArtifact

func (c *PeaknodeClient) GetZKPArtifact(ctx context.Context, proofOfLiabilitiesID string) (json.RawMessage, error)

GetZKPArtifact retrieves the ZKP artifact for a proof of liabilities. Real client: GET /api/liabilities/:id/zkp-artifact

func (*PeaknodeClient) HealthCheck

func (c *PeaknodeClient) HealthCheck(ctx context.Context) error

HealthCheck performs a lightweight GET /health request to verify server reachability. Used by the TUI for async connection checking (D-07, D-08).

func (*PeaknodeClient) ProcessLiabilities

func (c *PeaknodeClient) ProcessLiabilities(ctx context.Context, proofID string) (json.RawMessage, error)

ProcessLiabilities starts processing and returns the SSE job ID for streaming. Real client: POST /api/liabilities/:id/processing

func (*PeaknodeClient) StartScan

func (c *PeaknodeClient) StartScan(ctx context.Context, proofOfFundsID string) (json.RawMessage, error)

StartScan initiates a balance scan for a proof of funds. Real client: POST /api/funds/:id/scan

func (*PeaknodeClient) StreamProgress

func (c *PeaknodeClient) StreamProgress(ctx context.Context, jobID string) <-chan SSEEvent

StreamProgress connects to the SSE endpoint for the given job and returns a channel of typed events. The channel closes when the stream ends (done event), context is cancelled, or an error occurs. Safe for use in both Bubble Tea (goroutine ranging over channel with p.Send) and batch mode (direct range).

func (*PeaknodeClient) SubmitOwnershipSignature

func (c *PeaknodeClient) SubmitOwnershipSignature(ctx context.Context, proofID, signature string) (json.RawMessage, error)

SubmitOwnershipSignature submits a signature for verification. Real client: POST /api/ownership/:id/verification

func (*PeaknodeClient) UploadLiabilityData

func (c *PeaknodeClient) UploadLiabilityData(ctx context.Context, proofID, filePath string) (json.RawMessage, error)

UploadLiabilityData uploads liability data CSV file. Real client: POST /api/liabilities/:id/data

type ProgressEvent

type ProgressEvent struct {
	JobID    string `json:"job_id"`
	Status   string `json:"status"`
	Progress int    `json:"progress"`
}

ProgressEvent matches the server's ScanProgressEvent format. Uses string for JobID (JSON wire format) -- caller can parse to uuid.UUID if needed.

type SSEEvent

type SSEEvent struct {
	Progress *ProgressEvent
	Done     *DoneEvent
	Error    error
}

SSEEvent represents a parsed Server-Sent Event. Exactly one field is non-nil.

Directories

Path Synopsis
Package gen provides primitives to interact with the openapi HTTP API.
Package gen provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL