Skip to content

Commit 71c7f30

Browse files
daywalker90vincenzopalazzo
authored andcommitted
fix: tip function sent unwanted amount and expected wrong response
When fetching an invoice with an amount and then paying that invoice cln will error if you sent an amount on the pay command aswell Tip also expected an incompatible CoffeeTip response from pay e.g. pay does not have a field 'for_plugin'
1 parent e14d7d5 commit 71c7f30

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

coffee_core/src/coffee.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -586,15 +586,23 @@ impl PluginManager for CoffeeManager {
586586
}),
587587
)
588588
.await?;
589-
let tip: CoffeeTip = self
589+
let pay: PayResponse = self
590590
.cln(
591591
"pay",
592592
json!({
593593
"bolt11": invoice.invoice,
594-
"amount_msat": amount_msat,
595594
}),
596595
)
597596
.await?;
597+
let tip = CoffeeTip {
598+
for_plugin: plugin.name(),
599+
invoice: invoice.invoice,
600+
status: pay.status,
601+
destination: pay.destination,
602+
amount_msat: pay.amount_msat,
603+
amount_sent_msat: pay.amount_sent_msat,
604+
warning_partial_completion: pay.warning_partial_completion,
605+
};
598606
Ok(tip)
599607
}
600608

coffee_lib/src/types/mod.rs

+13
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,17 @@ pub mod response {
258258
pub amount_sent_msat: u64,
259259
pub warning_partial_completion: Option<String>,
260260
}
261+
262+
#[derive(Clone, Debug, Serialize, Deserialize)]
263+
pub struct PayResponse {
264+
pub payment_preimage: String,
265+
pub destination: Option<String>,
266+
pub payment_hash: String,
267+
pub created_at: f64,
268+
pub parts: u32,
269+
pub amount_msat: u64,
270+
pub amount_sent_msat: u64,
271+
pub warning_partial_completion: Option<String>,
272+
pub status: String,
273+
}
261274
}

0 commit comments

Comments
 (0)