Skip to content

Commit 72dd813

Browse files
committed
Add generate block rpc call to bitcoin node
1 parent f75fe92 commit 72dd813

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/bitcoin.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{
77
time::{Duration, Instant},
88
};
99

10-
use anyhow::{bail, Context};
10+
use anyhow::{anyhow, bail, Context};
1111
use async_trait::async_trait;
1212
use bitcoin::Address;
1313
use bitcoincore_rpc::{json::AddressType::Bech32m, Auth, Client, RpcApi};
@@ -165,6 +165,16 @@ impl BitcoinNode {
165165
) -> bitcoincore_rpc::Result<Vec<bitcoin::BlockHash>> {
166166
RpcApi::generate(self, block_num, None).await
167167
}
168+
169+
pub async fn generate_block(
170+
&self,
171+
// Address to send the block reward to
172+
output: String,
173+
// Either raw txs or txids, should be in mempool and in correct order
174+
transactions: Vec<String>,
175+
) -> bitcoincore_rpc::Result<bitcoin::BlockHash> {
176+
RpcApi::call(self, "generateblock", &[output.into(), transactions.into()]).await
177+
}
168178
}
169179

170180
#[async_trait]

0 commit comments

Comments
 (0)