Of course, the snippet of code is fairly useless because there’s no way to get money into it. ) PeerGroup peerGroup = new PeerGroup ( params, chain ) peerGroup. Wallet wallet = new Wallet ( params ) BlockChain chain = new BlockChain ( params, wallet.
To use it you need to download the block chain, which will load the wallet up with transactions that can be analyzed and spent.
The Peer/Group will send the wallet transactions which are broadcast across the network before they appear in a block.Ī Wallet starts out its life with no transactions in it, and thus a balance of zero, regardless of what the block chain contains. It will send the wallet blocks as they are received so the wallet can find and extract relevant transactions, that is, transactions which send or receive coins to keys stored within it. The block chain can be passed a Wallet in its constructor. Setupįor optimal operation the wallet needs to be connected to a BlockChain and a Peer or PeerGroup. This article assumes you’ve read Satoshi’s white paper and the WorkingWithTransactions article.
You’ll need to learn how to use the Wallet to build many kinds of apps. It lets you create new transactions which spend the previously stored transactions outputs, and it notifies you when the contents of the wallet have changed. It stores keys and the transactions that assign value to/from those keys. The Wallet class is one of the most important classes in bitcoinj. Learn how to use the wallet class and craft custom transactions with it.