Skip to main content

LoopIn

LoopIn initiates a loop in 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 LoopIn (LoopInRequest) returns (SwapResponse);

REST

HTTP MethodPath
POST /v1/loop/in

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>,
max_swap_fee: <int64>,
max_miner_fee: <int64>,
last_hop: <bytes>,
external_htlc: <bool>,
htlc_conf_target: <int32>,
label: <string>,
initiator: <string>,
route_hints: <RouteHint>,
private: <bool>,
};
client.loopIn(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.LoopInRequest

Source: looprpc/client.proto

FieldgRPC TypeREST TypeREST Placement
amt
int64stringbody
max_swap_fee
int64stringbody
max_miner_fee
int64stringbody
last_hop
bytesstringbody
external_htlc
boolbooleanbody
htlc_conf_target
int32integerbody
label
stringstringbody
initiator
stringstringbody
route_hints
RouteHint[]arraybody
private
boolbooleanbody

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