Commit Graph

354 Commits

Author SHA1 Message Date
Chris Stewart
4f288a12c0
2024 05 02 intellij compile (#5562)
* Get things compiling again with default intellij build

* Cleanup compile of coreTestJVM so we don't have warnings that cause failures in intellij's build
2024-05-02 13:42:36 -05:00
Chris Stewart
7ef6086673
Implement bitcoind RPC 26.x (#5550)
* Get build started for 26.1

* Start introducing v26 data structures

* Switch BitcoindVersion.newest = V26

* Fix GetTxOutSetInfoResult to use hash_serialized_3

* Fix WalletRpcTest

* Refactor PeerInfoResponse to add transport_protocol_type and session_id fields in v25

* Add ServiceIdentifier.NODE_P2P_V2, add support for v2transport to addnode, add default config setting for bitcoind to have v2transport=1 in test framework, add unit test to make sure we can establish a v2 connection

* Remove V20AssortedRpc

* Add loadtxoutset

* Implement getchainstates

* Add getprioritisedtransactions

* Add getaddrmaninfo

* Add importmempool

* Cleanup println
2024-04-27 14:51:45 -05:00
Scala Steward
afddf73c48
Update scalafmt-core to 3.8.1 (#5501)
* Update scalafmt-core to 3.8.1

* Update .scalafmt.conf settings to be factory default settings

* Fix typo

* scalafmt

* Empty commit to re-run CI

* Revert some scalafmt back to original scalafmt.conf

---------

Co-authored-by: Chris Stewart <stewart.chris1234@gmail.com>
2024-04-20 19:55:49 -05:00
Chris Stewart
e143792fb9
2024 04 16 bitcoindrpc descriptor (#5530)
* Integrate Descriptor class into 'getdescriptorinfo' RPC

* WIP: Invalid checksum that is valid according to bitcoin core

* Add descriptor.py in comments

* Get deriveaddresses RPC working with descriptors

* Parse descriptors in DescriptorsResult to Descriptor data type
2024-04-18 11:46:33 -05:00
Chris Stewart
a6d93622f8
2024 04 16 descriptor fidelity (#5529)
* Implement unit tests for key expression fidelity to user input for hardened paths

* Create HardenedType, rework BIP32Node to take Option[HardenedType] as a parameter

* Fix docs
2024-04-17 18:35:33 -05:00
Chris Stewart
0fa3be37dd
2024 04 08 Descriptors (#5525)
* Add DescriptorType, OutputDescriptor

* Get unit test passing for a descriptor with a xpub and bip32 path

* WIP: Implement checksum algo

* WIP: Implement polyMod

* Get checksum unit test case passing

* Get basic serialization test case passing

* Revert Bech32.scala

* WIP: Implement KeyExpression

* WIP: KeyOriginExpression

* Get basic KeyExpression test case passing

* Get basic unit tests workign for parsing Private/Public key descriptor expressions

* Add examples

* Get all key expression unit tests passing

* Get negative test vectors passing

* WIP: Get P2WPKHDescriptor tests working

* Get all serizliation tests passing for non-derivation path BIP382 descrioptors

* Get BIP382 derivation test cases passing

* Implement BIP382 failure test cases

* Get BIP381 test vectors passing

* Split key expressions into SingleKeyExpression,MultisigKeyExpression

* WIP: Multisig descriptors

* Remove custom building of scripts now that we have #5502

* Get BIP383 test vectors passing

* Get BIP384 test vectors passing

* Fix bug in runFailTest()

* Add RawSPKScriptExpression, use it with P2WSHExpression to ensure underlying spk is a RawScriptPubKey

* Get all negative test vectors working after fixing bug in runFailTest()

* Implement BIP385 raw() test vectors, skip addr() descriptor

* Get everything working up to dealing with taproot pubkey types

* Begin working on type hierarchy for different pubkeys

* Get things to the point of needing a custom pubkey type

* Get things compiling w/ PubKeyTypeExpression

* Get tr(WIF) example working

* WIP: Key reworking type hierachy to be PublicKey type specific

* WIP: Taproot helpers

* Get taproot descriptor working with both keypath and single level scriptpath

* Get recursive tapscript tree test vector working

* Implement negative test vectors for BIP386

* Add BIP386 derivation test

* Get extkey tr() descriptor test working

* Rename InternalPublicKeyExpression -> RawPublicXOnlyPublicKeyExpression

* Fix keyOrigin for tr() descriptors

* Cleanup comments

* Add comments

* Move leafVersion TapscriptControlBlock -> TapLeaf
2024-04-15 19:09:46 -05:00
Chris Stewart
2536fd3138
TapscriptTree, TapBranch, TapLeaf (#5520)
* Add taproot wallet test vectors

* Get parsing logic working

* Get first test case passing

* Add TapLeaf

* Get test cases working with two TapLeaf

* Add TapscriptTree as the top level type for a recursive data structure for TapscriptPath's

* Remove control block parsing for now until we actually test control blocks

* scalafmt
2024-04-12 11:16:14 -05:00
Chris Stewart
99c1292ddc
Add xor operator as NumberType.{^,xor()} (#5500)
* Add xor operator as NumberType.{^,xor()}

* Cleanup

* Consolidate number test suites

* Fix missing asserts
2024-03-28 15:21:59 -05:00
Chris Stewart
3ed78b5270
Upgrade to scala 2.13.13, fix compiler errors (#5428) 2024-02-27 10:21:39 -06:00
Chris Stewart
1dff918848
2023 02 21 pekko (#5413)
* Get dependencies resolving, get tor module compiling

* Get everything compiling with pekko

* Rework configs/logging to use pekko namespace

* Rename AkkaUtil -> PekkoUtil, BitcoinSAkkaAsyncTest -> BitcoinSPekkoAsyncTest
2024-02-22 10:26:21 -06:00
benthecarman
195cfbd273
Fix handling invoice with minimal encoding of feature bits (#5405) 2024-02-19 08:37:18 -06:00
Chris Stewart
d641c3da55
2024 01 25 Cache txid (#5374)
* Add LargeTransactionTest

* Remove unused ByteArrayOutputStream

* Add block test case for 00000000ce4a4666cce2205d760d37b5579cdedf3ac9e4295557e8ac962cde55

* Cache txId to avoid re-computing txids which can take alot of resources

* Cache WitnessTransaction.toBaseTx, remove println

* remove BlockTest as it didn't capture the bug
2024-01-27 10:57:33 -06:00
Chris Stewart
be1ec842c2
Fix bug in classifying things as MultiSigSPK that do not have enough public keys in the Script (#5371)
* Add test case for 3a8dd04bc1f8179d0b85c8e1a1e89d058833ae64a9a8c3681da3ca329297beb1

* Fix bug where we were classifying things are MultSigScriptPubKey that did not have maxSigs' number of public keys in the Script

* Remove redundant comment
2024-01-24 15:32:08 -06:00
Chris Stewart
a66925dba0
Fix bug where IndexOutOfBoundsException was occuring when parsing a script with only OP_CMS (#5370) 2024-01-24 11:42:21 -06:00
Chris Stewart
fd09724f48
2024 01 23 Validate we have maxSigs number of public keys in MultiSignatureScriptPubKey (#5369)
* Add test case for tx for 109c38

* Check that we have maxSigs' public keys in OP_CMS.isValidAsm()

* Fix val names
2024-01-23 16:43:23 -06:00
Chris Stewart
0f95a1f7bb
Fix bounds checking for MultiSignatureScriptPubKey.maxSigsRequired (#5365) 2024-01-21 09:17:24 -06:00
Chris Stewart
73785706d8
2024 01 20 Fix bug in parsing OP_CLTV and OP_CSV (#5363)
* Get test case setup for tx 1c1f50e

* Fix bug in OP_CHECKLOCKTIMEVERIFY.isValidAsm(), check that the ScriptNumber is lessthan or equal to 5 bytes in size

* Fix bug in OP_CHECKSEQUENCEVERIFY.isValidAsm(), check that the ScriptNumber is lessthan or equal to 5 bytes in size

* Fix bug to check <= rather than <

* Revert Constants.scala, ScriptNumberUtil.scala, remove superflous 'return'
2024-01-20 17:44:08 -06:00
Chris Stewart
618e1ca2d2
Fix bug in script parsing logic where we weren't checking if a ScriptNumber was negative for a MultiSignatureScriptPubKey (#5362) 2024-01-20 15:07:38 -06:00
Chris Stewart
421970dcf5
2024 01 11 bip68 bip112 txversion bug (#5346)
* Fix bug where number needed to be interpreted as a UInt32 rather than Int32 by the ScriptInterpreter in the case of OP_CSV

* Add static test vector, fix another occurrence of bug
2024-01-12 06:44:18 -06:00
Chris Stewart
ba8a0bf75a
2023 07 17 coretest script refactor (#5150)
* Refactor coreTest script test cases to consolidate

* Refactor blockchain tests in coreTest

* Refactor transaction tests in coreTest

* Refactor address tests in coreTest

* Fix missing asserts

* Fix missing asserts
2023-07-17 12:15:47 -05:00
Chris Stewart
aa8da307b7
Remove batchAndParallelExecute test case (#5122)
* Remove batchAndParallelExecute test case

* scalafmt
2023-06-29 08:24:38 -05:00
Chris Stewart
1d82ed04a7
2023 06 18 implement tcp connection using akka streams (#5111)
* WIP: Try to move byte streaming/parsing of p2p messages out of P2PClient

* WIP2: Work on killing the actor, replace it with a steram

* Get basic ability to send/receive version message working

* Transition PeerMessageReceiverState to Initializing inside of PeerMessagesender.connect()

* Refactor things out of PeerMessageSender.connect(), add some flow logs

* Get NeutrinoNodeTest be able to sync passing

* Fix some bugs, create ConnectionGraph helper class

* Use killswitch rather than Source.maybe to disconnect peer

* WIP: Debug

* Switch halfClose to false on Tcp.outgoingConnection() to not keep lingering connections

* Delete P2PClientActorTest

* Delete all P2PClient stuff

* Attempt implementing reconnection logic in PeerMessageSender

* remove supervisor

* Empty commit to re-run CI

* Small cleanups

* Implement sendResponseTimeout()

* Restore logback-test.xml

* Add callback to log error message on reconnect

* Increase queueSize/maxConcurrentOffers size
2023-06-24 07:53:44 -05:00
Chris Stewart
ebe98959ed
Upgrade to scalac 2.13.11 (#5097)
* Upgrade to scalac 2.13.11

* Fix compile issues with scalac 2.13.11
2023-06-08 10:27:39 -05:00
Chris Stewart
dc0e3645d0
2023 03 24 is tip stale (#5024)
* WIP

* Fix test

* Add more tests for stale header

* remove uncessary comments
2023-03-26 08:20:27 -05:00
benthecarman
5e6cb0d514
Fix MilliSatoshis.toSatoshis for large values (#5016) 2023-03-20 09:26:32 -05:00
benthecarman
cc8d327ea5
Support bip32 paths with 'h' instead of an apostrophe (#4881) 2022-11-12 12:49:38 -06:00
Chris Stewart
92613709aa
Add OrderedTLVPoints as this is an invariant in the codebase in DLCPayoutCurve (#4874) 2022-11-02 17:20:55 -05:00
Chris Stewart
e9b4c779fa
Upgrade scalajs to 1.10.1 (#4464)
* Upgrade scalajs to 1.10.1

* Upgrade to scalajs to 1.11.0

* Try to re-order order tests are run in to avoid scoverage bug with scalajs

* remove duplicate run of asyncUtilsTestJS/test
2022-11-01 18:15:44 -05:00
benthecarman
5111bccc5e
Add test for another tx that broke lnd/btcd (#4868) 2022-11-01 09:35:42 -05:00
benthecarman
8431b697a8
Add test for parsing super large transaction (#4849) 2022-10-17 16:08:14 -05:00
Chris Stewart
e8ebcf55cd
Fix bug where signatures were out of order from what was posted in the announcement (#4809) 2022-09-30 14:00:14 -05:00
Chris Stewart
9c506b639f
Add OrderedSchnorrSignatures, use it in OracleAttestment (#4803)
* Add OrderedSchnorrSignatures, use it in OracleAttestment, propagate it threw the codebase

* Small cleanups

* Add SortedVecFactory

* Fix test case with out of order nonces
2022-09-26 19:35:04 -05:00
Chris Stewart
fecb9902ec
2022 09 20 rm dlc test (#4792)
* Remove dlcTest module

* Fix file paths

* remove dlcTest/test from ci runs
2022-09-20 11:58:43 -05:00
benthecarman
c210052640
Refactor coin selection to be not be bitcoin-s specific (#4496)
* Refactor coin selection to be not be bitcoin-s specific

* Add to CoinSelectorUtxo
2022-07-20 08:40:11 -05:00
Chris Stewart
9412170f09
2022 07 11 fix invalid csa neg (#4495)
* Implement incorrect signature handling correctly for OP_CHECKSIGADD

* Revert tests

* scalafmt
2022-07-12 06:58:09 -05:00
benthecarman
f8f4facdd1
Correctly parse TaprootKeyPath how they are represented (#4494) 2022-07-11 19:45:59 -05:00
Chris Stewart
b16a8ca6aa
Fix bug where we weren't checking if a TaprootKeyPath w/ annex has two stack elements (#4491) 2022-07-11 09:17:52 -05:00
benthecarman
59732809d0
Represent and handle SIGHASH_DEFAULT correctly in TaprootKeyPath (#4488)
* Represent and handle SIGHASH_DEFAULT correctly in TaprootKeyPath

* Prevent construction of invalid TaprootKeyPath, fix tests

* Have SIGHASH_DEFAULT be SIGHASH_ALL in preTaproot cases
2022-07-11 07:22:08 -05:00
Chris Stewart
3892fa23ef
Restrict hash types allowed by taproot signature verification (#4481)
* Restrict hash types allowed by taproot signature verification

* Comment and small refactor

* Re-ignore taproot tx tests failures

* scalafmt

* Address ben's code review

* Calculate hash after doing cheap checks
2022-07-10 16:49:05 -05:00
Chris Stewart
ec599a5c3d
Fix containsOpSuccess implementation (#4480)
* Fix containsOpSuccess implementation

* Cache opSuccessBytes
2022-07-10 13:54:47 -05:00
benthecarman
0397ca6c78
tapscript/sigopsratio_3 failing correctly (#4461) 2022-07-10 08:11:57 -05:00
Chris Stewart
de935032ea
Make coreTestJVM.dependOn(testkit), add new multi core dispatcher to allow more cores for TaprootTTests to hopefully take load off the scala execution context (#4477) 2022-07-09 09:40:39 -05:00
benthecarman
5df5bf6741
Add support for taproot keyspend PSBTs (#4462) 2022-07-08 09:08:19 -05:00
Chris Stewart
211339f344
Add static test vectors for Taproot (#3769)
* Add static test vectors for Taproot and the ability to parse those test cases

Add TaprootWitness data structure, get parsing working for first static test case

WIP: Distinguish between TaprootKeyPath and TaprootScriptPath

Remove invariants and make val to method in TaprootScriptPath so we can parse test cases

Add TaprootTestCase.{txSigComponents, programs} methods

Try to run test case

WIP

Wrap failure case in Try

Get first test case passing

Fix building of sig component for p2sh

WIP test case legacy/pk-wrongkey

Get more test cases passing

Move where MAX_PUSH_SIZE is checked for segwit

Get another test case passing

Add links to bitcoin core in test case

Fix stack parsing for witness

Get success test cases passing (without signature verification?)

Add failure test cases

Fix basic compile failures except in javascript projects

Get basic TaprootKeyPath parsing working from ScriptWitness

Get invariants implemented correctly for TaprootScriptPath

WIP

WIP

Get first taproot signature serialization test working

Get tagged hash working correctly

Rework test framework, get 2nd success test case passing

Get compile working with rebase

Implement computeTapleafHash with a unit test case

Add scaffolding of computing merkle root test case

Implement computeTaprootMerkleRoot() with a unit test

Implement computeTapTweakHash() with a unit test

WIP: checkTapTweak()

WIP

Implement computeTapTweakHash() unit test

Rebase onto master

Get verifyTaprootCommitment() passing unit test

Refactors to be more readable

* WIP: Tapscript signature checking

* Get taproot script path signature serialization working for unit test

* Add carve out for unknown public key types

* WIP: OP_CHECKSIGADD

* Add test case to detect annex and compute its hash

* Get test case passing when using upgradable public keys with an annex on the stack

* Fix missing pattern match

* Fix bug with tapscript SIGHASH_ALL and add test case

* Add check if taproot flag is enabled

* Get signature verification working with annex hash

* Implement correct handling of fail case for OP_CHECKSIGADD

* Get test case passing

* DRY

* Fix bug, now we only allow tapscript sig checking when pubkey is 32 bytes in size

* Refactor evalChecksigTapscript to use XOnlyPubKey

* Get signature serialization working with OP_CODESEPARATOR

* Get SIGHASH_ANYONECANPAY|SINGLE example working

* Fix bug in BIP342 impl where we don't count op codes if the version is taproot

* Fix OP_CODESEPARATOR bug

* Implement calculating of OP_CODESEPARATOR idx relative to other opcodes, not push operations

* Fix OP_CHECKSIG tapscript bug where we didn't push OP_FALSE onto stack in case of signature validation failure

* Add annex to TaprootKeyPath

* Get signature chcking working with tapscript keypath annex

* Cleanup test framework code a bit to avoid casting exceptions

* Implement handling of OP_SUCCESS

* WIP: Segwit v0 serialization with nonstandard sighash flag

* Fix hash bug in segwit v0 serialization

* WIP

* Fix bug where we weren't defaulting to SIGHASH_DEFAULT when using tapscript

* Add disabled opcodes to OP_SUCCESS case

* Fix parsing for witnesses in test case

* Get a SIGHASH_SINGLE test case working

* Clean up rebase

* Fix default hash type in TaprootKeyPath

* Implement opCodeSeparator counting that does NOT work when OP_CODESEPARATOR is is not executed inside of an OP_IF, otherwise is very simple for the base case

* Cherry-pick ben's commits & rebase

* Remove script size limit for tap scripts

* Fix incorrect handling of unassigned spk

* Fix invariant

* get correct test case failing

* WIP: SIGHASH_ALL_ANYONECANPAY test case

* Cleanup logging/println

* Refactors & fix regressions in some simple unit tests

* Remove logback in core to get the entire project compiling again

* Make TapscriptPath.hasAnnex() more robust against exceptions

* Add validation of XOnlyPubKey to control block

* Implement known leaf versions in the control block

* Add TaprootUnknownPath and UnknownControlBlock

* Fix rebase

* Fix interpreter bug where v0 segwit wasn't failing when a wrong program was used

* Cleanup println

* Clean up println pt2

* Re-enable -Xfatal-warnings

* Turn off logback-test.xml

* Parallelize taproot success test cases

* Try to bump timeout

* Optimization: Reduce number of intersections in ScriptInterpreter.run()

* Ben's code review

* Take ben's clean stack bugfix

Co-authored-by: benthecarman <benthecarman@live.com>
2022-07-07 14:53:28 -05:00
benthecarman
000e7a7930
Have FutureUtil.makeAsync handle thrown exceptions (#4458) 2022-07-07 14:26:38 -05:00
Chris Stewart
83cff9a44c
2022 07 07 issue 4455 (#4457)
* Get simple serialization symmetry working for taproot keypath

* Implement generators for TaprootScriptPath, check serialization symmetry

* Make sure bytes are symmetrical too

* Add check in TaprootScriptPath.hasAnnex() to make sure therer is more than one stack element

* Cleanup

* Address ben's review

* Fix pattern match
2022-07-07 12:04:16 -05:00
Chris Stewart
11f6c8f024
2022 07 05 UnknownControlBlock (#4449)
* Add TaprootUnknownPath and UnknownControlBlock

* Fix small bugs and make validation more resilient against exceptions

* Take ben's suggestion and use abstract class

* Fix bug in TaprootKeyPath's default hash type

* Fix comment
2022-07-05 19:26:28 -05:00
Chris Stewart
6f6315c1e7
Fix taproot SIGHASH_SINGLE taproot annex hash bug (#4448) 2022-07-04 16:16:57 -05:00
benthecarman
64183568fe
Allow creation of TaprootTxSigComponent (#4445)
* Allow creation of TaprootTxSigComponent

* PreviousOutputMap using MapWrapper
2022-07-04 08:46:10 -05:00
Chris Stewart
0c14fc961b
Add test case for SIGHASH_ALL_ANYONECANPAY in taproot (#4442)
* Add test case for SIGHASH_ALL_ANYONECANPAY in taproot

* Remove spendingTx comment
2022-07-01 16:45:41 -05:00