Commit Graph

321 Commits

Author SHA1 Message Date
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
Chris Stewart
3122e1d0f8
Fix bug in taproot SIGHASH_ANYONECANPAY_SINGLE impl (#4440) 2022-07-01 10:24:09 -05:00
Chris Stewart
38d8f8cdf0
2022 06 30 OP_CODESEPARATOR impl compatible with taproot (#4439)
* Implement OP_CODESEPARATOR index checking

* Remove taproot serialization options

* Refactor name

Co-authored-by: benthecarman <benthecarman@live.com>
2022-06-30 13:59:14 -05:00
Chris Stewart
a97be26586
Get a SIGHASH_SINGLE test case working (#4431)
* Get a SIGHASH_SINGLE test case working

* Remove println
2022-06-27 15:23:49 -05:00
benthecarman
c4fd7035be
Add Taproot PSBT fields (#4420) 2022-06-27 08:55:30 -05:00
Chris Stewart
124cbe4b67
Add annex to TaprootKeyPath (#4416)
* Add annex to TaprootKeyPath

* Add TaprootWitness.annexHashOpt

* Fix duplicate method
2022-06-23 12:12:38 -05:00
Chris Stewart
a680f03c04
Implement BIP341 (#4409)
* Implement BIP341

Get coreTest working

* REmove logger

* scalafmt

* Cleanup

* Make checkSigTapScrip() take a SchnorrPublicKey

* Address ben's code review

* Adjust error type on WitenssVersionV1.rebuild()
2022-06-22 09:36:55 -05:00
Chris Stewart
9769fbcbb6
Add TaprootWitness, new methods to XOnlyPubKey (#4394)
* Add TaprootWitness, new methods to XOnlyPubKey

* Address codereview
2022-06-14 20:27:01 -05:00
Chris Stewart
ddbdde495d
2022 06 13 taprootspk xonlypubkey (#4388)
* Implement XOnlyPubKey inside of TaprootScriptPubKey

* Add ECPrivateKey.toXOnly

* Address code review
2022-06-13 18:43:43 -05:00
benthecarman
344a8fd759
Add TLVs defined in BOLT 4 (#4380)
* Add TLVs defined in BOLT 4

* Fix test case
2022-06-13 11:58:11 -05:00
benthecarman
ab215e26df
Set recovery id properly for buildLnInvoiceSignature (#4379) 2022-06-11 09:36:19 -05:00
benthecarman
efc1f9fb77
Have Satoshis extend Numeric (#4364)
* Have Satoshis extend Numeric

* Add test case
2022-06-11 06:13:05 -05:00
Nadav Kohen
b80bf4649e
Add HashType to ECDigitalSignature API (#4320)
* HashType now uses Int instead of Int32

* Moved HashType from core to crypto

* Added HashType helper functions to ECDigitalSignature

* Added tests

* Fixed compile
2022-05-29 18:25:22 -05:00
benthecarman
676c0b4261
Add isStandard to Address (#4353) 2022-05-27 08:04:18 -05:00
benthecarman
0a092e4e03
Add fromString for TransactionOutPoint (#4261) 2022-04-14 05:38:09 -05:00
Chris Stewart
f2fa56221d
2022 03 31 collateral invariant (#4232)
* DLCMessage.totalCollateral -> DLCMessage.collateral

* Fix bad names of {DLCOfferTLV,DLCAcceptTLV}.totalCollateralSatoshis, its not the total collateral, rather the collateral being contributed by the offerer and acceptor

* Fix rebase

* Fix appServerTest

* Fix docs
2022-03-31 09:48:08 -05:00
Chris Stewart
d5807daeab
Remove SpendingInfoDb.txid parameter (#4199) 2022-03-19 15:21:36 -05:00
Chris Stewart
8d2a749df6
Rename WitnessScriptPubKeyV1 -> TaprootScriptPubKey (#4198) 2022-03-19 13:26:03 -05:00
Chris Stewart
c3300aec52
2022 03 03 hdpath fromstring factory exn (#4159)
* Add explicit excpetion when we are unaware of the purpose in a hd path

* Remove test

* Cleanup
2022-03-04 06:05:49 -06:00
Chris Stewart
30226219e6
2022 03 01 static wix upgrade product code (#4149)
* Try fixing a stic wix productId so the windows OS can understand installations of bitcoin-s are the same product

* Add this branch to release.yml

* Use 1.9.0 windows product id

* Add EnvUtil.parseCommitsSinceLastTag, make last number on windows version be the number of commits since last tag

* Add ability to parse the version from a string

* use upgradeId rather than productId

* Remove feature branch from release.yml

* Remove test
2022-03-01 18:25:13 -06:00
Chris Stewart
528e7c8f0e
Remove TxoState.DoesNotExist (#4108) 2022-02-18 16:31:03 -06:00
benthecarman
f657510d80
Remove invoice max amount limit (#4104) 2022-02-18 12:16:39 -06:00
Chris Stewart
71711ca582
Add invariant to make sure spendingTxId is different than the txid (#4019) 2022-01-27 09:52:12 -06:00
Chris Stewart
b918cf78b7
Fix bugs where we were building internally inconsistent SpendingInfoDb (#4016)
* Fix bugs where we were building internally inconsistent SpendingInfoDb

* Fix error message
2022-01-27 07:22:09 -06:00
Chris Stewart
d983ad14f3
Fix contractid computation (#4012) 2022-01-26 05:30:29 -06:00
Chris Stewart
21de609ed8
2022 01 22 cetsignatures refactor (#4004)
* Get refactor working where we decouple CETSignatures and the partial refund signature

* Add DLCAcceptWithCetSigs() for the case where we have a refund sig, but no cet signatures

* Fix bugs

* Fix sighash parsing bugs
2022-01-23 16:13:36 -06:00
Chris Stewart
214213b59d
2022 01 16 issue 3983 (#3987)
* Add test case

* Add check that the pubkey is valid in WitnessScriptPubKeyV1.isValidAsm()
2022-01-17 14:38:51 -06:00
Chris Stewart
9dd126bb9f
Modify estimatefee endpoint to return a number rather than a string (#3973)
* Modify estimatefee endpoint to return a number rather than a string

* Fix compile

* Fix infinite loop on converting to sats/vb, add tests
2022-01-12 12:17:04 -06:00
Shreyansh
a58ef1cd02
Storing peers in database (#3773)
* rebase

* fix

* fix

* remove unwanted diffs

* fix

* formatting

* changes from comments

* Revert "changes from comments"

This reverts commit eb8a795718dc590802a19c7ce4cce4501bd2de1f.

* changes from comments

* add PeerManager

* add sha3-256

* add NetworkUtilTest

* formatting
2022-01-09 07:21:59 -06:00
Chris Stewart
8857af2b66
Address ben's code review on #3854 (#3962)
* Address ben's code review

* Rename DLCSerializationVersion

* Scalafmt and bug fix'

* Fix docs
2022-01-05 08:49:23 -06:00
Chris Stewart
8c5288d758
Implemented general payout curves (#3854)
* Implemented general payout curves including hyperbola curve piece support

WIP

Get GUI compiling

* WIP

* Get backward compatible serialization working, everything is equivalent except for in memory Scala data structures

* Get numeric contracts backward compatible

* Get rest of codebase compiling

* Add test case for old contract info

* Add sanity test vector for old enum contract descriptors

* Fix docs

* Remove comment

* Scalafmt

* Add DLCSerializationVersion, replace isOldSerialization

* Remove ValueIterator.takeNoSkip()

* Fix docs

Co-authored-by: nkohen <nadavk25@gmail.com>
2022-01-05 07:07:22 -06:00
Nadav Kohen
6652448f99
Added constructor for p2pkh for decompressed public keys (#3944) 2021-12-27 15:23:38 -06:00
Chris Stewart
0d37c4b54f
2021 12 08 block parsing bug caused by 65 byte taproot signatures (#3887)
* Add block  0000000000000000000593310d3b0cdc082af49f38b8a1611239072aef8433a8 test vector

* Add test cases

* wip

* Fix bug where we were classifying taproot txs as P2WPKHWitnessV0

* revert logging level

* Some cleanup

* Add logback.xml for scripts, remove scheduler in scan bitcoind

* Fix imports

* Take ben's suggestion and add check to CryptoUtil.isValidPubKey
2021-12-09 06:38:25 -06:00
Chris Stewart
8765c2f845
Disjoint union dlc (#3839)
* Implemented Disjoint Union DLC related data structures with dlcTest passing

Broke DLCClientTest up into multiple test files

Optimized DLC execution unit tests by checking all outcomes on a single setup DLC

Refactored DLCTest to allow for Disjoint Union DLC construction and validation, added tests

Responded to review

Fixed after cherry-pick

Fixed docs

* Fixed things after rebase

* Rebase

* Fix json serializer

* Finish fixing compile

* Start trying to make APIs better for multi oracle contract infos

* Clean things up in the GUI, try to make failures on disjoint union contracts as explicit as possible

* Use less numDigits as optimization for non secp CI test cases

* Fix compile

* Refactor BroadcastDLCDialog

* Fix test case optimization

* Clean up comment

Co-authored-by: nkohen <nadavk25@gmail.com>
2021-11-29 19:26:00 -06:00