Commit Graph

622 Commits

Author SHA1 Message Date
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
1b169d8fa0
Implement torstarted websocket callback (#4476)
* Implement tor started websocket callback

* Implement tor callbacks when tor is provided
2022-07-11 10:26:30 -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
benthecarman
ef50becf1b
Enforce MAX_PUSH_SIZE for taproot (#4486) 2022-07-11 06:41:37 -05:00
benthecarman
db63b286b3
Fix hashtype check to correctly handle scala's conversion (#4487) 2022-07-11 06:40:40 -05:00
benthecarman
91a1c84a6f
Enforce minimalif for tapscripts (#4484) 2022-07-10 19:03:51 -05:00
benthecarman
990e344a49
Disallow OP_CMS in taproot (#4485) 2022-07-10 18:47:31 -05:00
benthecarman
cc45924ed8
Validate max ScriptNumber bytes in OP_CHECKSIGADD (#4483)
* Validate max ScriptNumber bytes in OP_CHECKSIGADD

* Use correct error

* Fix so we check stack length before getting sig bytes
2022-07-10 17:55:44 -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
benthecarman
3821060e68
Schnorr sig parsing checks (#4482) 2022-07-10 16:00:38 -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
rorp
414557effb
Add imported flag to the seed JSON (#4459)
* Add `imported` flag to the seed JSON

* scalafmt

* update `walletinfo`

* fix docs

Co-authored-by: Chris Stewart <stewart.chris1234@gmail.com>
2022-07-08 18:55:47 -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
benthecarman
eae16a52f8
Allow creating input info of simple OP_TRUE script pub key (#4450) 2022-07-06 10:52:06 -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
benthecarman
5f93096c5a
Fix Taproot keyspend serialization (#4443) 2022-07-02 05:05:36 -05:00
benthecarman
93302fea01
Fix TaprootKeyPath.isValid for 64 byte sigs (#4444) 2022-07-02 05:02:47 -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
Shreyansh
42564bc810
Find and switch peers (#4408)
* add support to find and switch peers

* fix compile on 2.12

* allow empty config peers in regtest

* fix test

* minor fixes

changes timeouts, fix issue with ipv6 dns seeds, initDisconnect when disconnected bug, dbPeers order fix

* fix: not removing peers on initialization timeout

* fix: query again when previous failed

* fix: wrong condition for deferred peers

* restore log levels

* clean up

* add PeerStack to allow trying peers based on priority values

* fix migrations

* changes from comments

* use StartStopAsync

* changes from comments

* fix switch if peer down test

* changes from comments
2022-06-28 10:19:13 -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
5115d8d076
Move lastCodeSeparator to StartedScriptProgram (#4414) 2022-06-22 09:41:30 -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
acd1d227cf
Rework WitnessVersion.rebuild() to take WitnessScriptPubKey as a parameter (#4393)
* Rework WitnessVersion.rebuild() to take WitnessScriptPubKey as a parameter rather than the raw asm

* Fix bug when calculating witness program length

* Fix witnessProgram bug in ScriptInterpreter.rebuildV0()

* remove invariant, fix type
2022-06-14 20:08:13 -05:00
Nadav Kohen
ad8802164c
ECPublicKey.tweakMultiply -> multiply and Added CryptoParams.getG (#4391)
* Renamed ECPublicKey.tweakMultiply to just multiply and added CryptoParams.getG

* Used decompressed G in FieldElement.G

* Removed G from FieldElement altogether
2022-06-14 13:11:21 -05:00
rorp
fdf281b469
DLC <-> contact mapping (#4346)
* DLC <-> contact mapping

* updated docs

* populate dlc/contact mapping automatically

* typo

* respond to the PR comments

* rename `contact` to `peer`

* fix unit tests

* create a contact when an incoming offers gets created

* drop dlc_contact_mapping table

* fix build

* update the docs

* Revert "update the docs"

This reverts commit 2386adadcd.

* revert dlc-contact-* endpoints
t Please enter the commit message for your changes. Lines starting
2022-06-14 08:14:28 -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
GreyMcCarthy
5f82307e27
Added Compute Contract Id test Vectors (#4385)
* Testing contract id calculation

* Added implicit json reader imports
2022-06-13 14:13:48 -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
Chris Stewart
b021649ac4
Refactor WitnessVersion.rebuild() to be Either[ScriptError,ScriptPubKey] to make the taproot implemtation easier (#4382) 2022-06-11 10:35:13 -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
Shreyansh
d8fc8e588f
Remove Spv code (#4356)
* change node tests to neutrino

* get node test working

* merge DataMessageHandlerTest and DataMessageHandlerNeutrinoNodeTest

* delete unused files

* remove commented out spv parts

* formatting

* delete spv node

* remove merkle callback for neutrino node

* remove spv node wallet callbacks

* formatting

* remove SpvWalletApi

* replace SpvTestConfig with NeutrinoTestConfig

* more replace SpvTestConfig with NeutrinoTestConfig

* minor fix

* fix tests
2022-05-30 07:57:31 -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
rorp
f680ab8691
Persist whether wallet is rescanning in the database (#4326)
* Persist whether wallet is rescanning in the database

* fix cli

* fix build

* fix unit tests

* fix postgres tests

* remove wallet_state table

* fix rescan bug

* cleanup

* revert Cancellable's

* Cleanup

Co-authored-by: Chris Stewart <stewart.chris1234@gmail.com>
2022-05-23 19:03:02 -05:00
benthecarman
d60d984a6b
LnURL Module (#4295)
* LnURL Module

* Add lnurl tests to CI
2022-05-14 16:11:35 -05:00
benthecarman
6845caf778
Make all uint64 types from lnd a UInt64 (#4332)
* Make all uint64 types from lnd a UInt64

* Make all uint32 types from lnd a UInt32
2022-05-11 05:05:16 -05:00