Skip to content

Commit

Permalink
Webhooks (#63)
Browse files Browse the repository at this point in the history
* Add optional webhook to create request

* Make hash_swap_id optional
  • Loading branch information
dangeross authored Jul 24, 2024
1 parent d6092c7 commit d666868
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/swaps/boltz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,14 @@ pub struct MrhResponse {
pub signature: String,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Webhook {
pub url: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub hash_swap_id: Option<bool>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CreateSubmarineRequest {
Expand All @@ -598,6 +606,8 @@ pub struct CreateSubmarineRequest {
pub pair_hash: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub referral_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub webhook: Option<Webhook>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down Expand Up @@ -693,6 +703,8 @@ pub struct CreateReverseRequest {
pub address_signature: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub referral_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub webhook: Option<Webhook>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down Expand Up @@ -780,6 +792,8 @@ pub struct CreateChainRequest {
pub pair_hash: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub referral_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub webhook: Option<Webhook>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down
2 changes: 2 additions & 0 deletions tests/bitcoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ fn bitcoin_v2_submarine() {
refund_public_key,
pair_hash: None,
referral_id: None,
webhook: None,
};

let create_swap_response = boltz_api_v2.post_swap_req(&create_swap_req).unwrap();
Expand Down Expand Up @@ -267,6 +268,7 @@ fn bitcoin_v2_reverse() {
address: Some(claim_address.clone()),
claim_public_key,
referral_id: None, // Add address signature here.
webhook: None,
};

let boltz_api_v2 = BoltzApiClientV2::new(BOLTZ_TESTNET_URL_V2);
Expand Down
2 changes: 2 additions & 0 deletions tests/chain_swaps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ fn bitcoin_liquid_v2_chain() {
user_lock_amount: Some(1000000),
server_lock_amount: None,
pair_hash: None, // Add address signature here.
webhook: None,
};

let boltz_api_v2 = BoltzApiClientV2::new(BOLTZ_TESTNET_URL_V2);
Expand Down Expand Up @@ -280,6 +281,7 @@ fn liquid_bitcoin_v2_chain() {
user_lock_amount: Some(1000000),
server_lock_amount: None,
pair_hash: None, // Add address signature here.
webhook: None,
};

let boltz_api_v2 = BoltzApiClientV2::new(BOLTZ_TESTNET_URL_V2);
Expand Down
2 changes: 2 additions & 0 deletions tests/liquid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ fn liquid_v2_submarine() {
refund_public_key,
pair_hash: None,
referral_id: None,
webhook: None,
};

let create_swap_response = boltz_api_v2.post_swap_req(&create_swap_req).unwrap();
Expand Down Expand Up @@ -284,6 +285,7 @@ fn liquid_v2_reverse() {
address: Some(claim_address.clone()),
claim_public_key,
referral_id: None,
webhook: None,
};

let reverse_resp = boltz_api_v2.post_reverse_req(create_reverse_req).unwrap();
Expand Down

0 comments on commit d666868

Please sign in to comment.