Last active
August 29, 2015 14:13
-
-
Save ryandotsmith/90ac5c626e1c3e52b9b9 to your computer and use it in GitHub Desktop.
Block Chain U Code Examples Week 1 Lecture 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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