mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-02-13 05:11:24 -05:00
Add cancel_refund RPC endpoint
This commit is contained in:
parent
7193866c30
commit
63c1edbdd3
@ -30,7 +30,7 @@ pub fn register_modules(context: Arc<Context>) -> RpcModule<Arc<Context>> {
|
||||
.register_async_method("get_raw_history", |_, context| async move {
|
||||
get_raw_history(&context).await
|
||||
})
|
||||
.expect("Could not register RPC method get_history");
|
||||
.expect("Could not register RPC method get_raw_history");
|
||||
|
||||
module
|
||||
.register_async_method("get_seller", |params, context| async move {
|
||||
@ -67,6 +67,17 @@ pub fn register_modules(context: Arc<Context>) -> RpcModule<Arc<Context>> {
|
||||
resume_swap(*swap_id, &context).await
|
||||
})
|
||||
.expect("Could not register RPC method resume_swap");
|
||||
module
|
||||
.register_async_method("cancel_refund_swap", |params, context| async move {
|
||||
let params: HashMap<String, Uuid> = params.parse()?;
|
||||
|
||||
let swap_id = params.get("swap_id").ok_or_else(|| {
|
||||
jsonrpsee_core::Error::Custom("Does not contain swap_id".to_string())
|
||||
})?;
|
||||
|
||||
cancel_and_refund_swap(*swap_id, &context).await
|
||||
})
|
||||
.expect("Could not register RPC method cancel_refund_swap");
|
||||
module
|
||||
.register_async_method("withdraw_btc", |params, context| async move {
|
||||
let params: HashMap<String, String> = params.parse()?;
|
||||
@ -209,6 +220,17 @@ async fn resume_swap(
|
||||
execute_request(Method::Resume, params, context).await
|
||||
}
|
||||
|
||||
async fn cancel_and_refund_swap(
|
||||
swap_id: Uuid,
|
||||
context: &Arc<Context>,
|
||||
) -> Result<serde_json::Value, jsonrpsee_core::Error> {
|
||||
let params = Params {
|
||||
swap_id: Some(swap_id),
|
||||
..Default::default()
|
||||
};
|
||||
execute_request(Method::CancelAndRefund, params, context).await
|
||||
}
|
||||
|
||||
async fn withdraw_btc(
|
||||
withdraw_address: bitcoin::Address,
|
||||
amount: Option<bitcoin::Amount>,
|
||||
|
Loading…
x
Reference in New Issue
Block a user