ListOrders
ListOrders returns a list of all active and archived orders that are currently known to the trader daemon.
Source: poolrpc/trader.proto
gRPC
rpc ListOrders (ListOrdersRequest) returns (ListOrdersResponse);
REST
HTTP Method | Path |
---|---|
GET | /v1/pool/orders |
Code Samples
- gRPC
- REST
- Shell
- Javascript
- Python
const fs = require('fs');
const grpc = require('@grpc/grpc-js');
const protoLoader = require('@grpc/proto-loader');
const GRPC_HOST = 'localhost:12010'
const MACAROON_PATH = 'POOL_DIR/regtest/pool.macaroon'
const TLS_PATH = 'POOL_DIR/tls.cert'
const loaderOptions = {
keepCase: true,
longs: String,
enums: String,
defaults: true,
oneofs: true,
};
const packageDefinition = protoLoader.loadSync('poolrpc/trader.proto', loaderOptions);
const poolrpc = grpc.loadPackageDefinition(packageDefinition).poolrpc;
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 poolrpc.Trader(GRPC_HOST, creds);
let request = {
verbose: <bool>,
active_only: <bool>,
};
client.listOrders(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "asks": <Ask>,
// "bids": <Bid>,
// }
import codecs, grpc, os
# Generate the following 2 modules by compiling the poolrpc/trader.proto with the grpcio-tools.
# See https://github.com/lightningnetwork/lnd/blob/master/docs/grpc/python.md for instructions.
import trader_pb2 as poolrpc, trader_pb2_grpc as traderstub
GRPC_HOST = 'localhost:12010'
MACAROON_PATH = 'POOL_DIR/regtest/pool.macaroon'
TLS_PATH = 'POOL_DIR/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 = traderstub.TraderStub(channel)
request = poolrpc.ListOrdersRequest(
verbose=<bool>,
active_only=<bool>,
)
response = stub.ListOrders(request)
print(response)
# {
# "asks": <Ask>,
# "bids": <Bid>,
# }
- Javascript
- Python
const fs = require('fs');
const request = require('request');
const REST_HOST = 'localhost:8281'
const MACAROON_PATH = 'POOL_DIR/regtest/pool.macaroon'
let options = {
url: `https://${REST_HOST}/v1/pool/orders`,
// 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:
// {
// "asks": <array>, // <Ask>
// "bids": <array>, // <Bid>
// }
import base64, codecs, json, requests
REST_HOST = 'localhost:8281'
MACAROON_PATH = 'POOL_DIR/regtest/pool.macaroon'
TLS_PATH = 'POOL_DIR/tls.cert'
url = f'https://{REST_HOST}/v1/pool/orders'
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())
# {
# "asks": <Ask>,
# "bids": <Bid>,
# }
$ pool orders list --help
NAME:
pool orders list - list all existing orders
USAGE:
pool orders list [command options] [arguments...]
DESCRIPTION:
List all orders that are stored in the local order database
OPTIONS:
--verbose show verbose output including events
--show_archived include orders no longer active
Messages
poolrpc.ListOrdersRequest
Source: poolrpc/trader.proto
Field | gRPC Type | REST Type | REST Placement |
---|---|---|---|
verbose | bool | boolean | query |
active_only | bool | boolean | query |
poolrpc.ListOrdersResponse
Source: poolrpc/trader.proto
Field | gRPC Type | REST Type |
---|---|---|
asks | Ask[] | array |
bids | Bid[] | array |
Nested Messages
poolrpc.Ask
Field | gRPC Type | REST Type |
---|---|---|
details | Order | object |
lease_duration_blocks | uint32 | integer |
version | uint32 | integer |
announcement_constraints | ChannelAnnouncementConstraints | string |
confirmation_constraints | ChannelConfirmationConstraints | string |
poolrpc.Bid
Field | gRPC Type | REST Type |
---|---|---|
details | Order | object |
lease_duration_blocks | uint32 | integer |
version | uint32 | integer |
min_node_tier | NodeTier | string |
self_chan_balance | uint64 | string |
sidecar_ticket | string | string |
unannounced_channel | bool | boolean |
zero_conf_channel | bool | boolean |
poolrpc.MatchEvent
Field | gRPC Type | REST Type |
---|---|---|
match_state | MatchState | string |
units_filled | uint32 | integer |
matched_order | bytes | string |
reject_reason | MatchRejectReason | string |
poolrpc.Order
Field | gRPC Type | REST Type |
---|---|---|
trader_key | bytes | string |
rate_fixed | uint32 | integer |
amt | uint64 | string |
max_batch_fee_rate_sat_per_kw | uint64 | string |
order_nonce | bytes | string |
state | OrderState | string |
units | uint32 | integer |
units_unfulfilled | uint32 | integer |
reserved_value_sat | uint64 | string |
creation_timestamp_ns | uint64 | string |
events | OrderEvent[] | array |
min_units_match | uint32 | integer |
channel_type | OrderChannelType | string |
allowed_node_ids | bytes[] | array |
not_allowed_node_ids | bytes[] | array |
auction_type | AuctionType | string |
is_public | bool | boolean |
poolrpc.OrderEvent
Field | gRPC Type | REST Type |
---|---|---|
timestamp_ns | int64 | string |
event_str | string | string |
state_change | UpdatedEvent | object |
matched | MatchEvent | object |
poolrpc.UpdatedEvent
Field | gRPC Type | REST Type |
---|---|---|
previous_state | OrderState | string |
new_state | OrderState | string |
units_filled | uint32 | integer |
Enums
poolrpc.AuctionType
Name | Number |
---|---|
AUCTION_TYPE_BTC_INBOUND_LIQUIDITY | 0 |
AUCTION_TYPE_BTC_OUTBOUND_LIQUIDITY | 1 |
poolrpc.ChannelAnnouncementConstraints
Name | Number |
---|---|
ANNOUNCEMENT_NO_PREFERENCE | 0 |
ONLY_ANNOUNCED | 1 |
ONLY_UNANNOUNCED | 2 |
poolrpc.ChannelConfirmationConstraints
Name | Number |
---|---|
CONFIRMATION_NO_PREFERENCE | 0 |
ONLY_CONFIRMED | 1 |
ONLY_ZEROCONF | 2 |
poolrpc.MatchRejectReason
Name | Number |
---|---|
NONE | 0 |
SERVER_MISBEHAVIOR | 1 |
BATCH_VERSION_MISMATCH | 2 |
PARTIAL_REJECT_COLLATERAL | 3 |
PARTIAL_REJECT_DUPLICATE_PEER | 4 |
PARTIAL_REJECT_CHANNEL_FUNDING_FAILED | 5 |
poolrpc.MatchState
Name | Number |
---|---|
PREPARE | 0 |
ACCEPTED | 1 |
REJECTED | 2 |
SIGNED | 3 |
FINALIZED | 4 |
poolrpc.NodeTier
Name | Number |
---|---|
TIER_DEFAULT | 0 |
TIER_0 | 1 |
TIER_1 | 2 |
poolrpc.OrderChannelType
Name | Number |
---|---|
ORDER_CHANNEL_TYPE_UNKNOWN | 0 |
ORDER_CHANNEL_TYPE_PEER_DEPENDENT | 1 |
ORDER_CHANNEL_TYPE_SCRIPT_ENFORCED | 2 |
ORDER_CHANNEL_TYPE_SIMPLE_TAPROOT | 3 |
poolrpc.OrderState
Name | Number |
---|---|
ORDER_SUBMITTED | 0 |
ORDER_CLEARED | 1 |
ORDER_PARTIALLY_FILLED | 2 |
ORDER_EXECUTED | 3 |
ORDER_CANCELED | 4 |
ORDER_EXPIRED | 5 |
ORDER_FAILED | 6 |