bdk-ffi/src/bdk.udl

216 lines
3.8 KiB
Plaintext
Raw Normal View History

2021-10-11 23:04:18 -07:00
namespace bdk {
2021-10-21 14:35:40 +05:30
[Throws=BdkError]
2021-12-21 22:08:21 -08:00
ExtendedKeyInfo generate_extended_key(Network network, WordCount word_count, string? password);
2022-05-17 08:16:17 -04:00
[Throws=BdkError]
ExtendedKeyInfo restore_extended_key(Network network, string mnemonic, string? password);
2021-10-11 23:04:18 -07:00
};
2021-10-14 00:05:50 +05:30
[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",
2021-10-15 00:43:17 +05:30
"Esplora",
2021-10-14 00:05:50 +05:30
"Sled",
2022-03-11 22:45:37 -06:00
"Rusqlite",
2021-10-14 00:05:50 +05:30
};
2022-04-19 14:30:12 -04:00
dictionary AddressInfo {
u32 index;
string address;
};
2022-04-19 14:30:12 -04:00
enum AddressIndex {
"New",
"LastUnused",
};
enum Network {
"Bitcoin",
"Testnet",
"Signet",
"Regtest",
};
2021-10-14 04:23:17 +05:30
dictionary SledDbConfiguration {
string path;
string tree_name;
};
2022-03-11 22:45:37 -06:00
dictionary SqliteDbConfiguration {
string path;
};
2021-10-14 04:23:17 +05:30
[Enum]
interface DatabaseConfig {
2022-03-01 16:14:21 -05:00
Memory();
2021-10-15 00:43:17 +05:30
Sled(SledDbConfiguration config);
2022-03-11 22:45:37 -06:00
Sqlite(SqliteDbConfiguration config);
2021-10-14 04:23:17 +05:30
};
dictionary TransactionDetails {
2022-05-17 08:16:17 -04:00
u64? fee;
u64 received;
u64 sent;
string txid;
2021-10-17 02:28:26 +05:30
};
2021-12-21 22:08:21 -08:00
dictionary BlockTime {
2022-05-17 08:16:17 -04:00
u32 height;
u64 timestamp;
};
[Enum]
interface Transaction {
Unconfirmed(TransactionDetails details);
2021-12-21 22:08:21 -08:00
Confirmed(TransactionDetails details, BlockTime confirmation);
};
2022-05-17 08:16:17 -04:00
dictionary ExtendedKeyInfo {
string mnemonic;
string xprv;
string fingerprint;
};
enum WordCount {
"Words12",
"Words15",
"Words18",
"Words21",
"Words24",
};
2021-10-15 00:43:17 +05:30
dictionary ElectrumConfig {
2021-10-16 20:19:56 +05:30
string url;
string? socks5;
u8 retry;
u8? timeout;
u64 stop_gap;
2021-10-15 00:43:17 +05:30
};
dictionary EsploraConfig {
2021-10-16 20:19:56 +05:30
string base_url;
string? proxy;
u8? concurrency;
2021-10-16 20:19:56 +05:30
u64 stop_gap;
u64? timeout;
2021-10-15 00:43:17 +05:30
};
[Enum]
interface BlockchainConfig {
Electrum(ElectrumConfig config);
Esplora(EsploraConfig config);
};
interface Blockchain {
[Throws=BdkError]
constructor(BlockchainConfig config);
2022-05-17 08:16:17 -04:00
[Throws=BdkError]
void broadcast([ByRef] PartiallySignedBitcoinTransaction psbt);
};
callback interface Progress {
2021-10-15 01:54:32 +05:30
void update(f32 progress, string? message);
};
interface Wallet {
2021-10-16 20:19:56 +05:30
[Throws=BdkError]
constructor(string descriptor, string? change_descriptor, Network network, DatabaseConfig database_config);
2022-05-17 08:16:17 -04:00
2022-05-16 12:07:11 -04:00
[Throws=BdkError]
2022-04-19 14:30:12 -04:00
AddressInfo get_address(AddressIndex address_index);
2022-05-17 08:16:17 -04:00
2021-10-16 20:19:56 +05:30
[Throws=BdkError]
u64 get_balance();
2022-05-17 08:16:17 -04:00
2021-10-16 20:19:34 +05:30
[Throws=BdkError]
boolean sign([ByRef] PartiallySignedBitcoinTransaction psbt);
2022-05-17 08:16:17 -04:00
2021-10-17 02:28:26 +05:30
[Throws=BdkError]
sequence<Transaction> get_transactions();
2022-05-17 08:16:17 -04:00
Network get_network();
2022-05-17 08:16:17 -04:00
[Throws=BdkError]
void sync([ByRef] Blockchain blockchain, Progress? progress);
2021-10-15 00:43:17 +05:30
};
interface PartiallySignedBitcoinTransaction {
[Throws=BdkError]
constructor(string psbt_base64);
2022-05-17 08:16:17 -04:00
string serialize();
2022-05-17 08:16:17 -04:00
string txid();
};
2021-10-21 14:35:40 +05:30
2022-03-25 17:24:21 +00:00
interface TxBuilder {
constructor();
2022-05-17 08:16:17 -04:00
2022-03-25 17:24:21 +00:00
TxBuilder add_recipient(string address, u64 amount);
2022-05-17 08:16:17 -04:00
2022-03-25 17:24:21 +00:00
TxBuilder fee_rate(float sat_per_vbyte);
2022-05-17 08:16:17 -04:00
2022-03-31 17:17:24 +01:00
TxBuilder drain_wallet();
2022-05-17 08:16:17 -04:00
2022-03-31 17:17:43 +01:00
TxBuilder drain_to(string address);
2022-05-17 08:16:17 -04:00
2022-04-15 21:04:04 +01:00
TxBuilder enable_rbf();
2022-05-17 08:16:17 -04:00
2022-04-15 21:04:04 +01:00
TxBuilder enable_rbf_with_sequence(u32 nsequence);
2022-05-17 08:16:17 -04:00
TxBuilder add_data(sequence<u8> data);
2022-03-25 17:24:21 +00:00
[Throws=BdkError]
PartiallySignedBitcoinTransaction finish([ByRef] Wallet wallet);
2022-03-25 17:24:21 +00:00
};
2022-05-02 19:23:47 -07:00
interface BumpFeeTxBuilder {
constructor(string txid, float new_fee_rate);
2022-05-17 08:16:17 -04:00
2022-05-02 19:23:47 -07:00
BumpFeeTxBuilder allow_shrinking(string address);
2022-05-17 08:16:17 -04:00
2022-05-02 19:23:47 -07:00
BumpFeeTxBuilder enable_rbf();
2022-05-17 08:16:17 -04:00
2022-05-02 19:23:47 -07:00
BumpFeeTxBuilder enable_rbf_with_sequence(u32 nsequence);
2022-05-17 08:16:17 -04:00
2022-05-02 19:23:47 -07:00
[Throws=BdkError]
PartiallySignedBitcoinTransaction finish([ByRef] Wallet wallet);
2022-05-02 19:23:47 -07:00
};