https://github.com/bitcoin-s/bitcoin-s-spv-node
This is a implementation of an spv node using bitcoin-s-core
https://github.com/bitcoin-s/bitcoin-s-spv-node
Last synced: 12 days ago
JSON representation
This is a implementation of an spv node using bitcoin-s-core
- Host: GitHub
- URL: https://github.com/bitcoin-s/bitcoin-s-spv-node
- Owner: bitcoin-s
- License: mit
- Created: 2016-05-21T18:17:49.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-10-03T19:03:56.000Z (over 8 years ago)
- Last Synced: 2025-04-16T17:28:27.405Z (15 days ago)
- Language: Scala
- Size: 49.1 MB
- Stars: 18
- Watchers: 6
- Forks: 11
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/bitcoin-s/bitcoin-s-spv-node) [](https://coveralls.io/github/bitcoin-s/bitcoin-s-spv-node?branch=master)
This is an implementation of an SPV node on the Bitcoin network using Scala & [Bitcoin-S-Core](https://github.com/bitcoin-s/bitcoin-s-core).
Our implementation relies heavily on [Akka](http://akka.io/), which has an implementation of the [Actor model](https://en.wikipedia.org/wiki/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](http://doc.akka.io/docs/akka/2.4/scala.html).
# ExamplesLook inside of [Main.scala](https://github.com/Christewart/bitcoin-s-spv-node/blob/networking/src/main/scala/org/bitcoins/spvnode/Main.scala) for example of creating a [`PaymentActor`](https://github.com/Christewart/bitcoin-s-spv-node/blob/networking/src/main/scala/org/bitcoins/spvnode/networking/PaymentActor.scala), 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.
```scala
package org.bitcoins.spvnodeimport 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](https://github.com/Christewart/bitcoin-s-spv-node/blob/networking/src/main/resources/logback.xml#L18) file to DEBUG.
After that, you are ready to fire up your spv node with this command:
```bash
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](https://github.com/Christewart/bitcoin-s-spv-node/blob/database_documentation/doc/database_setup.md)
### Syncing our node
For more information on syncing our node with the peer to peer network, please read [header_sync](https://github.com/Christewart/bitcoin-s-spv-node/blob/database_documentation/doc/header_sync.md)