Skip to content

Commit ec3637e

Browse files
committed
Update testmempoolaccept RPC
1 parent 06a6c15 commit ec3637e

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

client/src/client.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -862,10 +862,13 @@ pub trait RpcApi: Sized {
862862
fn test_mempool_accept<R: RawTx>(
863863
&self,
864864
rawtxs: &[R],
865+
maxfeerate: Option<f64>,
865866
) -> Result<Vec<json::TestMempoolAcceptResult>> {
866867
let hexes: Vec<serde_json::Value> =
867868
rawtxs.to_vec().into_iter().map(|r| r.raw_hex().into()).collect();
868-
self.call("testmempoolaccept", &[hexes.into()])
869+
let mut args = [hexes.into(), opt_into_json(maxfeerate)?];
870+
let defaults = [null()];
871+
self.call("testmempoolaccept", handle_defaults(&mut args, &defaults))
869872
}
870873

871874
fn stop(&self) -> Result<String> {

integration_test/src/main.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -761,13 +761,13 @@ fn test_test_mempool_accept(cl: &Client) {
761761

762762
let tx =
763763
cl.create_raw_transaction(&[input.clone()], &output, Some(500_000), Some(false)).unwrap();
764-
let res = cl.test_mempool_accept(&[&tx]).unwrap();
765-
assert!(!res[0].allowed);
764+
let res = cl.test_mempool_accept(&[&tx], None).unwrap();
765+
assert!(res[0].allowed.is_some() && !res[0].allowed.unwrap());
766766
assert!(res[0].reject_reason.is_some());
767767
let signed =
768768
cl.sign_raw_transaction_with_wallet(&tx, None, None).unwrap().transaction().unwrap();
769-
let res = cl.test_mempool_accept(&[&signed]).unwrap();
770-
assert!(res[0].allowed, "not allowed: {:?}", res[0].reject_reason);
769+
let res = cl.test_mempool_accept(&[&signed], None).unwrap();
770+
assert!(res[0].allowed.unwrap(), "not allowed: {:?}", res[0].reject_reason);
771771
}
772772

773773
fn test_wallet_create_funded_psbt(cl: &Client) {

json/src/lib.rs

+11-4
Original file line numberDiff line numberDiff line change
@@ -833,23 +833,30 @@ impl SignRawTransactionResult {
833833
#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
834834
pub struct TestMempoolAcceptResult {
835835
pub txid: bitcoin::Txid,
836-
pub allowed: bool,
837-
#[serde(rename = "reject-reason")]
838-
pub reject_reason: Option<String>,
836+
pub wtxid: bitcoin::Txid,
837+
#[serde(rename = "package-error")]
838+
pub package_error: Option<String>,
839+
pub allowed: Option<bool>,
839840
/// Virtual transaction size as defined in BIP 141 (only present when 'allowed' is true)
840841
/// Added in Bitcoin Core v0.21
841842
pub vsize: Option<u64>,
842843
/// Transaction fees (only present if 'allowed' is true)
843844
/// Added in Bitcoin Core v0.21
844845
pub fees: Option<TestMempoolAcceptResultFees>,
846+
#[serde(rename = "reject-reason")]
847+
pub reject_reason: Option<String>,
845848
}
846849

847850
#[derive(Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]
848851
pub struct TestMempoolAcceptResultFees {
849852
/// Transaction fee in BTC
850853
#[serde(with = "bitcoin::amount::serde::as_btc")]
851854
pub base: Amount,
852-
// unlike GetMempoolEntryResultFees, this only has the `base` fee
855+
/// The effective feerate per KvB
856+
#[serde(rename = "effective-feerate", with = "bitcoin::amount::serde::as_btc")]
857+
pub effective_feerate: Amount,
858+
#[serde(rename = "effective-includes")]
859+
pub effective_includes: Vec<String>,
853860
}
854861

855862
#[derive(Copy, Clone, PartialEq, Eq, Debug, Deserialize, Serialize)]

0 commit comments

Comments
 (0)