Skip to main content

ServerStaticAddressLoopIn

ServerStaticAddressLoopIn initiates a static address loop-in swap. The server will respond with htlc details that the client can use to construct and sign the htlc tx.

Source: staticaddr.proto

gRPC

rpc ServerStaticAddressLoopIn (ServerStaticAddressLoopInRequest) returns (ServerStaticAddressLoopInResponse);

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('staticaddr.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.StaticAddressServer(GRPC_HOST, creds);
let request = {
htlc_client_pub_key: <bytes>,
swap_hash: <bytes>,
deposit_outpoints: <string>,
swap_invoice: <string>,
last_hop: <bytes>,
protocol_version: <StaticAddressProtocolVersion>,
user_agent: <string>,
payment_timeout_seconds: <uint32>,
};
client.serverStaticAddressLoopIn(request, function(err, response) {
console.log(response);
});
// Console output:
// {
// "htlc_server_pub_key": <bytes>,
// "htlc_expiry": <int32>,
// "standard_htlc_info": <ServerHtlcSigningInfo>,
// "high_fee_htlc_info": <ServerHtlcSigningInfo>,
// "extreme_fee_htlc_info": <ServerHtlcSigningInfo>,
// }

Messages

looprpc.ServerStaticAddressLoopInRequest

Source: staticaddr.proto

FieldgRPC TypeREST TypeREST Placement
htlc_client_pub_key
bytesunknownunknown
swap_hash
bytesunknownunknown
deposit_outpoints
string[]unknownunknown
swap_invoice
stringunknownunknown
last_hop
bytesunknownunknown
protocol_version
StaticAddressProtocolVersionunknownunknown
user_agent
stringunknownunknown
payment_timeout_seconds
uint32unknownunknown

looprpc.ServerStaticAddressLoopInResponse

Source: staticaddr.proto

FieldgRPC TypeREST Type
htlc_server_pub_key
bytesunknown
htlc_expiry
int32unknown
standard_htlc_info
ServerHtlcSigningInfounknown
high_fee_htlc_info
ServerHtlcSigningInfounknown
extreme_fee_htlc_info
ServerHtlcSigningInfounknown

Nested Messages

looprpc.ServerHtlcSigningInfo

FieldgRPC TypeREST Type
nonces
bytes[]unknown
fee_rate
uint64unknown

Enums

looprpc.StaticAddressProtocolVersion

NameNumber
V0
0