diff --git a/app/api/index.js b/app/api/index.js index a83ab3c0..f1b5bb2f 100644 --- a/app/api/index.js +++ b/app/api/index.js @@ -1,38 +1,6 @@ import axios from 'axios' -export function callApi(endpoint, method = 'get', data = null) { - const BASE_URL = 'http://localhost:3000/api/' - let payload - - if (data) { - payload = { - headers: { - 'Content-Type': 'application/json' - }, - method, - data, - url: `${BASE_URL}${endpoint}` - } - } else { - payload = { - headers: { - 'Content-Type': 'application/json' - }, - method, - url: `${BASE_URL}${endpoint}` - } - } - - return axios(payload) - .then(response => response.data) - .catch(error => error) -} - -export function callApis(endpoints) { - return axios.all(endpoints.map(endpoint => callApi(endpoint))) -} - -export function requestTicker() { +export default function requestTicker() { const BASE_URL = 'https://api.coinmarketcap.com/v1/ticker/bitcoin/' return axios({ method: 'get', diff --git a/app/lnd/config/index.js b/app/lnd/config/index.js new file mode 100644 index 00000000..3c0f7d2f --- /dev/null +++ b/app/lnd/config/index.js @@ -0,0 +1,9 @@ +// Cert will be located depending on your machine +// Mac OS X: /Users/user/Library/Application Support/Lnd/tls.cert +// Linux: ~/.lnd/tls.cert +// Windows: TODO find out where cert is located for windows machine +export default { + lightningRpc: `${__dirname}/rpc.proto`, + lightningHost: 'localhost:10009', + cert: '/Users/jmow/Library/Application Support/Lnd/tls.cert' +} diff --git a/app/lnd/config/rpc.proto b/app/lnd/config/rpc.proto new file mode 100644 index 00000000..f341e415 --- /dev/null +++ b/app/lnd/config/rpc.proto @@ -0,0 +1,690 @@ +syntax = "proto3"; + +//import "google/api/annotations.proto"; + +package lnrpc; + +service Lightning { + rpc WalletBalance (WalletBalanceRequest) returns (WalletBalanceResponse) { + option (google.api.http) = { + get: "/v1/balance/blockchain" + }; + } + rpc ChannelBalance (ChannelBalanceRequest) returns (ChannelBalanceResponse) { + option (google.api.http) = { + get: "/v1/balance/channels" + }; + } + + rpc GetTransactions (GetTransactionsRequest) returns (TransactionDetails) { + option (google.api.http) = { + get: "/v1/transactions" + }; + } + rpc SendCoins (SendCoinsRequest) returns (SendCoinsResponse) { + option (google.api.http) = { + post: "/v1/transactions" + body: "*" + }; + } + rpc SubscribeTransactions (GetTransactionsRequest) returns (stream Transaction); + + rpc SendMany (SendManyRequest) returns (SendManyResponse); + + rpc NewAddress (NewAddressRequest) returns (NewAddressResponse); + rpc NewWitnessAddress (NewWitnessAddressRequest) returns (NewAddressResponse) { + option (google.api.http) = { + get: "/v1/newaddress" + }; + } + + rpc SignMessage (SignMessageRequest) returns (SignMessageResponse); + rpc VerifyMessage (VerifyMessageRequest) returns (VerifyMessageResponse); + + rpc ConnectPeer (ConnectPeerRequest) returns (ConnectPeerResponse) { + option (google.api.http) = { + post: "/v1/peers" + body: "*" + }; + } + + rpc DisconnectPeer (DisconnectPeerRequest) returns (DisconnectPeerResponse) { + option (google.api.http) = { + delete: "/v1/peers/{pub_key}" + }; + } + + rpc ListPeers (ListPeersRequest) returns (ListPeersResponse) { + option (google.api.http) = { + get: "/v1/peers" + }; + } + rpc GetInfo (GetInfoRequest) returns (GetInfoResponse) { + option (google.api.http) = { + get: "/v1/getinfo" + }; + } + + // TODO(roasbeef): merge with below with bool? + rpc PendingChannels (PendingChannelRequest) returns (PendingChannelResponse) { + option (google.api.http) = { + get: "/v1/channels/pending" + }; + } + rpc ListChannels (ListChannelsRequest) returns (ListChannelsResponse) { + option (google.api.http) = { + get: "/v1/channels" + }; + } + rpc OpenChannelSync (OpenChannelRequest) returns (ChannelPoint) { + option (google.api.http) = { + post: "/v1/channels" + body: "*" + }; + } + + rpc OpenChannel (OpenChannelRequest) returns (stream OpenStatusUpdate); + + rpc CloseChannel (CloseChannelRequest) returns (stream CloseStatusUpdate) { + option (google.api.http) = { + delete: "/v1/channels/{channel_point.funding_txid}/{channel_point.output_index}/{force}" + }; + } + + rpc SendPayment (stream SendRequest) returns (stream SendResponse); + + rpc SendPaymentSync (SendRequest) returns (SendResponse) { + option (google.api.http) = { + post: "/v1/channels/transactions" + body: "*" + }; + } + + rpc AddInvoice (Invoice) returns (AddInvoiceResponse) { + option (google.api.http) = { + post: "/v1/invoices" + body: "*" + }; + } + rpc ListInvoices (ListInvoiceRequest) returns (ListInvoiceResponse) { + option (google.api.http) = { + get: "/v1/invoices/{pending_only}" + }; + } + rpc LookupInvoice (PaymentHash) returns (Invoice) { + option (google.api.http) = { + get: "/v1/invoices/{r_hash_str}" + }; + } + rpc SubscribeInvoices (InvoiceSubscription) returns (stream Invoice) { + option (google.api.http) = { + get: "/v1/invoices/subscribe" + }; + } + rpc DecodePayReq (PayReqString) returns (PayReq) { + option (google.api.http) = { + get: "/v1/payreq/{pay_req}" + }; + } + + rpc ListPayments (ListPaymentsRequest) returns (ListPaymentsResponse) { + option (google.api.http) = { + get: "/v1/payments" + }; + }; + + rpc DeleteAllPayments (DeleteAllPaymentsRequest) returns (DeleteAllPaymentsResponse) { + option (google.api.http) = { + delete: "/v1/payments" + }; + }; + + rpc DescribeGraph (ChannelGraphRequest) returns (ChannelGraph) { + option (google.api.http) = { + get: "/v1/graph" + }; + } + + rpc GetChanInfo (ChanInfoRequest) returns (ChannelEdge) { + option (google.api.http) = { + get: "/v1/graph/edge/{chan_id}" + }; + } + + rpc GetNodeInfo (NodeInfoRequest) returns (NodeInfo) { + option (google.api.http) = { + get: "/v1/graph/node/{pub_key}" + }; + } + + rpc QueryRoutes(QueryRoutesRequest) returns (QueryRoutesResponse) { + option (google.api.http) = { + get: "/v1/graph/routes/{pub_key}/{amt}" + }; + } + + rpc GetNetworkInfo (NetworkInfoRequest) returns (NetworkInfo) { + option (google.api.http) = { + get: "/v1/graph/info" + }; + } + + rpc StopDaemon(StopRequest) returns (StopResponse); + + rpc SubscribeChannelGraph(GraphTopologySubscription) returns (stream GraphTopologyUpdate); + + rpc SetAlias(SetAliasRequest) returns (SetAliasResponse); + + rpc DebugLevel (DebugLevelRequest) returns (DebugLevelResponse); +} + +message Transaction { + string tx_hash = 1 [ json_name = "tx_hash" ]; + int64 amount = 2 [ json_name = "amount" ]; + int32 num_confirmations = 3 [ json_name = "num_confirmations" ]; + string block_hash = 4 [ json_name = "block_hash" ]; + int32 block_height = 5 [ json_name = "block_height" ]; + int64 time_stamp = 6 [ json_name = "time_stamp" ]; + int64 total_fees = 7 [ json_name = "total_fees" ]; +} +message GetTransactionsRequest { +} +message TransactionDetails { + repeated Transaction transactions = 1 [json_name = "transactions"]; +} + +message SendRequest { + bytes dest = 1; + string dest_string = 2; + + int64 amt = 3; + + bytes payment_hash = 4; + string payment_hash_string = 5; + + string payment_request = 6; +} +message SendResponse { + string payment_error = 1 [json_name = "payment_error"]; + bytes payment_preimage = 2 [json_name = "payment_preimage"]; + Route payment_route = 3 [json_name = "payment_route"]; +} + +message ChannelPoint { + // TODO(roasbeef): make str vs bytes into a oneof + bytes funding_txid = 1 [ json_name = "funding_txid" ]; + string funding_txid_str = 2 [ json_name = "funding_txid_str" ]; + uint32 output_index = 3 [ json_name = "output_index" ]; +} + +message LightningAddress { + string pubkey = 1 [json_name = "pubkey"]; + string host = 2 [json_name = "host"]; +} + +message SendManyRequest { + map AddrToAmount = 1; +} +message SendManyResponse { + string txid = 1 [json_name = "txid"]; +} + +message SendCoinsRequest { + string addr = 1; + int64 amount = 2; +} +message SendCoinsResponse { + string txid = 1 [json_name = "txid"]; +} + +message NewAddressRequest { + enum AddressType { + WITNESS_PUBKEY_HASH = 0; + NESTED_PUBKEY_HASH = 1; + PUBKEY_HASH = 2; + } + AddressType type = 1; +} +message NewWitnessAddressRequest { +} +message NewAddressResponse { + string address = 1 [json_name = "address"]; +} + +message SignMessageRequest { + bytes msg = 1 [ json_name = "msg" ]; +} +message SignMessageResponse { + string signature = 1 [ json_name = "signature" ]; +} + +message VerifyMessageRequest { + bytes msg = 1 [ json_name = "msg" ]; + string signature = 2 [ json_name = "signature" ]; +} +message VerifyMessageResponse { + bool valid = 1 [ json_name = "valid" ]; + string pubkey = 2 [ json_name = "pubkey" ]; +} + +message ConnectPeerRequest { + LightningAddress addr = 1; + bool perm = 2; +} +message ConnectPeerResponse { + int32 peer_id = 1 [json_name = "peer_id"]; +} + +message DisconnectPeerRequest { + string pub_key = 1 [json_name = "pub_key"]; +} +message DisconnectPeerResponse { +} + +message HTLC { + bool incoming = 1 [json_name = "incoming"]; + int64 amount = 2 [json_name = "amount"]; + bytes hash_lock = 3 [json_name = "hash_lock"]; + uint32 expiration_height = 4 [json_name = "expiration_height"]; + uint32 revocation_delay = 5 [json_name = "revocation_delay"]; +} + +message ActiveChannel { + bool active = 1 [json_name = "active"]; + string remote_pubkey = 2 [json_name = "remote_pubkey"]; + string channel_point = 3 [json_name = "channel_point"]; + uint64 chan_id = 4 [json_name = "chan_id"]; + + int64 capacity = 5 [json_name = "capacity"]; + int64 local_balance = 6 [json_name = "local_balance"]; + int64 remote_balance = 7 [json_name = "remote_balance"]; + + int64 commit_fee = 8 [json_name = "commit_fee"]; + int64 commit_weight = 9 [ json_name = "commit_weight" ]; + int64 fee_per_kw = 10 [json_name = "fee_per_kw"]; + + int64 unsettled_balance = 11 [json_name = "unsettled_balance"]; + int64 total_satoshis_sent = 12 [json_name = "total_satoshis_sent"]; + int64 total_satoshis_received = 13 [json_name = "total_satoshis_received"]; + uint64 num_updates = 14 [json_name = "num_updates"]; + + repeated HTLC pending_htlcs = 15 [json_name = "pending_htlcs"]; +} + +message ListChannelsRequest { +} +message ListChannelsResponse { + repeated ActiveChannel channels = 11 [json_name = "channels"]; +} + +message Peer { + string pub_key = 1 [json_name = "pub_key"]; + int32 peer_id = 2 [json_name = "peer_id"]; + string address = 3 [json_name = "address"]; + + uint64 bytes_sent = 4 [json_name = "bytes_sent"]; + uint64 bytes_recv = 5 [json_name = "bytes_recv"]; + + int64 sat_sent = 6 [json_name = "sat_sent"]; + int64 sat_recv = 7 [json_name = "sat_recv"]; + + bool inbound = 8 [json_name = "inbound"]; + + int64 ping_time = 9 [json_name = "ping_time"]; +} + +message ListPeersRequest { +} +message ListPeersResponse { + repeated Peer peers = 1 [json_name = "peers"]; +} + +message GetInfoRequest { +} +message GetInfoResponse { + string identity_pubkey = 1 [json_name = "identity_pubkey"]; + string alias = 2 [json_name = "alias"]; + + uint32 num_pending_channels = 3 [json_name = "num_pending_channels"]; + uint32 num_active_channels = 4 [json_name = "num_active_channels"]; + + uint32 num_peers = 5 [json_name = "num_peers"]; + + uint32 block_height = 6 [json_name = "block_height"]; + string block_hash = 8 [json_name = "block_hash"]; + + bool synced_to_chain = 9 [ json_name = "synced_to_chain" ]; + bool testnet = 10 [ json_name = "testnet" ]; + + repeated string chains = 11 [ json_name = "chains" ]; +} + +message ConfirmationUpdate { + bytes block_sha = 1; + int32 block_height = 2; + + uint32 num_confs_left = 3; +} + +message ChannelOpenUpdate { + ChannelPoint channel_point = 1 [json_name = "channel_point"]; +} + +message ChannelCloseUpdate { + bytes closing_txid = 1 [json_name = "closing_txid"]; + + bool success = 2 [json_name = "success"]; +} + +message CloseChannelRequest { + ChannelPoint channel_point = 1; + int64 time_limit = 2; + bool force = 3; +} +message CloseStatusUpdate { + oneof update { + PendingUpdate close_pending = 1 [json_name = "close_pending"]; + ConfirmationUpdate confirmation = 2 [json_name = "confirmation"]; + ChannelCloseUpdate chan_close = 3 [json_name = "chan_close"]; + } +} + +message PendingUpdate { + bytes txid = 1 [json_name = "txid"]; + uint32 output_index = 2 [json_name = "output_index"]; +} + +message OpenChannelRequest { + int32 target_peer_id = 1 [json_name = "target_peer_id"]; + bytes node_pubkey = 2 [json_name = "node_pubkey"]; + string node_pubkey_string = 3 [json_name = "node_pubkey_string"]; + + int64 local_funding_amount = 4 [json_name = "local_funding_amount"]; + int64 push_sat = 5 [json_name = "push_sat"]; + + uint32 num_confs = 6 [json_name = "num_confs"]; +} +message OpenStatusUpdate { + oneof update { + PendingUpdate chan_pending = 1 [json_name = "chan_pending"]; + ConfirmationUpdate confirmation = 2 [json_name = "confirmation"]; + ChannelOpenUpdate chan_open = 3 [json_name = "chan_open"]; + } +} + +message PendingChannelRequest {} +message PendingChannelResponse { + message PendingChannel { + string remote_node_pub = 1 [ json_name = "remote_node_pub" ]; + string channel_point = 2 [ json_name = "channel_point" ]; + + int64 capacity = 3 [ json_name = "capacity" ]; + + int64 local_balance = 4 [ json_name = "local_balance" ]; + int64 remote_balance = 5 [ json_name = "remote_balance" ]; + } + + message PendingOpenChannel { + PendingChannel channel = 1 [ json_name = "channel" ]; + + uint32 confirmation_height = 2 [ json_name = "confirmation_height" ]; + uint32 blocks_till_open = 3 [ json_name = "blocks_till_open" ]; + + int64 commit_fee = 4 [json_name = "commit_fee" ]; + int64 commit_weight = 5 [ json_name = "commit_weight" ]; + int64 fee_per_kw = 6 [ json_name = "fee_per_kw" ]; + } + + message ClosedChannel { + PendingChannel channel = 1; + + string closing_txid = 2 [ json_name = "closing_txid" ]; + } + + message ForceClosedChannel { + PendingChannel channel = 1 [ json_name = "channel" ]; + + // TODO(roasbeef): HTLC's as well? + + string closing_txid = 2 [ json_name = "closing_txid" ]; + + int64 limbo_balance = 3 [ json_name = "limbo_balance" ]; + uint32 maturity_height = 4 [ json_name = "maturity_height" ]; + uint32 blocks_til_maturity = 5 [ json_name = "blocks_til_maturity" ]; + } + + int64 total_limbo_balance = 1 [ json_name = "total_limbo_balance" ]; + repeated PendingOpenChannel pending_open_channels = 2 [ json_name = "pending_open_channels" ]; + repeated ClosedChannel pending_closing_channels = 3 [ json_name = "pending_closing_channels" ]; + repeated ForceClosedChannel pending_force_closing_channels = 4 [ json_name = "pending_force_closing_channels" ]; +} + +message WalletBalanceRequest { + bool witness_only = 1; +} +message WalletBalanceResponse { + int64 balance = 1 [json_name = "balance"]; +} + +message ChannelBalanceRequest { +} +message ChannelBalanceResponse { + int64 balance = 1 [json_name = "balance"]; +} + +message QueryRoutesRequest { + string pub_key = 1; + int64 amt = 2; +} +message QueryRoutesResponse { + repeated Route routes = 1 [ json_name = "routes"]; +} + +message Hop { + uint64 chan_id = 1 [json_name = "chan_id"]; + int64 chan_capacity = 2 [json_name = "chan_capacity"]; + int64 amt_to_forward = 3 [json_name = "amt_to_forward"]; + int64 fee = 4 [json_name = "fee"]; +} + +message Route { + uint32 total_time_lock = 1 [json_name = "total_time_lock"]; + int64 total_fees = 2 [json_name = "total_fees"]; + int64 total_amt = 3 [json_name = "total_amt"]; + + repeated Hop hops = 4 [json_name = "hops"]; +} + +message NodeInfoRequest { + string pub_key = 1; +} + +message NodeInfo { + LightningNode node = 1 [json_name = "node"]; + + uint32 num_channels = 2 [json_name = "num_channels"]; + int64 total_capacity = 3 [json_name = "total_capacity"]; +} + +message LightningNode { + uint32 last_update = 1 [ json_name = "last_update" ]; + string pub_key = 2 [ json_name = "pub_key" ]; + string alias = 3 [ json_name = "alias" ]; + repeated NodeAddress addresses = 4 [ json_name = "addresses" ]; +} + +message NodeAddress { + string network = 1 [ json_name = "network" ]; + string addr = 2 [ json_name = "addr" ]; +} + +message RoutingPolicy { + uint32 time_lock_delta = 1 [json_name = "time_lock_delta"]; + int64 min_htlc = 2 [json_name = "min_htlc"]; + int64 fee_base_msat = 3 [json_name = "fee_base_msat"]; + int64 fee_rate_milli_msat = 4 [json_name = "fee_rate_milli_msat"]; +} + +message ChannelEdge { + uint64 channel_id = 1 [json_name = "channel_id"]; + string chan_point = 2 [json_name = "chan_point"]; + + uint32 last_update = 3 [json_name = "last_update"]; + + string node1_pub = 4 [json_name = "node1_pub"]; + string node2_pub = 5 [json_name = "node2_pub"]; + + int64 capacity = 6 [json_name = "capacity"]; + + RoutingPolicy node1_policy = 7 [json_name = "node1_policy"]; + RoutingPolicy node2_policy = 8 [json_name = "node2_policy"]; +} + +message ChannelGraphRequest { +} + +message ChannelGraph { + repeated LightningNode nodes = 1 [json_name = "nodes"]; + repeated ChannelEdge edges = 2 [json_name = "edges"]; +} + +message ChanInfoRequest { + uint64 chan_id = 1; +} + +message NetworkInfoRequest { +} +message NetworkInfo { + uint32 graph_diameter = 1 [json_name = "graph_diameter"]; + double avg_out_degree = 2 [json_name = "avg_out_degree"]; + uint32 max_out_degree = 3 [json_name = "max_out_degree"]; + + uint32 num_nodes = 4 [json_name = "num_nodes"]; + uint32 num_channels = 5 [json_name = "num_channels"]; + + int64 total_network_capacity = 6 [json_name = "total_network_capacity"]; + + double avg_channel_size = 7 [json_name = "avg_channel_size"]; + int64 min_channel_size = 8 [json_name = "min_channel_size"]; + int64 max_channel_size = 9 [json_name = "max_channel_size"]; + + // TODO(roasbeef): fee rate info, expiry + // * also additional RPC for tracking fee info once in +} + +message StopRequest{} +message StopResponse{} + +message GraphTopologySubscription {} +message GraphTopologyUpdate { + repeated NodeUpdate node_updates = 1; + repeated ChannelEdgeUpdate channel_updates = 2; + repeated ClosedChannelUpdate closed_chans = 3; +} +message NodeUpdate { + repeated string addresses = 1; + string identity_key = 2; + bytes global_features = 3; + string alias = 4; +} +message ChannelEdgeUpdate { + uint64 chan_id = 1; + + ChannelPoint chan_point = 2; + + int64 capacity = 3; + + RoutingPolicy routing_policy = 4; + + string advertising_node = 5; + string connecting_node = 6; +} +message ClosedChannelUpdate { + uint64 chan_id = 1; + int64 capacity = 2; + uint32 closed_height = 3; + ChannelPoint chan_point = 4; +} + +message SetAliasRequest { + string new_alias = 1; +} +message SetAliasResponse { +} + +message Invoice { + string memo = 1 [json_name = "memo"]; + bytes receipt = 2 [json_name = "receipt"]; + + bytes r_preimage = 3 [json_name = "r_preimage"]; + bytes r_hash = 4 [json_name = "r_hash"]; + + int64 value = 5 [json_name = "value"]; + + bool settled = 6 [json_name = "settled"]; + + int64 creation_date = 7 [json_name = "creation_date"]; + int64 settle_date = 8 [json_name = "settle_date"]; + + string payment_request = 9 [json_name = "payment_request"]; +} +message AddInvoiceResponse { + bytes r_hash = 1 [json_name = "r_hash"]; + + string payment_request = 2 [json_name = "payment_request"]; +} +message PaymentHash { + string r_hash_str = 1 [json_name = "r_hash_str"]; + bytes r_hash = 2 [json_name = "r_hash"]; +} +message ListInvoiceRequest { + bool pending_only = 1; +} +message ListInvoiceResponse { + repeated Invoice invoices = 1 [json_name = "invoices"]; +} + +message InvoiceSubscription { +} + + +message Payment { + string payment_hash = 1 [json_name = "payment_hash"]; + int64 value = 2 [json_name = "value"]; + + int64 creation_date = 3 [json_name = "creation_date"]; + + repeated string path = 4 [ json_name = "path" ]; + + int64 fee = 5 [json_name = "fee"]; +} + +message ListPaymentsRequest { +} + +message ListPaymentsResponse { + repeated Payment payments = 1 [json_name = "payments"]; +} + +message DeleteAllPaymentsRequest { +} + +message DeleteAllPaymentsResponse { +} + +message DebugLevelRequest { + bool show = 1; + string level_spec = 2; +} +message DebugLevelResponse { + string sub_systems = 1 [json_name = "sub_systems"]; +} + +message PayReqString { + string pay_req = 1; +} +message PayReq { + string destination = 1 [json_name = "destination"]; + string payment_hash = 2 [json_name = "payment_hash"]; + int64 num_satoshis = 3 [json_name = "num_satoshis"]; +} \ No newline at end of file diff --git a/app/lnd/index.js b/app/lnd/index.js new file mode 100644 index 00000000..5660126a --- /dev/null +++ b/app/lnd/index.js @@ -0,0 +1,7 @@ +import config from './config' +import lightning from './lib/lightning' +import methods from './methods' + +const lnd = lightning(config.lightningRpc, config.lightningHost) + +export default (event, msg, data) => methods(lnd, event, msg, data) diff --git a/app/lnd/lib/lightning.js b/app/lnd/lib/lightning.js new file mode 100644 index 00000000..7162f537 --- /dev/null +++ b/app/lnd/lib/lightning.js @@ -0,0 +1,14 @@ +import fs from 'fs' +import grpc from 'grpc' +import config from '../config' + +module.exports = (path, host) => { + process.env.GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA' + + const rpc = grpc.load(path) + + const lndCert = fs.readFileSync(config.cert) + const credentials = grpc.credentials.createSsl(lndCert) + + return new rpc.lnrpc.Lightning(host, credentials) +} diff --git a/app/lnd/methods/channelbalance.js b/app/lnd/methods/channelbalance.js new file mode 100644 index 00000000..135a6b6e --- /dev/null +++ b/app/lnd/methods/channelbalance.js @@ -0,0 +1,10 @@ +// LND Get Channel Balance +export default function channelbalance(lnd) { + return new Promise((resolve, reject) => { + lnd.channelBalance({}, (err, data) => { + if (err) { reject(err) } + + resolve(data) + }) + }) +} diff --git a/app/lnd/methods/channels.js b/app/lnd/methods/channels.js new file mode 100644 index 00000000..512fec27 --- /dev/null +++ b/app/lnd/methods/channels.js @@ -0,0 +1,10 @@ +// LND List Channels +export default function channels(lnd) { + return new Promise((resolve, reject) => { + lnd.listChannels({}, (err, data) => { + if (err) { reject(err) } + + resolve(data) + }) + }) +} diff --git a/app/lnd/methods/connectpeer.js b/app/lnd/methods/connectpeer.js new file mode 100644 index 00000000..33608fc2 --- /dev/null +++ b/app/lnd/methods/connectpeer.js @@ -0,0 +1,10 @@ +// LND Connect to a peer +export default function connectpeer(lnd, { pubkey, host }) { + return new Promise((resolve, reject) => { + lnd.connectPeer({ addr: { pubkey, host }, perm: true }, (err, data) => { + if (err) { reject(err) } + + resolve(data) + }) + }) +} diff --git a/app/lnd/methods/createinvoice.js b/app/lnd/methods/createinvoice.js new file mode 100644 index 00000000..c7fbba35 --- /dev/null +++ b/app/lnd/methods/createinvoice.js @@ -0,0 +1,10 @@ +// LND Create an invoice +export default function createInvoice(lnd, { memo, value }) { + return new Promise((resolve, reject) => { + lnd.addInvoice({ memo, value }, (err, data) => { + if (err) { reject(err) } + + resolve(data) + }) + }) +} diff --git a/app/lnd/methods/disconnectpeer.js b/app/lnd/methods/disconnectpeer.js new file mode 100644 index 00000000..e6a4bc88 --- /dev/null +++ b/app/lnd/methods/disconnectpeer.js @@ -0,0 +1,10 @@ +// LND Disconnect from a peer +export default function disconnectpeer(lnd, { pubkey }) { + return new Promise((resolve, reject) => { + lnd.disconnectPeer({ pub_key: pubkey }, (err, data) => { + if (err) { reject(err) } + + resolve(data) + }) + }) +} diff --git a/app/lnd/methods/index.js b/app/lnd/methods/index.js new file mode 100644 index 00000000..3f35be1b --- /dev/null +++ b/app/lnd/methods/index.js @@ -0,0 +1,115 @@ +/* eslint no-console: 0 */ // --> OFF + +import channelbalance from './channelbalance' +import channels from './channels' +import connectpeer from './connectpeer' +import createinvoice from './createinvoice' +import disconnectpeer from './disconnectpeer' +import info from './info' +import invoice from './invoice' +import invoices from './invoices' +import openchannel from './openchannel' +import payinvoice from './payinvoice' +import payments from './payments' +import peers from './peers' +import pendingchannels from './pendingchannels' +import walletbalance from './walletbalance' + +export default function (lnd, event, msg, data) { + switch (msg) { + case 'info': + info(lnd) + .then(infoData => event.sender.send('receiveInfo', infoData)) + .catch(error => console.log('info error: ', error)) + break + case 'peers': + // Data looks like { peers: [] } + peers(lnd) + .then(peersData => event.sender.send('receivePeers', peersData)) + .catch(error => console.log('peers error: ', error)) + break + case 'channels': + // Data looks like + // [ { channels: [] }, { total_limbo_balance: 0, pending_open_channels: [], pending_closing_channels: [], pending_force_closing_channels: [] } ] + Promise.all([channels, pendingchannels].map(func => func(lnd))) + .then(channelsData => + event.sender.send('receiveChannels', { channels: channelsData[0].channels, pendingChannels: channelsData[1] }) + ) + .catch(error => console.log('channels error: ', error)) + break + case 'payments': + // Data looks like { payments: [] } + payments(lnd) + .then(paymentsData => event.sender.send('receivePayments', paymentsData)) + .catch(error => console.log('payments error: ', error)) + break + case 'invoices': + // Data looks like { invoices: [] } + invoices(lnd) + .then(invoicesData => event.sender.send('receiveInvoices', invoicesData)) + .catch(error => console.log('invoices error: ', error)) + break + case 'invoice': + // Data looks like { invoices: [] } + invoice(data.payreq) + .then(invoiceData => event.sender.send('receiveInvoice', invoiceData)) + .catch(error => console.log('invoice error: ', error)) + break + case 'balance': + // Balance looks like [ { balance: '129477456' }, { balance: '243914' } ] + Promise.all([walletbalance, channelbalance].map(func => func(lnd))) + .then(balance => event.sender.send('receiveBalance', { walletBalance: balance[0].balance, channelBalance: balance[1].balance })) + .catch(error => console.log('balance error: ', error)) + break + case 'createInvoice': + // Invoice looks like { r_hash: Buffer, payment_request: '' } + // { memo, value } = data + createinvoice(lnd, data) + .then(newinvoice => + event.sender.send( + 'createdInvoice', + Object.assign(newinvoice, { memo: data.memo, value: data.value, r_hash: new Buffer(newinvoice.r_hash, 'hex').toString('hex') }) + ) + ) + .catch(error => console.log('createInvoice error: ', error)) + break + case 'sendPayment': + // Payment looks like { payment_preimage: Buffer, payment_route: Object } + // { paymentRequest } = data + payinvoice(lnd, data) + .then(({ payment_route }) => event.sender.send('paymentSuccessful', Object.assign(data, { payment_route }))) + .catch(error => console.log('payinvoice error: ', error)) + break + case 'openChannel': + // Response is empty. Streaming updates on channel status and updates + // { pubkey, localamt, pushamt } = data + openchannel(lnd, event, data) + .then((channel) => { + console.log('CHANNEL: ', channel) + event.sender.send('channelSuccessful', { channel }) + }) + .catch(error => console.log('openChannel error: ', error)) + break + case 'connectPeer': + // Returns a peer_id. Pass the pubkey, host and peer_id so we can add a new peer to the list + // { pubkey, host } = data + connectpeer(lnd, data) + .then(({ peer_id }) => { + console.log('peer_id: ', peer_id) + event.sender.send('connectSuccess', { pub_key: data.pubkey, address: data.host, peer_id }) + }) + .catch(error => console.log('connectPeer error: ', error)) + break + case 'disconnectPeer': + // Empty response. Pass back pubkey on success to remove it from the peers list + // { pubkey } = data + disconnectpeer(lnd, data) + .then(() => { + console.log('pubkey: ', data.pubkey) + event.sender.send('disconnectSuccess', { pubkey: data.pubkey }) + }) + .catch(error => console.log('disconnectPeer error: ', error)) + break + default: + } +} diff --git a/app/lnd/methods/info.js b/app/lnd/methods/info.js new file mode 100644 index 00000000..8b704980 --- /dev/null +++ b/app/lnd/methods/info.js @@ -0,0 +1,10 @@ +// LND Get Info +export default function info(lnd) { + return new Promise((resolve, reject) => { + lnd.getInfo({}, (err, data) => { + if (err) { reject(err) } + + resolve(data) + }) + }) +} diff --git a/app/lnd/methods/invoice.js b/app/lnd/methods/invoice.js new file mode 100644 index 00000000..2c1f4efa --- /dev/null +++ b/app/lnd/methods/invoice.js @@ -0,0 +1,12 @@ +import { decodeInvoice } from '../utils' + +// LND Get Invoice +export default function invoice(payreq) { + return new Promise((resolve, reject) => { + try { + resolve(decodeInvoice(payreq)) + } catch (error) { + reject(error) + } + }) +} diff --git a/app/lnd/methods/invoices.js b/app/lnd/methods/invoices.js new file mode 100644 index 00000000..9cad0746 --- /dev/null +++ b/app/lnd/methods/invoices.js @@ -0,0 +1,10 @@ +// LND Get Invoices +export default function invoices(lnd) { + return new Promise((resolve, reject) => { + lnd.listInvoices({}, (err, data) => { + if (err) { reject(err) } + + resolve(data) + }) + }) +} diff --git a/app/lnd/methods/openchannel.js b/app/lnd/methods/openchannel.js new file mode 100644 index 00000000..1282ee87 --- /dev/null +++ b/app/lnd/methods/openchannel.js @@ -0,0 +1,19 @@ +import bitcore from 'bitcore-lib' +import pushchannel from '../push/channel' + +const BufferUtil = bitcore.util.buffer + +export default function openchannel(lnd, event, payload) { + const { pubkey, localamt, pushamt } = payload + const res = { + node_pubkey: BufferUtil.hexToBuffer(pubkey), + local_funding_amount: Number(localamt), + push_sat: Number(pushamt) + } + + return new Promise((resolve, reject) => + pushchannel(lnd, event, res) + .then(data => resolve(data)) + .catch(error => reject(error)) + ) +} diff --git a/app/lnd/methods/payinvoice.js b/app/lnd/methods/payinvoice.js new file mode 100644 index 00000000..43bfa3b8 --- /dev/null +++ b/app/lnd/methods/payinvoice.js @@ -0,0 +1,10 @@ +// LND Pay an invoice +export default function payinvoice(lnd, { paymentRequest }) { + return new Promise((resolve, reject) => { + lnd.sendPaymentSync({ payment_request: paymentRequest }, (err, data) => { + if (err) { reject(err) } + + resolve(data) + }) + }) +} diff --git a/app/lnd/methods/payments.js b/app/lnd/methods/payments.js new file mode 100644 index 00000000..a276c3bd --- /dev/null +++ b/app/lnd/methods/payments.js @@ -0,0 +1,10 @@ +// LND Get Payments +export default function payments(lnd) { + return new Promise((resolve, reject) => { + lnd.listPayments({}, (err, data) => { + if (err) { reject(err) } + + resolve(data) + }) + }) +} diff --git a/app/lnd/methods/peers.js b/app/lnd/methods/peers.js new file mode 100644 index 00000000..1b604c1c --- /dev/null +++ b/app/lnd/methods/peers.js @@ -0,0 +1,10 @@ +// LND List Peers +export default function peers(lnd) { + return new Promise((resolve, reject) => { + lnd.listPeers({}, (err, data) => { + if (err) { reject(err) } + + resolve(data) + }) + }) +} diff --git a/app/lnd/methods/pendingchannels.js b/app/lnd/methods/pendingchannels.js new file mode 100644 index 00000000..4408e750 --- /dev/null +++ b/app/lnd/methods/pendingchannels.js @@ -0,0 +1,10 @@ +// LND Get Pending Channels +export default function channels(lnd) { + return new Promise((resolve, reject) => { + lnd.pendingChannels({}, (err, data) => { + if (err) { reject(err) } + + resolve(data) + }) + }) +} diff --git a/app/lnd/methods/walletbalance.js b/app/lnd/methods/walletbalance.js new file mode 100644 index 00000000..e6db48a6 --- /dev/null +++ b/app/lnd/methods/walletbalance.js @@ -0,0 +1,10 @@ +// LND Get Wallet Balance +export default function walletbalance(lnd) { + return new Promise((resolve, reject) => { + lnd.walletBalance({}, (err, data) => { + if (err) { reject(err) } + + resolve(data) + }) + }) +} diff --git a/app/lnd/push/channel.js b/app/lnd/push/channel.js new file mode 100644 index 00000000..4a115dec --- /dev/null +++ b/app/lnd/push/channel.js @@ -0,0 +1,16 @@ +export default function pushchannel(lnd, event, payload) { + return new Promise((resolve, reject) => { + try { + const call = lnd.openChannel(payload) + + call.on('data', data => event.sender.send('pushchannelupdated', { data })) + call.on('end', () => event.sender.send('pushchannelend')) + call.on('error', error => event.sender.send('pushchannelerror', { error })) + call.on('status', status => event.sender.send('pushchannelstatus', { status })) + + resolve(null, payload) + } catch (error) { + reject(error, null) + } + }) +} diff --git a/app/lnd/utils/index.js b/app/lnd/utils/index.js new file mode 100644 index 00000000..39cf69c0 --- /dev/null +++ b/app/lnd/utils/index.js @@ -0,0 +1,38 @@ +import zbase32 from 'zbase32' + +function convertBigEndianBufferToLong(longBuffer) { + let longValue = 0 + const byteArray = Buffer.from(longBuffer).swap64() + + for (let i = byteArray.length - 1; i >= 0; i -= 1) { + longValue = (longValue * 256) + byteArray[i] + } + + return longValue +} + +export function decodeInvoice(payreq) { + const payreqBase32 = zbase32.decode(payreq) + + const bufferHexRotated = Buffer.from(payreqBase32).toString('hex') + const bufferHex = bufferHexRotated.substr(bufferHexRotated.length - 1, bufferHexRotated.length) + + bufferHexRotated.substr(0, bufferHexRotated.length - 1) + const buffer = Buffer.from(bufferHex, 'hex') + + const paymentHashBuffer = buffer.slice(33, 65) + const paymentHashHex = paymentHashBuffer.toString('hex') + + const valueBuffer = buffer.slice(65, 73) + + const amount = convertBigEndianBufferToLong(valueBuffer) + + return { + payreq, + amount, + r_hash: paymentHashHex + } +} + +export default { + decodeInvoice +} diff --git a/app/main.dev.js b/app/main.dev.js index c5f4c8df..bce530ae 100644 --- a/app/main.dev.js +++ b/app/main.dev.js @@ -11,8 +11,9 @@ * * @flow */ -import { app, BrowserWindow } from 'electron' +import { app, BrowserWindow, ipcMain } from 'electron' import MenuBuilder from './menu' +import lnd from './lnd' let mainWindow = null; @@ -90,3 +91,8 @@ app.on('ready', async () => { const menuBuilder = new MenuBuilder(mainWindow); menuBuilder.buildMenu(); }); + +ipcMain.on('lnd', (event, { msg, data }) => { + lnd(event, msg, data) +}) + diff --git a/app/reducers/activity.js b/app/reducers/activity.js deleted file mode 100644 index cb391f4d..00000000 --- a/app/reducers/activity.js +++ /dev/null @@ -1,54 +0,0 @@ -import { callApis } from '../api' -// ------------------------------------ -// Constants -// ------------------------------------ -export const GET_ACTIVITY = 'GET_ACTIVITY' -export const RECEIVE_ACTIVITY = 'RECEIVE_ACTIVITY' - -// ------------------------------------ -// Actions -// ------------------------------------ -export function getActivity() { - return { - type: GET_ACTIVITY - } -} - -export function receiveActvity(data) { - return { - type: RECEIVE_ACTIVITY, - payments: data[0].data.payments.reverse(), - invoices: data[1].data.invoices.reverse() - } -} - -export const fetchActivity = () => async (dispatch) => { - dispatch(getActivity()) - const activity = await callApis(['payments', 'invoices']) - dispatch(receiveActvity(activity)) -} - -// ------------------------------------ -// Action Handlers -// ------------------------------------ -const ACTION_HANDLERS = { - [GET_ACTIVITY]: state => ({ ...state, activityLoading: true }), - [RECEIVE_ACTIVITY]: (state, { payments, invoices }) => ( - { ...state, activityLoading: false, payments, invoices } - ) -} - -// ------------------------------------ -// Reducer -// ------------------------------------ -const initialState = { - activityLoading: false, - payments: [], - invoices: [] -} - -export default function activityReducer(state = initialState, action) { - const handler = ACTION_HANDLERS[action.type] - - return handler ? handler(state, action) : state -} diff --git a/app/reducers/balance.js b/app/reducers/balance.js index 5958f239..db49a64c 100644 --- a/app/reducers/balance.js +++ b/app/reducers/balance.js @@ -1,4 +1,4 @@ -import { callApis } from '../api' +import { ipcRenderer } from 'electron' // ------------------------------------ // Constants // ------------------------------------ @@ -14,20 +14,17 @@ export function getBalance() { } } -export function receiveBalance(data) { - return { - type: RECEIVE_BALANCE, - walletBalance: data[0].data.balance, - channelBalance: data[1].data.balance - } -} - +// Send IPC event for balance export const fetchBalance = () => async (dispatch) => { dispatch(getBalance()) - const balance = await callApis(['wallet_balance', 'channel_balance']) - dispatch(receiveBalance(balance)) + ipcRenderer.send('lnd', { msg: 'balance' }) } +// Receive IPC event for balance +export const receiveBalance = (event, { walletBalance, channelBalance }) => dispatch => ( + dispatch({ type: RECEIVE_BALANCE, walletBalance, channelBalance }) +) + // ------------------------------------ // Action Handlers // ------------------------------------ diff --git a/app/reducers/channels.js b/app/reducers/channels.js index 20fef970..9003c5b5 100644 --- a/app/reducers/channels.js +++ b/app/reducers/channels.js @@ -1,5 +1,5 @@ import { createSelector } from 'reselect' -import { callApi, callApis } from '../api' +import { ipcRenderer } from 'electron' // ------------------------------------ // Constants // ------------------------------------ @@ -38,14 +38,6 @@ export function getChannels() { } } -export function receiveChannels(channels) { - return { - type: RECEIVE_CHANNELS, - channels: channels[0].data.channels, - pendingChannels: channels[1].data - } -} - export function openingChannel() { return { type: OPENING_CHANNEL @@ -64,24 +56,45 @@ export function openingFailure() { } } +// Send IPC event for peers export const fetchChannels = () => async (dispatch) => { dispatch(getChannels()) - const channels = await callApis(['channels', 'pending_channels']) - dispatch(receiveChannels(channels)) + ipcRenderer.send('lnd', { msg: 'channels' }) } -export const openChannel = ({ pubkey, localamt, pushamt }) => async (dispatch) => { - const payload = { pubkey, localamt, pushamt } +// Receive IPC event for channels +export const receiveChannels = (event, { channels, pendingChannels }) => dispatch => dispatch({ type: RECEIVE_CHANNELS, channels, pendingChannels }) + +// Send IPC event for opening a channel +export const openChannel = ({ pubkey, localamt, pushamt }) => (dispatch) => { dispatch(openingChannel()) - const channel = await callApi('addchannel', 'post', payload) + ipcRenderer.send('lnd', { msg: 'openChannel', data: { pubkey, localamt, pushamt } }) +} - if (channel.data) { - dispatch(openingSuccessful()) - } else { - dispatch(openingFailure()) - } +// TODO: Decide how to handle streamed updates for channels +// Receive IPC event for openChannel +export const channelSuccessful = () => (dispatch) => { + dispatch(fetchChannels()) +} + +// Receive IPC event for updated channel +export const pushchannelupdated = () => (dispatch) => { + dispatch(fetchChannels()) +} + +// Receive IPC event for channel end +export const pushchannelend = () => (dispatch) => { + dispatch(fetchChannels()) +} + +// Receive IPC event for channel error +export const pushchannelerror = () => (dispatch) => { + dispatch(fetchChannels()) +} - return channel +// Receive IPC event for channel status +export const pushchannelstatus = () => (dispatch) => { + dispatch(fetchChannels()) } // ------------------------------------ diff --git a/app/reducers/index.js b/app/reducers/index.js index a77099ec..d7df67f8 100644 --- a/app/reducers/index.js +++ b/app/reducers/index.js @@ -9,7 +9,6 @@ import peers from './peers' import channels from './channels' import form from './form' import invoice from './invoice' -import activity from './activity' const rootReducer = combineReducers({ router, @@ -20,8 +19,7 @@ const rootReducer = combineReducers({ peers, channels, form, - invoice, - activity + invoice }) export default rootReducer diff --git a/app/reducers/info.js b/app/reducers/info.js index 2cf7bef4..9be0c5a2 100644 --- a/app/reducers/info.js +++ b/app/reducers/info.js @@ -1,4 +1,4 @@ -import { callApi } from '../api' +import { ipcRenderer } from 'electron' // ------------------------------------ // Constants // ------------------------------------ @@ -14,19 +14,15 @@ export function getInfo() { } } -export function receiveInfo(data) { - return { - type: RECEIVE_INFO, - data - } -} - +// Send IPC event for getinfo export const fetchInfo = () => async (dispatch) => { dispatch(getInfo()) - const info = await callApi('info') - dispatch(receiveInfo(info.data)) + ipcRenderer.send('lnd', { msg: 'info' }) } +// Receive IPC event for info +export const receiveInfo = (event, data) => dispatch => dispatch({ type: RECEIVE_INFO, data }) + // ------------------------------------ // Action Handlers // ------------------------------------ diff --git a/app/reducers/invoice.js b/app/reducers/invoice.js index bed8e818..8cedcc2b 100644 --- a/app/reducers/invoice.js +++ b/app/reducers/invoice.js @@ -1,5 +1,5 @@ import { createSelector } from 'reselect' -import { callApi } from '../api' +import { ipcRenderer } from 'electron' import { btc, usd } from '../utils' // ------------------------------------ // Constants @@ -50,82 +50,51 @@ export function receiveInvoice(invoice) { } } -export function receiveFormInvoice(formInvoice) { - return { - type: RECEIVE_FORM_INVOICE, - formInvoice - } -} - export function getInvoices() { return { type: GET_INVOICES } } -export function receiveInvoices(data) { - return { - type: RECEIVE_INVOICES, - invoices: data.invoices.reverse() - } -} - export function sendInvoice() { return { type: SEND_INVOICE } } -export function invoiceSuccessful(invoice) { - return { - type: INVOICE_SUCCESSFUL, - invoice - } -} - export function invoiceFailed() { return { type: INVOICE_FAILED } } -export const fetchInvoice = payreq => async (dispatch) => { +// Send IPC event for a specific invoice +export const fetchInvoice = payreq => (dispatch) => { dispatch(getInvoice()) - const invoice = await callApi(`invoice/${payreq}`, 'get') - - if (invoice) { - dispatch(receiveFormInvoice(invoice.data)) - return true - } - dispatch(invoiceFailed()) - return false + ipcRenderer.send('lnd', { msg: 'invoice', data: { payreq } }) } -export const fetchInvoices = () => async (dispatch) => { - dispatch(getInvoice()) - const invoices = await callApi('invoices') - if (invoices) { - dispatch(receiveInvoices(invoices.data)) - } else { - dispatch(invoiceFailed()) - } +// Receive IPC event for form invoice +export const receiveFormInvoice = (event, formInvoice) => dispatch => dispatch({ type: RECEIVE_FORM_INVOICE, formInvoice }) - return invoices +// Send IPC event for invoices +export const fetchInvoices = () => (dispatch) => { + dispatch(getInvoices()) + ipcRenderer.send('lnd', { msg: 'invoices' }) } -export const createInvoice = (amount, memo, currency, rate) => async (dispatch) => { - const value = currency === 'btc' ? btc.btcToSatoshis(amount) : btc.btcToSatoshis(usd.usdToBtc(amount, rate)) +// Receive IPC event for invoices +export const receiveInvoices = (event, { invoices }) => dispatch => dispatch({ type: RECEIVE_INVOICES, invoices }) +// Send IPC event for creating an invoice +export const createInvoice = (amount, memo, currency, rate) => (dispatch) => { + const value = currency === 'btc' ? btc.btcToSatoshis(amount) : btc.btcToSatoshis(usd.usdToBtc(amount, rate)) dispatch(sendInvoice()) - const invoice = await callApi('addinvoice', 'post', { value, memo }) - if (invoice) { - dispatch(invoiceSuccessful({ memo, value, payment_request: invoice.data.payment_request })) - } else { - dispatch(invoiceFailed()) - } - - return invoice + ipcRenderer.send('lnd', { msg: 'createInvoice', data: { value, memo } }) } + +// Receive IPC event for newly created invoice +export const createdInvoice = (event, invoice) => dispatch => dispatch({ type: INVOICE_SUCCESSFUL, invoice }) // ------------------------------------ // Action Handlers // ------------------------------------ diff --git a/app/reducers/ipc.js b/app/reducers/ipc.js new file mode 100644 index 00000000..3d2ade7c --- /dev/null +++ b/app/reducers/ipc.js @@ -0,0 +1,36 @@ +import createIpc from 'redux-electron-ipc' +import { receiveInfo } from './info' +import { receivePeers, connectSuccess, disconnectSuccess } from './peers' +import { + receiveChannels, + channelSuccessful, + pushchannelupdated, + pushchannelend, + pushchannelerror, + pushchannelstatus +} from './channels' +import { receivePayments, paymentSuccessful } from './payment' +import { receiveInvoices, createdInvoice, receiveFormInvoice } from './invoice' +import { receiveBalance } from './balance' + +// Import all receiving IPC event handlers and pass them into createIpc +const ipc = createIpc({ + receiveInfo, + receivePeers, + receiveChannels, + receivePayments, + receiveInvoices, + receiveInvoice: receiveFormInvoice, + receiveBalance, + createdInvoice, + paymentSuccessful, + channelSuccessful, + pushchannelupdated, + pushchannelend, + pushchannelerror, + pushchannelstatus, + connectSuccess, + disconnectSuccess +}) + +export default ipc diff --git a/app/reducers/payment.js b/app/reducers/payment.js index 2bf3bc96..448214f4 100644 --- a/app/reducers/payment.js +++ b/app/reducers/payment.js @@ -1,5 +1,5 @@ import { createSelector } from 'reselect' -import { callApi } from '../api' +import { ipcRenderer } from 'electron' // ------------------------------------ // Constants @@ -29,13 +29,6 @@ export function getPayments() { } } -export function receivePayments(data) { - return { - type: RECEIVE_PAYMENTS, - payments: data.payments.reverse() - } -} - export function sendPayment() { return { type: SEND_PAYMENT @@ -55,32 +48,24 @@ export function paymentFailed() { } } -export const fetchPayments = () => async (dispatch) => { +// Send IPC event for payments +export const fetchPayments = () => (dispatch) => { dispatch(getPayments()) - const payments = await callApi('payments') - - if (payments) { - dispatch(receivePayments(payments.data)) - } else { - dispatch(paymentFailed()) - } - - return payments + ipcRenderer.send('lnd', { msg: 'payments' }) } -export const payInvoice = payment_request => async (dispatch) => { - dispatch(sendPayment()) - const payment = await callApi('sendpayment', 'post', { payment_request }) - - if (payment) { - dispatch(fetchPayments()) - } else { - dispatch(paymentFailed()) - } +// Receive IPC event for payments +export const receivePayments = (event, { payments }) => dispatch => dispatch({ type: RECEIVE_PAYMENTS, payments }) - return payment +export const payInvoice = paymentRequest => (dispatch) => { + dispatch(sendPayment()) + ipcRenderer.send('lnd', { msg: 'sendPayment', data: { paymentRequest } }) } +// Receive IPC event for successful payment +// TODO: Add payment to state, not a total re-fetch +export const paymentSuccessful = () => fetchPayments() + // ------------------------------------ // Action Handlers diff --git a/app/reducers/peers.js b/app/reducers/peers.js index 8862e7e1..e6aec70e 100644 --- a/app/reducers/peers.js +++ b/app/reducers/peers.js @@ -1,5 +1,5 @@ import { createSelector } from 'reselect' -import { callApi } from '../api' +import { ipcRenderer } from 'electron' // ------------------------------------ // Constants // ------------------------------------ @@ -27,13 +27,6 @@ export function connectPeer() { } } -export function connectSuccess(peer) { - return { - type: CONNECT_SUCCESS, - peer - } -} - export function connectFailure() { return { type: CONNECT_FAILURE @@ -46,13 +39,6 @@ export function disconnectPeer() { } } -export function disconnectSuccess(pubkey) { - return { - type: DISCONNECT_SUCCESS, - pubkey - } -} - export function disconnectFailure() { return { type: DISCONNECT_FAILURE @@ -79,53 +65,47 @@ export function getPeers() { } } -export function receivePeers({ peers }) { - return { - type: RECEIVE_PEERS, - peers - } -} - +// Send IPC event for peers export const fetchPeers = () => async (dispatch) => { dispatch(getPeers()) - const peers = await callApi('peers') - dispatch(receivePeers(peers.data)) + ipcRenderer.send('lnd', { msg: 'peers' }) } -export const connectRequest = ({ pubkey, host }) => async (dispatch) => { - dispatch(connectPeer()) - const success = await callApi('connect', 'post', { pubkey, host }) - if (success.data) { - dispatch(connectSuccess({ pub_key: pubkey, address: host, peer_id: success.data.peer_id })) - } else { - dispatch(connectFailure()) - } +// Receive IPC event for peers +export const receivePeers = (event, { peers }) => dispatch => dispatch({ type: RECEIVE_PEERS, peers }) - return success +// Send IPC event for connecting to a peer +export const connectRequest = ({ pubkey, host }) => (dispatch) => { + dispatch(connectPeer()) + ipcRenderer.send('lnd', { msg: 'connectPeer', data: { pubkey, host } }) } -export const disconnectRequest = ({ pubkey }) => async (dispatch) => { - dispatch(disconnectPeer()) - const success = await callApi('disconnect', 'post', { pubkey }) - if (success) { - dispatch(disconnectSuccess(pubkey)) - } else { - dispatch(disconnectFailure()) - } +// Send IPC receive for successfully connecting to a peer +export const connectSuccess = (event, peer) => dispatch => dispatch({ type: CONNECT_SUCCESS, peer }) - return success +// Send IPC send for disconnecting from a peer +export const disconnectRequest = ({ pubkey }) => (dispatch) => { + dispatch(disconnectPeer()) + ipcRenderer.send('lnd', { msg: 'disconnectPeer', data: { pubkey } }) } +// Send IPC receive for successfully disconnecting from a peer +export const disconnectSuccess = (event, { pubkey }) => dispatch => dispatch({ type: DISCONNECT_SUCCESS, pubkey }) + // ------------------------------------ // Action Handlers // ------------------------------------ const ACTION_HANDLERS = { [DISCONNECT_PEER]: state => ({ ...state, disconnecting: true }), - [DISCONNECT_SUCCESS]: (state, { pubkey }) => ({ ...state, disconnecting: false, peers: state.peers.filter(peer => peer.pub_key !== pubkey) }), + [DISCONNECT_SUCCESS]: (state, { pubkey }) => ( + { ...state, disconnecting: false, peer: null, peers: state.peers.filter(peer => peer.pub_key !== pubkey) } + ), [DISCONNECT_FAILURE]: state => ({ ...state, disconnecting: false }), [CONNECT_PEER]: state => ({ ...state, connecting: true }), - [CONNECT_SUCCESS]: (state, { peer }) => ({ ...state, connecting: false, peers: [...state.peers, peer] }), + [CONNECT_SUCCESS]: (state, { peer }) => ( + { ...state, connecting: false, peerForm: { pubkey: '', host: '', isOpen: false }, peers: [...state.peers, peer] } + ), [CONNECT_FAILURE]: state => ({ ...state, connecting: false }), [SET_PEER_FORM]: (state, { form }) => ({ ...state, peerForm: Object.assign({}, state.peerForm, form) }), diff --git a/app/reducers/ticker.js b/app/reducers/ticker.js index 552d98b2..6e9a5fdb 100644 --- a/app/reducers/ticker.js +++ b/app/reducers/ticker.js @@ -1,4 +1,4 @@ -import { requestTicker } from '../api' +import requestTicker from '../api' // ------------------------------------ // Constants // ------------------------------------ diff --git a/app/routes/app/components/App.js b/app/routes/app/components/App.js index e125e70d..1571f911 100644 --- a/app/routes/app/components/App.js +++ b/app/routes/app/components/App.js @@ -2,14 +2,8 @@ import React, { Component } from 'react' import PropTypes from 'prop-types' import Form from './components/Form' import Nav from './components/Nav' -import Socket from './components/Socket' import styles from './App.scss' -export const CHANNEL_DATA = 'CHANNEL_DATA' -export const CHANNEL_END = 'CHANNEL_END' -export const CHANNEL_ERROR = 'CHANNEL_ERROR' -export const CHANNEL_STATUS = 'CHANNEL_STATUS' - class App extends Component { componentWillMount() { const { fetchTicker, fetchBalance } = this.props @@ -34,7 +28,6 @@ class App extends Component { setForm, createInvoice, payInvoice, - fetchChannels, fetchInvoice, children } = this.props @@ -66,8 +59,6 @@ class App extends Component {
{children}
- - ) } @@ -90,7 +81,6 @@ App.propTypes = { setForm: PropTypes.func.isRequired, createInvoice: PropTypes.func.isRequired, payInvoice: PropTypes.func.isRequired, - fetchChannels: PropTypes.func.isRequired, fetchInvoice: PropTypes.func.isRequired, children: PropTypes.object.isRequired } diff --git a/app/routes/app/components/components/Form/Form.js b/app/routes/app/components/components/Form/Form.js index 40c56eec..a646f7fd 100644 --- a/app/routes/app/components/components/Form/Form.js +++ b/app/routes/app/components/components/Form/Form.js @@ -20,16 +20,12 @@ const Form = ({ }) => { const requestClicked = () => { createInvoice(amount, message, currency, btcTicker.price_usd) - .then((success) => { - if (success) { close() } - }) + close() } const payClicked = () => { payInvoice(payment_request) - .then((success) => { - if (success) { close() } - }) + close() } const paymentRequestOnChange = (payreq) => { diff --git a/app/routes/app/components/components/Socket.js b/app/routes/app/components/components/Socket.js deleted file mode 100644 index 68113f28..00000000 --- a/app/routes/app/components/components/Socket.js +++ /dev/null @@ -1,20 +0,0 @@ -import React from 'react' -import PropTypes from 'prop-types' -import Websocket from 'react-websocket' - -const Socket = ({ fetchChannels }) => { - const onMessage = () => { - // TODO: Assumes only socket relationship is with channels. Actually flesh out socket logic - fetchChannels() - } - - return ( - - ) -} - -Socket.propTypes = { - fetchChannels: PropTypes.func.isRequired -} - -export default Socket diff --git a/app/routes/wallet/components/components/Channels/components/ChannelForm/ChannelForm.js b/app/routes/wallet/components/components/Channels/components/ChannelForm/ChannelForm.js index 88d6d076..fdc3160e 100644 --- a/app/routes/wallet/components/components/Channels/components/ChannelForm/ChannelForm.js +++ b/app/routes/wallet/components/components/Channels/components/ChannelForm/ChannelForm.js @@ -12,9 +12,8 @@ const ChannelForm = ({ form, setForm, ticker, peers, openChannel }) => { const localamt = ticker.currency === 'btc' ? btc.btcToSatoshis(local_amt) : btc.btcToSatoshis(usd.usdToBtc(local_amt, ticker.btcTicker.price_usd)) const pushamt = ticker.currency === 'btc' ? btc.btcToSatoshis(push_amt) : btc.btcToSatoshis(usd.usdToBtc(push_amt, ticker.btcTicker.price_usd)) - openChannel({ pubkey: node_key, localamt, pushamt }).then((channel) => { - if (channel.data) { setForm({ isOpen: false }) } - }) + openChannel({ pubkey: node_key, localamt, pushamt }) + setForm({ isOpen: false }) } const customStyles = { diff --git a/app/routes/wallet/components/components/Peers/components/PeerForm/PeerForm.js b/app/routes/wallet/components/components/Peers/components/PeerForm/PeerForm.js index adcbd07c..80a092d6 100644 --- a/app/routes/wallet/components/components/Peers/components/PeerForm/PeerForm.js +++ b/app/routes/wallet/components/components/Peers/components/PeerForm/PeerForm.js @@ -6,10 +6,7 @@ import styles from './PeerForm.scss' const PeerForm = ({ form, setForm, connect }) => { const submit = () => { const { pubkey, host } = form - - connect({ pubkey, host }).then((success) => { - if (success.data) { setForm({ isOpen: false }) } - }) + connect({ pubkey, host }) } const customStyles = { diff --git a/app/routes/wallet/components/components/Peers/components/PeerModal/PeerModal.js b/app/routes/wallet/components/components/Peers/components/PeerModal/PeerModal.js index 2c3b0724..ed578209 100644 --- a/app/routes/wallet/components/components/Peers/components/PeerModal/PeerModal.js +++ b/app/routes/wallet/components/components/Peers/components/PeerModal/PeerModal.js @@ -4,11 +4,6 @@ import ReactModal from 'react-modal' import styles from './PeerModal.scss' const PeerModal = ({ isOpen, resetPeer, peer, disconnect }) => { - const disconnectClicked = () => { - disconnect({ pubkey: peer.pub_key }) - .then(success => (success ? resetPeer(null) : null)) - } - const customStyles = { overlay: { cursor: 'pointer', @@ -55,7 +50,7 @@ const PeerModal = ({ isOpen, resetPeer, peer, disconnect }) => {
{peer.bytes_sent}
-
+
disconnect({ pubkey: peer.pub_key })}>
Disconnect peer
diff --git a/app/store/configureStore.dev.js b/app/store/configureStore.dev.js index d5861fb7..b3b41237 100644 --- a/app/store/configureStore.dev.js +++ b/app/store/configureStore.dev.js @@ -1,9 +1,10 @@ -import { createStore, applyMiddleware, compose } from 'redux'; -import thunk from 'redux-thunk'; -import { createHashHistory } from 'history'; -import { routerMiddleware, routerActions } from 'react-router-redux'; -import { createLogger } from 'redux-logger'; -import rootReducer from '../reducers'; +import { createStore, applyMiddleware, compose } from 'redux' +import thunk from 'redux-thunk' +import { createHashHistory } from 'history' +import { routerMiddleware, routerActions } from 'react-router-redux' +import { createLogger } from 'redux-logger' +import rootReducer from '../reducers' +import ipc from '../reducers/ipc' const history = createHashHistory(); @@ -41,7 +42,7 @@ const configureStore = (initialState?: counterStateType) => { /* eslint-enable no-underscore-dangle */ // Apply Middleware & Compose Enhancers - enhancers.push(applyMiddleware(...middleware)); + enhancers.push(applyMiddleware(...middleware, ipc)); const enhancer = composeEnhancers(...enhancers); // Create Store diff --git a/package.json b/package.json index 334aea19..74676645 100644 --- a/package.json +++ b/package.json @@ -137,6 +137,7 @@ "electron": "^1.6.10", "electron-builder": "^19.8.0", "electron-devtools-installer": "^2.2.0", + "electron-rebuild": "^1.6.0", "enzyme": "^2.9.1", "enzyme-to-json": "^1.5.1", "eslint": "^4.4.1", @@ -183,9 +184,11 @@ }, "dependencies": { "axios": "^0.16.2", + "bitcore-lib": "^0.14.0", "devtron": "^1.4.0", "electron-debug": "^1.2.0", "font-awesome": "^4.7.0", + "grpc": "^1.4.1", "history": "^4.6.3", "moment-timezone": "^0.5.13", "prop-types": "^15.5.10", @@ -204,11 +207,13 @@ "react-svg-morph": "^0.1.10", "react-websocket": "^1.1.7", "redux": "^3.7.1", + "redux-electron-ipc": "^1.1.10", "redux-thunk": "^2.2.0", "reselect": "^3.0.1", "satoshi-bitcoin": "^1.0.4", "source-map-support": "^0.4.15", - "xtend": "^4.0.1" + "xtend": "^4.0.1", + "zbase32": "^0.0.2" }, "devEngines": { "node": ">=7.x", diff --git a/test/api/index.spec.js b/test/api/index.spec.js deleted file mode 100644 index 927b9b5f..00000000 --- a/test/api/index.spec.js +++ /dev/null @@ -1,55 +0,0 @@ -import { callApi } from '../../app/api' - -describe('API', () => { - describe('getinfo', () => { - it('is synced to the chain', async () => { - const info = await callApi('info') - expect(info.data.synced_to_chain).toEqual(true) - }) - - it('only supports 1 chain at a time', async () => { - const info = await callApi('info') - expect(info.data.chains.length).toEqual(1) - }) - }) - - describe('balance', () => { - it('returns wallet balance', async () => { - const wallet_balances = await callApi('wallet_balance') - expect(typeof (wallet_balances.data.balance)).toEqual('string') - }) - - it('returns channel balance', async () => { - const channel_balances = await callApi('channel_balance') - expect(typeof (channel_balances.data.balance)).toEqual('string') - }) - }) - - describe('peers', () => { - it('peers is an array', async () => { - const peers = await callApi('peers') - expect(Array.isArray(peers.data.peers)).toEqual(true) - }) - }) - - describe('channels', () => { - it('channels is an array', async () => { - const channels = await callApi('channels') - expect(Array.isArray(channels.data.channels)).toEqual(true) - }) - }) - - describe('invoices', () => { - it('invoices is an array', async () => { - const invoices = await callApi('invoices') - expect(Array.isArray(invoices.data.invoices)).toEqual(true) - }) - }) - - describe('payments', () => { - it('payments is an array', async () => { - const payments = await callApi('payments') - expect(Array.isArray(payments.data.payments)).toEqual(true) - }) - }) -}) diff --git a/yarn.lock b/yarn.lock index 571df020..53e25b8b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -246,6 +246,10 @@ argparse@^1.0.7: dependencies: sprintf-js "~1.0.2" +arguejs@^0.2.3: + version "0.2.3" + resolved "https://registry.yarnpkg.com/arguejs/-/arguejs-0.2.3.tgz#b6f939f5fe0e3cd1f3f93e2aa9262424bf312af7" + aria-query@^0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/aria-query/-/aria-query-0.7.0.tgz#4af10a1e61573ddea0cf3b99b51c52c05b424d24" @@ -322,6 +326,13 @@ asar-integrity@0.1.1: bluebird-lst "^1.0.2" fs-extra-p "^4.3.0" +ascli@~1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/ascli/-/ascli-1.0.1.tgz#bcfa5974a62f18e81cabaeb49732ab4a88f906bc" + dependencies: + colour "~0.7.1" + optjs "~3.2.2" + asn1.js@^4.0.0: version "4.9.1" resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-4.9.1.tgz#48ba240b45a9280e94748990ba597d216617fd40" @@ -1474,6 +1485,17 @@ binary-extensions@^1.0.0: buffers "~0.1.1" chainsaw "~0.1.0" +bitcore-lib@^0.14.0: + version "0.14.0" + resolved "https://registry.yarnpkg.com/bitcore-lib/-/bitcore-lib-0.14.0.tgz#21cb2359fe7b997a3b7b773eb7d7275ae37d644e" + dependencies: + bn.js "=2.0.4" + bs58 "=2.0.0" + buffer-compare "=1.0.0" + elliptic "=3.0.3" + inherits "=2.0.1" + lodash "=3.10.1" + bl@^1.0.0: version "1.2.1" resolved "https://registry.yarnpkg.com/bl/-/bl-1.2.1.tgz#cac328f7bee45730d404b692203fcb590e172d5e" @@ -1496,6 +1518,14 @@ bluebird@^3.0.5, bluebird@^3.4.7, bluebird@^3.5.0: version "3.5.0" resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.5.0.tgz#791420d7f551eea2897453a8a77653f96606d67c" +bn.js@=2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-2.0.4.tgz#220a7cd677f7f1bfa93627ff4193776fe7819480" + +bn.js@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-2.2.0.tgz#12162bc2ae71fc40a5626c33438f3a875cd37625" + bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.1.1, bn.js@^4.4.0: version "4.11.6" resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.6.tgz#53344adb14617a13f6e8dd2ce28905d1c0ba3215" @@ -1623,6 +1653,10 @@ browserslist@^1.1.1, browserslist@^1.1.3, browserslist@^1.3.6, browserslist@^1.5 caniuse-db "^1.0.30000639" electron-to-chromium "^1.2.7" +bs58@=2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/bs58/-/bs58-2.0.0.tgz#72b713bed223a0ac518bbda0e3ce3f4817f39eb5" + bser@1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/bser/-/bser-1.0.2.tgz#381116970b2a6deea5646dd15dd7278444b56169" @@ -1635,6 +1669,10 @@ bser@^2.0.0: dependencies: node-int64 "^0.4.0" +buffer-compare@=1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/buffer-compare/-/buffer-compare-1.0.0.tgz#acaa7a966e98eee9fae14b31c39a5f158fb3c4a2" + buffer-crc32@^0.2.1: version "0.2.13" resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242" @@ -1667,6 +1705,12 @@ builtin-status-codes@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8" +bytebuffer@~5: + version "5.0.1" + resolved "https://registry.yarnpkg.com/bytebuffer/-/bytebuffer-5.0.1.tgz#582eea4b1a873b6d020a48d58df85f0bba6cfddd" + dependencies: + long "~3" + bytes@2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/bytes/-/bytes-2.3.0.tgz#d5b680a165b6201739acb611542aabc2d8ceb070" @@ -1703,7 +1747,7 @@ camelcase@^1.0.2: version "1.2.1" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-1.2.1.tgz#9bb5304d2e0b56698b2c758b08a3eaa9daa58a39" -camelcase@^2.0.0: +camelcase@^2.0.0, camelcase@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-2.1.1.tgz#7c1d16d679a1bbe59ca02cacecfb011e201f5a1f" @@ -1873,6 +1917,10 @@ cli-cursor@^2.1.0: dependencies: restore-cursor "^2.0.0" +cli-spinners@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-1.0.0.tgz#ef987ed3d48391ac3dab9180b406a742180d6e6a" + cli-width@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.1.0.tgz#b234ca209b29ef66fc518d9b98d5847b00edf00a" @@ -1885,7 +1933,7 @@ cliui@^2.1.0: right-align "^0.1.1" wordwrap "0.0.2" -cliui@^3.2.0: +cliui@^3.0.3, cliui@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/cliui/-/cliui-3.2.0.tgz#120601537a916d29940f934da3b48d585a39213d" dependencies: @@ -1990,6 +2038,10 @@ colors@^1.1.2, colors@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/colors/-/colors-1.1.2.tgz#168a4701756b6a7f51a12ce0c97bfa28c084ed63" +colour@~0.7.1: + version "0.7.1" + resolved "https://registry.yarnpkg.com/colour/-/colour-0.7.1.tgz#9cb169917ec5d12c0736d3e8685746df1cadf778" + combined-stream@^1.0.5, combined-stream@~1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.5.tgz#938370a57b4a51dea2c77c15d5c5fdf895164009" @@ -2476,7 +2528,7 @@ debug@2.6.7: dependencies: ms "2.0.0" -debug@2.6.8, debug@^2.1.1, debug@^2.1.3, debug@^2.2.0, debug@^2.4.5, debug@^2.6.0, debug@^2.6.1, debug@^2.6.3, debug@^2.6.6, debug@^2.6.8: +debug@2.6.8, debug@^2.1.1, debug@^2.1.3, debug@^2.2.0, debug@^2.4.5, debug@^2.5.1, debug@^2.6.0, debug@^2.6.1, debug@^2.6.3, debug@^2.6.6, debug@^2.6.8: version "2.6.8" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.8.tgz#e731531ca2ede27d188222427da17821d68ff4fc" dependencies: @@ -2918,6 +2970,20 @@ electron-publish@19.8.0: fs-extra-p "^4.3.0" mime "^1.3.6" +electron-rebuild@^1.6.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/electron-rebuild/-/electron-rebuild-1.6.0.tgz#e8d26f4d8e9fe5388df35864b3658e5cfd4dcb7e" + dependencies: + colors "^1.1.2" + debug "^2.6.3" + fs-extra "^3.0.1" + node-abi "^2.0.0" + node-gyp "^3.6.0" + ora "^1.2.0" + rimraf "^2.6.1" + spawn-rx "^2.0.10" + yargs "^7.0.2" + electron-to-chromium@^1.2.7, electron-to-chromium@^1.3.11: version "1.3.14" resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.14.tgz#64af0f9efd3c3c6acd57d71f83b49ca7ee9c4b43" @@ -2930,6 +2996,15 @@ electron@^1.6.10: electron-download "^3.0.1" extract-zip "^1.0.3" +elliptic@=3.0.3: + version "3.0.3" + resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-3.0.3.tgz#865c9b420bfbe55006b9f969f97a0d2c44966595" + dependencies: + bn.js "^2.0.0" + brorand "^1.0.1" + hash.js "^1.0.0" + inherits "^2.0.1" + elliptic@^6.0.0: version "6.4.0" resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.4.0.tgz#cac9af8762c85836187003c8dfe193e5e2eae5df" @@ -4024,6 +4099,16 @@ growly@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081" +grpc@^1.4.1: + version "1.4.1" + resolved "https://registry.yarnpkg.com/grpc/-/grpc-1.4.1.tgz#3ee4a8346a613f2823928c9f8f99081b6368ec7c" + dependencies: + arguejs "^0.2.3" + lodash "^4.15.0" + nan "^2.0.0" + node-pre-gyp "^0.6.35" + protobufjs "^5.0.0" + gulp-util@^3.0.4: version "3.0.8" resolved "https://registry.yarnpkg.com/gulp-util/-/gulp-util-3.0.8.tgz#0054e1e744502e27c04c187c3ecc505dd54bbb4f" @@ -4393,7 +4478,7 @@ inherits@2, inherits@2.0.3, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.0, i version "2.0.3" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" -inherits@2.0.1: +inherits@2.0.1, inherits@=2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.1.tgz#b17d08d326b4423e568eff719f91b0b1cbdf69f1" @@ -5504,6 +5589,10 @@ lodash.uniq@^4.5.0: version "4.5.0" resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" +lodash@=3.10.1: + version "3.10.1" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" + lodash@^4.0.0, lodash@^4.1.0, lodash@^4.13.1, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.2, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0, lodash@^4.5.1, lodash@^4.6.1, lodash@^4.8.0, lodash@~4.17.4: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" @@ -5518,6 +5607,10 @@ lolex@^1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/lolex/-/lolex-1.6.0.tgz#3a9a0283452a47d7439e72731b9e07d7386e49f6" +long@~3: + version "3.2.0" + resolved "https://registry.yarnpkg.com/long/-/long-3.2.0.tgz#d821b7138ca1cb581c172990ef14db200b5c474b" + longest@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097" @@ -5789,7 +5882,7 @@ mute-stream@0.0.7: version "0.0.7" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" -nan@^2.3.0, nan@^2.3.2: +nan@^2.0.0, nan@^2.3.0, nan@^2.3.2: version "2.6.2" resolved "https://registry.yarnpkg.com/nan/-/nan-2.6.2.tgz#e4ff34e6c95fdfb5aecc08de6596f43605a7db45" @@ -5821,6 +5914,10 @@ no-case@^2.2.0: dependencies: lower-case "^1.1.1" +node-abi@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/node-abi/-/node-abi-2.1.0.tgz#50ad834affcf17440e12bfc5f9ba0946f572d10c" + node-emoji@^1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/node-emoji/-/node-emoji-1.5.1.tgz#fd918e412769bf8c448051238233840b2aff16a1" @@ -5838,7 +5935,7 @@ node-forge@0.6.33: version "0.6.33" resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.6.33.tgz#463811879f573d45155ad6a9f43dc296e8e85ebc" -node-gyp@^3.3.1: +node-gyp@^3.3.1, node-gyp@^3.6.0: version "3.6.2" resolved "https://registry.yarnpkg.com/node-gyp/-/node-gyp-3.6.2.tgz#9bfbe54562286284838e750eac05295853fa1c60" dependencies: @@ -5925,7 +6022,7 @@ node-notifier@^5.0.2: shellwords "^0.1.0" which "^1.2.12" -node-pre-gyp@^0.6.29: +node-pre-gyp@^0.6.29, node-pre-gyp@^0.6.35: version "0.6.36" resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.36.tgz#db604112cb74e0d477554e9b505b17abddfab786" dependencies: @@ -6182,6 +6279,19 @@ optionator@^0.8.1, optionator@^0.8.2: type-check "~0.3.2" wordwrap "~1.0.0" +optjs@~3.2.2: + version "3.2.2" + resolved "https://registry.yarnpkg.com/optjs/-/optjs-3.2.2.tgz#69a6ce89c442a44403141ad2f9b370bd5bb6f4ee" + +ora@^1.2.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/ora/-/ora-1.3.0.tgz#80078dd2b92a934af66a3ad72a5b910694ede51a" + dependencies: + chalk "^1.1.1" + cli-cursor "^2.1.0" + cli-spinners "^1.0.0" + log-symbols "^1.0.2" + original@>=0.0.5: version "1.0.0" resolved "https://registry.yarnpkg.com/original/-/original-1.0.0.tgz#9147f93fa1696d04be61e01bd50baeaca656bd3b" @@ -6828,6 +6938,15 @@ prop-types@^15.5.10, prop-types@^15.5.4, prop-types@^15.5.6, prop-types@^15.5.8: fbjs "^0.8.9" loose-envify "^1.3.1" +protobufjs@^5.0.0: + version "5.0.2" + resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-5.0.2.tgz#59748d7dcf03d2db22c13da9feb024e16ab80c91" + dependencies: + ascli "~1" + bytebuffer "~5" + glob "^7.0.5" + yargs "^3.10.0" + proxy-addr@~1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-1.1.4.tgz#27e545f6960a44a627d9b44467e35c1b6b4ce2f3" @@ -7210,6 +7329,10 @@ reduce-function-call@^1.0.1: dependencies: balanced-match "^0.4.2" +redux-electron-ipc@^1.1.10: + version "1.1.10" + resolved "https://registry.yarnpkg.com/redux-electron-ipc/-/redux-electron-ipc-1.1.10.tgz#0e4de0ae30eb8571209f24e75149007e965e65d1" + redux-logger@^3.0.6: version "3.0.6" resolved "https://registry.yarnpkg.com/redux-logger/-/redux-logger-3.0.6.tgz#f7555966f3098f3c88604c449cf0baf5778274bf" @@ -7479,6 +7602,12 @@ rx@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/rx/-/rx-4.1.0.tgz#a5f13ff79ef3b740fe30aa803fb09f98805d4782" +rxjs@^5.1.1: + version "5.4.3" + resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.4.3.tgz#0758cddee6033d68e0fd53676f0f3596ce3d483f" + dependencies: + symbol-observable "^1.0.1" + safe-buffer@^5.0.1, safe-buffer@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.0.tgz#fe4c8460397f9eaaaa58e73be46273408a45e223" @@ -7793,6 +7922,14 @@ spawn-command@^0.0.2-1: version "0.0.2" resolved "https://registry.yarnpkg.com/spawn-command/-/spawn-command-0.0.2.tgz#9544e1a43ca045f8531aac1a48cb29bdae62338e" +spawn-rx@^2.0.10: + version "2.0.11" + resolved "https://registry.yarnpkg.com/spawn-rx/-/spawn-rx-2.0.11.tgz#65451ad65662801daea75549832a782de0048dbf" + dependencies: + debug "^2.5.1" + lodash.assign "^4.2.0" + rxjs "^5.1.1" + spdx-correct@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-1.0.2.tgz#4b3073d933ff51f3912f03ac5519498a4150db40" @@ -8228,7 +8365,7 @@ svgpath@^2.1.0: version "2.2.1" resolved "https://registry.yarnpkg.com/svgpath/-/svgpath-2.2.1.tgz#0834bb67c89a76472b2bd06cc101fa7b517b222c" -symbol-observable@^1.0.3: +symbol-observable@^1.0.1, symbol-observable@^1.0.3: version "1.0.4" resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.4.tgz#29bf615d4aa7121bdd898b22d4b3f9bc4e2aa03d" @@ -8948,6 +9085,10 @@ window-size@0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d" +window-size@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.4.tgz#f8e1aa1ee5a53ec5bf151ffa09742a6ad7697876" + window-size@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.2.0.tgz#b4315bb4214a3d7058ebeee892e13fa24d98b075" @@ -9033,7 +9174,7 @@ xtend@~2.1.1: dependencies: object-keys "~0.4.0" -y18n@^3.2.1: +y18n@^3.2.0, y18n@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/y18n/-/y18n-3.2.1.tgz#6d15fba884c08679c0d77e88e7759e811e07fa41" @@ -9070,6 +9211,18 @@ yargs@^1.2.6: version "1.3.3" resolved "https://registry.yarnpkg.com/yargs/-/yargs-1.3.3.tgz#054de8b61f22eefdb7207059eaef9d6b83fb931a" +yargs@^3.10.0: + version "3.32.0" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.32.0.tgz#03088e9ebf9e756b69751611d2a5ef591482c995" + dependencies: + camelcase "^2.0.1" + cliui "^3.0.3" + decamelize "^1.1.1" + os-locale "^1.4.0" + string-width "^1.0.1" + window-size "^0.1.4" + y18n "^3.2.0" + yargs@^3.5.4, yargs@~3.10.0: version "3.10.0" resolved "https://registry.yarnpkg.com/yargs/-/yargs-3.10.0.tgz#f7ee7bd857dd7c1d2d38c0e74efbd681d1431fd1" @@ -9158,6 +9311,10 @@ yauzl@2.4.1: dependencies: fd-slicer "~1.0.1" +zbase32@^0.0.2: + version "0.0.2" + resolved "https://registry.yarnpkg.com/zbase32/-/zbase32-0.0.2.tgz#169c6f2130a6c27a84247017538b56826a54b283" + zip-stream@^1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/zip-stream/-/zip-stream-1.1.1.tgz#5216b48bbb4d2651f64d5c6e6f09eb4a7399d557"