fidelity.link

Spec draft

Overview

A fidelity.link bond is a transaction that sacrifices bitcoins by paying to a P2SH address that can be redeemed by anybody after some time. This is achieved by reveling the redeem script in a standaard OP_RETURN output in the same transaction.

See an example transaction in BlockCypher's block explorer or read more in this blogpost.

Definitions

  • A transaction is said to create a fidelity.link bond when it sacrifices to miners coins that can be redeemed in the future following this specification.
  • This is done by paying to the script:
    <magic string> <target block height> OP_CHECKLOCKTIMEVERIFY OP_DROP
  • Since this is not a standard script, the payment is made using a P2SH output. To ensure that anybody can still spend it, the script (preimage of the P2SH output) is revealed in an OP_RETURN output present in the same transaction. Target block height must be 2015 blocks from the current tip (or more, until OP_CSV is deployed).
  • The magic string is 'https://fidelity.link/', ascii encoded, which helps programs to pattern match fidelity link transactions, and advertises the protocol.

Tools

Sample code

var bitcore = require('bitcore-lib')
var utxo = { /* json result from https://insight.bitpay.com/addr/******/utxo */ }
var tx = new bitcore.Transaction()
tx.from(utxo)
var redeemScript = new bitcore.Script()
  .add(new Buffer('https://fidelity.link/'))
  .add(bitcore.crypto.BN.fromNumber(400000 /* target block height, at least 2015 blocks in the future */).toScriptNumBuffer())
  .add(bitcore.Opcode.OP_CHECKLOCKTIMEVERIFY)
  .add(bitcore.Opcode.OP_DROP)
tx.to(new bitcore.Address(redeemScript), 100 /* amount to pay to bond */)
tx.addData(redeemScript.toBuffer())
tx.sign(/* private key */)
console.log(tx.toString())

About

fidelity.link is open source. Made by Esteban Ordano.

Based on Peter Todd's Fidelity Bonds writeout.