Commit Graph

151 Commits

Author SHA1 Message Date
Chris Stewart
c26ef26d57 2020 05 19 improve test performance (#1449)
* Reduce number of property based tests on BIP32PathTest and add a Future to NetworkPayloadTest's property based tests so it hopefully runs faster on CI

* Run scalafmt

* Make a few more property based tests async

* Make forAllParallel, refactor some test cases to use it

* Make BlockMessageTest async

* Bump timeout
2020-05-20 06:55:36 -05:00
Ben Carman
4942315c9f Fix allowing BytesToPushOntoStack(0) (#1448) 2020-05-19 16:52:58 -05:00
Chris Stewart
4eb22932ae Reduce number of property based tests from 200 -> 100 so we don't time out on CI (#1447) 2020-05-19 07:25:34 -05:00
Chris Stewart
bc600c230e 2020 05 17 optimizations (#1435)
* Make ScriptOperationFactory subclasses use a val to cache operaetions rather than operations

* Make ScriptOperation's use a Vector rather than Seq. Seq is a trait that can sometimes be backed by a List which can have some O(n) behavior

* Remove BlockTest benchamarking test case

* Put popular opcodes at beginning of ScriptOperations.operations for an optimization

* Remove Try() allocation on ECPublicKey.isFullyValid()

* Fix how CompactSizeUInt was serialized to be more efficient, move isMultiSig() and isLocktimeSPK() to be inline so we don't evaluate it unless we absolutely need to

* Use Map inside of ScriptOperation.fromByte()

* Update map to look up script operation rather than iterating
2020-05-18 20:23:12 -05:00
Chris Stewart
0ac3328d4b Remove the clause in Transction.fromHex() where we throw in the case … (#1431)
* Remove the clause in Transction.fromHex() where we throw in the case of a witness transaction, do something smarter and look at bytes in the byte vector

* WIP add test case

* Add back try/catch as it's still necessary for cases of unsigned base transactions

* Add permalink to example test case
2020-05-18 14:28:00 -05:00
Nadav Kohen
4eb9980d6b InputInfo Refactor (#1400)
Added OutputReference and introduced public key computation on SPKs

Made InputInfo into an ADT

Made UTXOSpendingInfo use InputInfo

Replaced UTXOSpendingInfo with NewSpendingInfo and got non-test things compiling

Made aliases for (NewSpendingInfo/NewSpendingInfoFull/NewSpendingInfoSingle)[InputInfo]

Got rid of source code mention of UTXOSpendingInfo

sbt compile passes

tests compile

Fixed all coreTest tests

Renamed to UTXOInfo

Some cleanup

Moved redeem script and script witness accessors to companion object

Responded to code review

Added OutputReference and scaladocs

Moved p2pkhPreImageOpt downstream and generalized to hashPreImages

Fixed adding-spks.md

Fixed psbts.md and txbuilder.md

Renamed UTXOInfo

Apply renaming to docs
2020-05-15 11:14:15 -05:00
Chris Stewart
65f21acbf8 2020 05 11 bech32 addr tostring (#1413)
* Make Bech32Address.toString actually print the string representation not the object one

* Remove Bech32Address.toString all together and use the super class definition

* Add test case

* Run scalafmt
2020-05-11 10:59:36 -05:00
Nadav Kohen
a503441619 Crypto Project Refactor (#1380)
* Added crypto project and decoupled BitcoinSLogger from NetworkElement

Decoupled BitcoinSLogger from Factory

Moved NetworkElement into crypto project

Moved Factory and BitcoinSUtil (renamed to BytesUtil) to crypto project

Moved MaskedToString to crypto project

Added BytesUtil to imports and cleaned up CryptoUtil.recoverPoint

Moved the rest of crypto stuff to the crypto project

Moved crypto tests to crypto-test project

* Added documentation for crypto project
2020-04-30 12:34:53 -05:00
Ben Carman
dd479afae1 Fix isMinimalPush to not look for OP_1Negate when pushing 0x4f(79) (#1367) 2020-04-24 09:42:49 -05:00
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