update CLN to v24.05 and holdinvoice to v3.0.0

This commit is contained in:
daywalker90
2024-06-16 23:29:02 +02:00
parent 485961ee05
commit 92ada26f4a
9 changed files with 27 additions and 25 deletions

View File

@ -236,7 +236,7 @@ class CLNNode:
holdstub = hold_pb2_grpc.HoldStub(cls.hold_channel)
response = holdstub.HoldInvoiceCancel(request)
return response.state == hold_pb2.HoldInvoiceCancelResponse.Holdstate.CANCELED
return response.state == hold_pb2.Holdstate.CANCELED
@classmethod
def settle_hold_invoice(cls, preimage):
@ -247,7 +247,7 @@ class CLNNode:
holdstub = hold_pb2_grpc.HoldStub(cls.hold_channel)
response = holdstub.HoldInvoiceSettle(request)
return response.state == hold_pb2.HoldInvoiceSettleResponse.Holdstate.SETTLED
return response.state == hold_pb2.Holdstate.SETTLED
@classmethod
def gen_hold_invoice(
@ -272,7 +272,7 @@ class CLNNode:
request = hold_pb2.HoldInvoiceRequest(
description=description,
amount_msat=primitives__pb2.Amount(msat=num_satoshis * 1_000),
amount_msat=hold_pb2.Amount(msat=num_satoshis * 1_000),
label=f"Order:{order_id}-{lnpayment_concept}-{time}",
expiry=invoice_expiry,
cltv=cltv_expiry_blocks,
@ -309,13 +309,13 @@ class CLNNode:
# Will fail if 'unable to locate invoice'. Happens if invoice expiry
# time has passed (but these are 15% padded at the moment). Should catch it
# and report back that the invoice has expired (better robustness)
if response.state == hold_pb2.HoldInvoiceLookupResponse.Holdstate.OPEN:
if response.state == hold_pb2.Holdstate.OPEN:
pass
if response.state == hold_pb2.HoldInvoiceLookupResponse.Holdstate.SETTLED:
if response.state == hold_pb2.Holdstate.SETTLED:
pass
if response.state == hold_pb2.HoldInvoiceLookupResponse.Holdstate.CANCELED:
if response.state == hold_pb2.Holdstate.CANCELED:
pass
if response.state == hold_pb2.HoldInvoiceLookupResponse.Holdstate.ACCEPTED:
if response.state == hold_pb2.Holdstate.ACCEPTED:
lnpayment.expiry_height = response.htlc_expiry
lnpayment.status = LNPayment.Status.LOCKED
lnpayment.save(update_fields=["expiry_height", "status"])
@ -359,7 +359,7 @@ class CLNNode:
except Exception as e:
# If it fails at finding the invoice: it has been expired for more than an hour (and could be paid or just expired).
# In RoboSats DB we make a distinction between cancelled and returned
# (cln-grpc-hodl has separate state for hodl-invoices, which it forgets after an invoice expired more than an hour ago)
# (holdinvoice plugin has separate state for hodl-invoices, which it forgets after an invoice expired more than an hour ago)
if "empty result for listdatastore_state" in str(e):
print(str(e))
request2 = node_pb2.ListinvoicesRequest(
@ -439,7 +439,9 @@ class CLNNode:
# ...add up the cost of every hinted hop...
for hop_hint in hinted_route.hops:
route_cost += hop_hint.fee_base_msat.msat / 1_000
route_cost += hop_hint.fee_proportional_millionths * num_satoshis / 1_000_000
route_cost += (
hop_hint.fee_proportional_millionths * num_satoshis / 1_000_000
)
# ...and store the cost of the route to the array
routes_cost.append(route_cost)
@ -869,4 +871,4 @@ class CLNNode:
else:
raise e
return response.state == hold_pb2.HoldInvoiceLookupResponse.Holdstate.SETTLED
return response.state == hold_pb2.Holdstate.SETTLED

View File

@ -77,16 +77,16 @@ services:
network_mode: service:bitcoind
coordinator-CLN:
image: elementsproject/lightningd:${CLN_VERSION:-v23.08.1}
image: elementsproject/lightningd:${CLN_VERSION:-v24.05}
restart: always
container_name: coordinator-CLN
environment:
LIGHTNINGD_NETWORK: 'regtest'
volumes:
- cln:/root/.lightning
- ./docker/cln/plugins/cln-grpc-hold:/root/.lightning/plugins/cln-grpc-hold
- ./docker/cln/plugins/holdinvoice:/root/.lightning/plugins/holdinvoice
- bitcoin:/root/.bitcoin
command: --regtest --wumbo --bitcoin-rpcuser=test --bitcoin-rpcpassword=test --log-level=debug --rest-host=0.0.0.0 --rest-port=3010 --bind-addr=127.0.0.1:9737 --max-concurrent-htlcs=483 --grpc-port=9999 --grpc-hold-port=9998 --important-plugin=/root/.lightning/plugins/cln-grpc-hold --database-upgrade=true
command: --regtest --wumbo --bitcoin-rpcuser=test --bitcoin-rpcpassword=test --log-level=debug --rest-host=0.0.0.0 --rest-port=3010 --bind-addr=127.0.0.1:9737 --max-concurrent-htlcs=483 --grpc-port=9999 --grpc-hold-port=9998 --important-plugin=/root/.lightning/plugins/holdinvoice --database-upgrade=true
depends_on:
- bitcoind
network_mode: service:bitcoind

View File

@ -1,7 +1,7 @@
FROM debian:bullseye-slim as builder
ARG DEBIAN_FRONTEND=noninteractive
ARG LIGHTNINGD_VERSION=v23.08
ARG LIGHTNINGD_VERSION=v24.05
RUN apt-get update -qq && \
apt-get install -qq -y --no-install-recommends \
autoconf \
@ -18,13 +18,13 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
RUN rustup toolchain install stable --component rustfmt --allow-downgrade
WORKDIR /opt/lightningd
RUN git clone --recursive --branch cln-grpc-hold https://github.com/daywalker90/lightning.git /tmp/cln-grpc-hold
RUN cd /tmp/cln-grpc-hold \
RUN git clone https://github.com/daywalker90/holdinvoice.git /tmp/holdinvoice
RUN cd /tmp/holdinvoice \
&& cargo build --release
FROM elementsproject/lightningd:v23.08 as final
FROM elementsproject/lightningd:v24.05 as final
COPY --from=builder /tmp/cln-grpc-hold/target/release/cln-grpc-hold /tmp/cln-grpc-hold
COPY --from=builder /tmp/holdinvoice/target/release/holdinvoice /tmp/holdinvoice
COPY config /tmp/config
COPY entrypoint.sh entrypoint.sh
RUN chmod +x entrypoint.sh

View File

@ -5,6 +5,6 @@ addr=statictor:127.0.0.1:9051
grpc-port=9999
grpc-hold-port=9998
always-use-proxy=true
important-plugin=/root/.lightning/plugins/cln-grpc-hold
important-plugin=/root/.lightning/plugins/holdinvoice
# wallet=postgres://user:pass@localhost:5433/cln
# bookkeeper-db=postgres://user:pass@localhost:5433/cln

View File

@ -17,9 +17,9 @@ if [ "$EXPOSE_TCP" == "true" ]; then
socat "TCP4-listen:$LIGHTNINGD_RPC_PORT,fork,reuseaddr" "UNIX-CONNECT:${networkdatadir}/lightning-rpc" &
fg %-
else
# Always copy the cln-grpc-hodl plugin into the plugins directory on start up
# Always copy the holdinvoice plugin into the plugins directory on start up
mkdir -p /root/.lightning/plugins
cp /tmp/cln-grpc-hold /root/.lightning/plugins/cln-grpc-hold
cp /tmp/holdinvoice /root/.lightning/plugins/holdinvoice
if [ ! -f /root/.lightning/config ]; then
cp /tmp/config /root/.lightning/config
fi

Binary file not shown.

BIN
docker/cln/plugins/holdinvoice Executable file

Binary file not shown.

View File

@ -10,9 +10,9 @@ curl --parallel -o lightning.proto https://raw.githubusercontent.com/lightningne
-o router.proto https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/routerrpc/router.proto \
-o signer.proto https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/signrpc/signer.proto \
-o verrpc.proto https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/verrpc/verrpc.proto \
-o hold.proto https://raw.githubusercontent.com/daywalker90/lightning/cln-grpc-hold/proto/hold.proto \
-o primitives.proto https://raw.githubusercontent.com/ElementsProject/lightning/v23.08/cln-grpc/proto/primitives.proto \
-o node.proto https://raw.githubusercontent.com/ElementsProject/lightning/v23.08/cln-grpc/proto/node.proto
-o hold.proto https://raw.githubusercontent.com/daywalker90/holdinvoice/master/proto/hold.proto \
-o primitives.proto https://raw.githubusercontent.com/ElementsProject/lightning/v24.05/cln-grpc/proto/primitives.proto \
-o node.proto https://raw.githubusercontent.com/ElementsProject/lightning/v24.05/cln-grpc/proto/node.proto
echo -n "Done\nBuilding api from GRPC specs..."
python3 -m grpc_tools.protoc --proto_path=googleapis:. --python_out=. --grpc_python_out=. lightning.proto invoices.proto router.proto signer.proto verrpc.proto

View File

@ -2,6 +2,6 @@ ROBOSATS_ENVS_FILE=".env-sample"
BITCOIND_VERSION='24.0.1'
LND_VERSION='v0.17.0-beta'
CLN_VERSION='v23.08.1'
CLN_VERSION='v24.05'
REDIS_VERSION='7.2.1'
POSTGRES_VERSION='14.2'