Skip to content

Commit af02f7c

Browse files
committed
WIP: Mobile: bindings
1 parent 68a7959 commit af02f7c

File tree

13 files changed

+5948
-0
lines changed

13 files changed

+5948
-0
lines changed

mobile/config.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package mobile
2+
3+
type config struct {
4+
DebugLevel string `long:"debuglevel" description:"Logging level for all subsystems {trace, debug, info, warn, error, critical} -- You may also specify <subsystem>=<level>,<subsystem2>=<level>,... to set the log level for individual subsystems -- Use show to list available subsystems"`
5+
NameSpace string `long:"namespace" description:"The name of the JS namespace in which all the call back functions should be registered"`
6+
7+
OnLocalPrivCreate string `long:"onlocalprivcreate" description:"The name of the js callback function that should be called once the local private key has been generated. This function is expected to persist the key so that it can be provided via a command line flag on a future connection"`
8+
OnRemoteKeyReceive string `long:"onremotekeyreceive" description:"The name of the js callback function to be called once the client receives the remote static key. This function is expected to persist the key so that it can be provided via a command line flag on a future connection"`
9+
10+
OnAuthData string `long:"onauthdata" description:"The name of the js callback function to be called once the client receives auth data from the remote peer."`
11+
}

mobile/gen_stubs.sh

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash
2+
3+
function import_path() {
4+
local pkg=$1
5+
# Find out what version of pool to use for the imported auctioneer.proto by
6+
# parsing the go.mod file.
7+
LAST_LINE=$(grep "$pkg" ../go.mod | tail -n 1)
8+
PKG_PATH=""
9+
if [[ $LAST_LINE =~ "replace" ]]
10+
then
11+
# There is a replace directive. Use awk to split by spaces then extract field
12+
# 4 and 5 and stitch them together with an @ which will resolve into
13+
# github.com/lightninglabs/[email protected].
14+
PKG_PATH=$(echo $LAST_LINE | awk -F " " '{ print $4"@"$5 }')
15+
else
16+
# This is a normal directive, just combine field 1 and 2 with an @.
17+
PKG_PATH=$(echo $LAST_LINE | awk -F " " '{ print $1"@"$2 }')
18+
fi
19+
echo "$GOPATH/pkg/mod/$PKG_PATH"
20+
}
21+
22+
falafel=$(which falafel)
23+
24+
# Name of the package for the generated APIs.
25+
pkg="main"
26+
27+
# The package where the protobuf definitions originally are found.
28+
target_pkg="github.com/lightningnetwork/lnd/lnrpc"
29+
30+
lnd_src=$(import_path "github.com/lightningnetwork/lnd ")
31+
opts="package_name=$pkg,target_package=$target_pkg,api_prefix=1,js_stubs=1,build_tags=// +build js"
32+
protoc -I/usr/local/include -I. -I"$lnd_src/lnrpc" \
33+
--plugin=protoc-gen-custom=$falafel\
34+
--custom_out=. \
35+
--custom_opt="$opts" \
36+
--proto_path="$1" \
37+
rpc.proto stateservice.proto
38+
39+
target_pkg="github.com/lightningnetwork/lnd/lnrpc/verrpc"
40+
opts="package_name=$pkg,target_package=$target_pkg,api_prefix=1,js_stubs=1,build_tags=// +build js"
41+
protoc -I/usr/local/include -I. -I"$lnd_src/lnrpc" \
42+
--plugin=protoc-gen-custom=$falafel\
43+
--custom_out=. \
44+
--custom_opt="$opts" \
45+
--proto_path="$1" \
46+
verrpc/verrpc.proto
47+
48+
# TODO(guggero): Fix import problem with auctioneerrpc package.
49+
# When uncommenting the following lines, there will be errors in the generated
50+
# code. You'll need to manually add the auctioneerrpc package import and change
51+
# the batch snapshot messages from poolrpc to auctioneerrpc.
52+
# This will be fixed by generating the stubs directly in the repo where the
53+
# proto lives.
54+
#
55+
#target_pkg="github.com/lightninglabs/pool/poolrpc"
56+
#opts="package_name=$pkg,target_package=$target_pkg,api_prefix=1,js_stubs=1,build_tags=// +build js"
57+
#protoc -Iproto \
58+
# --plugin=protoc-gen-custom=$falafel\
59+
# --custom_out=. \
60+
# --custom_opt="$opts" \
61+
# --proto_path="$1" \
62+
# trader.proto
63+
64+
target_pkg="github.com/lightninglabs/loop/looprpc"
65+
opts="package_name=$pkg,target_package=$target_pkg,api_prefix=1,js_stubs=1,build_tags=// +build js"
66+
protoc -Iproto \
67+
--plugin=protoc-gen-custom=$falafel\
68+
--custom_out=. \
69+
--custom_opt="$opts" \
70+
--proto_path="$1" \
71+
loop.proto

mobile/go.mod

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module github.com/lightninglabs/lightning-node-connect/mobile
2+
3+
require (
4+
github.com/btcsuite/btcd/btcec/v2 v2.2.0
5+
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f
6+
github.com/golang/protobuf v1.5.2
7+
github.com/jessevdk/go-flags v1.4.0
8+
github.com/lightninglabs/faraday v0.2.7-alpha.0.20220614135954-0f761430806c
9+
github.com/lightninglabs/lightning-node-connect v0.1.9-alpha.0.20220602120524-e9964c685b18
10+
github.com/lightninglabs/loop v0.19.1-beta.0.20220614171321-490fb352ffe9
11+
github.com/lightninglabs/pool v0.5.6-alpha.0.20220615075127-160ae4594f4a
12+
github.com/lightningnetwork/lnd v0.15.0-beta.rc4
13+
google.golang.org/grpc v1.39.0
14+
gopkg.in/macaroon-bakery.v2 v2.0.1
15+
gopkg.in/macaroon.v2 v2.1.0
16+
)
17+
18+
replace github.com/lightninglabs/lightning-node-connect => ../../
19+
20+
replace github.com/lightninglabs/lightning-node-connect/hashmailrpc => ../../hashmailrpc
21+
22+
go 1.16

0 commit comments

Comments
 (0)