Commit Graph

736 Commits

Author SHA1 Message Date
Chris Stewart
9feabc1c2b
Make WebsocketTests rescan test more robust (#5661)
* Make WebsocketTests rescan test more robust

* Bump timeout on WebsocketTests address generated unit test

* Rework importseed endpoint to return a bool indicating if the import was successful

* Reduce Server.httpBadRequest() log level from ERROR -> INFO

* Remove adhoc json for walletinfo
2024-09-11 10:39:32 -05:00
Chris Stewart
1939e9fd2e
core: Fix bug in RescanStarted.entireRescanDoneF (#5654) 2024-09-05 08:48:33 -05:00
Chris Stewart
2d4a0adda4
Add FundTransactionHandlingApi, make FundTransactionHandling a case class (#5651) 2024-08-25 08:52:19 -05:00
Chris Stewart
4212d6d616
Create AccountHandlingApi, move inheritance from Wallet into HDWalletApi (#5627)
* Create AccountHandlingApi, move inheritance from Wallet.scala into HDWalletApi

* Fix get wallet accounts test
2024-08-21 13:23:46 -05:00
Chris Stewart
41fab3dfd2
2024 08 07 createnewaccount rpc (#5638)
* Implement creatnewaccount rpc

* Get WalletRoutesSpec createnewaccount unit test passing

* Rename HDPurposes -> HDPurpose

* Fix docs

* Implement ConsoleCli arg, change HDPurpose json serialization to be a json string instead of a num
2024-08-13 10:32:03 -05:00
Chris Stewart
0eb1788226
Refactor WalletApi.createNewAccount to not use KeyManagerParams (#5635) 2024-08-10 15:17:35 -07:00
Chris Stewart
38850d22e3
2024 07 31 bitcoind callbacks (#5631)
* Add NodeApiCallbacks

* Add BitcoindCallbacks

* Add BitcoindRpcAppConfig

* fix docs

* Add helper method for construction

* Add helper constructor method to avoid explicitly passing BitcoindRpcAppConfig parameter to BitcoindRpcClient when we have a BitcoindInstanceLocal

* Fix docs
2024-08-02 07:43:24 -07:00
Chris Stewart
e68ebeadbc
refactor: Create UtxoHandlingApi, move to has-a relationship within Wallet (#5624)
* refactor: Create UtxoHandlingApi, move to has-a relationship within Wallet

* Add WalletApi.{markUTXOsAsReserved, unmarkUTXOsAsReserved, listUtxos(state), listUtxos(account), listUtxos(tag)}

* move listUtxos(account) into NeutrinoHDWalletApi

* cleanup

* Revert files

* Revert more files

* Remove comment
2024-07-22 14:40:48 -05:00
Chris Stewart
654d4086b9
2024 05 08 scala3 core (#5580)
* Pull over scala3 compatible code for crypto/ project from https://github.com/bitcoin-s/bitcoin-s/pull/3497

* Pull over scala3 compatible code for core/ project from https://github.com/bitcoin-s/bitcoin-s/pull/3497

* Add -Xsource:3 to core/

* Get coreJVM/compile working

* restore files lost from master when checking out core/ from 2021-06-30

* Get entire codebase compiling

* Get bitcoindRpcTest/test:compile working

* Restore P2SHDescriptor constructor

* scalafmt

* Fix UInt8.toByte

* Get all merkle block tests working

* Fix GCS bug

* Add -Xsource:3 to cryptoTest/
2024-05-10 11:10:45 -05:00
Chris Stewart
9fe67bbdbe
Remove remaining 2.13 specific code as 2.13.x is the only compiler version supported (#5576)
Fix compile

Remove compat
2024-05-09 09:05:07 -05:00
Chris Stewart
36ec8a2911
Rework PeerManagerApi.{sendToRandomPeer, gossipMessage} to return Unit rather than Future[Unit], this removes the possibility of deadlocking on a full queue (#5561) 2024-05-04 08:53:22 -05:00
Chris Stewart
4f791d71d7
Upgrade clightning to 24.02.2 (#5558)
* Upgrade clightning to 24.02.2

* Fix download hash

* Fix version

* Change CLightningInfo.fees_collected_msat from String -> Long

* Fix channels parsing, add support for p2tr address type and remove nested-segwit for clightning

* Revert version

* amount_msats -> amount_msat

* Fix more json parsing

* Try commenting out asserts for midChannelsA being completed in CLightningChannelOpenerTest

* scalafmt

* msatoshi -> amount_msat

* Change assertion to check assert the channel is not active in CLightningChannelOpenerTest

* Fix CLightningPayResult

* Ignore test case that uses sendtoaddress until we upgrade to psbt v2
2024-05-01 13:28:12 -05:00
Chris Stewart
7ed2b8801a
2024 04 30 upgrade eclair v0.10.0 (#5557)
* Fix open, audit commands for v0.10.0

* Get all unit tests passing

* Add logger.error() to try to debug channel state

* Try adding delay to see if dual funding process can complete before we generate blocks

* scalafmt

* Try bumping number of blocks generated

* Try disabling dual funding

* Cleanup
2024-04-30 14:25:50 -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
Chris Stewart
23e32652f3
Implement bitcoind 25.2 (#5540)
* Implement downloading of bitcoind 25.2

* Add aarch64 hash

* Update x86 macos hash, windows hash

* WIP: scanblocks RPC

* Get in progress scanblocks state working

* Get scanblocks start request working

* Fix BitcoindRpcTestUtil.signRawTransaction

* Implement scanblocks abort

* Remove println

* Switch newest version of bitcoind to v25

* Fix BitcoindV25RpcClient.version

* move decodescript test to WalletRpcTest, rework decodescript test to use descriptors,  fix LoadWalletResult

* Empty commit to run CI

* sendrawtransaction maxburnamount param

* Modify testmempoolaccept RPC return type to have two new fields for fee information

* Add test for base too
2024-04-23 17:26:23 -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
9442dba217
Remove support for v21 of bitcoind (#5496)
* Remove support for v21 of bitcoind

* WIP: Remove deprecated rpcs wit legacy wallets

* WIP: Work up to importdescriptor

* Get low-r test case passing

* Simplify test case

* Remove BitcoindV21RpcClientTest and move test cases to BitcoindV24RpcClientTest

* Remove RpcTransactionRpcTest that only works on legacy wallet

* Fix MempoolRpcTest

* Delete MultisigRpcTest that depends on legacy wallet

* Get WalletRpcTest passing, ignore keypoolrefill test case for now until https://github.com/bitcoin/bitcoin/issues/29924 is resolved
2024-04-20 16:57:30 -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
790327639a
Tighten P2WSHWitnessSPKV0.apply() to only take RawScriptPubKey (#5509) 2024-04-06 16:57:21 -05:00
Chris Stewart
4ae9067083
Add invariant to P2WPKHWitnessSPKV0.apply() to make sure ECPublicKey is compressed now that we have #5502 (#5508) 2024-04-06 13:15:35 -05:00
Chris Stewart
c2cbaae88f
Add invariant to make sure we can't have p2sh(p2sh()) (#5507) 2024-04-06 12:57:18 -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
d162242a39
2024 03 24 v21 rpc refactor (#5494)
* WIP: Consolidate V19FilterRpc into BlockchainRpc

* Implement ChainApi.getFilterHeader() with bitcoind

* Make {BitcoindV22RpcClient,BitcoindV23RpcClient,BitcoindV24RpcClient} extend BitcoindRpcClient directly

* Fix MiningRpcTest

* Remove cast in BitcoindBackendTest
2024-03-26 13:04:26 -05:00
Chris Stewart
23337b7137
2024 03 11 PeerFinder.getPeersFromDnsSeeds async (#5472)
* WIP: Make getPeersFromDns async

* Get things compiling

* Comment out slow seeds
2024-03-12 12:14:01 -05:00
Chris Stewart
55e4dab86e
Rework NodeApi.downloadBlocks() to use DoubleSha256DigestBE (#5456)
* Rework NodeApi.downloadBlocks() to use DoubleSha256DigestBE rather than DoubleSha256Digest

* Fix test cases

* Fix docs

* Fix compile
2024-03-05 15:19:32 -06:00
Chris Stewart
8fb62ad21c
Use NodeCallbackStreamManager when calling NodeCallbacks constructors (#5439)
* Use NodeCallbackStreamManager when calling NodeCallbacks constructors to avoid dropping messages

* Fix handling of CallBackHandler.empty and names

* Empty commit to re-run CI

* Empty commit to re-run CI
2024-02-29 12:01:11 -06:00
Chris Stewart
3ed78b5270
Upgrade to scala 2.13.13, fix compiler errors (#5428) 2024-02-27 10:21:39 -06:00
Chris Stewart
b27cebca1c
2024 02 23 TaprootKeyPath.isValid() bug (#5421)
* Add reproducible test case for serialization symmetry failure

* Add check for TaprootKeyPath.isValid() for checking the SchnorrPublicKey is a valid x-cord in the SchnorrDigitalSignature()

* Reset ScalaTest settings
2024-02-23 14:33:36 -06:00
benthecarman
195cfbd273
Fix handling invoice with minimal encoding of feature bits (#5405) 2024-02-19 08:37:18 -06:00
Chris Stewart
fe33c2919c
Fix inconsistency of PeerDAO primary key usage (#5398)
* Fix inconsistency of PeerDAO primary key usage

* Add Peer.port helper method
2024-02-14 13:31:56 -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
5885f4e99e
2024 01 26 rm lazy bytes (#5373)
* Remove lazy evaluation of bytes in {Transaction, TransactionInput, TransactionOutput}

* use ByteVector.concat in BytesUtil.writeCmpctSizeUInt()

* mv cmpct.bytes into ByteVector.concat()

* Remove uncessary lazy byteSize
2024-01-26 10:38:53 -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
039144c2c8
Add access to underlying MultiSignatureScriptPubKey scriptNumbers represents requiredSigs, maxSigs (#5366) 2024-01-23 14:40:06 -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
9cd60d5366
2024 01 02 encapsulate state p2psink (#5342)
* Move NodeState back to node module

* Refactor peerWithServicesDataMap into NodeState

* More usage of state.peerDataMap in stream

* Fix log message

* Fix compile

* Move PeerFinder into NodeState

* WIP: Move PeerFinder init into NeutrinoNode.start()

* Get things mostly working again after rebase

* Fix bug in handling of headers message where we wouldn't transition to DoneSyncing if a peer sent us 0 headers

* Move SendToPeer into stream

* scalafmt

* Empty commit to run CI

* Re-add DataMessageHandlerTest

* Renable disconnecting portion of NeutrinoNodeTest

* Empty commit to run CI

* Remove disconnection part of test again

* Empty commit to re-run CI

* Empty commit to re-run CI
2024-01-13 17:22:01 -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
d6c1491ba8
2024 01 03 shuttingdown nodestate (#5341)
* Add NodeShuttingDown

* Add NodeShutdown to NodeStreamMessage, use it in PeerManager.stop()

* Add guard to NeutrinoNode.stop() to see if stop() was called when the isStarted flag is set, if we aren't started don't attempt to destroy the akka stream
2024-01-04 14:05:31 -06:00
Chris Stewart
b39736fb8d
Rework NodeTestUtil to use a specific bestBlockHash (#5332)
* Rework NodeTestUtil to use a specific bestBlockHash, this is useful in reorg situations

Use param in reorg test, modify scaladoc

WIP

* Cleanup

* Try to fix usage of stopHashBE

* Cleanup

* WIP: Fix getCompactFilterStartHeight()

* Revert logback-test.xml

* Fix bug with isFiltersSynced() in reorg situations

* scalafmt, fix compile

* Fix another bug with isFiltersSynced()

* Fix compile
2023-12-31 17:38:12 -06:00
Chris Stewart
5e81ec5ed2
Add ChainApi.getBestChainTips() (#5338)
* Add ChainApi.getBestChainTips()

* Implement BitcoindRpcClient.getBestChainTips()

* Revert NodeTestUtil

* Use ChainApi.getBestChainTips() throughout codebase rather than blockHeaderDAO.getBestChainTips()
2023-12-31 16:54:40 -06:00
Chris Stewart
06dfd9cea4
Rework randomPeerWithServices() to be inside of NodeState (#5331)
* Rework randomPeerWithServices() to be inside of NodeState, try to move more state into NodeState

* Don't try to sync from peer waitingForDisconnection

* Add PeerWithServices, keep track of ServiceIdentifier in PeerManager and NodeState

* Try to make reorg test more reliable

* Empty commit to run CI
2023-12-29 14:47:29 -06:00
Chris Stewart
d983a1bac4
2023 12 24 Make filter headers / filters sync work with block header reorgs (#5333)
* Rework ChainApi.nextBlockHeaderBatchRange() to take stopHash parameter, get chainTest/test passing

* WIP: Refactor ChainApi.nextFilterHeaderBatchRange()

* Finish ChainApi.nextFilterHeaderBatchRange() refactor, get all tests passing except reorg related tests in nodeTest

* Get NeutrinoNodeTest reorg test case working

* Improve flaky test

* Cleanup

* Switch sync check to bitcoinds(1)

* Empty commit to run CI

* Implement batchSize tests in ChainHandlerTest

* Rework ChainHandlerTest to not assume we have the genesis filter header / filter inserted into the database already

* Cleanup println

* Fix bug with nextFilterHeaderBatchRange() wrt to startHeightOpt parameter

* Fix off by one bug with compact filter sync

* Add check for connectionCount

* Add longer timeout

* scalafmt
2023-12-28 10:43:01 -06:00
Chris Stewart
16fb5d2dad
2023 12 19 compiler opts (#5330)
* Enable more compiler options

* enable -Xlint:valpattern, fix bug with out Test / scalacOptions were set with incorrect source code compiler flags

* Enable -Xlint:eta-sam

* Fix cryptoTestJVM

* Fix cryptoTestJS/test

* Fix asyncUtilTest

* Fix asyncUtilTest
2023-12-20 05:42:01 -06:00