Skip to content

Don't panic if broadcast_transaction fails due to duplicate broadcasts #13

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

Merged
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
15 changes: 14 additions & 1 deletion src/bitcoind_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,20 @@ impl BroadcasterInterface for BitcoindClient {
let tx_serialized = serde_json::json!(encode::serialize_hex(tx));
tokio::spawn(async move {
let mut rpc = bitcoind_rpc_client.lock().await;
rpc.call_method::<RawTx>("sendrawtransaction", &vec![tx_serialized]).await.unwrap();
// This may error due to RL calling `broadcast_transaction` with the same transaction
// multiple times, but the error is safe to ignore.
match rpc.call_method::<RawTx>("sendrawtransaction", &vec![tx_serialized]).await {
Ok(_) => {}
Err(e) => {
let err_str = e.get_ref().unwrap().to_string();
if !err_str.contains("Transaction already in block chain")
&& !err_str.contains("Inputs missing or spent")
&& !err_str.contains("non-BIP68-final")
{
panic!("{}", e);
}
}
}
});
}
}