Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@KarolTrzeszczkowski
Last active August 9, 2022 01:11
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save KarolTrzeszczkowski/3f7e719902e8d678efcc71875df66f21 to your computer and use it in GitHub Desktop.
Save KarolTrzeszczkowski/3f7e719902e8d678efcc71875df66f21 to your computer and use it in GitHub Desktop.
Description of p2sh notification protocol

Abstract

The p2sh notification protocol is to pin the p2sh address to the wallets of contract participants and provide aditional informations that will help participants deduce what contract is it.

Motivation

The main motivation of this protocol is to make p2sh smart contracts recoverable from the seed. Some smart contracts, like Licho Last Will or Moser-Eyal-Sirrer vault may be used for long term storage of savings. In this case it is desirable to have a way to reconstruct the contract address just from the seed.

Specification

p2sh notification message is a transaction with 1 OP_RETURN output and as many p2pkh dust outputs as the number of participants of the contract and possibly a change output.

The OP_RETURN output consists of:

protocol ID

0x0048533e, when pushed in little endian order, as suggested here, it is readable as '>sh\x00'.

script hash and contract version

Next part, pushed separately, is the contract address and contract version separated by space (0x20)

additional contract data

This part contains data necesary to reconstruct the script, like a length of timelock used by script or value of payment constrained by the covenant. Data contained here is up to each contract specification.

Example

Exemplary Licho Last Will p2sh notification will have outputs

OP_RETURN, (4) '>sh\x00', (44) 'prvwmkrrzmjxu407w89kndgkfyx4me5qh5jtv2ez6l 1', (10) '30375 1181'

↳ 0,

qpycc7fgqvzt3wkyzpvseau9af3kc9ua2vgnfzd7lp 5,46

qzwwap47fjt9zaah65vuww94dwcg5r5f5gw3wmvujl 5,46

qr3w9wvcnnsvf82f08afa6yty78q78lf6c9getv0z6 5,46

qpc5zfjsakfk9l6uwp3k4hdnlcpv43ztfcpnpf6xp3 79,18

prvwmkrrzmjxu407w89kndgkfyx4me5qh5jtv2ez6l 100,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment