Skip to main content

SubmitOrder

SubmitOrder creates a new ask or bid order and submits for the given account and submits it to the auction server for matching.

Source: poolrpc/trader.proto

gRPC

rpc SubmitOrder (SubmitOrderRequest) returns (SubmitOrderResponse);

REST

HTTP MethodPath
POST /v1/pool/orders

Code Samples

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 = {
ask: <Ask>,
bid: <Bid>,
initiator: <string>,
};
client.submitOrder(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "invalid_order": <InvalidOrder>,
// "accepted_order_nonce": <bytes>,
// "updated_sidecar_ticket": <string>,
// }

Messages

poolrpc.SubmitOrderRequest

Source: poolrpc/trader.proto

FieldgRPC TypeREST TypeREST Placement
ask
Askobjectbody
bid
Bidobjectbody
initiator
stringstringbody

poolrpc.SubmitOrderResponse

Source: poolrpc/trader.proto

FieldgRPC TypeREST Type
invalid_order
InvalidOrderobject
accepted_order_nonce
bytesstring
updated_sidecar_ticket
stringstring

Nested Messages

poolrpc.Ask

FieldgRPC TypeREST Type
details
Orderobject
lease_duration_blocks
uint32integer
version
uint32integer
announcement_constraints
ChannelAnnouncementConstraintsstring
confirmation_constraints
ChannelConfirmationConstraintsstring

poolrpc.Bid

FieldgRPC TypeREST Type
details
Orderobject
lease_duration_blocks
uint32integer
version
uint32integer
min_node_tier
NodeTierstring
self_chan_balance
uint64string
sidecar_ticket
stringstring
unannounced_channel
boolboolean
zero_conf_channel
boolboolean

poolrpc.InvalidOrder

FieldgRPC TypeREST Type
order_nonce
bytesstring
fail_reason
FailReasonstring
fail_string
stringstring

poolrpc.MatchEvent

FieldgRPC TypeREST Type
match_state
MatchStatestring
units_filled
uint32integer
matched_order
bytesstring
reject_reason
MatchRejectReasonstring

poolrpc.Order

FieldgRPC TypeREST Type
trader_key
bytesstring
rate_fixed
uint32integer
amt
uint64string
max_batch_fee_rate_sat_per_kw
uint64string
order_nonce
bytesstring
state
OrderStatestring
units
uint32integer
units_unfulfilled
uint32integer
reserved_value_sat
uint64string
creation_timestamp_ns
uint64string
events
OrderEvent[]array
min_units_match
uint32integer
channel_type
OrderChannelTypestring
allowed_node_ids
bytes[]array
not_allowed_node_ids
bytes[]array
auction_type
AuctionTypestring
is_public
boolboolean

poolrpc.OrderEvent

FieldgRPC TypeREST Type
timestamp_ns
int64string
event_str
stringstring
state_change
UpdatedEventobject
matched
MatchEventobject

poolrpc.UpdatedEvent

FieldgRPC TypeREST Type
previous_state
OrderStatestring
new_state
OrderStatestring
units_filled
uint32integer

Enums

poolrpc.AuctionType

NameNumber
AUCTION_TYPE_BTC_INBOUND_LIQUIDITY
0
AUCTION_TYPE_BTC_OUTBOUND_LIQUIDITY
1

poolrpc.ChannelAnnouncementConstraints

NameNumber
ANNOUNCEMENT_NO_PREFERENCE
0
ONLY_ANNOUNCED
1
ONLY_UNANNOUNCED
2

poolrpc.ChannelConfirmationConstraints

NameNumber
CONFIRMATION_NO_PREFERENCE
0
ONLY_CONFIRMED
1
ONLY_ZEROCONF
2

poolrpc.InvalidOrder.FailReason

NameNumber
INVALID_AMT
0

poolrpc.MatchRejectReason

NameNumber
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

NameNumber
PREPARE
0
ACCEPTED
1
REJECTED
2
SIGNED
3
FINALIZED
4

poolrpc.NodeTier

NameNumber
TIER_DEFAULT
0
TIER_0
1
TIER_1
2

poolrpc.OrderChannelType

NameNumber
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

NameNumber
ORDER_SUBMITTED
0
ORDER_CLEARED
1
ORDER_PARTIALLY_FILLED
2
ORDER_EXECUTED
3
ORDER_CANCELED
4
ORDER_EXPIRED
5
ORDER_FAILED
6