Skip to content

Instantly share code, notes, and snippets.

@NCrashed
Last active May 4, 2022 15:01
Show Gist options
  • Save NCrashed/0e973078c628c28bdf112f0b7054c554 to your computer and use it in GitHub Desktop.
Save NCrashed/0e973078c628c28bdf112f0b7054c554 to your computer and use it in GitHub Desktop.

Submarine 0 trust rebalance

  1. Alice opens 4M channel to Bob.
  2. Bob selects a random password P and calculates ripemd160 hash of it H(P).
  3. Bob locks 2M sats to the output with the script:
OP_SIZE 32 OP_EQUAL
OP_IF
OP_HASH160 <H(P)> OP_EQUALVERIFY
    <Alice pubkey>
OP_ELSE
    OP_DROP
    <cltv timeout> OP_CHECKLOCKTIMEVERIFY OP_DROP
    <Bob pubkey>
OP_ENDIF
OP_CHECKSIG

Proposed cltv timeout is 2000 blocks.

  1. Bobs generates invoice for 2M sats with preimage P and hash H(P).
  2. Alice pays the invoice and gets P from the proof of payment of HTLC.
  3. Alice spends locked onchain funds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment