Skip to content
Open
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ examples/lnsocket.wasm
examples/websockets_big.js
examples/websockets_big.html
rust/bindings.rs
Cargo.lock
Cargo.lock

*.swp
7 changes: 5 additions & 2 deletions commando.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) &&
cursor_push_str(&msgbuf, "\",\"jsonrpc\":\"2.0\"}");

if (!ok)
return 0;
Expand Down
2 changes: 1 addition & 1 deletion commando.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
#define COMMANDO_REPLY_CONTINUES 0x594b
#define COMMANDO_REPLY_TERM 0x594d

int EXPORT commando_make_rpc_msg(const char *method, const char *params, const char *rune, unsigned int req_id, unsigned char *buf, int buflen);
int EXPORT commando_make_rpc_msg(const char *method, const char *params, const char *rune, const char *id, unsigned char *buf, int buflen);

#endif /* LNSOCKET_COMMANDO */
6 changes: 3 additions & 3 deletions dist/js/lnsocket.js

Large diffs are not rendered by default.

Binary file modified dist/js/lnsocket.wasm
Binary file not shown.
10 changes: 7 additions & 3 deletions go/lnsocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/hex"
"fmt"
"io"
"math/rand"
"net"

"github.com/btcsuite/btcd/btcec/v2"
Expand All @@ -24,14 +25,15 @@ type CommandoMsg struct {
Rune string
Method string
Params string
RequestId uint64
RequestId string
}

func NewCommandoMsg(token string, method string, params string) CommandoMsg {
return CommandoMsg{
Rune: token,
Method: method,
Params: params,
RequestId: fmt.Sprintf("lnsocket:%d", rand.Uint64()),
}
}

Expand All @@ -47,7 +49,7 @@ func (msg *CommandoMsg) Decode(reader io.Reader, size uint32) error {
}

func (msg *CommandoMsg) Encode(buf *bytes.Buffer, pver uint32) error {
if err := lnwire.WriteUint64(buf, msg.RequestId); err != nil {
if err := lnwire.WriteUint64(buf, 0); err != nil {
return err
}

Expand All @@ -57,7 +59,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(msg.RequestId)
buf.WriteString("\",\"jsonrpc\":\"2.0\"}")

return nil
}
Expand Down