react-native-nitro-ark
Version:
Pure C++ Nitro Modules for Ark client
328 lines • 14.8 kB
TypeScript
import type { NitroArk, BarkCreateOpts, BarkArkInfo, Bolt11Invoice, BarkSendManyOutput, ArkoorPaymentResult, LightningSendResult, OnchainPaymentResult, OffchainBalanceResult, OnchainBalanceResult, NewAddressResult, KeyPairResult, LightningReceive, BarkMovement as NitroBarkMovement, BarkMovementDestination as NitroBarkMovementDestination, BoardResult, RoundStatus } from './NitroArk.nitro';
export type BarkVtxo = {
amount: number;
expiry_height: number;
server_pubkey: string;
exit_delta: number;
anchor_point: string;
point: string;
state: 'Spendable' | 'Spent' | 'Locked' | 'unknown';
};
export type MovementStatus = 'pending' | 'finished' | 'failed' | 'cancelled';
export type BarkMovementDestination = NitroBarkMovementDestination & {
payment_method: 'ark' | 'bitcoin' | 'output-script' | 'invoice' | 'offer' | 'lightning-address' | 'custom';
};
export type BarkMovement = NitroBarkMovement & {
status: MovementStatus;
sent_to: BarkMovementDestination[];
received_on: BarkMovementDestination[];
};
export declare const NitroArkHybridObject: NitroArk;
/**
* Creates a new BIP39 mnemonic phrase.
* @returns A promise resolving to the mnemonic string.
*/
export declare function createMnemonic(): Promise<string>;
/**
* Creates a new wallet at the specified directory.
* @param datadir Path to the data directory.
* @param opts The options for wallet creation.
* @returns A promise that resolves on success or rejects on error.
*/
export declare function createWallet(datadir: string, opts: BarkCreateOpts): Promise<void>;
/**
* Loads an existing wallet or creates a new one at the specified directory.
* Once loaded, the wallet state is managed internally.
* @param datadir Path to the data directory.
* @param config The configuration options for the wallet.
* @returns A promise that resolves on success or rejects on error.
*/
export declare function loadWallet(datadir: string, config: BarkCreateOpts): Promise<void>;
/**
* Closes the currently loaded wallet, clearing its state from memory.
* @returns A promise that resolves on success or rejects on error.
*/
export declare function closeWallet(): Promise<void>;
/**
* Refreshes the server state.
* @returns A promise that resolves on success or rejects on error.
*/
export declare function refreshServer(): Promise<void>;
/**
* Checks if a wallet is currently loaded.
* @returns A promise resolving to true if a wallet is loaded, false otherwise.
*/
export declare function isWalletLoaded(): Promise<boolean>;
/**
* Registers all confirmed boards with the server.
* @returns A promise that resolves on success.
*/
export declare function syncPendingBoards(): Promise<void>;
/**
* Runs wallet maintenance tasks for offchain.
* This includes refreshing vtxos that need to be refreshed.
* @returns A promise that resolves on success.
*/
export declare function maintenance(): Promise<void>;
/**
* Runs wallet maintenance tasks for both offchain and onchain.
* This includes refreshing vtxos that need to be refreshed.
* @returns A promise that resolves on success.
*/
export declare function maintenanceWithOnchain(): Promise<void>;
/**
* Refreshes vtxos that need to be refreshed.
* @returns A promise that resolves on success.
*/
export declare function maintenanceRefresh(): Promise<void>;
/**
* Synchronizes the wallet with the blockchain.
* @returns A promise that resolves on success.
*/
export declare function sync(): Promise<void>;
/**
* Synchronizes the Ark-specific exits.
* @returns A promise that resolves on success.
*/
export declare function syncExits(): Promise<void>;
/**
* Synchronizes pending rounds.
* @returns A promise that resolves on success.
*/
export declare function syncPendingRounds(): Promise<void>;
/**
* Gets the Ark-specific information.
* @returns A promise resolving to the BarkArkInfo object.
*/
export declare function getArkInfo(): Promise<BarkArkInfo>;
/**
* Gets the offchain balance for the loaded wallet.
* @returns A promise resolving to the OffchainBalanceResult object.
*/
export declare function offchainBalance(): Promise<OffchainBalanceResult>;
/**
* Derives the next keypair for the store.
* @returns A promise resolving to the KeyPairResult object.
*/
export declare function deriveStoreNextKeypair(): Promise<KeyPairResult>;
/**
* Gets the wallet's VTXO public key (hex string).
* @param index Index of the VTXO pubkey to retrieve.
* @returns A promise resolving to the KeyPairResult object.
*/
export declare function peakKeyPair(index: number): Promise<KeyPairResult>;
/**
* Peeks a derived address without advancing the wallet's address index.
* @param index Index of the address to preview.
* @returns A promise resolving to the NewAddressResult object.
*/
export declare function peakAddress(index: number): Promise<NewAddressResult>;
/**
* Gets the wallet's Address.
* @returns A promise resolving to NewAddressResult object.
*/
export declare function newAddress(): Promise<NewAddressResult>;
/**
* Signs a message with the private key at the specified index.
* @param message The message to sign.
* @param index The index of the keypair to use for signing.
* @returns A promise resolving to the signature string.
*/
export declare function signMessage(message: string, index: number): Promise<string>;
/**
* Signs a message with the private key at the specified index.
* @param message The message to sign.
* @param mnemonic The BIP39 mnemonic phrase to use for signing.
* @param network The network to use for signing.
* @param index The index of the keypair to use for signing.
* @returns A promise resolving to the signature string.
*/
export declare function signMesssageWithMnemonic(message: string, mnemonic: string, network: string, index: number): Promise<string>;
/**
* Derives a keypair from a mnemonic.
* @param mnemonic The mnemonic to derive the keypair from.
* @param network The network to derive the keypair for.
* @param index The index to derive the keypair from.
* @returns A promise resolving to the KeyPairResult object.
*/
export declare function deriveKeypairFromMnemonic(mnemonic: string, network: string, index: number): Promise<KeyPairResult>;
/**
* Verifies a signed message.
* @param message The original message.
* @param signature The signature to verify.
* @param publicKey The public key corresponding to the private key used for signing.
* @returns A promise resolving to true if the signature is valid, false otherwise.
*/
export declare function verifyMessage(message: string, signature: string, publicKey: string): Promise<boolean>;
/**
* Gets a paginated list of wallet history (balance changes).
* @returns A promise resolving to an array of BarkMovement objects.
*/
export declare function history(): Promise<BarkMovement[]>;
/**
* Gets the list of VTXOs as a JSON string for the loaded wallet.
* @param no_sync If true, skips synchronization with the blockchain. Defaults to false.
* @returns A promise resolving BarkVtxo[] array.
*/
export declare function vtxos(): Promise<BarkVtxo[]>;
/**
* Gets the first expiring VTXO blockheight for the loaded wallet.
* @returns A promise resolving to the first expiring VTXO blockheight.
*/
export declare function getFirstExpiringVtxoBlockheight(): Promise<number | undefined>;
/**
* Gets the next required refresh blockheight for the loaded wallet for the first expiring VTXO.
* @returns A promise resolving to the next required refresh blockheight.
*/
export declare function getNextRequiredRefreshBlockheight(): Promise<number | undefined>;
/**
* Gets the list of expiring VTXOs as a JSON Object of type BarkVtxo.
* @param threshold The block height threshold to check for expiring VTXOs.
* @returns A promise resolving BarkVtxo[] array.
*/
export declare function getExpiringVtxos(threshold: number): Promise<BarkVtxo[]>;
/**
* Gets the onchain balance for the loaded wallet.
* @returns A promise resolving to the OnchainBalanceResult object.
*/
export declare function onchainBalance(): Promise<OnchainBalanceResult>;
/**
* Synchronizes the onchain state of the wallet.
* @returns A promise that resolves on success.
*/
export declare function onchainSync(): Promise<void>;
/**
* Gets the list of unspent onchain outputs as a JSON Object of type BarkVtxo.
* @returns A promise resolving to the JSON string of unspent outputs.
*/
export declare function onchainListUnspent(): Promise<string>;
/**
* Gets the list of onchain UTXOs as a JSON string for the loaded wallet.
* @returns A promise resolving to the JSON string of UTXOs.
*/
export declare function onchainUtxos(): Promise<string>;
/**
* Gets a fresh onchain address for the loaded wallet.
* @returns A promise resolving to the Bitcoin address string.
*/
export declare function onchainAddress(): Promise<string>;
/**
* Sends funds using the onchain wallet.
* @param destination The destination Bitcoin address.
* @param amountSat The amount to send in satoshis.
* @returns A promise resolving to the OnchainPaymentResult object
*/
export declare function onchainSend(destination: string, amountSat: number): Promise<OnchainPaymentResult>;
/**
* Sends all funds from the onchain wallet to a destination address.
* @param destination The destination Bitcoin address.
* @returns A promise resolving to the transaction ID string.
*/
export declare function onchainDrain(destination: string): Promise<string>;
/**
* Sends funds to multiple recipients using the onchain wallet.
* @param outputs An array of objects containing destination address and amountSat.
* @returns A promise resolving to the transaction ID string.
*/
export declare function onchainSendMany(outputs: BarkSendManyOutput[]): Promise<string>;
/**
* Creates a Bolt 11 invoice.
* @param amountMsat The amount in millisatoshis for the invoice.
* @returns A promise resolving to Bolt11Invoice object.
*/
export declare function bolt11Invoice(amountMsat: number): Promise<Bolt11Invoice>;
/**
* Gets the status of a Lightning receive.
* @param paymentHash The payment hash of the Lightning receive.
* @returns A promise resolving to the Lightning receive status.
*/
export declare function lightningReceiveStatus(paymentHash: string): Promise<LightningReceive | undefined>;
/**
* Checks if a Lightning payment has been received and returns the preimage if available.
* @param paymentHash The payment hash of the Lightning payment.
* @param wait Whether to wait for the payment to be received.
* @returns A promise resolving to the preimage string if payment received, or null if not.
*/
export declare function checkLightningPayment(paymentHash: string, wait: boolean): Promise<string | null>;
/**
* Attempts to claim a Lightning payment, optionally using a claim token.
* @param paymentHash The payment hash of the Lightning payment.
* @param wait Whether to wait for the claim to complete.
* @param token Optional claim token used when no spendable VTXOs are owned.
* @returns A promise resolving to the claimed LightningReceive if successful, or null if not.
*/
export declare function tryClaimLightningReceive(paymentHash: string, wait: boolean, token?: string): Promise<LightningReceive>;
/**
* Checks and claims all open Lightning receives.
* @param wait Whether to wait for the claim to complete.
* @returns A promise that resolves on success or rejects on error.
*/
export declare function tryClaimAllLightningReceives(wait: boolean): Promise<void>;
/**
* Pays a Bolt11 Lightning invoice.
* @param destination The Lightning invoice.
* @param amountSat The amount in satoshis to send. Use 0 for invoice amount.
* @returns A promise resolving to a LightningSendResult object
*/
export declare function payLightningInvoice(destination: string, amountSat?: number): Promise<LightningSendResult>;
/**
* Sends a payment to a Bolt12 offer.
* @param offer The Bolt12 offer.
* @param amountSat The amount in satoshis to send. Use 0 for invoice amount.
* @returns A promise resolving to a LightningSendResult object
*/
export declare function payLightningOffer(offer: string, amountSat?: number): Promise<LightningSendResult>;
/**
* Sends a payment to a Lightning Address.
* @param addr The Lightning Address.
* @param amountSat The amount in satoshis to send.
* @param comment An optional comment.
* @returns A promise resolving to a LightningSendResult object
*/
export declare function payLightningAddress(addr: string, amountSat: number, comment: string): Promise<LightningSendResult>;
/**
* Boards a specific amount from the onchain wallet into Ark.
* @param amountSat The amount in satoshis to board.
* @returns A promise resolving to a BoardResult object
*/
export declare function boardAmount(amountSat: number): Promise<BoardResult>;
/**
* Boards all available funds from the onchain wallet into Ark.
* @returns A promise resolving to a BoardResult object.
*/
export declare function boardAll(): Promise<BoardResult>;
/**
* Validates an Arkoor address.
* @param address The Arkoor address to validate.
* @returns A promise resolving to void.
*/
export declare function validateArkoorAddress(address: string): Promise<void>;
/**
* Sends an Arkoor payment.
* @param destination The destination Arkoor address.
* @param amountSat The amount in satoshis to send.
* @returns A promise resolving to the ArkoorPaymentResult object
*/
export declare function sendArkoorPayment(destination: string, amountSat: number): Promise<ArkoorPaymentResult>;
/**
* Sends an onchain payment via an Ark round.
* @param destination The destination Bitcoin address.
* @param amountSat The amount in satoshis to send.
* @returns A promise resolving to the round status.
*/
export declare function sendRoundOnchainPayment(destination: string, amountSat: number): Promise<RoundStatus>;
/**
* Offboards specific VTXOs to a destination address.
* @param vtxoIds Array of VtxoId strings to offboard.
* @param destinationAddress Destination Bitcoin address (if empty, sends to internal wallet).
* @returns A promise resolving to the round status.
*/
export declare function offboardSpecific(vtxoIds: string[], destinationAddress: string): Promise<RoundStatus>;
/**
* Offboards all VTXOs to a destination address.
* @param destinationAddress Destination Bitcoin address (if empty, sends to internal wallet).
* @returns A promise resolving to the round status.
*/
export declare function offboardAll(destinationAddress: string): Promise<RoundStatus>;
export type { NitroArk, BarkCreateOpts, BarkConfigOpts, BarkArkInfo, Bolt11Invoice, BoardResult, BarkSendManyOutput, ArkoorPaymentResult, LightningSendResult, OnchainPaymentResult, OffchainBalanceResult, OnchainBalanceResult, NewAddressResult, KeyPairResult, LightningReceive, RoundStatus, } from './NitroArk.nitro';
//# sourceMappingURL=index.d.ts.map