Skip to content

Commit dff145e

Browse files
committed
Implementing proof of reserves
1 parent 881ca8d commit dff145e

File tree

6 files changed

+619
-0
lines changed

6 files changed

+619
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ Cargo.lock
33

44
*.swp
55
.idea
6+
7+
.vscode/

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Proof of reserves
10+
- Added a separate module to construct "proof of reserve" PSBTs, and verify them.
11+
912
### Wallet
1013
- Added an option that must be explicitly enabled to allow signing using non-`SIGHASH_ALL` sighashes (#350)
1114

Cargo.toml

+5
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ cc = { version = ">=1.0.64", optional = true }
3131
socks = { version = "0.3", optional = true }
3232
lazy_static = { version = "1.4", optional = true }
3333
tiny-bip39 = { version = "^0.8", optional = true }
34+
bitcoinconsensus = { git = "https://github.com/rust-bitcoin/rust-bitcoinconsensus", branch = "master", optional = true }
35+
bitcoin_hashes = { version = "^0.9", optional = true }
36+
base64 = { version = "^0.11", optional = true }
3437

3538
# Needed by bdk_blockchain_tests macro
3639
bitcoincore-rpc = { version = "0.13", optional = true }
@@ -56,6 +59,7 @@ key-value-db = ["sled"]
5659
async-interface = ["async-trait"]
5760
all-keys = ["keys-bip39"]
5861
keys-bip39 = ["tiny-bip39"]
62+
reserves = ["bitcoinconsensus", "bitcoin_hashes", "base64"]
5963

6064
# Debug/Test features
6165
test-blockchains = ["bitcoincore-rpc", "electrum-client"]
@@ -67,6 +71,7 @@ env_logger = "0.7"
6771
base64 = "^0.11"
6872
clap = "2.33"
6973
serial_test = "0.4"
74+
rstest = "^0.7"
7075

7176
[[example]]
7277
name = "address_validator"

src/error.rs

+4
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ pub enum Error {
6464
/// Required fee absolute value (satoshi)
6565
required: u64,
6666
},
67+
/// The proof of reserves is invalid. The reason is given in the string parameter.
68+
ProofOfReservesInvalid(String),
69+
/// Cannot verify the proof.
70+
CannotVerifyProof,
6771
/// In order to use the [`TxBuilder::add_global_xpubs`] option every extended
6872
/// key in the descriptor must either be a master key itself (having depth = 0) or have an
6973
/// explicit origin provided

src/wallet/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ use log::{debug, error, info, trace};
3737
pub mod address_validator;
3838
pub mod coin_selection;
3939
pub mod export;
40+
#[cfg(feature = "reserves")]
41+
pub mod reserves;
4042
pub mod signer;
4143
pub mod time;
4244
pub mod tx_builder;

0 commit comments

Comments
 (0)