Skip to content

Commit 1d374aa

Browse files
authored
Merge branch 'main' into documentation
2 parents 5f54f01 + 1503836 commit 1d374aa

20 files changed

+509
-381
lines changed

CHANGELOG.md

+29
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,32 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
10+
### Changed
11+
12+
- RPC server interface is disabled by default
13+
- It can be enabled by a feature flag
14+
15+
## [0.0.10] - 2024-09-04
16+
17+
### Changed
18+
19+
- If there is a connection to ledger while calling `Client::new()`, database won't get cleaned
20+
- Block lock checks fixed
21+
22+
## [0.0.9] - 2024-09-03
23+
24+
### Added
25+
26+
- Simple UTXO management
27+
28+
### Changed
29+
30+
- Improved logging
31+
- Error on unimplemented RPC argument
32+
- Improved main binary CLI interface
33+
834
## [0.0.8] - 2024-08-28
935

1036
### Added
@@ -122,6 +148,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
122148
- `generate_to_address`
123149
- `get_balance`
124150

151+
[Unreleased]: https://github.com/chainwayxyz/bitcoin-mock-rpc/compare/v0.0.10...HEAD
152+
[0.0.10]: https://github.com/chainwayxyz/bitcoin-mock-rpc/compare/v0.0.9...v0.0.10
153+
[0.0.9]: https://github.com/chainwayxyz/bitcoin-mock-rpc/compare/v0.0.8...v0.0.9
125154
[0.0.8]: https://github.com/chainwayxyz/bitcoin-mock-rpc/compare/v0.0.7...v0.0.8
126155
[0.0.7]: https://github.com/chainwayxyz/bitcoin-mock-rpc/compare/v0.0.6...v0.0.7
127156
[0.0.6]: https://github.com/chainwayxyz/bitcoin-mock-rpc/compare/v0.0.5...v0.0.6

Cargo.toml

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "bitcoin-mock-rpc"
3-
version = "0.0.8"
3+
version = "0.0.9"
44
edition = "2021"
55

66
[dependencies]
@@ -13,12 +13,16 @@ thiserror = "1.0.63"
1313
bitcoin-scriptexec = { git = "https://github.com/Bitcoin-Wildlife-Sanctuary/rust-bitcoin-scriptexec" }
1414
rusqlite = { version = "0.32.1", features = ["bundled"] }
1515
rs_merkle = "1.4"
16-
jsonrpsee = { version = "0.24.3", features = ["server", "client", "macros"], default-features = false }
17-
tokio = { version = "1.39.3", features = ["full"]}
1816
tracing = "0.1.40"
1917
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
20-
tower = "0.4.13"
2118
clap = { version = "4.5.16", features = ["derive"] }
19+
jsonrpsee = { version = "0.24.3", features = ["server", "client", "macros"], default-features = false, optional = true }
20+
tokio = { version = "1.39.3", features = ["full"], optional = true }
21+
tower = { version = "0.4.13", optional = true }
2222

23-
[[bin]]
24-
name = "bitcoin_mock_rpc"
23+
[dev-dependencies]
24+
tokio = { version = "1.39.3", features = ["full"] }
25+
26+
[features]
27+
# Enables RPC server interface. Note: Not stable nor complete. Use it in your own caution.
28+
rpc_server = ["dep:jsonrpsee", "dep:tokio", "dep:tower"]

README.md

+18-57
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
# Bitcoin Mock Remote Procedure Call
22

3-
Bitcoin-mock-rpc is a mock Bitcoin ledger with RPC interface but without a
4-
wallet support. Meaning there are only checks for consensus details of an
5-
operation. This library can be used to test Bitcoin applications, without
6-
needing to set up Bitcoin and with a **sandboxed environment**, for each test.
7-
8-
Bitcoin-mock-rpc is built on
9-
[bitcoincore-rpc's](https://github.com/rust-bitcoin/rust-bitcoincore-rpc)
10-
`RpcApi` trait. Meaning no real servers are needed for Rust applications. There
11-
is also an RPC server that can communicate with any application: No rust
12-
dependencies!
3+
`bitcoin-mock-rpc` is a mock Bitcoin ledger without a wallet support built on
4+
`RpcApi` trait in
5+
[bitcoincore-rpc](https://github.com/rust-bitcoin/rust-bitcoincore-rpc) library.
6+
Meaning there are only checks for consensus details of an operation. This
7+
library can be used to test Bitcoin applications, without needing to set up
8+
Bitcoin and with a **sandboxed environment**, for each test.
139

1410
This library is aimed to help the development of
1511
[Clementine](https://github.com/chainwayxyz/clementine). Therefore, it's usage
@@ -19,55 +15,8 @@ of this library can be taken as a reference.
1915
not gives any guarantee to act as the Bitcoin itself at any scale. Use it at
2016
your own risk.
2117

22-
## Differences Between Real Bitcoin RPC and Feature Set
23-
24-
This library is currently **under heavy development**. And it is not expected to
25-
provide a full Bitcoin experience. Code needs to be checked for what really is
26-
available as futures. Also, [changelog](CHANGELOG.md) is a great summary for
27-
what's available.
28-
29-
Some of the RPC functions behave similarly with real RPC while some of them are
30-
not (mostly wallet operations). To check if an RPC function behaves different
31-
than the real one, please check function comments in
32-
[`src/client/rpc_api.rs`](src/client/rpc_api.rs).
33-
3418
## Usage
3519

36-
### RPC Server
37-
38-
RPC server can be spawned as long as there are available ports for them. Each
39-
server will have an independent blockchain.
40-
41-
To run from CLI:
42-
43-
```bash
44-
$ cargo run
45-
Server started at 127.0.0.1:1024
46-
# ^^^^^^^^^^^^^^
47-
# Use this address in applications
48-
$ cargo run -- --help # Prints usage information
49-
```
50-
51-
To run in a Rust application:
52-
53-
```rust
54-
#[test]
55-
fn test() {
56-
// Calling `spawn_rpc_server` in a different test while this test is running
57-
// is OK and will spawn another blockchain. If parameters are the same
58-
// however, they will operate on the same blockchain. Note: (None, None)
59-
// will result to pick random values.
60-
let address = bitcoin_mock_rpc::spawn_rpc_server(None, None).unwrap();
61-
62-
let rpc =
63-
bitcoincore_rpc::Client::new(&address.0.to_string(), bitcoincore_rpc::Auth::None).unwrap();
64-
65-
// Use `bitcoincore_rpc` as is from now on. No code change is needed.
66-
}
67-
```
68-
69-
### `RpcApiWrapper` Trait For Rust Applications
70-
7120
`RpcApiWrapper` trait can be used to select between real and mock RPC:
7221

7322
```rust
@@ -98,6 +47,18 @@ fn test() {
9847
}
9948
```
10049

50+
## Differences Between Real Bitcoin RPC and Feature Set
51+
52+
This library is currently **under heavy development**. And it is not expected to
53+
provide a full Bitcoin experience. Code needs to be checked for what really is
54+
available as futures. Also, [changelog](CHANGELOG.md) is a great summary for
55+
what's available.
56+
57+
Some of the RPC functions behave similarly with real RPC while some of them are
58+
not (mostly wallet operations). To check if an RPC function behaves different
59+
than the real one, please check function comments in
60+
[`src/client/rpc_api.rs`](src/client/rpc_api.rs).
61+
10162
## Testing
10263

10364
Standard Rust tools are sufficient for testing:

src/bin/bitcoin_mock_rpc.rs

-61
This file was deleted.

0 commit comments

Comments
 (0)