Table of Contents

Class PsbtHelpers

Namespace
NArk.Abstractions.Helpers
Assembly
NArk.Abstractions.dll
public static class PsbtHelpers
Inheritance
PsbtHelpers
Inherited Members

Methods

GetArkFieldConditionWitness(PSBTInput)

Reads the Arkade condition-witness field set by SetArkFieldConditionWitness(PSBTInput, WitScript), or null when absent.

public static WitScript? GetArkFieldConditionWitness(this PSBTInput input)

Parameters

input PSBTInput

Returns

WitScript

GetArkFieldPrevArkTx(PSBTInput, Network)

Reads the prevarktx ark field.

public static Transaction? GetArkFieldPrevArkTx(this PSBTInput psbtInput, Network network)

Parameters

psbtInput PSBTInput

The PSBT input to read the field from.

network Network

The network to deserialize the transaction against.

Returns

Transaction

The previous Arkade transaction, or null if the field is absent or malformed.

GetArkFieldPrevoutTx(PSBTInput, Network)

Reads the prevouttx ark field.

public static Transaction? GetArkFieldPrevoutTx(this PSBTInput psbtInput, Network network)

Parameters

psbtInput PSBTInput

The PSBT input to read the field from.

network Network

The network to deserialize the transaction against.

Returns

Transaction

The previous output transaction, or null if the field is absent or malformed.

GetArkFieldsCosigners(PSBTInput)

Gets all cosigner public keys from a PSBT input

public static IReadOnlyCollection<CosignerPublicKeyData> GetArkFieldsCosigners(this PSBTInput psbtInput)

Parameters

psbtInput PSBTInput

Returns

IReadOnlyCollection<CosignerPublicKeyData>

GetTaprootScriptSpendSignatures(PSBTInput)

Reads all taproot script-spend signatures (PSBT_IN_TAP_SCRIPT_SIG, 0x14) set by SetTaprootScriptSpendSignature(PSBTInput, ECXOnlyPubKey, uint256, SecpSchnorrSignature, TaprootSigHash), keyed by lowercase hex-encoded x-only public key.

public static IReadOnlyDictionary<string, byte[]> GetTaprootScriptSpendSignatures(this PSBTInput input)

Parameters

input PSBTInput

Returns

IReadOnlyDictionary<string, byte[]>

SetArkFieldConditionWitness(PSBTInput, WitScript)

public static void SetArkFieldConditionWitness(this PSBTInput psbtInput, WitScript script)

Parameters

psbtInput PSBTInput
script WitScript

SetArkFieldPrevArkTx(PSBTInput, Transaction)

Sets the prevarktx ark field — the raw previous Arkade transaction an introspection opcode reads for this input. Stored under [0xde]||"prevarktx" (emulator ArkFieldPrevArkTx).

public static void SetArkFieldPrevArkTx(this PSBTInput psbtInput, Transaction prevArkTx)

Parameters

psbtInput PSBTInput

The PSBT input to write the field to.

prevArkTx Transaction

The previous Arkade transaction to store.

SetArkFieldPrevoutTx(PSBTInput, Transaction)

Sets the prevouttx ark field — the raw previous output transaction an introspection opcode reads for this input (e.g. on the emulator's /v1/onchain-tx path). Stored under [0xde]||"prevouttx" (emulator ArkFieldPrevoutTx).

public static void SetArkFieldPrevoutTx(this PSBTInput psbtInput, Transaction prevoutTx)

Parameters

psbtInput PSBTInput

The PSBT input to write the field to.

prevoutTx Transaction

The previous output transaction to store.

SetArkFieldTapTree(PSBTInput, TapScript[])

public static void SetArkFieldTapTree(this PSBTInput psbtInput, TapScript[] leaves)

Parameters

psbtInput PSBTInput
leaves TapScript[]

SetTaprootLeafScript(PSBTInput, TaprootSpendInfo, TapScript)

public static void SetTaprootLeafScript(this PSBTInput input, TaprootSpendInfo spendInfo, TapScript leafScript)

Parameters

input PSBTInput
spendInfo TaprootSpendInfo
leafScript TapScript

SetTaprootScriptSpendSignature(PSBTInput, ECXOnlyPubKey, uint256, SecpSchnorrSignature, TaprootSigHash)

public static void SetTaprootScriptSpendSignature(this PSBTInput input, ECXOnlyPubKey key, uint256 leafHash, SecpSchnorrSignature signature, TaprootSigHash sigHash = TaprootSigHash.Default)

Parameters

input PSBTInput
key ECXOnlyPubKey
leafHash uint256
signature SecpSchnorrSignature
sigHash TaprootSigHash

SignAndFillPsbt(IArkadeWalletSigner, ArkCoin, PSBT, TaprootReadyPrecomputedTransactionData, TaprootSigHash, CancellationToken)

public static Task SignAndFillPsbt(IArkadeWalletSigner signer, ArkCoin coin, PSBT psbt, TaprootReadyPrecomputedTransactionData precomputedTransactionData, TaprootSigHash sigHash = TaprootSigHash.Default, CancellationToken cancellationToken = default)

Parameters

signer IArkadeWalletSigner
coin ArkCoin
psbt PSBT
precomputedTransactionData TaprootReadyPrecomputedTransactionData
sigHash TaprootSigHash
cancellationToken CancellationToken

Returns

Task

TryGetTaprootLeafScript(PSBTInput, out byte[], out Script)

Reads the taproot leaf script (PSBT_IN_TAP_LEAF_SCRIPT, 0x15) set by SetTaprootLeafScript(PSBTInput, TaprootSpendInfo, TapScript) back out of a PSBT input.

public static bool TryGetTaprootLeafScript(this PSBTInput input, out byte[] controlBlock, out Script leafScript)

Parameters

input PSBTInput
controlBlock byte[]
leafScript Script

Returns

bool

true when the input carries a leaf script.

TryGetTaprootScriptSpendSignature(PSBTInput, ECXOnlyPubKey, uint256, out byte[])

Reads back the taproot script-spend signature (PSBT_IN_TAP_SCRIPT_SIG, 0x14) for one specific key + leaf pair — the exact counterpart of SetTaprootScriptSpendSignature(PSBTInput, ECXOnlyPubKey, uint256, SecpSchnorrSignature, TaprootSigHash). Unlike GetTaprootScriptSpendSignatures(PSBTInput) this also matches the leaf hash, so a signature made for a different tapscript leaf is not returned.

public static bool TryGetTaprootScriptSpendSignature(this PSBTInput input, ECXOnlyPubKey key, uint256 leafHash, out byte[] signature)

Parameters

input PSBTInput

The PSBT input to read from.

key ECXOnlyPubKey

The x-only public key the signature is expected from. The field is keyed by whatever Sign(OutputDescriptor, uint256, CancellationToken) returned when the signature was written, which is required to be the key named by the signing descriptor — so callers looking up a wallet's own signature pass coin.SignerDescriptor.ToXOnlyPubKey(). A signer that returned a derived or rotated key instead would not be found here.

leafHash uint256

The tapscript leaf hash the signature is expected to cover.

signature byte[]

The raw signature bytes; empty when none is present.

Returns

bool

true when the input carries a signature for that key + leaf.