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

[DRAFT] Support Core 22 and 23 #229

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ jobs:
"0.20.0",
"0.20.1",
"0.21.0",
"22.0",
"23.0",
]
steps:
- name: Checkout Crate
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ The following versions are officially supported and automatically tested:
* 0.20.0
* 0.20.1
* 0.21.0
* 22.0
* 23.0

# Minimum Supported Rust Version (MSRV)
This library should always compile with any combination of features on **Rust 1.41.1**.
6 changes: 6 additions & 0 deletions client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,12 @@ pub trait RpcApi: Sized {
self.call("getchaintips", &[])
}

/// Compute statistics about the total number and rate of transactions in the chain.
fn get_chain_tx_stats(&self, nblocks: Option<u64>, blockhash: Option<&bitcoin::BlockHash>)
-> Result<json::GetChainTxStatsResult> {
self.call("getchaintxstats", &[opt_into_json(nblocks)?, opt_into_json(blockhash)?])
}

fn send_to_address(
&self,
address: &Address<NetworkChecked>,
Expand Down
7 changes: 6 additions & 1 deletion integration_test/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ if bitcoind -version | grep -q "v0\.2"; then
FALLBACKFEEARG="-fallbackfee=0.00001000"
fi

bitcoind -regtest $BLOCKFILTERARG $FALLBACKFEEARG \
COINSTATSINDEXARG=""
if bitcoind -version | grep -q "v[2-9]"; then
COINSTATSINDEXARG="-coinstatsindex=1"
fi

bitcoind -regtest $BLOCKFILTERARG $FALLBACKFEEARG $COINSTATSINDEXARG \
-datadir=${TESTDIR}/2 \
-connect=127.0.0.1:12348 \
-rpcport=12349 \
Expand Down
6 changes: 5 additions & 1 deletion integration_test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,11 @@ fn test_create_wallet(cl: &Client) {
}

fn test_get_tx_out_set_info(cl: &Client) {
cl.get_tx_out_set_info(None, None, None).unwrap();
if version() >= 220000 {
cl.get_tx_out_set_info(Some(json::TxOutSetHashType::Muhash), None, Some(true)).unwrap();
} else {
cl.get_tx_out_set_info(None, None, None).unwrap();
}
}

fn test_get_chain_tips(cl: &Client) {
Expand Down
20 changes: 20 additions & 0 deletions json/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1810,6 +1810,26 @@ pub enum GetChainTipsResultStatus {
Active,
}

#[derive(Clone, PartialEq, Debug, Deserialize, Serialize)]
pub struct GetChainTxStatsResult {
/// The timestamp for the final block in the window, expressed in UNIX epoch time
pub time : u64,
/// The total number of transactions in the chain up to that point
pub txcount: u64,
/// The hash of the final block in the window
pub window_final_block_hash: bitcoin::BlockHash,
/// The height of the final block in the window.
pub window_final_block_height: u64,
/// Size of the window in number of blocks
pub window_block_count: u64,
/// The number of transactions in the window. Only returned if "window_block_count" is > 0
pub window_tx_count: Option<u64>,
/// The elapsed time in the window in seconds. Only returned if "window_block_count" is > 0
pub window_interval: Option<u64>,
/// The average rate of transactions per second in the window. Only returned if "window_interval" is > 0
pub txrate: Option<f64>,
}

impl FinalizePsbtResult {
pub fn transaction(&self) -> Option<Result<Transaction, encode::Error>> {
self.hex.as_ref().map(|h| encode::deserialize(h))
Expand Down