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

Trampoline: Return payment_hash as bytes directly #511

Merged
merged 1 commit into from
Sep 4, 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
1 change: 1 addition & 0 deletions libs/gl-client-py/tests/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def test_trampoline_pay(bitcoind, clients, node_factory):

res = n1.trampoline_pay(inv["bolt11"], bytes.fromhex(l2.info["id"]))
assert res
assert len(res.payment_hash) == 32 # There was a confusion about hex/bytes return.

l2.rpc.unsetchecks()

Expand Down
31 changes: 17 additions & 14 deletions libs/gl-plugin/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,11 +395,11 @@ impl Node for PluginNodeServer {
) -> Result<Response<pb::Empty>, Status> {
let req = request.into_inner();

if req.error != "" {
log::error!("Signer reports an error: {}", req.error);
log::warn!("The above error was returned instead of a response.");
return Ok(Response::new(pb::Empty::default()));
}
if req.error != "" {
log::error!("Signer reports an error: {}", req.error);
log::warn!("The above error was returned instead of a response.");
return Ok(Response::new(pb::Empty::default()));
}

// Create a state from the key-value-version tuples. Need to
// convert here, since `pb` is duplicated in the two different
Expand Down Expand Up @@ -566,18 +566,21 @@ impl Node for PluginNodeServer {
&self,
r: tonic::Request<pb::TrampolinePayRequest>,
) -> Result<tonic::Response<pb::TrampolinePayResponse>, Status> {
match tramp::trampolinepay(r.into_inner(), self.rpc_path.clone()).await {
match tramp::trampolinepay(r.into_inner(), self.rpc_path.clone())
.await
.map(|res| {
<cln_rpc::model::responses::PayResponse as Into<cln_grpc::pb::PayResponse>>::into(
res,
)
}) {
Ok(res) => Ok(tonic::Response::new(pb::TrampolinePayResponse {
payment_preimage: res.payment_preimage.to_vec(),
payment_hash: res.payment_hash.to_hex().into_bytes(),
payment_preimage: res.payment_preimage,
payment_hash: res.payment_hash,
created_at: res.created_at,
parts: res.parts,
amount_msat: res.amount_msat.msat(),
amount_sent_msat: res.amount_sent_msat.msat(),
destination: res
.destination
.map(|d| d.to_hex().into_bytes())
.unwrap_or_default(),
amount_msat: res.amount_msat.unwrap_or_default().msat,
amount_sent_msat: res.amount_sent_msat.unwrap_or_default().msat,
destination: res.destination.unwrap_or_default(),
})),
Err(e) => Err(Status::new(Code::Unknown, e.to_string())),
}
Expand Down
Loading