Allow NonWitness and Witness UTXOs in same InputPSBTMap (#1761)

This commit is contained in:
Ben Carman 2020-08-06 17:58:43 -05:00 committed by GitHub
parent d9024b1752
commit e4e81d8546
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 7 deletions

View file

@ -119,14 +119,16 @@ class PSBTUnitTest extends BitcoinSAsyncTest {
assert(psbtWithSigHash.bytes == nextExpected.bytes)
}
it must "fail to create a InputPSBTMap with both a NonWitness and Witness UTXO" in {
it must "create a InputPSBTMap with both a NonWitness and Witness UTXO" in {
val nonWitnessOrUnknownUTXO = NonWitnessOrUnknownUTXO(Transaction(
"02000000019dfc6628c26c5899fe1bd3dc338665bfd55d7ada10f6220973df2d386dec12760100000000ffffffff01f03dcd1d000000001600147b3a00bfdc14d27795c2b74901d09da6ef13357900000000"))
val witnessUTXO =
WitnessUTXO(TransactionOutput(Satoshis.one, EmptyScriptPubKey))
assertThrows[IllegalArgumentException](
InputPSBTMap(Vector(nonWitnessOrUnknownUTXO, witnessUTXO)))
val inputMap = InputPSBTMap(Vector(nonWitnessOrUnknownUTXO, witnessUTXO))
assert(
inputMap.bytes == hex"01005202000000019dfc6628c26c5899fe1bd3dc338665bfd55d7ada10f6220973df2d386dec12760100000000ffffffff01f03dcd1d000000001600147b3a00bfdc14d27795c2b74901d09da6ef1335790000000001010901000000000000000000")
}
it must "correctly filter a GlobalPSBTMap" in {

View file

@ -149,10 +149,6 @@ object GlobalPSBTMap extends PSBTMapFactory[GlobalPSBTRecord, GlobalPSBTMap] {
case class InputPSBTMap(elements: Vector[InputPSBTRecord])
extends SeqWrapper[InputPSBTRecord]
with PSBTMap[InputPSBTRecord] {
require(
this.witnessUTXOOpt.isEmpty || this.nonWitnessOrUnknownUTXOOpt.isEmpty,
"InputPSBTMap cannot have both a NonWitnessOrUnknownUTXO and a WitnessUTXO"
)
override protected val wrapped: Vector[InputPSBTRecord] = elements
import org.bitcoins.core.psbt.InputPSBTRecord._