mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-26 21:42:48 +01:00
Add HashType to ECDigitalSignature API (#4320)
* HashType now uses Int instead of Int32 * Moved HashType from core to crypto * Added HashType helper functions to ECDigitalSignature * Added tests * Fixed compile
This commit is contained in:
parent
676c0b4261
commit
b80bf4649e
54 changed files with 265 additions and 186 deletions
|
@ -3,7 +3,7 @@ package org.bitcoins.commons
|
|||
import org.bitcoins.commons.jsonmodels.{SerializedPSBT, SerializedTransaction}
|
||||
import org.bitcoins.core.number.UInt32
|
||||
import org.bitcoins.core.psbt.{GlobalPSBTRecord, OutputPSBTRecord, PSBT}
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.crypto.HashType
|
||||
import org.bitcoins.testkitcore.util.BitcoinSUnitTest
|
||||
import scodec.bits._
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.bitcoins.core.number.UInt32
|
|||
import org.bitcoins.core.psbt.InputPSBTRecord.PartialSignature
|
||||
import org.bitcoins.core.psbt._
|
||||
import org.bitcoins.core.script.constant.ScriptToken
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.crypto.HashType
|
||||
import play.api.libs.json._
|
||||
import scodec.bits.ByteVector
|
||||
|
||||
|
|
|
@ -6,8 +6,12 @@ import org.bitcoins.core.protocol.script.ScriptPubKey
|
|||
import org.bitcoins.core.protocol.transaction.Transaction
|
||||
import org.bitcoins.core.psbt.PSBT
|
||||
import org.bitcoins.core.script.ScriptType
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.crypto.{ECDigitalSignature, ECPublicKey, ECPublicKeyBytes}
|
||||
import org.bitcoins.crypto.{
|
||||
ECDigitalSignature,
|
||||
ECPublicKey,
|
||||
ECPublicKeyBytes,
|
||||
HashType
|
||||
}
|
||||
|
||||
sealed abstract class RpcPsbtResult
|
||||
|
||||
|
|
|
@ -36,9 +36,8 @@ import org.bitcoins.core.protocol.{
|
|||
}
|
||||
import org.bitcoins.core.psbt.PSBT
|
||||
import org.bitcoins.core.script.ScriptType
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.wallet.fee.{BitcoinFeeUnit, SatoshisPerByte}
|
||||
import org.bitcoins.crypto._
|
||||
import org.bitcoins.crypto.{HashType, _}
|
||||
import play.api.libs.json._
|
||||
import ujson.{Num, Str, Value}
|
||||
import scodec.bits.ByteVector
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.bitcoins.core.protocol.ln.currency.MilliSatoshis
|
|||
import org.bitcoins.core.protocol.script.{ScriptPubKey, WitnessScriptPubKey}
|
||||
import org.bitcoins.core.protocol.transaction.{Transaction, TransactionInput}
|
||||
import org.bitcoins.core.psbt._
|
||||
import org.bitcoins.core.script.crypto._
|
||||
import org.bitcoins.core.util.BytesUtil
|
||||
import org.bitcoins.crypto._
|
||||
import play.api.libs.json._
|
||||
|
|
|
@ -14,11 +14,15 @@ import org.bitcoins.core.protocol.script.{
|
|||
}
|
||||
import org.bitcoins.core.protocol.transaction._
|
||||
import org.bitcoins.core.protocol.{Bech32Address, BitcoinAddress, P2PKHAddress}
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.wallet.fee.SatoshisPerByte
|
||||
import org.bitcoins.core.wallet.signer.BitcoinSigner
|
||||
import org.bitcoins.core.wallet.utxo.{ECSignatureParams, P2WPKHV0InputInfo}
|
||||
import org.bitcoins.crypto.{DoubleSha256DigestBE, ECPrivateKey, ECPublicKey}
|
||||
import org.bitcoins.crypto.{
|
||||
DoubleSha256DigestBE,
|
||||
ECPrivateKey,
|
||||
ECPublicKey,
|
||||
HashType
|
||||
}
|
||||
import org.bitcoins.rpc.client.common.{BitcoindRpcClient, BitcoindVersion}
|
||||
import org.bitcoins.rpc.config.{BitcoindInstanceLocal, BitcoindInstanceRemote}
|
||||
import org.bitcoins.rpc.util.RpcUtil
|
||||
|
|
|
@ -14,12 +14,12 @@ import org.bitcoins.core.protocol.BitcoinAddress
|
|||
import org.bitcoins.core.protocol.blockchain.MerkleBlock
|
||||
import org.bitcoins.core.protocol.transaction.{Transaction, TransactionInput}
|
||||
import org.bitcoins.core.psbt.PSBT
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.crypto.{
|
||||
DoubleSha256Digest,
|
||||
DoubleSha256DigestBE,
|
||||
ECPrivateKeyBytes,
|
||||
ECPublicKey
|
||||
ECPublicKey,
|
||||
HashType
|
||||
}
|
||||
import org.bitcoins.rpc.client.common.BitcoindVersion._
|
||||
import play.api.libs.json._
|
||||
|
|
|
@ -10,8 +10,7 @@ import org.bitcoins.commons.serializers.JsonWriters._
|
|||
import org.bitcoins.core.api.chain.ChainQueryApi
|
||||
import org.bitcoins.core.api.chain.db.{CompactFilterDb, CompactFilterHeaderDb}
|
||||
import org.bitcoins.core.protocol.transaction.Transaction
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.crypto.{DoubleSha256DigestBE, ECPrivateKey}
|
||||
import org.bitcoins.crypto.{DoubleSha256DigestBE, ECPrivateKey, HashType}
|
||||
import org.bitcoins.rpc.client.common.{BitcoindRpcClient, BitcoindVersion}
|
||||
import org.bitcoins.rpc.config.BitcoindInstance
|
||||
import play.api.libs.json._
|
||||
|
|
|
@ -11,8 +11,7 @@ import org.bitcoins.commons.serializers.JsonWriters._
|
|||
import org.bitcoins.core.api.chain.ChainQueryApi
|
||||
import org.bitcoins.core.api.chain.db.{CompactFilterDb, CompactFilterHeaderDb}
|
||||
import org.bitcoins.core.protocol.transaction.Transaction
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.crypto.{DoubleSha256DigestBE, ECPrivateKey}
|
||||
import org.bitcoins.crypto.{DoubleSha256DigestBE, ECPrivateKey, HashType}
|
||||
import org.bitcoins.rpc.client.common.{BitcoindRpcClient, BitcoindVersion}
|
||||
import org.bitcoins.rpc.config.BitcoindInstance
|
||||
import play.api.libs.json._
|
||||
|
|
|
@ -10,8 +10,7 @@ import org.bitcoins.commons.serializers.JsonWriters._
|
|||
import org.bitcoins.core.api.chain.ChainQueryApi
|
||||
import org.bitcoins.core.api.chain.db.{CompactFilterDb, CompactFilterHeaderDb}
|
||||
import org.bitcoins.core.protocol.transaction.Transaction
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.crypto.{DoubleSha256DigestBE, ECPrivateKey}
|
||||
import org.bitcoins.crypto.{DoubleSha256DigestBE, ECPrivateKey, HashType}
|
||||
import org.bitcoins.rpc.client.common.{
|
||||
BitcoindRpcClient,
|
||||
BitcoindVersion,
|
||||
|
|
|
@ -12,9 +12,8 @@ import org.bitcoins.core.api.chain.ChainQueryApi.FilterResponse
|
|||
import org.bitcoins.core.api.chain.db.CompactFilterDb
|
||||
import org.bitcoins.core.gcs.FilterType
|
||||
import org.bitcoins.core.protocol.transaction.Transaction
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.util.FutureUtil
|
||||
import org.bitcoins.crypto.{DoubleSha256DigestBE, ECPrivateKey}
|
||||
import org.bitcoins.crypto.{DoubleSha256DigestBE, ECPrivateKey, HashType}
|
||||
import org.bitcoins.rpc.client.common.{
|
||||
BitcoindRpcClient,
|
||||
BitcoindVersion,
|
||||
|
|
|
@ -9,9 +9,8 @@ import org.bitcoins.core.api.chain.ChainQueryApi.FilterResponse
|
|||
import org.bitcoins.core.api.chain.db.CompactFilterDb
|
||||
import org.bitcoins.core.gcs.FilterType
|
||||
import org.bitcoins.core.protocol.transaction.Transaction
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.util.FutureUtil
|
||||
import org.bitcoins.crypto.{DoubleSha256DigestBE, ECPrivateKey}
|
||||
import org.bitcoins.crypto.{DoubleSha256DigestBE, ECPrivateKey, HashType}
|
||||
import org.bitcoins.rpc.client.common.{
|
||||
BitcoindRpcClient,
|
||||
BitcoindVersion,
|
||||
|
|
|
@ -9,9 +9,8 @@ import org.bitcoins.core.api.chain.ChainQueryApi.FilterResponse
|
|||
import org.bitcoins.core.api.chain.db.CompactFilterDb
|
||||
import org.bitcoins.core.gcs.FilterType
|
||||
import org.bitcoins.core.protocol.transaction.Transaction
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.util.FutureUtil
|
||||
import org.bitcoins.crypto.{DoubleSha256DigestBE, ECPrivateKey}
|
||||
import org.bitcoins.crypto.{DoubleSha256DigestBE, ECPrivateKey, HashType}
|
||||
import org.bitcoins.rpc.client.common.{
|
||||
BitcoindRpcClient,
|
||||
BitcoindVersion,
|
||||
|
|
|
@ -6,7 +6,6 @@ import org.bitcoins.core.policy.Policy
|
|||
import org.bitcoins.core.protocol.script._
|
||||
import org.bitcoins.core.protocol.transaction._
|
||||
import org.bitcoins.core.script.PreExecutionScriptProgram
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.script.interpreter.ScriptInterpreter
|
||||
import org.bitcoins.core.script.result.ScriptOk
|
||||
import org.bitcoins.core.wallet.builder.StandardNonInteractiveFinalizer
|
||||
|
@ -15,7 +14,8 @@ import org.bitcoins.core.wallet.utxo.{ECSignatureParams, P2PKHInputInfo}
|
|||
import org.bitcoins.crypto.{
|
||||
ECDigitalSignature,
|
||||
ECPrivateKey,
|
||||
EmptyDigitalSignature
|
||||
EmptyDigitalSignature,
|
||||
HashType
|
||||
}
|
||||
import org.bitcoins.testkitcore.util.TransactionTestUtil
|
||||
import org.bitcoins.testkitcore.gen.{CreditingTxGen, ScriptGenerators}
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
package org.bitcoins.core.crypto
|
||||
|
||||
import org.bitcoins.core.currency.{Bitcoins, CurrencyUnits, Satoshis}
|
||||
import org.bitcoins.core.number.{Int32, UInt32}
|
||||
import org.bitcoins.core.number.UInt32
|
||||
import org.bitcoins.core.policy.Policy
|
||||
import org.bitcoins.core.protocol.script._
|
||||
import org.bitcoins.core.protocol.transaction._
|
||||
import org.bitcoins.core.script.crypto._
|
||||
import org.bitcoins.core.serializers.script.ScriptParser
|
||||
import org.bitcoins.core.util._
|
||||
import org.bitcoins.core.wallet.builder.StandardNonInteractiveFinalizer
|
||||
import org.bitcoins.core.wallet.fee.SatoshisPerVirtualByte
|
||||
import org.bitcoins.crypto.DoubleSha256Digest
|
||||
import org.bitcoins.crypto._
|
||||
import org.bitcoins.testkitcore.gen.{CreditingTxGen, ScriptGenerators}
|
||||
import org.bitcoins.testkitcore.util.BitcoinSUnitTest
|
||||
|
||||
|
@ -396,7 +395,7 @@ class TransactionSignatureSerializerTest extends BitcoinSUnitTest {
|
|||
}
|
||||
|
||||
it must "fail to create a SIGHASH from an invalid number" in {
|
||||
val z = Int32.zero
|
||||
val z = 0
|
||||
Try(SIGHASH_NONE(z)).isFailure must be(true)
|
||||
Try(SIGHASH_SINGLE(z)).isFailure must be(true)
|
||||
Try(SIGHASH_ANYONECANPAY(z)).isFailure must be(true)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.bitcoins.core.protocol.script
|
||||
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.crypto.ECDigitalSignature
|
||||
import org.bitcoins.crypto.{ECDigitalSignature, HashType}
|
||||
import org.bitcoins.testkitcore.util.{BitcoinSJvmTest, TestUtil}
|
||||
import scodec.bits.ByteVector
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package org.bitcoins.core.protocol.script
|
|||
|
||||
import org.bitcoins.core.crypto._
|
||||
import org.bitcoins.core.currency.CurrencyUnits
|
||||
import org.bitcoins.core.number.Int32
|
||||
import org.bitcoins.core.policy.Policy
|
||||
import org.bitcoins.core.protocol.script.testprotocol.SignatureHashTestCase
|
||||
import org.bitcoins.core.protocol.transaction.{
|
||||
|
@ -11,10 +10,9 @@ import org.bitcoins.core.protocol.transaction.{
|
|||
TransactionOutput,
|
||||
WitnessTransaction
|
||||
}
|
||||
import org.bitcoins.core.script.crypto.{HashType, SIGHASH_ALL}
|
||||
import org.bitcoins.core.serializers.script.RawScriptSignatureParser
|
||||
import org.bitcoins.core.util.BytesUtil
|
||||
import org.bitcoins.crypto.{DoubleSha256Digest, ECDigitalSignature}
|
||||
import org.bitcoins.crypto._
|
||||
import org.bitcoins.testkitcore.util.{BitcoinSJvmTest, TestUtil}
|
||||
import scodec.bits.ByteVector
|
||||
import upickle.default._
|
||||
|
@ -90,8 +88,7 @@ class ScriptSignatureTest extends BitcoinSJvmTest {
|
|||
val hex =
|
||||
"8c493046022100d23459d03ed7e9511a47d13292d3430a04627de6235b6e51a40f9cd386f2abe3022100e7d25b080f0bb8d8d5f878bba7d54ad2fda650ea8d158a33ee3cbd11768191fd004104b0e2c879e4daf7b9ab68350228c159766676a14f5815084ba166432aab46198d4cca98fa3e9981d0a90b2effc514b76279476550ba3663fdcaff94c38420e9d5"
|
||||
val scriptSig: ScriptSignature = RawScriptSignatureParser.read(hex)
|
||||
HashType(scriptSig.signatures.head.bytes.last) must be(
|
||||
SIGHASH_ALL(Int32.zero))
|
||||
HashType(scriptSig.signatures.head.bytes.last) must be(SIGHASH_ALL(0))
|
||||
}
|
||||
|
||||
it must "have an empty script signature" in {
|
||||
|
|
|
@ -3,9 +3,8 @@ package org.bitcoins.core.protocol.script.testprotocol
|
|||
import org.bitcoins.core.number.{Int32, UInt32}
|
||||
import org.bitcoins.core.protocol.script.ScriptPubKey
|
||||
import org.bitcoins.core.protocol.transaction.Transaction
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.serializers.script.ScriptParser
|
||||
import org.bitcoins.crypto.DoubleSha256Digest
|
||||
import org.bitcoins.crypto.{DoubleSha256Digest, HashType}
|
||||
import ujson._
|
||||
import upickle.default._
|
||||
|
||||
|
@ -34,7 +33,7 @@ object SignatureHashTestCase {
|
|||
val script: ScriptPubKey = ScriptPubKey(asm)
|
||||
val inputIndex: UInt32 = UInt32(elements(2).num.toInt)
|
||||
val hashTypeNum: Int32 = Int32(elements(3).num.toInt)
|
||||
val hashType: HashType = HashType(hashTypeNum)
|
||||
val hashType: HashType = HashType(hashTypeNum.toInt)
|
||||
val hash: DoubleSha256Digest =
|
||||
DoubleSha256Digest(elements.last.str)
|
||||
SignatureHashTestCase(transaction,
|
||||
|
|
|
@ -10,8 +10,7 @@ import org.bitcoins.core.protocol.script.{
|
|||
import org.bitcoins.core.protocol.transaction.Transaction
|
||||
import org.bitcoins.core.psbt.GlobalPSBTRecord.XPubKey
|
||||
import org.bitcoins.core.psbt.InputPSBTRecord.ProofOfReservesCommitment
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.crypto.ECPublicKey
|
||||
import org.bitcoins.crypto.{ECPublicKey, HashType}
|
||||
import org.bitcoins.testkitcore.gen.PSBTGenerators
|
||||
import org.bitcoins.testkitcore.util.BitcoinSUnitTest
|
||||
import scodec.bits._
|
||||
|
|
|
@ -13,9 +13,8 @@ import org.bitcoins.core.psbt.InputPSBTRecord.{
|
|||
}
|
||||
import org.bitcoins.core.psbt.PSBTGlobalKeyId.XPubKeyKeyId
|
||||
import org.bitcoins.core.script.constant._
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.wallet.utxo.{ConditionalPath, InputInfo}
|
||||
import org.bitcoins.crypto._
|
||||
import org.bitcoins.crypto.{HashType, _}
|
||||
import org.bitcoins.testkitcore.util.BitcoinSUnitTest
|
||||
import org.bitcoins.testkitcore.util.TransactionTestUtil._
|
||||
import scodec.bits._
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
package org.bitcoins.core.script.crypto
|
||||
|
||||
import org.bitcoins.testkitcore.gen.NumberGenerator
|
||||
import org.scalacheck.{Prop, Properties}
|
||||
|
||||
class HashTypeSpec extends Properties("HashTypeSpec") {
|
||||
|
||||
property("serialization symmetry") = {
|
||||
Prop.forAll(NumberGenerator.int32s) { i32 =>
|
||||
val hashType = HashType.fromBytes(i32.bytes)
|
||||
|
||||
hashType.num == i32 &&
|
||||
i32.bytes.last == hashType.byte &&
|
||||
//this check cannot check the other 3 bytes in
|
||||
//hash type as they are discarded from inclusion
|
||||
//on a bitcoin digital signature. Not sure why satoshi
|
||||
//would have just used a uint8_t to represent a hash type
|
||||
//instead of a uint32_t.
|
||||
HashType.fromByte(hashType.byte).byte == hashType.byte
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -5,7 +5,6 @@ import org.bitcoins.core.number.UInt32
|
|||
import org.bitcoins.core.protocol.script._
|
||||
import org.bitcoins.core.protocol.transaction._
|
||||
import org.bitcoins.core.script.constant.ScriptNumber
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.util.BitcoinScriptUtil
|
||||
import org.bitcoins.core.wallet.fee.{SatoshisPerByte, SatoshisPerVirtualByte}
|
||||
import org.bitcoins.core.wallet.utxo.{
|
||||
|
@ -17,6 +16,7 @@ import org.bitcoins.core.wallet.utxo.{
|
|||
import org.bitcoins.crypto.{
|
||||
DoubleSha256DigestBE,
|
||||
ECPrivateKey,
|
||||
HashType,
|
||||
LowRDummyECDigitalSignature,
|
||||
Sign
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import org.bitcoins.core.currency.{Bitcoins, CurrencyUnits, Satoshis}
|
|||
import org.bitcoins.core.number.UInt32
|
||||
import org.bitcoins.core.protocol.script._
|
||||
import org.bitcoins.core.protocol.transaction._
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.wallet.fee.SatoshisPerVirtualByte
|
||||
import org.bitcoins.core.wallet.utxo.{
|
||||
ConditionalPath,
|
||||
|
@ -12,7 +11,12 @@ import org.bitcoins.core.wallet.utxo.{
|
|||
ScriptSignatureParams,
|
||||
UnassignedSegwitNativeInputInfo
|
||||
}
|
||||
import org.bitcoins.crypto.{DoubleSha256DigestBE, ECPrivateKey, ECPublicKey}
|
||||
import org.bitcoins.crypto.{
|
||||
DoubleSha256DigestBE,
|
||||
ECPrivateKey,
|
||||
ECPublicKey,
|
||||
HashType
|
||||
}
|
||||
import org.bitcoins.testkitcore.Implicits._
|
||||
import org.bitcoins.testkitcore.gen.{
|
||||
CreditingTxGen,
|
||||
|
|
|
@ -4,7 +4,6 @@ import org.bitcoins.core.currency.{Bitcoins, CurrencyUnits, Satoshis}
|
|||
import org.bitcoins.core.number.UInt32
|
||||
import org.bitcoins.core.protocol.script._
|
||||
import org.bitcoins.core.protocol.transaction._
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.wallet.fee.SatoshisPerVirtualByte
|
||||
import org.bitcoins.core.wallet.utxo.{
|
||||
ConditionalPath,
|
||||
|
@ -12,7 +11,12 @@ import org.bitcoins.core.wallet.utxo.{
|
|||
ScriptSignatureParams,
|
||||
UnassignedSegwitNativeInputInfo
|
||||
}
|
||||
import org.bitcoins.crypto.{DoubleSha256DigestBE, ECPrivateKey, ECPublicKey}
|
||||
import org.bitcoins.crypto.{
|
||||
DoubleSha256DigestBE,
|
||||
ECPrivateKey,
|
||||
ECPublicKey,
|
||||
HashType
|
||||
}
|
||||
import org.bitcoins.testkitcore.Implicits._
|
||||
import org.bitcoins.testkitcore.gen.ScriptGenerators
|
||||
import org.bitcoins.testkitcore.util.BitcoinSUnitTest
|
||||
|
|
|
@ -4,8 +4,7 @@ import org.bitcoins.core.currency.CurrencyUnits
|
|||
import org.bitcoins.core.number.UInt32
|
||||
import org.bitcoins.core.protocol.script._
|
||||
import org.bitcoins.core.protocol.transaction._
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.crypto.DoubleSha256DigestBE
|
||||
import org.bitcoins.crypto.{DoubleSha256DigestBE, HashType}
|
||||
import org.bitcoins.testkitcore.Implicits._
|
||||
import org.bitcoins.testkitcore.gen.ScriptGenerators
|
||||
import org.bitcoins.testkitcore.util.BitcoinSUnitTest
|
||||
|
|
|
@ -15,14 +15,13 @@ import org.bitcoins.core.protocol.transaction.{
|
|||
TransactionOutPoint,
|
||||
TransactionOutput
|
||||
}
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.wallet.utxo.{
|
||||
ConditionalPath,
|
||||
InputInfo,
|
||||
ScriptSignatureParams,
|
||||
TxoState
|
||||
}
|
||||
import org.bitcoins.crypto.{DoubleSha256DigestBE, Sign}
|
||||
import org.bitcoins.crypto.{DoubleSha256DigestBE, HashType, Sign}
|
||||
|
||||
/** DB representation of a native V0
|
||||
* SegWit UTXO
|
||||
|
|
|
@ -5,7 +5,6 @@ import org.bitcoins.core.protocol.script.ScriptPubKey
|
|||
import org.bitcoins.core.protocol.transaction.TransactionOutput
|
||||
import org.bitcoins.core.psbt.InputPSBTRecord.PartialSignature
|
||||
import org.bitcoins.core.script.constant.ScriptToken
|
||||
import org.bitcoins.core.script.crypto._
|
||||
import org.bitcoins.core.script.flag.{ScriptFlag, ScriptFlagUtil}
|
||||
import org.bitcoins.core.script.result.ScriptErrorWitnessPubKeyType
|
||||
import org.bitcoins.core.util.BitcoinScriptUtil
|
||||
|
@ -13,7 +12,8 @@ import org.bitcoins.crypto.{
|
|||
DERSignatureUtil,
|
||||
ECDigitalSignature,
|
||||
ECPublicKey,
|
||||
ECPublicKeyBytes
|
||||
ECPublicKeyBytes,
|
||||
HashType
|
||||
}
|
||||
import scodec.bits.ByteVector
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package org.bitcoins.core.crypto
|
||||
|
||||
import org.bitcoins.core.protocol.transaction.Transaction
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.wallet.utxo.{InputInfo, InputSigningInfo}
|
||||
import org.bitcoins.crypto.{
|
||||
DERSignatureUtil,
|
||||
ECAdaptorSignature,
|
||||
ECDigitalSignature,
|
||||
ECPrivateKey
|
||||
ECPrivateKey,
|
||||
HashType
|
||||
}
|
||||
import scodec.bits.ByteVector
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package org.bitcoins.core.crypto
|
||||
|
||||
import org.bitcoins.core.currency.CurrencyUnit
|
||||
import org.bitcoins.core.number.UInt32
|
||||
import org.bitcoins.core.number.{Int32, UInt32}
|
||||
import org.bitcoins.core.protocol.CompactSizeUInt
|
||||
import org.bitcoins.core.protocol.script._
|
||||
import org.bitcoins.core.protocol.transaction._
|
||||
|
@ -10,7 +10,18 @@ import org.bitcoins.core.script.crypto._
|
|||
import org.bitcoins.core.serializers.transaction.RawTransactionOutputParser
|
||||
import org.bitcoins.core.util.{BitcoinScriptUtil, BytesUtil}
|
||||
import org.bitcoins.core.wallet.utxo.{InputInfo, InputSigningInfo}
|
||||
import org.bitcoins.crypto.{CryptoUtil, DoubleSha256Digest}
|
||||
import org.bitcoins.crypto.{
|
||||
CryptoUtil,
|
||||
DoubleSha256Digest,
|
||||
HashType,
|
||||
SIGHASH_ALL,
|
||||
SIGHASH_ALL_ANYONECANPAY,
|
||||
SIGHASH_ANYONECANPAY,
|
||||
SIGHASH_NONE,
|
||||
SIGHASH_NONE_ANYONECANPAY,
|
||||
SIGHASH_SINGLE,
|
||||
SIGHASH_SINGLE_ANYONECANPAY
|
||||
}
|
||||
import scodec.bits.ByteVector
|
||||
|
||||
/** Created by chris on 2/16/16.
|
||||
|
@ -114,7 +125,7 @@ sealed abstract class TransactionSignatureSerializer {
|
|||
updatedInputs,
|
||||
spendingTransaction.outputs,
|
||||
spendingTransaction.lockTime)
|
||||
val sigHashBytes = hashType.num.bytes.reverse
|
||||
val sigHashBytes = Int32(hashType.num).bytes.reverse
|
||||
|
||||
hashType match {
|
||||
case _: SIGHASH_NONE =>
|
||||
|
@ -213,7 +224,8 @@ sealed abstract class TransactionSignatureSerializer {
|
|||
spendingTransaction.version.bytes.reverse ++ outPointHash ++ sequenceHash ++
|
||||
i.previousOutput.bytes ++ CompactSizeUInt.calc(scriptBytes).bytes ++
|
||||
scriptBytes ++ amount.bytes ++ i.sequence.bytes.reverse ++
|
||||
outputHash ++ spendingTransaction.lockTime.bytes.reverse ++ hashType.num.bytes.reverse
|
||||
outputHash ++ spendingTransaction.lockTime.bytes.reverse ++ Int32(
|
||||
hashType.num).bytes.reverse
|
||||
serializationForSig
|
||||
}
|
||||
}
|
||||
|
@ -318,7 +330,7 @@ sealed abstract class TransactionSignatureSerializer {
|
|||
UInt32.zero)
|
||||
}
|
||||
|
||||
/** Executes the [[org.bitcoins.core.script.crypto.SIGHASH_NONE SIGHASH_NONE]]
|
||||
/** Executes the [[SIGHASH_NONE SIGHASH_NONE]]
|
||||
* procedure on a spending transaction for the input specified by inputIndex.
|
||||
*/
|
||||
private def sigHashNone(
|
||||
|
@ -338,7 +350,7 @@ sealed abstract class TransactionSignatureSerializer {
|
|||
sigHashNoneTx
|
||||
}
|
||||
|
||||
/** Executes the [[org.bitcoins.core.script.crypto.SIGHASH_SINGLE SIGHASH_SINGLE]] procedure on a spending
|
||||
/** Executes the [[SIGHASH_SINGLE SIGHASH_SINGLE]] procedure on a spending
|
||||
* transaction for the input specified by inputIndex
|
||||
*/
|
||||
private def sigHashSingle(
|
||||
|
@ -369,14 +381,14 @@ sealed abstract class TransactionSignatureSerializer {
|
|||
sigHashSingleTx
|
||||
}
|
||||
|
||||
/** Executes the [[org.bitcoins.core.script.crypto.SIGHASH_ALL SIGHASH_ALL]] procedure on a spending
|
||||
/** Executes the [[SIGHASH_ALL SIGHASH_ALL]] procedure on a spending
|
||||
* transaction at inputIndex.
|
||||
*/
|
||||
private def sigHashAll(spendingTransaction: Transaction): Transaction = {
|
||||
spendingTransaction
|
||||
}
|
||||
|
||||
/** Executes the [[org.bitcoins.core.script.crypto.SIGHASH_ANYONECANPAY SIGHASH_ANYONECANPAY]] procedure
|
||||
/** Executes the [[SIGHASH_ANYONECANPAY SIGHASH_ANYONECANPAY]] procedure
|
||||
* on a spending transaction at inputIndex.
|
||||
*/
|
||||
private def sigHashAnyoneCanPay(
|
||||
|
|
|
@ -7,9 +7,8 @@ import org.bitcoins.core.protocol.BitcoinAddress
|
|||
import org.bitcoins.core.protocol.tlv._
|
||||
import org.bitcoins.core.protocol.transaction.TransactionOutPoint
|
||||
import org.bitcoins.core.psbt.InputPSBTRecord.PartialSignature
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.wallet.fee.SatoshisPerVirtualByte
|
||||
import org.bitcoins.crypto._
|
||||
import org.bitcoins.crypto.{HashType, _}
|
||||
import scodec.bits.ByteVector
|
||||
|
||||
import scala.annotation.tailrec
|
||||
|
|
|
@ -14,11 +14,10 @@ import org.bitcoins.core.protocol.transaction._
|
|||
import org.bitcoins.core.protocol.{Bech32Address, BitcoinAddress}
|
||||
import org.bitcoins.core.psbt.InputPSBTRecord.PartialSignature
|
||||
import org.bitcoins.core.psbt.PSBT
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.util.{FutureUtil, Indexed}
|
||||
import org.bitcoins.core.wallet.signer.BitcoinSigner
|
||||
import org.bitcoins.core.wallet.utxo._
|
||||
import org.bitcoins.crypto._
|
||||
import org.bitcoins.crypto.{HashType, _}
|
||||
import scodec.bits.ByteVector
|
||||
|
||||
import scala.concurrent.{ExecutionContext, Future}
|
||||
|
|
|
@ -15,9 +15,8 @@ import org.bitcoins.core.protocol.dlc.models.{
|
|||
import org.bitcoins.core.protocol.transaction.{Transaction, WitnessTransaction}
|
||||
import org.bitcoins.core.psbt.InputPSBTRecord.PartialSignature
|
||||
import org.bitcoins.core.psbt.PSBT
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.util.{FutureUtil, Indexed}
|
||||
import org.bitcoins.crypto.{ECAdaptorSignature, ECPublicKey}
|
||||
import org.bitcoins.crypto.{ECAdaptorSignature, ECPublicKey, HashType}
|
||||
import scodec.bits.ByteVector
|
||||
|
||||
import scala.concurrent.{ExecutionContext, Future}
|
||||
|
|
|
@ -5,7 +5,6 @@ import org.bitcoins.core.number.UInt32
|
|||
import org.bitcoins.core.policy.Policy
|
||||
import org.bitcoins.core.protocol.script._
|
||||
import org.bitcoins.core.script.control.OP_RETURN
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.wallet.builder.{
|
||||
AddWitnessDataFinalizer,
|
||||
RawTxBuilder,
|
||||
|
@ -15,7 +14,7 @@ import org.bitcoins.core.wallet.builder.{
|
|||
import org.bitcoins.core.wallet.fee.FeeUnit
|
||||
import org.bitcoins.core.wallet.signer.BitcoinSigner
|
||||
import org.bitcoins.core.wallet.utxo._
|
||||
import org.bitcoins.crypto.{DummyECDigitalSignature, Sign}
|
||||
import org.bitcoins.crypto.{DummyECDigitalSignature, HashType, Sign}
|
||||
|
||||
import scala.annotation.tailrec
|
||||
import scala.util.{Failure, Success, Try}
|
||||
|
|
|
@ -6,13 +6,12 @@ import org.bitcoins.core.hd.BIP32Path
|
|||
import org.bitcoins.core.number.UInt32
|
||||
import org.bitcoins.core.protocol.script._
|
||||
import org.bitcoins.core.protocol.transaction._
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.script.interpreter.ScriptInterpreter
|
||||
import org.bitcoins.core.util.BitcoinScriptUtil
|
||||
import org.bitcoins.core.wallet.fee.SatoshisPerVirtualByte
|
||||
import org.bitcoins.core.wallet.signer.BitcoinSigner
|
||||
import org.bitcoins.core.wallet.utxo._
|
||||
import org.bitcoins.crypto._
|
||||
import org.bitcoins.crypto.{HashType, _}
|
||||
import scodec.bits._
|
||||
|
||||
import scala.annotation.tailrec
|
||||
|
|
|
@ -4,11 +4,10 @@ import org.bitcoins.core.byteVectorOrdering
|
|||
import org.bitcoins.core.number.UInt32
|
||||
import org.bitcoins.core.protocol.script._
|
||||
import org.bitcoins.core.protocol.transaction._
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.util.SeqWrapper
|
||||
import org.bitcoins.core.wallet.signer.BitcoinSigner
|
||||
import org.bitcoins.core.wallet.utxo._
|
||||
import org.bitcoins.crypto._
|
||||
import org.bitcoins.crypto.{HashType, _}
|
||||
import scodec.bits.ByteVector
|
||||
|
||||
import scala.annotation.tailrec
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.bitcoins.core.psbt
|
|||
|
||||
import org.bitcoins.core.crypto.ExtPublicKey
|
||||
import org.bitcoins.core.hd.BIP32Path
|
||||
import org.bitcoins.core.number.UInt32
|
||||
import org.bitcoins.core.number.{Int32, UInt32}
|
||||
import org.bitcoins.core.protocol.CompactSizeUInt
|
||||
import org.bitcoins.core.protocol.script._
|
||||
import org.bitcoins.core.protocol.transaction.{
|
||||
|
@ -11,10 +11,9 @@ import org.bitcoins.core.protocol.transaction.{
|
|||
Transaction,
|
||||
TransactionOutput
|
||||
}
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.serializers.script.RawScriptWitnessParser
|
||||
import org.bitcoins.core.util.BytesUtil
|
||||
import org.bitcoins.crypto._
|
||||
import org.bitcoins.crypto.{HashType, _}
|
||||
import scodec.bits.ByteVector
|
||||
|
||||
sealed trait PSBTRecord extends NetworkElement {
|
||||
|
@ -218,7 +217,7 @@ object InputPSBTRecord extends Factory[InputPSBTRecord] {
|
|||
case class SigHashType(hashType: HashType) extends InputPSBTRecord {
|
||||
override type KeyId = SigHashTypeKeyId.type
|
||||
override val key: ByteVector = ByteVector(SigHashTypeKeyId.byte)
|
||||
override val value: ByteVector = hashType.num.bytesLE
|
||||
override val value: ByteVector = Int32(hashType.num).bytesLE
|
||||
}
|
||||
|
||||
case class RedeemScript(redeemScript: ScriptPubKey) extends InputPSBTRecord {
|
||||
|
|
|
@ -7,11 +7,10 @@ import org.bitcoins.core.protocol.script._
|
|||
import org.bitcoins.core.protocol.transaction._
|
||||
import org.bitcoins.core.psbt.InputPSBTRecord.PartialSignature
|
||||
import org.bitcoins.core.psbt.PSBT
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.script.flag.ScriptFlag
|
||||
import org.bitcoins.core.wallet.builder.TxBuilderError
|
||||
import org.bitcoins.core.wallet.utxo._
|
||||
import org.bitcoins.crypto._
|
||||
import org.bitcoins.crypto.{HashType, _}
|
||||
import scodec.bits.ByteVector
|
||||
|
||||
sealed abstract class SignerUtils {
|
||||
|
|
|
@ -6,11 +6,11 @@ import org.bitcoins.core.protocol.CompactSizeUInt
|
|||
import org.bitcoins.core.protocol.script._
|
||||
import org.bitcoins.core.protocol.transaction._
|
||||
import org.bitcoins.core.script.constant.ScriptConstant
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.util.{BitcoinScriptUtil, BytesUtil}
|
||||
import org.bitcoins.crypto.{
|
||||
ECPublicKey,
|
||||
ECPublicKeyBytes,
|
||||
HashType,
|
||||
LowRDummyECDigitalSignature,
|
||||
NetworkElement,
|
||||
Sign
|
||||
|
|
|
@ -7,8 +7,7 @@ import org.bitcoins.core.protocol.script.{
|
|||
SignatureVersion
|
||||
}
|
||||
import org.bitcoins.core.protocol.transaction._
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.crypto.Sign
|
||||
import org.bitcoins.crypto.{HashType, Sign}
|
||||
|
||||
/** Stores the information required to generate a signature (ECSignatureParams)
|
||||
* or to generate a script signature (ScriptSignatureParams) for a given satisfaction
|
||||
|
|
|
@ -93,6 +93,10 @@ sealed abstract class CryptoGenerators {
|
|||
hash <- CryptoGenerators.doubleSha256Digest
|
||||
} yield privKey.sign(hash)
|
||||
|
||||
def hashType: Gen[HashType] = {
|
||||
Gen.oneOf(HashType.hashTypes)
|
||||
}
|
||||
|
||||
def schnorrDigitalSignature: Gen[SchnorrDigitalSignature] = {
|
||||
for {
|
||||
privKey <- privateKey
|
||||
|
|
|
@ -92,4 +92,34 @@ class ECDigitalSignatureTest extends BitcoinSCryptoTest {
|
|||
}
|
||||
}
|
||||
|
||||
it must "not view an incorrectly encoded sig_hash byte as strictly encoded" in {
|
||||
forAll(CryptoGenerators.digitalSignature, CryptoGenerators.hashType) {
|
||||
case (sig, hashType) =>
|
||||
val bigSigHash = ByteVector.fromInt(i = hashType.num, size = 4)
|
||||
assert(sig.hashTypeOpt.isEmpty)
|
||||
|
||||
val sigWithBigSigHash = ECDigitalSignature(sig.bytes.++(bigSigHash))
|
||||
assert(sigWithBigSigHash.hashTypeOpt.contains(hashType))
|
||||
assert(!sigWithBigSigHash.isStrictEncoded)
|
||||
}
|
||||
}
|
||||
|
||||
it must "correctly append and find HashTypes" in {
|
||||
forAll(CryptoGenerators.digitalSignature, CryptoGenerators.hashType) {
|
||||
case (sig, hashType) =>
|
||||
assert(sig.hashTypeOpt.isEmpty)
|
||||
val sigWithHashType = sig.appendHashType(hashType)
|
||||
assert(sigWithHashType.hashTypeOpt.contains(hashType))
|
||||
}
|
||||
}
|
||||
|
||||
it must "not append a HashType if one is already there" in {
|
||||
forAll(CryptoGenerators.digitalSignature,
|
||||
CryptoGenerators.hashType,
|
||||
CryptoGenerators.hashType) { case (sig, hashType, hashType2) =>
|
||||
val sigWithHashType = sig.appendHashType(hashType)
|
||||
assertThrows[IllegalArgumentException](
|
||||
sigWithHashType.appendHashType(hashType2))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,15 @@
|
|||
package org.bitcoins.core.script.crypto
|
||||
package org.bitcoins.crypto
|
||||
|
||||
import org.bitcoins.core.number.Int32
|
||||
import org.bitcoins.testkitcore.util.BitcoinSUnitTest
|
||||
import scodec.bits.ByteVector
|
||||
|
||||
/** Created by chris on 2/27/16.
|
||||
*/
|
||||
class HashTypeTest extends BitcoinSUnitTest {
|
||||
class HashTypeTest extends BitcoinSCryptoTest {
|
||||
|
||||
"HashType" must "combine hash types with SIGHASH_ANYONECANPAY" in {
|
||||
HashType.sigHashAllAnyoneCanPay.num must be(Int32(0x81))
|
||||
HashType.sigHashNoneAnyoneCanPay.num must be(Int32(0x82))
|
||||
HashType.sigHashSingleAnyoneCanPay.num must be(Int32(0x83))
|
||||
HashType.sigHashAllAnyoneCanPay.num must be(0x81)
|
||||
HashType.sigHashNoneAnyoneCanPay.num must be(0x82)
|
||||
HashType.sigHashSingleAnyoneCanPay.num must be(0x83)
|
||||
}
|
||||
|
||||
it must "find a hash type by its hex value" in {
|
||||
|
@ -22,8 +20,8 @@ class HashTypeTest extends BitcoinSUnitTest {
|
|||
}
|
||||
|
||||
it must "find a hash type by its byte value" in {
|
||||
HashType(0.toByte) must be(SIGHASH_ALL(Int32.zero))
|
||||
HashType(1.toByte) must be(SIGHASH_ALL(Int32.one))
|
||||
HashType(0.toByte) must be(SIGHASH_ALL(0))
|
||||
HashType(1.toByte) must be(SIGHASH_ALL(1))
|
||||
HashType(2.toByte) must be(HashType.sigHashNone)
|
||||
HashType(3.toByte) must be(HashType.sigHashSingle)
|
||||
HashType(0x80) must be(HashType.sigHashAnyoneCanPay)
|
||||
|
@ -31,20 +29,21 @@ class HashTypeTest extends BitcoinSUnitTest {
|
|||
}
|
||||
|
||||
it must "default to SIGHASH_ALL if the given string/byte is not known" in {
|
||||
HashType(ByteVector(0x124.toByte)) must be(SIGHASH_ALL(Int32(36)))
|
||||
HashType(ByteVector(0x124.toByte)) must be(SIGHASH_ALL(36))
|
||||
}
|
||||
|
||||
it must "find hashType for number 1190874345" in {
|
||||
//1190874345 & 0x80 = 0x80
|
||||
val num = Int32(1190874345)
|
||||
val num = 1190874345
|
||||
HashType(num).isInstanceOf[SIGHASH_ANYONECANPAY] must be(true)
|
||||
HashType(num.bytes).isInstanceOf[SIGHASH_ANYONECANPAY] must be(true)
|
||||
HashType(ByteVector.fromInt(num))
|
||||
.isInstanceOf[SIGHASH_ANYONECANPAY] must be(true)
|
||||
}
|
||||
|
||||
it must "determine if a given number is of hashType SIGHASH_ALL" in {
|
||||
HashType.isSigHashAll(Int32.zero) must be(true)
|
||||
HashType.isSigHashAll(Int32.one) must be(true)
|
||||
HashType.isSigHashAll(Int32(5)) must be(true)
|
||||
HashType.isSigHashAll(0) must be(true)
|
||||
HashType.isSigHashAll(1) must be(true)
|
||||
HashType.isSigHashAll(5) must be(true)
|
||||
|
||||
HashType.isSigHashAll(HashType.sigHashNone.num) must be(false)
|
||||
HashType.isSigHashAll(HashType.sigHashSingle.num) must be(false)
|
||||
|
@ -62,22 +61,22 @@ class HashTypeTest extends BitcoinSUnitTest {
|
|||
|
||||
it must "intercept require statements for each hashType with illegal inputs" in {
|
||||
intercept[IllegalArgumentException] {
|
||||
SIGHASH_ALL(Int32(2))
|
||||
SIGHASH_ALL(2)
|
||||
}
|
||||
}
|
||||
|
||||
it must "find each specific hashType from byte sequence of default value" in {
|
||||
//tests each hashtypes overriding fromBytes function
|
||||
HashType(HashType.sigHashAll.num.bytes) must be(HashType.sigHashAll)
|
||||
HashType(HashType.sigHashNone.num.bytes) must be(HashType.sigHashNone)
|
||||
HashType(HashType.sigHashSingle.num.bytes) must be(HashType.sigHashSingle)
|
||||
HashType(HashType.sigHashAnyoneCanPay.num.bytes) must be(
|
||||
HashType(HashType.sigHashAll.num) must be(HashType.sigHashAll)
|
||||
HashType(HashType.sigHashNone.num) must be(HashType.sigHashNone)
|
||||
HashType(HashType.sigHashSingle.num) must be(HashType.sigHashSingle)
|
||||
HashType(HashType.sigHashAnyoneCanPay.num) must be(
|
||||
HashType.sigHashAnyoneCanPay)
|
||||
HashType(HashType.sigHashAllAnyoneCanPay.num.bytes) must be(
|
||||
HashType(HashType.sigHashAllAnyoneCanPay.num) must be(
|
||||
HashType.sigHashAllAnyoneCanPay)
|
||||
HashType(HashType.sigHashNoneAnyoneCanPay.num.bytes) must be(
|
||||
HashType(HashType.sigHashNoneAnyoneCanPay.num) must be(
|
||||
HashType.sigHashNoneAnyoneCanPay)
|
||||
HashType(HashType.sigHashSingleAnyoneCanPay.num.bytes) must be(
|
||||
HashType(HashType.sigHashSingleAnyoneCanPay.num) must be(
|
||||
HashType.sigHashSingleAnyoneCanPay)
|
||||
}
|
||||
|
||||
|
@ -85,4 +84,22 @@ class HashTypeTest extends BitcoinSUnitTest {
|
|||
HashType(105512910).isInstanceOf[SIGHASH_ANYONECANPAY] must be(true)
|
||||
}
|
||||
|
||||
it must "have serialization symmetry" in {
|
||||
forAll(NumberGenerator.ints.map(ByteVector.fromInt(_))) { i32 =>
|
||||
val hashType = HashType.fromBytes(i32)
|
||||
|
||||
hashType.num == i32.toInt() &&
|
||||
i32.last == hashType.byte &&
|
||||
//this check cannot check the other 3 bytes in
|
||||
//hash type as they are discarded from inclusion
|
||||
//on a bitcoin digital signature. Not sure why satoshi
|
||||
//would have just used a uint8_t to represent a hash type
|
||||
//instead of a uint32_t.
|
||||
HashType.fromByte(hashType.byte).byte == hashType.byte
|
||||
}
|
||||
|
||||
forAll(CryptoGenerators.hashType) { hashType =>
|
||||
assert(HashType.fromByte(hashType.byte) == hashType)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -68,6 +68,9 @@ sealed abstract class DERSignatureUtil {
|
|||
/** This functions implements the strict der encoding rules that were created in BIP66
|
||||
* [[https://github.com/bitcoin/bips/blob/master/bip-0066.mediawiki]]
|
||||
* [[https://github.com/bitcoin/bitcoin/blob/master/src/script/interpreter.cpp#L98]]
|
||||
*
|
||||
* IMPORTANT: This function assumes signature has a SigHash byte and will fail if not!
|
||||
*
|
||||
* @param signature the signature to check if they are strictly der encoded
|
||||
* @return boolean indicating whether the signature was der encoded or not
|
||||
*/
|
||||
|
@ -82,6 +85,9 @@ sealed abstract class DERSignatureUtil {
|
|||
/** This functions implements the strict der encoding rules that were created in BIP66
|
||||
* https://github.com/bitcoin/bips/blob/master/bip-0066.mediawiki
|
||||
* [[https://github.com/bitcoin/bitcoin/blob/master/src/script/interpreter.cpp#L98]]
|
||||
*
|
||||
* IMPORTANT: This function assumes bytes has a SigHash byte and will fail if not!
|
||||
*
|
||||
* @param bytes the bytes to check if they are strictly der encoded
|
||||
* @return boolean indicating whether the bytes were der encoded or not
|
||||
*/
|
||||
|
|
|
@ -77,6 +77,23 @@ sealed abstract class ECDigitalSignature extends NetworkElement {
|
|||
rBytes ++ sBytes
|
||||
}
|
||||
|
||||
def hashTypeOpt: Option[HashType] = {
|
||||
val trailingBytes = bytes.drop(ECDigitalSignature.fromRS(r, s).bytes.length)
|
||||
|
||||
if (trailingBytes.nonEmpty && trailingBytes.length <= 4) {
|
||||
Some(HashType.fromBytes(trailingBytes))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
def appendHashType(hashType: HashType): ECDigitalSignature = {
|
||||
require(this.hashTypeOpt.isEmpty,
|
||||
"Cannot append HashType to signature which already has HashType")
|
||||
|
||||
val bytesWithHashType = bytes.:+(hashType.byte)
|
||||
ECDigitalSignature.fromBytes(bytesWithHashType)
|
||||
}
|
||||
}
|
||||
|
||||
case object EmptyDigitalSignature extends ECDigitalSignature {
|
||||
|
@ -153,6 +170,9 @@ object ECDigitalSignature extends Factory[ECDigitalSignature] {
|
|||
|
||||
def apply(r: BigInt, s: BigInt): ECDigitalSignature = fromRS(r, s)
|
||||
|
||||
def apply(r: BigInt, s: BigInt, hashType: HashType): ECDigitalSignature =
|
||||
fromRS(r, s, hashType)
|
||||
|
||||
/** Takes in the r and s component of a digital signature and gives back a ECDigitalSignature object
|
||||
* The ECDigitalSignature object complies with strict der encoding as per BIP62
|
||||
* note: That the hash type for the signature CANNOT be added to the digital signature
|
||||
|
@ -178,6 +198,20 @@ object ECDigitalSignature extends Factory[ECDigitalSignature] {
|
|||
fromBytes(bytes)
|
||||
}
|
||||
|
||||
/** Takes in the r and s component of a digital signature along with a HashType and gives
|
||||
* back a ECDigitalSignature object
|
||||
* The ECDigitalSignature object complies with strict der encoding as per BIP62
|
||||
* note: That the hash type for the signature CANNOT be added to the digital signature
|
||||
*
|
||||
* @param r the r component of the digital signature
|
||||
* @param s the s component of the digital signature
|
||||
* @param hashType The HashType byte to append
|
||||
* @return
|
||||
*/
|
||||
def fromRS(r: BigInt, s: BigInt, hashType: HashType): ECDigitalSignature = {
|
||||
fromRS(r, s).appendHashType(hashType)
|
||||
}
|
||||
|
||||
/** Reads a 64 byte bytevector and assumes
|
||||
* the first 32 bytes in the R value,
|
||||
* the second 32 is the value
|
||||
|
@ -191,6 +225,14 @@ object ECDigitalSignature extends Factory[ECDigitalSignature] {
|
|||
fromRS(r, s)
|
||||
}
|
||||
|
||||
/** Reads a 64 byte bytevector and assumes
|
||||
* the first 32 bytes in the R value,
|
||||
* the second 32 is the value
|
||||
*/
|
||||
def fromRS(byteVector: ByteVector, hashType: HashType): ECDigitalSignature = {
|
||||
fromRS(byteVector).appendHashType(hashType)
|
||||
}
|
||||
|
||||
/** Reads a 64 byte bytevector and assumes
|
||||
* the first 32 bytes in the R value,
|
||||
* the second 32 is the value
|
||||
|
@ -200,6 +242,14 @@ object ECDigitalSignature extends Factory[ECDigitalSignature] {
|
|||
fromRS(bytes)
|
||||
}
|
||||
|
||||
/** Reads a 64 byte bytevector and assumes
|
||||
* the first 32 bytes in the R value,
|
||||
* the second 32 is the value
|
||||
*/
|
||||
def fromRS(hex: String, hashType: HashType): ECDigitalSignature = {
|
||||
fromRS(hex).appendHashType(hashType)
|
||||
}
|
||||
|
||||
/** Minimally encoded zero signature
|
||||
* This will NOT be 64 bytes in length, it will be much less
|
||||
* due to the DER encoding
|
||||
|
|
|
@ -1,26 +1,29 @@
|
|||
package org.bitcoins.core.script.crypto
|
||||
package org.bitcoins.crypto
|
||||
|
||||
import org.bitcoins.core.number.Int32
|
||||
import org.bitcoins.crypto.{ECDigitalSignature, Factory}
|
||||
import scodec.bits.ByteVector
|
||||
import scodec.bits.{ByteOrdering, ByteVector}
|
||||
|
||||
/** Created by chris on 1/18/16.
|
||||
*/
|
||||
sealed trait HashType {
|
||||
def num: Int32
|
||||
def byte: Byte = num.bytes.last
|
||||
def num: Int
|
||||
def byte: Byte = ByteVector.fromInt(num).last
|
||||
}
|
||||
|
||||
object HashType extends Factory[HashType] {
|
||||
|
||||
private def intFromBytes(bytes: ByteVector): Int = {
|
||||
require(bytes.size <= 4, "We cannot have an Int32 be larger than 4 bytes")
|
||||
bytes.toInt(signed = false, ordering = ByteOrdering.BigEndian)
|
||||
}
|
||||
|
||||
def fromBytes(bytes: ByteVector): HashType = {
|
||||
val num = Int32(bytes)
|
||||
val num = intFromBytes(bytes)
|
||||
fromNumber(num)
|
||||
}
|
||||
|
||||
def fromByte(byte: Byte): HashType = fromBytes(ByteVector.fromByte(byte))
|
||||
|
||||
def fromNumber(num: Int32): HashType = {
|
||||
def fromNumber(num: Int): HashType = {
|
||||
if (isSigHashNone(num)) {
|
||||
if (isSigHashNoneAnyoneCanPay(num)) {
|
||||
SIGHASH_NONE_ANYONECANPAY(num)
|
||||
|
@ -50,28 +53,28 @@ object HashType extends Factory[HashType] {
|
|||
case h: HashType => h.byte
|
||||
}
|
||||
|
||||
def isSigHashAllOne(num: Int32): Boolean = (num & Int32(0x1f)) == Int32(1)
|
||||
def isSigHashAllOne(num: Int): Boolean = (num & 0x1f) == 1
|
||||
|
||||
def isSigHashNone(num: Int32): Boolean = (num & Int32(0x1f)) == Int32(2)
|
||||
def isSigHashNone(num: Int): Boolean = (num & 0x1f) == 2
|
||||
|
||||
def isSigHashSingle(num: Int32): Boolean = (num & Int32(0x1f)) == Int32(3)
|
||||
def isSigHashSingle(num: Int): Boolean = (num & 0x1f) == 3
|
||||
|
||||
def isSigHashAnyoneCanPay(num: Int32): Boolean =
|
||||
(num & Int32(0x80)) == Int32(0x80)
|
||||
def isSigHashAnyoneCanPay(num: Int): Boolean =
|
||||
(num & 0x80) == 0x80
|
||||
|
||||
def isSigHashAllAnyoneCanPay(num: Int32): Boolean = {
|
||||
def isSigHashAllAnyoneCanPay(num: Int): Boolean = {
|
||||
isSigHashAllOne(num) && isSigHashAnyoneCanPay(num)
|
||||
}
|
||||
|
||||
def isSigHashNoneAnyoneCanPay(num: Int32): Boolean = {
|
||||
def isSigHashNoneAnyoneCanPay(num: Int): Boolean = {
|
||||
isSigHashNone(num) && isSigHashAnyoneCanPay(num)
|
||||
}
|
||||
|
||||
def isSigHashSingleAnyoneCanPay(num: Int32): Boolean = {
|
||||
def isSigHashSingleAnyoneCanPay(num: Int): Boolean = {
|
||||
isSigHashSingle(num) && isSigHashAnyoneCanPay(num)
|
||||
}
|
||||
|
||||
def isSigHashAll(num: Int32): Boolean = {
|
||||
def isSigHashAll(num: Int): Boolean = {
|
||||
if (
|
||||
!(isSigHashNone(num) ||
|
||||
isSigHashSingle(num) ||
|
||||
|
@ -83,7 +86,7 @@ object HashType extends Factory[HashType] {
|
|||
else false
|
||||
}
|
||||
|
||||
def isOnlyAnyoneCanPay(num: Int32): Boolean = {
|
||||
def isOnlyAnyoneCanPay(num: Int): Boolean = {
|
||||
!(HashType.isSigHashAllAnyoneCanPay(num) ||
|
||||
HashType.isSigHashNoneAnyoneCanPay(num) ||
|
||||
HashType.isSigHashSingleAnyoneCanPay(num))
|
||||
|
@ -116,9 +119,7 @@ object HashType extends Factory[HashType] {
|
|||
sigHashAllAnyoneCanPayByte
|
||||
)
|
||||
|
||||
def apply(num: Int32): HashType = fromNumber(num)
|
||||
|
||||
def apply(int: Int): HashType = HashType(Int32(int))
|
||||
def apply(num: Int): HashType = fromNumber(num)
|
||||
|
||||
def apply(byte: Byte): HashType = fromByte(byte)
|
||||
|
||||
|
@ -134,10 +135,10 @@ object HashType extends Factory[HashType] {
|
|||
*
|
||||
* Have to be careful using this value, since native scala numbers are signed
|
||||
* We need this because this serializes to 0x00000080 instead of 0xffffff80
|
||||
* If we try to use Int32(sigHashAnyoneCanPayByte) we will get the latter serialization
|
||||
* If we try to use Int(sigHashAnyoneCanPayByte) we will get the latter serialization
|
||||
* because all native scala numbers are signed
|
||||
*/
|
||||
val sigHashAnyoneCanPayNum = Int32(0x80)
|
||||
val sigHashAnyoneCanPayNum = 0x80
|
||||
|
||||
val sigHashAnyoneCanPayByte = 0x80.toByte
|
||||
|
||||
|
@ -147,17 +148,17 @@ object HashType extends Factory[HashType] {
|
|||
/** The default byte for [[SIGHASH_NONE]] */
|
||||
val sigHashNoneByte: Byte = 2.toByte
|
||||
|
||||
val sigHashNone: SIGHASH_NONE = SIGHASH_NONE(Int32(sigHashNoneByte))
|
||||
val sigHashNone: SIGHASH_NONE = SIGHASH_NONE(sigHashNoneByte.toInt)
|
||||
|
||||
/** The default byte for [[SIGHASH_SINGLE]] */
|
||||
val sigHashSingleByte: Byte = 3.toByte
|
||||
|
||||
val sigHashSingle: SIGHASH_SINGLE = SIGHASH_SINGLE(Int32(sigHashSingleByte))
|
||||
val sigHashSingle: SIGHASH_SINGLE = SIGHASH_SINGLE(sigHashSingleByte.toInt)
|
||||
|
||||
val sigHashAllAnyoneCanPayByte =
|
||||
(HashType.sigHashAllByte | HashType.sigHashAnyoneCanPayByte).toByte
|
||||
|
||||
val sigHashAllAnyoneCanPayNum = Int32(sigHashAllByte) | sigHashAnyoneCanPayNum
|
||||
val sigHashAllAnyoneCanPayNum = sigHashAllByte.toInt | sigHashAnyoneCanPayNum
|
||||
|
||||
val sigHashAllAnyoneCanPay = SIGHASH_ALL_ANYONECANPAY(
|
||||
sigHashAllAnyoneCanPayNum)
|
||||
|
@ -166,7 +167,7 @@ object HashType extends Factory[HashType] {
|
|||
(HashType.sigHashNoneByte | HashType.sigHashAnyoneCanPayByte).toByte
|
||||
|
||||
val sigHashNoneAnyoneCanPayNum =
|
||||
Int32(sigHashNoneByte) | sigHashAnyoneCanPayNum
|
||||
sigHashNoneByte.toInt | sigHashAnyoneCanPayNum
|
||||
|
||||
val sigHashNoneAnyoneCanPay = SIGHASH_NONE_ANYONECANPAY(
|
||||
sigHashNoneAnyoneCanPayNum)
|
||||
|
@ -175,7 +176,7 @@ object HashType extends Factory[HashType] {
|
|||
(HashType.sigHashSingleByte | HashType.sigHashAnyoneCanPayByte).toByte
|
||||
|
||||
val sigHashSingleAnyoneCanPayNum =
|
||||
Int32(sigHashSingleByte) | sigHashAnyoneCanPayNum
|
||||
sigHashSingleByte.toInt | sigHashAnyoneCanPayNum
|
||||
|
||||
val sigHashSingleAnyoneCanPay = SIGHASH_SINGLE_ANYONECANPAY(
|
||||
sigHashSingleAnyoneCanPayNum)
|
||||
|
@ -192,7 +193,7 @@ object HashType extends Factory[HashType] {
|
|||
/** defaultValue is the underlying value of the HashType. The last byte of a signature determines the HashType.
|
||||
* https://en.bitcoin.it/wiki/OP_CHECKSIG
|
||||
*/
|
||||
case class SIGHASH_ALL(override val num: Int32) extends HashType {
|
||||
case class SIGHASH_ALL(override val num: Int) extends HashType {
|
||||
require(
|
||||
HashType.isSigHashAll(num),
|
||||
"SIGHASH_ALL acts as a 'catch-all' for undefined hashtypes, and has a default " +
|
||||
|
@ -202,36 +203,35 @@ case class SIGHASH_ALL(override val num: Int32) extends HashType {
|
|||
}
|
||||
|
||||
object SIGHASH_ALL {
|
||||
def apply(byte: Byte): SIGHASH_ALL = SIGHASH_ALL(Int32(byte))
|
||||
def apply(byte: Byte): SIGHASH_ALL = new SIGHASH_ALL(byte.toInt)
|
||||
}
|
||||
|
||||
case class SIGHASH_NONE(override val num: Int32) extends HashType {
|
||||
case class SIGHASH_NONE(override val num: Int) extends HashType {
|
||||
require(HashType.isSigHashNone(num),
|
||||
"The given number is not a SIGHASH_NONE number: " + num)
|
||||
}
|
||||
|
||||
case class SIGHASH_SINGLE(override val num: Int32) extends HashType {
|
||||
case class SIGHASH_SINGLE(override val num: Int) extends HashType {
|
||||
require(HashType.isSigHashSingle(num),
|
||||
"The given number is not a SIGHASH_SINGLE number: " + num)
|
||||
}
|
||||
|
||||
case class SIGHASH_ANYONECANPAY(override val num: Int32) extends HashType {
|
||||
case class SIGHASH_ANYONECANPAY(override val num: Int) extends HashType {
|
||||
require(HashType.isSigHashAnyoneCanPay(num),
|
||||
"The given number was not a SIGHASH_ANYONECANPAY number: " + num)
|
||||
}
|
||||
|
||||
case class SIGHASH_ALL_ANYONECANPAY(override val num: Int32) extends HashType {
|
||||
case class SIGHASH_ALL_ANYONECANPAY(override val num: Int) extends HashType {
|
||||
require(HashType.isSigHashAllAnyoneCanPay(num),
|
||||
"The given number was not a SIGHASH_ALL_ANYONECANPAY number: " + num)
|
||||
}
|
||||
|
||||
case class SIGHASH_NONE_ANYONECANPAY(override val num: Int32) extends HashType {
|
||||
case class SIGHASH_NONE_ANYONECANPAY(override val num: Int) extends HashType {
|
||||
require(HashType.isSigHashNoneAnyoneCanPay(num),
|
||||
"The given number was not a SIGHASH_NONE_ANYONECANPAY number: " + num)
|
||||
}
|
||||
|
||||
case class SIGHASH_SINGLE_ANYONECANPAY(override val num: Int32)
|
||||
extends HashType {
|
||||
case class SIGHASH_SINGLE_ANYONECANPAY(override val num: Int) extends HashType {
|
||||
require(
|
||||
HashType.isSigHashSingleAnyoneCanPay(num),
|
||||
"The given number was not a SIGHASH_SINGLE_ANYONECANPAY number: " + num)
|
|
@ -21,7 +21,6 @@ import org.bitcoins.core.protocol.transaction.{
|
|||
TransactionOutPoint
|
||||
}
|
||||
import org.bitcoins.core.protocol.{BitcoinAddress, BlockTimeStamp}
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.util.Indexed
|
||||
import org.bitcoins.core.wallet.fee.SatoshisPerVirtualByte
|
||||
import org.bitcoins.core.wallet.utxo.{
|
||||
|
@ -29,7 +28,7 @@ import org.bitcoins.core.wallet.utxo.{
|
|||
InputInfo,
|
||||
ScriptSignatureParams
|
||||
}
|
||||
import org.bitcoins.crypto._
|
||||
import org.bitcoins.crypto.{HashType, _}
|
||||
import play.api.libs.json._
|
||||
import scodec.bits.ByteVector
|
||||
|
||||
|
|
|
@ -18,10 +18,9 @@ import org.bitcoins.core.protocol.transaction.{
|
|||
TransactionConstants,
|
||||
TransactionOutPoint
|
||||
}
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.wallet.fee.SatoshisPerVirtualByte
|
||||
import org.bitcoins.core.wallet.utxo._
|
||||
import org.bitcoins.crypto._
|
||||
import org.bitcoins.crypto.{HashType, _}
|
||||
import org.bitcoins.rpc.BitcoindException
|
||||
import org.bitcoins.testkit.rpc.BitcoindRpcTestUtil
|
||||
import org.bitcoins.testkit.util.BitcoindRpcTest
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.bitcoins.core.crypto.ECPrivateKeyUtil
|
|||
import org.bitcoins.core.protocol.script.ScriptPubKey
|
||||
import org.bitcoins.core.protocol.transaction._
|
||||
import org.bitcoins.core.psbt.PSBT
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.crypto.HashType
|
||||
import org.bitcoins.core.wallet.signer.BitcoinSigner
|
||||
import org.bitcoins.core.wallet.utxo._
|
||||
import scodec.bits._
|
||||
|
|
|
@ -30,10 +30,9 @@ import org.bitcoins.core.protocol.transaction.{
|
|||
Transaction => Tx
|
||||
}
|
||||
import org.bitcoins.core.psbt.PSBT
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.util.StartStopAsync
|
||||
import org.bitcoins.core.wallet.fee.{SatoshisPerKW, SatoshisPerVirtualByte}
|
||||
import org.bitcoins.crypto._
|
||||
import org.bitcoins.crypto.{HashType, _}
|
||||
import org.bitcoins.lnd.rpc.LndRpcClient._
|
||||
import org.bitcoins.lnd.rpc.LndUtils._
|
||||
import org.bitcoins.lnd.rpc.config._
|
||||
|
@ -726,7 +725,7 @@ class LndRpcClient(val instance: LndInstance, binaryOpt: Option[File] = None)(
|
|||
output: TransactionOutput): Future[(ScriptSignature, ScriptWitness)] = {
|
||||
val signDescriptor =
|
||||
SignDescriptor(output = Some(output),
|
||||
sighash = UInt32(HashType.sigHashAll.num.toBigInt),
|
||||
sighash = UInt32(HashType.sigHashAll.num),
|
||||
inputIndex = inputIdx)
|
||||
|
||||
computeInputScript(tx, Vector(signDescriptor)).map(_.head)
|
||||
|
|
|
@ -14,12 +14,11 @@ import org.bitcoins.core.protocol.script._
|
|||
import org.bitcoins.core.protocol.tlv.{NumericDLCOutcomeType, _}
|
||||
import org.bitcoins.core.protocol.transaction._
|
||||
import org.bitcoins.core.psbt.InputPSBTRecord.PartialSignature
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.util.sorted.OrderedAnnouncements
|
||||
import org.bitcoins.core.util.{BitcoinScriptUtil, FutureUtil, NumberUtil}
|
||||
import org.bitcoins.core.wallet.fee.SatoshisPerVirtualByte
|
||||
import org.bitcoins.core.wallet.utxo._
|
||||
import org.bitcoins.crypto._
|
||||
import org.bitcoins.crypto.{HashType, _}
|
||||
import org.scalatest.Assertions.{assert, fail, succeed}
|
||||
import org.scalatest.{Assertion, Assertions}
|
||||
import scodec.bits.BitVector
|
||||
|
|
|
@ -4,7 +4,6 @@ import org.bitcoins.core.currency.{CurrencyUnit, CurrencyUnits}
|
|||
import org.bitcoins.core.number.UInt32
|
||||
import org.bitcoins.core.protocol.script._
|
||||
import org.bitcoins.core.protocol.transaction._
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.script.interpreter.ScriptInterpreter
|
||||
import org.bitcoins.core.wallet.utxo.{
|
||||
ConditionalPath,
|
||||
|
@ -12,7 +11,7 @@ import org.bitcoins.core.wallet.utxo.{
|
|||
P2SHNestedSegwitV0InputInfo,
|
||||
ScriptSignatureParams
|
||||
}
|
||||
import org.bitcoins.crypto.Sign
|
||||
import org.bitcoins.crypto.{HashType, Sign}
|
||||
import org.scalacheck.Gen
|
||||
|
||||
sealed abstract class CreditingTxGen {
|
||||
|
|
|
@ -2,7 +2,6 @@ package org.bitcoins.testkitcore.gen
|
|||
|
||||
import org.bitcoins.core.crypto._
|
||||
import org.bitcoins.core.number.{UInt64, UInt8}
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.{core, crypto}
|
||||
import org.bitcoins.crypto.{
|
||||
AesEncryptedData,
|
||||
|
@ -17,6 +16,7 @@ import org.bitcoins.crypto.{
|
|||
ECPrivateKey,
|
||||
ECPublicKey,
|
||||
FieldElement,
|
||||
HashType,
|
||||
SchnorrDigitalSignature,
|
||||
SchnorrNonce,
|
||||
SchnorrPublicKey,
|
||||
|
@ -274,7 +274,7 @@ sealed abstract class CryptoGenerators {
|
|||
hash = CryptoUtil.sha256Hash160(pubKey.bytes)
|
||||
} yield hash
|
||||
|
||||
/** Generates a random [[org.bitcoins.core.script.crypto.HashType HashType]] */
|
||||
/** Generates a random [[HashType HashType]] */
|
||||
def hashType: Gen[HashType] =
|
||||
Gen.oneOf(
|
||||
HashType.sigHashAll,
|
||||
|
|
|
@ -10,7 +10,6 @@ import org.bitcoins.core.protocol.script._
|
|||
import org.bitcoins.core.protocol.transaction._
|
||||
import org.bitcoins.core.script.constant.ScriptNumber
|
||||
import org.bitcoins.core.script.control.{ConditionalOperation, OP_IF, OP_NOTIF}
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.core.script.interpreter.ScriptInterpreter
|
||||
import org.bitcoins.core.wallet.signer.{
|
||||
MultiSigSigner,
|
||||
|
@ -23,7 +22,8 @@ import org.bitcoins.crypto.{
|
|||
ECDigitalSignature,
|
||||
ECPrivateKey,
|
||||
ECPublicKey,
|
||||
EmptyDigitalSignature
|
||||
EmptyDigitalSignature,
|
||||
HashType
|
||||
}
|
||||
import org.scalacheck.Gen
|
||||
import scodec.bits.ByteVector
|
||||
|
|
|
@ -6,8 +6,7 @@ import org.bitcoins.core.number.UInt32
|
|||
import org.bitcoins.core.policy.Policy
|
||||
import org.bitcoins.core.protocol.script._
|
||||
import org.bitcoins.core.protocol.transaction._
|
||||
import org.bitcoins.core.script.crypto.HashType
|
||||
import org.bitcoins.crypto.ECPrivateKey
|
||||
import org.bitcoins.crypto.{ECPrivateKey, HashType}
|
||||
import org.scalacheck.Gen
|
||||
|
||||
/** Created by chris on 11/28/16.
|
||||
|
|
Loading…
Add table
Reference in a new issue