Rusty Russell [ARCHIVE] on Nostr: 📅 Original date posted:2015-08-30 📝 Original message: Pierre <pm+lists at ...
📅 Original date posted:2015-08-30
📝 Original message:
Pierre <pm+lists at acinq.fr> writes:
> Thanks, this helps a lot !
>
> I have more questions after reviewing your new branch 'state', if you have
> time for that ;-)
>
> 1) In PKT_UPDATE_ADD_HTLC, why is the field amount an int32 and not an
> uint32 ? the value shouldn't be negative right ?
Indeed! Thanks, fixed (see below for patch).
> 2) For a given payee, is the (simplified) htlc flow always :
>
> A->B PKT_UPDATE_ADD_HTLC
> B->A PKT_UPDATE_COMPLETE_HTLC
> A->B PKT_UPDATE_ADD_HTLC
> B->A PKT_UPDATE_COMPLETE_HTLC ?
>
> can we have two successive PKT_UPDATE_ADD_HTLC with the same H, the latter
> updating the former ? and then a single completion ?
That's not quite right.
Adding an HTLC goes like so:
A: PKT_UPDATE_ADD_HTLC
B: PKT_UPDATE_ACCEPT (or PKT_UPDATE_DECLINE_HTLC, in which case end)
A: PKT_UPDATE_SIGNATURE
B: PKT_UPDATE_COMPLETE
There are three ways to remove it.
It has timed out, so A wants to cancel it:
A: PKT_UPDATE_TIMEDOUT_HTLC
OR, B finally gets a failure upstream, so wants to cancel it:
B: PKT_UPDATE_ROUTEFAIL_HTLC
OR, B gets the R value, and wants to compleete it:
B: PKT_UPDATE_COMPLETE_HTLC
All these cases lead to the
PKT_UPDATE_ACCEPT/PKT_UPDATE_SIGNATURE/PKT_UPDATE_COMPLETE sequence.
I will rename PKT_UPDATE_COMPLETE_HTLC to PKT_UPDATE_FULFILL_HTLC which
avoids overloading "COMPLETE".
> 3) Since an htlc is completed with a PKT_UPDATE_COMPLETE_HTLC, what is the
> use case of PKT_UPDATE ?
PKT_UPDATE is a non-htlc transfer. It was useful for writing test
utilities, but I've actually now taken it out of the state machine since
it's not useful in practice.
So all updates are now HTLC updates..
> 4) Why is there no PKT_UPDATE_DECLINE ?
See above.
> 5) I understand the High/Low priorities are a way of resolving conflicts,
> but I don't get how it works. Could you please explain the principle of it ?
Sure. The protocol can only do one update at a time. In the case where
we both propose an update, we need to decide which goes first.
Thus, each peer alternates between high and low priority states. If
you're high priority, your update takes precedence. Arbitrarily, the
anchor funder starts in high priority, the other one in low priority.
> 6) In a closing by mutual consent, who is supposed to publish the final
> transaction ?
Both sides should publish (they should be identical anyway, but it
doesn't matter).
> 7) How do we manage the fees ?
That's mainly unresolved. A node will decline if not enough fees are
offered, but how those are advertised (and how routes are advertised) is
still TBA.
We'll probably implement fixed fees and terrible routing to begin with.
Cheers,
Rusty.
Subject: protocol: HTLC amounts can't be negative.
Reported-by: Pierre <pm+lists at acinq.fr>
Signed-off-by: Rusty Russell <rusty at rustcorp.com.au>
diff --git a/lightning.pb-c.c b/lightning.pb-c.c
index b601697..3108aa5 100644
--- a/lightning.pb-c.c
+++ b/lightning.pb-c.c
@@ -1711,7 +1711,7 @@ static const ProtobufCFieldDescriptor update_add_htlc__field_descriptors[4] =
"amount",
2,
PROTOBUF_C_LABEL_REQUIRED,
- PROTOBUF_C_TYPE_INT32,
+ PROTOBUF_C_TYPE_UINT32,
0, /* quantifier_offset */
offsetof(UpdateAddHtlc, amount),
NULL,
diff --git a/lightning.pb-c.h b/lightning.pb-c.h
index 05b0a58..77a6c7b 100644
--- a/lightning.pb-c.h
+++ b/lightning.pb-c.h
@@ -278,7 +278,7 @@ struct _UpdateAddHtlc
/*
* Amount for htlc
*/
- int32_t amount;
+ uint32_t amount;
/*
* Hash for HTLC R value.
*/
diff --git a/lightning.proto b/lightning.proto
index 4388c5c..86ca52e 100644
--- a/lightning.proto
+++ b/lightning.proto
@@ -113,7 +113,7 @@ message update_add_htlc {
// Hash for which I will supply preimage to revoke this commitment tx.
required sha256_hash revocation_hash = 1;
// Amount for htlc
- required int32 amount = 2;
+ required uint32 amount = 2;
// Hash for HTLC R value.
required sha256_hash r_hash = 3;
// Time at which HTLC expires (absolute)
Published at
2023-06-09 12:44:13Event JSON
{
"id": "b0168f9945e8d33ce1563cd48630314f827507abd77a3a0e9190b01859068cfd",
"pubkey": "13bd8c1c5e3b3508a07c92598647160b11ab0deef4c452098e223e443c1ca425",
"created_at": 1686314653,
"kind": 1,
"tags": [
[
"e",
"411039e29beedd756d6465ad4673665a870719132c14b04854b4a23ce0f88d89",
"",
"root"
],
[
"e",
"3696c4268bb915c4b4d1e7af6549174d1f919bb0b46bcc80e548851634aad5ec",
"",
"reply"
],
[
"p",
"208e7a4699791a0264a0298ffa60456c51ac8d8992096a1b67389965eccc82ff"
]
],
"content": "📅 Original date posted:2015-08-30\n📝 Original message:\nPierre \u003cpm+lists at acinq.fr\u003e writes:\n\u003e Thanks, this helps a lot !\n\u003e\n\u003e I have more questions after reviewing your new branch 'state', if you have\n\u003e time for that ;-)\n\u003e\n\u003e 1) In PKT_UPDATE_ADD_HTLC, why is the field amount an int32 and not an\n\u003e uint32 ? the value shouldn't be negative right ?\n\nIndeed! Thanks, fixed (see below for patch).\n\n\u003e 2) For a given payee, is the (simplified) htlc flow always :\n\u003e\n\u003e A-\u003eB PKT_UPDATE_ADD_HTLC\n\u003e B-\u003eA PKT_UPDATE_COMPLETE_HTLC\n\u003e A-\u003eB PKT_UPDATE_ADD_HTLC\n\u003e B-\u003eA PKT_UPDATE_COMPLETE_HTLC ?\n\u003e\n\u003e can we have two successive PKT_UPDATE_ADD_HTLC with the same H, the latter\n\u003e updating the former ? and then a single completion ?\n\nThat's not quite right.\n\nAdding an HTLC goes like so:\n\nA: PKT_UPDATE_ADD_HTLC\nB: PKT_UPDATE_ACCEPT (or PKT_UPDATE_DECLINE_HTLC, in which case end)\nA: PKT_UPDATE_SIGNATURE\nB: PKT_UPDATE_COMPLETE\n\nThere are three ways to remove it.\n\nIt has timed out, so A wants to cancel it:\nA: PKT_UPDATE_TIMEDOUT_HTLC \n\nOR, B finally gets a failure upstream, so wants to cancel it:\nB: PKT_UPDATE_ROUTEFAIL_HTLC\n\nOR, B gets the R value, and wants to compleete it:\nB: PKT_UPDATE_COMPLETE_HTLC\n\nAll these cases lead to the\nPKT_UPDATE_ACCEPT/PKT_UPDATE_SIGNATURE/PKT_UPDATE_COMPLETE sequence.\n\nI will rename PKT_UPDATE_COMPLETE_HTLC to PKT_UPDATE_FULFILL_HTLC which\navoids overloading \"COMPLETE\".\n\n\u003e 3) Since an htlc is completed with a PKT_UPDATE_COMPLETE_HTLC, what is the\n\u003e use case of PKT_UPDATE ?\n\nPKT_UPDATE is a non-htlc transfer. It was useful for writing test\nutilities, but I've actually now taken it out of the state machine since\nit's not useful in practice.\n\nSo all updates are now HTLC updates..\n\n\u003e 4) Why is there no PKT_UPDATE_DECLINE ?\n\nSee above.\n\n\u003e 5) I understand the High/Low priorities are a way of resolving conflicts,\n\u003e but I don't get how it works. Could you please explain the principle of it ?\n\nSure. The protocol can only do one update at a time. In the case where\nwe both propose an update, we need to decide which goes first.\n\nThus, each peer alternates between high and low priority states. If\nyou're high priority, your update takes precedence. Arbitrarily, the\nanchor funder starts in high priority, the other one in low priority.\n\n\u003e 6) In a closing by mutual consent, who is supposed to publish the final\n\u003e transaction ?\n\nBoth sides should publish (they should be identical anyway, but it\ndoesn't matter).\n\n\u003e 7) How do we manage the fees ?\n\nThat's mainly unresolved. A node will decline if not enough fees are\noffered, but how those are advertised (and how routes are advertised) is\nstill TBA.\n\nWe'll probably implement fixed fees and terrible routing to begin with.\n\nCheers,\nRusty.\n\nSubject: protocol: HTLC amounts can't be negative.\n\nReported-by: Pierre \u003cpm+lists at acinq.fr\u003e\nSigned-off-by: Rusty Russell \u003crusty at rustcorp.com.au\u003e\n\ndiff --git a/lightning.pb-c.c b/lightning.pb-c.c\nindex b601697..3108aa5 100644\n--- a/lightning.pb-c.c\n+++ b/lightning.pb-c.c\n@@ -1711,7 +1711,7 @@ static const ProtobufCFieldDescriptor update_add_htlc__field_descriptors[4] =\n \"amount\",\n 2,\n PROTOBUF_C_LABEL_REQUIRED,\n- PROTOBUF_C_TYPE_INT32,\n+ PROTOBUF_C_TYPE_UINT32,\n 0, /* quantifier_offset */\n offsetof(UpdateAddHtlc, amount),\n NULL,\ndiff --git a/lightning.pb-c.h b/lightning.pb-c.h\nindex 05b0a58..77a6c7b 100644\n--- a/lightning.pb-c.h\n+++ b/lightning.pb-c.h\n@@ -278,7 +278,7 @@ struct _UpdateAddHtlc\n /*\n * Amount for htlc\n */\n- int32_t amount;\n+ uint32_t amount;\n /*\n * Hash for HTLC R value.\n */\ndiff --git a/lightning.proto b/lightning.proto\nindex 4388c5c..86ca52e 100644\n--- a/lightning.proto\n+++ b/lightning.proto\n@@ -113,7 +113,7 @@ message update_add_htlc {\n // Hash for which I will supply preimage to revoke this commitment tx.\n required sha256_hash revocation_hash = 1;\n // Amount for htlc\n- required int32 amount = 2;\n+ required uint32 amount = 2;\n // Hash for HTLC R value.\n required sha256_hash r_hash = 3;\n // Time at which HTLC expires (absolute)",
"sig": "fdd3765305ec427537aec9f6bb02c344e313ba4a8ffa44c420b2e9234c014cae5390c0b60372f6918654965bfa7bb51020c270d4b91f37570bbbcc63b501ab94"
}