Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Rust bdk to alpha 3 #441

Merged
merged 3 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 29 additions & 37 deletions bdk-ffi/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions bdk-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ path = "uniffi-bindgen.rs"
default = ["uniffi/cli"]

[dependencies]
bdk = { version = "1.0.0-alpha.2", features = ["all-keys", "keys-bip39"] }
bdk = { version = "1.0.0-alpha.3", features = ["all-keys", "keys-bip39"] }

# TODO 22: The bdk_esplora crate uses esplora_client which uses reqwest for async. By default it uses the system
# openssl library, which is creating problems for cross-compilation. I'd rather use rustls, but it's hidden
Expand All @@ -28,7 +28,7 @@ bdk = { version = "1.0.0-alpha.2", features = ["all-keys", "keys-bip39"] }
# bdk = { git = "https://github.com/thunderbiscuit/bdk.git", branch = "test-rust-tls", version = "1.0.0-alpha.2", features = ["all-keys", "keys-bip39"] }
# bdk_esplora = { git = "https://github.com/thunderbiscuit/bdk.git", branch = "test-rust-tls", version = "0.4.0", package = "bdk_esplora", default-features = false, features = ["std", "blocking", "async-https-rustls"] }

bdk_esplora = { version = "0.4.0", default-features = false, features = ["std", "blocking"] }
bdk_esplora = { version = "0.5.0", default-features = false, features = ["std", "blocking"] }
uniffi = { version = "=0.25.1" }

[build-dependencies]
Expand Down
95 changes: 37 additions & 58 deletions bdk-ffi/src/bdk.udl
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
namespace bdk {};

// ------------------------------------------------------------------------
// bdk crate - error module
// ------------------------------------------------------------------------

[Error]
enum Alpha3Error {
"Generic"
};

[Error]
interface CalculateFeeError {
MissingTxOut(sequence<OutPoint> out_points);
NegativeFee(i64 fee);
};

// ------------------------------------------------------------------------
// bdk crate - types module
// ------------------------------------------------------------------------
Expand Down Expand Up @@ -36,7 +51,7 @@ dictionary Balance {
u64 total;
};

dictionary LocalUtxo {
dictionary LocalOutput {
OutPoint outpoint;
TxOut txout;
KeychainKind keychain;
Expand All @@ -52,42 +67,6 @@ dictionary TxOut {
// bdk crate - wallet module
// ------------------------------------------------------------------------

[Error]
enum BdkError {
"Generic",
"NoRecipients",
"NoUtxosSelected",
"OutputBelowDustLimit",
"InsufficientFunds",
"BnBTotalTriesExceeded",
"BnBNoExactMatch",
"UnknownUtxo",
"TransactionNotFound",
"TransactionConfirmed",
"IrreplaceableTransaction",
"FeeRateTooLow",
"FeeTooLow",
"FeeRateUnavailable",
"MissingKeyOrigin",
"Key",
"ChecksumMismatch",
"SpendingPolicyRequired",
"InvalidPolicyPathError",
"Signer",
"InvalidOutpoint",
"Descriptor",
"Miniscript",
"MiniscriptPsbt",
"Bip32",
"Psbt",
};

[Error]
interface CalculateFeeError {
MissingTxOut(sequence<OutPoint> out_points);
NegativeFee(i64 fee);
};

interface FeeRate {
f32 as_sat_per_vb();
f32 sat_per_kwu();
Expand All @@ -100,7 +79,7 @@ enum ChangeSpendPolicy {
};

interface Wallet {
[Name=new_no_persist, Throws=BdkError]
[Name=new_no_persist, Throws=Alpha3Error]
constructor(Descriptor descriptor, Descriptor? change_descriptor, Network network);

AddressInfo get_address(AddressIndex address_index);
Expand All @@ -113,10 +92,10 @@ interface Wallet {

boolean is_mine([ByRef] Script script);

[Throws=BdkError]
[Throws=Alpha3Error]
void apply_update(Update update);

[Throws=BdkError]
[Throws=Alpha3Error]
boolean sign(PartiallySignedTransaction psbt);

SentAndReceivedValues sent_and_received([ByRef] Transaction tx);
Expand Down Expand Up @@ -165,7 +144,7 @@ interface TxBuilder {

TxBuilder enable_rbf_with_sequence(u32 nsequence);

[Throws=BdkError]
[Throws=Alpha3Error]
PartiallySignedTransaction finish([ByRef] Wallet wallet);
};

Expand All @@ -178,7 +157,7 @@ interface BumpFeeTxBuilder {

BumpFeeTxBuilder enable_rbf_with_sequence(u32 nsequence);

[Throws=BdkError]
[Throws=Alpha3Error]
PartiallySignedTransaction finish([ByRef] Wallet wallet);
};

Expand All @@ -189,30 +168,30 @@ interface BumpFeeTxBuilder {
interface Mnemonic {
constructor(WordCount word_count);

[Name=from_string, Throws=BdkError]
[Name=from_string, Throws=Alpha3Error]
constructor(string mnemonic);

[Name=from_entropy, Throws=BdkError]
[Name=from_entropy, Throws=Alpha3Error]
constructor(sequence<u8> entropy);

string as_string();
};

interface DerivationPath {
[Throws=BdkError]
[Throws=Alpha3Error]
constructor(string path);
};

interface DescriptorSecretKey {
constructor(Network network, [ByRef] Mnemonic mnemonic, string? password);

[Name=from_string, Throws=BdkError]
[Name=from_string, Throws=Alpha3Error]
constructor(string secret_key);

[Throws=BdkError]
[Throws=Alpha3Error]
DescriptorSecretKey derive([ByRef] DerivationPath path);

[Throws=BdkError]
[Throws=Alpha3Error]
DescriptorSecretKey extend([ByRef] DerivationPath path);

DescriptorPublicKey as_public();
Expand All @@ -223,20 +202,20 @@ interface DescriptorSecretKey {
};

interface DescriptorPublicKey {
[Name=from_string, Throws=BdkError]
[Name=from_string, Throws=Alpha3Error]
constructor(string public_key);

[Throws=BdkError]
[Throws=Alpha3Error]
DescriptorPublicKey derive([ByRef] DerivationPath path);

[Throws=BdkError]
[Throws=Alpha3Error]
DescriptorPublicKey extend([ByRef] DerivationPath path);

string as_string();
};

interface Descriptor {
[Throws=BdkError]
[Throws=Alpha3Error]
constructor(string descriptor, Network network);

[Name=new_bip44]
Expand Down Expand Up @@ -275,10 +254,10 @@ interface Descriptor {
interface EsploraClient {
constructor(string url);

[Throws=BdkError]
[Throws=Alpha3Error]
Update scan(Wallet wallet, u64 stop_gap, u64 parallel_requests);

[Throws=BdkError]
[Throws=Alpha3Error]
void broadcast([ByRef] Transaction transaction);
};

Expand Down Expand Up @@ -322,7 +301,7 @@ enum WordCount {
};

interface Address {
[Throws=BdkError]
[Throws=Alpha3Error]
constructor(string address, Network network);

Network network();
Expand All @@ -337,7 +316,7 @@ interface Address {
};

interface Transaction {
[Throws=BdkError]
[Throws=Alpha3Error]
constructor(sequence<u8> transaction_bytes);

string txid();
Expand All @@ -356,7 +335,7 @@ interface Transaction {
};

interface PartiallySignedTransaction {
[Throws=BdkError]
[Throws=Alpha3Error]
constructor(string psbt_base64);

string serialize();
Expand All @@ -367,4 +346,4 @@ interface PartiallySignedTransaction {
dictionary OutPoint {
string txid;
u32 vout;
};
};
Loading
Loading