Commit Graph

118 Commits

Author SHA1 Message Date
Chris Stewart
7caf0c355b 2019 08 09 Don't use BlockHeaderDAO in TipValidation (#688)
* WIP: De-futurify TipValidatoin.chewNewTip()

* De-futrify POW and TipValidation, now tip connection is done synchronously thanks to our in memory blockchain implementation

* Fix improt issues, unused parameters
2019-08-13 10:33:19 -05:00
Chris Stewart
5d8a4c0ef2 Change 'height' types from Long -> Int. Int.MaxValue is 2147483647, which is an order of magnitude more than current block heights on mainnet/testnet bitcoin (#685) 2019-08-09 09:22:00 -05:00
Chris Stewart
b0b1c1cc42 Start the process of refactoring our ChainHandler to be able to avoid… (#655)
* 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
2019-08-06 13:31:54 -05:00
Torkel Rogstad
46280c9e59 Add functionality for updating SPV node bloom filter (#585)
* 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
2019-08-02 09:22:20 -05:00
cwaldron97
e6dcd1cfb4 Cleaning up Publish Logs (#634)
* 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.
2019-07-31 12:28:22 +02:00
Torkel Rogstad
c64f143628 Fix merkle block parsing error 2019-07-19 10:49:34 +02:00
Nadav Kohen
0013aded27 Removed self-reference infinite loop for LnTaggedFields.apply (#641) 2019-07-17 12:34:33 -05:00
Torkel Rogstad
98db3def4c Merge pull request #590 from torkelrogstad/2019-07-10-addresses
Add notion of address types in wallet
2019-07-16 14:01:03 +02:00
Torkel Rogstad
4bdc7966d0 Add notion of address types in wallet
In this commit we
1) Add the notion of address types in the wallet, and remove
    the emphasis on account types. Users now just request
    a segwit/nested-segwit/legacy address, and we take care
    of querying for the correct account
2) Fix a bug where a wallet could only get addresses for
    its default address type. This was a pretty minor bug,
    where a few values that should have been dynamic was
    hard coded.
2019-07-16 12:36:38 +02:00
Torkel Rogstad
4f4636448c Node cleanup (#591)
* 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
2019-07-13 09:26:00 -05:00
Torkel Rogstad
6c2789135e Add more type identifiers
In this commit we add type identifers for P2P
messages we hadn't previously implemented. Note
that these aren't used anywhere yet.
2019-07-12 11:04:15 +02:00
Torkel Rogstad
48d7bc6c33 Merge pull request #565 from piu130/master
Remove redundant function checkResult and refactor Numbers
2019-07-11 13:01:36 +02:00
Ramon Boss
c9e1d5b421 format code 2019-07-10 13:52:55 +02:00
Ramon Boss
e34b79562b add scala doc and remove deprecated methods 2019-07-10 13:50:00 +02:00
Ramon Boss
512f3ab2f3 use of seperate trait Bounded 2019-07-10 08:40:12 +02:00
Ramon Boss
df4507edef implement isInBound for numbers 2019-07-10 08:39:50 +02:00
Torkel Rogstad
a71aecec52 Process outgoing transactions (#555)
* Split wallet functionality into multiple traits

In this commit we refactor LockedWallet into multiple traits
that provide functionality related to a subset of total wallet
functionality. This has the benefit of making it clear which
methods are helper methods that are only intended to be used
in a very specific setting, and which methods are part of the
internal wallet API that other parts of the wallet can use.

* Rework TransactionOutput and TransactionOutPoint to case classes

* Add extension methods for flattening lists of assertions

* Segregate confirmed and unconfirmed balance methods

* Add test for FutureUtil.sequentially

* Add trace logging of balance fetching

* Process outgoing TXOs

Move TX processing into separate trait, add internal API method

Unify DB representation of TXOs

    Prior to this commit we stored TXO information
    across diferent tables, with joins and tuples
    needed a bunch of places to keep track of
    everything we needed. In this commit we unify
    the tables, leaving us with only one table for
    TXOs.
2019-07-09 06:25:24 -05:00
cwaldron97
307714f33a changed default rpcport from 18332 to 18443 2019-07-08 15:46:22 -05:00
Kai BrĂĽnnler
2f2da68461 remove duplicate duplicate check :) (#575) 2019-07-04 14:54:46 -05:00
rorp
d74a0560b8 [WIP] New Eclair RPC client (#535)
* [WIP] New Eclair RPC client

* channel, close, connect, getinfo, open, peers

* allchannels, allnodes, allupdates

* audit, channels, findroutetonode, forceclose, updaterelayfee

* Initial version of createinvoice

* ShortChannelId: improved error handling and scaladoc

* addressed the PR comments

* parseinvoice, payinvoice, getsentinfo, getreceivedinfo, sendtonode, sendtoroute

* unit tests

* addressed the PR comments

* ws, usablebalances, channelstats, networkfees, getinvoice, listinvoices

* addressed PR comments

* change eclair URL

* cleanup

* addressed comments

* fidex compiler warnings

* Eclair 0.3.1

* scaladoc

* cleanup
2019-07-03 13:38:56 -05:00
Ramon Boss
b3cdb6015c add comment about checking required range in apply 2019-07-03 11:55:15 +02:00
Ramon Boss
ffcfe360a6 remove redundant function checkResult 2019-07-03 11:48:47 +02:00
Chris Stewart
243e6cb65b Add case for empty bloom filter (#561) 2019-07-02 10:39:22 -05:00
Torkel Rogstad
d5a7b7aa0f Merge pull request #534 from torkelrogstad/2019-06-17-wallet-transactions
Process incoming transactions
2019-07-02 11:19:57 +02:00
Ramon Boss
e2585248d9 implement Ordered[T] instead of creating custom methods (#553)
* implement Ordered[T] instead of creating new methods for that

* remove new line

* implement Ordered in LnCurrencyUnit

* implement Ordered in MilliSatoshis

* implement Ordered in ScriptNumber
2019-06-27 09:02:34 -05:00
Torkel Rogstad
0f5669bac3 Rename HDCHain.toAddress 2019-06-27 15:28:08 +02:00
Torkel Rogstad
b3600f4888 DB loggers exposed in logging configuration 2019-06-27 15:28:08 +02:00
Torkel Rogstad
75bf52a431 Add toAddress on HDChain 2019-06-27 15:28:08 +02:00
Torkel Rogstad
db1987b36a Merge pull request #546 from torkelrogstad/2019-06-21-aes-cfb
Use key based encryption in AesCrypt
2019-06-27 12:16:53 +02:00
Torkel Rogstad
66524f8c43 Respond to code review from Chris 2019-06-26 17:24:50 +02:00
Torkel Rogstad
da8c6d0f4b Use explicit constructor for creating AesSalt
This fixes a stack overflow bug where calling
fromBytes called .apply(ByteVector) which called
fromBytes which etc...
2019-06-26 11:26:38 +02:00
Torkel Rogstad
017fad25b1 Merge pull request #547 from cwaldron97/2019-06-21_Siphashkey
SipHashKey
2019-06-25 18:59:31 +02:00
Torkel Rogstad
1b2a959d54 Make AesSalt a factory object 2019-06-25 11:39:20 +02:00
Torkel Rogstad
161db9ff92 Add toBase64/fromBase64 to AesEncryptedData 2019-06-25 11:39:17 +02:00
Nadav Kohen
95dad1fc1d Made GolombFilter extend NetworkElement (#549) 2019-06-24 14:43:04 -05:00
cwaldron97
a457717eb4 scalafmt 2019-06-24 14:12:47 -05:00
cwaldron97
4288014f68 Changes applied from PR Review 2019-06-24 11:51:50 -05:00
Torkel Rogstad
f93b8cadbe Update wallet project to work new AES changes 2019-06-24 17:25:11 +02:00
Torkel Rogstad
d58f3dc715 Update AesCrypt to work with keys
In this commit we update our AesCrypt
functionality to work with AES keys rather
than passphrases that are extended to keys.
This makes it easier to integrate with other
languages, as the key stretching introduces
a bunch of additional parameters to the
actual AES encryption.

We also include tests that verify that we're
able to encrypt/decrypt using Bitcoin-S,
Crypto-JS (JavaScript), pycrypto (Python)
and OpenSSL CLI.
2019-06-24 17:21:41 +02:00
cwaldron97
276a6701f6 fixed all compiler errors and warning 2019-06-21 16:06:44 -05:00
cwaldron97
bea1cd04fb fixing compilation errors 2019-06-21 15:40:39 -05:00
cwaldron97
67683a7131 added ByteVector import statement 2019-06-21 15:08:47 -05:00
cwaldron97
934e89e662 fixed toArray def 2019-06-21 14:54:58 -05:00
cwaldron97
9aa0c7bc1c SipHashKey case class added 2019-06-21 14:48:47 -05:00
Nadav Kohen
67fb821b00 Implemented BIP 157 Block Filter Headers (#532) 2019-06-17 14:52:10 -05:00
Torkel Rogstad
a87858247c Service identifier and node cleanup (#522)
* 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
2019-06-17 14:27:51 -05:00
Nadav Kohen
c89104bfda BIP 158 Golomb-Rice Coded Sets and block filters (#481)
* Implemented GCS (WIP)

Added some of Chris' tests for golombEncode and golombDecode

Fixed GCS.golombDecodeSet

Separated GCS object from GolombFilter class

Added hanging test for set encoding

Fixed property test for encoding and decoding arbitrary sets

Added test for GCS.buildGCS and hashing function consistency

Added method to construct a Block Filter from a Block

Added scaladocs in GCS.scala

Added TempUtxoProvider to make BlockFilter testable

Wrote a test for GolombFilter.matchesHash

Added test for arbitrary data matching in bip 158 filter

Added optional right-padding on GCS BitVector, BlockFilter.fromHex, and got started on BlockFilterTest

Cleaned up Bip158TestCase.fromJsArray

Fixed parsing of test vectors for bip 158

Wrote test for BlockFilter (doesn't pass)

Responded to some code review

Included CompactSizeUInt in filter

Created BitcoinScriptUtil.getDataTokens for output serialization

Wrote test for BitcoinScriptUtil.getDataTokens

Added test for BitcoinScriptUtil on the genesis block

Fixed name

:(

* Fixed SipHash and block serialization!

* Fixed bugs relating to empty scripts, all tests passgit push --force-with-lease nadav 2019-05-28-bip158 !

* Cleaned up BitcoinScriptUtil.getDataTokens and its test

* Responded to code review

* Factored out common code from BlockFilter apply methods

* Some cleanup
2019-06-17 11:17:20 -05:00
Torkel Rogstad
435aef7b0b Pass bloom filter to SPV node (#514)
* 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
2019-06-17 06:48:26 -05:00
Torkel Rogstad
8d141ac450 Generate bloom filters from wallet (#501)
* Add findAll() to CRUD

* Add getAddressInfo to Wallet API

* Insert pubkey into bloomfilter also inserts hash

In this commit we also simplify parts of
BloomFilterTest, and move what used to be in
BloomFilterSpec into BloomFilterTest.

* Add bloom filter generation to wallet

* Add bloom false positive rate to wallet config

* Add logging to SQL errors

* Fix a bug where HDPath.next returned the wrong path

* Add FutureUtil.sequentially

* Make bloom filter size calculation more explicit

* Return Vector of pubkeys instead of Seq

* Verbose handling of address fetching in test
2019-06-12 09:29:20 -05:00
Torkel Rogstad
6de0ba268e Bump P2P + crypto test coverage (#506)
* Rename P2P tests and move generators into correct package

* Add more tests for P2P messages

* Add note on coverage to contributing guide

* Replace network in P2P header with typed network

* Add more P2P tests

* Add more tests for ECPriv and ECPub
2019-06-11 10:01:46 -05:00