-
Notifications
You must be signed in to change notification settings - Fork 10
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
Add an 'id' field to commando requests #22
Open
niftynei
wants to merge
2
commits into
jb55:master
Choose a base branch
from
niftynei:nifty/go_id
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jb55
reviewed
Jul 5, 2023
commando.c
Outdated
@@ -27,6 +27,8 @@ int EXPORT commando_make_rpc_msg(const char *method, const char *params, | |||
cursor_push_str(&msgbuf, params) && | |||
cursor_push_str(&msgbuf, ",\"rune\":\"") && | |||
cursor_push_str(&msgbuf, rune) && | |||
cursor_push_str(&msgbuf, "\",\"id\":\"") && | |||
cursor_push_u64(&msgbuf, (u64)req_id) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this won't push a string, this pushes a raw u64
Is that ok if it’s encased in quotes? I should have read the underlying
routine…
…On Tue, Jul 4, 2023 at 20:00 William Casarin ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In commando.c
<#22 (comment)>:
> @@ -27,6 +27,8 @@ int EXPORT commando_make_rpc_msg(const char *method, const char *params,
cursor_push_str(&msgbuf, params) &&
cursor_push_str(&msgbuf, ",\"rune\":\"") &&
cursor_push_str(&msgbuf, rune) &&
+ cursor_push_str(&msgbuf, "\",\"id\":\"") &&
+ cursor_push_u64(&msgbuf, (u64)req_id) &&
this won't push a string, this pushes a raw u64
—
Reply to this email directly, view it on GitHub
<#22 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIMAKPIKEDV2H7AEEEZJL3XOSVCZANCNFSM6AAAAAAZ6G5J3I>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
On Tue, Jul 04, 2023 at 05:20:20PM -0700, neil saitug wrote:
Is that ok if it’s encased in quotes? I should have read the underlying
routine…
you would need to sprintf it like you did on the golang side
|
niftynei
force-pushed
the
nifty/go_id
branch
2 times, most recently
from
November 10, 2023 22:34
dd1ccf9
to
88fe3d5
Compare
Updated: now the |
On Tue, Jul 04, 2023 at 07:09:40PM -0400, niftynei wrote:
turn the type from int to string -> print directly to CLN
Closes: #22
---
commando.c | 7 +++++--
commando.h | 2 +-
dist/js/lnsocket.js | 6 +++---
dist/js/lnsocket.wasm | Bin 147919 -> 142399 bytes
4 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/commando.c b/commando.c
index 9112498..6fbfd9f 100644
--- a/commando.c
+++ b/commando.c
@@ -4,9 +4,10 @@
#include "endian.h"
#include "commando.h"
#include "export.h"
+#include <stdio.h>
int EXPORT commando_make_rpc_msg(const char *method, const char *params,
- const char *rune, unsigned int req_id, unsigned char *buf, int buflen)
+ const char *rune, const char *req_id, unsigned char *buf, int buflen)
{
struct cursor msgbuf;
int ok;
@@ -27,7 +28,9 @@ int EXPORT commando_make_rpc_msg(const char *method, const char *params,
cursor_push_str(&msgbuf, params) &&
cursor_push_str(&msgbuf, ",\"rune\":\"") &&
cursor_push_str(&msgbuf, rune) &&
- cursor_push_str(&msgbuf, "\",\"id\":\"d0\",\"jsonrpc\":\"2.0\"}");
+ cursor_push_str(&msgbuf, "\",\"id\":\"") &&
+ cursor_push_str(&msgbuf, req_id) &&
Is this still a number? If so we can just use a temporary buffer to
sprintf a number like we do on the golang side? Otherwise this breaks
the API.
|
I think any string is valid now? Yeah it definitely breaks the API for users downstream of the C library. |
On Thu, Nov 30, 2023 at 11:32:51AM -0800, neil saitug wrote:
> Is this still a number?
I think any string is valid now? Yeah it definitely breaks the API for
users downstream of the C library.
ok, good to know. thanks!
|
niftynei
force-pushed
the
nifty/go_id
branch
2 times, most recently
from
November 30, 2023 21:23
0a672a7
to
2396322
Compare
turn the type from int to string -> print directly to CLN
Lets us send a bunch of messages at once (but currently incredibly not thread safe lol)
niftynei
force-pushed
the
nifty/go_id
branch
from
November 30, 2023 21:25
2396322
to
d12e152
Compare
On Tue, Jul 04, 2023 at 06:30:50PM -0400, niftynei wrote:
diff --git a/go/lnsocket.go b/go/lnsocket.go
index 7947866..7083e09 100644
--- a/go/lnsocket.go
+++ b/go/lnsocket.go
@@ -57,7 +57,9 @@ func (msg *CommandoMsg) Encode(buf *bytes.Buffer, pver uint32) error {
buf.WriteString(msg.Params)
buf.WriteString(",\"rune\":\"")
buf.WriteString(msg.Rune)
- buf.WriteString("\",\"id\":\"d0\",\"jsonrpc\":\"2.0\"}")
+ buf.WriteString("\",\"id\":\"")
+ buf.WriteString(fmt.Sprintf("%d", msg.RequestId))
If RequestId is a string, I think we need to update RequestId to a
string like we do in the C version.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Tested for the golang one, the commando one probably needs some more test runs.
Fixes the error where
commando
requires anid
field at the top level for calls.