Replace null values with EmptyTransaction and PSBT.empty

This commit is contained in:
Ben Carman 2020-01-28 10:37:16 -06:00
parent d2ed88067b
commit 964fcbc064
2 changed files with 7 additions and 4 deletions

View File

@ -8,7 +8,7 @@ import org.bitcoins.cli.CliReaders._
import org.bitcoins.core.config.NetworkParameters
import org.bitcoins.core.currency._
import org.bitcoins.core.protocol._
import org.bitcoins.core.protocol.transaction.Transaction
import org.bitcoins.core.protocol.transaction.{EmptyTransaction, Transaction}
import org.bitcoins.core.psbt.PSBT
import org.bitcoins.picklers._
import scopt.OParser
@ -196,7 +196,7 @@ object Cli extends App {
),
cmd("finalizepsbt")
.hidden()
.action((_, conf) => conf.copy(command = FinalizePSBT(null)))
.action((_, conf) => conf.copy(command = FinalizePSBT(PSBT.empty)))
.text("Finalizes the given PSBT if it can")
.children(
opt[PSBT]("psbt")
@ -210,7 +210,7 @@ object Cli extends App {
),
cmd("extractfrompsbt")
.hidden()
.action((_, conf) => conf.copy(command = ExtractFromPSBT(null)))
.action((_, conf) => conf.copy(command = ExtractFromPSBT(PSBT.empty)))
.text("Extracts a transaction from the given PSBT if it can")
.children(
opt[PSBT]("psbt")
@ -224,7 +224,8 @@ object Cli extends App {
),
cmd("converttopsbt")
.hidden()
.action((_, conf) => conf.copy(command = ConvertToPSBT(null)))
.action((_, conf) =>
conf.copy(command = ConvertToPSBT(EmptyTransaction)))
.text("Creates an empty psbt from the given transaction")
.children(
opt[Transaction]("unsignedTx")

View File

@ -614,6 +614,8 @@ object PSBT extends Factory[PSBT] {
// The magic bytes and separator defined by https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#specification
final val magicBytes = hex"70736274ff"
final val empty = fromUnsignedTx(EmptyTransaction)
def fromString(str: String): PSBT = {
ByteVector.fromHex(str) match {
case Some(hex) =>