Thursday 13 April 2017

Stamping a hash on the bitcoin blockchain using bitcoinjs-lib?

I'm trying to figure out how to "stamp" a hash on the bitcoin blockchain, basically the idea here it to create a proof of existence of a hash at a given block.

One example i have is this transaction which has the hash "53369b735891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03" as "data_hex" on it's output.

After reading this tutorial, i understood i can create a "raw transaction" and then broadcast it using one of those broadcast pages or bitcoin-core. The problem is, i don't understand:

1 - What is the syntax to create a "dummy" transaction so it only creates this proof and spend minimal amount of money to create this proof

2 - How to set such "output" value and how to know if that is a "best practice", is there a better way of stamping it on the bitcoin blockchain?

I found this code example on the article, but it's very unclear to me

var bitcoin = require(‘bitcoinjs-lib’);
var key = bitcoin.ECKey.fromWIF("L1Kzcyy88LyckShYdvoLFg1FYpB5ce1JmTYtieHrhkN65GhVoq73");
var tx = new bitcoin.TransactionBuilder();
tx.addInput("d18e7106e5492baf8f3929d2d573d27d89277f3825d3836aa86ea1d843b5158b", 1);
tx.addOutput("12idKQBikRgRuZEbtxXQ4WFYB7Wa3hZzhT", 149000);
tx.sign(0, key);
console.log(tx.build().toHex());

  • Where would i get the "input" value?
  • How to set my hash as "output"
  • How to specify what's the fee i'm willing to pay?
  • How to spend the minimal amount of coins necessary for stamping it?

Apologize for such abstract question, i'm not new to coding or bitcoin but the lack of documentation in the library and the complexity of the matter is very puzzling.



via kroe

No comments:

Post a Comment