Psbt

data class Psbt(    val global: Global,     val inputs: List<Input>,     val outputs: List<Output>)

A partially signed bitcoin transaction: see https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki.

Parameters

global

global psbt data containing the transaction to be signed.

inputs

signing data for each input of the transaction to be signed (order matches the unsigned tx).

outputs

signing data for each output of the transaction to be signed (order matches the unsigned tx).

Constructors

Link copied to clipboard
fun Psbt(tx: Transaction)

Implements the PSBT creator role; initializes a PSBT for the given unsigned transaction.

Link copied to clipboard
fun Psbt(    global: Global,     inputs: List<Input>,     outputs: List<Output>)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun computeFees(): Satoshi?

Compute the fees paid by the PSBT. Note that if some inputs have not been updated yet, the fee cannot be computed.

Link copied to clipboard
fun extract(): Either<UpdateFailure, Transaction>

Implements the PSBT extractor role: extracts a valid transaction from the psbt data.

Link copied to clipboard
fun finalizeNonWitnessInput(outPoint: OutPoint, scriptSig: List<ScriptElt>): Either<UpdateFailure, Psbt>
fun finalizeNonWitnessInput(inputIndex: Int, scriptSig: List<ScriptElt>): Either<UpdateFailure, Psbt>

Implements the PSBT finalizer role: finalizes a given non-segwit input. This will clear all fields from the input except the utxo, scriptSig and unknown entries.

Link copied to clipboard
fun finalizeWitnessInput(outPoint: OutPoint, scriptWitness: ScriptWitness): Either<UpdateFailure, Psbt>
fun finalizeWitnessInput(inputIndex: Int, scriptWitness: ScriptWitness): Either<UpdateFailure, Psbt>

Implements the PSBT finalizer role: finalizes a given segwit input. This will clear all fields from the input except the utxo, scriptSig, scriptWitness and unknown entries.

Link copied to clipboard
fun getInput(outPoint: OutPoint): Input?
fun getInput(inputIndex: Int): Input?
Link copied to clipboard
fun sign(priv: PrivateKey, outPoint: OutPoint): Either<UpdateFailure, SignPsbtResult>
fun sign(priv: PrivateKey, inputIndex: Int): Either<UpdateFailure, SignPsbtResult>

Implements the PSBT signer role: sign a given input. The caller needs to carefully verify that it wants to spend that input, and that the unsigned transaction matches what it expects.

Link copied to clipboard
fun updateNonWitnessInput(    inputTx: Transaction,     outputIndex: Int,     redeemScript: List<ScriptElt>? = null,     sighashType: Int? = null,     derivationPaths: Map<PublicKey, KeyPathWithMaster> = mapOf()): Either<UpdateFailure, Psbt>

Implements the PSBT updater role; adds information about a given non-segwit utxo.

Link copied to clipboard
fun updateNonWitnessOutput(    outputIndex: Int,     redeemScript: List<ScriptElt>? = null,     derivationPaths: Map<PublicKey, KeyPathWithMaster> = mapOf()): Either<UpdateFailure, Psbt>

Add details for a non-segwit output.

Link copied to clipboard
fun updatePreimageChallenges(    outPoint: OutPoint,     ripemd160: Set<ByteVector>,     sha256: Set<ByteVector>,     hash160: Set<ByteVector>,     hash256: Set<ByteVector>): Either<UpdateFailure, Psbt>
fun updatePreimageChallenges(    inputIndex: Int,     ripemd160: Set<ByteVector>,     sha256: Set<ByteVector>,     hash160: Set<ByteVector>,     hash256: Set<ByteVector>): Either<UpdateFailure, Psbt>
Link copied to clipboard
fun updateWitnessInput(    outPoint: OutPoint,     txOut: TxOut,     redeemScript: List<ScriptElt>? = null,     witnessScript: List<ScriptElt>? = null,     sighashType: Int? = null,     derivationPaths: Map<PublicKey, KeyPathWithMaster> = mapOf()): Either<UpdateFailure, Psbt>

Implements the PSBT updater role; adds information about a given segwit utxo. When you have access to the complete input transaction, you should prefer [updateWitnessInputTx].

Link copied to clipboard
fun updateWitnessInputTx(    inputTx: Transaction,     outputIndex: Int,     redeemScript: List<ScriptElt>? = null,     witnessScript: List<ScriptElt>? = null,     sighashType: Int? = null,     derivationPaths: Map<PublicKey, KeyPathWithMaster> = mapOf()): Either<UpdateFailure, Psbt>

Implements the PSBT updater role; adds information about a given segwit utxo. Note that we always fill the nonWitnessUtxo (see https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#cite_note-7).

Link copied to clipboard
fun updateWitnessOutput(    outputIndex: Int,     witnessScript: List<ScriptElt>? = null,     redeemScript: List<ScriptElt>? = null,     derivationPaths: Map<PublicKey, KeyPathWithMaster> = mapOf()): Either<UpdateFailure, Psbt>

Add details for a segwit output.

Properties

Link copied to clipboard
val global: Global
Link copied to clipboard
val inputs: List<Input>
Link copied to clipboard
val outputs: List<Output>