* Remove isInitialized() check in sendMsg, which was causing a deadlock
* Enable akka logging to help debug NeutrinoNodeTest
* Revert to bypassing the isInitialized() check in sendMsg()
* Run scalafmt again
* Remove AKKA_CONFIG that was preventing sane logging for akka, move db-commons reference.conf to testkit so we can control testkit applications, and then rename app/server/.../application.conf to reference.conf like good libraries should do
* Update contributing.md
* update a few more links inside of contributing.md
* Run scalafmt
* Bump Scala versions
Support Scala 2.12.9
and 2.13.0.
To make this easier, we delete the `scripts` project. Everything
that was in here was covered by content on the website. We also
delete the `doc` folder, as that was a remnant from when `scripts`
was called `doc`.
* Crib uPickle akka-http support while we wait for publish
* Fix compiler warnings
* Add note on test logging to contribution guide
* Reduce duplication in Blockchain implementation
* Use Scala 2.12 for website
* Introduce compat package object for collections converters
* Fix Either compiler warnings
* Add sync-chain and create-wallet docs from deleted scripts
* Fix rebase goofup
* Split app loggers into their corresponding modules
This avoids a bunch of places with awkward implicit resolution.
We also make sure that all logging in node, chain and wallet
happens with the app loggers, and not BitcoinSLogger
* Tune test logging level to WARN
* Start refactoring BroadcastTransactionTest to use new SpvNodeFundedWalletBitcoind fixture
* Double timeout to 10.seconds on spv node disconnect
* Attempt to bump disconnect even more
* Add more logging around starting and stoping spv node to try and debug failures with fixtures on test suites
* move starting of spv node into one place in the fixtures -- createSpvNode() --, also look at ordering of destruction to make sure that the spv node is stopped/destroyed BEFORE bitcoind is stopped/destroyed. If the inverse order happens, our spv node won't receive a response from bitcoind and will hang waiting for the Tcp connection to close gracefully
* Try switching from to to get CI to pass
* Add more logging and throws to try and debug failures on ci
* Add logging in the case we send a close command and peer isn't defined
* Match on Tcp.Connect on default receive in P2PClient
* Make SpvNode.disconnect() check to see if we are connected before attempting to disconnect
* Add more logging in fixtures, change behavior of SpvNode.disconnect() to not throw if we are already disconnected
* Switch to preferred way of terminating actor system in tests
* Make PeerMessageSender.sendMsg() return a , make sure a message is not sent to P2PClient until we are fully intialized
* Switch p2p logging to DEBUG
* Complete disconnect promise on peer message recv in the case where we didn't have a peer to begin with
* Make SpvNodeTest more robust, fix bug for when we send 'sendheaders' message. We shouldn't do this until our peer has sent us a verack
* Only send 'sendheaders' message to our peer after we receive a 'sendheaders' message from our peer. Hopefully this solves async issues where we were sending 'sendheaders' before our handshake was fully completed with our peer which means we wouldn't get headers sent to us
* Cleanup pt1
* Start the process of refactoring our ChainHandler to be able to avoid database calls on TipValidation
WIP: Begin explicity passing state back and forth in return types of PeerMessageReceiver, P2PClient, , DataMessageHandler. This commit also implements the ability to keep our blockchain completely in memory. Previously when we were updating the tip of the chain, we had to make a database read to figure out what the best tips are. This is suboptimal for performance because a database read needs to be done for every block header we see, now we just keep the chain in memory
Fix bug in DataMessageHandler that pre-emptively sent a getheadersmsg to our peer. Make 'chainApiF' internal to our spvNode (not a parameter). This forces the chainApi to be created from disk everytime a new SpvNode is spun up. This keeps us in sync with the blockchain at disk at the cost of disk access and less modularity of SpvNode
Address torkel code review
Fix rebase issues
Address code review
Address nadav code review
* Rebase onto master, fix api changes
* Add functionality for updating SPV node bloom filter
* Add SPV node shutdown to exit hook
* Clean up traits/case classes
* Change fixture in WalletBloomTest
* Fix logging bug in TransactionProcessing
* Add MerkleBuffers
In this commit we add MerkleBuffers, which is an object
that lets us aggreagate merkleblocks with their corresponding
transactions before sending them out. This is global, mutable
state (bad!) but it's a working solution for now;
* Use TestAsyncUtil
* Add MerkleBuffers test
* Send getdata if receiving single header
* Change awaitSync to use block count
* Fix UpdateBloomFilterTest
* Add more logging of chain/headers validation
* Send getdata for all blocks
* Nits: Scaladocs, comments toString
* Add logging to data directory
In this commit we add the ability for the node, chain
and wallet projects (+ the server) to log to the users
data directory instead of whatever directory the
binaries was launched from. This is inherently a bit
more complicated than our previous setup, because
we need to read the user directory before we can create
loggers. As a result of this, some files/methods were
moved around, so the relevant app config could be
found in scope.
We also introduce several logging categories that can be
tuned individually through user configuration. These logggers
are exposed both as traits that give a field `logger`, or
as methods that return the required logger.
* Add datadir configuration to AppConfig
In this commit we add support for AppConfig to pick up
the data directory configuration file. We also add
a section to the contributing guide on how to tune
logging levels.
* Pass data directories explicitly for configuration
* This PR is attempting to remove the publishing errors when publish
locally many of which are incorrectly linked things in scaladocs which
there are some differences in formatting. Hopefully this removes alot
if not all of the "link not found for ..." warning messages that show
up.
* Add functionality for broadcasting TXs to node
In this commit we add functionality and tests
for broadcasting a TX from our node. To accomplish
this we introduce a table over broadcastable TXs
that's added to when the externally facing method
broadcastTransaction(tx) withing SpvNode is called.
We send out a inv message for the TX we just added,
and upon receiving a getdata message we search in
the previously mentioned table for entries where
the hashes match up.
* Broadcast TX from server to SPV node
* Perform assertions on the balance of bitcoind after sending a TX
* Remove typeclass from broadcast TX
* Refactor withFundedWalletAndBitcoind
* Match on BitcoindExecption instead of throwable
* Clean up broadcast functionality after code review
* Cleanup
In this commit we cleanup a few Scaladocs and change some
trait/impl pairs into just a case class.
* Node cleanup
In this commit we
1) Rename Client to P2PClient. Client is a very generic name.
2) Clean up some Scaladocs
3) Remove some unecessary objects/traits/classes and replace them
with case classes
4) Add trace logging of bytes received in P2PClient
* Attempt to sync with sendheaders
Fix sync with headers by generating one block in regtest to get out of IBD
Fix comment
Add more comments
Add missing actor system import
more clean up
* refactor test case to avoid sleeping the thread
* Log messages more granularely in node
* Add pong message
* Rework P2P service identifier
The old implementation didn't catch the notion
that service identifiers was a bit field where
multiple services could be set at the same time.
* Make Peer take InetSocketAddress
Previously it took NetworkIpAddress.
This doesn't make any sense, as we
need to know the services bitfield
to construct a NetworkIpAddress.
* Clean up logs and toString methods
* Clean up node README and main method
* Make all networks final case objects
* Skip publishing of wallet, node and chain
* Clean up logging of node and chain modules
* Add logging of max height in SpvNodeMain
* Clean up Scaladoc and toStrings
* Add logging configuration as symlinks in node
We'll have to figure out a more stable solution to
configure logging for the SPV node, but for the time
being this is an acceptable solution.
* Fix 2.11 compiler error
* Add getAddressInfo to Wallet API
* Add Bloom filter and event callbacks to SPV node
* Move wallet test trait to testkit
* Test for connecting SPV node with wallet
* Tune logging in SPV node
* Clean up BloomFilter
* Proper toString in inventory and inventorymessage
* Actually pass in callbacks to SPV node
* Fix rebase screwup and partially respond to code review
* Default to file based databases in tests
This is due to issues with deadlocks with
in-memory based databases. We need DBs
to stay alive between connections, but
not across tests.
In DB intensive chain validation tests we
use in-memory databases instead. This
seems like a reasonable tradeoff between
simplicity and speed.
* Make SpvNodeCallbacks contain sequence of functions within
* Make Bloom filter non-optional in SpvNode
* Reshuffle package location of P2P messages
Previously the companion objects for P2P messages
and the actual messages were in different pacakges.
This made them more awkward to use than necessary.
We also clean up some Scaladocs in this commit.
* Move all P2P messages to core
* Replace AppConfig with more specific types
* Rework database configuration
In this commit we:
1) Introduce new database settings for all submodules,
and at the same time remove the singular datbase setting
for the entire project
2) Introduce a new method .initialize on all configs
that is responsible for creating needed directories,
databases and files
3) Introduce a new class BitcoinSAppConfig that wraps
configs for all three other subproject config. We
also provide implicit conversions that enable this
super-config to be passed in wherever a specialized
config is required.
4) Add more tests for our configuration setup.
* Add Ammonite to Docs deps
* WIP: 2018 12 22 node project (#280)
* Add files from old spv node project
src compiling
test files compiling
ran scalafmt
Fix serializer tests
Get non networking test cases to work
WIP: Debug peermessagehandler
Update CRUD, remove all of the Actor craziness. Add DbManagement trait and unit test db
WIP: Rewroking PeerMessageHandler, create Peer, DataMessageHandler, PeerHandler
Reworking Client to handle all tcp messages and message alignment for bitcoin p2p messages
* Wip: Node refactor
* Create node test project, move all node tests into that project and move all generators for the node project into testkit
* Rework ClientTest to use testkit, start minimizing akka usage, implement connect(),isConnected(), disconnect(), isDisconnected() in PeerMessageReceiver
* Create Peer, PeerHandler, PeerMessageSender and PeerMessageReceiver
* update readme about status of node project (#359)
* Add flyway plugin to manage database schemas (#361)
* Add flyway plugin to manage database schemas
* Switch database driver to sqlite3 to be more portable, rework configs for sqlite3
* Set up sqlite database directories and files if they are not already created
* Add torkel's review
* Add chain, wallet, db-commons projects (#367)
* Add chain, wallet, db-commons projects
* Rework db creation logic if they db does not exist
* Add config logging to try to debug travis ci
* Pass explicit class loader for db config
* Remove duplicate call to dbConfig
* Make DbConfig.dbConfig a lazy val
* Remove noisy log
* Add scaladoc to DbConfig
* Switch dbConfig readme paragraphs
* Fix compile issues introduced during rebase onto master with rpc changes (#394)
* WIP: 2019 03 12 tip validation (#378)
* Implement blockchain handling data structures
Add TipValidation happy path
Add more test cases for TipValidation.checkNewTip for badPrevBlockHash and badPOW
Add overflow check, fix endianness bug for checking proof of work
Add pow transition check, refactor difficultyChangeInterval into chain params, add more tests
fix a few nits
Fix compile error, clean up unused import
Remove redundant files from node project
* Implement GetNextWorkRequrired/CalculateNextWorkRequired, move BlockHeaderDAOTest cases into chain project
* Add full POW change check in TipValidation, address code review nits
* Configure logging in chainTest, turn logging OFF in other test projects
* Address code review pt2
* Add coverage minimum for chain project (#398)
* Add coverage minimum for chain project
* Add first Blockchain.connectTip() unit test, switch to a in memory sqlite database for unit tests, starting using fixtures for BlockHeaderDAO in unit tests
* Add tests for ChainHandler.processNewHeader(), ChainHandler.getHeader(), Blockchain.connectTip(). Refactor redundant configurations being passed around excessivly
* Address code review, fix a flaky test in ClientTest.scala
* Test Fixtures (#403)
* Working test fixtures
* Removed ChainTestFixture trait in main code
* Composing Fixtures (#413)
* Downloaded over 9000 mainnet BlockHeaders into a json file
* Added new fixture with populated blockHeaderDAO
* Split writing to db into batches
* Rebased
* Simplified fixtures with makeFixture abstraction
* Added util functions for composing builders
* Add integration test between bitcoind <-> zmq <-> bitcoin-s-chain project. Test that we can relay a header from bitcoind over zmq into the bitcoin-s chain project. Redo ZmqConfig to use InetSocketAddress
* Address code review
* wip
* A compiling withBitcoindZmqChainHandler fixture
* Tests passing!
* Made blockHeaderDAO private
* Got 9000 new block headers from 562375 to 571375
* Added offset to populated blockHeaderDAO fixture
* Added scaladocs to fixture things
* Initial wallet: import UTXO and spend it (#391)
* Updates ExtKeyVersion with fromChainParams method
* Add equals to Address
* Update BIP44 classes
* Add ScriptType
* Initial work on wallet support
* Add foreign keys pragma for SQLite
* Add UTXO models and DAO
* Add addres P2WPKH generation and WIP for addUTXO
* Add logging config for wallet
* Add change address generation, proper-ish addUtxo and sendToAddress
* Address code review on #391
* Add empty AES passphrase invariant
* Add poor mans test fixtures
* Add listUtxos, listAddresses and getBalance to wallet API
* Use fixtures from chain project
* Fix CI test failures
* Fix broken up package path
* Updates bloop config for new projects (#424)
* Multi fixture file (#419)
* Created FixtureTag and ChainFixture
Used ChainFixture in BitcoinPowTest
Added implicit conversions for nice syntactic sugar
* Added documentation for multi-fixture
* Made defaultTag a val
* add a logback-test.xml to the wallet project (#433)
* Introduce AppConfig that combines ChainParams and DbConfig (#432)
* 2019 04 23 app config per project db config per project (#434)
* Add DB conf file resolution that works across projects
* Create applicatoin configurations for specific projects, rework DbConfig structures for individual projects. Force network to be mixed into DbConfig rather than DbConfig to be mixed into the network
* Add ammonite to db-commons, remove noisy logs
* remove mixin for DbConfig that required a NetworkDb. Now networkDb is just a field on 'DbConfig', this simplifies things downstream type wise when interacting with the projects AppConfig. This commit also removes a parameter from AppConfig, now only a DbConfig needs to be passed in, and we can derive the network and chain params from the DbConfig. The only exemption is UnitTestDbConfig as it is sometimes handy to specify a different network (i.e. mainnet) when testing
* Turn DbConfig objects to case objects, wrap those case objects in their parent type companion object
* remove cast in Wallet.scala
* Add EnhancedEither class for 2.11 compat (#437)
Add implicit conversion from Either to
2.11-compatible Either-wrapper. Also
remove trailing comma in WalletTestUtil
that breaks 2.11 build.
* Fix CI tests hanging (#438)
* Execute wallet tests sequentially to avoid SQLite deadlocks
* Refactor logback config to reduce duplication
* Use in-memory SQLite DB for unit tests
* Debug prints for DatabaseConfig.forConfig
* Fork JVMs in test to ensure proper in-memory DBs
* Pass in Akka config to Eclair tests, avoid cluttering Akka log output
* Don't fork JVM on node tests'
* Move things out of ChainUnitTest (#448)
* Move things out of ChainUnitTest
* Remove printlns
* 2019 04 29 client test (#449)
* Bump timeout on connect to node test
* Change from isConnected -> isInitialized to avoid the error trying to disconnect before we are fully initialized
* Wrote tests for POW difficulty change calculation and header processing (#429)
Fixed BitcoinPowTest
Rebased onto AppConfig code
Rewrote ChainHandler integration test
Made chain handler test synchronous
Fixed a couple test bugs
Implmented a more efficient getAncestorByHeight
Fixed ChainHandler integration test by using the correct starting conditions
Responded to code review
Responded to more code review
Deleted redundant Pow test
Made BlockHeaderDAO.getAncestorAtHeight use a List for its loop to improve performance
* WIP: Create ChainSync, BitcoindChainHandlerViaRpc, add simple ChainSyncTes… (#450)
* Create ChainSync, BitcoindChainHandlerViaRpc, add simple ChainSyncTest to sync one block from a external bitcoind instance via rpc
* Add check for having the best block hash in our chain state already
* Fix prev block hash to be empty hash if genesis block header
* BlockchainBuilder (#439)
* First commit for implementing a BlockchainBuilder
* use Builder rather than ReusableBuilder to be compatible with scala 2.11.x
* Decouple Blockchain & BlockHeaderDAO
* Rebase onto node, incorporate changes in #429
* Add more comments
* Reverse order of headers in builder
* rebase onot node branch, refactor apis
* DB: Add utility method for listing tables in a DB (#447)
* Node rebase (#458)
* Implement BIP32 path diffing
* Rebase node onto newest HD changes in master
* Fix 2.11 compile errors
* 2019 05 01 wallet ammonite scripts pt2 (#452)
* wip -- not finding testkit in doc worksheet
Wip -- classdef not found for create-wallet.sc
zmq bug
Clean up some logs
nest zmq start in bitcoindF
update jeromq to 0.5.2-SNAPSHOT to get rid of annoying log to stdout
Rebase onto node branch with new configs
Successfully running ammonite script create-wallet.sc
2019 05 01 wallet ammonite scripts pt2 (#25)
* Refactor Ammonite dep
* Add basic error handling in AmmoniteBridge
* Add very basic README for doc project
Fix compile issues after rebasing onto master
Add code to sync our wallet code with bitcoind after creating a tx
* refactor ZMQSubscriber to _hopefully_ avoid hanging when we call context.term(). We do this by closing the socket before calling context.term() and using socket.setLinger()
* Update doc/src/main/scala/org/bitcoins/doc/wallet/create-wallet.sc
Co-Authored-By: Christewart <stewart.chris1234@gmail.com>
* 2019 05 05 sync chain (#460)
* Add code to sync our wallet code with bitcoind after creating a tx
Add script to illustrate how the chain persisted and how to sync against a running bitcoind instance on regtest
* fix bug relating to subtraction operator not being communative in Pow.getNextWorkRequired(). This kept us from being able to switch proof of work intervals correctly
* rename script from persist-chain.sc -> sync-chain.sc
* fix 2.11.x compile issues
* Refactor chain, node, wallet config (#463)
* Refactor chain, node, wallet config
Get rid of NetworkDb, DbConfig
Add proper structure to conf system,
moving everything under the bitcoin-s
root key.
* Remove Scalacheck from node project
* Add doc on configuration
* Add override feature to AppConfig
* Address code review in #463
* Throw if default data dir is used in tests, add Scaladoc to AppConfig
* Add explanations for withOverrides, link to configuration.md from AppConfig
* Fix compile error
* Moves chain fixtures to testkit project (#475)
reset node files
* Store encrypted mnemonic to disk (#462)
* Add WalletStorage object
* Add encrypted mnemonic storage, locked wallet
Add lock and unlock operations to wallet.
Separate between locked and unlock wallet.
* Handle non-existant seed file
* Respond to code review from Chris
* Use val instead of import
* Add doc on how mnemonics are encrypted/stored
* 2019 05 15 spv sync headers (#479)
* Implement SpvNode skeleton, create NodeUnitTest and move it to the testkit
* Implement test case to sync a header via spv into bitcoin-s
* Fix compiler errors
* Make node project Main runnable (#26)
* Add logging configuration to node project
* Make default config workable in non-test environments
* Add more logging of config in BH DAO and AppConfig
* Make Peer id optional
* Make node Main.scala runnable
* Implement Main.scala to sync with a locally running bitcoind instance. You can now run with 'bloop run node' and sync the node if you adjust the parameters inside of Main.scala. This also reworks the structure of 'AppConfig'. It turns the *AppConfig into a case class intead of case objects. This allows us to pass custom configs into those case classes
* Address code review from torkel
* Reintroduce withOverrides (#29)
* Turn off chain validation logs
* Make datadir a parameter to bitcoind config rather than having it implicitly written to the bitcoin.conf file. This was a difference that was occurring in the node branch which had a parameter for the datadir and master which was implicitly writing it to bitcoin.conf
* Add ability to overrwrite conf file except in the case of overwriting the DEFAULT_DATADIR & DEFAULT_CONF
* remove extra Bitcoind.stopServers in WalletIntegrationTest