Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

send msg via v2 bot #2260

Open
Evanfeenstra opened this issue Dec 20, 2024 · 0 comments
Open

send msg via v2 bot #2260

Evanfeenstra opened this issue Dec 20, 2024 · 0 comments
Assignees
Labels

Comments

@Evanfeenstra
Copy link
Contributor

Evanfeenstra commented Dec 20, 2024

v2 bot can be used to send msg to hunters if they are on Sphinx

To send a simple text msg to a user, they need to be added first (key exchange must be completed). If the bot invited the user in the first place, then they may already be connected?

First, check if the user exists already:

  • GET /contact/{pubkey}
// returns
export interface Contact {
  version: number;
  my_idx: number;
  pubkey: string;
  lsp: string;
  scid: number;
  contact_key?: string;
}

You must wait until the contact_key is defined, that means the user has signed on and key exchange has been completed

If user does exist:

  • POST /send to send a msg

For simple text msg, set amt_msat=0, is_tribe=false. wait=true will wait until the msg succeeded before returning

// body:
interface PayBody {
  dest: string;
  amt_msat?: number;
  content?: string;
  is_tribe?: boolean;
  reply_uuid?: string;
  msg_type?: number;
  wait?: boolean;
}
// returns:
export interface SendOnionRes {
  status: SendOnionStatus; // "COMPLETE", "PENDING", or "FAILED"
  tag: string;
  preimage?: string;
  payment_hash?: string;
  message?: string; // this is the error message if status==FAILED
}

If user does not exist:

  • POST /add_contact
interface AddContactBody {
  contact_info: string;
  alias?: string;
}

add_contact will send the key exchange request, then you can use get_contact again to check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants