Commit Graph

292 Commits

Author SHA1 Message Date
Nadav Kohen
ea4a5e0c42 Increased test coverage by 0.97% (#1343) 2020-04-20 12:53:51 -05:00
Ben Carman
00e4cf4c95 TransactionSignatureChecker bug fix and tests (#1341)
* TransactionSignatureChecker bug fix and tests

* Add new tests
2020-04-20 08:57:36 -05:00
Nadav Kohen
ec0af42ce4 Removed SingleSigner abstraction and replaced with a simple signSingle method in SignerUtils (#1308) 2020-04-07 14:26:07 -05:00
Chris Stewart
1db6bd059a Remove flaky gcs test that times out (#1301) 2020-04-06 10:54:32 -05:00
Ben Carman
774e03a0f5 P2WSH Signer fix + tests (#1300)
* P2WSH Signer fix + tests

* Respond to review
2020-04-05 07:42:57 -05:00
Chris Stewart
0d60e0f822 Replace all usages of List inside of ScriptParser with Vector (#1280) 2020-03-30 12:28:31 -05:00
Ben Carman
f6515c6779 Give ScriptInterpreter functions to verify a transaction or single input (#1223)
* Add TxSigCompenent constuctor

* Add verifyInputScript to ScriptInterpreter

* Add tests
2020-03-19 07:58:56 -05:00
Nadav Kohen
e0b234843d Bouncy Castle Fallback (#1232)
* Added Bouncy Castle fallback to all Secp calls in ECKey.scala

* Fixed bugs and made ExtKey support use of BouncyCastle

* An attempt to add bouncy castle testing to CI

* Responded to review

* De-coupled libsecp256k1 uses from Bouncy Castle uses

* Responded to review
2020-03-17 13:20:06 -05:00
Nadav Kohen
052b64b7e2 Seq and Map Wrappers (#1131)
* Renamed size to byteSize in NetworkElement to avoid ambiguity

* Introduced SeqWrapper and MapWrapper to allow for wrapper case classes to have direct access to underlying methods

* Responded to review
2020-02-24 14:39:20 -06:00
Chris Stewart
436e1ab1da Reduce GCS generator params again to try and stop timing out on CI (#1144)
* Reduce GCS generator params again to try and stop timing out on CI

* Reduce magic number to 30 as 40 can still fail

* Reduce gain
2020-02-21 11:22:04 -06:00
Ben Carman
cf3dd113b5 Reserved TxoState (#1111)
* Reserved TxoState

* Allow fund transaction handling to mark utxos as Reserved

* Add test, fix overloading default arg issue
2020-02-13 06:51:50 -06:00
Ben Carman
bc34e2d327 Descriptor fixes and test (#1116) 2020-02-13 06:48:15 -06:00
Ben Carman
d1aa6386f0 CLI Commands for PSBTs (#1074)
CLI Commands for PSBTs
2020-01-30 14:50:08 -06:00
Chris Stewart
52f39f0ab8 Attempt to keep GCSTest for timing out on CI (#1075)
* Attempt to keep GCSTest for timing out on CI

* Move more stuff out of generator loop
2020-01-29 20:51:39 +01:00
Ben Carman
77631a4a46 Increase code coverage 2020-01-29 12:01:09 -06:00
rorp
63b4217056 LnInvoice must ignore unknown LN tag fields (#1068) 2020-01-27 08:48:49 -08:00
rorp
8a4d7c5729 Fix the order of LN tag fields in serialized invoces (#1066) 2020-01-23 15:13:29 -06:00
Chris Stewart
f8a21201ac Run test:scalafmt, and enforce it on CI (#1023)
* Run test:scalafmt, and enforce it on CI

* Run test:scalafmt
2020-01-23 14:46:57 -06:00
Nadav Kohen
48f775182b PSBT Support (#1031)
* PSBT Serialization/Deserialization (#917)

* PSBT Serialization and Deserialization

* Remove debug code

* Create PSBTParseResult, Add more psbt test cases, and various small nits

* PSBT version checking

* Remove PSBTHelper, give PSBTRecord and PSBTMap a fromBytes

* Fix compile issue, preserve ADT

* PSBT Combiner

* PSBT Updater

* Fix PSBT version number to be read as little endian

* Make function names more clear, add scaladoc, require not finalized

* Combiner scaladocs

* Test case from BIP

* Make compatible with older versions

* PSBT: Fix for EmptyWitness changes (#968)

* PSBTInputMap to UTXOSigningInfo

* Remove vars

* Add missing param

* Fix byteVectorOrdering for when x == y

* getUTXOSpendingInfo Tests

* Fix formatting errors

* Give conditional path default value

* formatting fix

* Fixed InputPSBTRecord.FinalizedScriptSig using asmBytes (#1004)

* Fixed PSBTTest after rebasing onto master

* PSBT Constructors and Extraction (#997)

* Added PSBT constructors

* Revived option to use signers in toUTXOSpendingInfo

* Added transaction extraction

* Responded to code review

* Added extraction test from BIP

* Added validation (option) to PSBT extraction

* Added property based test for PSBT.extractTransactionAndValidate

* Marked PSBT as new code for PropertyCheckConfiguration

* PSBT Finalizer (#1002)

* Added finalizing functionality to PSBTs

* Cleaned things up

* Added finalizer test, fails

* Check that PSBT is not already finalized when finalizing PSBT

* Added P2PKWithTimeout cases

* Formatting fix

* PSBT Generators (#1019)

* Introduced non-finalized constructor

* Added property based test comparing finalized and un-finalized construction, it currently fails due to EmptyScriptPubKey not being supported in various ways. Also fixed a ton of bugs!

* Fixed easy bugs relating to EmptyScriptPubKey, one is left

* Fixed the last bugs (multisig order and 0-of-n stuff) and now tests pass!

* Separated out direct finalized PSBT construction from non-finalized PSBT construction

* Translated construction work in tests into PSBT generators

* Added serialization symmetry test

* Made PSBT fee generation dependent on other generators to ensure low enough fees for signing

* Responded to code review

* Added scaladocs

* Fixed arbitraryPSBT to work with older scala versions

* Fixed PSBT compilation breakages from rebase

* Fixed test breakages from rebase

* Validate the PSBT unknown is not a known field

* Increase code coverage on PSBT tests

* Address review

* formatting

* Add error messages, rename function

* Psbt Signer (#1025)

* PSBT Signer

* Create addSignature function for PSBTs

* Use PartialSignature instead of Tuple

* Create extra util functions

* scaladoc and simplify case

* Formatting fix for psbt scaladocs

* Clean up code, add error messages, and scaladoc

* add type hints

* Change InputPSBTMap.fromUTXOSpendingInfo to use BitcoinSingleSigner

* optimize import

* Define separator byte for psbt map

* getRecords simplification

* remove braces, add error message

* PSBT stuff assigned to nkohen (#1035)

* Responded to psbt review assigned to me

* Moved separatorByte to a place where all can use it

* PSBT independent record calls (#1037)

* PSBT independent record calls

* move logic to super class

Co-authored-by: Nadav Kohen <nadavk25@gmail.com>

* Reworked PSBT finalization to return a Try[PSBT] rather than an Option[PSBT] (#1036)

* PSBT signer property based tests (#1038)

* PSBT property based tests

* Address review

* PSBT Combiner property based tests (#1039)

* PSBT Combiner property based tests

* Create pruneGlobal util function

* Switch to arbitrary gen

* Use BaseTransaction instead of Transaction

* Fix transaction witness to work from base transactions

* PSBTs response to Chris's review (#1046)

* PSBT chris's review

* Rename val, give master fingerprint a val

* Formatting fix

* Responded to code review from chris assigned to nkohen

* Split PSBT.scala into many files

* PSBT Docs (#1048)

* PSBT docs

* Fix compiler error, remove nesting

* PSBT output updater tests

* Validate psbt outputs

* Clean up code

* Remove P2WPKHWitnessV0 addition

* format

* PSBT Updater property based tests

* Move code to match block

* EmptyScriptWitness check

* Address nadav review

* Remove unnecessary code, make utxo adder better

* Move require and add error message

* Move require

* PSBT unit tests by Ben

* Change to EmptyScriptPubKey

* Added unit tests to increase code coverage

* responded to review

* Move PSBT unit test to separate file

* Make unknown generator only generate distinct records

* Use groupBy key instead of distinct

* use only first element

* Combine distinctness by key

Co-authored-by: Ben Carman <benthecarman@live.com>
2020-01-23 11:36:42 -07:00
Ben Carman
f310b01bd3 Bech32 weakness test vectors (#1056)
* Bech32 weakness test vectors

* bech32 weakness test for ln invoices
2020-01-23 08:53:32 -06:00
Nadav Kohen
512b23ba63 Added PubKey addition functionality (#1051) 2020-01-21 14:30:28 -07:00
Chris Stewart
b8c59b4c93 2020 1 11 accounts (#1022)
* Create 'fundRawTransaction' and 'fundRawTransactionInternal'

* Move TransactionTestUtil to testkit, begin writing tests for fundrawtransaction

* Add FundTransactionTests

* Move things to 'FundTransactionHandling' trait

* Start segregating things by HDAccount in the wallet, this gives us the ability to query for balances based on account, fund a transaction based on an account, generate a new address based on an account etc. All old api calls are now based on the default account, i.e. getBalance() returns the balance for account 0, fundRawTransaction funds the transaction from account 0 etc.

* Fix compile issue with 2.11.x

* Bump address generation Thread.sleep() to 500ms

* Address ben code review

* Address code review
2020-01-21 14:20:58 -06:00
Nadav Kohen
db6447d88a Single Signing (#1020)
* Introduced UTXOSpendingInfoSingle

* Implemented constructors for UTXOSpendingInfoSingle

* Introduced BitcoinSignerSingle

* Implemented SingleSigner

* Added property-based test for SingleSigner, it fails

* Fixed SignerTest :)

* Responded to code review

* Added scaladocs

* Fixed p2sh(p2wsh) signing

* Responded to code review and separated UTXOSpendingInfoSingle from UTXOSpendingInfoFull

* Fixed outputGen after rebase

* Fixed txbuilder.md to show this branch's changes
2020-01-15 10:00:55 -07:00
Chris Stewart
54b2fa814e 2020 1 04 fund raw tx (#1010)
* Create 'fundRawTransaction' and 'fundRawTransactionInternal'

* Move TransactionTestUtil to testkit, begin writing tests for fundrawtransaction

* Add FundTransactionTests

* Move things to 'FundTransactionHandling' trait

* Address code review

* Run scalafmt
2020-01-13 13:45:33 -06:00
Ben Carman
9c00162923 Increase core test coverage 2020-01-08 16:15:55 -06:00
Chris Stewart
0421076b21 Create MaskedToString, implement it in ECPrivateKey, ExtPrivateKey, M… (#1011)
* Create MaskedToString, implement it in ECPrivateKey, ExtPrivateKey, MnemonicCode

* Add MaskedToString to AesPassword, AesKey, and BIP39Seed

* Add final to MaskedToString.toString() so it can't be overriden
2020-01-07 12:31:13 -06:00
rorp
b5d21a5a54 Support for payment secret and features LN invoice tags (#1012) 2020-01-07 10:27:45 -08:00
Chris Stewart
3bedcb20e0 Add more expressive txo states for the wallet (#1001)
* Add more expressive txo states for the wallet

* Rename 'PendingReceived/PendingSpent' -> 'UnconfirmedReceived/UnconfirmedSent'

* Address code review

* Fix posInt implementation to work with older scala versions

* Rename to PendingConfirmationReceived/PendingConfirmationSpent
2020-01-05 18:42:20 -06:00
Chris Stewart
67eb7df235 2019 12 17 sign ext key (#959)
* Create ExtSign, use it on ExtPrivateKey

* Add documentation on how to Sign things with ExtSign

* Add ExtSign.sign for a bip32 path

* Make sign(bytes,path) not return a Future, add documentation

* Address nadav's code review

* Fix mdoc sign.md
2019-12-20 12:47:10 -06:00
Nadav Kohen
c67b2978bf P2PKWithTimeoutSPK (#967)
* Introduced P2PKWithTimeoutSPK

* Responded to review

* Added some testing for cltv and p2pkWithTimeout SPKs

* Responded to more review
2019-12-19 09:48:00 -06:00
Chris Stewart
713d76ae67 Add invariant to WitnessTransaction that says inputs.length == witnes… (#954)
* Add invariant to WitnessTransaction that says inputs.length == witnesses.length

* Remove println

* Address code review
2019-12-17 13:42:58 -06:00
Chris Stewart
388becbc6b 2019 12 10 scalatest 3.1.0 (#933)
* Update scalatest to 3.1.0

* Modify code to support scalatest 3.1.0
2019-12-10 09:12:47 -06:00
Ben Carman
ea15938087 BIP32Path Factory and new tests (#928) 2019-12-10 07:34:00 -06:00
rorp
cbd038b514 Neutrino Wallet: OnCompactFilter handler (#905)
* Neutrino Wallet: OnCompactFilter handler
2019-12-06 13:10:33 -08:00
Nadav Kohen
b2e5337827 Timelock bug fix (#920)
* Fix CLTV bug where timestamps using seconds are not allowed in TxBuilder

* Added test for CLTV second timestamp and ran scalafmt

* Fixed another bug

* Fixed bug where calcLockTime was not looking past first CLTV tx
2019-12-06 10:57:56 -06:00
Nadav Kohen
1578e2642f Nicer Satoshis.apply (#899)
* Replaced Satoshis(Int64(_)) with Satoshis(_)

* Fixed SignerTest
2019-11-26 14:43:14 -06:00
rorp
d6f1e5c0ba Refactor compact filter matching (#838)
* Refactor compact filter matching

* cleanup

* some more changes

* addressed the PR comments

* cleanup

* cleanup
2019-11-26 13:40:19 -06:00
rorp
14d3878d01 Rescan RPC (#854)
* Rescan RPC

* cleanup

* fix optional args

* cleanup

* unit tests

* fix build error

* fix unit tests

* scalaMock

* cleanup

* more unit tests

* some more validation checks
2019-11-21 08:03:32 -06:00
Nadav Kohen
911541cf52 Made ScriptPubKey and ScriptSignature toStrings nicer (#859) 2019-11-18 11:12:38 -06:00
Nadav Kohen
fb2188b7d8 OP_NOTIF ScriptPubKey and Signing (#858)
* Implemented OP_NOTIF

* Responded to code review

* Fixed test bug for sampling
2019-11-18 10:45:33 -06:00
Nadav Kohen
fad72c66d5 Increase some Test Coverage (#866)
* Added ScriptTypeTest

* Added ScriptSignature coverage

* Added Signer test coverage

* Added test coverage for UTXOSpendingInfo

* Responded to code review
2019-11-15 12:21:52 -06:00
Nadav Kohen
609f7e6ad6 ScriptInterpreter Conditional Refactor (#855)
* Redid conditional interpreting without binary trees

* Fixed ControlOperationsInterpreterTest

* Implemented O(1) conditional handling as proposed here https://github.com/bitcoin/bitcoin/pull/16902 because Ben Carman pointed it out

* Added some docs

* Responded to code review
2019-11-08 13:19:53 -06:00
Nadav Kohen
f2081dfa46 OP_IF Signing (#827)
* Introduced ConditionalScriptPubKey

Some more progress

Added Conditional signing infrastracture, tests do not pass and there are no Conditional tests

Fixed tests!

* Redid calcLockTime and calcSequenceForInputs in TxBuilder (added Conditional support)

* Added ScriptGenerators for Conditional scripts, only one test to go!

* Fixed CLTV(Empty) tests

* Responded to code review

* responded to code review

* ScriptSignature only types Policy-compliant script signatures

* Fixed md doc
2019-11-05 18:48:50 -06:00
Nadav Kohen
4a3677c009 RawScriptPubKey (#843)
* Introduced RawScriptPubKey type

* Responded to code review
2019-10-31 18:34:48 -05:00
Nadav Kohen
40ebc8e53e Replace scriptPubKeyToSatisfy with spendingInfoToSatisfy in Signer (#842)
* Replace scriptPubKeyToSatisfy with spendingInfoToSatisfy and made UTXOSpendingInfo ADT nicer

Tightened up types on Signer with a type parameter

Factored out common functionality in Signer

Responded to code review

* More review
2019-10-31 12:17:30 -05:00
Nadav Kohen
0c2bdafdf0 GCSTest fix (#845)
* Raised the min p value in GCSTest to avoid large x/2^p values which cause long unary to happen

* Lowered upper bound to 50
2019-10-31 06:21:23 -05:00
Nadav Kohen
ec7bd7f51d Removed the ScriptProgram companion object (#811) 2019-10-23 10:12:41 -05:00
Ben Carman
92f8fd96a0 Refactor old test cases to use BitcoinSUnitTest (#814) 2019-10-20 02:35:03 -05:00
Chris Stewart
62bb36928e Update script_tests.json, fix bugs that were unveiled with that updat… (#799)
* Update script_tests.json, fix bugs that were unveiled with that update. Specifically around handling negative zero in Script, and cleanstack behavior for segwit scripts. We were not checking for equality at the byte level for negative zero. With cleanstack, we were failing the script, but not failing with the correct error. If you look at interpreter.cpp in bitcoin core, cleanstack check is done before checking if the stacktop is true or false

* Address code review
2019-10-15 09:57:47 -05:00
rorp
6d050602ce Increase test coverage (#810)
* Increase test coverage

* more coverage
2019-10-14 19:54:34 -05:00
Ben Carman
9d16d723ae Script Program apply method refactor part 5 (#760) (#801)
* Script Program apply method refactor part 5 (#760)

* Formatting
2019-10-13 13:20:03 -05:00
Ben Carman
f475808dbd Script Program apply method refactor part 7 (#760) (#804) 2019-10-13 09:17:28 -05:00
Ben Carman
e7ce9cd157 Script Program apply method refactor part 6 (#760) (#802) 2019-10-13 09:09:56 -05:00
Ben Carman
7641c2b73f Script Program apply method refactor part 3 (#760) (#795)
* Script Program apply method refactor part 3 (#760)

* Remove unsused method

* Documentation

* Fix test case
2019-10-12 11:09:37 -05:00
rorp
82e6c36493 Make ChainApi to scan the block filters in order to find matches (#786)
* Make ChainApi to scan the block filters in order to find matches

* performance improvements, unit test

* some parallelization

* addressed comments

* parallelism level

* fix parallelism computation

* Scala 2.11 compatibility

* increased test coverage

* cleanup

* more checks and cleanup

* change ChainApi.getMatchingBlocks signature

* some more changes
2019-10-11 14:19:42 -05:00
Nadav Kohen
8e40c0e9d0 2019 10 01 script program cleanup (#791)
* Tightened up types, only allowing ExecutionInProgressScriptPrograms to be executed in Script OPs and having output type that cannot be PreExecutionScriptProgram

* Fixed all tests!

* Replaced all calls to loop and loopOrComplete with a single one at the bottom to retain the tailrec property

* Added a couple docs
2019-10-08 12:28:58 -05:00
Chris Stewart
00eafd9970 Use the fact that network headers specify the number of bytes in the … (#783)
* Use the fact that network headers specify the number of bytes in the payload rather than just parsing from bytes.size, this should allow us to be more precise when parsing NetworkPayloads rather than _hoping_ that bytes.size does not land on pseudo-valid NetworkPayload. This hopefully resolves #782

* Add safety check around HeadersMessage.toString()

* Add invariant to NetworkMessage saying payloadSize in header must be the actual payload size
2019-10-06 09:48:53 -05:00
Chris Stewart
e819baf0dd Reduce GCSTest by more, remove unused warnings when using scala console from sbt (#779) 2019-10-03 09:46:43 -05:00
Chris Stewart
eefbc37a81 2019 09 28 common test trait (#767)
* Create base traits for async tests called BaseAsyncTest, and then create two subtypes, BitcoinSAsyncTest and BitcoinSAsyncFixtureTest to make it easier to manage resources related to test cases. Now it is easier to shutdown things like an actor system in a structured manner

* Remove two bitcoind tests that don't make sense, 'duration' in the parameter is _really_ an interval (bad naming by usTesting an interval does not make sense inside of TestRpcUtilTest

* Turn log off for ChainAppConfigTest we expect to fail

* Bump timeout for BitcoinSUnitTest, use builtint sbt scalafmtCheck

* Remove hardcoded scalafmt binary

* reduce generator size to attempt to fix #768
2019-09-30 14:55:25 -05:00
rorp
74a44d1c4d Initial BIP157 support (#695)
* WIP: Initial BIP157 support

* store block hash and hetgh along with its compact filter header

* download and parse block filters

* getcfilters/cfilter

* cfilter table

* rescan full filter chain

* improved rescan performance

* optimize compact headers download

* addressed the PR comments

* split SVP and Neutrino node implementations

* configurable filter batch sizes

* initial filter sync

* addressed comments

* chage filter table's primary key

* fix Golomb filter deserialization

* batch database inserts

* neutrino node test

* fixed node test

* addressed the PR comments

* serializers tests

* cleanup

* fix compilation errors

* fix unit tests

* increase test coverage

* enable NeutrinoNodeTest

* make scalafmt happy

* don't cache experimental binaries

* inclease test coverage

* fix unit tests

* more granular CI tests

* disable NeutrinoNodeTest

* refactor tests

* addressed comments

* test coveage

* fix formatting

* responded to the comments

* some more changes

* fix the build

* test coverage

* revert testnet3 config parameter

* minor changes

* cleanup
2019-09-25 13:18:51 -05:00
Chris Stewart
67ead0bc7e 2019 09 05 scalafmt update (#735)
* Update scalafmt to 2.0.1

* Scalafmt

In this commit we
1) Reconfigure the .scalafmt.conf file
2) Add a scalafmt binary (same version as specified in conf file)
3) Use said binary on CI to check that everything is formatted correctly

* Ran scalafmt

* Update scalafmt ignore

* Add scalafmt plugin to project/plugins.sbt, run it

* run scalafmt
2019-09-05 20:02:58 -05:00
Torkel Rogstad
5e9b26bbab Remove untyped CryptoUtil methods (#722)
Types are our friends:-)
2019-08-27 06:32:50 -05:00
Torkel Rogstad
c2f37335b8 Bump Scala versions (#697)
* 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
2019-08-23 13:53:00 -05:00
Torkel Rogstad
2f5d4db1b2 Bump test coverage (#713)
* Bump test coverage

* Lower test coverage requirement for chain
2019-08-23 18:32:55 +02:00
Torkel Rogstad
a76f61f97c Add configurable logging to data directory (#640)
* 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
2019-08-01 06:01:56 -05:00
cwaldron97
7183296b6b Killing Joda Dependency (#643)
Remove Joda dependency
2019-07-29 12:22:25 +02:00
Torkel Rogstad
c64f143628 Fix merkle block parsing error 2019-07-19 10:49:34 +02:00
Torkel Rogstad
245a77b3db Merge pull request #637 from cwaldron97/2019-07-16-remove-bitcoinj-dep
Remove BitcoinJ from dependencies
2019-07-18 11:01:19 +02:00
cwaldron97
ab29c0cc8f more removal 2019-07-17 14:47:45 -05:00
cwaldron97
87f6300082 started to remove bitcoinj deps 2019-07-16 15:12:38 -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
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
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
Chris Stewart
243e6cb65b Add case for empty bloom filter (#561) 2019-07-02 10:39:22 -05:00
Torkel Rogstad
6ffd505946 Add sampleSome method to scalacheck.Gen 2019-06-27 15:29:21 +02:00
Torkel Rogstad
0f5669bac3 Rename HDCHain.toAddress 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
da9fa4d385 Move util function into test where it's used' 2019-06-27 11:22:02 +02:00
Torkel Rogstad
66524f8c43 Respond to code review from Chris 2019-06-26 17:24:50 +02:00
Torkel Rogstad
bac49ec1d8 Add more tests to AesCryptTest, fix doc string 2019-06-25 18:55:22 +02:00
Torkel Rogstad
161db9ff92 Add toBase64/fromBase64 to AesEncryptedData 2019-06-25 11:39:17 +02:00
cwaldron97
4345ddbb1e fixed compiler errors 2019-06-24 15:50:51 -05:00
cwaldron97
a457717eb4 scalafmt 2019-06-24 14:12:47 -05:00
Torkel Rogstad
77d056e5fa Add REPL.it link to AesCryptTest 2019-06-24 17:37:03 +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
5ccc025f2e added .map to have SipHashKey Constructor 2019-06-21 17:08:33 -05:00
cwaldron97
0e97ff6ed4 fixed GCSTest file 2019-06-21 16:53:41 -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
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
35b1d726fb Merge pull request #511 from torkelrogstad/2019-06-11-website-guides
Website guides on HD key and address generation
2019-06-11 18:06:13 +02:00
Torkel Rogstad
34a06258ed Cleanup TransactionTest 2019-06-11 18:01:50 +02: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
Torkel Rogstad
1ff0dee934 Reshuffle package location of P2P messages (#495)
* 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
2019-06-06 09:13:32 -05:00
Chris Stewart
a3dd824e57 Node (#490)
* 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
2019-06-04 09:53:00 -05:00
Chris Stewart
08b4ee1afe update readmes (#467) 2019-05-30 09:02:03 -05:00
Torkel Rogstad
90f2551571 BIP84 and BIP49 (#444)
* BIP84 and BIP49

* Respond to code review

* Update HDChainType.scala
2019-05-03 04:47:10 -05:00
Torkel Rogstad
e34c4505d4 Natural language syntax for currencies (#440)
* Convert CurrencyUnit and LnCurrencyUnit Scalacheck to Scalatest

* Add Int and Long syntax to LnCurrencyUnit, MilliSatoshis and CurrencyUnit

* Tweak toString methods
2019-05-02 06:49:35 -05:00
Ramon Boss
6944f948ab added test and fixed code (#435) 2019-04-23 13:44:27 -05:00
Torkel Rogstad
2e9c524652 Add AES encryption and decryption (#395) 2019-04-08 09:47:43 -05:00
Chris Stewart
4d88354073 Implement nbits compression encoding for the difficulty threshold in … (#390)
* Implement nbits compression encoding for the difficulty threshold in a block header

* Create BlockHeader.TargetDifficultyHelper to pass around meta info about the difficulty, implement rest of test cases in arith_uint256_tests.cpp related to pow difficulty

* Address torkel's code review
2019-03-26 11:07:27 -05:00
Chris Stewart
3b8d6af4c6 2019 03 20 chainparams add mining consensus rules (#388)
* Add mining parameters to bitcoin-s chain params

* Add allowMinDifficultyBlocks and noRetargeting to ChainParams

* Add basic unit tests for new chain params vals

* Add powLimit tests

* Address torkel's code review
2019-03-21 09:10:18 -05:00
Torkel Rogstad
06e5b6b450 Add BIP44 and BIP32 path support (#379)
* Add BIP44 and BIP32 path support

Make paths from strings, indexes/coins/chains,
BIP32 children types.

Derive xprivs and xpubs from paths.

* Address code review on BIP44 from Chris

* Rename children -> path, bip32child -> bip32node

* update README with bip44 name changes
2019-03-19 13:09:11 -05:00
Torkel Rogstad
e83b40ea93 Add doc on generating coverage report (#380) 2019-03-14 11:39:45 -05:00
Chris Stewart
35493249cc Implement difficulty calculation from nBits (#377)
* Implement difficulty calculation from nBits

* Torkel's suggest to use bitvector indexing rather than bitmasks

* Explicitly import BitcoinSUnitTest
2019-03-12 07:49:51 -05:00
Chris Stewart
eaa87b1e2b Move BitcoinSUnitTest abstract class to the testkit project so it can be reused across our codebase (#375) 2019-03-07 14:48:34 -06:00
Chris Stewart
9fceb5266b Fix compilation problem on scala 2.11.x wrt trezor test cases (#372) 2019-03-04 15:53:18 -06:00
Chris Stewart
a7920b7512 Fix package path for CryptoGenerators (#365) 2019-02-28 06:46:58 -06:00
Torkel Rogstad
db5a7254b9 BIP39 support (#353)
* Adds SHA256 hashing of BitVector

* Add BIP39 support
2019-02-28 06:13:37 -06:00
Torkel Rogstad
25fa009b95 Rework Bech32 (#360)
Refactor commonalities between LN and BTC
Add support for RegTest
2019-02-27 15:55:41 -06:00
Nadav Kohen
a0c1ab91b4 testkit refactor (rename and repackage) (#355)
* Refactored testkit to have a package called testkit and renamed AsyncUtil and TestUtil, ran scalafmt

* Updated internal file names list
2019-02-21 10:04:31 -06:00
Chris Stewart
7633bf6179 Add more tests to bump test coverage (#345) 2019-02-19 10:34:23 -06:00
Chris Stewart
2879d9c25c 2019 02 14 fix digital signature bug ln invoice (#337)
* Fix bug of sign issue when serializing r,s ln invoice signatures, we weren't using the proper sign in some rare cases. We always want the BigInteger to be non-negative for r,s

* Fixing initialization problem with EmptyDigitalSignature

* revert default Deps.scala bitcoinsV to published version

* Address code review nits

* remove negative ln currency unit test case
2019-02-16 16:04:31 -06:00
Torkel Rogstad
696e9f4c45 Add BasicArithmetic trait (#329)
* Add BasicArithmetic to MilliSatoshis

* Add BasicArithmetic

* Add LnCurrencyUnit, CurrencyUnit, Number to BasicArithmetic

* Add tests for BasicArithmetic

* Make logger in unit test class protected and annotated

* Use BitcoinSUnitTest class

* Address code review
2019-02-16 15:19:00 -06:00
Chris Stewart
fe4d26858c Add bitcoin-s unit test class, all unit tests going forward should extend this (#335) 2019-02-15 07:13:33 -06:00
Chris Stewart
e3a99f085f Add explicit test cases for parsing an htlc (#333) 2019-02-13 08:56:24 -06:00
Chris Stewart
6dce938f06 rm usage of getSimpleName, as it breaks logback logging schemes (#322) 2019-02-03 10:51:31 -06:00
Chris Stewart
268e235b4d Add secp256k1jni readme, start working main project readme, move old readme to core/README.md (#276)
Add documentation for TxBuilder

Try to fix links on core/README.md

add readme badges for bintray

Nits and formatting of README (#23)

ran scalafmt, fixed format in secp readme
2019-01-08 09:29:06 -06:00
Chris Stewart
a50c6c15b3 Add test case (#285)
WIP2

Fix bug where we weren't padding byte boundary on signature data

fix nits, run scalafmt

Address torkel's code review
2019-01-07 07:53:52 -06:00
Chris Stewart
44bccce602 Add hard coded secp256k1 files for linux x86_64 bit arch (#263)
* Add hard coded secp256k1 files for linux x86_64 bit arch

* Add binary files that ignored in .gitignore
2018-12-11 15:38:17 -05:00
Chris Stewart
a8e513fd0c Rework TransactionWitness, add more tests for resizing (#267)
Turn down logging again
2018-12-10 10:53:45 -05:00
Chris Stewart
cc2067c88c Remove all old EscrowTimeoutScriptSig/ScriptPubKey and channels stuff, this is obsolete now with the Lightning Network (#265)
run scalafmt
2018-12-09 15:47:57 -05:00
Nadav Kohen
4b8cebf3a4 Added scalafmt and ran it (#264) 2018-12-09 14:43:31 -05:00
Chris Stewart
18986b620d Lightning Network (#256)
* Implementation of LnCurrencyUnit

Fix unary and unneeded comments.

Refactor and change arithmetic to use PicoBitcoins.

Add property based testing for LnCurrencyUnits

Refactor LnCurrencyUnits after code review

Fix case and change LnPolicy to val

Remove division and add Unit tests

* Add additional unit tests and deserialization

* WIP: Implement LnHumanReadablePart (#190)

* Initial Implementation of LnHumanReadablePart

* Add unit tests and improve deserialization from string

* Refactor LnParams and LnHrp. Add requirements for instantiating LnHrp.

* Clean up and re-organize things

Re-working LnHumanReadablePart.fromString

Fix unnecessary pattern match

Removing test case

* Created eclairRpc project (#193)

Added getinfo functionality

Added connect functionality

Added most of the rpcs

Added send and checkpayment functionality

Added updaterelayfee functionality

Fixed compile errors

Ran scalafmt

Added DaemonInstance and start/stop methods

Added TestUtil

Added open test

Fixed typo in allUpdates

Fixed ChannelResult

Add eclair prefix to rpc stuff

open channel unit test passing

Adding instructions to grab default eclair in build

Add zmq config to bitcoin.conf

rename test log files, bump timeouts on connections

Add eclair-rpc README, rework some RpcUtil/TestUtil stuff for async

fixing bug in precious block, addressing code review

Address more code review comments

* Add NodeId, NodeUri, ChannelId (#196)

refactor json serializing methods to SerializerUtil, add more types

* Adding LnCurrencyUnit types to rpc api, fixing bug where eclair tests were not binding to a random port for zmq (#198)

Remove start stuff

* Adding more rpc tests, testing open, payment over channel, and closing of the channel (#199)

Add checkpayment tests

Address code review, create EclairTestUtil.createNodPair

* Two way eclair transactions sanity test (#200)

* Added a test for sending payments in both directions

* Updated travis bitcoin core version

* Initial LnInvoice Implementation (#194)

Start typing some ln invoice stuff

Add support for Fallback Address encoding

Part 1: Breaking out Bech32 specific functions into a util class, don't embed in Bech32Address

re-naming fromBase8ToBase5 -> from8BitTo5bit

Part 1: Breaking out Bech32 specific functions into a util class, don't embed in Bech32Address

rework ln invoices tags

fix more method names in Bech32

Rename ScriptPubKeyTag -> NodeIdTag

All invoice tags tests passing except weird serialization order one

Address code review, add some more comments

rename 'LnInvoiceTags' -> 'LnInvoiceTaggedFields'

create a UInt5 type to represent all of the bech32 data structures

Passing all serialization in the BOLT11 examples

First cut at deserialization

* Adding bitcoin-s types to the eclair-rpc, fixing bug with decoding numbers, refactoring more things (#204)

* Switch bech32 p2wpkh hash from RipdeMd160 -> Sha256Hash160Digest (#206)

* Add testkit project / dependency (#209)

fix core-gen build.sbt name

* add correct dependencies to testkit (#210)

* Get dep name right (#211)

* Add serialization symmetry property for LnInvoice, fixing various bugs in LnInvoice data structures, adding generators for various LnInvoice data structures (#217)

* Reworking AuthCredentials and Instances so that we can read from config files (#218)

add core files that were missing

* Reworking a lot of testkit data structures to be more helpful for testing (#219)

Add missing EclairApi file

remove noisy log

* Rebase onto master, fix testkit compile issues

* Simplify LnCurrencyUnit, add MilliSatoshis, refactor EclairRpc to use… (#226)

* Simplify LnCurrencyUnit, add MilliSatoshis, refactor EclairRpc to use MilliSatoshis

* Add some helper functions around millisatoshis for comparing them to other things

* more tests / helper methods, at generator for millisatoshis

* Fix typo

* Fix comparison operators for millisatoshis, add Writes for MilliSatos… (#227)

* Fix comparison operators for millisatoshis, add Writes for MilliSatoshis in JsonWriters

* re-add comparison operators to LnCurrencyUnit for convinience

* Add millisatoshi reads (#228)

* Updating version of eclair to https://github.com/ACINQ/eclair/releases/download/v0.2-beta8/eclair-node-0.2-beta8-52821b8.jar (#229)

* Derive nodeId from ln invoice signature, move nodeid case class into … (#230)

* Derive nodeId from ln invoice signature, move nodeid case class into the core project

* Add missing assert

* Fix null pointer exception that could occurred during requiring the invoice's signature to valid. This could occurr if a user tried to construct an invoice with an invalid signature (#233)

* Turn down logging / remove logging (#235)

* Cleaned up eclair conf (#237)

* Cleaned up eclair conf

* Added test for bad auth and Reads for LnInvoice

* WIP: rebase onto master with new compiler opts

fix more compiler warnings with testkit

* fix new compiler warnings for scalac 2.12.x on ln (#253)

* fix new compiler warnings for scalac 2.12.x on ln

* fix missing p2wpkhoutput in rawoutput testkit/CreditingTxGen.scala

* First cut at code review for the ln branch (#258)

Fix bug in parsing the LnTagPrefix.CltvExpiry, add properties that check if the NodeIdTag is given explicitly to the invoice

remove dumb invariants

revert version

* 2018 12 4 ln code review rd2 (#259)

* Amend EclairRpc test case for confirming that channel is closed

* Add final check to test case to make sure the bitcoind wallet received funds when closing channel

* Address Torkel's code review

* Addresses some review on #256 (#260)

* Docstring cleanup, small nits

* Refactors some redudant data, nested if => switch

* Fixes SO error by reversing remowal of `new`

* Fixes a couple of bugs

* map.get instead of list.find

* StringBuilder in HRP

* Rework NetworkParam to LnParam

* Cleanup

* Renames file to match trait/object name

* Docstring cleanup, pure formatting

* Simplifies a few expressions, doesn't change semantics

* Adds overloaded findRoute method instead of Either[NodeId, LnInvoice]

* Eclair cleanup

* Address concerns from Chris

* Type annotation to match case

* Address nadav's code review
2018-12-08 11:03:24 -05:00
Chris Stewart
953142c013 2018 11 21 performance improvements (#249)
* Change ScriptConstant members from def to val

change all stuff in org.bitcoins.script.constant._ to actually be constant , this seems to improve performance from rudimentary bench marks by 2x

* rework RawSerializerHelper.writeCmpctSizeUInt to remove extra loop

* Fix bug where P2WPKHWitnessV0/P2WSHWitnessV0 didn't extend ScritpWitnessV0, add a few optimizations in ScriptWitness
2018-11-23 20:56:19 -05:00
Chris Stewart
91b838f2ac Remove annoying logs 2018-11-18 18:37:26 -05:00
Chris Stewart
88e9b0b1df Add compiler options for the Compile scope 2018-11-18 18:37:26 -05:00
Tanner R
b0db84dd76 Initial Test Coverage Improvement (#214) 2018-10-12 21:28:17 -04:00
Chris Stewart
84c99dbdb6 implement p2sh(p2wpkh) inside of the interpreter and TxBuilder (#207)
fix bug in P2SHScriptSignature.redeemScript

uncommenting the fuzz tests

Add p2sh(p2wsh) test vectors from BIP143

Fix possible index out of bounds exception w/ updating an EmptyWitness
2018-10-01 10:00:44 -04:00
Chris Stewart
84e92d4dfa removing scoded.bits prefix from application code
Finishing scodec.bits refactor
2018-08-10 14:01:14 -05:00
Daniel James
5b5852bf72 scodec
Migration to scodec

Src is compiling

tests compiling

All unit tests passing now

fix compiler issue in ScriptParser

bump timeout to run on travis ci

Fixing two unit tests that had types failing

Turn down excessive logging

Uncomment rpc tests

fixing nits
2018-08-09 21:32:17 -05:00
Chris Stewart
0c29c8cfda Add invariant that doesn't allow segwit scripts to be created with uncompressed public keys
reset scalafmt for rpc/

Removing unit test that used uncompressed public key for P2WSH, removing extra debug
2018-07-22 14:10:01 -05:00
Chris Stewart
2cd44c0f07 refactor hash type to derive the byte from the underlying int32, refactor some other things to make hash type nicer 2018-06-01 13:04:41 -05:00
Nadav Kohen
6368642d09 Added sequence parameter to coinbase and removed fruitless type test 2018-05-31 10:57:36 -05:00
Chris Stewart
9cc2bb1695 Fix overflow bug with parsing script with OP_PUSHDATA4 2018-05-28 19:47:56 -05:00
Chris Stewart
8716378cc1 Refactoring TransactionSignatureSerializer to only take TxSigCompnents
Cleaning up nits
2018-05-22 06:00:53 -05:00
Chris Stewart
32f64e0dd9 Changing TxSigComponent to take a TransactionOutput instead of a ScriptPubKey, refactoring ScriptProgram into 3 companion objects PreExecutionScriptProgram, ExecutionInProgressScriptProgram, ExecutedScriptProgram 2018-05-19 09:25:32 -05:00
Chris Stewart
40d53bb7b3 Changing Transaction, BlockHeader version type from UInt32 -> Int32 to reflect what the bitcoin protocol actually is 2018-05-16 09:13:31 -04:00
Chris Stewart
9d834a69d0 :# This is a combination of 2 commits.
Create AddressFactory interface for creating addresses, adding toString method to print address string

Adding isValid to AddressFactory
2018-05-10 10:27:56 -05:00
Daniel James
0309675528 Refactor multi-module build
- separate Java source copied from libsecp256k1 into separate module
- split main module into core core-gen core-test
  - generators can be published separated to core code for use in
    3rd-party tests
- code coverage needs to be aggregated
2018-05-02 16:18:01 -04:00