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

Generateblock rpc #69

Merged
merged 2 commits into from
Jan 10, 2025
Merged
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
14 changes: 12 additions & 2 deletions src/bitcoin.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use std::{
collections::HashSet,
collections::{HashMap, HashSet},
fs::File,
future::Future,
process::Stdio,
sync::Arc,
time::{Duration, Instant},
};

use anyhow::{bail, Context};
use anyhow::{anyhow, bail, Context};
use async_trait::async_trait;
use bitcoin::Address;
use bitcoincore_rpc::{json::AddressType::Bech32m, Auth, Client, RpcApi};
Expand Down Expand Up @@ -165,6 +165,16 @@ impl BitcoinNode {
) -> bitcoincore_rpc::Result<Vec<bitcoin::BlockHash>> {
RpcApi::generate(self, block_num, None).await
}

pub async fn generate_block(
&self,
// Address to send the block reward to
output: String,
// Either raw txs or txids, should be in mempool and in correct order
transactions: Vec<String>,
) -> bitcoincore_rpc::Result<HashMap<String, String>> {
RpcApi::call(self, "generateblock", &[output.into(), transactions.into()]).await
}
}

#[async_trait]
Expand Down
Loading