Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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