ListStaticAddresses
ListStaticAddresses lists saved static addresses, including addresses that have never received a deposit. Each page reads a fresh database snapshot and orders addresses by ID.
Source: looprpc/client.proto
gRPC
rpc ListStaticAddresses (ListStaticAddressesRequest) returns (ListStaticAddressesResponse);
REST
| HTTP Method | Path |
|---|---|
| GET | /v1/staticaddr/addresses |
Code Samples
- gRPC
- REST
- loop
- Javascript
- Python
- grpcurl
const fs = require('fs');
const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');
const GRPC_HOST = 'localhost:11010'
const MACAROON_PATH = 'LOOP_DIR/regtest/loop.macaroon'
const TLS_PATH = 'LOOP_DIR/regtest/tls.cert'
const loaderOptions = {
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true,
};
const packageDefinition = protoLoader.loadSync('looprpc/client.proto', loaderOptions);
const looprpc = grpc.loadPackageDefinition(packageDefinition).looprpc;
process.env.GRPC_SSL_CIPHER_SUITES = 'HIGH+ECDSA';
const tlsCert = fs.readFileSync(TLS_PATH);
const sslCreds = grpc.credentials.createSsl(tlsCert);
const macaroon = fs.readFileSync(MACAROON_PATH).toString('hex');
const macaroonCreds = grpc.credentials.createFromMetadataGenerator(function(args, callback) {
let metadata = new grpc.Metadata();
metadata.add('macaroon', macaroon);
callback(null, metadata);
});
let creds = grpc.credentials.combineChannelCredentials(sslCreds, macaroonCreds);
let client = new looprpc.SwapClient(GRPC_HOST, creds);
let request = {
labels: <string>,
include_deposits: <bool>,
state_filter: <DepositState>,
after_id: <uint32>,
page_size: <uint32>,
};
client.listStaticAddresses(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "addresses": <StaticAddressInfo>,
// "next_after_id": <uint32>,
// }
import codecs, grpc, os
# Generate the following 2 modules by compiling the looprpc/client.proto with the grpcio-tools.
# See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions.
import client_pb2 as looprpc, client_pb2_grpc as clientstub
GRPC_HOST = 'localhost:11010'
MACAROON_PATH = 'LOOP_DIR/regtest/loop.macaroon'
TLS_PATH = 'LOOP_DIR/regtest/tls.cert'
# create macaroon credentials
macaroon = codecs.encode(open(MACAROON_PATH, 'rb').read(), 'hex')
def metadata_callback(context, callback):
callback([('macaroon', macaroon)], None)
auth_creds = grpc.metadata_call_credentials(metadata_callback)
# create SSL credentials
os.environ['GRPC_SSL_CIPHER_SUITES'] = 'HIGH+ECDSA'
cert = open(TLS_PATH, 'rb').read()
ssl_creds = grpc.ssl_channel_credentials(cert)
# combine macaroon and SSL credentials
combined_creds = grpc.composite_channel_credentials(ssl_creds, auth_creds)
# make the request
channel = grpc.secure_channel(GRPC_HOST, combined_creds)
stub = clientstub.SwapClientStub(channel)
request = looprpc.ListStaticAddressesRequest(
labels=<string>,
include_deposits=<bool>,
state_filter=<DepositState>,
after_id=<uint32>,
page_size=<uint32>,
)
response = stub.ListStaticAddresses(request)
print(response)
# {
# "addresses": <StaticAddressInfo>,
# "next_after_id": <uint32>,
# }
# grpcurl docs: https://github.com/fullstorydev/grpcurl
# Proto source: https://github.com/lightninglabs/loop
# Also requires: https://github.com/lightningnetwork/lnd
GRPC_HOST=localhost:11010
LOOP_DIR=~/.loop
LOOP_SOURCE=path/to/loop
LND_SOURCE=path/to/lnd
NETWORK=mainnet
MACAROON_PATH="$LOOP_DIR/$NETWORK/loop.macaroon"
TLS_PATH="$LOOP_DIR/$NETWORK/tls.cert"
grpcurl \
-import-path $LOOP_SOURCE \
-import-path $LND_SOURCE \
-proto looprpc/client.proto \
-cacert $TLS_PATH \
-H "macaroon: $(xxd -ps -u -c 1000 $MACAROON_PATH)" \
-d '{ "labels": <string>, "include_deposits": <bool>, "state_filter": <DepositState>, "after_id": <uint32>, "page_size": <uint32> }' \
$GRPC_HOST \
looprpc.SwapClient/ListStaticAddresses
- Javascript
- Python
- curl
const fs = require('fs');
const request = require('request');
const REST_HOST = 'localhost:8081'
const MACAROON_PATH = 'LOOP_DIR/regtest/loop.macaroon'
let options = {
url: `https://${REST_HOST}/v1/staticaddr/addresses`,
// Work-around for self-signed certificates.
rejectUnauthorized: false,
json: true,
headers: {
'Grpc-Metadata-macaroon': fs.readFileSync(MACAROON_PATH).toString('hex'),
},
}
request.get(options, function(error, response, body) {
console.log(body);
});
// Console output:
// {
// "addresses": <array>, // <StaticAddressInfo>
// "next_after_id": <integer>, // <uint32>
// }
import base64, codecs, json, requests
REST_HOST = 'localhost:8081'
MACAROON_PATH = 'LOOP_DIR/regtest/loop.macaroon'
TLS_PATH = 'LOOP_DIR/regtest/tls.cert'
url = f'https://{REST_HOST}/v1/staticaddr/addresses'
macaroon = codecs.encode(open(MACAROON_PATH, 'rb').read(), 'hex')
headers = {'Grpc-Metadata-macaroon': macaroon}
r = requests.get(url, headers=headers, verify=TLS_PATH)
print(r.json())
# {
# "addresses": <StaticAddressInfo>,
# "next_after_id": <uint32>,
# }
REST_HOST=localhost:8081
LOOP_DIR=~/.loop
NETWORK=mainnet
MACAROON_PATH="$LOOP_DIR/$NETWORK/loop.macaroon"
TLS_PATH="$LOOP_DIR/$NETWORK/tls.cert"
curl \
--cacert $TLS_PATH \
-H "Grpc-Metadata-macaroon: $(xxd -ps -u -c 1000 $MACAROON_PATH)" \
https://$REST_HOST/v1/staticaddr/addresses
$ loop static listaddresses --help
NAME:
loop static listaddresses - List all saved static addresses, including unfunded addresses.
USAGE:
loop static listaddresses [options]
OPTIONS:
--label string [ --label string ] match an exact, case-sensitive address label. Repeat to match any label. Commas are literal and an empty label matches unlabeled addresses
--include-deposits include visible deposits for each address, optionally limited by --filter. With --filter, addresses with no matching deposits are left out (default: false)
--filter string specify a filter to only display deposits in the specified state. Leaving out the filter returns all deposits.
The state can be one of the following:
deposited
withdrawing
withdrawn
looping_in
looped_in
opening_channel
channel_published
publish_expired_deposit
sweep_htlc_timeout
htlc_timeout_swept
wait_for_expiry_sweep
expired
--help, -h show help
GLOBAL OPTIONS:
--rpcserver string loopd daemon address host:port (default: "localhost:11010") [$LOOPCLI_RPCSERVER]
--network string, -n string the network loop is running on e.g. mainnet, testnet, etc. (default: "mainnet") [$LOOPCLI_NETWORK]
--loopdir string path to loop's base directory (default: ~/.loop) [$LOOPCLI_LOOPDIR]
--tlscertpath string path to loop's TLS certificate (default: ~/.loop/mainnet/tls.cert) [$LOOPCLI_TLSCERTPATH]
--macaroonpath string path to macaroon file (default: ~/.loop/mainnet/loop.macaroon) [$LOOPCLI_MACAROONPATH]
Messages
looprpc.ListStaticAddressesRequest
Source: looprpc/client.proto
| Field | gRPC Type | REST Type | REST Placement |
|---|---|---|---|
labels | string[] | array | query |
include_deposits | bool | boolean | query |
state_filter | DepositState | object | query |
after_id | uint32 | integer | query |
page_size | uint32 | integer | query |
looprpc.ListStaticAddressesResponse
Source: looprpc/client.proto
| Field | gRPC Type | REST Type |
|---|---|---|
addresses | StaticAddressInfo[] | array |
next_after_id | uint32 | integer |
Nested Messages
looprpc.Deposit
| Field | gRPC Type | REST Type |
|---|---|---|
id | bytes | string |
state | DepositState | string |
outpoint | string | string |
value | int64 | string |
confirmation_height | int64 | string |
blocks_until_expiry | int64 | string |
swap_hash | bytes | string |
cost_onchain | int64 | string |
cost_onchain_status | OnchainCostStatus | string |
static_address | string | string |
address_label | string | string |
funding_tx_label | string | string |
looprpc.StaticAddressInfo
| Field | gRPC Type | REST Type |
|---|---|---|
static_address | string | string |
address_label | string | string |
type | StaticAddressType | string |
key_family | uint32 | integer |
key_index | uint32 | integer |
expiry | uint32 | integer |
initiation_height | int32 | integer |
protocol_version | uint32 | integer |
deposits | Deposit[] | array |
Enums
looprpc.DepositState
| Name | Number |
|---|---|
UNKNOWN_STATE | 0 |
DEPOSITED | 1 |
WITHDRAWING | 2 |
WITHDRAWN | 3 |
LOOPING_IN | 4 |
LOOPED_IN | 5 |
SWEEP_HTLC_TIMEOUT | 6 |
HTLC_TIMEOUT_SWEPT | 7 |
PUBLISH_EXPIRED | 8 |
WAIT_FOR_EXPIRY_SWEEP | 9 |
EXPIRED | 10 |
OPENING_CHANNEL | 11 |
CHANNEL_PUBLISHED | 12 |
looprpc.OnchainCostStatus
| Name | Number |
|---|---|
ONCHAIN_COST_STATUS_UNKNOWN | 0 |
ONCHAIN_COST_STATUS_PARTIAL | 1 |
ONCHAIN_COST_STATUS_COMPLETE | 2 |
ONCHAIN_COST_STATUS_PENDING | 3 |
looprpc.StaticAddressType
| Name | Number |
|---|---|
STATIC_ADDRESS_TYPE_UNKNOWN | 0 |
STATIC_ADDRESS_TYPE_LEGACY | 1 |
STATIC_ADDRESS_TYPE_RECEIVE | 2 |
STATIC_ADDRESS_TYPE_CHANGE | 3 |