Skip to content
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
20 changes: 15 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ members = [
"libs/gl-plugin",
"libs/gl-signerproxy",
"libs/gl-cli",
"libs/gl-util",
]

[workspace.dependencies]
Expand Down
12 changes: 6 additions & 6 deletions libs/gl-client-py/tests/test_plugin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from gltesting.fixtures import *
from pyln.testing.utils import wait_for
from pyln import grpc as clnpb
import grpc
import pytest
import secrets
from pathlib import Path
Expand Down Expand Up @@ -92,7 +93,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.
assert len(res.payment_hash) == 32 # There was a confusion about hex/bytes return.

l2.rpc.unsetchecks()

Expand Down Expand Up @@ -124,7 +125,9 @@ def test_trampoline_pay(bitcoind, clients, node_factory):

# calling `trampoline_pay` with an unkown tmrp_node_id must fail.
with pytest.raises(
expected_exception=ValueError, match=r"Peer error: No such peer"
expected_exception=ValueError,

match=f"Unknown peer {l3.info['id']}",
):
res = n1.trampoline_pay(inv["bolt11"], bytes.fromhex(l3.info["id"]))

Expand All @@ -134,13 +137,10 @@ def test_trampoline_pay(bitcoind, clients, node_factory):
# trampoline payments must fail.
with pytest.raises(
expected_exception=ValueError,
match=r"Features \\\"[a-f0-9]+\\\" do not contain feature bit 427",
match="Peer doesn't suport trampoline payments",
):
res = n1.trampoline_pay(inv["bolt11"], bytes.fromhex(l3.info["id"]))

res = n1.listpays()
print(f"LISTPAYS: {res}")


def test_trampoline_multi_htlc(bitcoind, clients, node_factory):
c1 = clients.new()
Expand Down
1 change: 1 addition & 0 deletions libs/gl-plugin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ cln-rpc = { workspace = true }
env_logger = "^0.7.1"
futures = "0.3"
gl-client = { version = "^0.3.0", path = "../gl-client" }
gl-util = { version = "0.1", path = "../gl-util" }
governor = { version = "0.5", default-features = false, features = ["std"] }
hex = "0.4"
hyper = "0.14.28"
Expand Down
13 changes: 9 additions & 4 deletions libs/gl-plugin/src/awaitables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ const RPC_CALL_DELAY_MSEC: u64 = 250;

#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error("Peer error: {0}")]
Peer(&'static str),
#[error("Unknown peer {0}")]
PeerUnknown(String),
#[error("Can't connect to peer {0}")]
PeerConnectionFailure(String),
#[error("Channel error: {0}")]
Channel(&'static str),
#[error("RPC error: {0}")]
Expand Down Expand Up @@ -270,7 +272,10 @@ async fn ensure_peer_connection(
level: None,
})
.await?;
let peer = res.peers.first().ok_or(Error::Peer("No such peer"))?;
let peer = res
.peers
.first()
.ok_or(Error::PeerUnknown(peer_id.to_string()))?;

if !peer.connected {
log::debug!("Peer {} is not connected, connecting", peer_id);
Expand All @@ -282,7 +287,7 @@ async fn ensure_peer_connection(
let res = rpc
.call_typed(&req)
.await
.map_err(|_| Error::Peer("unable to connect"))?;
.map_err(|_| Error::PeerConnectionFailure(peer_id.to_string()))?;

log::debug!("Connect call to {} resulted in {:?}", peer_id, res);
}
Expand Down
2 changes: 1 addition & 1 deletion libs/gl-plugin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub mod responses;
pub mod stager;
pub mod storage;
pub mod tlv;
mod tramp;
pub mod tramp;
#[cfg(unix)]
mod unix;

Expand Down
26 changes: 10 additions & 16 deletions libs/gl-plugin/src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,30 +555,24 @@ 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())
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) => {
debug!("Trampoline payment successful");
Ok(tonic::Response::new(pb::TrampolinePayResponse {
.map(cln_rpc::model::responses::PayResponse::into)
.map(|res: cln_grpc::pb::PayResponse| {
tonic::Response::new(pb::TrampolinePayResponse {
payment_preimage: res.payment_preimage,
payment_hash: res.payment_hash,
created_at: res.created_at,
parts: res.parts,
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) => {
debug!("Trampoline payment failed: {}", e);
Err(Status::new(Code::Unknown, e.to_string()))
}
}
})
})
.map_err(|err| {
debug!("Trampoline payment failed: {}", err);
err.into()
})
}
}

Expand Down
Loading
Loading