Skip to content

Commit 2cd778e

Browse files
authored
Merge pull request #13 from valentinewallace/fix-broadcast-tx-panic
Don't panic if broadcast_transaction fails due to duplicate broadcasts
2 parents c3218f2 + 198a839 commit 2cd778e

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/bitcoind_client.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,20 @@ impl BroadcasterInterface for BitcoindClient {
238238
let tx_serialized = serde_json::json!(encode::serialize_hex(tx));
239239
tokio::spawn(async move {
240240
let mut rpc = bitcoind_rpc_client.lock().await;
241-
rpc.call_method::<RawTx>("sendrawtransaction", &vec![tx_serialized]).await.unwrap();
241+
// This may error due to RL calling `broadcast_transaction` with the same transaction
242+
// multiple times, but the error is safe to ignore.
243+
match rpc.call_method::<RawTx>("sendrawtransaction", &vec![tx_serialized]).await {
244+
Ok(_) => {}
245+
Err(e) => {
246+
let err_str = e.get_ref().unwrap().to_string();
247+
if !err_str.contains("Transaction already in block chain")
248+
&& !err_str.contains("Inputs missing or spent")
249+
&& !err_str.contains("non-BIP68-final")
250+
{
251+
panic!("{}", e);
252+
}
253+
}
254+
}
242255
});
243256
}
244257
}

0 commit comments

Comments
 (0)