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

fix: tip function sent unwanted amount and expected wrong response #253

Merged
merged 1 commit into from
Mar 1, 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
12 changes: 10 additions & 2 deletions coffee_core/src/coffee.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//! Coffee mod implementation
use std::collections::HashMap;
use std::fmt::Debug;
use std::vec::Vec;

Check warning on line 4 in coffee_core/src/coffee.rs

View workflow job for this annotation

GitHub Actions / Build (nightly)

the item `Vec` is imported redundantly

Check warning on line 4 in coffee_core/src/coffee.rs

View workflow job for this annotation

GitHub Actions / Build (nightly)

the item `Vec` is imported redundantly
use tokio::fs;

use async_trait::async_trait;
use clightningrpc_common::client::Client;
use clightningrpc_common::json_utils;
use clightningrpc_conf::{CLNConf, SyncCLNConf};
use log;

Check warning on line 11 in coffee_core/src/coffee.rs

View workflow job for this annotation

GitHub Actions / Build (nightly)

the item `log` is imported redundantly

Check warning on line 11 in coffee_core/src/coffee.rs

View workflow job for this annotation

GitHub Actions / Build (nightly)

the item `log` is imported redundantly
use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize};
use serde_json::json;
Expand Down Expand Up @@ -586,15 +586,23 @@
}),
)
.await?;
let tip: CoffeeTip = self
let pay: PayResponse = self
.cln(
"pay",
json!({
"bolt11": invoice.invoice,
"amount_msat": amount_msat,
}),
)
.await?;
let tip = CoffeeTip {
for_plugin: plugin.name(),
invoice: invoice.invoice,
status: pay.status,
destination: pay.destination,
amount_msat: pay.amount_msat,
amount_sent_msat: pay.amount_sent_msat,
warning_partial_completion: pay.warning_partial_completion,
};
Ok(tip)
}

Expand Down
13 changes: 13 additions & 0 deletions coffee_lib/src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,17 @@ pub mod response {
pub amount_sent_msat: u64,
pub warning_partial_completion: Option<String>,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct PayResponse {
pub payment_preimage: String,
pub destination: Option<String>,
pub payment_hash: String,
pub created_at: f64,
pub parts: u32,
pub amount_msat: u64,
pub amount_sent_msat: u64,
pub warning_partial_completion: Option<String>,
pub status: String,
}
}
Loading