Spec - 4G0R4/celebrity-escrow GitHub Wiki

Libs

  • uses mempool.space api
  • uses nostr
  • uses taprootjs (cuz it will have paths later)

INPUTS TO CONTRACT

  • alice npub
  • bob npub
  • escrow npub
  • alice sats at stake
  • bob sats at stake
  • contract text
  • fee for escrow if he gets involved (optional) 10% or 2ksats

TODO/MISC:

  • alice "start contract" html form
  • bob "accept contract / view contract state" html page
  • escrow "view current contract state" page
  • host + publish form (buy a name & link it up) (s3 bucket + cloudfront) or (cloudflare + github pages)
  • for now website has a set of "standard" nostr relays it uses. we show what they are. alice/bob should just use one for now (to make it easier, later v2 we can do some clever discovery stuff)

ALICE VISITS

  • create the multisig address

    • shax(contract text) + epub
    • bitcoinjs (V2: or taprootjs if we want to deal with the time lock spending path condition of bet never happened)
  • shove whole contract into nostr event

    • nip + celeb escrow
    • json blob of the 6 inputs - ptags as the content
    • p tags alice, bob + escrow
    • event id, make 3 urls out of it
    • bookmark this page ( alice's page)
    • on nostr
      • share this with bob
      • share this with alice
      • share this with escrow as necessary
  • for example stake is 10k sats

    • sign a tx that has 5ks of her own and 5k of "anypay" and 10k as an output to her
    • sign a tx that is ecrow + alice to alice
    • this all goes, presigned, into the nostr event
    • alice needs a button saying bob won

BOB visits the page ( bobs page)

  • sees the same payment address
  • alice has already deposited her share (green check)
  • enter his key
  • sign a tx that is alice + bob to bob
  • sign a tx that is ecrow + bob to bob
  • new event and publish to nostr
  • e tag references alices original event
  • bob also sees the escrow url
  • bob needs a button saying alice won
  • make a page that takes event id and participant id and shows
    • the contract from their perspective
    • bitcoin address to pay to
    • whether it's been paid (mempool.space api)

ESCROW visits his link

  • text explining what this whole thing is
  • contract text
  • give to alice (nostr profile)
  • give to bob (nostr profile)
  • what my cut is of the contract is, if i choose to "decide on it"

SDK

Nostr part of the sdk:

function createContract({
alice_nsec:
alice_pub:
bob_pub:
escrow_pub:
alice_sats:
bob_sats:
escrow_sats:
contract_text:
alice_bob_psbt:
alice_escrow_psbt:
})
  • encrypts a contract-details message with and posts an event encrypted with ecdh (alice priv * bob pub) to kind 3333
  • returns link to website with the 3333 event id
  • (tbd) can dm bob directly if we can look up his profile
function acceptContract({
bob_nsec:
event_id:
bob_escrow_psbt:
})
  • encrypts a contact-details message with psbt and posts to kind 3334 with an e tag of the original event id
  • show a link and say please send this to alice
  • (tbd) can dm alice directly if we can look up her profile

(TBD)

function escrowAlertWinner({
escrow_nsec:
event_id:
})
  • sends 2 DM's one to alice and one to bob letting them know a winner was selected
  • same standard link to the 3333 web page url, from alice/bob's perspective
  • on that page, mempool api will be used to verify what winner was chosen