From 5d02e70eda97f97ecc83ce98fe628b7668260204 Mon Sep 17 00:00:00 2001 From: Chris Stewart Date: Fri, 9 Mar 2018 10:09:18 -0600 Subject: [PATCH] Adding TxBuilderError.{WrongWitness, WrongRedeemScript, WrongPublicKey} for the case where we have a pre-image that does not hash to the right commitment in the spk --- .../scala/org/bitcoins/core/policy/Policy.scala | 4 +++- .../core/wallet/builder/TxBuilderError.scala | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/main/scala/org/bitcoins/core/policy/Policy.scala b/src/main/scala/org/bitcoins/core/policy/Policy.scala index 11413564c7..4a38ab132e 100644 --- a/src/main/scala/org/bitcoins/core/policy/Policy.scala +++ b/src/main/scala/org/bitcoins/core/policy/Policy.scala @@ -9,7 +9,7 @@ import org.bitcoins.core.script.flag._ * Mimics the policy files found in bitcoin core * https://github.com/bitcoin/bitcoin/blob/master/src/policy/policy.h */ -trait Policy { +sealed abstract class Policy { /** * Mandatory script verification flags that all new blocks must comply with for @@ -49,6 +49,8 @@ trait Policy { /** Max fee for a transaction is set to 10 mBTC right now */ def maxFee: CurrencyUnit = Satoshis(Int64(10)) * CurrencyUnits.oneMBTC + + def isRBFEnabled: Boolean = true } object Policy extends Policy diff --git a/src/main/scala/org/bitcoins/core/wallet/builder/TxBuilderError.scala b/src/main/scala/org/bitcoins/core/wallet/builder/TxBuilderError.scala index 1026bf07ef..6f986a9ae2 100644 --- a/src/main/scala/org/bitcoins/core/wallet/builder/TxBuilderError.scala +++ b/src/main/scala/org/bitcoins/core/wallet/builder/TxBuilderError.scala @@ -24,6 +24,21 @@ object TxBuilderError { */ case object WrongSigner extends TxBuilderError + /** Means that the [[org.bitcoins.core.protocol.script.ScriptWitnessV0]] you passed as an argument does + * not hash to the commitment inside of [[org.bitcoins.core.protocol.script.P2WSHWitnessSPKV0]] + */ + case object WrongWitness extends TxBuilderError + + /** Means that the redeem script you passed as an argument does not hash to the commitment + * inside of the [[org.bitcoins.core.protocol.script.P2SHScriptPubKey]] + */ + case object WrongRedeemScript extends TxBuilderError + + /** Means that you passed the wrong public key for a [[org.bitcoins.core.protocol.script.P2PKHScriptPubKey]] or a + * [[org.bitcoins.core.protocol.script.P2WPKHWitnessSPKV0]] that you are trying to spend + */ + case object WrongPublicKey extends TxBuilderError + /** Can occurr when we are trying to sign a [[org.bitcoins.core.protocol.script.P2SHScriptPubKey]] but * we do not have a redeem script for that p2sh spk. */