You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Daniel Cousens 43f724cb0b integration tests: add brainwallet/README examples 11 years ago
..
brainwallet.js integration tests: add brainwallet/README examples 11 years ago
p2sh.js tests: remove unused variable 11 years ago
readme.js integration tests: add brainwallet/README examples 11 years ago

readme.js

var assert = require('assert')

var bitcoin = require('../../')

describe('bitcoinjs-lib (README)', function() {
it('can generate a Bitcoin address from a WIF private key', function() {
var key = bitcoin.ECKey.fromWIF('Kxr9tQED9H44gCmp6HAdmemAzU3n84H3dGkuWTKvE23JgHMW8gct')

assert.equal(key.pub.getAddress().toString(), '19AAjaTUbRjQCMuVczepkoPswiZRhjtg31')
})

it('can create a Transaction', function() {
var tx = new bitcoin.TransactionBuilder()

// Add the input (who is paying) of the form [previous transaction hash, index of the output to use]
tx.addInput("aa94ab02c182214f090e99a0d57021caffd0f195a81c24602b1028b130b63e31", 0)

// Add the output (who to pay to) of the form [payee's address, amount in satoshis]
tx.addOutput("1Gokm82v6DmtwKEB8AiVhm82hyFSsEvBDK", 15000)

// Initialize a private key using WIF
var key = bitcoin.ECKey.fromWIF("L1uyy5qTuGrVXrmrsvHWHgVzW9kKdrp27wBC7Vs6nZDTF2BRUVwy")

// Sign the first input with the new key
tx.sign(0, key)

assert.