Skip to content
Evan Feenstra edited this page Mar 24, 2021 · 1 revision

multitenant relay

Apps will need to make some changes:

  • HUB /api/v1/signup POST endpoint now return addition pubkey field (used as described on next item) and new route_hint key inside the invite object returned.
  • the PUT contacts/tokens route requires "pubkey" in body now (the pubkey got from HUB on signup endpoint)
  • When creating INVITER contact record during signup, add route_hint as long as nickname and pubkey (all of them coming inside INVITE object on signup response)
  • "self" contact no longer is guaranteed to have id=1. ALL places in apps where id=1 is checked need to be changed. isOwner needs to be used to find owner record

route hints

  • "route_hint" is a new field on createContact and updateContact route (new text field needs to be added on PROFILE view and CONTACT DETAILS view)

  • "owner_route_hint" on joinTribe route (if it exists on tribe server)

  • "route_hint" should be included in the query for GET /route

    • we will need to figure out a new "contact sharing" string that includes route hint (pubkey:hub_pubkey:chan_id)

HUB needed changes

  • on signup endpoint response add new "pubkey" key with the node pubkey value (invite.node.pubkey)

publishing non-zero node policies to hub

Relay will include a non_zero_policies array in the ping to hub. Each item in the array is an object with:

{
  chan_id: string,
  node: string, // "node1_policy" or "node2_policy"
  fee_base_msat: number
}

tribes

group type = 2

joining

Scanning QR code will give you sphinx.chat://?action=tribe&uuid=xxxxx&host=tribes.sphinx.chat

Then you can call https://{host}/tribes/{uuid} to get the full details to display:

{
  name,
  description,
  img,
  groupKey,
  host,
  uuid,
  priceToJoin,
  pricePerMessage,
}

To actually join, you can POST to /tribe with the name,uuid,group_key,host,img,amount (amount is the priceToJoin), which will add that chat to your relay DB, and subscribe you to the group chat.

creating tribe

same POST to /group, with new params:

{
  is_tribe: true,   // lets just keep this true to start
  is_listed: true,  // lets just keep this true to start
  price_per_message: 100,
  price_to_join: 100,
  img: "https://asdf", // image URL
  description: "hi",
  tags: ["Bitcoin","Sphinx","Lightning"]
}

sending message

Rather than encrypting with the recipient's contact_key, you need to encrypt using the group_key of the group. And send a dictionary with {chat_id: encrypted_message} as the remote_text_map same as always.

displaying messages:

The "contact" for a message might NOT be in relay contacts table, or in device DB. Because of this, simply show the alias attached to the message

create tribe

join tribe

tags