bdk-ffi/src/bdk.udl

174 lines
3.4 KiB
Plaintext

namespace bdk {
[Throws=BdkError]
ExtendedKeyInfo generate_extended_key(Network network, WordCount word_count, string? password);
[Throws=BdkError]
ExtendedKeyInfo restore_extended_key(Network network, string mnemonic, string? password);
};
[Error]
enum BdkError {
"InvalidU32Bytes",
"Generic",
"ScriptDoesntHaveAddressForm",
"NoRecipients",
"NoUtxosSelected",
"OutputBelowDustLimit",
"InsufficientFunds",
"BnBTotalTriesExceeded",
"BnBNoExactMatch",
"UnknownUtxo",
"TransactionNotFound",
"TransactionConfirmed",
"IrreplaceableTransaction",
"FeeRateTooLow",
"FeeTooLow",
"FeeRateUnavailable",
"MissingKeyOrigin",
"Key",
"ChecksumMismatch",
"SpendingPolicyRequired",
"InvalidPolicyPathError",
"Signer",
"InvalidNetwork",
"InvalidProgressValue",
"ProgressUpdateError",
"InvalidOutpoint",
"Descriptor",
"AddressValidator",
"Encode",
"Miniscript",
"Bip32",
"Secp256k1",
"Json",
"Hex",
"Psbt",
"PsbtParse",
"Electrum",
"Esplora",
"Sled",
"Rusqlite",
};
enum Network {
"Bitcoin",
"Testnet",
"Signet",
"Regtest",
};
dictionary SledDbConfiguration {
string path;
string tree_name;
};
dictionary SqliteDbConfiguration {
string path;
};
[Enum]
interface DatabaseConfig {
Memory();
Sled(SledDbConfiguration config);
Sqlite(SqliteDbConfiguration config);
};
dictionary TransactionDetails {
u64? fee;
u64 received;
u64 sent;
string txid;
};
dictionary BlockTime {
u32 height;
u64 timestamp;
};
[Enum]
interface Transaction {
Unconfirmed(TransactionDetails details);
Confirmed(TransactionDetails details, BlockTime confirmation);
};
dictionary ElectrumConfig {
string url;
string? socks5;
u8 retry;
u8? timeout;
u64 stop_gap;
};
dictionary EsploraConfig {
string base_url;
string? proxy;
u8? concurrency;
u64 stop_gap;
u64? timeout;
};
[Enum]
interface BlockchainConfig {
Electrum(ElectrumConfig config);
Esplora(EsploraConfig config);
};
interface Blockchain {
[Throws=BdkError]
constructor(BlockchainConfig config);
[Throws=BdkError]
void broadcast([ByRef] PartiallySignedBitcoinTransaction psbt);
};
callback interface Progress {
void update(f32 progress, string? message);
};
interface Wallet {
[Throws=BdkError]
constructor(string descriptor, string? change_descriptor, Network network, DatabaseConfig database_config);
string get_new_address();
string get_last_unused_address();
[Throws=BdkError]
u64 get_balance();
[Throws=BdkError]
void sign([ByRef] PartiallySignedBitcoinTransaction psbt);
[Throws=BdkError]
sequence<Transaction> get_transactions();
Network get_network();
[Throws=BdkError]
void sync([ByRef] Blockchain blockchain, Progress? progress);
};
interface PartiallySignedBitcoinTransaction {
[Throws=BdkError]
constructor(string psbt_base64);
string serialize();
string txid();
};
interface TxBuilder {
constructor();
TxBuilder add_recipient(string address, u64 amount);
TxBuilder fee_rate(float sat_per_vbyte);
TxBuilder drain_wallet();
TxBuilder drain_to(string address);
TxBuilder enable_rbf();
TxBuilder enable_rbf_with_sequence(u32 nsequence);
[Throws=BdkError]
PartiallySignedBitcoinTransaction build([ByRef] Wallet wallet);
};
dictionary ExtendedKeyInfo {
string mnemonic;
string xprv;
string fingerprint;
};
enum WordCount {
"Words12",
"Words15",
"Words18",
"Words21",
"Words24",
};