mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2024-11-19 01:40:55 +01:00
Pull over simple syntax changes for scala3 libraries (#5719)
* Pull over simple syntax changes for {cryptTest,coreTest,testkitCore,appCommons} from #5713 * Fix case analysis in Picklers.scala
This commit is contained in:
parent
90203b295b
commit
ab6d3f5cb7
@ -32,4 +32,4 @@ jobs:
|
||||
~/.bitcoin-s/binaries
|
||||
key: ${{ runner.os }}-app-chain-core-tests-cache
|
||||
- name: run tests
|
||||
run: sbt coverage dbCommonsTest/test chainTest/test chain/coverageReport chain/coverageAggregate chain/coveralls cryptoTestJVM/test cryptoJVM/test cryptoJVM/coverageReport cryptoJVM/coverageAggregate cryptoJVM/coveralls coreTestJVM/test coreJVM/coverageReport coreJVM/coverageAggregate coreJVM/coveralls secp256k1jni/test zmq/test zmq/coverageReport zmq/coverageAggregate zmq/coveralls appCommonsTest/test appServerTest/test oracleServerTest/test lnurlTest/test
|
||||
run: sbt -J-Xmx4g coverage dbCommonsTest/test chainTest/test chain/coverageReport chain/coverageAggregate chain/coveralls cryptoTestJVM/test cryptoJVM/test cryptoJVM/coverageReport cryptoJVM/coverageAggregate cryptoJVM/coveralls coreTestJVM/test coreJVM/coverageReport coreJVM/coverageAggregate coreJVM/coveralls secp256k1jni/test zmq/test zmq/coverageReport zmq/coverageAggregate zmq/coveralls appCommonsTest/test appServerTest/test oracleServerTest/test lnurlTest/test
|
||||
|
@ -30,4 +30,4 @@ jobs:
|
||||
~/.bitcoin-s/binaries
|
||||
key: ${{ runner.os }}-keymanager-wallet-dlc-test-cache
|
||||
- name: run tests
|
||||
run: sbt coverage keyManagerTest/test keyManager/coverageReport keyManager/coverageAggregate keyManager/coveralls feeProviderTest/test walletTest/test dlcWalletTest/test wallet/coverageReport wallet/coverageAggregate wallet/coveralls dlcOracleTest/test asyncUtilsTestJVM/test dlcOracle/coverageReport dlcOracle/coverageAggregate dlcOracle/coveralls
|
||||
run: sbt -J-Xmx4g coverage keyManagerTest/test keyManager/coverageReport keyManager/coverageAggregate keyManager/coveralls feeProviderTest/test walletTest/test dlcWalletTest/test wallet/coverageReport wallet/coverageAggregate wallet/coveralls dlcOracleTest/test asyncUtilsTestJVM/test dlcOracle/coverageReport dlcOracle/coverageAggregate dlcOracle/coveralls
|
||||
|
2
.github/workflows/Linux_2.13_Node_Tests.yml
vendored
2
.github/workflows/Linux_2.13_Node_Tests.yml
vendored
@ -30,4 +30,4 @@ jobs:
|
||||
~/.bitcoin-s/binaries
|
||||
key: ${{ runner.os }}-node-test-cache
|
||||
- name: run tests
|
||||
run: sbt -J-Xmx2g cryptoTestJS/test coreJS/test 'set scalaJSStage in Global := FullOptStage' cryptoTestJS/test coreJS/test asyncUtilsTestJS/test coverage nodeTest/test node/coverageReport node/coverageAggregate node/coveralls dlcNodeTest/test
|
||||
run: sbt -J-Xmx4g cryptoTestJS/test coreJS/test 'set scalaJSStage in Global := FullOptStage' cryptoTestJS/test coreJS/test asyncUtilsTestJS/test coverage nodeTest/test node/coverageReport node/coverageAggregate node/coveralls dlcNodeTest/test
|
||||
|
2
.github/workflows/Linux_2.13_RPC_Tests.yml
vendored
2
.github/workflows/Linux_2.13_RPC_Tests.yml
vendored
@ -30,4 +30,4 @@ jobs:
|
||||
~/.bitcoin-s/binaries
|
||||
key: ${{ runner.os }}-rpc-tests-cache
|
||||
- name: run tests
|
||||
run: sbt coverage bitcoindRpcTest/test bitcoindRpc/coverageReport bitcoindRpc/coverageAggregate bitcoindRpc/coveralls eclairRpcTest/test eclairRpc/coverageReport eclairRpc/coverageAggregate eclairRpc/coveralls lndRpcTest/test clightningRpcTest/test esploraTest/test
|
||||
run: sbt -J-Xmx4g coverage bitcoindRpcTest/test bitcoindRpc/coverageReport bitcoindRpc/coverageAggregate bitcoindRpc/coveralls eclairRpcTest/test eclairRpc/coverageReport eclairRpc/coverageAggregate eclairRpc/coveralls lndRpcTest/test clightningRpcTest/test esploraTest/test
|
||||
|
@ -32,4 +32,4 @@ jobs:
|
||||
~/.bitcoin-s/binaries
|
||||
key: ${{ runner.os }}-wallet-node-dlc-test-cache
|
||||
- name: run tests
|
||||
run: sbt coverage cryptoTestJVM/test coreTestJVM/test secp256k1jni/test zmq/test appCommonsTest/test asyncUtilsTestJVM/test chainTest/test dlcNodeTest/test appServerTest/test
|
||||
run: sbt -J-Xmx4g coverage cryptoTestJVM/test coreTestJVM/test secp256k1jni/test zmq/test appCommonsTest/test asyncUtilsTestJVM/test chainTest/test dlcNodeTest/test appServerTest/test
|
||||
|
2
.github/workflows/Mac_2.13_RPC_Tests.yml
vendored
2
.github/workflows/Mac_2.13_RPC_Tests.yml
vendored
@ -32,4 +32,4 @@ jobs:
|
||||
~/.bitcoin-s/binaries
|
||||
key: ${{ runner.os }}-rpc-tests-cache
|
||||
- name: run tests
|
||||
run: sbt coverage bitcoindRpcTest/test bitcoindRpc/coverageReport bitcoindRpc/coverageAggregate bitcoindRpc/coveralls eclairRpcTest/test eclairRpc/coverageReport eclairRpc/coverageAggregate eclairRpc/coveralls lndRpcTest/test esploraTest/test
|
||||
run: sbt -J-Xmx4g coverage bitcoindRpcTest/test bitcoindRpc/coverageReport bitcoindRpc/coverageAggregate bitcoindRpc/coveralls eclairRpcTest/test eclairRpc/coverageReport eclairRpc/coverageAggregate eclairRpc/coveralls lndRpcTest/test esploraTest/test
|
||||
|
@ -32,4 +32,4 @@ jobs:
|
||||
~/.bitcoin-s/binaries
|
||||
key: ${{ runner.os }}-wallet-node-dlc-test-cache
|
||||
- name: run tests
|
||||
run: sbt coverage walletTest/test dlcWalletTest/test wallet/coverageReport wallet/coverageAggregate wallet/coveralls nodeTest/test node/coverageReport node/coverageAggregate node/coveralls dlcOracleTest/test dlcOracle/coverageReport dlcOracle/coveralls
|
||||
run: sbt -J-Xmx4g coverage walletTest/test dlcWalletTest/test wallet/coverageReport wallet/coverageAggregate wallet/coveralls nodeTest/test node/coverageReport node/coverageAggregate node/coveralls dlcOracleTest/test dlcOracle/coverageReport dlcOracle/coveralls
|
||||
|
2
.github/workflows/PostgresTests.yml
vendored
2
.github/workflows/PostgresTests.yml
vendored
@ -34,4 +34,4 @@ jobs:
|
||||
~/.bitcoin-s/binaries
|
||||
key: ${{ runner.os }}-postgres-cache
|
||||
- name: run tests
|
||||
run: sbt dbCommonsTest/test walletTest/test dlcWalletTest/test chainTest/test dlcOracleTest/test nodeTest/test
|
||||
run: sbt -J-Xmx4g dbCommonsTest/test walletTest/test dlcWalletTest/test chainTest/test dlcOracleTest/test nodeTest/test
|
||||
|
2
.github/workflows/Windows.yml
vendored
2
.github/workflows/Windows.yml
vendored
@ -35,5 +35,5 @@ jobs:
|
||||
~/.bitcoin-s/binaries
|
||||
key: ${{ runner.os }}-cache
|
||||
- name: Windows Crypto, Core, and Database tests
|
||||
run: sbt cryptoTestJVM/test coreTestJVM/test secp256k1jni/test zmq/test appCommonsTest/test asyncUtilsTestJVM/test asyncUtilsTestJS/test appServerTest/test
|
||||
run: sbt -J-Xmx4g cryptoTestJVM/test coreTestJVM/test secp256k1jni/test zmq/test appCommonsTest/test asyncUtilsTestJVM/test asyncUtilsTestJS/test appServerTest/test
|
||||
shell: bash
|
||||
|
2
.github/workflows/docker-publish.yml
vendored
2
.github/workflows/docker-publish.yml
vendored
@ -25,4 +25,4 @@ jobs:
|
||||
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
|
||||
- name: Build and push
|
||||
run: sbt "oracleServer/docker:publish;appServer/docker:publish"
|
||||
run: sbt -J-Xmx4g "oracleServer/docker:publish;appServer/docker:publish"
|
2
.github/workflows/native.yml
vendored
2
.github/workflows/native.yml
vendored
@ -36,7 +36,7 @@ jobs:
|
||||
# from https://github.com/graalvm/graalvm-ce-builds/releases
|
||||
java-version: graalvm@21.0.2=tgz+https://github.com/graalvm/graalvm-ce-builds/releases/download/jdk-21.0.2/graalvm-community-jdk-21.0.2_${{runner.os}}-x64_bin.tar.gz
|
||||
- run: git fetch --tags || true
|
||||
- run: sbt cli/nativeImage
|
||||
- run: sbt -J-Xmx4g cli/nativeImage
|
||||
shell: bash
|
||||
if: ${{ matrix.os != 'windows-latest' }}
|
||||
- run: echo $(pwd)
|
||||
|
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
@ -21,7 +21,7 @@ jobs:
|
||||
java-version: '21.0.4'
|
||||
cache: 'sbt'
|
||||
- uses: olafurpg/setup-gpg@v3
|
||||
- run: sbt -J-Xmx2g ci-release docs/publishWebsite
|
||||
- run: sbt -J-Xmx4g ci-release docs/publishWebsite
|
||||
env:
|
||||
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
|
||||
PGP_SECRET: ${{ secrets.PGP_SECRET }}
|
||||
@ -68,7 +68,7 @@ jobs:
|
||||
run: brew install sbt
|
||||
- name: Build all zips
|
||||
shell: bash # windows needs shell defined
|
||||
run: sbt "universal:stage;universal:packageBin"
|
||||
run: sbt -J-Xmx4g "universal:stage;universal:packageBin"
|
||||
- name: View Artifacts
|
||||
run: ls -l app/server/target/universal/stage
|
||||
# - name: Build appServer
|
||||
|
@ -51,7 +51,7 @@ class DLCStatusTest extends BitcoinSJvmTest {
|
||||
assert(read[DLCStatus](write(status)) == status)
|
||||
assert(
|
||||
read[DLCStatus](
|
||||
write(status.asInstanceOf[DLCStatus])(Picklers.dlcStatusW)
|
||||
write(status.asInstanceOf[DLCStatus])(using Picklers.dlcStatusW)
|
||||
) == status
|
||||
)
|
||||
}
|
||||
@ -100,7 +100,7 @@ class DLCStatusTest extends BitcoinSJvmTest {
|
||||
assert(read[DLCStatus](write(status)) == status)
|
||||
assert(
|
||||
read[DLCStatus](
|
||||
write(status.asInstanceOf[DLCStatus])(Picklers.dlcStatusW)
|
||||
write(status.asInstanceOf[DLCStatus])(using Picklers.dlcStatusW)
|
||||
) == status
|
||||
)
|
||||
}
|
||||
@ -142,7 +142,7 @@ class DLCStatusTest extends BitcoinSJvmTest {
|
||||
assert(read[DLCStatus](write(status)) == status)
|
||||
assert(
|
||||
read[DLCStatus](
|
||||
write(status.asInstanceOf[DLCStatus])(Picklers.dlcStatusW)
|
||||
write(status.asInstanceOf[DLCStatus])(using Picklers.dlcStatusW)
|
||||
) == status
|
||||
)
|
||||
}
|
||||
@ -184,7 +184,7 @@ class DLCStatusTest extends BitcoinSJvmTest {
|
||||
assert(read[DLCStatus](write(status)) == status)
|
||||
assert(
|
||||
read[DLCStatus](
|
||||
write(status.asInstanceOf[DLCStatus])(Picklers.dlcStatusW)
|
||||
write(status.asInstanceOf[DLCStatus])(using Picklers.dlcStatusW)
|
||||
) == status
|
||||
)
|
||||
}
|
||||
@ -226,7 +226,7 @@ class DLCStatusTest extends BitcoinSJvmTest {
|
||||
assert(read[DLCStatus](write(status)) == status)
|
||||
assert(
|
||||
read[DLCStatus](
|
||||
write(status.asInstanceOf[DLCStatus])(Picklers.dlcStatusW)
|
||||
write(status.asInstanceOf[DLCStatus])(using Picklers.dlcStatusW)
|
||||
) == status
|
||||
)
|
||||
}
|
||||
@ -283,7 +283,7 @@ class DLCStatusTest extends BitcoinSJvmTest {
|
||||
assert(read[DLCStatus](write(status)) == status)
|
||||
assert(
|
||||
read[DLCStatus](
|
||||
write(status.asInstanceOf[DLCStatus])(Picklers.dlcStatusW)
|
||||
write(status.asInstanceOf[DLCStatus])(using Picklers.dlcStatusW)
|
||||
) == status
|
||||
)
|
||||
}
|
||||
@ -342,7 +342,7 @@ class DLCStatusTest extends BitcoinSJvmTest {
|
||||
assert(read[DLCStatus](write(status)) == status)
|
||||
assert(
|
||||
read[DLCStatus](
|
||||
write(status.asInstanceOf[DLCStatus])(Picklers.dlcStatusW)
|
||||
write(status.asInstanceOf[DLCStatus])(using Picklers.dlcStatusW)
|
||||
) == status
|
||||
)
|
||||
}
|
||||
@ -395,7 +395,7 @@ class DLCStatusTest extends BitcoinSJvmTest {
|
||||
assert(read[DLCStatus](write(status)) == status)
|
||||
assert(
|
||||
read[DLCStatus](
|
||||
write(status.asInstanceOf[DLCStatus])(Picklers.dlcStatusW)
|
||||
write(status.asInstanceOf[DLCStatus])(using Picklers.dlcStatusW)
|
||||
) == status
|
||||
)
|
||||
}
|
||||
|
@ -51,10 +51,10 @@ class DLCAcceptJsonSerializerTest extends BitcoinSUnitTest {
|
||||
|
||||
it must "have serialization symmetry for a accept json message" in {
|
||||
val accept = upickle.default.read[DLCAcceptTLV](testString)(
|
||||
Picklers.dlcAcceptTLVPickler
|
||||
using Picklers.dlcAcceptTLVPickler
|
||||
)
|
||||
val json: String =
|
||||
upickle.default.write(accept)(Picklers.dlcAcceptTLVPickler)
|
||||
upickle.default.write(accept)(using Picklers.dlcAcceptTLVPickler)
|
||||
assert(json == testString.replaceAll("\\s", ""))
|
||||
}
|
||||
|
||||
|
@ -48,9 +48,10 @@ class DLCSignJsonSerializerTest extends BitcoinSUnitTest {
|
||||
|
||||
it must "have serialization symmetry for dlc sign messages" in {
|
||||
val sign =
|
||||
upickle.default.read[DLCSignTLV](testString)(Picklers.dlcSignTLVPickler)
|
||||
upickle.default.read[DLCSignTLV](testString)(
|
||||
using Picklers.dlcSignTLVPickler)
|
||||
val json: String =
|
||||
upickle.default.write(sign)(Picklers.dlcSignTLVPickler)
|
||||
upickle.default.write(sign)(using Picklers.dlcSignTLVPickler)
|
||||
assert(json == testString.replaceAll("\\s", ""))
|
||||
}
|
||||
}
|
||||
|
@ -11,10 +11,11 @@ class SpendingInfoDbSerializerTest extends BitcoinSUnitTest {
|
||||
it must "be symmetrical" in {
|
||||
val original = TransactionTestUtil.spendingInfoDb
|
||||
val json = upickle.default.writeJs[SpendingInfoDb](original)(
|
||||
Picklers.spendingInfoDbPickler
|
||||
using Picklers.spendingInfoDbPickler
|
||||
)
|
||||
|
||||
val parsed = upickle.default.read(json)(Picklers.spendingInfoDbPickler)
|
||||
val parsed =
|
||||
upickle.default.read(json)(using Picklers.spendingInfoDbPickler)
|
||||
|
||||
assert(parsed == original)
|
||||
}
|
||||
|
@ -23,14 +23,15 @@ object ContractDescriptorParser {
|
||||
value match {
|
||||
case obj: Obj =>
|
||||
upickle.default
|
||||
.read[ContractDescriptorV0TLV](obj)(Picklers.contractDescriptorV0)
|
||||
.read[ContractDescriptorV0TLV](obj)(
|
||||
using Picklers.contractDescriptorV0)
|
||||
case arr: Arr =>
|
||||
// we read the number of digits from the announcement,
|
||||
// take in tlv points for the payout curve
|
||||
// and don't provide access to give a rounding mode as a parameter
|
||||
val payoutPoints: Vector[TLVPoint] = arr.value.toVector.map { pointJs =>
|
||||
upickle.default
|
||||
.read[TLVPoint](pointJs)(Picklers.tlvPointReader)
|
||||
.read[TLVPoint](pointJs)(using Picklers.tlvPointReader)
|
||||
}
|
||||
|
||||
val payoutCurve = DLCPayoutCurve
|
||||
|
@ -178,7 +178,7 @@ object WalletNotification {
|
||||
override val `type`: WalletWsType = WalletWsType.NewAddress
|
||||
|
||||
override val json: ujson.Value = {
|
||||
upickle.default.writeJs(this)(WsPicklers.newAddressPickler)
|
||||
upickle.default.writeJs(this)(using WsPicklers.newAddressPickler)
|
||||
}
|
||||
}
|
||||
|
||||
@ -187,7 +187,7 @@ object WalletNotification {
|
||||
override val `type`: WalletWsType = WalletWsType.TxProcessed
|
||||
|
||||
override val json: ujson.Value = {
|
||||
upickle.default.writeJs(this)(WsPicklers.txProcessedPickler)
|
||||
upickle.default.writeJs(this)(using WsPicklers.txProcessedPickler)
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,7 +196,7 @@ object WalletNotification {
|
||||
override val `type`: WalletWsType = WalletWsType.TxBroadcast
|
||||
|
||||
override val json: ujson.Value = {
|
||||
upickle.default.writeJs(this)(WsPicklers.txBroadcastPickler)
|
||||
upickle.default.writeJs(this)(using WsPicklers.txBroadcastPickler)
|
||||
}
|
||||
}
|
||||
|
||||
@ -205,7 +205,7 @@ object WalletNotification {
|
||||
override val `type`: WalletWsType = WalletWsType.ReservedUtxos
|
||||
|
||||
override val json: ujson.Value = {
|
||||
upickle.default.writeJs(this)(WsPicklers.reservedUtxosPickler)
|
||||
upickle.default.writeJs(this)(using WsPicklers.reservedUtxosPickler)
|
||||
}
|
||||
}
|
||||
|
||||
@ -214,7 +214,7 @@ object WalletNotification {
|
||||
override val `type`: WalletWsType = WalletWsType.DLCStateChange
|
||||
|
||||
override val json: ujson.Value = {
|
||||
upickle.default.writeJs(this)(WsPicklers.dlcStateChangePickler)
|
||||
upickle.default.writeJs(this)(using WsPicklers.dlcStateChangePickler)
|
||||
}
|
||||
}
|
||||
|
||||
@ -223,7 +223,7 @@ object WalletNotification {
|
||||
override val `type`: WalletWsType = WalletWsType.DLCOfferAdd
|
||||
|
||||
override val json: ujson.Value = {
|
||||
upickle.default.writeJs(this)(WsPicklers.dlcOfferAddPickler)
|
||||
upickle.default.writeJs(this)(using WsPicklers.dlcOfferAddPickler)
|
||||
}
|
||||
}
|
||||
|
||||
@ -232,7 +232,7 @@ object WalletNotification {
|
||||
override val `type`: WalletWsType = WalletWsType.DLCOfferRemove
|
||||
|
||||
override val json: ujson.Value = {
|
||||
upickle.default.writeJs(this)(WsPicklers.dlcOfferRemovePickler)
|
||||
upickle.default.writeJs(this)(using WsPicklers.dlcOfferRemovePickler)
|
||||
}
|
||||
}
|
||||
|
||||
@ -241,7 +241,7 @@ object WalletNotification {
|
||||
override val `type`: WalletWsType = WalletWsType.RescanComplete
|
||||
|
||||
override val json: ujson.Value = {
|
||||
upickle.default.writeJs(this)(WsPicklers.rescanPickler)
|
||||
upickle.default.writeJs(this)(using WsPicklers.rescanPickler)
|
||||
}
|
||||
}
|
||||
|
||||
@ -250,7 +250,7 @@ object WalletNotification {
|
||||
override val `type`: WalletWsType = WalletWsType.FeeRateChange
|
||||
|
||||
override val json: ujson.Value = {
|
||||
upickle.default.writeJs(this)(WsPicklers.feeRatePickler)
|
||||
upickle.default.writeJs(this)(using WsPicklers.feeRatePickler)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -262,7 +262,7 @@ object ChainNotification {
|
||||
override val `type`: ChainWsType = ChainWsType.BlockProcessed
|
||||
|
||||
override val json: ujson.Value = {
|
||||
upickle.default.writeJs(this)(WsPicklers.blockProcessedPickler)
|
||||
upickle.default.writeJs(this)(using WsPicklers.blockProcessedPickler)
|
||||
}
|
||||
}
|
||||
|
||||
@ -273,7 +273,7 @@ object ChainNotification {
|
||||
|
||||
override val json: ujson.Value = {
|
||||
upickle.default.writeJs(this)(
|
||||
WsPicklers.compactFilterHeaderProcessedPickler
|
||||
using WsPicklers.compactFilterHeaderProcessedPickler
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -283,7 +283,8 @@ object ChainNotification {
|
||||
override val `type`: ChainWsType = ChainWsType.CompactFilterProcessed
|
||||
|
||||
override val json: ujson.Value = {
|
||||
upickle.default.writeJs(this)(WsPicklers.compactFilterProcessedPickler)
|
||||
upickle.default.writeJs(this)(
|
||||
using WsPicklers.compactFilterProcessedPickler)
|
||||
}
|
||||
}
|
||||
|
||||
@ -292,7 +293,7 @@ object ChainNotification {
|
||||
override val `type`: ChainWsType = ChainWsType.SyncFlagChanged
|
||||
|
||||
override val json: ujson.Value = {
|
||||
upickle.default.writeJs(this)(WsPicklers.syncFlagChangedPickler)
|
||||
upickle.default.writeJs(this)(using WsPicklers.syncFlagChangedPickler)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -304,7 +305,7 @@ object TorNotification {
|
||||
override val payload: Unit = ()
|
||||
|
||||
override val json: ujson.Value = {
|
||||
upickle.default.writeJs(this)(WsPicklers.torStartedPickler)
|
||||
upickle.default.writeJs(this)(using WsPicklers.torStartedPickler)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -316,7 +317,7 @@ object DLCNodeNotification {
|
||||
override def `type`: DLCNodeWsType = DLCNodeWsType.DLCConnectionInitiated
|
||||
|
||||
override def json: Value = upickle.default.writeJs(this)(
|
||||
WsPicklers.dlcNodeConnectionInitiatedPickler
|
||||
using WsPicklers.dlcNodeConnectionInitiatedPickler
|
||||
)
|
||||
}
|
||||
|
||||
@ -325,7 +326,7 @@ object DLCNodeNotification {
|
||||
override def `type`: DLCNodeWsType = DLCNodeWsType.DLCConnectionEstablished
|
||||
|
||||
override def json: Value = upickle.default.writeJs(this)(
|
||||
WsPicklers.dlcNodeConnectionEstablishedPickler
|
||||
using WsPicklers.dlcNodeConnectionEstablishedPickler
|
||||
)
|
||||
}
|
||||
|
||||
@ -334,7 +335,8 @@ object DLCNodeNotification {
|
||||
override def `type`: DLCNodeWsType = DLCNodeWsType.DLCConnectionFailed
|
||||
|
||||
override def json: Value =
|
||||
upickle.default.writeJs(this)(WsPicklers.dlcNodeConnectionFailedPickler)
|
||||
upickle.default.writeJs(this)(
|
||||
using WsPicklers.dlcNodeConnectionFailedPickler)
|
||||
}
|
||||
|
||||
case class DLCAcceptFailed(payload: (Sha256Digest, String))
|
||||
@ -342,7 +344,7 @@ object DLCNodeNotification {
|
||||
override def `type`: DLCNodeWsType = DLCNodeWsType.DLCAcceptFailed
|
||||
|
||||
override def json: Value =
|
||||
upickle.default.writeJs(this)(WsPicklers.dlcAcceptFailedPickler)
|
||||
upickle.default.writeJs(this)(using WsPicklers.dlcAcceptFailedPickler)
|
||||
}
|
||||
|
||||
case class DLCAcceptSucceed(payload: Sha256Digest)
|
||||
@ -350,7 +352,7 @@ object DLCNodeNotification {
|
||||
override def `type`: DLCNodeWsType = DLCNodeWsType.DLCAcceptSucceed
|
||||
|
||||
override def json: Value =
|
||||
upickle.default.writeJs(this)(WsPicklers.dlcAcceptSucceedPickler)
|
||||
upickle.default.writeJs(this)(using WsPicklers.dlcAcceptSucceedPickler)
|
||||
}
|
||||
|
||||
case class DLCOfferSendFailed(payload: (Sha256Digest, String))
|
||||
@ -358,7 +360,7 @@ object DLCNodeNotification {
|
||||
override def `type`: DLCNodeWsType = DLCNodeWsType.DLCOfferSendFailed
|
||||
|
||||
override def json: Value =
|
||||
upickle.default.writeJs(this)(WsPicklers.dlcOfferSendFailedPickler)
|
||||
upickle.default.writeJs(this)(using WsPicklers.dlcOfferSendFailedPickler)
|
||||
}
|
||||
|
||||
case class DLCOfferSendSucceed(payload: Sha256Digest)
|
||||
@ -366,7 +368,7 @@ object DLCNodeNotification {
|
||||
override def `type`: DLCNodeWsType = DLCNodeWsType.DLCOfferSendSucceed
|
||||
|
||||
override def json: Value =
|
||||
upickle.default.writeJs(this)(WsPicklers.dlcOfferSendSucceedPickler)
|
||||
upickle.default.writeJs(this)(using WsPicklers.dlcOfferSendSucceedPickler)
|
||||
}
|
||||
|
||||
case class DLCSignFailed(payload: (Sha256Digest, String))
|
||||
@ -374,7 +376,7 @@ object DLCNodeNotification {
|
||||
override def `type`: DLCNodeWsType = DLCNodeWsType.DLCSignFailed
|
||||
|
||||
override def json: Value =
|
||||
upickle.default.writeJs(this)(WsPicklers.dlcSignFailedPickler)
|
||||
upickle.default.writeJs(this)(using WsPicklers.dlcSignFailedPickler)
|
||||
}
|
||||
|
||||
case class DLCSignSucceed(payload: Sha256Digest)
|
||||
@ -382,6 +384,6 @@ object DLCNodeNotification {
|
||||
override def `type`: DLCNodeWsType = DLCNodeWsType.DLCSignSucceed
|
||||
|
||||
override def json: Value =
|
||||
upickle.default.writeJs(this)(WsPicklers.dlcSignSucceedPickler)
|
||||
upickle.default.writeJs(this)(using WsPicklers.dlcSignSucceedPickler)
|
||||
}
|
||||
}
|
||||
|
@ -1812,7 +1812,7 @@ object CreateNewAccount {
|
||||
def fromJsArr(arr: ujson.Arr): Try[CreateNewAccount] = {
|
||||
arr.arr.toVector match {
|
||||
case purposeJs +: _ =>
|
||||
Try(upickle.default.read(purposeJs)(Picklers.hdPurpose))
|
||||
Try(upickle.default.read(purposeJs)(using Picklers.hdPurpose))
|
||||
.map(CreateNewAccount.apply)
|
||||
case _ =>
|
||||
val exn = new IllegalArgumentException(
|
||||
|
@ -558,7 +558,7 @@ object Picklers {
|
||||
// can't make implicit because it will overlap with ones needed for cli
|
||||
val oracleAnnouncementTLVJsonWriter: Writer[OracleAnnouncementTLV] =
|
||||
writer[Value].comap { case v0: OracleAnnouncementV0TLV =>
|
||||
writeJs(v0)(announcementV0JsonWriter)
|
||||
writeJs(v0)(using announcementV0JsonWriter)
|
||||
}
|
||||
|
||||
// can't make implicit because it will overlap with ones needed for cli
|
||||
@ -577,7 +577,7 @@ object Picklers {
|
||||
|
||||
implicit val fundingInputV0Writer: Writer[FundingInputTLV] =
|
||||
writer[Value].comap { case v0: FundingInputV0TLV =>
|
||||
writeJs(v0)(fundingInputWriter)
|
||||
writeJs(v0)(using fundingInputWriter)
|
||||
}
|
||||
|
||||
implicit val fundingInputWriter: Writer[FundingInputV0TLV] =
|
||||
@ -730,16 +730,16 @@ object Picklers {
|
||||
implicit val contractDescriptorWriter: Writer[ContractDescriptorTLV] =
|
||||
writer[Value].comap {
|
||||
case v0: ContractDescriptorV0TLV =>
|
||||
writeJs(v0)(contractDescriptorV0)
|
||||
writeJs(v0)(using contractDescriptorV0)
|
||||
case v1: ContractDescriptorV1TLV =>
|
||||
writeJs(v1)(contractDescriptorV1Writer)
|
||||
writeJs(v1)(using contractDescriptorV1Writer)
|
||||
}
|
||||
|
||||
implicit val oracleInfoV0TLVWriter: Writer[OracleInfoV0TLV] =
|
||||
writer[Obj].comap { oracleInfo =>
|
||||
Obj(
|
||||
"announcement" -> writeJs(oracleInfo.announcement)(
|
||||
oracleAnnouncementTLVJsonWriter
|
||||
using oracleAnnouncementTLVJsonWriter
|
||||
)
|
||||
)
|
||||
}
|
||||
@ -750,7 +750,7 @@ object Picklers {
|
||||
Obj(
|
||||
"threshold" -> Num(threshold.toDouble),
|
||||
"announcements" -> oracles.map(o =>
|
||||
writeJs(o)(oracleAnnouncementTLVJsonWriter))
|
||||
writeJs(o)(using oracleAnnouncementTLVJsonWriter))
|
||||
)
|
||||
}
|
||||
|
||||
@ -775,7 +775,7 @@ object Picklers {
|
||||
Obj(
|
||||
"threshold" -> Num(threshold.toDouble),
|
||||
"announcements" -> oracles.map(o =>
|
||||
writeJs(o)(oracleAnnouncementTLVJsonWriter)),
|
||||
writeJs(o)(using oracleAnnouncementTLVJsonWriter)),
|
||||
"params" -> writeJs(params)
|
||||
)
|
||||
}
|
||||
@ -825,9 +825,9 @@ object Picklers {
|
||||
val contractInfoJsonWriter: Writer[ContractInfoTLV] = {
|
||||
writer[ujson.Value].comap {
|
||||
case contractInfoV0TLV: ContractInfoV0TLV =>
|
||||
writeJs(contractInfoV0TLV)(contractInfoV0TLVJsonWriter)
|
||||
writeJs(contractInfoV0TLV)(using contractInfoV0TLVJsonWriter)
|
||||
case contractInfoV1TLV: ContractInfoV1TLV =>
|
||||
writeJs(contractInfoV1TLV)(contractInfoV1TLVJsonWriter)
|
||||
writeJs(contractInfoV1TLV)(using contractInfoV1TLVJsonWriter)
|
||||
}
|
||||
}
|
||||
|
||||
@ -835,9 +835,9 @@ object Picklers {
|
||||
writer[Obj].comap { offer =>
|
||||
import offer._
|
||||
Obj(
|
||||
"contractFlags" -> Str(contractFlags.toHexString),
|
||||
"contractFlags" -> Str(ByteVector.fromByte(contractFlags).toHex),
|
||||
"chainHash" -> Str(chainHash.hex),
|
||||
"contractInfo" -> writeJs(contractInfo)(contractInfoJsonWriter),
|
||||
"contractInfo" -> writeJs(contractInfo)(using contractInfoJsonWriter),
|
||||
"fundingPubKey" -> Str(fundingPubKey.hex),
|
||||
"payoutSPK" -> Str(payoutSPK.hex),
|
||||
"payoutSerialId" -> Num(payoutSerialId.toBigInt.toDouble),
|
||||
@ -1211,25 +1211,25 @@ object Picklers {
|
||||
|
||||
implicit val dlcStatusW: Writer[DLCStatus] = writer[Value].comap {
|
||||
case o: Offered =>
|
||||
writeJs(o)(offeredW)
|
||||
writeJs(o)(using offeredW)
|
||||
case a: AcceptedComputingAdaptorSigs =>
|
||||
writeJs(a)(acceptedComputingAdaptorSigsW)
|
||||
writeJs(a)(using acceptedComputingAdaptorSigsW)
|
||||
case a: Accepted =>
|
||||
writeJs(a)(acceptedW)
|
||||
writeJs(a)(using acceptedW)
|
||||
case s: SignedComputingAdaptorSigs =>
|
||||
writeJs(s)(signedComputingAdaptorSigsW)
|
||||
writeJs(s)(using signedComputingAdaptorSigsW)
|
||||
case s: Signed =>
|
||||
writeJs(s)(signedW)
|
||||
writeJs(s)(using signedW)
|
||||
case b: Broadcasted =>
|
||||
writeJs(b)(broadcastedW)
|
||||
writeJs(b)(using broadcastedW)
|
||||
case c: Confirmed =>
|
||||
writeJs(c)(confirmedW)
|
||||
writeJs(c)(using confirmedW)
|
||||
case c: Claimed =>
|
||||
writeJs(c)(claimedW)
|
||||
writeJs(c)(using claimedW)
|
||||
case r: RemoteClaimed =>
|
||||
writeJs(r)(remoteClaimedW)
|
||||
writeJs(r)(using remoteClaimedW)
|
||||
case r: Refunded =>
|
||||
writeJs(r)(refundedW)
|
||||
writeJs(r)(using refundedW)
|
||||
}
|
||||
|
||||
implicit val dlcOfferAddR: Reader[IncomingDLCOfferDb] = reader[Obj].map {
|
||||
|
@ -69,17 +69,18 @@ object WsPicklers {
|
||||
}
|
||||
|
||||
private def writeChainNotification(
|
||||
notification: ChainNotification[_]
|
||||
notification: ChainNotification[?]
|
||||
): ujson.Obj = {
|
||||
val payloadJson: ujson.Value = notification match {
|
||||
case BlockProcessedNotification(block) =>
|
||||
upickle.default.writeJs(block)(Picklers.getBlockHeaderResultPickler)
|
||||
upickle.default.writeJs(block)(
|
||||
using Picklers.getBlockHeaderResultPickler)
|
||||
case CompactFilterHeaderProcessedNotification(filterHeader) =>
|
||||
upickle.default.writeJs(filterHeader)(
|
||||
Picklers.compactFilterHeaderPickler
|
||||
using Picklers.compactFilterHeaderPickler
|
||||
)
|
||||
case CompactFilterProcessedNotification(filter) =>
|
||||
upickle.default.writeJs(filter)(Picklers.compactFilterDbPickler)
|
||||
upickle.default.writeJs(filter)(using Picklers.compactFilterDbPickler)
|
||||
case SyncFlagChangedNotification(syncing) =>
|
||||
upickle.default.writeJs(syncing)
|
||||
}
|
||||
@ -91,24 +92,27 @@ object WsPicklers {
|
||||
notificationObj
|
||||
}
|
||||
|
||||
private def readChainNotification(obj: ujson.Obj): ChainNotification[_] = {
|
||||
private def readChainNotification(obj: ujson.Obj): ChainNotification[?] = {
|
||||
val typeObj = read[ChainWsType](obj(PicklerKeys.typeKey))
|
||||
val payloadObj = obj(PicklerKeys.payloadKey)
|
||||
|
||||
typeObj match {
|
||||
case ChainWsType.BlockProcessed =>
|
||||
val block =
|
||||
upickle.default.read(payloadObj)(Picklers.getBlockHeaderResultPickler)
|
||||
upickle.default.read(payloadObj)(
|
||||
using Picklers.getBlockHeaderResultPickler)
|
||||
BlockProcessedNotification(block)
|
||||
case ChainWsType.CompactFilterHeaderProcessed =>
|
||||
val filterheader =
|
||||
upickle.default.read(payloadObj)(Picklers.compactFilterHeaderPickler)
|
||||
upickle.default.read(payloadObj)(
|
||||
using Picklers.compactFilterHeaderPickler)
|
||||
|
||||
CompactFilterHeaderProcessedNotification(filterheader)
|
||||
|
||||
case ChainWsType.CompactFilterProcessed =>
|
||||
val filter =
|
||||
upickle.default.read(payloadObj)(Picklers.compactFilterDbPickler)
|
||||
upickle.default.read(payloadObj)(
|
||||
using Picklers.compactFilterDbPickler)
|
||||
CompactFilterProcessedNotification(filter)
|
||||
case ChainWsType.SyncFlagChanged =>
|
||||
val syncing = payloadObj.bool
|
||||
@ -117,29 +121,29 @@ object WsPicklers {
|
||||
}
|
||||
|
||||
private def writeWalletNotification(
|
||||
notification: WalletNotification[_]
|
||||
notification: WalletNotification[?]
|
||||
): ujson.Obj = {
|
||||
val payloadJson: ujson.Value = notification match {
|
||||
case TxBroadcastNotification(tx) =>
|
||||
upickle.default.writeJs(tx)(Picklers.transactionPickler)
|
||||
upickle.default.writeJs(tx)(using Picklers.transactionPickler)
|
||||
case TxProcessedNotification(tx) =>
|
||||
upickle.default.writeJs(tx)(Picklers.transactionPickler)
|
||||
upickle.default.writeJs(tx)(using Picklers.transactionPickler)
|
||||
case NewAddressNotification(address) =>
|
||||
upickle.default.writeJs(address)(Picklers.bitcoinAddressPickler)
|
||||
upickle.default.writeJs(address)(using Picklers.bitcoinAddressPickler)
|
||||
case ReservedUtxosNotification(utxos) =>
|
||||
val vec = utxos.map(u =>
|
||||
upickle.default.writeJs(u)(Picklers.spendingInfoDbPickler))
|
||||
upickle.default.writeJs(u)(using Picklers.spendingInfoDbPickler))
|
||||
ujson.Arr.from(vec)
|
||||
case DLCStateChangeNotification(status) =>
|
||||
upickle.default.writeJs(status)(Picklers.dlcStatusW)
|
||||
upickle.default.writeJs(status)(using Picklers.dlcStatusW)
|
||||
case DLCOfferAddNotification(offerDb) =>
|
||||
upickle.default.writeJs(offerDb)(Picklers.dlcOfferAddW)
|
||||
upickle.default.writeJs(offerDb)(using Picklers.dlcOfferAddW)
|
||||
case DLCOfferRemoveNotification(offerHash) =>
|
||||
upickle.default.writeJs(offerHash)(Picklers.dlcOfferRemoveW)
|
||||
upickle.default.writeJs(offerHash)(using Picklers.dlcOfferRemoveW)
|
||||
case r: RescanComplete =>
|
||||
upickle.default.writeJs(r)(Picklers.rescanComplete)
|
||||
upickle.default.writeJs(r)(using Picklers.rescanComplete)
|
||||
case FeeRateChange(feeRate) =>
|
||||
upickle.default.writeJs(feeRate)(Picklers.feeUnit)
|
||||
upickle.default.writeJs(feeRate)(using Picklers.feeUnit)
|
||||
}
|
||||
|
||||
val notificationObj = ujson.Obj(
|
||||
@ -149,45 +153,49 @@ object WsPicklers {
|
||||
notificationObj
|
||||
}
|
||||
|
||||
private def readWalletNotification(obj: ujson.Obj): WalletNotification[_] = {
|
||||
private def readWalletNotification(obj: ujson.Obj): WalletNotification[?] = {
|
||||
val typeObj = read[WalletWsType](obj(PicklerKeys.typeKey))
|
||||
val payloadObj = obj(PicklerKeys.payloadKey)
|
||||
typeObj match {
|
||||
case WalletWsType.TxBroadcast =>
|
||||
val tx = upickle.default.read(payloadObj)(Picklers.transactionPickler)
|
||||
val tx =
|
||||
upickle.default.read(payloadObj)(using Picklers.transactionPickler)
|
||||
TxBroadcastNotification(tx)
|
||||
case WalletWsType.TxProcessed =>
|
||||
val tx = upickle.default.read(payloadObj)(Picklers.transactionPickler)
|
||||
val tx =
|
||||
upickle.default.read(payloadObj)(using Picklers.transactionPickler)
|
||||
TxProcessedNotification(tx)
|
||||
case WalletWsType.NewAddress =>
|
||||
val address =
|
||||
upickle.default.read(payloadObj)(Picklers.bitcoinAddressPickler)
|
||||
upickle.default.read(payloadObj)(using Picklers.bitcoinAddressPickler)
|
||||
NewAddressNotification(address)
|
||||
case WalletWsType.ReservedUtxos =>
|
||||
val utxos = obj(PicklerKeys.payloadKey).arr.toVector.map { utxoJson =>
|
||||
upickle.default.read(utxoJson)(Picklers.spendingInfoDbPickler)
|
||||
upickle.default.read(utxoJson)(using Picklers.spendingInfoDbPickler)
|
||||
}
|
||||
ReservedUtxosNotification(utxos)
|
||||
case WalletWsType.DLCStateChange =>
|
||||
val status = upickle.default.read(payloadObj)(Picklers.dlcStatusR)
|
||||
val status = upickle.default.read(payloadObj)(using Picklers.dlcStatusR)
|
||||
DLCStateChangeNotification(status)
|
||||
case WalletWsType.DLCOfferAdd =>
|
||||
val offerDb = upickle.default.read(payloadObj)(Picklers.dlcOfferAddR)
|
||||
val offerDb =
|
||||
upickle.default.read(payloadObj)(using Picklers.dlcOfferAddR)
|
||||
DLCOfferAddNotification(offerDb)
|
||||
case WalletWsType.DLCOfferRemove =>
|
||||
val offerHash =
|
||||
upickle.default.read(payloadObj)(Picklers.dlcOfferRemoveR)
|
||||
upickle.default.read(payloadObj)(using Picklers.dlcOfferRemoveR)
|
||||
DLCOfferRemoveNotification(offerHash)
|
||||
case WalletWsType.RescanComplete =>
|
||||
val complete = upickle.default.read(payloadObj)(Picklers.rescanComplete)
|
||||
val complete =
|
||||
upickle.default.read(payloadObj)(using Picklers.rescanComplete)
|
||||
complete
|
||||
case WalletWsType.FeeRateChange =>
|
||||
FeeRateChange(upickle.default.read(payloadObj)(Picklers.feeUnit))
|
||||
FeeRateChange(upickle.default.read(payloadObj)(using Picklers.feeUnit))
|
||||
}
|
||||
}
|
||||
|
||||
private def writeTorNotification(
|
||||
notification: TorNotification[_]
|
||||
notification: TorNotification[?]
|
||||
): ujson.Obj = {
|
||||
val payloadJson = notification.`type` match {
|
||||
case TorWsType.TorStarted =>
|
||||
@ -201,7 +209,7 @@ object WsPicklers {
|
||||
notificationObj
|
||||
}
|
||||
|
||||
private def readTorNotification(obj: ujson.Obj): TorNotification[_] = {
|
||||
private def readTorNotification(obj: ujson.Obj): TorNotification[?] = {
|
||||
val typeObj = read[TorWsType](obj(PicklerKeys.typeKey))
|
||||
typeObj match {
|
||||
case TorWsType.TorStarted =>
|
||||
@ -210,7 +218,7 @@ object WsPicklers {
|
||||
}
|
||||
|
||||
private def writeDLCNodeNotification(
|
||||
notification: DLCNodeNotification[_]
|
||||
notification: DLCNodeNotification[?]
|
||||
): ujson.Obj = {
|
||||
def addr2str(address: InetSocketAddress) =
|
||||
address.getHostName + ":" + address.getPort
|
||||
@ -246,7 +254,7 @@ object WsPicklers {
|
||||
|
||||
private def readDLCNodeNotification(
|
||||
obj: ujson.Obj
|
||||
): DLCNodeNotification[_] = {
|
||||
): DLCNodeNotification[?] = {
|
||||
val typeObj = read[DLCNodeWsType](obj(PicklerKeys.typeKey))
|
||||
val payloadObj = obj(PicklerKeys.payloadKey)
|
||||
|
||||
@ -328,16 +336,16 @@ object WsPicklers {
|
||||
}
|
||||
|
||||
implicit val dlcNodeNotificationPickler
|
||||
: ReadWriter[DLCNodeNotification[_]] = {
|
||||
: ReadWriter[DLCNodeNotification[?]] = {
|
||||
readwriter[ujson.Obj]
|
||||
.bimap(writeDLCNodeNotification, readDLCNodeNotification)
|
||||
}
|
||||
|
||||
implicit val walletNotificationPickler: ReadWriter[WalletNotification[_]] = {
|
||||
implicit val walletNotificationPickler: ReadWriter[WalletNotification[?]] = {
|
||||
readwriter[ujson.Obj].bimap(writeWalletNotification, readWalletNotification)
|
||||
}
|
||||
|
||||
implicit val chainNotificationPickler: ReadWriter[ChainNotification[_]] = {
|
||||
implicit val chainNotificationPickler: ReadWriter[ChainNotification[?]] = {
|
||||
readwriter[ujson.Obj].bimap(writeChainNotification, readChainNotification)
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ import scala.sys.process.{Process, ProcessBuilder, ProcessLogger}
|
||||
trait NativeProcessFactory extends BitcoinSLogger {
|
||||
implicit protected def executionContext: ExecutionContext
|
||||
|
||||
private[this] var processOpt: Option[Process] = None
|
||||
private var processOpt: Option[Process] = None
|
||||
|
||||
private lazy val process: ProcessBuilder = scala.sys.process.Process(cmd)
|
||||
|
||||
|
@ -18,7 +18,7 @@ class TaprootWalletTestVectors extends BitcoinSUnitTest {
|
||||
|
||||
lazy val testCase: TaprootWalletTestCases = {
|
||||
upickle.default.read[TaprootWalletTestCases](lines)(
|
||||
TaprootWalletTestCase.walletTestVectorReader
|
||||
using TaprootWalletTestCase.walletTestVectorReader
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ package org.bitcoins.core.crypto
|
||||
|
||||
import org.bitcoins.testkitcore.gen.CryptoGenerators
|
||||
import org.bitcoins.testkitcore.util.BitcoinSUnitTest
|
||||
import scodec.bits.HexStringSyntax
|
||||
import scodec.bits.ByteVector
|
||||
|
||||
import scala.util.{Failure, Try}
|
||||
|
||||
@ -28,9 +28,9 @@ class BIP39SeedTest extends BitcoinSUnitTest {
|
||||
forAll(CryptoGenerators.entropy.bits128) { entropy =>
|
||||
val attempt = Try { BIP39Seed.fromBytes(entropy.toByteVector.drop(1)) }
|
||||
assert(attempt.isFailure)
|
||||
val exc = attempt.asInstanceOf[Failure[_]].exception
|
||||
val exc = attempt.asInstanceOf[Failure[?]].exception
|
||||
|
||||
assert(exc.getMessage contains "Seed must be between")
|
||||
assert(exc.getMessage `contains` "Seed must be between")
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,16 +38,16 @@ class BIP39SeedTest extends BitcoinSUnitTest {
|
||||
forAll(CryptoGenerators.entropy.bits256) { entropy =>
|
||||
val attempt = Try {
|
||||
BIP39Seed.fromBytes(
|
||||
(entropy ++ entropy).toByteVector ++ hex"c"
|
||||
(entropy ++ entropy).toByteVector ++ ByteVector.fromValidHex("c")
|
||||
) // one byte too much
|
||||
}
|
||||
assert(attempt.isFailure)
|
||||
|
||||
val exc = attempt
|
||||
.asInstanceOf[Failure[_]]
|
||||
.asInstanceOf[Failure[?]]
|
||||
.exception
|
||||
|
||||
assert(exc.getMessage contains "Seed must be between")
|
||||
assert(exc.getMessage `contains` "Seed must be between")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package org.bitcoins.core.crypto
|
||||
|
||||
import org.bitcoins.core.crypto.ExtKeyVersion._
|
||||
import org.bitcoins.core.crypto.ExtKeyVersion.*
|
||||
import org.bitcoins.core.hd.BIP32Path
|
||||
import org.bitcoins.core.number.UInt32
|
||||
import org.bitcoins.testkitcore.gen.{
|
||||
@ -9,7 +9,7 @@ import org.bitcoins.testkitcore.gen.{
|
||||
NumberGenerator
|
||||
}
|
||||
import org.bitcoins.testkitcore.util.BitcoinSUnitTest
|
||||
import scodec.bits.HexStringSyntax
|
||||
import scodec.bits.ByteVector
|
||||
|
||||
import scala.util.{Failure, Success, Try}
|
||||
|
||||
@ -101,7 +101,7 @@ class ExtKeyTest extends BitcoinSUnitTest {
|
||||
// https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#test-vectors
|
||||
it must "pass the test vectors in BIP32" in {
|
||||
// master key
|
||||
val seedBytes = hex"000102030405060708090a0b0c0d0e0f"
|
||||
val seedBytes = ByteVector.fromValidHex("000102030405060708090a0b0c0d0e0f")
|
||||
|
||||
val path = BIP32Path.empty
|
||||
|
||||
@ -176,7 +176,8 @@ class ExtKeyTest extends BitcoinSUnitTest {
|
||||
|
||||
it must "pass test vector 2 in BIP32" in {
|
||||
val seedBytes =
|
||||
hex"fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542"
|
||||
ByteVector.fromValidHex(
|
||||
"fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542")
|
||||
|
||||
val masterPriv =
|
||||
ExtPrivateKey(LegacyMainNetPriv, Some(seedBytes), BIP32Path.empty)
|
||||
@ -252,7 +253,8 @@ class ExtKeyTest extends BitcoinSUnitTest {
|
||||
|
||||
it must "pass test vector 3 in BIP32" in {
|
||||
val seedBytes =
|
||||
hex"4b381541583be4423346c643850da4b320e46a87ae3d2a4e6da11eba819cd4acba45d239319ac14f863b8d5ab5a0d0c64d2e8a1e7d1457df2e5a3c51c73235be"
|
||||
ByteVector.fromValidHex(
|
||||
"4b381541583be4423346c643850da4b320e46a87ae3d2a4e6da11eba819cd4acba45d239319ac14f863b8d5ab5a0d0c64d2e8a1e7d1457df2e5a3c51c73235be")
|
||||
|
||||
val masterPrivKey =
|
||||
ExtPrivateKey(LegacyMainNetPriv, Some(seedBytes), BIP32Path.empty)
|
||||
@ -278,7 +280,8 @@ class ExtKeyTest extends BitcoinSUnitTest {
|
||||
|
||||
it must "pass test vector 4 in BIP32" in {
|
||||
val seedBytes =
|
||||
hex"3ddd5602285899a946114506157c7997e5444528f3003f6134712147db19b678"
|
||||
ByteVector.fromValidHex(
|
||||
"3ddd5602285899a946114506157c7997e5444528f3003f6134712147db19b678")
|
||||
|
||||
val masterPrivKey =
|
||||
ExtPrivateKey(LegacyMainNetPriv, Some(seedBytes), BIP32Path.empty)
|
||||
@ -473,7 +476,8 @@ class ExtKeyTest extends BitcoinSUnitTest {
|
||||
|
||||
it must "not serialize a ExtPrivateKey to string" in {
|
||||
val seedBytes =
|
||||
hex"4b381541583be4423346c643850da4b320e46a87ae3d2a4e6da11eba819cd4acba45d239319ac14f863b8d5ab5a0d0c64d2e8a1e7d1457df2e5a3c51c73235be"
|
||||
ByteVector.fromValidHex(
|
||||
"4b381541583be4423346c643850da4b320e46a87ae3d2a4e6da11eba819cd4acba45d239319ac14f863b8d5ab5a0d0c64d2e8a1e7d1457df2e5a3c51c73235be")
|
||||
|
||||
val masterPriv =
|
||||
ExtPrivateKey(LegacyMainNetPriv, Some(seedBytes), BIP32Path.empty)
|
||||
|
@ -3,7 +3,7 @@ package org.bitcoins.core.crypto
|
||||
import org.bitcoins.testkitcore.gen.CryptoGenerators
|
||||
import org.bitcoins.testkitcore.util.BitcoinSUnitTest
|
||||
import org.scalatest.Assertion
|
||||
import scodec.bits.{BinStringSyntax, BitVector, ByteVector}
|
||||
import scodec.bits.{BitVector, ByteVector}
|
||||
import ujson._
|
||||
import upickle.default._
|
||||
|
||||
@ -60,7 +60,7 @@ class MnemonicCodeTest extends BitcoinSUnitTest {
|
||||
it must "fail to generate mnemonics from entropy of bad length" in {
|
||||
def testEntropyFailure(entropy: BitVector): Assertion = {
|
||||
val short = entropy.drop(1)
|
||||
val long = entropy ++ bin"1"
|
||||
val long = entropy ++ BitVector.fromValidHex("1")
|
||||
assertThrows[IllegalArgumentException](MnemonicCode.fromEntropy(short))
|
||||
assertThrows[IllegalArgumentException](MnemonicCode.fromEntropy(long))
|
||||
}
|
||||
@ -79,12 +79,12 @@ class MnemonicCodeTest extends BitcoinSUnitTest {
|
||||
assert(attempt.isFailure)
|
||||
|
||||
val exc = attempt
|
||||
.asInstanceOf[Failure[_]]
|
||||
.asInstanceOf[Failure[?]]
|
||||
.exception
|
||||
|
||||
val message = exc.getMessage
|
||||
|
||||
message contains "Entropy cannot be longer"
|
||||
message `contains` "Entropy cannot be longer"
|
||||
}
|
||||
}
|
||||
|
||||
@ -99,11 +99,11 @@ class MnemonicCodeTest extends BitcoinSUnitTest {
|
||||
}
|
||||
assert(attempt.isFailure)
|
||||
val exc = attempt
|
||||
.asInstanceOf[Failure[_]]
|
||||
.asInstanceOf[Failure[?]]
|
||||
.exception
|
||||
|
||||
val message = exc.getMessage
|
||||
assert(message contains "Entropy must be at least")
|
||||
assert(message `contains` "Entropy must be at least")
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,8 +113,8 @@ class MnemonicCodeTest extends BitcoinSUnitTest {
|
||||
val codeT = Try(MnemonicCode.fromEntropy(e.drop(1)))
|
||||
|
||||
assert(codeT.isFailure)
|
||||
val exc = codeT.asInstanceOf[Failure[_]].exception
|
||||
assert(exc.getMessage contains "Entropy must be a multiple")
|
||||
val exc = codeT.asInstanceOf[Failure[?]].exception
|
||||
assert(exc.getMessage `contains` "Entropy must be a multiple")
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,8 +151,8 @@ class MnemonicCodeTest extends BitcoinSUnitTest {
|
||||
}
|
||||
|
||||
assert(fromWordsT.isFailure)
|
||||
val exc = fromWordsT.asInstanceOf[Failure[_]].exception
|
||||
assert(exc.getMessage contains "checksum is not valid")
|
||||
val exc = fromWordsT.asInstanceOf[Failure[?]].exception
|
||||
assert(exc.getMessage `contains` "checksum is not valid")
|
||||
}
|
||||
|
||||
it must "fail to generate mnemonic codes from word vectors of bad length" in {
|
||||
@ -161,12 +161,12 @@ class MnemonicCodeTest extends BitcoinSUnitTest {
|
||||
assert(attempt.isFailure)
|
||||
|
||||
val exc = attempt
|
||||
.asInstanceOf[Failure[_]]
|
||||
.asInstanceOf[Failure[?]]
|
||||
.exception
|
||||
|
||||
val message = exc.getMessage
|
||||
|
||||
assert(message contains "Number of words")
|
||||
assert(message `contains` "Number of words")
|
||||
}
|
||||
|
||||
forAll(CryptoGenerators.mnemonicPhrase) { phrase =>
|
||||
@ -175,11 +175,11 @@ class MnemonicCodeTest extends BitcoinSUnitTest {
|
||||
assert(attempt.isFailure)
|
||||
|
||||
val exc = attempt
|
||||
.asInstanceOf[Failure[_]]
|
||||
.asInstanceOf[Failure[?]]
|
||||
.exception
|
||||
|
||||
val message = exc.getMessage
|
||||
assert(message contains "Number of words")
|
||||
assert(message `contains` "Number of words")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ class BIP32PathTest extends BitcoinSUnitTest {
|
||||
|
||||
it must "have varargs and vector constructors what work the same way" in {
|
||||
forAll(HDGenerators.bip32Path) { bip32 =>
|
||||
assert(BIP32Path(bip32.path) == BIP32Path(bip32.path: _*))
|
||||
assert(BIP32Path(bip32.path) == BIP32Path(bip32.path*))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,13 +38,13 @@ class CurrencyUnitTest extends BitcoinSUnitTest {
|
||||
}
|
||||
|
||||
it must "have Long syntax" in {
|
||||
forAll(Gen.choose(0, Satoshis.max.toLong / 100000000)) { num =>
|
||||
forAll(Gen.choose(0L, Satoshis.max.toLong / 100000000)) { num =>
|
||||
assert(num.bitcoins == Bitcoins(num))
|
||||
assert(num.bitcoin == Bitcoins(num))
|
||||
assert(num.BTC == Bitcoins(num))
|
||||
}
|
||||
|
||||
forAll(Gen.choose(0, Satoshis.max.toLong)) { num =>
|
||||
forAll(Gen.choose(0L, Satoshis.max.toLong)) { num =>
|
||||
assert(num.satoshis == Satoshis(num))
|
||||
assert(num.satoshi == Satoshis(num))
|
||||
assert(num.sats == Satoshis(num))
|
||||
|
@ -6,7 +6,7 @@ import org.bitcoins.crypto.SipHashKey
|
||||
import org.bitcoins.testkitcore.gen.NumberGenerator
|
||||
import org.bitcoins.testkitcore.util.BitcoinSUnitTest
|
||||
import org.scalacheck.Gen
|
||||
import scodec.bits.{BinStringSyntax, ByteVector}
|
||||
import scodec.bits.{BitVector, ByteVector}
|
||||
|
||||
class GCSTest extends BitcoinSUnitTest {
|
||||
behavior of "GCS"
|
||||
@ -18,7 +18,7 @@ class GCSTest extends BitcoinSUnitTest {
|
||||
|
||||
val encoding = GCS.golombEncode(item = original, p = p)
|
||||
|
||||
assert(encoding == bin"000")
|
||||
assert(encoding == BitVector.fromValidBin("000"))
|
||||
|
||||
val decode = GCS.golombDecode(codedItem = encoding, p = p)
|
||||
|
||||
@ -31,7 +31,7 @@ class GCSTest extends BitcoinSUnitTest {
|
||||
|
||||
val encoding = GCS.golombEncode(item = original, p = p)
|
||||
|
||||
assert(encoding == bin"001")
|
||||
assert(encoding == BitVector.fromValidBin("001"))
|
||||
|
||||
val decode = GCS.golombDecode(codedItem = encoding, p = p)
|
||||
|
||||
@ -44,7 +44,7 @@ class GCSTest extends BitcoinSUnitTest {
|
||||
|
||||
val encoding = GCS.golombEncode(item = original, p = p)
|
||||
|
||||
assert(encoding == bin"010")
|
||||
assert(encoding == BitVector.fromValidBin("010"))
|
||||
|
||||
val decode = GCS.golombDecode(codedItem = encoding, p = p)
|
||||
|
||||
@ -57,7 +57,7 @@ class GCSTest extends BitcoinSUnitTest {
|
||||
|
||||
val encoding = GCS.golombEncode(item = original, p = p)
|
||||
|
||||
assert(encoding == bin"011")
|
||||
assert(encoding == BitVector.fromValidBin("011"))
|
||||
|
||||
val decode = GCS.golombDecode(codedItem = encoding, p = p)
|
||||
|
||||
@ -70,7 +70,7 @@ class GCSTest extends BitcoinSUnitTest {
|
||||
|
||||
val encoding = GCS.golombEncode(item = original, p = p)
|
||||
|
||||
assert(encoding == bin"1000")
|
||||
assert(encoding == BitVector.fromValidBin("1000"))
|
||||
|
||||
val decode = GCS.golombDecode(codedItem = encoding, p = p)
|
||||
|
||||
@ -83,7 +83,7 @@ class GCSTest extends BitcoinSUnitTest {
|
||||
|
||||
val encoding = GCS.golombEncode(item = original, p = p)
|
||||
|
||||
assert(encoding == bin"1001")
|
||||
assert(encoding == BitVector.fromValidBin("1001"))
|
||||
|
||||
val decode = GCS.golombDecode(codedItem = encoding, p = p)
|
||||
|
||||
@ -96,7 +96,7 @@ class GCSTest extends BitcoinSUnitTest {
|
||||
|
||||
val encoding = GCS.golombEncode(item = original, p = p)
|
||||
|
||||
assert(encoding == bin"1010")
|
||||
assert(encoding == BitVector.fromValidBin("1010"))
|
||||
|
||||
val decode = GCS.golombDecode(codedItem = encoding, p = p)
|
||||
|
||||
@ -109,7 +109,7 @@ class GCSTest extends BitcoinSUnitTest {
|
||||
|
||||
val encoding = GCS.golombEncode(item = original, p = p)
|
||||
|
||||
assert(encoding == bin"1011")
|
||||
assert(encoding == BitVector.fromValidBin("1011"))
|
||||
|
||||
val decode = GCS.golombDecode(codedItem = encoding, p = p)
|
||||
|
||||
@ -122,7 +122,7 @@ class GCSTest extends BitcoinSUnitTest {
|
||||
|
||||
val encoding = GCS.golombEncode(item = original, p = p)
|
||||
|
||||
assert(encoding == bin"11000")
|
||||
assert(encoding == BitVector.fromValidBin("11000"))
|
||||
|
||||
val decode = GCS.golombDecode(codedItem = encoding, p = p)
|
||||
|
||||
@ -135,7 +135,7 @@ class GCSTest extends BitcoinSUnitTest {
|
||||
|
||||
val encoding = GCS.golombEncode(item = original, p = p)
|
||||
|
||||
assert(encoding == bin"11001")
|
||||
assert(encoding == BitVector.fromValidBin("11001"))
|
||||
|
||||
val decode = GCS.golombDecode(codedItem = encoding, p = p)
|
||||
|
||||
@ -170,12 +170,12 @@ class GCSTest extends BitcoinSUnitTest {
|
||||
|
||||
val codedSet = GCS.encodeSortedSet(sortedItems, p)
|
||||
|
||||
val coded0 = bin"000"
|
||||
val coded1 = bin"001"
|
||||
val coded2 = bin"010"
|
||||
val coded3 = bin"011"
|
||||
val coded4 = bin"1000"
|
||||
val coded5 = bin"1001"
|
||||
val coded0 = BitVector.fromValidBin("000")
|
||||
val coded1 = BitVector.fromValidBin("001")
|
||||
val coded2 = BitVector.fromValidBin("010")
|
||||
val coded3 = BitVector.fromValidBin("011")
|
||||
val coded4 = BitVector.fromValidBin("1000")
|
||||
val coded5 = BitVector.fromValidBin("1001")
|
||||
val expectedCodedSet =
|
||||
coded0 ++ coded1 ++ coded2 ++ coded3 ++ coded4 ++ coded5
|
||||
|
||||
|
@ -79,7 +79,7 @@ class MilliSatoshisTest extends BitcoinSUnitTest {
|
||||
|
||||
it must "subtract msats" in {
|
||||
forAll(LnCurrencyUnitGen.milliSatoshisPair) { case (first, second) =>
|
||||
val subtracted = first subtractSafe second
|
||||
val subtracted = first `subtractSafe` second
|
||||
val isPositive = (first.toBigInt - second.toBigInt) >= 0
|
||||
|
||||
assert(subtracted.isSuccess == isPositive)
|
||||
|
@ -498,7 +498,7 @@ class DescriptorTest extends BitcoinSUnitTest {
|
||||
)
|
||||
case x: ScriptPathTreeExpression =>
|
||||
x.source.leafs.head.source
|
||||
.asInstanceOf[P2PKScriptExpression[_]]
|
||||
.asInstanceOf[P2PKScriptExpression[?]]
|
||||
.source
|
||||
.asInstanceOf[ExtXOnlyPublicKeyExpression]
|
||||
.ecPublicKeyExpression
|
||||
|
@ -6,7 +6,7 @@ import org.bitcoins.core.protocol.CompactSizeUInt
|
||||
import org.bitcoins.testkitcore.gen.NumberGenerator
|
||||
import org.bitcoins.testkitcore.util.BitcoinSUnitTest
|
||||
import org.scalacheck.Gen
|
||||
import scodec.bits.{ByteVector, HexStringSyntax}
|
||||
import scodec.bits.ByteVector
|
||||
|
||||
class RawAddrV2MessageSerializerTest extends BitcoinSUnitTest {
|
||||
|
||||
@ -108,7 +108,7 @@ class RawAddrV2MessageSerializerTest extends BitcoinSUnitTest {
|
||||
IPv4AddrV2Message(
|
||||
UInt32(4523),
|
||||
CompactSizeUInt(UInt64(53453453L)),
|
||||
InetAddress.getByAddress(hex"00000000".toArray),
|
||||
InetAddress.getByAddress(ByteVector.fromValidHex("00000000").toArray),
|
||||
UInt16(8333)
|
||||
)
|
||||
|
||||
@ -125,7 +125,8 @@ class RawAddrV2MessageSerializerTest extends BitcoinSUnitTest {
|
||||
val msg = IPv6AddrV2Message(
|
||||
UInt32(4523),
|
||||
CompactSizeUInt(UInt64(53453453L)),
|
||||
InetAddress.getByAddress(hex"00000000000000000000000000000000".toArray),
|
||||
InetAddress.getByAddress(
|
||||
ByteVector.fromValidHex("00000000000000000000000000000000").toArray),
|
||||
UInt16(8333)
|
||||
)
|
||||
|
||||
@ -144,7 +145,7 @@ class RawAddrV2MessageSerializerTest extends BitcoinSUnitTest {
|
||||
val msg = TorV2AddrV2Message(
|
||||
UInt32(4523),
|
||||
CompactSizeUInt(UInt64(53453453L)),
|
||||
hex"00000000000000000000",
|
||||
ByteVector.fromValidHex("00000000000000000000"),
|
||||
UInt16(8333)
|
||||
)
|
||||
|
||||
@ -161,7 +162,8 @@ class RawAddrV2MessageSerializerTest extends BitcoinSUnitTest {
|
||||
val msg = TorV3AddrV2Message(
|
||||
UInt32(4523),
|
||||
CompactSizeUInt(UInt64(53453453L)),
|
||||
hex"0000000000000000000000000000000000000000000000000000000000000000",
|
||||
ByteVector.fromValidHex(
|
||||
"0000000000000000000000000000000000000000000000000000000000000000"),
|
||||
UInt16(8333)
|
||||
)
|
||||
|
||||
@ -180,7 +182,8 @@ class RawAddrV2MessageSerializerTest extends BitcoinSUnitTest {
|
||||
val msg = I2PAddrV2Message(
|
||||
UInt32(4523),
|
||||
CompactSizeUInt(UInt64(53453453L)),
|
||||
hex"0000000000000000000000000000000000000000000000000000000000000000",
|
||||
ByteVector.fromValidHex(
|
||||
"0000000000000000000000000000000000000000000000000000000000000000"),
|
||||
UInt16(8333)
|
||||
)
|
||||
|
||||
@ -199,7 +202,7 @@ class RawAddrV2MessageSerializerTest extends BitcoinSUnitTest {
|
||||
val msg = CJDNSAddrV2Message(
|
||||
UInt32(4523),
|
||||
CompactSizeUInt(UInt64(53453453L)),
|
||||
hex"fc000000000000000000000000000000",
|
||||
ByteVector.fromValidHex("fc000000000000000000000000000000"),
|
||||
UInt16(8333)
|
||||
)
|
||||
|
||||
@ -219,7 +222,7 @@ class RawAddrV2MessageSerializerTest extends BitcoinSUnitTest {
|
||||
UInt32(4523),
|
||||
CompactSizeUInt(UInt64(53453453L)),
|
||||
0x07,
|
||||
hex"00000000000000000000000000000000",
|
||||
ByteVector.fromValidHex("00000000000000000000000000000000"),
|
||||
UInt16(8333)
|
||||
)
|
||||
|
||||
|
@ -7,7 +7,7 @@ import org.bitcoins.core.protocol.CompactSizeUInt
|
||||
import org.bitcoins.core.protocol.blockchain.{BlockHeader, MainNetChainParams}
|
||||
import org.bitcoins.crypto.{CryptoUtil, DoubleSha256Digest}
|
||||
import org.bitcoins.testkitcore.chain.ChainTestUtil
|
||||
import scodec.bits.{ByteVector, HexStringSyntax}
|
||||
import scodec.bits.ByteVector
|
||||
|
||||
import java.time.Instant
|
||||
import java.time.temporal.ChronoUnit
|
||||
@ -146,7 +146,8 @@ class NetworkUtilTest extends BitcoinSUtilTest {
|
||||
// the parsing of the remainder
|
||||
it must "parse a byte vector with three messages in it" in {
|
||||
val bytes =
|
||||
hex"fabfb5da6d65726b6c65626c6f636b0097000000b4b6e45d00000020387191f7d488b849b4080fdf105c71269fc841a2f0f2944fc5dc785c830c716e37f36373098aae06a668cc74e388caf50ecdcb5504ce936490b4b72940e08859548c305dffff7f20010000000200000002ecd1c722709bfc241f8b94fc64034dcba2c95409dc4cd1d7b864e1128a04e5b044133327b04ff8ac576e7748a4dae4111f0c765dacbfe0c5a9fddbeb8f60d5af0105fabfb5da747800000000000000000000cc0100004413332702000000065b7f0f3eec398047e921037815aa41709b6243a1897f1423194b7558399ae0300000000017160014008dc9d88d1797305f3fbd30d2b36d6bde984a09feffffffe9145055d671fd705a09f028033da614b619205b9926fe5ebe45e15ae8b3231e0100000017160014d74cfac04bb0e6838c35f1f4a0a60d13655be2fbfeffffff797f8ff9c10fa618b6254343a648be995410e82c03fd8accb0de2271a3fb1abd00000000171600143ee832c09db48eca28a64a358ed7a01dbe52d31bfeffffffc794dba971b9479dfcbc662a3aacd641553bdb2418b15c0221c5dfd4471a7a70000000001716001452c13ba0314f7718c234ed6adfea6422ce03a545feffffffb7c3bf1762b15f3b0e0eaa5beb46fe96a9e2829a7413fd900b9b7e0d192ab64800000000171600143ee832c09db48eca28a64a358ed7a01dbe52d31bfeffffffb6ced6cb8dfc2f7f5b37561938ead3bc5ca4036e2b45d9738cc086a10eed4e010100000017160014aebb17e245fe8c98a75f0b6717fcadca30e491e2feffffff02002a7515000000001976a9148374ff8beb55ea2945039881ca26071b5749fafe88ac485620000000000017a91405d36a2b0bdedf3fc58bed6f9e4026f8934a2716876b050000fabfb5da686561646572730000000000010000001406e05800"
|
||||
ByteVector.fromValidHex(
|
||||
"fabfb5da6d65726b6c65626c6f636b0097000000b4b6e45d00000020387191f7d488b849b4080fdf105c71269fc841a2f0f2944fc5dc785c830c716e37f36373098aae06a668cc74e388caf50ecdcb5504ce936490b4b72940e08859548c305dffff7f20010000000200000002ecd1c722709bfc241f8b94fc64034dcba2c95409dc4cd1d7b864e1128a04e5b044133327b04ff8ac576e7748a4dae4111f0c765dacbfe0c5a9fddbeb8f60d5af0105fabfb5da747800000000000000000000cc0100004413332702000000065b7f0f3eec398047e921037815aa41709b6243a1897f1423194b7558399ae0300000000017160014008dc9d88d1797305f3fbd30d2b36d6bde984a09feffffffe9145055d671fd705a09f028033da614b619205b9926fe5ebe45e15ae8b3231e0100000017160014d74cfac04bb0e6838c35f1f4a0a60d13655be2fbfeffffff797f8ff9c10fa618b6254343a648be995410e82c03fd8accb0de2271a3fb1abd00000000171600143ee832c09db48eca28a64a358ed7a01dbe52d31bfeffffffc794dba971b9479dfcbc662a3aacd641553bdb2418b15c0221c5dfd4471a7a70000000001716001452c13ba0314f7718c234ed6adfea6422ce03a545feffffffb7c3bf1762b15f3b0e0eaa5beb46fe96a9e2829a7413fd900b9b7e0d192ab64800000000171600143ee832c09db48eca28a64a358ed7a01dbe52d31bfeffffffb6ced6cb8dfc2f7f5b37561938ead3bc5ca4036e2b45d9738cc086a10eed4e010100000017160014aebb17e245fe8c98a75f0b6717fcadca30e491e2feffffff02002a7515000000001976a9148374ff8beb55ea2945039881ca26071b5749fafe88ac485620000000000017a91405d36a2b0bdedf3fc58bed6f9e4026f8934a2716876b050000fabfb5da686561646572730000000000010000001406e05800")
|
||||
val (messages, leftover) = NetworkUtil.parseIndividualMessages(bytes)
|
||||
assert(messages.length == 3)
|
||||
|
||||
|
@ -2,7 +2,7 @@ package org.bitcoins.crypto
|
||||
|
||||
import org.scalacheck.Gen
|
||||
import org.scalatest.compatible.Assertion
|
||||
import scodec.bits.{ByteVector, HexStringSyntax}
|
||||
import scodec.bits.ByteVector
|
||||
|
||||
class AesCryptTest extends BitcoinSCryptoTest {
|
||||
behavior of "AesEncrypt"
|
||||
@ -14,7 +14,7 @@ class AesCryptTest extends BitcoinSCryptoTest {
|
||||
private def getIV(bytes: ByteVector): AesIV = AesIV.fromValidBytes(bytes)
|
||||
|
||||
val aesKey: AesKey =
|
||||
getKey(hex"12345678123456781234567812345678")
|
||||
getKey(ByteVector.fromValidHex("12345678123456781234567812345678"))
|
||||
|
||||
val badAesKey: AesKey = getKey(aesKey.bytes.reverse)
|
||||
|
||||
@ -51,33 +51,38 @@ class AesCryptTest extends BitcoinSCryptoTest {
|
||||
|
||||
val first =
|
||||
TestVector(
|
||||
plainText = hex"76fe35880055e1fac950f484a815cd22",
|
||||
key = getKey(hex"2eefdf6ee2dbca83e7b7648a8f9d1897"),
|
||||
plainText = ByteVector.fromValidHex("76fe35880055e1fac950f484a815cd22"),
|
||||
key =
|
||||
getKey(ByteVector.fromValidHex("2eefdf6ee2dbca83e7b7648a8f9d1897")),
|
||||
cipherText = AesEncryptedData(
|
||||
cipherText = hex"974b22d3de46a58023ddb94dac574293",
|
||||
iv = getIV(hex"889dc64377f6d993ef713c995f9c1ee5")
|
||||
cipherText =
|
||||
ByteVector.fromValidHex("974b22d3de46a58023ddb94dac574293"),
|
||||
iv =
|
||||
getIV(ByteVector.fromValidHex("889dc64377f6d993ef713c995f9c1ee5"))
|
||||
)
|
||||
)
|
||||
|
||||
runTest(first)
|
||||
|
||||
val second = TestVector(
|
||||
plainText = hex"3a4f73044d035017d91883ebfc113da7",
|
||||
key = getKey(hex"5ce91f97ed28fd5d1172e23eb17b1baa"),
|
||||
plainText = ByteVector.fromValidHex("3a4f73044d035017d91883ebfc113da7"),
|
||||
key = getKey(ByteVector.fromValidHex("5ce91f97ed28fd5d1172e23eb17b1baa")),
|
||||
cipherText = AesEncryptedData(
|
||||
cipherText = hex"f0ff04edc644388edb872237ac558367",
|
||||
iv = getIV(hex"3f91d29f81d48174b25a3d0143eb833c")
|
||||
cipherText =
|
||||
ByteVector.fromValidHex("f0ff04edc644388edb872237ac558367"),
|
||||
iv = getIV(ByteVector.fromValidHex("3f91d29f81d48174b25a3d0143eb833c"))
|
||||
)
|
||||
)
|
||||
|
||||
runTest(second)
|
||||
|
||||
val third = TestVector(
|
||||
plainText = hex"5f6a62cb52309db4573bfed807e07bb2",
|
||||
key = getKey(hex"c62bea08786568283dafabde6d699e0f"),
|
||||
plainText = ByteVector.fromValidHex("5f6a62cb52309db4573bfed807e07bb2"),
|
||||
key = getKey(ByteVector.fromValidHex("c62bea08786568283dafabde6d699e0f")),
|
||||
cipherText = AesEncryptedData(
|
||||
cipherText = hex"161bd64b0b4efe3561e949344e9efaaf",
|
||||
iv = getIV(hex"455014871cd34f8dcfd7c1e387987bff")
|
||||
cipherText =
|
||||
ByteVector.fromValidHex("161bd64b0b4efe3561e949344e9efaaf"),
|
||||
iv = getIV(ByteVector.fromValidHex("455014871cd34f8dcfd7c1e387987bff"))
|
||||
)
|
||||
)
|
||||
|
||||
@ -89,14 +94,15 @@ class AesCryptTest extends BitcoinSCryptoTest {
|
||||
// echo foobar | openssl enc -aes-128-cfb -K 5ce91f97ed28fd5d1172e23eb17b1baa \
|
||||
// -iv 455014871cd34f8dcfd7c1e387987bff -p -base64 -nosalt
|
||||
it must "pass an openssl hard coded vector" in {
|
||||
val key = getKey(hex"5CE91F97ED28FD5D1172E23EB17B1BAA")
|
||||
val key =
|
||||
getKey(ByteVector.fromValidHex("5CE91F97ED28FD5D1172E23EB17B1BAA"))
|
||||
val plainText = "foobar"
|
||||
val plainBytesE = ByteVector.encodeUtf8(plainText)
|
||||
val plainbytes = plainBytesE match {
|
||||
case Left(_) => fail(s"Unsuccessful encoding")
|
||||
case Right(b) => b
|
||||
}
|
||||
val iv = getIV(hex"455014871CD34F8DCFD7C1E387987BFF")
|
||||
val iv = getIV(ByteVector.fromValidHex("455014871CD34F8DCFD7C1E387987BFF"))
|
||||
// val expectedCipher = ByteVector.fromValidBase64("oE8HErg1lg==")
|
||||
|
||||
val encrypted = AesCrypt.encryptWithIV(plainbytes, iv, key)
|
||||
@ -137,8 +143,9 @@ class AesCryptTest extends BitcoinSCryptoTest {
|
||||
* KKbLXDQUy7ajmuIJm7ZR7ugaRubqGl1JwG+x5C451JXIFofnselHVTy/u8u0Or9nV2d7Kjy0
|
||||
*/
|
||||
it must "pass a hardcoded crypto-js vector where we decrypt with a key" in {
|
||||
val key = getKey(hex"12345678123456781234567812345678")
|
||||
val iv = getIV(hex"87654321876543218765432187654321")
|
||||
val key =
|
||||
getKey(ByteVector.fromValidHex("12345678123456781234567812345678"))
|
||||
val iv = getIV(ByteVector.fromValidHex("87654321876543218765432187654321"))
|
||||
val expectedCipher = ByteVector.fromValidBase64(
|
||||
"KKbLXDQUy7ajmuIJm7ZR7ugaRubqGl1JwG+x5C451JXIFofnselHVTy/u8u0Or9nV2d7Kjy0"
|
||||
)
|
||||
@ -252,8 +259,9 @@ class AesCryptTest extends BitcoinSCryptoTest {
|
||||
}
|
||||
}
|
||||
|
||||
val key = getKey(hex"e67a00b510bcff7f4a0101ff5f7fb690")
|
||||
val iv = getIV(hex"f43b7f80624e7f01123ac272beb1ff7f")
|
||||
val key =
|
||||
getKey(ByteVector.fromValidHex("e67a00b510bcff7f4a0101ff5f7fb690"))
|
||||
val iv = getIV(ByteVector.fromValidHex("f43b7f80624e7f01123ac272beb1ff7f"))
|
||||
val plainText = "The quick brown fox jumps over the lazy dog."
|
||||
val plainBytesE = ByteVector.encodeUtf8(plainText)
|
||||
val plainbytes = plainBytesE match {
|
||||
@ -261,7 +269,8 @@ class AesCryptTest extends BitcoinSCryptoTest {
|
||||
case Right(b) => b
|
||||
}
|
||||
val expectedCipher =
|
||||
hex"09697c53d3a1e5ec5a465231e536c70428f53cb7d4030a707e42daa338ce147ec2d55c865e85dfb5072a1bf31a977cf4"
|
||||
ByteVector.fromValidHex(
|
||||
"09697c53d3a1e5ec5a465231e536c70428f53cb7d4030a707e42daa338ce147ec2d55c865e85dfb5072a1bf31a977cf4")
|
||||
|
||||
// test encrypting and decrypting ourselves
|
||||
{
|
||||
@ -360,9 +369,9 @@ class AesCryptTest extends BitcoinSCryptoTest {
|
||||
.filter(!AesKey.keylengths.contains(_))
|
||||
.map(NumberGenerator.bytevector(_))
|
||||
|
||||
val first +: second +: _ = bytevectorGens
|
||||
val first +: second +: _ = bytevectorGens: @unchecked
|
||||
val badKeyLenghts: Gen[ByteVector] =
|
||||
Gen.oneOf(first, second, bytevectorGens: _*)
|
||||
Gen.oneOf(first, second, bytevectorGens*)
|
||||
|
||||
forAll(badKeyLenghts) { bytes =>
|
||||
assert(AesKey.fromBytes(bytes).isEmpty)
|
||||
@ -380,7 +389,7 @@ class AesCryptTest extends BitcoinSCryptoTest {
|
||||
}
|
||||
|
||||
it must "not be constructable from invalid length bytes" in {
|
||||
val bytes = hex"12345"
|
||||
val bytes = ByteVector.fromValidHex("12345")
|
||||
intercept[IllegalArgumentException] {
|
||||
AesIV.fromValidBytes(bytes)
|
||||
}
|
||||
|
@ -696,7 +696,7 @@ trait DLCTest {
|
||||
dlcOffer: TestDLCClient,
|
||||
dlcAccept: TestDLCClient,
|
||||
fundingTxF: Future[SetupDLC] => Future[Transaction],
|
||||
publishTransaction: Transaction => Future[_]
|
||||
publishTransaction: Transaction => Future[?]
|
||||
)(implicit ec: ExecutionContext): Future[(SetupDLC, SetupDLC)] = {
|
||||
val offerSigReceiveP = {
|
||||
Promise[(CETSignatures, PartialSignature)]()
|
||||
|
@ -344,7 +344,7 @@ sealed abstract class CryptoGenerators {
|
||||
mGen.flatMap { m =>
|
||||
val upperBound = m.toInt * 2 - 2
|
||||
|
||||
val randGen = Gen.chooseNum(0L, upperBound).map(UInt64(_))
|
||||
val randGen = Gen.chooseNum(0, upperBound).map(UInt64(_))
|
||||
|
||||
randGen.map(rand => (p, m, rand))
|
||||
}
|
||||
|
@ -19,13 +19,13 @@ trait CurrencyUnitGenerator {
|
||||
def currencyUnit: Gen[CurrencyUnit] = Gen.oneOf(satoshis, bitcoins)
|
||||
|
||||
def positiveSatoshis: Gen[Satoshis] =
|
||||
Gen.choose(0, Long.MaxValue).map(Satoshis.apply)
|
||||
Gen.choose(0L, Long.MaxValue).map(Satoshis.apply)
|
||||
|
||||
/** Generates a postiive satoshi value that is 'realistic'. This current
|
||||
* 'realistic' range is from 0 to 1,000,000 bitcoin
|
||||
*/
|
||||
def positiveRealistic: Gen[Satoshis] =
|
||||
Gen.choose(0, Bitcoins(1000000).satoshis.toLong).map { n =>
|
||||
Gen.choose(0L, Bitcoins(1000000).satoshis.toLong).map { n =>
|
||||
Satoshis(n)
|
||||
}
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ trait TLVGen {
|
||||
outcomes <- Gen.listOfN(numOutcomes, StringGenerators.genString)
|
||||
totalInput <-
|
||||
Gen
|
||||
.choose(numOutcomes + 1, Long.MaxValue / 10000L)
|
||||
.choose(numOutcomes + 1L, Long.MaxValue / 10000L)
|
||||
.map(Satoshis.apply)
|
||||
(contractDescriptor, _) =
|
||||
DLCTestUtil.genContractDescriptors(outcomes.toVector, totalInput)
|
||||
@ -195,7 +195,7 @@ trait TLVGen {
|
||||
numDigits <- Gen.choose(3, 7)
|
||||
totalInput <-
|
||||
Gen
|
||||
.choose(numDigits + 1, Long.MaxValue / 10000L)
|
||||
.choose(numDigits + 1L, Long.MaxValue / 10000L)
|
||||
.map(Satoshis.apply)
|
||||
(contractDescriptor, _) =
|
||||
DLCTestUtil.genMultiDigitContractInfo(numDigits, totalInput)
|
||||
|
@ -87,7 +87,7 @@ object TransactionGenerators {
|
||||
accum
|
||||
} else {
|
||||
val amt = Gen
|
||||
.choose(100, remainingAmount.toBigDecimal.toLongExact)
|
||||
.choose(100L, remainingAmount.toBigDecimal.toLongExact)
|
||||
.map(n => Satoshis(n))
|
||||
.sampleSome
|
||||
loop(remaining - 1, remainingAmount - amt, amt +: accum)
|
||||
@ -1040,7 +1040,7 @@ object TransactionGenerators {
|
||||
txLockTime: UInt32
|
||||
): Gen[ScriptNumber] = {
|
||||
if (txLockTime < TransactionConstants.locktimeThreshold) {
|
||||
Gen.choose(0, txLockTime.toLong).map(ScriptNumber(_))
|
||||
Gen.choose(0L, txLockTime.toLong).map(ScriptNumber(_))
|
||||
} else {
|
||||
Gen
|
||||
.choose(
|
||||
|
@ -28,7 +28,7 @@ trait LnCurrencyUnitGen {
|
||||
} yield PicoBitcoins(amount)
|
||||
|
||||
def positivePicoBitcoin: Gen[PicoBitcoins] = {
|
||||
Gen.choose(0, PicoBitcoins.max.toLong).map(PicoBitcoins(_))
|
||||
Gen.choose(0L, PicoBitcoins.max.toLong).map(PicoBitcoins(_))
|
||||
}
|
||||
|
||||
def lnCurrencyUnit: Gen[LnCurrencyUnit] =
|
||||
@ -39,7 +39,7 @@ trait LnCurrencyUnitGen {
|
||||
}
|
||||
|
||||
def realisticLnInvoice: Gen[LnCurrencyUnit] = {
|
||||
val gen = Gen.choose(0, LnPolicy.maxAmountMSat.toLong)
|
||||
val gen = Gen.choose(0L, LnPolicy.maxAmountMSat.toLong)
|
||||
val msat = gen.map(MilliSatoshis(_))
|
||||
msat.map(LnCurrencyUnits.fromMSat(_))
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ sealed abstract class LnInvoiceGen {
|
||||
} yield LnInvoiceSignature(version, sig)
|
||||
|
||||
def invoiceTimestamp: Gen[UInt64] = {
|
||||
Gen.choose(0, LnInvoice.MAX_TIMESTAMP_U64.toLong).map(UInt64(_))
|
||||
Gen.choose(0L, LnInvoice.MAX_TIMESTAMP_U64.toLong).map(UInt64(_))
|
||||
}
|
||||
|
||||
def lnInvoice(privateKey: ECPrivateKey): Gen[LnInvoice] = {
|
||||
|
Loading…
Reference in New Issue
Block a user