Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Bitcoin

You're reading from   Learning Bitcoin Embrace the new world of fiance by leveraging the power of crypto-currencies using Bitcoin and the Blockchain

Arrow left icon
Product type Paperback
Published in Oct 2015
Publisher
ISBN-13 9781785287305
Length 236 pages
Edition 1st Edition
Tools
Arrow right icon
Toc

Table of Contents (10) Chapters Close

Sending transactions


In Chapter 5, Installing a Bitcoin Node, we used the Bitcoin node to build, sign, and broadcast a Bitcoin transaction using the createrawtransaction, signrawtransaction, and sendrawtransaction commands.

In this example, we'll perform the same operations but using Javascript and the BitcoinJS library. The process involves the same three steps:

  1. Build a transaction with a list of inputs and outputs.

  2. Sign the transaction with the required private keys.

  3. Broadcast the transaction to the network.

Simple transactions

Using the bitcoinjs library, we will work with the TransactionBuilder object to construct a new transaction. We simply provide the object with one or more private keys as the source of our funds and with one or more addresses for the output, each with the amount we want to send.

Note

For the following examples, real bitcoin can be at stake. Make sure to have backups of your keys before experimenting with them.

In the following example, our script will prompt for the private...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime