Skip to content

Second brain bridge #88

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

Open
tomastiminskas opened this issue May 5, 2025 · 0 comments
Open

Second brain bridge #88

tomastiminskas opened this issue May 5, 2025 · 0 comments
Assignees

Comments

@tomastiminskas
Copy link
Collaborator

You can use this tribe to test: sphinx.chat://?action=tribeV2&pubkey=02562730251fc79a4299bc15553de1d7e31d8090415cf9d0298029d5fe9214993a&host=tribes.v2.sphinx.chat
tapping on Second Brain icon

Or create a new one and set this url:
https://machinelearning.sphinx.chat/

We need a new database table with LSat name and the following columns:

- identifier: String
- macaroon: String
- paymentRequest: String
- preimage: String?
- issuer: String?
- paths: String?
- metadata: String?
- status: Int
- createdAt: Date?

On first launch you will get a first message:

AUTHORIZE

Message:

- application: sphinx
- type: AUTHORIZE
  1. Show AUTHORIZE popup
  2. On authorize button touched send response
Image

Response:

- application: sphinx
- type: AUTHORIZE
- password: random password length 16 (save locally) - will be used in this session
- pubkey: your public key

GETLSAT

- application: sphinx
- type: GETLSAT
- issuer: machinelearning.sphinx.chat
  1. Search Lsat with issuer and status active (0 = expired, 1 = active)

RESPONSE IF THERE'S NO ACTIVE LSAT

- application: sphinx
- type: GETLSAT
- issuer: machinelearning.sphinx.chat
- password: random password length 16 (save locally)
- success: 0
- macaroon: null
- paymentRequest: null
- preimage: null
- status: null
- identifier: null
- paths: null

RESPONSE IF THERE IS ACTIVE LSAT

- application: sphinx
- type: GETLSAT
- issuer: machinelearning.sphinx.chat
- password: random password length 16 (save locally)
- success: 1
- macaroon: macaroon string
- paymentRequest: payment request string
- preimage: presage string
- status: 1
- identifier: identifier string
- paths: null

SIGN

- application: sphinx
- type: SIGN
- message: string
  1. Sign message using bindings:
Image

SUCCESS RESPONSE

- application: sphinx
- type: SIGN
- password: random password length 16 (save locally)
- success: 1
- signature: signed message

FAILURE RESPONSE

- application: sphinx
- type: SIGN
- password: random password length 16 (save locally)
- success: 0

To be asked for a budget authorizations you need to try to add content. For that tap on + icon the left column and try to add a link of any tweet

SETBUDGET

- application: sphinx
- type: SETBUDGET
  1. Show authorize popup with amount field
  2. On Authorize button touched save budget locally
  3. Sen SETBUDGET RESPONSE
Image

SETBUDGET RESPONSE

- application: sphinx
- type: SETBUDGET
- password: random password length 16 (save locally)
- pubkey: your public key
- budget: 20 (the budget you set on the form)

LSAT

- application: sphinx
- type: LSAT
- issuer: machinelearning.sphinx.chat
- macaroon: macaroon string
- paymentRequest: payment request string
  1. Decode payment request and get amount
  2. Check if can play with current saved budget: check if the amount you entered in authorize popup and you saved locally is enough to pay the payment request amount. If so then subtract the payment request amount to the saved budget and save again (it will be 0 now)
  3. Save LSAT in db with macaroon, paymentRequest, issuer and identifier (get identifier from macaroon using binding idFromMacaroon)
  4. Pay invoice using bindings and wait for settle status (same as we do when paying an invoice). Add a 10 seconds timeout.
  5. On settled save preimage on lsat and send response

SUCCESS RESPONSE

- application: sphinx
- type: LSAT
- success: 1
- budget: 0
- password: random password length 16 (save locally)
- lsat: "LSAT \(lsat.macaroon):\(lsat.preimage ?? "")"  (check format of LSAT value: LSAT string first, then macaroon and preimage separated by :)

FALURE RESPONSE

- application: sphinx
- type: LSAT
- success: 0
- password: random password length 16 (save locally)

If you try to add a new tweet when you just run out of budget you will get the UPDATELSAT message

UPDATELSAT

- application: sphinx
- type: UPDATELSAT
- identifier: identifier string (the identifier of the LSAT you just run out of)
- status: expired
  1. Search Lsat on db by identifier
  2. Update status to expired (0) on db

RESPONSE TO UPDATE LSAT

- application: sphinx
- type: UPDATELSAT
- password: random password length 16 (save locally)
- success: 1
- lsat: "LSAT \(lsat.macaroon):\(lsat.preimage ?? "")"

After this your will get SETBUDGET message again

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

No branches or pull requests

2 participants