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);
|
2021-10-21 14:40:26 +05:30
|
|
|
[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
|
|
|
};
|
|
|
|
|
2021-10-14 10:58:16 -07:00
|
|
|
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
|
|
|
};
|
|
|
|
|
2021-10-18 15:48:30 +05:30
|
|
|
dictionary TransactionDetails {
|
2022-04-20 06:13:49 +05:30
|
|
|
u64? fee;
|
2021-10-17 02:28:26 +05:30
|
|
|
u64 received;
|
|
|
|
u64 sent;
|
2021-11-12 12:29:53 -05:00
|
|
|
string txid;
|
2021-10-17 02:28:26 +05:30
|
|
|
};
|
|
|
|
|
2021-12-21 22:08:21 -08:00
|
|
|
dictionary BlockTime {
|
2021-10-18 15:48:30 +05:30
|
|
|
u32 height;
|
|
|
|
u64 timestamp;
|
|
|
|
};
|
|
|
|
|
|
|
|
[Enum]
|
|
|
|
interface Transaction {
|
|
|
|
Unconfirmed(TransactionDetails details);
|
2021-12-21 22:08:21 -08:00
|
|
|
Confirmed(TransactionDetails details, BlockTime confirmation);
|
2021-10-18 15:48:30 +05:30
|
|
|
};
|
|
|
|
|
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;
|
2022-04-20 23:15:14 -07:00
|
|
|
u8? concurrency;
|
2021-10-16 20:19:56 +05:30
|
|
|
u64 stop_gap;
|
2022-04-20 23:15:14 -07:00
|
|
|
u64? timeout;
|
2021-10-15 00:43:17 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
[Enum]
|
|
|
|
interface BlockchainConfig {
|
|
|
|
Electrum(ElectrumConfig config);
|
|
|
|
Esplora(EsploraConfig config);
|
|
|
|
};
|
|
|
|
|
2022-04-20 23:15:14 -07:00
|
|
|
interface Blockchain {
|
|
|
|
[Throws=BdkError]
|
|
|
|
constructor(BlockchainConfig config);
|
|
|
|
[Throws=BdkError]
|
2022-04-22 14:10:00 -07:00
|
|
|
void broadcast([ByRef] PartiallySignedBitcoinTransaction psbt);
|
2022-04-20 23:15:14 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
callback interface Progress {
|
2021-10-15 01:54:32 +05:30
|
|
|
void update(f32 progress, string? message);
|
|
|
|
};
|
|
|
|
|
2022-01-24 20:32:49 +00:00
|
|
|
interface Wallet {
|
2021-10-16 20:19:56 +05:30
|
|
|
[Throws=BdkError]
|
2022-04-20 23:15:14 -07:00
|
|
|
constructor(string descriptor, string? change_descriptor, Network network, DatabaseConfig database_config);
|
2021-10-16 20:19:56 +05:30
|
|
|
string get_new_address();
|
2021-11-04 22:45:00 +05:30
|
|
|
string get_last_unused_address();
|
2021-10-16 20:19:56 +05:30
|
|
|
[Throws=BdkError]
|
|
|
|
u64 get_balance();
|
2021-10-16 20:19:34 +05:30
|
|
|
[Throws=BdkError]
|
|
|
|
void sign([ByRef] PartiallySignedBitcoinTransaction psbt);
|
2021-10-17 02:28:26 +05:30
|
|
|
[Throws=BdkError]
|
2021-10-18 15:48:30 +05:30
|
|
|
sequence<Transaction> get_transactions();
|
2021-10-16 20:25:58 +05:30
|
|
|
Network get_network();
|
|
|
|
[Throws=BdkError]
|
2022-04-20 23:15:14 -07:00
|
|
|
void sync([ByRef] Blockchain blockchain, Progress? progress);
|
2021-10-15 00:43:17 +05:30
|
|
|
};
|
2021-10-16 16:42:35 +05:30
|
|
|
|
|
|
|
interface PartiallySignedBitcoinTransaction {
|
|
|
|
[Throws=BdkError]
|
2022-02-24 11:48:19 -08:00
|
|
|
constructor(string psbt_base64);
|
|
|
|
string serialize();
|
2022-04-22 14:10:00 -07:00
|
|
|
string txid();
|
2021-10-16 16:42:35 +05:30
|
|
|
};
|
2021-10-21 14:35:40 +05:30
|
|
|
|
2022-03-25 17:24:21 +00:00
|
|
|
interface TxBuilder {
|
|
|
|
constructor();
|
|
|
|
TxBuilder add_recipient(string address, u64 amount);
|
|
|
|
TxBuilder fee_rate(float sat_per_vbyte);
|
2022-03-31 17:17:24 +01:00
|
|
|
TxBuilder drain_wallet();
|
2022-03-31 17:17:43 +01:00
|
|
|
TxBuilder drain_to(string address);
|
2022-04-15 21:04:04 +01:00
|
|
|
TxBuilder enable_rbf();
|
|
|
|
TxBuilder enable_rbf_with_sequence(u32 nsequence);
|
2022-03-25 17:24:21 +00:00
|
|
|
[Throws=BdkError]
|
|
|
|
PartiallySignedBitcoinTransaction build([ByRef] Wallet wallet);
|
|
|
|
};
|
|
|
|
|
2021-10-21 14:35:40 +05:30
|
|
|
dictionary ExtendedKeyInfo {
|
|
|
|
string mnemonic;
|
|
|
|
string xprv;
|
|
|
|
string fingerprint;
|
|
|
|
};
|
|
|
|
|
2021-12-21 22:08:21 -08:00
|
|
|
enum WordCount {
|
2021-10-21 14:35:40 +05:30
|
|
|
"Words12",
|
|
|
|
"Words15",
|
|
|
|
"Words18",
|
|
|
|
"Words21",
|
|
|
|
"Words24",
|
|
|
|
};
|