libaskexperts
Version:
A TypeScript library to create experts based on NIP-174
68 lines (67 loc) • 2.01 kB
TypeScript
import { ExpertParams } from "./types";
/**
* Expert class that implements the NIP-174 protocol
*
* This class encapsulates all the logic of working with nostr and lightning payments
* for experts who want to participate in the Ask Experts protocol.
*/
export declare class Expert {
private pool;
private nwcClient;
private expertPrivkey;
private expertPubkey;
private askRelays;
private questionRelays;
private hashtags;
private onAskCallback;
private onQuestionCallback;
private bidTimeout;
private min_bid_sats?;
private activeBids;
private subscriptions;
/**
* Create a new Expert
*
* @param params Configuration parameters for the expert
*/
constructor({ nwcString, expertPrivkey, askRelays, questionRelays, hashtags, onAsk, onQuestion, bidTimeout, // Default 10 minutes
min_bid_sats, }: ExpertParams);
/**
* Start listening for asks
*/
start(): void;
/**
* Clean up resources when the expert is disposed
*/
[Symbol.dispose](): void;
/**
* Handle an ask event
*
* @param askEvent The ask event to handle
*/
private handleAskEvent;
/**
* Set up a subscription for questions related to a bid
*
* @param askEvent The original ask event
* @param bidEvent The bid event
* @param bidPayloadEvent The bid payload event
* @param paymentHash The payment hash for the invoice
* @param bid The bid object returned by onAsk
*/
private setupQuestionSubscription;
/**
* Handle a question event
*
* @param questionEvent The question event to handle
* @param activeBid The active bid associated with this question
*/
private handleQuestionEvent;
/**
* Set up a subscription for followup questions
*
* @param answerMessageId The answer message_id tag
* @param activeBid The active bid associated with this conversation
*/
private setupFollowupSubscription;
}