Table of Contents

Class ArkBip21

Namespace
NArk.Abstractions.Payments
Assembly
NArk.Abstractions.dll

Builds and parses BIP21 URIs with Ark protocol extensions.

Building: ArkBip21.Create().WithArkAddress("tark1...").WithAmount(0.001m).Build()

Parsing: ArkBip21.Parse("bitcoin:addr?ark=tark1...") — also handles raw Ark addresses, Lightning invoices, and Bitcoin addresses.

public class ArkBip21
Inheritance
ArkBip21
Inherited Members

Methods

Build()

Builds the BIP21 URI string. Format: bitcoin:[onchain_address]?amount=X&ark=Y&lightning=Z

At least one destination must be set: an ark address, an on-chain address, or a lightning value (BOLT11 / LNURL — itself a destination). assetId alone is not a destination — it constrains what to send, not where — so it does not satisfy the precondition; pair it with an ark address.

The on-chain address slot may be empty when only ark or only lightning is set — e.g. a Lightning-only URI bitcoin:?lightning=lnurl1…. The bitcoin: scheme stays consistent across per-path toggle states; any LN-capable wallet (or BIP21 parser that understands the lightning= param) routes off the query string. Strict parsers that require a path-position address should set one via WithOnchainAddress(string?) or WithArkAddress(string); the SDK no longer forces it.

public string Build()

Returns

string

Exceptions

InvalidOperationException

No destination was set. Call WithArkAddress(string), WithOnchainAddress(string?), or WithLightning(string?). An asset alone is not a destination.

Create()

Creates a new builder instance.

public static ArkBip21 Create()

Returns

ArkBip21

Parse(string?)

Parses any payment destination: BIP21 URI, Ark address, Lightning invoice, or Bitcoin address.

public static Bip21PaymentInfo? Parse(string? input)

Parameters

input string

Returns

Bip21PaymentInfo

Parsed payment info, or null if the input is unrecognized.

ParseStrict(string)

Parses a BIP21 URI. Throws FormatException for invalid URIs. Use Parse(string?) for lenient parsing that returns null on failure.

public static Bip21PaymentInfo ParseStrict(string bip21Uri)

Parameters

bip21Uri string

Returns

Bip21PaymentInfo

Exceptions

FormatException

The URI is not a valid BIP21 URI.

WithAmount(decimal?)

Sets the payment amount in BTC.

public ArkBip21 WithAmount(decimal? amount)

Parameters

amount decimal?

Returns

ArkBip21

WithArkAddress(string)

Sets the Ark protocol address (placed in ark query parameter).

public ArkBip21 WithArkAddress(string arkAddress)

Parameters

arkAddress string

Returns

ArkBip21

WithAssetId(string?)

Sets the asset ID (placed in asset query parameter, forces Ark-only).

public ArkBip21 WithAssetId(string? assetId)

Parameters

assetId string

Returns

ArkBip21

WithCustomParameter(string, string)

Adds a custom query parameter.

public ArkBip21 WithCustomParameter(string key, string value)

Parameters

key string
value string

Returns

ArkBip21

WithLightning(string?)

Sets the Lightning invoice or LNURL (placed in lightning query parameter).

public ArkBip21 WithLightning(string? lightning)

Parameters

lightning string

Returns

ArkBip21

WithOnchainAddress(string?)

Sets the Bitcoin on-chain address (optional, placed in URI path).

public ArkBip21 WithOnchainAddress(string? address)

Parameters

address string

Returns

ArkBip21