Skip to content
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

Webhooks #63

Merged
merged 2 commits into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
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
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
Loading