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
inputPSBTInput
Returns
- WitScript
GetArkFieldPrevArkTx(PSBTInput, Network)
Reads the prevarktx ark field.
public static Transaction? GetArkFieldPrevArkTx(this PSBTInput psbtInput, Network network)
Parameters
psbtInputPSBTInputThe PSBT input to read the field from.
networkNetworkThe network to deserialize the transaction against.
Returns
- Transaction
The previous Arkade transaction, or
nullif the field is absent or malformed.
GetArkFieldPrevoutTx(PSBTInput, Network)
Reads the prevouttx ark field.
public static Transaction? GetArkFieldPrevoutTx(this PSBTInput psbtInput, Network network)
Parameters
psbtInputPSBTInputThe PSBT input to read the field from.
networkNetworkThe network to deserialize the transaction against.
Returns
- Transaction
The previous output transaction, or
nullif 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
psbtInputPSBTInput
Returns
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
inputPSBTInput
Returns
SetArkFieldConditionWitness(PSBTInput, WitScript)
public static void SetArkFieldConditionWitness(this PSBTInput psbtInput, WitScript script)
Parameters
psbtInputPSBTInputscriptWitScript
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
psbtInputPSBTInputThe PSBT input to write the field to.
prevArkTxTransactionThe 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
psbtInputPSBTInputThe PSBT input to write the field to.
prevoutTxTransactionThe previous output transaction to store.
SetArkFieldTapTree(PSBTInput, TapScript[])
public static void SetArkFieldTapTree(this PSBTInput psbtInput, TapScript[] leaves)
Parameters
psbtInputPSBTInputleavesTapScript[]
SetTaprootLeafScript(PSBTInput, TaprootSpendInfo, TapScript)
public static void SetTaprootLeafScript(this PSBTInput input, TaprootSpendInfo spendInfo, TapScript leafScript)
Parameters
inputPSBTInputspendInfoTaprootSpendInfoleafScriptTapScript
SetTaprootScriptSpendSignature(PSBTInput, ECXOnlyPubKey, uint256, SecpSchnorrSignature, TaprootSigHash)
public static void SetTaprootScriptSpendSignature(this PSBTInput input, ECXOnlyPubKey key, uint256 leafHash, SecpSchnorrSignature signature, TaprootSigHash sigHash = TaprootSigHash.Default)
Parameters
inputPSBTInputkeyECXOnlyPubKeyleafHashuint256signatureSecpSchnorrSignaturesigHashTaprootSigHash
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
signerIArkadeWalletSignercoinArkCoinpsbtPSBTprecomputedTransactionDataTaprootReadyPrecomputedTransactionDatasigHashTaprootSigHashcancellationTokenCancellationToken
Returns
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
inputPSBTInputcontrolBlockbyte[]leafScriptScript
Returns
- bool
truewhen 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
inputPSBTInputThe PSBT input to read from.
keyECXOnlyPubKeyThe 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.leafHashuint256The tapscript leaf hash the signature is expected to cover.
signaturebyte[]The raw signature bytes; empty when none is present.
Returns
- bool
truewhen the input carries a signature for that key + leaf.