From 46681e08d7fb0ce391bcd1a5c2884723708235d5 Mon Sep 17 00:00:00 2001 From: Chris Stewart Date: Thu, 5 Sep 2019 20:02:58 -0500 Subject: [PATCH] 2019 09 05 scalafmt update (#735) * Update scalafmt to 2.0.1 * Scalafmt In this commit we 1) Reconfigure the .scalafmt.conf file 2) Add a scalafmt binary (same version as specified in conf file) 3) Use said binary on CI to check that everything is formatted correctly * Ran scalafmt * Update scalafmt ignore * Add scalafmt plugin to project/plugins.sbt, run it * run scalafmt --- .scalafmt.conf | 52 +++++-- .travis.yml | 6 +- .../src/main/scala/org/bitcoins/cli/Cli.scala | 4 +- .../scala/org/bitcoins/cli/CliReaders.scala | 2 +- .../akkahttpupickle/UpickleSupport.scala | 2 +- binaries/scalafmt | Bin 0 -> 20478 bytes .../bitcoins/rpc/BitcoindInstanceTest.scala | 30 ++-- .../bitcoins/rpc/common/WalletRpcTest.scala | 32 +++- .../config/BitcoindAuthCredentialsTest.scala | 14 +- .../rpc/config/BitcoindConfigTest.scala | 86 +++++------ .../rpc/v17/BitcoindV17RpcClientTest.scala | 17 +-- .../org/bitcoins/rpc/v17/PsbtRpcTest.scala | 9 +- .../rpc/client/common/BitcoindRpcClient.scala | 2 - .../rpc/config/BitcoindInstance.scala | 1 - .../rpc/serializers/JsonReaders.scala | 16 +- build.sbt | 20 ++- .../chain/blockchain/Blockchain.scala | 2 +- .../chain/blockchain/Blockchain.scala | 2 +- .../org/bitcoins/chain/api/ChainApi.scala | 13 +- .../bitcoins/core/crypto/BIP39SeedTest.scala | 2 +- .../core/crypto/ECDigitalSignatureTest.scala | 2 +- .../org/bitcoins/core/crypto/ExtKeyTest.scala | 2 +- .../core/crypto/MnemonicCodeTest.scala | 2 +- .../core/crypto/bip32/BIP32PathTest.scala | 2 +- .../bitcoins/core/gcs/BlockFilterTest.scala | 17 +-- .../scala/org/bitcoins/core/gcs/GCSTest.scala | 5 +- .../bitcoins/core/gcs/GolombFilterTest.scala | 10 +- .../org/bitcoins/core/number/UInt32Spec.scala | 2 +- .../org/bitcoins/core/number/UInt8Spec.scala | 2 +- .../bitcoins/core/protocol/Bech32Test.scala | 2 +- .../protocol/ln/LnInvoiceSignatureTest.scala | 2 +- .../core/protocol/ln/LnInvoiceUnitTest.scala | 2 +- .../core/protocol/ln/LnUtilTest.scala | 2 +- .../core/protocol/ln/ShortChannelIdTest.scala | 41 +++-- .../transaction/TransactionTest.scala | 8 +- .../TransactionSignatureSerializer.scala | 8 +- .../scala/org/bitcoins/core/gcs/GCS.scala | 2 +- .../org/bitcoins/core/number/NumberType.scala | 6 +- .../core/protocol/CompactSizeUInt.scala | 2 +- .../core/protocol/ln/PaymentPreimage.scala | 2 +- .../core/protocol/ln/ShortChannelId.scala | 35 +++-- .../arithmetic/ArithmeticInterpreter.scala | 2 +- .../core/script/constant/Constants.scala | 3 +- .../interpreter/ScriptInterpreter.scala | 2 +- .../core/script/stack/StackInterpreter.scala | 2 +- .../serializers/script/ScriptParser.scala | 2 +- .../org/bitcoins/core/util/NumberUtil.scala | 6 +- .../eclair/rpc/EclairRpcClientTest.scala | 4 +- .../eclair/rpc/json/EclairModels.scala | 81 ++++++---- .../eclair/rpc/json/JsonReaders.scala | 52 +++---- .../org/bitcoins/node/NodeAppConfigTest.scala | 18 +-- project/plugins.sbt | 2 + .../testkit/BitcoinSTestAppConfig.scala | 30 ++-- .../gen/BlockchainElementsGenerator.scala | 13 +- .../testkit/core/gen/HDGenerators.scala | 38 +++-- .../testkit/core/gen/ScriptGenerators.scala | 144 +++++++++--------- .../core/gen/TransactionGenerators.scala | 11 +- .../testkit/core/gen/WitnessGenerators.scala | 7 +- .../testkit/core/gen/ln/LnInvoiceGen.scala | 57 ++++--- .../testkit/core/gen/ln/LnRouteGen.scala | 11 +- .../gen/p2p/ControlMessageGenerator.scala | 50 +++--- .../testkit/util/BitcoindRpcTest.scala | 2 +- .../bitcoins/wallet/WalletAppConfigTest.scala | 26 ++-- .../bitcoins/wallet/WalletStorageTest.scala | 10 +- .../wallet/models/SpendingInfoDAOTest.scala | 22 ++- .../wallet/internal/AddressHandling.scala | 9 +- .../wallet/internal/UtxoHandling.scala | 13 +- .../org/bitcoins/zmq/ZMQSubscriber.scala | 17 +-- 68 files changed, 581 insertions(+), 521 deletions(-) create mode 100755 binaries/scalafmt diff --git a/.scalafmt.conf b/.scalafmt.conf index ae2a0fc824..c87dafd95c 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,18 +1,46 @@ -version = "1.5.1" +version = "2.0.1" # See Documentation at https://scalameta.org/scalafmt/#Configuration -maxColumn=80 -docstrings=ScalaDoc -continuationIndent.callSite=2 -continuationIndent.defnSite=4 -align=some -align.openParenDefnSite=false -newlines.alwaysBeforeTopLevelStatements=true -newlines.sometimesBeforeColonInMethodReturnType=false -newlines.alwaysBeforeCurlyBraceLambdaParams=false -#newlines.alwaysBeforeMultilineDef=false +trailingCommas = never +maxColumn = 80 +docstrings = ScalaDoc +continuationIndent { + callSite = 2 + defnSite = 4 +} + +align = some +align { + openParenDefnSite = false + openParenCallSite = true +} + +danglingParentheses { + callSite = false + defnSite = false +} + +newlines { + alwaysBeforeTopLevelStatements = true + sometimesBeforeColonInMethodReturnType = false + alwaysBeforeCurlyBraceLambdaParams = false +} + +assumeStandardLibraryStripMargin = true rewrite.rules = [ - SortModifiers + SortModifiers, + RedundantParens, + SortImports ] +binPack.literalArgumentLists = true + +project { + excludeFilters = [ + .bloop, + .metals, + target + ] +} + # Consider Rewrite Rules diff --git a/.travis.yml b/.travis.yml index 453e125d86..a280022137 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,8 +53,10 @@ matrix: # compile website, to check for documentation regressions - stage: test - name: Compile website - script: sbt docs/mdoc + name: Compile website and check formatting + script: + - sbt docs/mdoc + - ./binaries/scalafmt --test --non-interactive # Release snapshots/versions of all libraries # run ci-release only if previous stages passed diff --git a/app/cli/src/main/scala/org/bitcoins/cli/Cli.scala b/app/cli/src/main/scala/org/bitcoins/cli/Cli.scala index 5045b94501..82f5fb478b 100644 --- a/app/cli/src/main/scala/org/bitcoins/cli/Cli.scala +++ b/app/cli/src/main/scala/org/bitcoins/cli/Cli.scala @@ -199,7 +199,9 @@ object Cli extends App { } val js = ujson.read(rawBody) - val jsObj = try { js.obj } catch { + val jsObj = try { + js.obj + } catch { case _: Throwable => error(s"Response was not a JSON object! Got: $rawBody") } diff --git a/app/cli/src/main/scala/org/bitcoins/cli/CliReaders.scala b/app/cli/src/main/scala/org/bitcoins/cli/CliReaders.scala index ecf48ee90a..9568cffee3 100644 --- a/app/cli/src/main/scala/org/bitcoins/cli/CliReaders.scala +++ b/app/cli/src/main/scala/org/bitcoins/cli/CliReaders.scala @@ -24,7 +24,7 @@ object CliReaders { val msg = s"$str is not a valid network! Valid networks: $networks" sys.error(msg) - } + } } implicit val bitcoinAddressReads: Read[BitcoinAddress] = diff --git a/app/server/src/main/scala/de/heikoseeberger/akkahttpupickle/UpickleSupport.scala b/app/server/src/main/scala/de/heikoseeberger/akkahttpupickle/UpickleSupport.scala index 44e3ddd580..5d89a5378a 100644 --- a/app/server/src/main/scala/de/heikoseeberger/akkahttpupickle/UpickleSupport.scala +++ b/app/server/src/main/scala/de/heikoseeberger/akkahttpupickle/UpickleSupport.scala @@ -22,7 +22,7 @@ import akka.http.scaladsl.model.MediaType import akka.http.scaladsl.model.MediaTypes.`application/json` import akka.http.scaladsl.unmarshalling.{FromEntityUnmarshaller, Unmarshaller} import akka.util.ByteString -import upickle.default.{Reader, Writer, read, write} +import upickle.default.{read, write, Reader, Writer} import scala.collection.immutable.Seq /** diff --git a/binaries/scalafmt b/binaries/scalafmt new file mode 100755 index 0000000000000000000000000000000000000000..8220503ab206085b89ba1798da720802978343d0 GIT binary patch literal 20478 zcmce-1B_)|w>Da~ZQHhO+qUiQva7mm+cvtYcGjf=PyU;8l5>)~lD)F_ zRQ7oGn0dy0##p4pjP9;3j3(9&jOGp=M6Oma4#qB)uKZ-AFfi8q%)CUNR@QdrM7l&I zWY#1^^nV}8{xyI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WXqxaLMr0$Bo`=XrxpP}gchk?2MT5soATz&V@@ok#Ytv7+M&&|uT z%StbPU$@M*OiI`-W%r6E0qGBnpDhi2+-`|>Yr3suHtS|t(m@u+zB`rMIi6xV`sMXK!4i&+@Zpo=vq(x#apd z%>UuNH1~dsnG3{ksNI}(`(;LtYMBdGYYT#vH zdjp?=(6bTH4Mg6HfNG$w5Pk!pTjJ0SL|%H1YTyA0{02fdG@u)ZyyzN~0uew-8oz-! z)~};mfV?&tlrj*YQU<>Ts4KbA%|%|Ciy9J}W$~K}UFVE$Ao9XWR0DbB@f!$T--~V_ z^70H+1LrH^HxRly6Wu`MkzZ5;S83um5W2<#-9Y4yG^&9MOz|5C9X>`k5V?7dYTzOp z{02gMjHBkpAa_#ChSv`079f|;pxOWdwi0UrQr!^X%?d1N85o3s@DVEm JgRKXM2LSZxEz vec.exists(_.address == address))) - val rpcAddress = groupingsAfter.find(vec => vec.exists(_.address == address)).get.head + val rpcAddress = + groupingsAfter.find(vec => vec.exists(_.address == address)).get.head assert(rpcAddress.address == address) assert(rpcAddress.balance == amount) // the change address should be added to an exiting address grouping - assert(!groupingsBefore.exists(vec => vec.exists(_.address == changeAddress))) + assert( + !groupingsBefore.exists(vec => vec.exists(_.address == changeAddress))) - val changeGroupingOpt = groupingsAfter.find(vec => vec.exists(_.address == changeAddress)) + val changeGroupingOpt = + groupingsAfter.find(vec => vec.exists(_.address == changeAddress)) assert(changeGroupingOpt.nonEmpty) val changeGrouping = changeGroupingOpt.get assert(changeGrouping.size > 1) - val rpcChangeAddress = changeGrouping.find(addr => addr.address == changeAddress).get + val rpcChangeAddress = + changeGrouping.find(addr => addr.address == changeAddress).get assert(rpcChangeAddress.address == changeAddress) assert(rpcChangeAddress.balance == changeAmount) } diff --git a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/config/BitcoindAuthCredentialsTest.scala b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/config/BitcoindAuthCredentialsTest.scala index 992e49ee13..3db89fe83c 100644 --- a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/config/BitcoindAuthCredentialsTest.scala +++ b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/config/BitcoindAuthCredentialsTest.scala @@ -9,7 +9,7 @@ import org.bitcoins.testkit.rpc.BitcoindRpcTestUtil class BitcoindAuthCredentialsTest extends BitcoinSUnitTest { it must "handle cookie based auth" in { val confStr = """ - |regtest=1 + |regtest=1 """.stripMargin val conf = BitcoindConfig(confStr, BitcoindRpcTestUtil.tmpDir()) val auth = BitcoindAuthCredentials.fromConfig(conf) @@ -25,9 +25,9 @@ class BitcoindAuthCredentialsTest extends BitcoinSUnitTest { it must "default to password based auth" in { val confStr = """ - |regtest=1 - |rpcuser=foo - |rpcpassword=bar + |regtest=1 + |rpcuser=foo + |rpcpassword=bar """.stripMargin val conf = BitcoindConfig(confStr, BitcoindRpcTestUtil.tmpDir()) val auth = BitcoindAuthCredentials.fromConfig(conf) @@ -44,9 +44,9 @@ class BitcoindAuthCredentialsTest extends BitcoinSUnitTest { it must "handle password based auth" in { val confStr = """ - |regtest=1 - |rpcuser=foo - |rpcpassword=bar + |regtest=1 + |rpcuser=foo + |rpcpassword=bar """.stripMargin val conf = BitcoindConfig(confStr, BitcoindRpcTestUtil.tmpDir()) diff --git a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/config/BitcoindConfigTest.scala b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/config/BitcoindConfigTest.scala index 0cb64f218f..f8dc617c93 100644 --- a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/config/BitcoindConfigTest.scala +++ b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/config/BitcoindConfigTest.scala @@ -20,7 +20,7 @@ class BitcoindConfigTest extends BitcoinSUnitTest { it must "parse networks" in { val conf = BitcoindConfig(""" - |regtest=1 + |regtest=1 """.stripMargin, tmpDir) assert(conf.network == RegTest) @@ -28,13 +28,13 @@ class BitcoindConfigTest extends BitcoinSUnitTest { it must "prioritize a prefixed option" in { val confStr = """ - |regtest=1 - | - |rpcport=2000 - |regtest.rpcport=3000 - | - |[regtest] - |rpcport=4000 + |regtest=1 + | + |rpcport=2000 + |regtest.rpcport=3000 + | + |[regtest] + |rpcport=4000 """.stripMargin.split("\n") val conf = BitcoindConfig(confStr, tmpDir) @@ -44,14 +44,14 @@ class BitcoindConfigTest extends BitcoinSUnitTest { it must "avoid to get prefixed options in section headers" in { val confStr = """ - |regtest=1 - | - |rpcport=2000 - | - |[regtest] - |rpcport=4000 - | - |regtest.rpcport=3000 + |regtest=1 + | + |rpcport=2000 + | + |[regtest] + |rpcport=4000 + | + |regtest.rpcport=3000 """.stripMargin.split("\n") val conf = BitcoindConfig(confStr, tmpDir) @@ -61,12 +61,12 @@ class BitcoindConfigTest extends BitcoinSUnitTest { it must "avoid getting options for the wrong network" in { val confStr = """ - |testnet=1 - | - |[regtest] - |rpcport=4000 - | - |regtest.rpcport=3000 + |testnet=1 + | + |[regtest] + |rpcport=4000 + | + |regtest.rpcport=3000 """.stripMargin.split("\n") val conf = BitcoindConfig(confStr, tmpDir) @@ -76,17 +76,17 @@ class BitcoindConfigTest extends BitcoinSUnitTest { it must "get options with multiple header sections" in { val confStr = """ - |testnet=1 - | - |[test] - |rpcuser=username - |rpcport=3000 - | - |[regtest] - |rpcport=4000 - | - |[main] - |rpcport=1000 + |testnet=1 + | + |[test] + |rpcuser=username + |rpcport=3000 + | + |[regtest] + |rpcport=4000 + | + |[main] + |rpcport=1000 """.stripMargin.split("\n") val conf = BitcoindConfig(confStr, tmpDir) @@ -105,17 +105,17 @@ class BitcoindConfigTest extends BitcoinSUnitTest { it must "get options with multiple header sections when our section is the last" in { val confStr = """ - |regtest=1 - | - |[test] - |rpcport=3000 - | - |[main] - |rpcport=1000 + |regtest=1 + | + |[test] + |rpcport=3000 + | + |[main] + |rpcport=1000 - |[regtest] - |rpcport=4000 - |rpcuser=username + |[regtest] + |rpcport=4000 + |rpcuser=username """.stripMargin.split("\n") val conf = BitcoindConfig(confStr, tmpDir) diff --git a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/v17/BitcoindV17RpcClientTest.scala b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/v17/BitcoindV17RpcClientTest.scala index 671a399f7f..b81a4b46d6 100644 --- a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/v17/BitcoindV17RpcClientTest.scala +++ b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/v17/BitcoindV17RpcClientTest.scala @@ -113,9 +113,8 @@ class BitcoindV17RpcClientTest extends BitcoindRpcTest { (client, _) <- clientsF addr <- client.getNewAddress info <- client.getAddressInfo(addr) - } yield - assert( - info.timestamp.exists(_.getDayOfYear == LocalDateTime.now.getDayOfYear)) + } yield assert( + info.timestamp.exists(_.getDayOfYear == LocalDateTime.now.getDayOfYear)) } it should "be able to get the address info for a given P2SHSegwit address" in { @@ -123,9 +122,8 @@ class BitcoindV17RpcClientTest extends BitcoindRpcTest { (client, _) <- clientsF addr <- client.getNewAddress(addressType = AddressType.P2SHSegwit) info <- client.getAddressInfo(addr) - } yield - assert( - info.timestamp.exists(_.getDayOfYear == LocalDateTime.now.getDayOfYear)) + } yield assert( + info.timestamp.exists(_.getDayOfYear == LocalDateTime.now.getDayOfYear)) } it should "be able to get the address info for a given Legacy address" in { @@ -133,9 +131,8 @@ class BitcoindV17RpcClientTest extends BitcoindRpcTest { (client, _) <- clientsF addr <- client.getNewAddress(addressType = AddressType.Legacy) info <- client.getAddressInfo(addr) - } yield - assert( - info.timestamp.exists(_.getDayOfYear == LocalDateTime.now.getDayOfYear)) + } yield assert( + info.timestamp.exists(_.getDayOfYear == LocalDateTime.now.getDayOfYear)) } // needs #360 to be merged @@ -180,7 +177,7 @@ class BitcoindV17RpcClientTest extends BitcoindRpcTest { case exc => logger.error(s"throwing $exc") throw exc - } + } def importTx(n: Int): Future[Unit] = for { diff --git a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/v17/PsbtRpcTest.scala b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/v17/PsbtRpcTest.scala index db349c9b1e..97c3462bde 100644 --- a/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/v17/PsbtRpcTest.scala +++ b/bitcoind-rpc-test/src/test/scala/org/bitcoins/rpc/v17/PsbtRpcTest.scala @@ -73,11 +73,10 @@ class PsbtRpcTest extends BitcoindRpcTest { Map(newAddr -> Bitcoins(0.5))) processed <- client.walletProcessPsbt(psbt) finalized <- client.finalizePsbt(processed.psbt) - } yield - finalized match { - case _: FinalizedPsbt => succeed - case _: NonFinalizedPsbt => fail - } + } yield finalized match { + case _: FinalizedPsbt => succeed + case _: NonFinalizedPsbt => fail + } } // copies this test from Core: https://github.com/bitcoin/bitcoin/blob/master/test/functional/rpc_psbt.py#L158 diff --git a/bitcoind-rpc/src/main/scala/org/bitcoins/rpc/client/common/BitcoindRpcClient.scala b/bitcoind-rpc/src/main/scala/org/bitcoins/rpc/client/common/BitcoindRpcClient.scala index d03c42d39f..b4cdff048b 100644 --- a/bitcoind-rpc/src/main/scala/org/bitcoins/rpc/client/common/BitcoindRpcClient.scala +++ b/bitcoind-rpc/src/main/scala/org/bitcoins/rpc/client/common/BitcoindRpcClient.scala @@ -86,8 +86,6 @@ sealed trait BitcoindVersion object BitcoindVersion { - - /** The newest version of `bitcoind` we support */ val newest = V18 diff --git a/bitcoind-rpc/src/main/scala/org/bitcoins/rpc/config/BitcoindInstance.scala b/bitcoind-rpc/src/main/scala/org/bitcoins/rpc/config/BitcoindInstance.scala index 0755ce77cf..e053bd969e 100644 --- a/bitcoind-rpc/src/main/scala/org/bitcoins/rpc/config/BitcoindInstance.scala +++ b/bitcoind-rpc/src/main/scala/org/bitcoins/rpc/config/BitcoindInstance.scala @@ -18,7 +18,6 @@ import java.nio.file.Files import scala.util.Properties - /** * Created by chris on 4/29/17. */ diff --git a/bitcoind-rpc/src/main/scala/org/bitcoins/rpc/serializers/JsonReaders.scala b/bitcoind-rpc/src/main/scala/org/bitcoins/rpc/serializers/JsonReaders.scala index 97ea54d740..175c9813ab 100644 --- a/bitcoind-rpc/src/main/scala/org/bitcoins/rpc/serializers/JsonReaders.scala +++ b/bitcoind-rpc/src/main/scala/org/bitcoins/rpc/serializers/JsonReaders.scala @@ -442,10 +442,9 @@ object JsonReaders { pubkey <- (json \ "pubkey").validate[ECPublicKey] masterFingerprint <- (json \ "master_fingerprint").validate[String] path <- (json \ "path").validate[String] - } yield - PsbtBIP32Deriv(pubkey = pubkey, - masterFingerprint = masterFingerprint, - path = path) + } yield PsbtBIP32Deriv(pubkey = pubkey, + masterFingerprint = masterFingerprint, + path = path) } implicit object RpcPsbtScriptReads extends Reads[RpcPsbtScript] { @@ -455,11 +454,10 @@ object JsonReaders { hex <- (json \ "hex").validate[ScriptPubKey] scriptType <- (json \ "type").validateOpt[ScriptType] address <- (json \ "address").validateOpt[BitcoinAddress] - } yield - RpcPsbtScript(asm = asm, - hex = hex, - scriptType = scriptType, - address = address) + } yield RpcPsbtScript(asm = asm, + hex = hex, + scriptType = scriptType, + address = address) } implicit object MapPubKeySignatureReads diff --git a/build.sbt b/build.sbt index c068ae4755..0fa34823d8 100644 --- a/build.sbt +++ b/build.sbt @@ -74,7 +74,7 @@ lazy val `bitcoin-s` = project import scala.collection.JavaConverters._ val logger = streams.value.log - def cleanPath(path: Path, isRoot: Boolean = true): Unit = { + def cleanPath(path: Path, isRoot: Boolean = true): Unit = if (Files.isDirectory(path)) { path.toFile.list().map { file => val toClean = path.resolve(file) @@ -89,7 +89,6 @@ lazy val `bitcoin-s` = project } else { Files.deleteIfExists(path) } - } val websiteScaladocDir = Paths.get("website", "static", "api").toAbsolutePath @@ -111,14 +110,17 @@ lazy val `bitcoin-s` = project .drop(1) // skip the root directory .foreach { child => val pathDiff = generatedDir.toPath.relativize(child) - Files.copy(child, - websiteScaladocDir.resolve(pathDiff), - StandardCopyOption.REPLACE_EXISTING) + Files.copy( + child, + websiteScaladocDir.resolve(pathDiff), + StandardCopyOption.REPLACE_EXISTING + ) } } catch { case e: Throwable => logger.err( - "Error when copying Scaladocs to website folder: ${e.toString}") + "Error when copying Scaladocs to website folder: ${e.toString}" + ) throw e } Seq(generatedDir) @@ -294,8 +296,10 @@ lazy val bench = project lazy val eclairRpcTest = project .in(file("eclair-rpc-test")) .settings(CommonSettings.testSettings: _*) - .settings(libraryDependencies ++= Deps.eclairRpcTest, - name := "bitcoin-s-eclair-rpc-test") + .settings( + libraryDependencies ++= Deps.eclairRpcTest, + name := "bitcoin-s-eclair-rpc-test" + ) .dependsOn(core % testAndCompile, testkit) lazy val nodeDbSettings = dbFlywaySettings("nodedb") diff --git a/chain/src/main/scala-2.11/org/bitcoins/chain/blockchain/Blockchain.scala b/chain/src/main/scala-2.11/org/bitcoins/chain/blockchain/Blockchain.scala index 955e5f7bbb..1d8abc4c1f 100644 --- a/chain/src/main/scala-2.11/org/bitcoins/chain/blockchain/Blockchain.scala +++ b/chain/src/main/scala-2.11/org/bitcoins/chain/blockchain/Blockchain.scala @@ -2,7 +2,7 @@ package org.bitcoins.chain.blockchain import org.bitcoins.chain.models.BlockHeaderDb -import scala.collection.{IndexedSeqLike, mutable} +import scala.collection.{mutable, IndexedSeqLike} /** @inheritdoc */ case class Blockchain(headers: Vector[BlockHeaderDb]) diff --git a/chain/src/main/scala-2.12/org/bitcoins/chain/blockchain/Blockchain.scala b/chain/src/main/scala-2.12/org/bitcoins/chain/blockchain/Blockchain.scala index dcc78da95e..f228647ddf 100644 --- a/chain/src/main/scala-2.12/org/bitcoins/chain/blockchain/Blockchain.scala +++ b/chain/src/main/scala-2.12/org/bitcoins/chain/blockchain/Blockchain.scala @@ -2,7 +2,7 @@ package org.bitcoins.chain.blockchain import org.bitcoins.chain.models.BlockHeaderDb -import scala.collection.{IndexedSeqLike, mutable} +import scala.collection.{mutable, IndexedSeqLike} /** @inheritdoc */ case class Blockchain(headers: Vector[BlockHeaderDb]) diff --git a/chain/src/main/scala/org/bitcoins/chain/api/ChainApi.scala b/chain/src/main/scala/org/bitcoins/chain/api/ChainApi.scala index 03b322b32c..3e76783f87 100644 --- a/chain/src/main/scala/org/bitcoins/chain/api/ChainApi.scala +++ b/chain/src/main/scala/org/bitcoins/chain/api/ChainApi.scala @@ -50,12 +50,11 @@ trait ChainApi { for { hash <- getBestBlockHash headerOpt <- getHeader(hash) - } yield - headerOpt match { - case None => - throw new RuntimeException( - s"We found best hash=${hash.hex} but could not retrieve the full header!!!") - case Some(header) => header - } + } yield headerOpt match { + case None => + throw new RuntimeException( + s"We found best hash=${hash.hex} but could not retrieve the full header!!!") + case Some(header) => header + } } } diff --git a/core-test/src/test/scala/org/bitcoins/core/crypto/BIP39SeedTest.scala b/core-test/src/test/scala/org/bitcoins/core/crypto/BIP39SeedTest.scala index c11cd2610f..483e02078a 100644 --- a/core-test/src/test/scala/org/bitcoins/core/crypto/BIP39SeedTest.scala +++ b/core-test/src/test/scala/org/bitcoins/core/crypto/BIP39SeedTest.scala @@ -8,7 +8,7 @@ import scala.util.{Failure, Try} class BIP39SeedTest extends BitcoinSUnitTest { behavior of "BIP39Seed" - override implicit val generatorDrivenConfig: PropertyCheckConfiguration = + implicit override val generatorDrivenConfig: PropertyCheckConfiguration = generatorDrivenConfigNewCode it must "have serialization symmetry - with password" in { diff --git a/core-test/src/test/scala/org/bitcoins/core/crypto/ECDigitalSignatureTest.scala b/core-test/src/test/scala/org/bitcoins/core/crypto/ECDigitalSignatureTest.scala index c7da1c6938..17ab5c1d59 100644 --- a/core-test/src/test/scala/org/bitcoins/core/crypto/ECDigitalSignatureTest.scala +++ b/core-test/src/test/scala/org/bitcoins/core/crypto/ECDigitalSignatureTest.scala @@ -9,7 +9,7 @@ import scodec.bits.ByteVector */ class ECDigitalSignatureTest extends BitcoinSUnitTest { - override implicit val generatorDrivenConfig = generatorDrivenConfigNewCode + implicit override val generatorDrivenConfig = generatorDrivenConfigNewCode "ECDigitalSignature" must "say that empty signature is a valid DER encoded signature" in { val emptySiganture = ECDigitalSignature(ByteVector.empty) diff --git a/core-test/src/test/scala/org/bitcoins/core/crypto/ExtKeyTest.scala b/core-test/src/test/scala/org/bitcoins/core/crypto/ExtKeyTest.scala index 096c0e12d3..436a5449e3 100644 --- a/core-test/src/test/scala/org/bitcoins/core/crypto/ExtKeyTest.scala +++ b/core-test/src/test/scala/org/bitcoins/core/crypto/ExtKeyTest.scala @@ -15,7 +15,7 @@ import scala.util.{Failure, Success, Try} class ExtKeyTest extends BitcoinSUnitTest { - override implicit val generatorDrivenConfig: PropertyCheckConfiguration = + implicit override val generatorDrivenConfig: PropertyCheckConfiguration = generatorDrivenConfigNewCode behavior of "ExtKey" diff --git a/core-test/src/test/scala/org/bitcoins/core/crypto/MnemonicCodeTest.scala b/core-test/src/test/scala/org/bitcoins/core/crypto/MnemonicCodeTest.scala index ecb744c694..46ca16c994 100644 --- a/core-test/src/test/scala/org/bitcoins/core/crypto/MnemonicCodeTest.scala +++ b/core-test/src/test/scala/org/bitcoins/core/crypto/MnemonicCodeTest.scala @@ -13,7 +13,7 @@ import scala.util.{Failure, Try} class MnemonicCodeTest extends BitcoinSUnitTest { - override implicit val generatorDrivenConfig: PropertyCheckConfiguration = + implicit override val generatorDrivenConfig: PropertyCheckConfiguration = generatorDrivenConfigNewCode behavior of "MnemonicCode" diff --git a/core-test/src/test/scala/org/bitcoins/core/crypto/bip32/BIP32PathTest.scala b/core-test/src/test/scala/org/bitcoins/core/crypto/bip32/BIP32PathTest.scala index f2977e31c6..ab8b1a058b 100644 --- a/core-test/src/test/scala/org/bitcoins/core/crypto/bip32/BIP32PathTest.scala +++ b/core-test/src/test/scala/org/bitcoins/core/crypto/bip32/BIP32PathTest.scala @@ -16,7 +16,7 @@ import org.bitcoins.core.crypto.ExtPrivateKey class BIP32PathTest extends BitcoinSUnitTest { - override implicit val generatorDrivenConfig: PropertyCheckConfiguration = + implicit override val generatorDrivenConfig: PropertyCheckConfiguration = generatorDrivenConfigNewCode behavior of "BIP32Child" diff --git a/core-test/src/test/scala/org/bitcoins/core/gcs/BlockFilterTest.scala b/core-test/src/test/scala/org/bitcoins/core/gcs/BlockFilterTest.scala index da59790701..6e86064858 100644 --- a/core-test/src/test/scala/org/bitcoins/core/gcs/BlockFilterTest.scala +++ b/core-test/src/test/scala/org/bitcoins/core/gcs/BlockFilterTest.scala @@ -63,15 +63,14 @@ class BlockFilterTest extends BitcoinSUnitTest { header <- array(6).validate[String].map(DoubleSha256DigestBE.fromHex) notes <- array(7).validate[String] - } yield - Bip158TestCase(height, - blockHash, - block, - scripts, - prevHeader, - filter, - header, - notes) + } yield Bip158TestCase(height, + blockHash, + block, + scripts, + prevHeader, + filter, + header, + notes) parseResult.get } diff --git a/core-test/src/test/scala/org/bitcoins/core/gcs/GCSTest.scala b/core-test/src/test/scala/org/bitcoins/core/gcs/GCSTest.scala index 3372bc43d1..a1073e3be1 100644 --- a/core-test/src/test/scala/org/bitcoins/core/gcs/GCSTest.scala +++ b/core-test/src/test/scala/org/bitcoins/core/gcs/GCSTest.scala @@ -240,7 +240,10 @@ class GCSTest extends BitcoinSUnitTest { } def genKey: Gen[SipHashKey] = - Gen.listOfN(16, NumberGenerator.byte).map(ByteVector(_)).map(SipHashKey(_)) + Gen + .listOfN(16, NumberGenerator.byte) + .map(ByteVector(_)) + .map(SipHashKey(_)) forAll(genPM, genItems, genKey) { case ((p, m), items, k) => diff --git a/core-test/src/test/scala/org/bitcoins/core/gcs/GolombFilterTest.scala b/core-test/src/test/scala/org/bitcoins/core/gcs/GolombFilterTest.scala index 70ef59256e..b45c4890fc 100644 --- a/core-test/src/test/scala/org/bitcoins/core/gcs/GolombFilterTest.scala +++ b/core-test/src/test/scala/org/bitcoins/core/gcs/GolombFilterTest.scala @@ -12,7 +12,10 @@ class GolombFilterTest extends BitcoinSUnitTest { it must "match encoded data for arbitrary GCS parameters" in { def genKey: Gen[SipHashKey] = - Gen.listOfN(16, NumberGenerator.byte).map(ByteVector(_)).map(SipHashKey(_)) + Gen + .listOfN(16, NumberGenerator.byte) + .map(ByteVector(_)) + .map(SipHashKey(_)) def genPMRand: Gen[(UInt8, UInt64, UInt64)] = NumberGenerator.genP.flatMap { p => @@ -49,7 +52,10 @@ class GolombFilterTest extends BitcoinSUnitTest { it must "match arbitrary encoded data for bip 158 GCS parameters" in { val genKey: Gen[SipHashKey] = - Gen.listOfN(16, NumberGenerator.byte).map(ByteVector(_)).map(SipHashKey(_)) + Gen + .listOfN(16, NumberGenerator.byte) + .map(ByteVector(_)) + .map(SipHashKey(_)) val genData: Gen[Vector[ByteVector]] = Gen.chooseNum(1, 10000).flatMap { size => diff --git a/core-test/src/test/scala/org/bitcoins/core/number/UInt32Spec.scala b/core-test/src/test/scala/org/bitcoins/core/number/UInt32Spec.scala index a31bd172e1..b3786f384d 100644 --- a/core-test/src/test/scala/org/bitcoins/core/number/UInt32Spec.scala +++ b/core-test/src/test/scala/org/bitcoins/core/number/UInt32Spec.scala @@ -112,7 +112,7 @@ class UInt32Spec extends Properties("UInt32") { Prop.forAllNoShrink(NumberGenerator.uInt32s, Gen.choose(0, 32)) { case (u32, shift) => val r = Try(u32 << shift) - val expected = (u32.toLong << shift) & 0xffffffffL + val expected = (u32.toLong << shift) & 0xFFFFFFFFL if (r.isSuccess && expected <= UInt32.max.toLong) { r.get == UInt32(expected) } else { diff --git a/core-test/src/test/scala/org/bitcoins/core/number/UInt8Spec.scala b/core-test/src/test/scala/org/bitcoins/core/number/UInt8Spec.scala index 98872f991c..2cd58ce502 100644 --- a/core-test/src/test/scala/org/bitcoins/core/number/UInt8Spec.scala +++ b/core-test/src/test/scala/org/bitcoins/core/number/UInt8Spec.scala @@ -25,7 +25,7 @@ class UInt8Spec extends Properties("UInt8Spec") { Prop.forAllNoShrink(NumberGenerator.uInt8, Gen.choose(0, 8)) { case (u8: UInt8, shift: Int) => val r = Try(u8 << shift) - val expected = (u8.toLong << shift) & 0xffL + val expected = (u8.toLong << shift) & 0xFFL if (expected <= UInt8.max.toLong) { r.get == UInt8(expected.toShort) } else { diff --git a/core-test/src/test/scala/org/bitcoins/core/protocol/Bech32Test.scala b/core-test/src/test/scala/org/bitcoins/core/protocol/Bech32Test.scala index 6e982faa96..a653a98558 100644 --- a/core-test/src/test/scala/org/bitcoins/core/protocol/Bech32Test.scala +++ b/core-test/src/test/scala/org/bitcoins/core/protocol/Bech32Test.scala @@ -13,7 +13,7 @@ import org.bitcoins.testkit.util.BitcoinSUnitTest import scala.util.{Failure, Success} class Bech32Test extends BitcoinSUnitTest { - override implicit val generatorDrivenConfig: PropertyCheckConfiguration = + implicit override val generatorDrivenConfig: PropertyCheckConfiguration = generatorDrivenConfigNewCode behavior of "Bech32" diff --git a/core-test/src/test/scala/org/bitcoins/core/protocol/ln/LnInvoiceSignatureTest.scala b/core-test/src/test/scala/org/bitcoins/core/protocol/ln/LnInvoiceSignatureTest.scala index 3e2857061f..5fb68179c4 100644 --- a/core-test/src/test/scala/org/bitcoins/core/protocol/ln/LnInvoiceSignatureTest.scala +++ b/core-test/src/test/scala/org/bitcoins/core/protocol/ln/LnInvoiceSignatureTest.scala @@ -7,7 +7,7 @@ import org.bitcoins.testkit.util.BitcoinSUnitTest class LnInvoiceSignatureTest extends BitcoinSUnitTest { - override implicit val generatorDrivenConfig: PropertyCheckConfiguration = + implicit override val generatorDrivenConfig: PropertyCheckConfiguration = generatorDrivenConfigNewCode behavior of "LnInvoiceSignature" diff --git a/core-test/src/test/scala/org/bitcoins/core/protocol/ln/LnInvoiceUnitTest.scala b/core-test/src/test/scala/org/bitcoins/core/protocol/ln/LnInvoiceUnitTest.scala index 52fe53fe27..a4a20c9959 100644 --- a/core-test/src/test/scala/org/bitcoins/core/protocol/ln/LnInvoiceUnitTest.scala +++ b/core-test/src/test/scala/org/bitcoins/core/protocol/ln/LnInvoiceUnitTest.scala @@ -25,7 +25,7 @@ import scodec.bits.ByteVector class LnInvoiceUnitTest extends BitcoinSUnitTest { behavior of "LnInvoice" - override implicit val generatorDrivenConfig: PropertyCheckConfiguration = + implicit override val generatorDrivenConfig: PropertyCheckConfiguration = generatorDrivenConfigNewCode val hrpEmpty = LnHumanReadablePart(LnBitcoinMainNet) diff --git a/core-test/src/test/scala/org/bitcoins/core/protocol/ln/LnUtilTest.scala b/core-test/src/test/scala/org/bitcoins/core/protocol/ln/LnUtilTest.scala index 5f316e974d..ba003d7356 100644 --- a/core-test/src/test/scala/org/bitcoins/core/protocol/ln/LnUtilTest.scala +++ b/core-test/src/test/scala/org/bitcoins/core/protocol/ln/LnUtilTest.scala @@ -6,7 +6,7 @@ import org.bitcoins.core.protocol.ln.util.LnUtil import org.bitcoins.testkit.util.BitcoinSUnitTest class LnUtilTest extends BitcoinSUnitTest { - override implicit val generatorDrivenConfig: PropertyCheckConfiguration = + implicit override val generatorDrivenConfig: PropertyCheckConfiguration = generatorDrivenConfigNewCode behavior of "LnUtil" diff --git a/core-test/src/test/scala/org/bitcoins/core/protocol/ln/ShortChannelIdTest.scala b/core-test/src/test/scala/org/bitcoins/core/protocol/ln/ShortChannelIdTest.scala index 9c6519b1da..5c417ac882 100644 --- a/core-test/src/test/scala/org/bitcoins/core/protocol/ln/ShortChannelIdTest.scala +++ b/core-test/src/test/scala/org/bitcoins/core/protocol/ln/ShortChannelIdTest.scala @@ -6,27 +6,40 @@ class ShortChannelIdTest extends FlatSpec with MustMatchers { it must "convert short channel id to and from human readable form" in { // BOLT example - ShortChannelId.fromHumanReadableString("539268x845x1") must be (ShortChannelId.fromHex("83a8400034d0001")) - ShortChannelId.fromHex("83a8400034d0001").toHumanReadableString must be ("539268x845x1") + ShortChannelId.fromHumanReadableString("539268x845x1") must be( + ShortChannelId.fromHex("83a8400034d0001")) + ShortChannelId.fromHex("83a8400034d0001").toHumanReadableString must be( + "539268x845x1") // min value - ShortChannelId.fromHumanReadableString("0x0x0") must be (ShortChannelId.fromHex("0")) - ShortChannelId.fromHex("0").toHumanReadableString must be ("0x0x0") + ShortChannelId.fromHumanReadableString("0x0x0") must be( + ShortChannelId.fromHex("0")) + ShortChannelId.fromHex("0").toHumanReadableString must be("0x0x0") // max value - ShortChannelId.fromHumanReadableString("16777215x16777215x65535") must be (ShortChannelId.fromHex("ffffffffffffffff")) - ShortChannelId.fromHex("ffffffffffffffff").toHumanReadableString must be ("16777215x16777215x65535") + ShortChannelId.fromHumanReadableString("16777215x16777215x65535") must be( + ShortChannelId.fromHex("ffffffffffffffff")) + ShortChannelId.fromHex("ffffffffffffffff").toHumanReadableString must be( + "16777215x16777215x65535") } it must "validate short channel id components" in { - an [IllegalArgumentException] must be thrownBy ShortChannelId.fromHumanReadableString("16777216x0x0") - an [IllegalArgumentException] must be thrownBy ShortChannelId.fromHumanReadableString("-1x0x0") - an [IllegalArgumentException] must be thrownBy ShortChannelId.fromHumanReadableString("0x16777216x0") - an [IllegalArgumentException] must be thrownBy ShortChannelId.fromHumanReadableString("0x-1x0") - an [IllegalArgumentException] must be thrownBy ShortChannelId.fromHumanReadableString("0x0x65536") - an [IllegalArgumentException] must be thrownBy ShortChannelId.fromHumanReadableString("0x0x-1") - an [NoSuchElementException] must be thrownBy ShortChannelId.fromHumanReadableString("1x1x1x1") - ShortChannelId.fromHumanReadableString("cafebabe") must be (ShortChannelId.fromHex("cafebabe")) + an[IllegalArgumentException] must be thrownBy ShortChannelId + .fromHumanReadableString("16777216x0x0") + an[IllegalArgumentException] must be thrownBy ShortChannelId + .fromHumanReadableString("-1x0x0") + an[IllegalArgumentException] must be thrownBy ShortChannelId + .fromHumanReadableString("0x16777216x0") + an[IllegalArgumentException] must be thrownBy ShortChannelId + .fromHumanReadableString("0x-1x0") + an[IllegalArgumentException] must be thrownBy ShortChannelId + .fromHumanReadableString("0x0x65536") + an[IllegalArgumentException] must be thrownBy ShortChannelId + .fromHumanReadableString("0x0x-1") + an[NoSuchElementException] must be thrownBy ShortChannelId + .fromHumanReadableString("1x1x1x1") + ShortChannelId.fromHumanReadableString("cafebabe") must be( + ShortChannelId.fromHex("cafebabe")) } } diff --git a/core-test/src/test/scala/org/bitcoins/core/protocol/transaction/TransactionTest.scala b/core-test/src/test/scala/org/bitcoins/core/protocol/transaction/TransactionTest.scala index d00cac3374..9546ffa71b 100644 --- a/core-test/src/test/scala/org/bitcoins/core/protocol/transaction/TransactionTest.scala +++ b/core-test/src/test/scala/org/bitcoins/core/protocol/transaction/TransactionTest.scala @@ -173,10 +173,10 @@ class TransactionTest extends BitcoinSUnitTest { assert( outPoint.txId == input.previousOutput.txId, s""" - |OutPoint txId not the same as input prevout txid - |outPoint.txId: ${outPoint.txId} - |input prevout txid: ${input.previousOutput.txId} - |""".stripMargin + |OutPoint txId not the same as input prevout txid + |outPoint.txId: ${outPoint.txId} + |input prevout txid: ${input.previousOutput.txId} + |""".stripMargin ) val txSigComponent = amountOpt match { case Some(amount) => diff --git a/core/src/main/scala/org/bitcoins/core/crypto/TransactionSignatureSerializer.scala b/core/src/main/scala/org/bitcoins/core/crypto/TransactionSignatureSerializer.scala index c3838569d7..64a93485e2 100644 --- a/core/src/main/scala/org/bitcoins/core/crypto/TransactionSignatureSerializer.scala +++ b/core/src/main/scala/org/bitcoins/core/crypto/TransactionSignatureSerializer.scala @@ -62,10 +62,10 @@ sealed abstract class TransactionSignatureSerializer { val inputSigsRemoved = for { input <- spendingTransaction.inputs s = input.scriptSignature - } yield - TransactionInput(input.previousOutput, - NonStandardScriptSignature(s.compactSizeUInt.hex), - input.sequence) + } yield TransactionInput( + input.previousOutput, + NonStandardScriptSignature(s.compactSizeUInt.hex), + input.sequence) //make sure all scriptSigs have empty asm inputSigsRemoved.map( diff --git a/core/src/main/scala/org/bitcoins/core/gcs/GCS.scala b/core/src/main/scala/org/bitcoins/core/gcs/GCS.scala index 422fb100d2..dd1f948aea 100644 --- a/core/src/main/scala/org/bitcoins/core/gcs/GCS.scala +++ b/core/src/main/scala/org/bitcoins/core/gcs/GCS.scala @@ -4,7 +4,7 @@ import org.bitcoins.core.number.{UInt64, UInt8} import org.bitcoins.core.protocol.CompactSizeUInt import org.bouncycastle.crypto.macs.SipHash import org.bouncycastle.crypto.params.KeyParameter -import scodec.bits.{BitVector, BinStringSyntax, ByteVector} +import scodec.bits.{BinStringSyntax, BitVector, ByteVector} import scala.annotation.tailrec diff --git a/core/src/main/scala/org/bitcoins/core/number/NumberType.scala b/core/src/main/scala/org/bitcoins/core/number/NumberType.scala index ea726616ba..78b9ece775 100644 --- a/core/src/main/scala/org/bitcoins/core/number/NumberType.scala +++ b/core/src/main/scala/org/bitcoins/core/number/NumberType.scala @@ -133,7 +133,7 @@ sealed abstract class UInt32 extends UnsignedNumber[UInt32] { override def apply: A => UInt32 = UInt32(_) override def hex: String = BitcoinSUtil.encodeHex(toLong).slice(8, 16) - override def andMask = 0xffffffffL + override def andMask = 0xFFFFFFFFL } /** @@ -142,7 +142,7 @@ sealed abstract class UInt32 extends UnsignedNumber[UInt32] { sealed abstract class UInt64 extends UnsignedNumber[UInt64] { override def hex: String = encodeHex(underlying) override def apply: A => UInt64 = UInt64(_) - override def andMask = 0xffffffffffffffffL + override def andMask = 0xFFFFFFFFFFFFFFFFL /** * Converts a [[BigInt]] to a 8 byte hex representation. @@ -178,7 +178,7 @@ sealed abstract class Int32 extends SignedNumber[Int32] { */ sealed abstract class Int64 extends SignedNumber[Int64] { override def apply: A => Int64 = Int64(_) - override def andMask = 0xffffffffffffffffL + override def andMask = 0xFFFFFFFFFFFFFFFFL override def hex: String = BitcoinSUtil.encodeHex(toLong) } diff --git a/core/src/main/scala/org/bitcoins/core/protocol/CompactSizeUInt.scala b/core/src/main/scala/org/bitcoins/core/protocol/CompactSizeUInt.scala index 980a32287e..eeabf12845 100644 --- a/core/src/main/scala/org/bitcoins/core/protocol/CompactSizeUInt.scala +++ b/core/src/main/scala/org/bitcoins/core/protocol/CompactSizeUInt.scala @@ -140,7 +140,7 @@ object CompactSizeUInt extends Factory[CompactSizeUInt] { CompactSizeUInt(UInt64(script.bytes.size), 1) } else if (script.bytes.size <= 0xffff) { CompactSizeUInt(UInt64(script.bytes.size), 3) - } else if (script.bytes.size <= 0xffffffffL) { + } else if (script.bytes.size <= 0xFFFFFFFFL) { CompactSizeUInt(UInt64(script.bytes.size), 5) } else CompactSizeUInt(UInt64(script.bytes.size), 9) } diff --git a/core/src/main/scala/org/bitcoins/core/protocol/ln/PaymentPreimage.scala b/core/src/main/scala/org/bitcoins/core/protocol/ln/PaymentPreimage.scala index 4a7093c064..475f3cfb90 100644 --- a/core/src/main/scala/org/bitcoins/core/protocol/ln/PaymentPreimage.scala +++ b/core/src/main/scala/org/bitcoins/core/protocol/ln/PaymentPreimage.scala @@ -22,4 +22,4 @@ object PaymentPreimage extends Factory[PaymentPreimage] { def random: PaymentPreimage = fromBytes(ECPrivateKey.freshPrivateKey.bytes) -} \ No newline at end of file +} diff --git a/core/src/main/scala/org/bitcoins/core/protocol/ln/ShortChannelId.scala b/core/src/main/scala/org/bitcoins/core/protocol/ln/ShortChannelId.scala index 6b13d4383f..34341ab9ef 100644 --- a/core/src/main/scala/org/bitcoins/core/protocol/ln/ShortChannelId.scala +++ b/core/src/main/scala/org/bitcoins/core/protocol/ln/ShortChannelId.scala @@ -28,9 +28,9 @@ case class ShortChannelId(u64: UInt64) extends NetworkElement { * }}} */ def toHumanReadableString: String = { - val blockHeight = (u64 >> 40) & UInt64(0xFFFFFF) - val txIndex = (u64 >> 16) & UInt64(0xFFFFFF) - val outputIndex = u64 & UInt64(0xFFFF) + val blockHeight = (u64 >> 40) & UInt64(0xFFFFFF) + val txIndex = (u64 >> 16) & UInt64(0xFFFFFF) + val outputIndex = u64 & UInt64(0xFFFF) s"${blockHeight.toInt}x${txIndex.toInt}x${outputIndex.toInt}" } @@ -42,19 +42,24 @@ object ShortChannelId extends Factory[ShortChannelId] { new ShortChannelId(UInt64.fromBytes(byteVector)) } - def fromHumanReadableString(str: String): ShortChannelId = str.split("x") match { - case Array(_blockHeight, _txIndex, _outputIndex) => - val blockHeight = BigInt(_blockHeight) - require(blockHeight >= 0 && blockHeight <= 0xffffff, "ShortChannelId: invalid block height") + def fromHumanReadableString(str: String): ShortChannelId = + str.split("x") match { + case Array(_blockHeight, _txIndex, _outputIndex) => + val blockHeight = BigInt(_blockHeight) + require(blockHeight >= 0 && blockHeight <= 0xffffff, + "ShortChannelId: invalid block height") - val txIndex = _txIndex.toInt - require(txIndex >= 0 && txIndex <= 0xffffff, "ShortChannelId:invalid tx index") + val txIndex = _txIndex.toInt + require(txIndex >= 0 && txIndex <= 0xffffff, + "ShortChannelId:invalid tx index") - val outputIndex = _outputIndex.toInt - require(outputIndex >= 0 && outputIndex <= 0xffff, "ShortChannelId: invalid output index") + val outputIndex = _outputIndex.toInt + require(outputIndex >= 0 && outputIndex <= 0xffff, + "ShortChannelId: invalid output index") - val u64 = UInt64(((blockHeight & 0xffffffL) << 40) | ((txIndex & 0xffffffL) << 16) | (outputIndex & 0xffffL)) - ShortChannelId(u64) - case _: Array[String] => fromHex(str) - } + val u64 = UInt64( + ((blockHeight & 0xFFFFFFL) << 40) | ((txIndex & 0xFFFFFFL) << 16) | (outputIndex & 0xFFFFL)) + ShortChannelId(u64) + case _: Array[String] => fromHex(str) + } } diff --git a/core/src/main/scala/org/bitcoins/core/script/arithmetic/ArithmeticInterpreter.scala b/core/src/main/scala/org/bitcoins/core/script/arithmetic/ArithmeticInterpreter.scala index 8c35f9779d..28897d416b 100644 --- a/core/src/main/scala/org/bitcoins/core/script/arithmetic/ArithmeticInterpreter.scala +++ b/core/src/main/scala/org/bitcoins/core/script/arithmetic/ArithmeticInterpreter.scala @@ -61,7 +61,7 @@ sealed abstract class ArithmeticInterpreter { x match { case ScriptNumber.zero => ScriptNumber.zero case _: ScriptNumber => ScriptNumber(x.toLong.abs) - }) + }) } /** Negates the stack top. */ diff --git a/core/src/main/scala/org/bitcoins/core/script/constant/Constants.scala b/core/src/main/scala/org/bitcoins/core/script/constant/Constants.scala index 43dde34f00..343c9f837b 100644 --- a/core/src/main/scala/org/bitcoins/core/script/constant/Constants.scala +++ b/core/src/main/scala/org/bitcoins/core/script/constant/Constants.scala @@ -59,7 +59,8 @@ sealed abstract class ScriptNumber def *(that: ScriptNumber): ScriptNumber = ScriptNumber(underlying * that.underlying) - override def compare(that: ScriptNumber): Int = underlying compare that.underlying + override def compare(that: ScriptNumber): Int = + underlying compare that.underlying def <(that: Int64): Boolean = underlying < that.toLong diff --git a/core/src/main/scala/org/bitcoins/core/script/interpreter/ScriptInterpreter.scala b/core/src/main/scala/org/bitcoins/core/script/interpreter/ScriptInterpreter.scala index f57852744d..df6bbc8673 100644 --- a/core/src/main/scala/org/bitcoins/core/script/interpreter/ScriptInterpreter.scala +++ b/core/src/main/scala/org/bitcoins/core/script/interpreter/ScriptInterpreter.scala @@ -790,7 +790,7 @@ sealed abstract class ScriptInterpreter { //since this is not a coinbase tx we cannot have any empty previous outs inside of inputs !transaction.inputs.exists(_.previousOutput == EmptyTransactionOutPoint) } - inputOutputsNotZero && txNotLargerThanBlock && outputsSpendValidAmountsOfMoney && + inputOutputsNotZero && txNotLargerThanBlock && outputsSpendValidAmountsOfMoney && allOutputsValidMoneyRange && noDuplicateInputs && isValidScriptSigForCoinbaseTx } diff --git a/core/src/main/scala/org/bitcoins/core/script/stack/StackInterpreter.scala b/core/src/main/scala/org/bitcoins/core/script/stack/StackInterpreter.scala index c1b8447ffb..281792b68c 100644 --- a/core/src/main/scala/org/bitcoins/core/script/stack/StackInterpreter.scala +++ b/core/src/main/scala/org/bitcoins/core/script/stack/StackInterpreter.scala @@ -173,7 +173,7 @@ sealed abstract class StackInterpreter { logger.error( "The index for OP_ROLL would have caused an index out of bounds exception") ScriptProgram(program, ScriptErrorInvalidStackOperation) - } + } ) } diff --git a/core/src/main/scala/org/bitcoins/core/serializers/script/ScriptParser.scala b/core/src/main/scala/org/bitcoins/core/serializers/script/ScriptParser.scala index 15e4601248..2c9adaf2ca 100644 --- a/core/src/main/scala/org/bitcoins/core/serializers/script/ScriptParser.scala +++ b/core/src/main/scala/org/bitcoins/core/serializers/script/ScriptParser.scala @@ -197,7 +197,7 @@ sealed abstract class ScriptParser extends Factory[List[ScriptToken]] { ScriptNumber(g.group(1)) } else { ScriptConstant(g.group(1)) - })) + })) scriptConstants.toList } diff --git a/core/src/main/scala/org/bitcoins/core/util/NumberUtil.scala b/core/src/main/scala/org/bitcoins/core/util/NumberUtil.scala index 05e1380101..61a3a99313 100644 --- a/core/src/main/scala/org/bitcoins/core/util/NumberUtil.scala +++ b/core/src/main/scala/org/bitcoins/core/util/NumberUtil.scala @@ -215,7 +215,7 @@ sealed abstract class NumberUtil extends BitcoinSLogger { nWordNotZero && ((nSize > 34) || (nWord > UInt8.max.toBigInt && nSize > 33) || - (nWord > UInt32(0xffffL).toBigInt && nSize > 32)) + (nWord > UInt32(0xFFFFL).toBigInt && nSize > 32)) } BlockHeader.TargetDifficultyHelper(result.abs(), isNegative, isOverflow) @@ -273,14 +273,14 @@ sealed abstract class NumberUtil extends BitcoinSLogger { } //~0x007fffff = 0xff800000 - require((compact & UInt32(0xff800000L)) == UInt32.zero, + require((compact & UInt32(0xFF800000L)) == UInt32.zero, s"Exponent/sign bit must not be set yet in compact encoding") require(size < 256, "Size of compact encoding can't be more than 2^256") compact = compact | UInt32(size << 24) compact = { - if (isNegative && ((compact & UInt32(0x007fffffL)) != UInt32.zero)) { + if (isNegative && ((compact & UInt32(0x007FFFFFL)) != UInt32.zero)) { compact | negativeFlag } else { compact | UInt32.zero diff --git a/eclair-rpc-test/src/test/scala/org/bitcoins/eclair/rpc/EclairRpcClientTest.scala b/eclair-rpc-test/src/test/scala/org/bitcoins/eclair/rpc/EclairRpcClientTest.scala index dc61302cf6..6239e34bb2 100644 --- a/eclair-rpc-test/src/test/scala/org/bitcoins/eclair/rpc/EclairRpcClientTest.scala +++ b/eclair-rpc-test/src/test/scala/org/bitcoins/eclair/rpc/EclairRpcClientTest.scala @@ -54,7 +54,7 @@ class EclairRpcClientTest extends AsyncFlatSpec with BeforeAndAfterAll { sys.error { val msg = s""""Eclair binary directory (${BitcoindRpcTestUtil.binaryDirectory}) is empty. - |Run 'sbt downloadEclair' to fetch needed binaries""".stripMargin + |Run 'sbt downloadEclair' to fetch needed binaries""".stripMargin msg } } @@ -988,7 +988,7 @@ class EclairRpcClientTest extends AsyncFlatSpec with BeforeAndAfterAll { ourUpdates.flatMap(our => allUpdates.map { all => our != all - }) + }) } val checkedUpatesF: Future[Unit] = diff --git a/eclair-rpc/src/main/scala/org/bitcoins/eclair/rpc/json/EclairModels.scala b/eclair-rpc/src/main/scala/org/bitcoins/eclair/rpc/json/EclairModels.scala index 744fef36de..46b02afd1e 100644 --- a/eclair-rpc/src/main/scala/org/bitcoins/eclair/rpc/json/EclairModels.scala +++ b/eclair-rpc/src/main/scala/org/bitcoins/eclair/rpc/json/EclairModels.scala @@ -1,12 +1,22 @@ package org.bitcoins.eclair.rpc.json -import org.bitcoins.core.crypto.{DoubleSha256Digest, DoubleSha256DigestBE, ECDigitalSignature, Sha256Digest} +import org.bitcoins.core.crypto.{ + DoubleSha256Digest, + DoubleSha256DigestBE, + ECDigitalSignature, + Sha256Digest +} import org.bitcoins.core.currency.Satoshis import org.bitcoins.core.protocol.ln.channel.{ChannelState, FundedChannelId} import org.bitcoins.core.protocol.ln.currency.MilliSatoshis import org.bitcoins.core.protocol.ln.fee.FeeProportionalMillionths import org.bitcoins.core.protocol.ln.node.NodeId -import org.bitcoins.core.protocol.ln.{LnHumanReadablePart, LnInvoiceSignature, PaymentPreimage, ShortChannelId} +import org.bitcoins.core.protocol.ln.{ + LnHumanReadablePart, + LnInvoiceSignature, + PaymentPreimage, + ShortChannelId +} import org.bitcoins.eclair.rpc.network.PeerState import play.api.libs.json.JsObject @@ -265,19 +275,20 @@ case class ChannelResult( feeProportionalMillionths: Option[FeeProportionalMillionths], data: JsObject) { import JsonReaders._ - lazy val shortChannelId: Option[ShortChannelId] = (data \ "shortChannelId").validate[ShortChannelId].asOpt + lazy val shortChannelId: Option[ShortChannelId] = + (data \ "shortChannelId").validate[ShortChannelId].asOpt } // ChannelResult ends here case class InvoiceResult( - prefix: LnHumanReadablePart, - timestamp: FiniteDuration, - nodeId: NodeId, - serialized: String, - description: String, - paymentHash: Sha256Digest, - expiry: FiniteDuration) + prefix: LnHumanReadablePart, + timestamp: FiniteDuration, + nodeId: NodeId, + serialized: String, + description: String, + paymentHash: Sha256Digest, + expiry: FiniteDuration) case class PaymentRequest( prefix: LnHumanReadablePart, @@ -288,30 +299,33 @@ case class PaymentRequest( signature: LnInvoiceSignature) case class PaymentResult( - id: String, - paymentHash: Sha256Digest, - preimage: Option[PaymentPreimage], - amountMsat: MilliSatoshis, - createdAt: FiniteDuration, - completedAt: Option[FiniteDuration], - status: PaymentStatus) + id: String, + paymentHash: Sha256Digest, + preimage: Option[PaymentPreimage], + amountMsat: MilliSatoshis, + createdAt: FiniteDuration, + completedAt: Option[FiniteDuration], + status: PaymentStatus) case class ReceivedPaymentResult( - paymentHash: Sha256Digest, - amountMsat: MilliSatoshis, - receivedAt: FiniteDuration) + paymentHash: Sha256Digest, + amountMsat: MilliSatoshis, + receivedAt: FiniteDuration) sealed trait PaymentStatus + object PaymentStatus { case object PENDING extends PaymentStatus case object SUCCEEDED extends PaymentStatus case object FAILED extends PaymentStatus def apply(s: String): PaymentStatus = s match { - case "PENDING" => PENDING + case "PENDING" => PENDING case "SUCCEEDED" => SUCCEEDED - case "FAILED" => FAILED - case err => throw new IllegalArgumentException(s"Unknown payment status code `${err}`") + case "FAILED" => FAILED + case err => + throw new IllegalArgumentException( + s"Unknown payment status code `${err}`") } } @@ -319,29 +333,28 @@ case class PaymentId(value: String) { override def toString: String = value } - sealed trait WebSocketEvent object WebSocketEvent { - case class PaymentRelayed( amountIn: MilliSatoshis, amountOut: MilliSatoshis, paymentHash: Sha256Digest, fromChannelId: FundedChannelId, toChannelId: FundedChannelId, - timestamp: FiniteDuration) extends WebSocketEvent + timestamp: FiniteDuration) + extends WebSocketEvent case class PaymentReceived( amount: MilliSatoshis, paymentHash: Sha256Digest, fromChannelId: FundedChannelId, - timestamp: FiniteDuration) extends WebSocketEvent + timestamp: FiniteDuration) + extends WebSocketEvent - case class PaymentFailed( - paymentHash: Sha256Digest, - failures: Vector[String]) extends WebSocketEvent + case class PaymentFailed(paymentHash: Sha256Digest, failures: Vector[String]) + extends WebSocketEvent case class PaymentSent( amount: MilliSatoshis, @@ -349,11 +362,13 @@ object WebSocketEvent { paymentHash: Sha256Digest, paymentPreimage: PaymentPreimage, toChannelId: FundedChannelId, - timestamp: FiniteDuration) extends WebSocketEvent + timestamp: FiniteDuration) + extends WebSocketEvent case class PaymentSettlingOnchain( amount: MilliSatoshis, paymentHash: Sha256Digest, - timestamp: FiniteDuration) extends WebSocketEvent + timestamp: FiniteDuration) + extends WebSocketEvent -} \ No newline at end of file +} diff --git a/eclair-rpc/src/main/scala/org/bitcoins/eclair/rpc/json/JsonReaders.scala b/eclair-rpc/src/main/scala/org/bitcoins/eclair/rpc/json/JsonReaders.scala index f656180f83..e700128e03 100644 --- a/eclair-rpc/src/main/scala/org/bitcoins/eclair/rpc/json/JsonReaders.scala +++ b/eclair-rpc/src/main/scala/org/bitcoins/eclair/rpc/json/JsonReaders.scala @@ -122,14 +122,13 @@ object JsonReaders { description <- (jsValue \ "description").validate[String] paymentHash <- (jsValue \ "paymentHash").validate[Sha256Digest] expiry <- (jsValue \ "expiry").validate[Long] - } yield - InvoiceResult(prefix, - timestamp.seconds, - nodeId, - serialized, - description, - paymentHash, - expiry.seconds) + } yield InvoiceResult(prefix, + timestamp.seconds, + nodeId, + serialized, + description, + paymentHash, + expiry.seconds) } } @@ -145,13 +144,12 @@ object JsonReaders { localMsat <- (jsValue \ "data" \ "commitments" \ "localCommit" \ "spec" \ "toLocalMsat") .validate[MilliSatoshis] - } yield - OpenChannelInfo(nodeId = nodeId, - shortChannelId = shortChannelId, - channelId = channelId, - localMsat = localMsat, - remoteMsat = remoteMsat, - state = state) + } yield OpenChannelInfo(nodeId = nodeId, + shortChannelId = shortChannelId, + channelId = channelId, + localMsat = localMsat, + remoteMsat = remoteMsat, + state = state) } implicit val baseChannelInfoReads: Reads[BaseChannelInfo] = Reads { jsValue => @@ -164,12 +162,11 @@ object JsonReaders { localMsat <- (jsValue \ "data" \ "commitments" \ "localCommit" \ "spec" \ "toLocalMsat") .validate[MilliSatoshis] - } yield - BaseChannelInfo(nodeId = nodeId, - channelId = channelId, - localMsat = localMsat, - remoteMsat = remoteMsat, - state = state) + } yield BaseChannelInfo(nodeId = nodeId, + channelId = channelId, + localMsat = localMsat, + remoteMsat = remoteMsat, + state = state) } implicit val channelInfoReads: Reads[ChannelInfo] = Reads { jsValue => @@ -220,13 +217,12 @@ object JsonReaders { feeProportional <- (js \ "data" \ "channelUpdate" \ "feeProportionalMillionths") .validateOpt[FeeProportionalMillionths] data <- (js \ "data").validate[JsObject] - } yield - ChannelResult(nodeId = nodeId, - state = state, - channelId = channelId, - feeBaseMsat = feeBaseMsat, - feeProportionalMillionths = feeProportional, - data = data) + } yield ChannelResult(nodeId = nodeId, + state = state, + channelId = channelId, + feeBaseMsat = feeBaseMsat, + feeProportionalMillionths = feeProportional, + data = data) } implicit val lnInvoiceReads: Reads[LnInvoice] = diff --git a/node-test/src/test/scala/org/bitcoins/node/NodeAppConfigTest.scala b/node-test/src/test/scala/org/bitcoins/node/NodeAppConfigTest.scala index 77f0c0882b..a444839100 100644 --- a/node-test/src/test/scala/org/bitcoins/node/NodeAppConfigTest.scala +++ b/node-test/src/test/scala/org/bitcoins/node/NodeAppConfigTest.scala @@ -39,15 +39,15 @@ class NodeAppConfigTest extends BitcoinSUnitTest { val tempDir = Files.createTempDirectory("bitcoin-s") val tempFile = Files.createFile(tempDir.resolve("bitcoin-s.conf")) val confStr = """ - | bitcoin-s { - | network = testnet3 - | - | logging { - | level = off - | - | p2p = warn - | } - | } + | bitcoin-s { + | network = testnet3 + | + | logging { + | level = off + | + | p2p = warn + | } + | } """.stripMargin val _ = Files.write(tempFile, confStr.getBytes()) diff --git a/project/plugins.sbt b/project/plugins.sbt index 47a99438a4..344309ac4c 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -29,3 +29,5 @@ addSbtPlugin("org.scalameta" % "sbt-mdoc" % "1.3.2") // SQL migrations addSbtPlugin("io.github.davidmweber" % "flyway-sbt" % "6.0.0") + +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.0.1") diff --git a/testkit/src/main/scala/org/bitcoins/testkit/BitcoinSTestAppConfig.scala b/testkit/src/main/scala/org/bitcoins/testkit/BitcoinSTestAppConfig.scala index ef65d769f2..67fee87815 100644 --- a/testkit/src/main/scala/org/bitcoins/testkit/BitcoinSTestAppConfig.scala +++ b/testkit/src/main/scala/org/bitcoins/testkit/BitcoinSTestAppConfig.scala @@ -17,11 +17,11 @@ object BitcoinSTestAppConfig { def getTestConfig(config: Config*): BitcoinSAppConfig = { val overrideConf = ConfigFactory.parseString { """ - |bitcoin-s { - | logging { - | level = WARN - | } - |} + |bitcoin-s { + | logging { + | level = WARN + | } + |} """.stripMargin } val tmpDir = Files.createTempDirectory("bitcoin-s-") @@ -47,12 +47,12 @@ object BitcoinSTestAppConfig { def memConfigForProject(project: ProjectType): String = { val name = project.toString().toLowerCase() s""" - | $name.db { - | url = "jdbc:sqlite:file:$name.db:?mode=memory&cache=shared" - | connectionPool = disabled - | keepAliveConnection = true - | } - |""".stripMargin + | $name.db { + | url = "jdbc:sqlite:file:$name.db:?mode=memory&cache=shared" + | connectionPool = disabled + | keepAliveConnection = true + | } + |""".stripMargin } val confStr = project match { @@ -60,10 +60,10 @@ object BitcoinSTestAppConfig { case Some(p) => memConfigForProject(p) } val nestedConfStr = s""" - | bitcoin-s { - | $confStr - | } - |""".stripMargin + | bitcoin-s { + | $confStr + | } + |""".stripMargin ConfigFactory.parseString(nestedConfStr) } diff --git a/testkit/src/main/scala/org/bitcoins/testkit/core/gen/BlockchainElementsGenerator.scala b/testkit/src/main/scala/org/bitcoins/testkit/core/gen/BlockchainElementsGenerator.scala index 03c0f39795..232c8bb961 100644 --- a/testkit/src/main/scala/org/bitcoins/testkit/core/gen/BlockchainElementsGenerator.scala +++ b/testkit/src/main/scala/org/bitcoins/testkit/core/gen/BlockchainElementsGenerator.scala @@ -72,13 +72,12 @@ sealed abstract class BlockchainElementsGenerator { merkleRootHash = Merkle.computeMerkleRoot(txs) time <- NumberGenerator.uInt32s nonce <- NumberGenerator.uInt32s - } yield - BlockHeader(version, - previousBlockHash, - merkleRootHash, - time, - nBits, - nonce) + } yield BlockHeader(version, + previousBlockHash, + merkleRootHash, + time, + nBits, + nonce) /** Generates a [[org.bitcoins.core.protocol.blockchain.BlockHeader BlockHeader]] that has a merkle root * hash corresponding to the given txs */ diff --git a/testkit/src/main/scala/org/bitcoins/testkit/core/gen/HDGenerators.scala b/testkit/src/main/scala/org/bitcoins/testkit/core/gen/HDGenerators.scala index 9cc0821429..ab6c2af5e6 100644 --- a/testkit/src/main/scala/org/bitcoins/testkit/core/gen/HDGenerators.scala +++ b/testkit/src/main/scala/org/bitcoins/testkit/core/gen/HDGenerators.scala @@ -105,11 +105,10 @@ object HDGenerators { accountIndex <- NumberGenerator.positiveInts addressIndex <- NumberGenerator.positiveInts chainType <- hdChainType - } yield - LegacyHDPath(coinType = coinType, - addressIndex = addressIndex, - accountIndex = accountIndex, - chainType = chainType) + } yield LegacyHDPath(coinType = coinType, + addressIndex = addressIndex, + accountIndex = accountIndex, + chainType = chainType) def segwithHdPath: Gen[SegWitHDPath] = for { @@ -117,11 +116,10 @@ object HDGenerators { accountIndex <- NumberGenerator.positiveInts addressIndex <- NumberGenerator.positiveInts chainType <- hdChainType - } yield - SegWitHDPath(coinType = coinType, - addressIndex = addressIndex, - accountIndex = accountIndex, - chainType = chainType) + } yield SegWitHDPath(coinType = coinType, + addressIndex = addressIndex, + accountIndex = accountIndex, + chainType = chainType) def nestedSegwithHdPath: Gen[NestedSegWitHDPath] = for { @@ -129,11 +127,10 @@ object HDGenerators { accountIndex <- NumberGenerator.positiveInts addressIndex <- NumberGenerator.positiveInts chainType <- hdChainType - } yield - NestedSegWitHDPath(coinType = coinType, - addressIndex = addressIndex, - accountIndex = accountIndex, - chainType = chainType) + } yield NestedSegWitHDPath(coinType = coinType, + addressIndex = addressIndex, + accountIndex = accountIndex, + chainType = chainType) def hdPath: Gen[HDPath] = Gen.oneOf(legacyHdPath, segwithHdPath, nestedSegwithHdPath) @@ -143,12 +140,11 @@ object HDGenerators { def hdPathWithConstructor: Gen[(HDPath, HDPathConstructor)] = for { path <- hdPath - } yield - path match { - case legacy: LegacyHDPath => (legacy, LegacyHDPath(_)) - case nested: NestedSegWitHDPath => (nested, NestedSegWitHDPath(_)) - case segwit: SegWitHDPath => (segwit, SegWitHDPath(_)) - } + } yield path match { + case legacy: LegacyHDPath => (legacy, LegacyHDPath(_)) + case nested: NestedSegWitHDPath => (nested, NestedSegWitHDPath(_)) + case segwit: SegWitHDPath => (segwit, SegWitHDPath(_)) + } /** * Generates a pair of paths that can be diffed. diff --git a/testkit/src/main/scala/org/bitcoins/testkit/core/gen/ScriptGenerators.scala b/testkit/src/main/scala/org/bitcoins/testkit/core/gen/ScriptGenerators.scala index f7c275e799..3f8c26e39b 100644 --- a/testkit/src/main/scala/org/bitcoins/testkit/core/gen/ScriptGenerators.scala +++ b/testkit/src/main/scala/org/bitcoins/testkit/core/gen/ScriptGenerators.scala @@ -37,11 +37,10 @@ sealed abstract class ScriptGenerators extends BitcoinSLogger { val signatures: Gen[Seq[ECDigitalSignature]] = for { numKeys <- Gen.choose(1, Consensus.maxPublicKeysPerMultiSig) hash <- CryptoGenerators.doubleSha256Digest - } yield - for { - _ <- 0 until numKeys - privKey = ECPrivateKey() - } yield privKey.sign(hash) + } yield for { + _ <- 0 until numKeys + privKey = ECPrivateKey() + } yield privKey.sign(hash) signatures.map(sigs => MultiSignatureScriptSignature(sigs)) } @@ -414,35 +413,34 @@ sealed abstract class ScriptGenerators extends BitcoinSLogger { (scriptPubKey, privKeys) <- randomNonLockTimeNonP2SHScriptPubKey hashType <- CryptoGenerators.hashType cltv = CLTVScriptPubKey(cltvLockTime, scriptPubKey) - } yield - scriptPubKey match { - case m: MultiSignatureScriptPubKey => - val requiredSigs = m.requiredSigs - val cltvScriptSig = lockTimeHelper(Some(lockTime), - sequence, - cltv, - privKeys, - Some(requiredSigs), - hashType) - (cltvScriptSig.asInstanceOf[CLTVScriptSignature], cltv, privKeys) - case _: P2PKHScriptPubKey | _: P2PKScriptPubKey => - val cltvScriptSig = lockTimeHelper(Some(lockTime), - sequence, - cltv, - privKeys, - None, - hashType) - (cltvScriptSig.asInstanceOf[CLTVScriptSignature], cltv, privKeys) - case _: UnassignedWitnessScriptPubKey | _: WitnessScriptPubKeyV0 => - throw new IllegalArgumentException( - "Cannot created a witness scriptPubKey for a CSVScriptSig since we do not have a witness") - case _: P2SHScriptPubKey | _: CLTVScriptPubKey | _: CSVScriptPubKey | - _: NonStandardScriptPubKey | _: WitnessCommitment | - EmptyScriptPubKey => - throw new IllegalArgumentException( - "We only " + - "want to generate P2PK, P2PKH, and MultiSig ScriptSignatures when creating a CSVScriptSignature") - } + } yield scriptPubKey match { + case m: MultiSignatureScriptPubKey => + val requiredSigs = m.requiredSigs + val cltvScriptSig = lockTimeHelper(Some(lockTime), + sequence, + cltv, + privKeys, + Some(requiredSigs), + hashType) + (cltvScriptSig.asInstanceOf[CLTVScriptSignature], cltv, privKeys) + case _: P2PKHScriptPubKey | _: P2PKScriptPubKey => + val cltvScriptSig = lockTimeHelper(Some(lockTime), + sequence, + cltv, + privKeys, + None, + hashType) + (cltvScriptSig.asInstanceOf[CLTVScriptSignature], cltv, privKeys) + case _: UnassignedWitnessScriptPubKey | _: WitnessScriptPubKeyV0 => + throw new IllegalArgumentException( + "Cannot created a witness scriptPubKey for a CSVScriptSig since we do not have a witness") + case _: P2SHScriptPubKey | _: CLTVScriptPubKey | _: CSVScriptPubKey | + _: NonStandardScriptPubKey | _: WitnessCommitment | + EmptyScriptPubKey => + throw new IllegalArgumentException( + "We only " + + "want to generate P2PK, P2PKH, and MultiSig ScriptSignatures when creating a CSVScriptSignature") + } /** * Generates a signed `CLTVScriptSignature` that spends @@ -461,31 +459,30 @@ sealed abstract class ScriptGenerators extends BitcoinSLogger { (scriptPubKey, privKeys) <- randomNonLockTimeNonP2SHScriptPubKey hashType <- CryptoGenerators.hashType csv = CSVScriptPubKey(csvScriptNum, scriptPubKey) - } yield - scriptPubKey match { - case m: MultiSignatureScriptPubKey => - val requiredSigs = m.requiredSigs - val csvScriptSig = lockTimeHelper(None, - sequence, - csv, - privKeys, - Some(requiredSigs), - hashType) - (csvScriptSig.asInstanceOf[CSVScriptSignature], csv, privKeys) - case _: P2PKHScriptPubKey | _: P2PKScriptPubKey => - val csvScriptSig = - lockTimeHelper(None, sequence, csv, privKeys, None, hashType) - (csvScriptSig.asInstanceOf[CSVScriptSignature], csv, privKeys) - case _: UnassignedWitnessScriptPubKey | _: WitnessScriptPubKeyV0 => - throw new IllegalArgumentException( - "Cannot created a witness scriptPubKey for a CSVScriptSig since we do not have a witness") - case _: P2SHScriptPubKey | _: CLTVScriptPubKey | _: CSVScriptPubKey | - _: NonStandardScriptPubKey | _: WitnessCommitment | - EmptyScriptPubKey => - throw new IllegalArgumentException( - "We only " + - "want to generate P2PK, P2PKH, and MultiSig ScriptSignatures when creating a CLTVScriptSignature.") - } + } yield scriptPubKey match { + case m: MultiSignatureScriptPubKey => + val requiredSigs = m.requiredSigs + val csvScriptSig = lockTimeHelper(None, + sequence, + csv, + privKeys, + Some(requiredSigs), + hashType) + (csvScriptSig.asInstanceOf[CSVScriptSignature], csv, privKeys) + case _: P2PKHScriptPubKey | _: P2PKScriptPubKey => + val csvScriptSig = + lockTimeHelper(None, sequence, csv, privKeys, None, hashType) + (csvScriptSig.asInstanceOf[CSVScriptSignature], csv, privKeys) + case _: UnassignedWitnessScriptPubKey | _: WitnessScriptPubKeyV0 => + throw new IllegalArgumentException( + "Cannot created a witness scriptPubKey for a CSVScriptSig since we do not have a witness") + case _: P2SHScriptPubKey | _: CLTVScriptPubKey | _: CSVScriptPubKey | + _: NonStandardScriptPubKey | _: WitnessCommitment | + EmptyScriptPubKey => + throw new IllegalArgumentException( + "We only " + + "want to generate P2PK, P2PKH, and MultiSig ScriptSignatures when creating a CLTVScriptSignature.") + } def signedCSVScriptSignature: Gen[ (CSVScriptSignature, CSVScriptPubKey, Seq[ECPrivateKey])] = @@ -543,10 +540,9 @@ sealed abstract class ScriptGenerators extends BitcoinSLogger { val txSignatures: Seq[ECDigitalSignature] = for { i <- 0 until requiredSigs.getOrElse(1) - } yield - TransactionSignatureCreator.createSig(txSignatureComponent, - privateKeys(i), - hashType) + } yield TransactionSignatureCreator.createSig(txSignatureComponent, + privateKeys(i), + hashType) lock match { case csv: CSVScriptPubKey => @@ -572,12 +568,11 @@ sealed abstract class ScriptGenerators extends BitcoinSLogger { p2shScriptPubKey = P2SHScriptPubKey(wtxSigComponent.scriptPubKey) p2shScriptSig = P2SHScriptSignature( wtxSigComponent.scriptPubKey.asInstanceOf[WitnessScriptPubKey]) - } yield - (p2shScriptSig, - p2shScriptPubKey, - privKeys, - witness, - wtxSigComponent.amount) + } yield (p2shScriptSig, + p2shScriptPubKey, + privKeys, + witness, + wtxSigComponent.amount) def signedP2SHP2WSHScriptSignature: Gen[ ( @@ -590,12 +585,11 @@ sealed abstract class ScriptGenerators extends BitcoinSLogger { (witness, wtxSigComponent, privKeys) <- WitnessGenerators.signedP2WSHTransactionWitness p2shScriptPubKey = P2SHScriptPubKey(wtxSigComponent.scriptPubKey) p2shScriptSig = P2SHScriptSignature(wtxSigComponent.scriptPubKey) - } yield - (p2shScriptSig, - p2shScriptPubKey, - privKeys, - witness, - wtxSigComponent.amount) + } yield (p2shScriptSig, + p2shScriptPubKey, + privKeys, + witness, + wtxSigComponent.amount) /** * This function chooses a random signed `ScriptSignature` diff --git a/testkit/src/main/scala/org/bitcoins/testkit/core/gen/TransactionGenerators.scala b/testkit/src/main/scala/org/bitcoins/testkit/core/gen/TransactionGenerators.scala index cc353615af..71e0fe4db3 100644 --- a/testkit/src/main/scala/org/bitcoins/testkit/core/gen/TransactionGenerators.scala +++ b/testkit/src/main/scala/org/bitcoins/testkit/core/gen/TransactionGenerators.scala @@ -355,12 +355,11 @@ object TransactionGenerators extends BitcoinSLogger { for { (signedScriptSig, csvScriptPubKey, privateKeys) <- ScriptGenerators .signedCSVScriptSignature(csvScriptNum, sequence) - } yield - lockTimeTxHelper(signedScriptSig, - csvScriptPubKey, - privateKeys, - sequence, - None) + } yield lockTimeTxHelper(signedScriptSig, + csvScriptPubKey, + privateKeys, + sequence, + None) /** Generates a [[org.bitcoins.core.protocol.transaction.WitnessTransaction WitnessTransaction]] that has all of * it's inputs signed correctly */ diff --git a/testkit/src/main/scala/org/bitcoins/testkit/core/gen/WitnessGenerators.scala b/testkit/src/main/scala/org/bitcoins/testkit/core/gen/WitnessGenerators.scala index 9a2e27c47c..3ca884c66b 100644 --- a/testkit/src/main/scala/org/bitcoins/testkit/core/gen/WitnessGenerators.scala +++ b/testkit/src/main/scala/org/bitcoins/testkit/core/gen/WitnessGenerators.scala @@ -192,10 +192,9 @@ sealed abstract class WitnessGenerators extends BitcoinSLogger { val requiredSigs = scriptPubKey.requiredSigs val txSignatures = for { i <- 0 until requiredSigs - } yield - TransactionSignatureCreator.createSig(unsignedWtxSigComponent, - privateKeys(i), - hashType) + } yield TransactionSignatureCreator.createSig(unsignedWtxSigComponent, + privateKeys(i), + hashType) //add the signature to the scriptSig instead of having an empty scriptSig val signedScriptSig = MultiSignatureScriptSignature(txSignatures) diff --git a/testkit/src/main/scala/org/bitcoins/testkit/core/gen/ln/LnInvoiceGen.scala b/testkit/src/main/scala/org/bitcoins/testkit/core/gen/ln/LnInvoiceGen.scala index 1610acec15..6f596b6382 100644 --- a/testkit/src/main/scala/org/bitcoins/testkit/core/gen/ln/LnInvoiceGen.scala +++ b/testkit/src/main/scala/org/bitcoins/testkit/core/gen/ln/LnInvoiceGen.scala @@ -101,16 +101,15 @@ sealed abstract class LnInvoiceGen { for { paymentHash <- paymentHashTag descOrHashTag <- descriptionOrDescriptionHashTag - } yield - LnTaggedFields( - paymentHash = paymentHash, - descriptionOrHash = descOrHashTag, - expiryTime = None, - cltvExpiry = None, - fallbackAddress = None, - nodeId = None, - routingInfo = None - ) + } yield LnTaggedFields( + paymentHash = paymentHash, + descriptionOrHash = descOrHashTag, + expiryTime = None, + cltvExpiry = None, + fallbackAddress = None, + nodeId = None, + routingInfo = None + ) } def optionalTags(nodeIdOpt: Option[NodeId]): Gen[LnTaggedFields] = { @@ -123,16 +122,15 @@ sealed abstract class LnInvoiceGen { cltvExpiry <- Gen.option(cltvExpiry) fallbackAddress <- Gen.option(fallbackAddress) routes <- Gen.option(routingInfo) - } yield - LnTaggedFields( - paymentHash = paymentHash, - descriptionOrHash = descOrHashTag, - expiryTime = expiryTime, - cltvExpiry = cltvExpiry, - fallbackAddress = fallbackAddress, - nodeId = nodeIdOpt.map(NodeIdTag(_)), - routingInfo = routes - ) + } yield LnTaggedFields( + paymentHash = paymentHash, + descriptionOrHash = descOrHashTag, + expiryTime = expiryTime, + cltvExpiry = cltvExpiry, + fallbackAddress = fallbackAddress, + nodeId = nodeIdOpt.map(NodeIdTag(_)), + routingInfo = routes + ) } def allTags(nodeIdOpt: Option[NodeId]): Gen[LnTaggedFields] = { @@ -145,16 +143,15 @@ sealed abstract class LnInvoiceGen { cltvExpiry <- cltvExpiry fallbackAddress <- fallbackAddress routes <- routingInfo - } yield - LnTaggedFields( - paymentHash = paymentHash, - descriptionOrHash = descOrHashTag, - expiryTime = Some(expiryTime), - cltvExpiry = Some(cltvExpiry), - fallbackAddress = Some(fallbackAddress), - nodeId = nodeIdOpt.map(NodeIdTag(_)), - routingInfo = Some(routes) - ) + } yield LnTaggedFields( + paymentHash = paymentHash, + descriptionOrHash = descOrHashTag, + expiryTime = Some(expiryTime), + cltvExpiry = Some(cltvExpiry), + fallbackAddress = Some(fallbackAddress), + nodeId = nodeIdOpt.map(NodeIdTag(_)), + routingInfo = Some(routes) + ) } /** Generated a tagged fields with an explicit diff --git a/testkit/src/main/scala/org/bitcoins/testkit/core/gen/ln/LnRouteGen.scala b/testkit/src/main/scala/org/bitcoins/testkit/core/gen/ln/LnRouteGen.scala index 30ebcd6445..28ed2e1109 100644 --- a/testkit/src/main/scala/org/bitcoins/testkit/core/gen/ln/LnRouteGen.scala +++ b/testkit/src/main/scala/org/bitcoins/testkit/core/gen/ln/LnRouteGen.scala @@ -39,12 +39,11 @@ trait LnRouteGen { baseFee <- feeBaseMSat feeProp <- feeProportionalMillionths cltvExpiryDelta <- NumberGenerator.positiveShort - } yield - LnRoute(pubkey = pubKey, - shortChannelID = id, - feeBaseMsat = baseFee, - feePropMilli = feeProp, - cltvExpiryDelta = cltvExpiryDelta) + } yield LnRoute(pubkey = pubKey, + shortChannelID = id, + feeBaseMsat = baseFee, + feePropMilli = feeProp, + cltvExpiryDelta = cltvExpiryDelta) def routes: Gen[Vector[LnRoute]] = { Gen diff --git a/testkit/src/main/scala/org/bitcoins/testkit/core/gen/p2p/ControlMessageGenerator.scala b/testkit/src/main/scala/org/bitcoins/testkit/core/gen/p2p/ControlMessageGenerator.scala index 92d1ffe86c..a62992d29d 100644 --- a/testkit/src/main/scala/org/bitcoins/testkit/core/gen/p2p/ControlMessageGenerator.scala +++ b/testkit/src/main/scala/org/bitcoins/testkit/core/gen/p2p/ControlMessageGenerator.scala @@ -38,13 +38,12 @@ object ControlMessageGenerator { for { fee <- CurrencyUnitGenerator.feeUnit.suchThat( !_.isInstanceOf[SatoshisPerVirtualByte]) - } yield - fee match { - case fee: SatoshisPerByte => FeeFilterMessage(fee) - case fee: SatoshisPerKiloByte => FeeFilterMessage(fee) - case SatoshisPerVirtualByte(_) => - throw new RuntimeException(s"We cannot end up here") - } + } yield fee match { + case fee: SatoshisPerByte => FeeFilterMessage(fee) + case fee: SatoshisPerKiloByte => FeeFilterMessage(fee) + case SatoshisPerVirtualByte(_) => + throw new RuntimeException(s"We cannot end up here") + } } /** @@ -67,22 +66,21 @@ object ControlMessageGenerator { userAgent <- StringGenerators.genString startHeight <- NumberGenerator.int32s relay = scala.util.Random.nextInt() % 2 == 0 - } yield - VersionMessage( - version, - identifier, - timestamp, - addressReceiveServices, - addressReceiveIpAddress, - addressReceivePort, - addressTransServices, - addressTransIpAddress, - addressTransPort, - nonce, - userAgent, - startHeight, - relay - ) + } yield VersionMessage( + version, + identifier, + timestamp, + addressReceiveServices, + addressReceiveIpAddress, + addressReceivePort, + addressTransServices, + addressTransIpAddress, + addressTransPort, + nonce, + userAgent, + startHeight, + relay + ) /** * Generates a [[org.bitcoins.core.p2p.PingMessage]] @@ -154,8 +152,10 @@ object ControlMessageGenerator { hashFuncs <- Gen.choose(0, 50) tweak <- NumberGenerator.uInt32s flags <- BloomFilterGenerator.bloomFlag - } yield - FilterLoadMessage(ByteVector(filter), UInt32(hashFuncs), tweak, flags) + } yield FilterLoadMessage(ByteVector(filter), + UInt32(hashFuncs), + tweak, + flags) /** * Creates a [[org.bitcoins.core.p2p.FilterAddMessage]] diff --git a/testkit/src/main/scala/org/bitcoins/testkit/util/BitcoindRpcTest.scala b/testkit/src/main/scala/org/bitcoins/testkit/util/BitcoindRpcTest.scala index 8e85ed3822..7e60ca7b51 100644 --- a/testkit/src/main/scala/org/bitcoins/testkit/util/BitcoindRpcTest.scala +++ b/testkit/src/main/scala/org/bitcoins/testkit/util/BitcoindRpcTest.scala @@ -27,7 +27,7 @@ abstract class BitcoindRpcTest extends AsyncFlatSpec with BeforeAndAfterAll { sys.error { val msg = s""""bitcoind binary directory (${BitcoindRpcTestUtil.binaryDirectory}) is empty. - |Run 'sbt downloadBitcoind' to fetch needed binaries""".stripMargin + |Run 'sbt downloadBitcoind' to fetch needed binaries""".stripMargin msg } } diff --git a/wallet-test/src/test/scala/org/bitcoins/wallet/WalletAppConfigTest.scala b/wallet-test/src/test/scala/org/bitcoins/wallet/WalletAppConfigTest.scala index a638dac1a6..4f1ce71539 100644 --- a/wallet-test/src/test/scala/org/bitcoins/wallet/WalletAppConfigTest.scala +++ b/wallet-test/src/test/scala/org/bitcoins/wallet/WalletAppConfigTest.scala @@ -38,10 +38,10 @@ class WalletAppConfigTest extends BitcoinSUnitTest { it should "not matter how the overrides are passed in" in { val overrider = ConfigFactory.parseString(s""" - |bitcoin-s { - | network = mainnet - |} - |""".stripMargin) + |bitcoin-s { + | network = mainnet + |} + |""".stripMargin) val throughConstuctor = WalletAppConfig(tempDir, overrider) val throughWithOverrides = config.withOverrides(overrider) @@ -82,15 +82,15 @@ class WalletAppConfigTest extends BitcoinSUnitTest { val tempDir = Files.createTempDirectory("bitcoin-s") val tempFile = Files.createFile(tempDir.resolve("bitcoin-s.conf")) val confStr = """ - | bitcoin-s { - | network = testnet3 - | - | logging { - | level = off - | - | p2p = warn - | } - | } + | bitcoin-s { + | network = testnet3 + | + | logging { + | level = off + | + | p2p = warn + | } + | } """.stripMargin val _ = Files.write(tempFile, confStr.getBytes()) diff --git a/wallet-test/src/test/scala/org/bitcoins/wallet/WalletStorageTest.scala b/wallet-test/src/test/scala/org/bitcoins/wallet/WalletStorageTest.scala index dd755485a5..14a8a4dd87 100644 --- a/wallet-test/src/test/scala/org/bitcoins/wallet/WalletStorageTest.scala +++ b/wallet-test/src/test/scala/org/bitcoins/wallet/WalletStorageTest.scala @@ -91,11 +91,11 @@ class WalletStorageTest it must "fail to read a mnemonic that has bad JSON in it" in { _ => val badJson = """ - | { - | "iv":"ba7722683dad8067df8d069ee04530cc", - | "cipherText":, - | "salt":"2b7e7d718139518070a87fbbda03ea33cdcda83b555020e9344774e6e7d08af2" - | } + | { + | "iv":"ba7722683dad8067df8d069ee04530cc", + | "cipherText":, + | "salt":"2b7e7d718139518070a87fbbda03ea33cdcda83b555020e9344774e6e7d08af2" + | } """.stripMargin Files.write(datadir.resolve(WalletStorage.ENCRYPTED_SEED_FILE_NAME), badJson.getBytes()) diff --git a/wallet-test/src/test/scala/org/bitcoins/wallet/models/SpendingInfoDAOTest.scala b/wallet-test/src/test/scala/org/bitcoins/wallet/models/SpendingInfoDAOTest.scala index f67d9d26a2..05aa59e14f 100644 --- a/wallet-test/src/test/scala/org/bitcoins/wallet/models/SpendingInfoDAOTest.scala +++ b/wallet-test/src/test/scala/org/bitcoins/wallet/models/SpendingInfoDAOTest.scala @@ -25,12 +25,11 @@ class SpendingInfoDAOTest extends BitcoinSWalletTest with WalletDAOFixture { for { created <- WalletTestUtil.insertSegWitUTXO(daos) read <- utxoDAO.read(created.id.get) - } yield - read match { - case None => fail(s"Did not read back a UTXO") - case Some(_: SegwitV0SpendingInfo) => succeed - case Some(other) => fail(s"did not get segwit UTXO: $other") - } + } yield read match { + case None => fail(s"Did not read back a UTXO") + case Some(_: SegwitV0SpendingInfo) => succeed + case Some(other) => fail(s"did not get segwit UTXO: $other") + } } it should "insert a legacy UTXO and read it" in { daos => @@ -38,12 +37,11 @@ class SpendingInfoDAOTest extends BitcoinSWalletTest with WalletDAOFixture { for { created <- WalletTestUtil.insertLegacyUTXO(daos) read <- utxoDAO.read(created.id.get) - } yield - read match { - case None => fail(s"Did not read back a UTXO") - case Some(_: LegacySpendingInfo) => succeed - case Some(other) => fail(s"did not get a legacy UTXO: $other") - } + } yield read match { + case None => fail(s"Did not read back a UTXO") + case Some(_: LegacySpendingInfo) => succeed + case Some(other) => fail(s"did not get a legacy UTXO: $other") + } } it should "find incoming outputs being spent, given a TX" in { daos => diff --git a/wallet/src/main/scala/org/bitcoins/wallet/internal/AddressHandling.scala b/wallet/src/main/scala/org/bitcoins/wallet/internal/AddressHandling.scala index 65266009b7..da3b54fdf8 100644 --- a/wallet/src/main/scala/org/bitcoins/wallet/internal/AddressHandling.scala +++ b/wallet/src/main/scala/org/bitcoins/wallet/internal/AddressHandling.scala @@ -47,11 +47,10 @@ private[wallet] trait AddressHandling extends KeyHandlingLogger { Vector[(TransactionOutput, TransactionOutPoint)]] = for { spks <- listSPKs() - } yield - transaction.outputs.zipWithIndex.collect { - case (out, index) if spks.contains(out.scriptPubKey) => - (out, TransactionOutPoint(transaction.txId, UInt32(index))) - }.toVector + } yield transaction.outputs.zipWithIndex.collect { + case (out, index) if spks.contains(out.scriptPubKey) => + (out, TransactionOutPoint(transaction.txId, UInt32(index))) + }.toVector /** * Derives a new address in the wallet for the diff --git a/wallet/src/main/scala/org/bitcoins/wallet/internal/UtxoHandling.scala b/wallet/src/main/scala/org/bitcoins/wallet/internal/UtxoHandling.scala index 946b94785e..000858c5d7 100644 --- a/wallet/src/main/scala/org/bitcoins/wallet/internal/UtxoHandling.scala +++ b/wallet/src/main/scala/org/bitcoins/wallet/internal/UtxoHandling.scala @@ -134,13 +134,12 @@ private[wallet] trait UtxoHandling extends KeyHandlingLogger { addressDbEitherF.flatMap { addressDbE => val biasedE: CompatEither[AddUtxoError, Future[SpendingInfoDb]] = for { addressDb <- addressDbE - } yield - writeUtxo(txid = transaction.txIdBE, - confirmations = confirmations, - spent = spent, - output, - outPoint, - addressDb) + } yield writeUtxo(txid = transaction.txIdBE, + confirmations = confirmations, + spent = spent, + output, + outPoint, + addressDb) EitherUtil.liftRightBiasedFutureE(biasedE) } map { diff --git a/zmq/src/main/scala/org/bitcoins/zmq/ZMQSubscriber.scala b/zmq/src/main/scala/org/bitcoins/zmq/ZMQSubscriber.scala index 6f9831ad5c..3e03c3b6d0 100644 --- a/zmq/src/main/scala/org/bitcoins/zmq/ZMQSubscriber.scala +++ b/zmq/src/main/scala/org/bitcoins/zmq/ZMQSubscriber.scala @@ -19,20 +19,18 @@ import scodec.bits.ByteVector * @param rawBlockListener */ class ZMQSubscriber( - socket: InetSocketAddress, - hashTxListener: Option[ByteVector => Unit], - hashBlockListener: Option[ByteVector => Unit], - rawTxListener: Option[ByteVector => Unit], - rawBlockListener: Option[ByteVector => Unit]) - extends BitcoinSLogger { + socket: InetSocketAddress, + hashTxListener: Option[ByteVector => Unit], + hashBlockListener: Option[ByteVector => Unit], + rawTxListener: Option[ByteVector => Unit], + rawBlockListener: Option[ByteVector => Unit]) + extends BitcoinSLogger { private var running = true private val context = ZMQ.context(1) private val subscriber: ZMQ.Socket = context.socket(SocketType.SUB) - - private val uri = socket.getHostString + ":" + socket.getPort private case object SubscriberRunnable extends Runnable { @@ -91,7 +89,8 @@ class ZMQSubscriber( } private val subscriberThread = new Thread(SubscriberRunnable) - subscriberThread.setName(s"ZMQSubscriber-thread-${System.currentTimeMillis()}") + subscriberThread.setName( + s"ZMQSubscriber-thread-${System.currentTimeMillis()}") subscriberThread.setDaemon(true) def start(): Unit = {