GithubHelp home page GithubHelp logo

imranmehdi5511 / bitcoin-s-spv-node Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bitcoin-s/bitcoin-s-spv-node

0.0 0.0 0.0 50.26 MB

This is a implementation of an spv node using bitcoin-s-core

License: MIT License

Scala 100.00%

bitcoin-s-spv-node's Introduction

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

bitcoin-s-spv-node's People

Contributors

christewart avatar tommccabe avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.