Skip to content

Commit

Permalink
feat: detect already spent swap outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1011 committed Jul 9, 2024
1 parent 6efe35b commit 72c4d75
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 56 deletions.
28 changes: 26 additions & 2 deletions src/boltz/api.rs

Large diffs are not rendered by default.

15 changes: 10 additions & 5 deletions src/chain/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use serde_json::json;
use std::error::Error;
use std::fs;

use crate::chain::types::{ChainBackend, NetworkInfo, ZmqNotification};
use crate::chain::types::{ChainBackend, NetworkInfo, TransactionBroadcastError, ZmqNotification};
use crate::chain::zmq::ZmqClient;

enum StringOrU64 {
Expand All @@ -31,8 +31,8 @@ impl Serialize for StringOrU64 {
}

#[derive(Deserialize)]
struct RpcError {
message: String,
pub struct RpcError {
pub message: String,
}

#[derive(Deserialize)]
Expand Down Expand Up @@ -149,10 +149,15 @@ impl ChainBackend for ChainClient {
crate::chain::utils::parse_hex(block_hex)
}

async fn send_raw_transaction(&self, hex: String) -> Result<String, Box<dyn Error>> {
self.clone()
async fn send_raw_transaction(&self, hex: String) -> Result<String, TransactionBroadcastError> {
match self
.clone()
.request_params::<String>("sendrawtransaction", vec![hex])
.await
{
Ok(res) => Ok(res),
Err(err) => Err(err.into()),
}
}

async fn get_transaction(&self, hash: String) -> Result<Transaction, Box<dyn Error>> {
Expand Down
Loading

0 comments on commit 72c4d75

Please sign in to comment.