Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Something went wrong...better call Craig Wright$ curl https://api.redshift.radar.tech/api/markets
[
{
"onchainTicker":"BTC",
"offchainTicker":"LBTC",
"market":"BTC_LBTC"
},
{
"onchainTicker":"ETH",
"offchainTicker":"LBTC",
"market":"ETH_LBTC"
}
][
{
"market": string,
"payReq": {
"minExpirationSeconds": string,
"minBaseUnits": string,
"maxBaseUnits": string
}
},
{
"market": string,
"payReq": {
"minExpirationSeconds": string,
"minBaseUnits": string,
"maxBaseUnits": string
}
}
]Something went wrong...better call Craig Wright$ curl https://api.redshift.radar.tech/api/markets/requirements
[
{
"market":"BTC_LBTC",
"payReq":{
"minExpirationSeconds":"2400",
"minBaseUnits":"30000",
"maxBaseUnits":"1000000"
}
},
{
"market":"ETH_LBTC",
"payReq":{
"minExpirationSeconds":"900",
"minBaseUnits":"1",
"maxBaseUnits":"1000000"
}
}
]{
"market": string,
"payReq": {
"minExpirationSeconds": string,
"minBaseUnits": string,
"maxBaseUnits": string
}
}InvalidMarket | NoQuoteProvidersForTheRequestedMarket | NoQuoteProvidersAvailableSomething went wrong...better call Craig Wright$ curl https://api.redshift.radar.tech/api/markets/BTC_LBTC/requirements
{
"market":"BTC_LBTC",
"payReq":{
"minExpirationSeconds":"2400",
"minBaseUnits":"30000",
"maxBaseUnits":"1000000"
}
}import { WebSocketClient } from "@radar/redshift-api-client";
const client = new WebSocketClient();
await client.connect();
const quoteRequest = {
market: "BTC_LBTC",
invoice: "lnbc1m1p0zwsllpp5np23cxgafxcqnk434v86rlnpght09gvnzwtrvy0y704nqtjtffvqdqdgdf4wgztv4uhxcqzpg3awyquek08frfexrphkm9sjwdggkfepm6uxex0lg4m8s0s59d7z8kdf9cajvc00cwl2nzu57qe9n92fv2mzm4hlgctw2x3v0lxcjrrcpul9wen",
refundAddress: "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
};
const quote = await client.requestQuote(quoteRequest);
console.log(quote);
// {
// orderId: "13283979-2c0b-45e4-b2e0-2a487535822e";
// expiryTimestampMs: 1578598212267;
// amount: "0.001056000000000000";
// details: {
// payToAddress: "3LKomc2i3rLm2TnA36U4pGH25cFWvRMnJB";
// redeemScript: "76a914d5846ccb08521347c1d5718ec460656d67427cbf8763752102369b4d174f601239daef6a83bf553092e139901e6ed19ffbcbedcee07be7a4ae6703575709b17576a914c1e27ac884310271f04dd1ebe9eb4e135113a1d08868ac";
// refundableAtBlockHeight: 612183;
// }
// }import io from "socket.io-client";
const socket = io.connect("https://api.redshift.radar.tech/user/v1");
const request = {
market: "BTC_LBTC",
invoice: "lnbc1m1p0pv6fepp5kjf5zgm6590w77u3qtg38cjwxwz36l505q3gurl4nl8xw47t33msdqsgdf4wfmnyp9k27tncqzpgwrdthp4apgu7v4s53xc27clm82nkchmylm5huvwdd660q36e82vske04eeesljjyt89q3aglzr9l7l3yxpy5pwfl08unztfrqhcndesqyym288",
refundAddress: "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
};
socket.emit(
"requestQuote",
request,
({ success, message }: WebSocketResponse<Quote | string>) => {
console.log("Successful:", success, "Response Message:", message);
},
);Endpoints to interact with and retrieve orders.
[
{
"id": string,
"market": string,
"onchainTicker": string,
"createdAt": string,
"state": string,
"payToAddress": string,
"amount": string | BigNumber
"amountPaid": string | BigNumbe
"expiryTimestamp": Date
}
]InvalidOnchainTicker
InvalidInvoiceHashSomething went wrong...better call Craig Wright$ curl https://api.redshift.radar.tech/api/orders?invoiceHash=0a942325eb07d744c3b98a3b8e0d50bee02d9d2fe4f0cd1734ff3ce8b60a994c
[
{
"id": "a61131f7-0b66-460e-b3d8-37d59f94b8aa",
"market": "BTC_LBTC",
"onchainTicker": "BTC",
"createdAt": "2019-11-05T20:11:08.821Z",
"state": "Complete",
"payToAddress": "383HpQyScZvbyXJrdD6WCnLGRBeeQMBDX7",
"amount": "0.0003559",
"amountPaid": "0.0006669"
},
{
"id": "0ec6f515-5d61-4998-ba93-97a4e51164e9",
"market": "BTC_LBTC",
"onchainTicker": "BTC",
"createdAt": "2019-11-05T20:05:45.168Z",
"state": "FundWindowElapsed",
"payToAddress": "363ZmnA5BYYQq3FQhTBmYNcEKY5CwWoekS",
"amount": "0.0003593",
"amountPaid": "0"
}
]
{
"id": string,
"market": string,
"onchainTicker": string,
"createdAt": string,
"state": string,
"payToAddress": string,
"amount": string | BigNumber
"amountPaid": string | BigNumbe
"expiryTimestamp": Date
}InvalidOrderIdOrderNotFoundSomething went wrong...better call Craig Wright$ curl https://api.redshift.radar.tech/api/orders/206820ee-0136-436b-8d0a-f288eb4011d0
{
"market": "ETH_LBTC",
"onchainTicker": "ETH",
"createdAt": "2020-01-05T01:59:48.385Z",
"state": "Complete",
"payToAddress": "0x46340430971885eFfA5757eE03356eD228258ac0",
"amount": "0.37583397",
"amountPaid": "0.37583397",
"invoice": "lnbc6500u1p0pzskxpp55n4d4gaahlnvrqg3exlmuvwtppkgu0h5h79wyhznxkljjh4qyw7qdqjg9kxcgrfdcsycsj5gvcqzpgxqyz5vq9rqymmgvr5h4kejvd99qe7xdpqakkraqrpdrpwhpmpwuv5ha830k50jqjv84t6a49gu633ykg3xwr2k2hjfeasq08l0lwhgkmy63s3spscplrl",
"paymentHash": "a4eadaa3bdbfe6c18111c9bfbe31cb086c8e3ef4bf8ae25c5335bf295ea023bc",
"paymentPreimage": "4073e2c3affd699b93959029a7d481ac4daf5a98bda8f040c6e8fbc0cf791001"
}WaitingForFundingTx | WaitingForFundingTxConfirmation | FundWindowElapsedInvalidOrderIdOrderNotFoundSomething went wrong...better call Craig Wright$ curl https://api.redshift.radar.tech/api/orders/206820ee-0136-436b-8d0a-f288eb4011d0
"Complete"{
"orderId": string,
"expiryTimestampMs": number,
"amount": string,
"details": {
"redeemScript": string,
"payToAddress": string,
"refundableAtBlockHeight": number
}
}InvalidOrderIdOrderNotFoundSomething went wrong...better call Craig Wright$ curl https://api.redshift.radar.tech/api/orders/206820ee-0136-436b-8d0a-f288eb4011d0/fundDetails
{
"orderId": "206820ee-0136-436b-8d0a-f288eb4011d0",
"expiryTimestampMs": 1578190188508,
"amount": "0.375833970000000000",
"details": {
"unsignedFundingTx": {
"to": "0x46340430971885eFfA5757eE03356eD228258ac0",
"data": "0x3fdcdd1e206820ee0136436b8d0af288eb4011d000000000000000000000000000000000a4eadaa3bdbfe6c18111c9bfbe31cb086c8e3ef4bf8ae25c5335bf295ea023bc",
"value": "375833970000000000"
}
}
}[
{
"type": string,
"id": string
}
]InvalidOrderIdOrderNotFoundSomething went wrong...better call Craig Wright$ curl https://api.redshift.radar.tech/api/orders/206820ee-0136-436b-8d0a-f288eb4011d0/transactions
[
{
"type": "FUND",
"id": "0x46ac9daadba75fd2af42584dd0cc3ddc1c66d2d9fa1af4f7af8f416cd5c6e83f"
}
]// Bitcoin Refund
{
"market": string,
"state": string,
"blocksRemaining": number,
"refundableAtBlockHeight": number,
"refundableBalance": string,
"details": {
"refundAddress": string,
"redeemScript": string,
"currentBlockHeight": number,
"feeTokensPerVirtualByte": number,
"utxos": [
{
"txId": string,
"index": number,
"tokens": number
}
]
}
}
// Ethereum Refund
{
"market": string,
"state": string,
"blocksRemaining": number,
"refundableAtBlockHeight": number,
"refundableBalance": string,
"details": {
"to": string,
"data": string
}
}InvalidOrderIdOrderNotFoundSomething went wrong...better call Craig Wright// Bitcoin Order
$ curl https://api.redshift.radar.tech/api/orders/53f27403-98da-4e08-8578-04ec6cfba4b1/refund
{
"market": "BTC_LBTC",
"state": "Complete",
"blocksRemaining": 0,
"refundableAtBlockHeight": 607878,
"refundableBalance": "0.0005263",
"details": {
"refundAddress": "bc1q50qmmgf3mtp95qesqq27h8gsdx9syuzv9p8qfa",
"redeemScript": "76a9148ec7c524f0cfca47daaa56827c76d94e0ea47c2c8763752103698deb28d5807611b0545b2c0b59ea4ae84393b2e22b7f131f1b89694b43749a6703864609b17576a914a3c1bda131dac25a03300015eb9d10698b02704c8868ac",
"currentBlockHeight": 612073,
"feeTokensPerVirtualByte": 30,
"utxos": [
{
"txId": "d2a153c4024152a06cb1ee6e5da1fac3548085ed77dc75f438586c37fed26678",
"index": 1,
"tokens": 52630
}
]
}
}
// Ethereum Order
$ curl https://api.redshift.radar.tech/api/orders/206820ee-0136-436b-8d0a-f288eb4011d0/refund
{
"market": "ETH_LBTC",
"state": "Complete",
"blocksRemaining": 0,
"refundableAtBlockHeight": 9224305,
"refundableBalance": "0.37583397",
"details": {
"to": "0x46340430971885eFfA5757eE03356eD228258ac0",
"data": "0xdfdecfaf206820ee0136436b8d0af288eb4011d000000000000000000000000000000000"
}
}npm install @radar/redshift-api-clientyarn add @radar/redshift-api-clientimport { RedshiftClient } from '@radar/redshift-api-client';const client = new RedshiftClient();const client = new RedshiftClient(RedshiftApiUrl.MAINNET);const client = new RedshiftClient(RedshiftApiUrl.TESTNET);const markets = await client.http.getMarkets();await client.ws.connect();import { HttpClient } from '@radar/redshift-api-client';const client = new HttpClient();const client = new HttpClient(RedshiftApiUrl.MAINNET);const client = new HttpClient(RedshiftApiUrl.TESTNET);const markets = await client.getMarkets();const orders = await client.getOrders(invoice);
// Or filter by the on-chain asset used to fund the swap
const orders = await client.getOrders(invoice, OnChainTicker.ETH);const order = await client.getOrder(orderId);const state = await client.getOrderState(orderId);const state = await client.getOrderFundDetails(orderId);const state = await client.getOrderTransactions(orderId);const details = await client.getOrderRefundDetails(orderId);import { WebSocketClient } from '@radar/redshift-api-client';const client = new WebSocketClient();const client = new WebSocketClient(RedshiftApiUrl.MAINNET);const client = new WebSocketClient(RedshiftApiUrl.TESTNET);await client.connect();client.disconnect();await client.requestQuote(quoteRequest);await client.subscribeToOrderState(orderId);client.onOrderStateChanged(stateUpdate => {
console.log(stateUpdate);
});await client.unsubscribeFromOrderState(orderId);await client.subscribeToBlockHeight(network, subnet);client.onBlockHeightChanged(blockHeightUpdate => {
console.log(blockHeightUpdate);
});await client.unsubscribeFromBlockHeight(network, subnet);const details = await client.requestRefundDetails(orderId);const { txId } = await client.broadcastTransaction(txRequest);npm install @radar/htlcyarn add @radar/htlcimport { HTLC, UTXO } from '@radar/htlc';
const htlc = HTLC.construct(Network.BITCOIN, BitcoinSubnet.SIMNET, {
paymentHash: 'fba6da3ff596b9c6fabe67d4f728474697640ef6edd9e361c2a46be345112839',
claimerPublicKey: '0286ab3b59ce3862515b01c8a282edb6011b4eb50c608ab298bfd70f6033f7bc65',
refundAddress: 'sb1qxnqqm56ta40p3uhtsmtdxglhwuxjk3tul94mq0',
timelock: {
type: UTXO.LockType.ABSOLUTE,
blockHeight: 597732,
},
});import { HTLC, UTXO } from '@radar/htlc';
const htlc = HTLC.construct(Network.BITCOIN, BitcoinSubnet.SIMNET, {
paymentHash: 'fba6da3ff596b9c6fabe67d4f728474697640ef6edd9e361c2a46be345112839',
claimerPublicKey: '0286ab3b59ce3862515b01c8a282edb6011b4eb50c608ab298bfd70f6033f7bc65',
refundAddress: 'sb1qxnqqm56ta40p3uhtsmtdxglhwuxjk3tul94mq0',
timelock: {
type: UTXO.LockType.RELATIVE,
blockBuffer: 50,
},
});import { HTLC } from '@radar/htlc';
const htlc = HTLC.construct(
Network.BITCOIN,
BitcoinSubnet.SIMNET,
'76a914c15949a2e2a414b5c641f32c4c2ee07be644e165876375210398c9a44bed9f59c6041a574602aab0af6a08f3f0fb847fd9a167f7afd71b8d25670114b27576a9143f1857b3db895b4d481a46e5a0129cb2b04781c88868ac',
);import { HTLC, UTXO } from '@radar/htlc';
const htlc = HTLC.construct(Network.BITCOIN, BitcoinSubnet.SIMNET, {
paymentHash: 'fba6da3ff596b9c6fabe67d4f728474697640ef6edd9e361c2a46be345112839',
claimerPublicKey: '0286ab3b59ce3862515b01c8a282edb6011b4eb50c608ab298bfd70f6033f7bc65',
refundPublicKey: '029814897bbfe085fcf1611a7100919f31b4424443d694a52b86bbb9ab9447d073',
timelock: {
type: UTXO.LockType.RELATIVE,
blockBuffer: 50,
},
});const { details } = htlc;const { redeemScript } = htlc;const fundTxHex = htlc.fund(utxos, fundingAmount, privateKey);const claimTxHex = htlc.claim(
utxos,
destinationAddress,
currentBlockHeight,
feeTokensPerVirtualByte,
paymentSecret,
privateKey,
);const refundTxHex = htlc.refund(
utxos,
destinationAddress,
currentBlockHeight,
feeTokensPerVirtualByte,
privateKey,
);import { HTLC } from '@radar/htlc';
const htlc = HTLC.construct(Network.ETHEREUM, EthereumSubnet.GANACHE_SIMNET, {
orderUUID,
provider: web3.currentProvider,
assetType: EVM.AssetType.ETHER,
});import { HTLC } from '@radar/htlc';
const htlc = HTLC.construct(Network.ETHEREUM, EthereumSubnet.GANACHE_SIMNET, {
orderUUID,
provider: web3.currentProvider,
tokenContractAddress,
assetType: EVM.AssetType.ERC20,
});const { contract } = htlc;const txReceipt = await htlc.fund(amount, paymentHash);const txReceipt = await htlc.claim(paymentSecret);const txReceipt = await htlc.refund();const txReceipt = await htlc.refund(true, {
gas: 200000,
});const unsignedTx = await htlc.refund(false);import { HTLC } from '@radar/htlc';
const htlc = HTLC.construct(Network.STELLAR, StellarSubnet.TESTNET, {
secret: 'SCHMRGINH4CDPUPKBEQZTFZHNRSZKC3NYEFMSUYNDKA4OQK3ZA7JT7C6',
});await htlc.create();const fundEnvelope = await htlc.fund(
userPubKey,
fundAmount,
paymentHash,
);
const refundEnvelope = await htlc.refund(
userPubKey,
timelockInSeconds,
);await htlc.claim(paymentSecret);docker-compose up -dyarn test// Request
{
market: Market;
// Bitcoin Response
{
success: boolean,
import io from 'socket.io-client';
const socket = io.connect("https://api.redshift.radar.tech/user/v1");
const request = {
market: "BTC_LBTC";
invoice: "lnbc1m1p0pv6fepp5kjf5zgm6590w77u3qtg38cjwxwz36l505q3gurl4nl8xw47t33msdqsgdf4wfmnyp9k27tncqzpgwrdthp4apgu7v4s53xc27clm82nkchmylm5huvwdd660q36e82vske04eeesljjyt89q3aglzr9l7l3yxpy5pwfl08unztfrqhcndesqyym288";
refundAddress: "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa";
}
socket.emit(
"requestQuote",
request,
({ success, message }: WebSocketResponse<Quote | string>) => {
if (success) {
console.log(message)
// {
// orderId: "13283979-2c0b-45e4-b2e0-2a487535822e";
// expiryTimestampMs: 1578598212267;
// amount: "0.001056000000000000";
// details: {
// payToAddress: "3LKomc2i3rLm2TnA36U4pGH25cFWvRMnJB";
// redeemScript: "76a914d5846ccb08521347c1d5718ec460656d67427cbf8763752102369b4d174f601239daef6a83bf553092e139901e6ed19ffbcbedcee07be7a4ae6703575709b17576a914c1e27ac884310271f04dd1ebe9eb4e135113a1d08868ac";
// refundableAtBlockHeight: 612183;
// }
// }
}
return reject(new Error(message));
},
);// Request
{
orderId: string
// Response
{
success: boolean
import io from 'socket.io-client';
// Request
{
orderId: string
}// Response
{
success: boolean
}import io from 'socket.io-client';
const socket = io.connect("https://api.redshift.radar.tech/user/v1");
const request = {
orderId: "13283979-2c0b-45e4-b2e0-2a487535822e"
}
socket.emit(
"unsubscribeFromOrderState",
request,
({ success, message }: WebSocketResponse<Quote | string>) => {
if (success) {
return resolve("Unsubscribed!");
}
return reject(new Error(message));
},
);// Request
{
network: Network;
subnet: Subnet;
}// Response
{
success: boolean
}import io from 'socket.io-client';
const socket = io.connect("https://api.redshift.radar.tech/user/v1");
const request = {
network: "bitcoin";
subnet: "mainnet";
}
socket.emit(
"subscribeToBlockHeight",
request,
({ success, message }: WebSocketResponse<Quote | string>) => {
if (success) {
return resolve("Subscribed!");
}
return reject(new Error(message));
},
);// Request
{
network: Network;
subnet: Subnet;
}// Response
{
success: boolean
}import io from 'socket.io-client';
const socket = io.connect("https://api.redshift.radar.tech/user/v1");
const request = {
network: "bitcoin";
subnet: "mainnet";
}
socket.emit(
"unsubscribeToBlockHeight",
request,
({ success, message }: WebSocketResponse<Quote | string>) => {
if (success) {
return resolve("Subscribed!");
}
return reject(new Error(message));
},
);// Request
{
orderId: string
}// Bitcoin Response
{
success: boolean,
message: {
market: Market;
state: UserSwapState;
blocksRemaining: number | undefined;
refundableAtBlockHeight: number | undefined;
refundableBalance: string;
details: {
refundAddress: string;
redeemScript: string;
currentBlockHeight: number;
feeTokensPerVirtualByte: number;
utxos: TxOutput[];
}
}
}
// Ethereum Response
{
success: boolean,
message: {
market: Market;
state: UserSwapState;
blocksRemaining: number | undefined;
refundableAtBlockHeight: number | undefined;
refundableBalance: string;
details: {
to: string;
data: string;
}
}
}import io from 'socket.io-client';
const socket = io.connect("https://api.redshift.radar.tech/user/v1");
const request = {
orderId: "13283979-2c0b-45e4-b2e0-2a487535822e";
}
socket.emit(
"requestRefundDetails",
request,
({ success, message }: WebSocketResponse<Quote | string>) => {
if (success) {
console.log(message)
// {
// market: "BTC_LBTC";
// state: "Completed";
// blocksRemaining: 0;
// refundableAtBlockHeight: 607878;
// refundableBalance: "0.0005263";
// details: {
// refundAddress: "bc1q50qmmgf3mtp95qesqq27h8gsdx9syuzv9p8qfa";
// redeemScript: "76a9148ec7c524f0cfca47daaa56827c76d94e0ea47c2c8763752103698deb28d5807611b0545b2c0b59ea4ae84393b2e22b7f131f1b89694b43749a6703864609b17576a914a3c1bda131dac25a03300015eb9d10698b02704c8868ac";
// currentBlockHeight: 612073;
// feeTokensPerVirtualByte: 30;
// utxos: [
// {
// "txId": "d2a153c4024152a06cb1ee6e5da1fac3548085ed77dc75f438586c37fed26678",
// "index": 1,
// "tokens": 52630
// }
// ];
// }
// }
}
return reject(new Error(message));
},
);// Request
{
onchainTicker: OnChainTicker;
signedTxHex: string;
}// Response
{
success: boolean,
message: {
txId: "d2a153c4024152a06cb1ee6e5da1fac3548085ed77dc75f438586c37fed26678"
}
}import io from 'socket.io-client';
const socket = io.connect("https://api.redshift.radar.tech/user/v1");
const request = {
onchainTicker: "BTC",
signedTxHex: "8adb7454fe7d8d0f55ee89c592926d6f6f032207020e4ad56ff7ca3c80cbe26e"
}
socket.emit(
"broadcastTransaction",
request,
({ success, message }: WebSocketResponse<Quote | string>) => {
if (success) {
console.log(message)
// {
// txId: "d2a153c4024152a06cb1ee6e5da1fac3548085ed77dc75f438586c37fed26678",
// }
}
return reject(new Error(message));
},
);// Response
{
market: Market;
payReq: {
minExpirationSeconds: string;
minBaseUnits: string;
maxBaseUnits: string;
}
}import io from 'socket.io-client';
const socket = io.connect("https://api.redshift.radar.tech/user/v1");
const request = { }
socket.emit(
"requestMarketRequirements",
request,
({ success, message }: WebSocketResponse<Quote | string>) => {
if (success) {
console.log(message)
// {
// market: "BTC_LBTC";
// payReq:{
// minExpirationSeconds:"2400",
// minBaseUnits:"30000",
// maxBaseUnits:"1000000"
// }
// }
}
return reject(new Error(message));
},
);npm install @radar/lnrpc
# OR
yarn add @radar/lnrpcimport {
createAutopilotRpc,
createChainRpc,
createInvoicesRpc,
createLnRpc,
createRouterRpc,
createSignRpc,
createWalletRpc,
createWatchtowerRpc,
createWtClientRpc,
} from '@radar/lnrpc';import createLnRpc from '@radar/lnrpc';import createLnRpc, {
AutopilotRpc,
ChainRpc,
createAutopilotRpc,
createChainRpc,
createInvoicesRpc,
createRouterRpc,
createSignRpc,
createWalletRpc,
createWatchtowerRpc,
createWtClientRpc,
InvoicesRpc,
LnRpc,
RouterRpc,
RpcClientConfig,
SignRpc,
WalletRpc,
WatchtowerRpc,
WtClientRpc,
} from '@radar/lnrpc';
export class Lightning {
public static lnrpc: LnRpc;
public static autopilotrpc: AutopilotRpc;
public static chainrpc: ChainRpc;
public static invoicesrpc: InvoicesRpc;
public static routerrpc: RouterRpc;
public static signrpc: SignRpc;
public static walletrpc: WalletRpc;
public static watchtowerrpc: WatchtowerRpc;
public static wtclientrpc: WtClientRpc;
/**
* Initialize gRPC clients for the main server and all sub-servers
* @param config The RPC client connection configuration
*/
public static async init(config: RpcClientConfig): Promise<void> {
this.lnrpc = await createLnRpc(config);
this.autopilotrpc = await createAutopilotRpc(config);
this.chainrpc = await createChainRpc(config);
this.invoicesrpc = await createInvoicesRpc(config);
this.routerrpc = await createRouterRpc(config);
this.signrpc = await createSignRpc(config);
this.walletrpc = await createWalletRpc(config);
this.watchtowerrpc = await createWatchtowerRpc(config);
this.wtclientrpc = await createWtClientRpc(config);
}
}import createLnRpc from '@radar/lnrpc';
(async () => {
const lnRpcClient = await createLnRpc(config);
// All requests are promisified and typed
const { confirmedBalance } = await lnRpcClient.walletBalance();
// ...and you're off!
console.log(confirmedBalance);
// subscribe to LND server events
const subscriber = await lnRpcClient.subscribeInvoices();
subscriber.on('data', invoice => {
console.log(invoice); // do something with invoice event
});
})();import createLnRpc from '@radar/lnrpc';
(async () => {
const lnRpcClient = await createLnRpc({
/*
* By default lnrpc connects to `localhost:10001`,
* however we can point to any host.
*/
server: '173.239.209.2:3001',
/*
* By default lnrpc looks for your tls certificate at:
* `~/.lnd/tls.cert`, unless it detects you're using macOS and
* defaults to `~/Library/Application\ Support/Lnd/tls.cert`
* however you can configure your own SSL certificate path like:
*/
tls: './path/to/tls.cert',
/*
* You can also provide a TLS certificate directly as a string
* (Just make sure you don't commit this to git).
* Overwrites: `tls`
*/
cert: process.env.MY_SSL_CERT,
/*
* Optional path to configure macaroon authentication
* from LND generated macaroon file.
*/
macaroonPath: './path/to/data/admin.macaroon',
/*
* Optional way to configure macaroon authentication by
* passing a hex encoded string of your macaroon file.
* Encoding: `xxd -ps -u -c 1000 ./path/to/data/admin.macaroon`
* Details: https://github.com/lightningnetwork/lnd/blob/dc3db4b/docs/macaroons.md#using-macaroons-with-grpc-clients
*/
macaroon: process.env.MY_MACAROON_HEX,
});
try {
const getInfoResponse = await lnRpcClient.getInfo();
console.log(getInfoResponse);
} catch (error) {
console.error(error);
}
})();git clone git@github.com:RadarTech/lnrpc.git && cd $_
npm install
# OR
yarnnpm run update-protos
# OR
yarn update-protos
# AND
npm run generate
# OR
yarn generategit clone https://github.com/RadarTech/redshift-monorepo.gitcd redshift-monorepo/samples/sdk-usage-vueyarnyarn startasync created() {
[this.markets, this.requirements] = await Promise.all([
redshift.http.getMarkets(),
redshift.http.getMarketRequirements(),
]);
}/**
* Validate the passed invoice. If valid, return the decoded invoice
* @param invoice The bolt11 invoice
*/
isValidInvoice(invoice: string) {
try {
const decodedInvoice = decode(invoice);
return {
decodedInvoice,
isValid: true,
};
} catch (error) {
return {
isValid: false,
};
}
}// Ensure the invoice meets the market requirements
const decodedInvoice = decode(data.invoice);
const invoiceMeetsRequirements = this.marketRequirementsSatisfied(
decodedInvoice,
data.market,
);
if (!invoiceMeetsRequirements) return;// Establish a WebSocket connection
await redshift.ws.connect();
// Request the quote
const quote = await redshift.ws.requestQuote({
invoice: data.invoice,
market: data.market,
});{
"orderId":"56f970d4-24cc-4112-8e1a-4bef7becbee2",
"expiryTimestampMs":1571943386485,
"amount":"0.005068660000000000",
"details":{
"unsignedFundingTx":{
"to":"0xd4589fB5b5ABB44e1A8cb95CfF0Ca9E0e78D9D5d",
"data":"0x3fdcdd1e56f970d424cc41128e1a4bef7becbee20000000000000000000000000000000009495061c40a27c05ca574ff5c4d61869e4a936a003b13f8050d5aeba0ecfc7d",
"value":"5068660000000000"
}
}
}await redshift.ws.subscribeToOrderState(this.orderId);redshift.ws.onOrderStateChanged(this.handleStateChange);/**
* Call eth_sendTransaction. Display an error message if
* an error is thrown.
* @param address The active address
*/
async sendTransaction(address: string) {
try {
const { data, to, value } = this.tx; // Tx values from REDSHIFT
await metamask.sendTransaction({
data,
to,
value: value ? decToHex(value as string) : undefined,
from: address,
});
} catch (error) {
this.metamaskError = error.message;
}
}this.refund.details = await redshift.ws.requestRefundDetails(this.orderId);if (this.blocksUntilRefundable > 0) {
const { network, subnet } = getNetworkDetails(this.refund.details.market);
await redshift.ws.subscribeToBlockHeight(network, subnet);
redshift.ws.onBlockHeightChanged(update =>
this.handleBlockHeightChange(update, network, subnet),
);
}Error: Failed to load gRPC binary module because it was not installed for the current systemUtilities used across REDSHIFT codebases
npm install @radar/redshift-typesnpm install @radar/redshift-utilsyarn add @radar/redshift-utilsimport { validator } from '@radar/redshift-utils';const isValid = await validator.isValidNetwork(network);const isValid = await validator.isValidOnchainTicker(ticker);const isValid = await validator.isValidMarket(market);const isValid = await validator.isValidUUID(uuid);const isValid = await validator.isValidBase58Check(s);const isValid = await validator.isValidBech32(s);const isValid = await validator.isValidBase58CheckOrBech32(s);const isValid = await validator.isValidHex(s);const isValid = await validator.isValidNetworkAndSubnet(network, subnet);yarn add @radar/redshift-types"typeRoots": ["node_modules/@radar/redshift-types/src/declarations", "node_modules/@types"]




