mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-20 22:13:14 +01:00
Fix/typos (#2633)
* Fix typos * Collection minor fixes Removes redundant .headOption on options Replaces .exists(_ == ???) with .contains(???) Replaces option == None with option.isEmpty
This commit is contained in:
parent
f0d21ebb81
commit
b079073094
32 changed files with 55 additions and 57 deletions
|
@ -1,7 +1,7 @@
|
||||||

|

|
||||||
[](https://github.com/bitcoin-s/bitcoin-s/actions) [](https://coveralls.io/github/bitcoin-s/bitcoin-s?branch=master) [](https://mvnrepository.com/artifact/org.bitcoin-s) [](https://gitter.im/bitcoin-s-core)
|
[](https://github.com/bitcoin-s/bitcoin-s/actions) [](https://coveralls.io/github/bitcoin-s/bitcoin-s?branch=master) [](https://mvnrepository.com/artifact/org.bitcoin-s) [](https://gitter.im/bitcoin-s-core)
|
||||||
|
|
||||||
Feature rich toolkit for making Bitcoin and Lightning applications
|
Feature-rich toolkit for making Bitcoin and Lightning applications
|
||||||
on the JVM.
|
on the JVM.
|
||||||
|
|
||||||
For a complete guide on how to get started with Bitcoin-S, see our website at
|
For a complete guide on how to get started with Bitcoin-S, see our website at
|
||||||
|
|
|
@ -107,7 +107,7 @@ class MempoolRpcTest extends BitcoindRpcTest {
|
||||||
txid = DoubleSha256Digest.empty
|
txid = DoubleSha256Digest.empty
|
||||||
result <- client.getMemPoolEntryOpt(txid)
|
result <- client.getMemPoolEntryOpt(txid)
|
||||||
} yield {
|
} yield {
|
||||||
assert(result == None)
|
assert(result.isEmpty)
|
||||||
}
|
}
|
||||||
resultF
|
resultF
|
||||||
}
|
}
|
||||||
|
|
|
@ -250,7 +250,7 @@ class BitcoindV17RpcClientTest extends BitcoindRpcTest {
|
||||||
_ <- client.createWallet("suredbits")
|
_ <- client.createWallet("suredbits")
|
||||||
wallets <- client.listWallets
|
wallets <- client.listWallets
|
||||||
} yield {
|
} yield {
|
||||||
assert(wallets.exists(_ == "suredbits"))
|
assert(wallets.contains("suredbits"))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -234,7 +234,7 @@ object BitcoindRpcClient {
|
||||||
|
|
||||||
/** Creates an RPC client from the given instance,
|
/** Creates an RPC client from the given instance,
|
||||||
* together with the given actor system. This is for
|
* together with the given actor system. This is for
|
||||||
* advanced users, wher you need fine grained control
|
* advanced users, where you need fine grained control
|
||||||
* over the RPC client.
|
* over the RPC client.
|
||||||
*/
|
*/
|
||||||
def withActorSystem(instance: BitcoindInstance)(implicit
|
def withActorSystem(instance: BitcoindInstance)(implicit
|
||||||
|
|
|
@ -115,7 +115,7 @@ object BitcoindV16RpcClient {
|
||||||
|
|
||||||
/** Creates an RPC client from the given instance,
|
/** Creates an RPC client from the given instance,
|
||||||
* together with the given actor system. This is for
|
* together with the given actor system. This is for
|
||||||
* advanced users, wher you need fine grained control
|
* advanced users, where you need fine grained control
|
||||||
* over the RPC client.
|
* over the RPC client.
|
||||||
*/
|
*/
|
||||||
def withActorSystem(instance: BitcoindInstance)(implicit
|
def withActorSystem(instance: BitcoindInstance)(implicit
|
||||||
|
|
|
@ -124,7 +124,7 @@ object BitcoindV17RpcClient {
|
||||||
|
|
||||||
/** Creates an RPC client from the given instance,
|
/** Creates an RPC client from the given instance,
|
||||||
* together with the given actor system. This is for
|
* together with the given actor system. This is for
|
||||||
* advanced users, wher you need fine grained control
|
* advanced users, where you need fine grained control
|
||||||
* over the RPC client.
|
* over the RPC client.
|
||||||
*/
|
*/
|
||||||
def withActorSystem(instance: BitcoindInstance)(implicit
|
def withActorSystem(instance: BitcoindInstance)(implicit
|
||||||
|
|
|
@ -190,7 +190,7 @@ case class BitcoindConfig(
|
||||||
} yield result
|
} yield result
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Searches the config for a key matchinng the provided
|
/** Searches the config for a key matching the provided
|
||||||
* string that's _not_ in a section header or prefixed
|
* string that's _not_ in a section header or prefixed
|
||||||
* by a network.
|
* by a network.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -156,7 +156,7 @@ class BlockHeaderDAOTest extends ChainDbUnitTest {
|
||||||
blockHeaderDAO: BlockHeaderDAO =>
|
blockHeaderDAO: BlockHeaderDAO =>
|
||||||
val chainTipsF = blockHeaderDAO.getBestChainTips
|
val chainTipsF = blockHeaderDAO.getBestChainTips
|
||||||
chainTipsF.map { tips =>
|
chainTipsF.map { tips =>
|
||||||
assert(tips.headOption == Some(genesisHeaderDb))
|
assert(tips.headOption.contains(genesisHeaderDb))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ class CompactFilterHeaderDAOTest extends ChainDbUnitTest {
|
||||||
it must "get the best filter header with a table with zero rows in it" in {
|
it must "get the best filter header with a table with zero rows in it" in {
|
||||||
filterHeaderDAO =>
|
filterHeaderDAO =>
|
||||||
filterHeaderDAO.getBestFilterHeader.map { opt =>
|
filterHeaderDAO.getBestFilterHeader.map { opt =>
|
||||||
assert(opt == None)
|
assert(opt.isEmpty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,8 +157,6 @@ case class CompactFilterDAO()(implicit
|
||||||
}
|
}
|
||||||
|
|
||||||
def getBestFilterHeight: Future[Int] = {
|
def getBestFilterHeight: Future[Int] = {
|
||||||
safeDatabase.run(bestFilterHeightQuery).map { filterHeightOpt =>
|
safeDatabase.run(bestFilterHeightQuery).map(_.getOrElse(0))
|
||||||
filterHeightOpt.headOption.getOrElse(0)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,7 +155,7 @@ case class CompactFilterHeaderDAO()(implicit
|
||||||
|
|
||||||
def getBestFilterHeaderHeight: Future[Int] = {
|
def getBestFilterHeaderHeight: Future[Int] = {
|
||||||
safeDatabase.run(bestFilterHeaderHeightQuery).map { filterHeaderHeightOpt =>
|
safeDatabase.run(bestFilterHeaderHeightQuery).map { filterHeaderHeightOpt =>
|
||||||
filterHeaderHeightOpt.headOption.getOrElse(0)
|
filterHeaderHeightOpt.getOrElse(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ class ArithmeticInterpreterTest extends BitcoinSUnitTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "perform an OP_1SUB corectly" in {
|
it must "perform an OP_1SUB correctly" in {
|
||||||
val stack = List(ScriptNumber.zero)
|
val stack = List(ScriptNumber.zero)
|
||||||
val script = List(OP_1SUB)
|
val script = List(OP_1SUB)
|
||||||
val program =
|
val program =
|
||||||
|
@ -77,7 +77,7 @@ class ArithmeticInterpreterTest extends BitcoinSUnitTest {
|
||||||
newProgram.error must be(Some(ScriptErrorInvalidStackOperation))
|
newProgram.error must be(Some(ScriptErrorInvalidStackOperation))
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "perform an OP_SUB corectly" in {
|
it must "perform an OP_SUB correctly" in {
|
||||||
val stack = List(ScriptNumber.one, ScriptNumber.zero)
|
val stack = List(ScriptNumber.one, ScriptNumber.zero)
|
||||||
val script = List(OP_SUB)
|
val script = List(OP_SUB)
|
||||||
val program =
|
val program =
|
||||||
|
@ -100,7 +100,7 @@ class ArithmeticInterpreterTest extends BitcoinSUnitTest {
|
||||||
newProgram.error must be(Some(ScriptErrorInvalidStackOperation))
|
newProgram.error must be(Some(ScriptErrorInvalidStackOperation))
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "perform an OP_ABS on a negative number corectly" in {
|
it must "perform an OP_ABS on a negative number correctly" in {
|
||||||
val stack = List(ScriptNumber(-1))
|
val stack = List(ScriptNumber(-1))
|
||||||
val script = List(OP_ABS)
|
val script = List(OP_ABS)
|
||||||
val program =
|
val program =
|
||||||
|
@ -299,7 +299,7 @@ class ArithmeticInterpreterTest extends BitcoinSUnitTest {
|
||||||
newProgram.script.isEmpty must be(true)
|
newProgram.script.isEmpty must be(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "evaulate an OP_NUMEQUAL for two zeros" in {
|
it must "evaluate an OP_NUMEQUAL for two zeros" in {
|
||||||
val stack = List(ScriptNumber.zero, ScriptNumber.zero)
|
val stack = List(ScriptNumber.zero, ScriptNumber.zero)
|
||||||
val script = List(OP_NUMEQUAL)
|
val script = List(OP_NUMEQUAL)
|
||||||
val program =
|
val program =
|
||||||
|
|
|
@ -6,7 +6,7 @@ import org.bitcoins.testkit.util.BitcoinSUnitTest
|
||||||
*/
|
*/
|
||||||
class ArithmeticOperationsTest extends BitcoinSUnitTest {
|
class ArithmeticOperationsTest extends BitcoinSUnitTest {
|
||||||
|
|
||||||
"ArithmeticOperatoins" must "define OP_1ADD" in {
|
"ArithmeticOperations" must "define OP_1ADD" in {
|
||||||
OP_1ADD.opCode must be(139)
|
OP_1ADD.opCode must be(139)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,10 @@ import org.bitcoins.testkit.util.BitcoinSUnitTest
|
||||||
class BytesToPushOntoStackFactoryTest extends BitcoinSUnitTest {
|
class BytesToPushOntoStackFactoryTest extends BitcoinSUnitTest {
|
||||||
|
|
||||||
"ScriptNumberFactory" must "represent the number 1" in {
|
"ScriptNumberFactory" must "represent the number 1" in {
|
||||||
BytesToPushOntoStack.operations.exists(
|
BytesToPushOntoStack.operations.contains(BytesToPushOntoStack(1)) must be(
|
||||||
_ == BytesToPushOntoStack(1)) must be(true)
|
true)
|
||||||
BytesToPushOntoStack.operations.exists(
|
BytesToPushOntoStack.operations.contains(BytesToPushOntoStack(75)) must be(
|
||||||
_ == BytesToPushOntoStack(75)) must be(true)
|
true)
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "find the number two" in {
|
it must "find the number two" in {
|
||||||
|
@ -29,8 +29,8 @@ class BytesToPushOntoStackFactoryTest extends BitcoinSUnitTest {
|
||||||
|
|
||||||
it must "not allow creation of the script number -2" in {
|
it must "not allow creation of the script number -2" in {
|
||||||
intercept[IllegalArgumentException] {
|
intercept[IllegalArgumentException] {
|
||||||
BytesToPushOntoStack.operations.exists(
|
BytesToPushOntoStack.operations.contains(
|
||||||
_ == BytesToPushOntoStack(-2)) must be(false)
|
BytesToPushOntoStack(-2)) must be(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ class LockTimeInterpreterTest extends BitcoinSUnitTest {
|
||||||
it must "mark the transaction as invalid if the stack top is negative" in {
|
it must "mark the transaction as invalid if the stack top is negative" in {
|
||||||
val stack = Seq(ScriptNumber(-1))
|
val stack = Seq(ScriptNumber(-1))
|
||||||
val script = Seq(OP_CHECKLOCKTIMEVERIFY)
|
val script = Seq(OP_CHECKLOCKTIMEVERIFY)
|
||||||
val oldInput = TestUtil.transaction.inputs(0)
|
val oldInput = TestUtil.transaction.inputs.head
|
||||||
val txInputAdjustedSequenceNumber =
|
val txInputAdjustedSequenceNumber =
|
||||||
TransactionInput(oldInput.previousOutput,
|
TransactionInput(oldInput.previousOutput,
|
||||||
oldInput.scriptSignature,
|
oldInput.scriptSignature,
|
||||||
|
@ -75,7 +75,7 @@ class LockTimeInterpreterTest extends BitcoinSUnitTest {
|
||||||
it must "mark the transaction as invalid if the locktime on the tx is < 500000000 && stack top is >= 500000000" in {
|
it must "mark the transaction as invalid if the locktime on the tx is < 500000000 && stack top is >= 500000000" in {
|
||||||
val stack = Seq(ScriptNumber(500000000))
|
val stack = Seq(ScriptNumber(500000000))
|
||||||
val script = Seq(OP_CHECKLOCKTIMEVERIFY)
|
val script = Seq(OP_CHECKLOCKTIMEVERIFY)
|
||||||
val oldInput = TestUtil.transaction.inputs(0)
|
val oldInput = TestUtil.transaction.inputs.head
|
||||||
val txInputAdjustedSequenceNumber =
|
val txInputAdjustedSequenceNumber =
|
||||||
TransactionInput(oldInput.previousOutput,
|
TransactionInput(oldInput.previousOutput,
|
||||||
oldInput.scriptSignature,
|
oldInput.scriptSignature,
|
||||||
|
@ -101,7 +101,7 @@ class LockTimeInterpreterTest extends BitcoinSUnitTest {
|
||||||
it must "mark the transaction as invalid if the locktime on the tx is >= 500000000 && stack top is < 500000000" in {
|
it must "mark the transaction as invalid if the locktime on the tx is >= 500000000 && stack top is < 500000000" in {
|
||||||
val stack = Seq(ScriptNumber(499999999))
|
val stack = Seq(ScriptNumber(499999999))
|
||||||
val script = Seq(OP_CHECKLOCKTIMEVERIFY)
|
val script = Seq(OP_CHECKLOCKTIMEVERIFY)
|
||||||
val oldInput = TestUtil.transaction.inputs(0)
|
val oldInput = TestUtil.transaction.inputs.head
|
||||||
val txInputAdjustedSequenceNumber =
|
val txInputAdjustedSequenceNumber =
|
||||||
TransactionInput(oldInput.previousOutput,
|
TransactionInput(oldInput.previousOutput,
|
||||||
oldInput.scriptSignature,
|
oldInput.scriptSignature,
|
||||||
|
@ -127,7 +127,7 @@ class LockTimeInterpreterTest extends BitcoinSUnitTest {
|
||||||
it must "mark the transaction as invalid if the stack top item is greater than the tx locktime" in {
|
it must "mark the transaction as invalid if the stack top item is greater than the tx locktime" in {
|
||||||
val stack = Seq(ScriptNumber(499999999))
|
val stack = Seq(ScriptNumber(499999999))
|
||||||
val script = Seq(OP_CHECKLOCKTIMEVERIFY)
|
val script = Seq(OP_CHECKLOCKTIMEVERIFY)
|
||||||
val oldInput = TestUtil.transaction.inputs(0)
|
val oldInput = TestUtil.transaction.inputs.head
|
||||||
val txInputAdjustedSequenceNumber =
|
val txInputAdjustedSequenceNumber =
|
||||||
TransactionInput(oldInput.previousOutput,
|
TransactionInput(oldInput.previousOutput,
|
||||||
oldInput.scriptSignature,
|
oldInput.scriptSignature,
|
||||||
|
@ -157,7 +157,7 @@ class LockTimeInterpreterTest extends BitcoinSUnitTest {
|
||||||
it must "mark the transaction as valid if the locktime on the tx is < 500000000 && stack top is < 500000000" in {
|
it must "mark the transaction as valid if the locktime on the tx is < 500000000 && stack top is < 500000000" in {
|
||||||
val stack = Seq(ScriptNumber(0))
|
val stack = Seq(ScriptNumber(0))
|
||||||
val script = Seq(OP_CHECKLOCKTIMEVERIFY)
|
val script = Seq(OP_CHECKLOCKTIMEVERIFY)
|
||||||
val oldInput = TestUtil.transaction.inputs(0)
|
val oldInput = TestUtil.transaction.inputs.head
|
||||||
val txInputAdjustedSequenceNumber =
|
val txInputAdjustedSequenceNumber =
|
||||||
TransactionInput(oldInput.previousOutput,
|
TransactionInput(oldInput.previousOutput,
|
||||||
oldInput.scriptSignature,
|
oldInput.scriptSignature,
|
||||||
|
@ -185,7 +185,7 @@ class LockTimeInterpreterTest extends BitcoinSUnitTest {
|
||||||
it must "mark the transaction as valid if the locktime on the tx is >= 500000000 && stack top is >= 500000000" in {
|
it must "mark the transaction as valid if the locktime on the tx is >= 500000000 && stack top is >= 500000000" in {
|
||||||
val stack = Seq(ScriptNumber(500000000))
|
val stack = Seq(ScriptNumber(500000000))
|
||||||
val script = Seq(OP_CHECKLOCKTIMEVERIFY)
|
val script = Seq(OP_CHECKLOCKTIMEVERIFY)
|
||||||
val oldInput = TestUtil.transaction.inputs(0)
|
val oldInput = TestUtil.transaction.inputs.head
|
||||||
val txInputAdjustedSequenceNumber =
|
val txInputAdjustedSequenceNumber =
|
||||||
TransactionInput(oldInput.previousOutput,
|
TransactionInput(oldInput.previousOutput,
|
||||||
oldInput.scriptSignature,
|
oldInput.scriptSignature,
|
||||||
|
|
|
@ -321,8 +321,8 @@ class BitcoinScriptUtilTest extends BitcoinSUnitTest {
|
||||||
BitcoinScriptUtil.removeSignaturesFromScript(signatures,
|
BitcoinScriptUtil.removeSignaturesFromScript(signatures,
|
||||||
p2shScriptSig.asm)
|
p2shScriptSig.asm)
|
||||||
val sigExists =
|
val sigExists =
|
||||||
signatures.map(sig => asmWithoutSigs.exists(_ == ScriptConstant(sig.hex)))
|
signatures.map(sig => asmWithoutSigs.contains(ScriptConstant(sig.hex)))
|
||||||
sigExists.exists(_ == true) must be(false)
|
sigExists.contains(true) must be(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
it must "cast a script token to a boolean value" in {
|
it must "cast a script token to a boolean value" in {
|
||||||
|
|
|
@ -108,7 +108,7 @@ sealed abstract class BloomFilter extends NetworkElement with BitcoinSLogger {
|
||||||
@tailrec
|
@tailrec
|
||||||
def loop(remainingBitIndexes: Seq[Int], accum: BitVector): Boolean = {
|
def loop(remainingBitIndexes: Seq[Int], accum: BitVector): Boolean = {
|
||||||
if (remainingBitIndexes.isEmpty) {
|
if (remainingBitIndexes.isEmpty) {
|
||||||
!accum.toIndexedSeq.exists(_ == false)
|
!accum.toIndexedSeq.contains(false)
|
||||||
} else {
|
} else {
|
||||||
val currentIndex = remainingBitIndexes.head
|
val currentIndex = remainingBitIndexes.head
|
||||||
val byteIndex = currentIndex >>> 3
|
val byteIndex = currentIndex >>> 3
|
||||||
|
|
|
@ -349,7 +349,7 @@ object PartialMerkleTree {
|
||||||
//require(remainingBits.isEmpty, s"Remainging bits should be empty, got ${remainingBits}")
|
//require(remainingBits.isEmpty, s"Remainging bits should be empty, got ${remainingBits}")
|
||||||
//we must have used all the hashes provided to us to reconstruct the partial merkle tree as per BIP37
|
//we must have used all the hashes provided to us to reconstruct the partial merkle tree as per BIP37
|
||||||
require(
|
require(
|
||||||
remainingHashes.size == 0,
|
remainingHashes.isEmpty,
|
||||||
"We should not have any left over hashes after building our partial merkle tree, got: " + remainingHashes)
|
"We should not have any left over hashes after building our partial merkle tree, got: " + remainingHashes)
|
||||||
//we must not have any matches remaining, unless the remaining bits were use to pad our byte vector to 8 bits
|
//we must not have any matches remaining, unless the remaining bits were use to pad our byte vector to 8 bits
|
||||||
//for instance, we could have had 5 bits to indicate how to build the merkle tree, but we need to pad it with 3 bits
|
//for instance, we could have had 5 bits to indicate how to build the merkle tree, but we need to pad it with 3 bits
|
||||||
|
|
|
@ -120,7 +120,7 @@ case class ContractInfo(
|
||||||
.flatMap { oracles =>
|
.flatMap { oracles =>
|
||||||
vec.map { case MultiOracleOutcome(digitsVec, amt) =>
|
vec.map { case MultiOracleOutcome(digitsVec, amt) =>
|
||||||
val outcomesVec =
|
val outcomesVec =
|
||||||
digitsVec.toVector.map(UnsignedNumericOutcome.apply)
|
digitsVec.map(UnsignedNumericOutcome.apply)
|
||||||
(NumericOracleOutcome(oracles.zip(outcomesVec)), amt)
|
(NumericOracleOutcome(oracles.zip(outcomesVec)), amt)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,7 @@ object LnTaggedFields {
|
||||||
val dataLength = LnUtil.decodeDataLength(dataLengthU5s)
|
val dataLength = LnUtil.decodeDataLength(dataLengthU5s)
|
||||||
|
|
||||||
//t is the actual possible payload
|
//t is the actual possible payload
|
||||||
val payload: Vector[UInt5] = t.take(dataLength.toInt).toVector
|
val payload: Vector[UInt5] = t.take(dataLength.toInt)
|
||||||
|
|
||||||
val tag = LnTag.fromLnTagPrefix(prefix, payload)
|
val tag = LnTag.fromLnTagPrefix(prefix, payload)
|
||||||
|
|
||||||
|
|
|
@ -272,7 +272,7 @@ sealed abstract class ArithmeticInterpreter extends BitcoinSLogger {
|
||||||
|
|
||||||
/** Performs the given arithmetic operation on the stack head
|
/** Performs the given arithmetic operation on the stack head
|
||||||
* @param program the program whose stack top is used as an argument for the arithmetic operation
|
* @param program the program whose stack top is used as an argument for the arithmetic operation
|
||||||
* @param op the arithmetic ooperation that needs to be executed on the number, for instance incrementing by 1
|
* @param op the arithmetic operation that needs to be executed on the number, for instance incrementing by 1
|
||||||
* @return the program with the result from performing the arithmetic operation pushed onto the top of the stack
|
* @return the program with the result from performing the arithmetic operation pushed onto the top of the stack
|
||||||
*/
|
*/
|
||||||
@tailrec
|
@tailrec
|
||||||
|
@ -328,7 +328,7 @@ sealed abstract class ArithmeticInterpreter extends BitcoinSLogger {
|
||||||
|
|
||||||
/** Performs the given arithmetic operation on the top two stack items
|
/** Performs the given arithmetic operation on the top two stack items
|
||||||
* @param program the program whose stack top is used as an argument for the arithmetic operation
|
* @param program the program whose stack top is used as an argument for the arithmetic operation
|
||||||
* @param op the arithmetic ooperation that needs to be executed on the number, for instance incrementing by 1
|
* @param op the arithmetic operation that needs to be executed on the number, for instance incrementing by 1
|
||||||
* @return the program with the result from performing the arithmetic operation pushed onto the top of the stack
|
* @return the program with the result from performing the arithmetic operation pushed onto the top of the stack
|
||||||
*/
|
*/
|
||||||
@tailrec
|
@tailrec
|
||||||
|
|
|
@ -38,7 +38,7 @@ sealed abstract class LockTimeInterpreter extends BitcoinSLogger {
|
||||||
val input = program.txSignatureComponent.transaction
|
val input = program.txSignatureComponent.transaction
|
||||||
.inputs(program.txSignatureComponent.inputIndex.toInt)
|
.inputs(program.txSignatureComponent.inputIndex.toInt)
|
||||||
val transaction = program.txSignatureComponent.transaction
|
val transaction = program.txSignatureComponent.transaction
|
||||||
if (program.stack.size == 0) {
|
if (program.stack.isEmpty) {
|
||||||
logger.error(
|
logger.error(
|
||||||
"Transaction validation failing in OP_CHECKLOCKTIMEVERIFY because we have no stack items")
|
"Transaction validation failing in OP_CHECKLOCKTIMEVERIFY because we have no stack items")
|
||||||
program.failExecution(ScriptErrorInvalidStackOperation)
|
program.failExecution(ScriptErrorInvalidStackOperation)
|
||||||
|
|
|
@ -54,9 +54,9 @@ sealed abstract class ScriptParser
|
||||||
operations match {
|
operations match {
|
||||||
//for parsing strings like 'Az', need to remove single quotes
|
//for parsing strings like 'Az', need to remove single quotes
|
||||||
//example: [[https://github.com/bitcoin/bitcoin/blob/master/src/test/data/script_valid.json#L24]]
|
//example: [[https://github.com/bitcoin/bitcoin/blob/master/src/test/data/script_valid.json#L24]]
|
||||||
case h +: t if h.size > 0 && h.head == '\'' && h.last == '\'' =>
|
case h +: t if h.nonEmpty && h.head == '\'' && h.last == '\'' =>
|
||||||
val strippedQuotes = h.replace("\'", "")
|
val strippedQuotes = h.replace("\'", "")
|
||||||
if (strippedQuotes.size == 0) {
|
if (strippedQuotes.isEmpty) {
|
||||||
loop(t, OP_0.bytes ++ accum)
|
loop(t, OP_0.bytes ++ accum)
|
||||||
} else {
|
} else {
|
||||||
val bytes: ByteVector = {
|
val bytes: ByteVector = {
|
||||||
|
|
|
@ -26,7 +26,7 @@ class AesCryptTest extends BitcoinSUnitTest {
|
||||||
*
|
*
|
||||||
* Here's a link to the first test vector:
|
* Here's a link to the first test vector:
|
||||||
* https://gchq.github.io/CyberChef/#recipe=AES_Encrypt(%7B'option':'Hex','string':'2eefdf6ee2dbca83e7b7648a8f9d1897'%7D,%7B'option':'Hex','string':'889dc64377f6d993ef713c995f9c1ee5'%7D,'CFB','Hex','Hex')&input=NzZmZTM1ODgwMDU1ZTFmYWM5NTBmNDg0YTgxNWNkMjI
|
* https://gchq.github.io/CyberChef/#recipe=AES_Encrypt(%7B'option':'Hex','string':'2eefdf6ee2dbca83e7b7648a8f9d1897'%7D,%7B'option':'Hex','string':'889dc64377f6d993ef713c995f9c1ee5'%7D,'CFB','Hex','Hex')&input=NzZmZTM1ODgwMDU1ZTFmYWM5NTBmNDg0YTgxNWNkMjI
|
||||||
* The other vectors can be repliacted by tweaking the values
|
* The other vectors can be replicated by tweaking the values
|
||||||
* in the UI.
|
* in the UI.
|
||||||
*/
|
*/
|
||||||
it must "decrypt and encrypt some hard coded test vectors" in {
|
it must "decrypt and encrypt some hard coded test vectors" in {
|
||||||
|
|
|
@ -133,7 +133,7 @@ If you're looking to set up a DLC Oracle instead go to the [oracle server docs](
|
||||||
|
|
||||||
We are finally ready to start running some programs! Follow the [instructions here](applications/server.md#building-the-server) to build the server. Then, follow [these instructions](applications/cli.md) to setup the CLI.
|
We are finally ready to start running some programs! Follow the [instructions here](applications/server.md#building-the-server) to build the server. Then, follow [these instructions](applications/cli.md) to setup the CLI.
|
||||||
|
|
||||||
There are 2 ways to use the bitcoin-s server. It can either can be as a neutrino node or use bitcoind as a backend.
|
There are 2 ways to use the bitcoin-s server. It can either be as a neutrino node or use bitcoind as a backend.
|
||||||
This can be configured by the configuration option `bitcoin-s.node.mode` choosing either `neutrino` or `bitcoind`.
|
This can be configured by the configuration option `bitcoin-s.node.mode` choosing either `neutrino` or `bitcoind`.
|
||||||
|
|
||||||
### Option A: Neutrino Server
|
### Option A: Neutrino Server
|
||||||
|
@ -150,7 +150,7 @@ Testnet:
|
||||||
`bitcoin-s.node.peers = ["neutrino.testnet3.suredbits.com:18333"]`
|
`bitcoin-s.node.peers = ["neutrino.testnet3.suredbits.com:18333"]`
|
||||||
|
|
||||||
If you would like to use your own node you can either use the bitcoind backend option or connect to your own compatible node.
|
If you would like to use your own node you can either use the bitcoind backend option or connect to your own compatible node.
|
||||||
There is no released version of bitcoind that is neutrino compatible so you will either have to compile the latest `master` yourself, or use the experimental version provided by running `sbt downloadBitcoind`.
|
There is no released version of bitcoind that is neutrino compatible, so you will either have to compile the latest `master` yourself, or use the experimental version provided by running `sbt downloadBitcoind`.
|
||||||
|
|
||||||
After building your bitcoin-s server, properly configuring it to be in `neutrino` mode you can start your server with:
|
After building your bitcoin-s server, properly configuring it to be in `neutrino` mode you can start your server with:
|
||||||
|
|
||||||
|
|
|
@ -305,7 +305,7 @@ class EclairRpcClientTest extends BitcoinSAsyncTest {
|
||||||
.lnbcrt(Some(12345.msats.toLnCurrencyUnit))
|
.lnbcrt(Some(12345.msats.toLnCurrencyUnit))
|
||||||
.toString)
|
.toString)
|
||||||
assert(invoice.network == LnBitcoinRegTest)
|
assert(invoice.network == LnBitcoinRegTest)
|
||||||
assert(invoice.amount == Some(123450.pBTC))
|
assert(invoice.amount.contains(123450.pBTC))
|
||||||
assert(invoice.isValidSignature)
|
assert(invoice.isValidSignature)
|
||||||
assert(
|
assert(
|
||||||
invoice.timestamp > UInt64(1561063731)
|
invoice.timestamp > UInt64(1561063731)
|
||||||
|
@ -328,7 +328,7 @@ class EclairRpcClientTest extends BitcoinSAsyncTest {
|
||||||
.lnbcrt(Some(12345.msats.toLnCurrencyUnit))
|
.lnbcrt(Some(12345.msats.toLnCurrencyUnit))
|
||||||
.toString)
|
.toString)
|
||||||
assert(invoice.network == LnBitcoinRegTest)
|
assert(invoice.network == LnBitcoinRegTest)
|
||||||
assert(invoice.amount == Some(123450.pBTC))
|
assert(invoice.amount.contains(123450.pBTC))
|
||||||
assert(invoice.isValidSignature)
|
assert(invoice.isValidSignature)
|
||||||
assert(
|
assert(
|
||||||
invoice.timestamp > UInt64(1561063731)
|
invoice.timestamp > UInt64(1561063731)
|
||||||
|
@ -355,7 +355,7 @@ class EclairRpcClientTest extends BitcoinSAsyncTest {
|
||||||
.lnbcrt(Some(123450.pBTC))
|
.lnbcrt(Some(123450.pBTC))
|
||||||
.toString)
|
.toString)
|
||||||
assert(invoice.network == LnBitcoinRegTest)
|
assert(invoice.network == LnBitcoinRegTest)
|
||||||
assert(invoice.amount == Some(123450.pBTC))
|
assert(invoice.amount.contains(123450.pBTC))
|
||||||
assert(invoice.isValidSignature)
|
assert(invoice.isValidSignature)
|
||||||
assert(
|
assert(
|
||||||
invoice.timestamp > UInt64(1561063731)
|
invoice.timestamp > UInt64(1561063731)
|
||||||
|
@ -385,7 +385,7 @@ class EclairRpcClientTest extends BitcoinSAsyncTest {
|
||||||
.lnbcrt(Some(12345.msats.toLnCurrencyUnit))
|
.lnbcrt(Some(12345.msats.toLnCurrencyUnit))
|
||||||
.toString)
|
.toString)
|
||||||
assert(invoice.network == LnBitcoinRegTest)
|
assert(invoice.network == LnBitcoinRegTest)
|
||||||
assert(invoice.amount == Some(123450.pBTC))
|
assert(invoice.amount.contains(123450.pBTC))
|
||||||
assert(invoice.isValidSignature)
|
assert(invoice.isValidSignature)
|
||||||
assert(
|
assert(
|
||||||
invoice.timestamp > UInt64(1561063731)
|
invoice.timestamp > UInt64(1561063731)
|
||||||
|
|
|
@ -67,7 +67,7 @@ private[peer] object MerkleBuffers extends P2PLogger {
|
||||||
logger.trace(
|
logger.trace(
|
||||||
s"Block=${block.blockHeader.hashBE} has matches=${matches.map(_.flip)}")
|
s"Block=${block.blockHeader.hashBE} has matches=${matches.map(_.flip)}")
|
||||||
|
|
||||||
matches.exists(_ == tx.txId)
|
matches.contains(tx.txId)
|
||||||
} match {
|
} match {
|
||||||
case None =>
|
case None =>
|
||||||
logger.debug(
|
logger.debug(
|
||||||
|
|
|
@ -254,7 +254,7 @@ class TrezorAddressTest extends BitcoinSWalletTest with EmptyFixture {
|
||||||
accountsWithVectors = {
|
accountsWithVectors = {
|
||||||
assert(accounts.length == testVectors.length)
|
assert(accounts.length == testVectors.length)
|
||||||
val accountsWithVectors = testVectors.map { vec =>
|
val accountsWithVectors = testVectors.map { vec =>
|
||||||
assert(accounts.filter(_.hdAccount.index == vec.account).length == 1)
|
assert(accounts.count(_.hdAccount.index == vec.account) == 1)
|
||||||
accounts.find(_.hdAccount.index == vec.account) match {
|
accounts.find(_.hdAccount.index == vec.account) match {
|
||||||
case None =>
|
case None =>
|
||||||
fail(
|
fail(
|
||||||
|
|
|
@ -2,5 +2,5 @@ package org.bitcoins.wallet
|
||||||
|
|
||||||
import grizzled.slf4j.Logging
|
import grizzled.slf4j.Logging
|
||||||
|
|
||||||
/** Exposes acccess to the wallet logger */
|
/** Exposes access to the wallet logger */
|
||||||
private[bitcoins] trait WalletLogger extends Logging
|
private[bitcoins] trait WalletLogger extends Logging
|
||||||
|
|
|
@ -215,7 +215,7 @@ private[wallet] trait TransactionProcessing extends WalletLogger {
|
||||||
}
|
}
|
||||||
|
|
||||||
processed <- FutureUtil.sequentially(outputsToUse)(markAsPendingSpent)
|
processed <- FutureUtil.sequentially(outputsToUse)(markAsPendingSpent)
|
||||||
} yield processed.flatten.toVector
|
} yield processed.flatten
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,7 @@ case class AddressTagDAO()(implicit
|
||||||
spks.map(spk => BitcoinAddress.fromScriptPubKey(spk, network))
|
spks.map(spk => BitcoinAddress.fromScriptPubKey(spk, network))
|
||||||
|
|
||||||
val findByAddressFs = addresses.map(address => findByAddress(address))
|
val findByAddressFs = addresses.map(address => findByAddress(address))
|
||||||
FutureUtil.collect(findByAddressFs).map(_.toVector.flatten)
|
FutureUtil.collect(findByAddressFs).map(_.flatten)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,22 +43,22 @@ class ZMQSubscriber(
|
||||||
val isConnected = subscriber.connect(uri)
|
val isConnected = subscriber.connect(uri)
|
||||||
|
|
||||||
if (isConnected) {
|
if (isConnected) {
|
||||||
hashTxListener.map { _ =>
|
hashTxListener.foreach { _ =>
|
||||||
subscriber.subscribe(HashTx.topic.getBytes(ZMQ.CHARSET))
|
subscriber.subscribe(HashTx.topic.getBytes(ZMQ.CHARSET))
|
||||||
logger.debug("subscribed to the transaction hashes from zmq")
|
logger.debug("subscribed to the transaction hashes from zmq")
|
||||||
}
|
}
|
||||||
|
|
||||||
rawTxListener.map { _ =>
|
rawTxListener.foreach { _ =>
|
||||||
subscriber.subscribe(RawTx.topic.getBytes(ZMQ.CHARSET))
|
subscriber.subscribe(RawTx.topic.getBytes(ZMQ.CHARSET))
|
||||||
logger.debug("subscribed to raw transactions from zmq")
|
logger.debug("subscribed to raw transactions from zmq")
|
||||||
}
|
}
|
||||||
|
|
||||||
hashBlockListener.map { _ =>
|
hashBlockListener.foreach { _ =>
|
||||||
subscriber.subscribe(HashBlock.topic.getBytes(ZMQ.CHARSET))
|
subscriber.subscribe(HashBlock.topic.getBytes(ZMQ.CHARSET))
|
||||||
logger.debug("subscribed to the hashblock stream from zmq")
|
logger.debug("subscribed to the hashblock stream from zmq")
|
||||||
}
|
}
|
||||||
|
|
||||||
rawBlockListener.map { _ =>
|
rawBlockListener.foreach { _ =>
|
||||||
subscriber.subscribe(RawBlock.topic.getBytes(ZMQ.CHARSET))
|
subscriber.subscribe(RawBlock.topic.getBytes(ZMQ.CHARSET))
|
||||||
logger.debug("subscribed to raw block stream from zmq")
|
logger.debug("subscribed to raw block stream from zmq")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue