Table of Contents

Class OutputDescriptor

Namespace
NBitcoin.Scripting
Assembly
NArk.Abstractions.dll
public abstract class OutputDescriptor : IEquatable<OutputDescriptor>
Inheritance
OutputDescriptor
Implements
Derived
Inherited Members
Extension Methods

Properties

Network

public Network Network { get; }

Property Value

Network

Methods

AddChecksum(string)

public static string AddChecksum(string desc)

Parameters

desc string

Returns

string

Equals(OutputDescriptor?)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(OutputDescriptor? other)

Parameters

other OutputDescriptor

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Determines whether the specified object is equal to the current object.

public override sealed bool Equals(object? obj)

Parameters

obj object

The object to compare with the current object.

Returns

bool

true if the specified object is equal to the current object; otherwise, false.

GetCheckSum(string)

public static string GetCheckSum(string desc)

Parameters

desc string

Returns

string

GetHashCode()

Serves as the default hash function.

public override int GetHashCode()

Returns

int

A hash code for the current object.

GetScriptPubKeyType()

Infer the address type for that descriptor. When it is impossible, just return null. e.g. In case of descriptors those are agnostic to the actual scriptpubkey format (e.g. "multi"), it just returns null.

public ScriptPubKeyType? GetScriptPubKeyType()

Returns

ScriptPubKeyType?

IsRange()

public bool IsRange()

Returns

bool

IsSolvable()

Output descriptor has solvability property. Which means whether we are able to know how to create ScirptSig (or witness) for the descriptor. It is always false for addr() and raw(), and otherwise true. But this may change in the future, see: https://github.com/bitcoin/bitcoin/issues/24114 for the discussion.

public bool IsSolvable()

Returns

bool

IsTopLevelOnly()

public bool IsTopLevelOnly()

Returns

bool

NewAddr(IDestination, Network)

public static OutputDescriptor NewAddr(IDestination dest, Network network)

Parameters

dest IDestination
network Network

Returns

OutputDescriptor

NewCombo(PubKeyProvider, Network)

public static OutputDescriptor NewCombo(PubKeyProvider pk, Network network)

Parameters

pk PubKeyProvider
network Network

Returns

OutputDescriptor

NewMulti(uint, IEnumerable<PubKeyProvider>, bool, Network, bool)

public static OutputDescriptor NewMulti(uint m, IEnumerable<PubKeyProvider> pks, bool isSorted, Network network, bool isTapScript = false)

Parameters

m uint
pks IEnumerable<PubKeyProvider>
isSorted bool
network Network
isTapScript bool

Returns

OutputDescriptor

NewPK(PubKeyProvider, Network)

public static OutputDescriptor NewPK(PubKeyProvider pk, Network network)

Parameters

pk PubKeyProvider
network Network

Returns

OutputDescriptor

NewPKH(PubKeyProvider, Network)

public static OutputDescriptor NewPKH(PubKeyProvider pk, Network network)

Parameters

pk PubKeyProvider
network Network

Returns

OutputDescriptor

NewRaw(Script, Network)

public static OutputDescriptor NewRaw(Script sc, Network network)

Parameters

sc Script
network Network

Returns

OutputDescriptor

NewRawTr(PubKeyProvider, Network)

public static OutputDescriptor NewRawTr(PubKeyProvider outputPubkeyProvider, Network network)

Parameters

outputPubkeyProvider PubKeyProvider
network Network

Returns

OutputDescriptor

NewSH(OutputDescriptor, Network)

public static OutputDescriptor NewSH(OutputDescriptor inner, Network network)

Parameters

inner OutputDescriptor
network Network

Returns

OutputDescriptor

NewTr(PubKeyProvider, Network, TapTree?)

public static OutputDescriptor NewTr(PubKeyProvider innerPubKey, Network network, OutputDescriptor.TapTree? tapTree = null)

Parameters

innerPubKey PubKeyProvider
network Network
tapTree OutputDescriptor.TapTree

Returns

OutputDescriptor

NewWPKH(PubKeyProvider, Network)

public static OutputDescriptor NewWPKH(PubKeyProvider pk, Network network)

Parameters

pk PubKeyProvider
network Network

Returns

OutputDescriptor

NewWSH(OutputDescriptor, Network)

public static OutputDescriptor NewWSH(OutputDescriptor inner, Network network)

Parameters

inner OutputDescriptor
network Network

Returns

OutputDescriptor

Parse(string, Network, bool, ISigningRepository?)

Parse descriptor from string representation. OutputDescriptor class does not hold private key data in memory, so if you want to parse private key, you must pass the reference to the DB with repo argument. Parser will inject private keys they've found into the DB. this can later be used with other methods such as TryGetPrivateString

public static OutputDescriptor Parse(string desc, Network network, bool requireCheckSum = false, ISigningRepository? repo = null)

Parameters

desc string

descriptor to parse

network Network

Network for the descriptor.

requireCheckSum bool

if true, Do not parse descriptors without checksum. default: false

repo ISigningRepository

repository to inject private key information.

Returns

OutputDescriptor

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

TryExpand(uint, ISigningRepository, out List<Script>, IDictionary<uint, ExtPubKey>?)

Expand descriptor into actual scriptPubKeys.

public bool TryExpand(uint pos, ISigningRepository repo, out List<Script> outputScripts, IDictionary<uint, ExtPubKey>? cache = null)

Parameters

pos uint

position index to expand

repo ISigningRepository

repository to which to put resulted information.

outputScripts List<Script>

resulted scriptPubKey

cache IDictionary<uint, ExtPubKey>

Returns

bool

TryExpand(uint, Func<KeyId, Key?>, ISigningRepository, out List<Script>, bool, IDictionary<uint, ExtPubKey>?)

Expand descriptor into actual scriptPubKeys. TODO: cache

public bool TryExpand(uint pos, Func<KeyId, Key?> privateKeyProvider, ISigningRepository repo, out List<Script> outputScripts, bool isTaproot = false, IDictionary<uint, ExtPubKey>? cache = null)

Parameters

pos uint

position index to expand

privateKeyProvider Func<KeyId, Key>

provider to inject private keys in case of hardened derivation

repo ISigningRepository

repository to which to put resulted information.

outputScripts List<Script>

resulted scriptPubKey

isTaproot bool
cache IDictionary<uint, ExtPubKey>

Returns

bool

TryParse(string, Network, out OutputDescriptor?, bool, ISigningRepository?)

Parse descriptor from string representation. OutputDescriptor class does not hold private key data in memory, so if you want to parse private key, you must pass the reference to the DB with repo argument. Parser will inject private keys they've found into the DB. this can later be used with other methods such as TryGetPrivateString

public static bool TryParse(string desc, Network network, out OutputDescriptor? result, bool requireCheckSum = false, ISigningRepository? repo = null)

Parameters

desc string

descriptor to parse

network Network

Network for the descriptor.

result OutputDescriptor
requireCheckSum bool

If true, Do not parse descriptors without checksum. Default: false

repo ISigningRepository

repository to inject private key information.

Returns

bool