-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Hand-wavy design
MDFs (mutually distrusting functionaries) will each run a node on each blockchain as well as an API service which will require endpoints like:
/generate?address=<payee address>&nonce=<random nonce>/peg?txid=<transaction hash>/sign?txid=<transaction hash>&tx=<serialized partially signed transaction>
/generate
Someone wanting to pay into a sidechain will hit this endpoint on each MDF with a payee address and a nonce. The MDFs will then record the payee address and nonce and calculate the P2SH address and redeemScript (using Contracthashtool#generate) the user will be paying to.
It returns the P2SH address to pay into on success. Each MDF should return the same result.
/peg
The user will hit this endpoint with the transaction hash of a transaction they made on the blockchain paying to the P2SH address from the previous step after the confirmation period has lapsed. The MDF contacted will create a transaction on the sidechain paying to the payee address with an appropriate output value in accordance with the predefined peg ratio wrt the output amount in the referenced blockchain transaction.
It returns the partially signed sidechain transaction.
/sign
The user will then hit this endpoint of M-1 MDFs to gather the required number of signatures for the sidechain transaction. The txid parameter is the hash of the transaction on the initial blockchain. The tx parameter is the serialized partially signed sidechain transaction. It is assumed that the MDFs can quickly retrieve the payee address and nonce from their database given the P2SH address seen in the output of the txid transaction and feed them into Contracthashtool#claim in order to derive a private key for signing.
It returns the partially (or potentially completely) signed transaction on success.