@arkade-os/sdk
Version:
Bitcoin wallet SDK with Taproot and Ark integration
51 lines (50 loc) • 1.98 kB
TypeScript
import { P2TR } from "@scure/btc-signer/payment.js";
import { Coin, SendBitcoinParams } from ".";
import { Identity } from "../identity";
import { Network, NetworkName } from "../networks";
import { OnchainProvider } from "../providers/onchain";
import { AnchorBumper } from "../utils/anchor";
import { Transaction } from "../utils/transaction";
/**
* Onchain Bitcoin wallet implementation for traditional Bitcoin transactions.
*
* This wallet handles regular Bitcoin transactions on the blockchain without
* using the Ark protocol. It supports P2TR (Pay-to-Taproot) addresses and
* provides basic Bitcoin wallet functionality.
*
* @example
* ```typescript
* const wallet = await OnchainWallet.create(identity, 'mainnet');
* const balance = await wallet.getBalance();
* const txid = await wallet.send({
* address: 'bc1...',
* amount: 50000
* });
* ```
*/
export declare class OnchainWallet implements AnchorBumper {
private identity;
static MIN_FEE_RATE: number;
static DUST_AMOUNT: number;
readonly onchainP2TR: P2TR;
readonly provider: OnchainProvider;
readonly network: Network;
private constructor();
static create(identity: Identity, networkName: NetworkName, provider?: OnchainProvider): Promise<OnchainWallet>;
get address(): string;
getCoins(): Promise<Coin[]>;
getBalance(): Promise<number>;
send(params: SendBitcoinParams): Promise<string>;
bumpP2A(parent: Transaction): Promise<[string, string]>;
}
/**
* Select coins to reach a target amount, prioritizing those closer to expiry
* @param coins List of coins to select from
* @param targetAmount Target amount to reach in satoshis
* @param forceChange If true, ensure the coin selection will require a change output
* @returns Selected coins and change amount, or null if insufficient funds
*/
export declare function selectCoins(coins: Coin[], targetAmount: number, forceChange?: boolean): {
inputs: Coin[];
changeAmount: bigint;
};