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

This commit is contained in:
Chris Stewart 2018-03-09 10:09:18 -06:00
parent 9a36ef92f2
commit 5d02e70eda
2 changed files with 18 additions and 1 deletions

View file

@ -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

View file

@ -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.
*/