diff --git a/src/bitcoin.rs b/src/bitcoin.rs index 3ef09c5..c2f1a81 100644 --- a/src/bitcoin.rs +++ b/src/bitcoin.rs @@ -1,5 +1,5 @@ use std::{ - collections::HashSet, + collections::{HashMap, HashSet}, fs::File, future::Future, process::Stdio, @@ -7,7 +7,7 @@ use std::{ 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}; @@ -165,6 +165,16 @@ impl BitcoinNode { ) -> bitcoincore_rpc::Result> { 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, + ) -> bitcoincore_rpc::Result> { + RpcApi::call(self, "generateblock", &[output.into(), transactions.into()]).await + } } #[async_trait]