Documentation
¶
Index ¶
- Constants
- Variables
- func CheckAvailability() (bool, error)
- func CreateWorkAsk(ctx context.Context, resolver *AddressResolver, signer address.Address, ...) (int64, error)
- func GetProof(cid cid.Cid) ([]byte, error)
- func GetProofStatus(ctx context.Context, requestCid cid.Cid) (common.ProofResponse, error)
- func PollWork(address string) (common.WorkResponse, error)
- func RequestProof(request common.ProofRequest) (bool, error)
- func RespondWork(ctx context.Context, resolver *AddressResolver, address address.Address, ...) (common.ProofReward, bool, error)
- func Sign(ctx context.Context, resolver *AddressResolver, signer address.Address, ...) (string, error)
- func TokenAmountFromNfil(nfil NFilAmount) abi.TokenAmount
- func UploadProofData(ctx context.Context, proofData []byte) (cid.Cid, error)
- func Verify(ctx context.Context, resolver *AddressResolver, nonceCache *NonceCache, ...) (bool, error)
- func VerifyHexSig(ctx context.Context, resolver *AddressResolver, nonceCache *NonceCache, ...) error
- func WaitForProof(request common.ProofRequest) ([]byte, error)
- func WithdrawAsk(ctx context.Context, resolver *AddressResolver, signer address.Address, ...) error
- type AddressCacheEntry
- type AddressResolver
- type ClientPaymentStatus
- type NFilAmount
- type NonceCache
- type NonceKey
- type PriceResponse
- type Signature
- type SignedMsg
- type Tos
- type WalletAPI
Constants ¶
const AddressCacheSize = 1000
const AddressCacheTTL = 5 * time.Minute
const NonceExpiry = 60 * time.Second
const SkewAllowance = 5 * time.Second
Variables ¶
var MaxRetryTime = 30 * time.Minute
Functions ¶
func CheckAvailability ¶
func CreateWorkAsk ¶
func CreateWorkAsk(ctx context.Context, resolver *AddressResolver, signer address.Address, price abi.TokenAmount) (int64, error)
func GetProofStatus ¶
func GetProofStatus(ctx context.Context, requestCid cid.Cid) (common.ProofResponse, error)
GetProofStatus checks the status of a proof request by ID
func RequestProof ¶
func RequestProof(request common.ProofRequest) (bool, error)
RequestProof submits a proof request to the service
func RespondWork ¶
func RespondWork(ctx context.Context, resolver *AddressResolver, address address.Address, rcid string, proof []byte) (common.ProofReward, bool, error)
func Sign ¶
func Sign(ctx context.Context, resolver *AddressResolver, signer address.Address, dst string, data []byte, nonceTime time.Time) (string, error)
Sign creates a signature for the given data using the provided wallet API and returns it as hex
func TokenAmountFromNfil ¶
func TokenAmountFromNfil(nfil NFilAmount) abi.TokenAmount
TokenAmountFromNfil converts a nanoFIL (nFIL) amount to attoFIL.
func UploadProofData ¶
UploadProofData uploads proof data to the service and returns the CID
func Verify ¶
func Verify(ctx context.Context, resolver *AddressResolver, nonceCache *NonceCache, signer address.Address, data []byte, sig *Signature) (bool, error)
Verify verifies a signature against the given data using the provided resolver and nonce cache
func VerifyHexSig ¶
func VerifyHexSig(ctx context.Context, resolver *AddressResolver, nonceCache *NonceCache, signer address.Address, dst string, data []byte, hexSig string) error
VerifyHexSig deserializes a hex-encoded signature and verifies it
func WaitForProof ¶
func WaitForProof(request common.ProofRequest) ([]byte, error)
WaitForProof submits a proof request and waits for the result
func WithdrawAsk ¶
func WithdrawAsk(ctx context.Context, resolver *AddressResolver, signer address.Address, askID int64) error
Types ¶
type AddressCacheEntry ¶
AddressCacheEntry holds cached address resolution with TTL
type AddressResolver ¶
type AddressResolver struct {
// contains filtered or unexported fields
}
AddressResolver provides cached StateAccountKey lookups
func NewAddressResolver ¶
func NewAddressResolver(wallet WalletAPI) (*AddressResolver, error)
NewAddressResolver creates a new cached address resolver
func (*AddressResolver) ResolveAccountKey ¶
func (ar *AddressResolver) ResolveAccountKey(ctx context.Context, addr address.Address) (address.Address, error)
ResolveAccountKey resolves an address to its account key with caching
type ClientPaymentStatus ¶
type ClientPaymentStatus struct {
Found bool `json:"found"`
Nonce int64 `json:"nonce"`
CumulativeAmountNFil int64 `json:"cumulative_amount_nfil"`
AmountNFil int64 `json:"amount_nfil"`
Signature []byte `json:"signature"`
CreatedAt string `json:"created_at"`
}
ClientPaymentStatus represents the payment status for a client wallet as returned by the backend /client/payment/status/{wallet-id} endpoint.
func GetClientPaymentStatus ¶
func GetClientPaymentStatus(walletID abi.ActorID) (*ClientPaymentStatus, error)
GetClientPaymentStatus retrieves the latest payment status for a given wallet ID.
type NFilAmount ¶
type NFilAmount = int64
func NfilFromTokenAmount ¶
func NfilFromTokenAmount(tokenAmount abi.TokenAmount) (NFilAmount, error)
NfilFromTokenAmount converts a token amount in attoFIL to nanoFIL (nFIL). It returns an error if the token amount is not divisible by 1 nFIL.
type NonceCache ¶
type NonceCache struct {
// contains filtered or unexported fields
}
NonceCache provides thread-safe replay protection using rotating time buckets
func NewNonceCache ¶
func NewNonceCache() *NonceCache
NewNonceCache creates a new NonceCache instance
type NonceKey ¶
type NonceKey struct {
AccountKey string // canonical account key string for consistent hashing
NonceID uint64
}
NonceKey represents a unique combination of account key and nonce ID
type PriceResponse ¶
type PriceResponse struct {
Price int64 `json:"price_nfil"`
PriceNfilBase int64 `json:"price_nfil_base"`
PriceNfilServiceFee int64 `json:"price_nfil_service_fee"`
FeeNum int64 `json:"fee_num"`
FeeDenom int64 `json:"fee_denom"`
Epoch int64 `json:"epoch"`
}
func GetCurrentPrice ¶
func GetCurrentPrice() (PriceResponse, error)
GetCurrentPrice retrieves the current price for proof generation from the service
type SignedMsg ¶
SignedMsg is the signed payload, Sig.Sig = nil for signing bytes
func (*SignedMsg) SigningBytes ¶
type WalletAPI ¶
type WalletAPI interface {
StateAccountKey(context.Context, address.Address, types.TipSetKey) (address.Address, error)
WalletSign(context.Context, address.Address, []byte) (*crypto.Signature, error)
WalletVerify(context.Context, address.Address, []byte, *crypto.Signature) (bool, error)
}
WalletAPI defines the interface for wallet operations