Skip to content

Instantly share code, notes, and snippets.

@ryandotsmith
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryandotsmith/90ac5c626e1c3e52b9b9 to your computer and use it in GitHub Desktop.
Save ryandotsmith/90ac5c626e1c3e52b9b9 to your computer and use it in GitHub Desktop.
Block Chain U Code Examples Week 1 Lecture 1
var bitcoin = require('bitcoinjs-lib');
var Chain = require('chain-node');
var chain = new Chain({
blockChain: "testnet3"
});
/*
* key = bitcion.ECKey.makeRandom()
* key.toWIF()
* adr = key.pub.getAddress(bitcoin.networks.testnet).toString()
*/
var key = bitcoin.ECKey.fromWIF('L39adbxH2aiSzjx4vGz1BSouYiQSeDruXjSw93LFHDnGFwi9pqdD');
var tx = new bitcoin.TransactionBuilder();
tx.addInput("97eb9638ac8a841bf9bc2c530330a8cd20267e9eca85a57f496beb526587891d", 0);
tx.addOutput("myypZRZu9LWrG1VsEJCR5QkEZAf5TfcjHU", 10000000);
tx.sign(0, key);
var signedHex = tx.build().toHex();
console.log(signedHex);
chain.sendTransaction(signedHex, function(err, resp) {
console.log(err);
console.log(resp);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment