Skip to main content

LoopOut

LoopOut initiates an loop out swap with the given parameters. The call returns after the swap has been set up with the swap server. From that point onwards, progress can be tracked via the SwapStatus stream that is returned from Monitor().

Source: looprpc/client.proto

gRPC

rpc LoopOut (LoopOutRequest) returns (SwapResponse);

REST

HTTP MethodPath
POST /v1/loop/out

Code Samples

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/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 = {
amt: <int64>,
dest: <string>,
max_swap_routing_fee: <int64>,
max_prepay_routing_fee: <int64>,
max_swap_fee: <int64>,
max_prepay_amt: <int64>,
max_miner_fee: <int64>,
loop_out_channel: <uint64>,
outgoing_chan_set: <uint64>,
sweep_conf_target: <int32>,
htlc_confirmations: <int32>,
swap_publication_deadline: <uint64>,
label: <string>,
initiator: <string>,
account: <string>,
account_addr_type: <AddressType>,
is_external_addr: <bool>,
reservation_ids: <bytes>,
};
client.loopOut(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "id": <string>,
// "id_bytes": <bytes>,
// "htlc_address": <string>,
// "htlc_address_p2wsh": <string>,
// "htlc_address_p2tr": <string>,
// "server_message": <string>,
// }

Messages

looprpc.LoopOutRequest

Source: looprpc/client.proto

FieldgRPC TypeREST TypeREST Placement
amt
int64stringbody
dest
stringstringbody
max_swap_routing_fee
int64stringbody
max_prepay_routing_fee
int64stringbody
max_swap_fee
int64stringbody
max_prepay_amt
int64stringbody
max_miner_fee
int64stringbody
loop_out_channeldeprecated
uint64stringbody
outgoing_chan_set
uint64[]arraybody
sweep_conf_target
int32integerbody
htlc_confirmations
int32integerbody
swap_publication_deadline
uint64stringbody
label
stringstringbody
initiator
stringstringbody
account
stringstringbody
account_addr_type
AddressTypestringbody
is_external_addr
boolbooleanbody
reservation_ids
bytes[]arraybody

looprpc.SwapResponse

Source: looprpc/client.proto

FieldgRPC TypeREST Type
iddeprecated
stringstring
id_bytes
bytesstring
htlc_addressdeprecated
stringstring
htlc_address_p2wsh
stringstring
htlc_address_p2tr
stringstring
server_message
stringstring

Enums

looprpc.AddressType

NameNumber
ADDRESS_TYPE_UNKNOWN
0
TAPROOT_PUBKEY
1