Skip to content

Latest commit

 

History

History
53 lines (37 loc) · 3.18 KB

README.md

File metadata and controls

53 lines (37 loc) · 3.18 KB

Build Status Coverage Status

This is an implementation of an SPV node on the Bitcoin network using Scala & Bitcoin-S-Core.

Our implementation relies heavily on Akka, which has an implementation of the Actor model in Scala. If you want to read more about Akka and what it is/how it is used, it is best to start reading here.

Examples

Look inside of Main.scala for example of creating a PaymentActor, that montiors an address. Once a transaction that pays to the address is included in a block, it sends a message back to your actor saying a payment was successful.

package org.bitcoins.spvnode

import org.bitcoins.core.config.TestNet3
import org.bitcoins.core.crypto.{DoubleSha256Digest, Sha256Hash160Digest}
import org.bitcoins.core.protocol.blockchain.TestNetChainParams
import org.bitcoins.core.protocol.{BitcoinAddress, P2PKHAddress}
import org.bitcoins.core.util.BitcoinSUtil
import org.bitcoins.spvnode.constant.Constants
import org.bitcoins.spvnode.networking.PaymentActor
import org.bitcoins.spvnode.networking.sync.BlockHeaderSyncActor

/**
  * Created by chris on 8/29/16.
  */
object Main extends App {


  override def main(args : Array[String]) = {
    val blockHeaderSyncActor = BlockHeaderSyncActor(Constants.actorSystem)
    val gensisBlockHash = TestNetChainParams.genesisBlock.blockHeader.hash
    val startHeader = BlockHeaderSyncActor.StartHeaders(Seq(gensisBlockHash))
    blockHeaderSyncActor ! startHeader
  }
}

If you want to see more logging for the networking stuff, adjust your logback.xml file to DEBUG.

After that, you are ready to fire up your spv node with this command:

chris@chris-870Z5E-880Z5E-680Z5E:~/dev/bitcoins-spv-node$ sbt run

After that, you should start seeing headers being synced to your node. The headers are stored inside of a file called block_headers.dat file inside of src/main/resources. Note that this does not use any checkpointing system, so to sync up all ~930,000 headers on TestNet3 will take awhile.

Perisistent storage

For more information on how we store block headers in our spv node, please read database_documentation

Syncing our node

For more information on syncing our node with the peer to peer network, please read header_sync