Merge pull request #298 from shocknet/basic-coordinates
Basic coordinates
This commit is contained in:
commit
a339d1058c
7 changed files with 231 additions and 124 deletions
|
|
@ -51,7 +51,7 @@
|
||||||
"request-promise": "^4.2.6",
|
"request-promise": "^4.2.6",
|
||||||
"response-time": "^2.3.2",
|
"response-time": "^2.3.2",
|
||||||
"shelljs": "^0.8.2",
|
"shelljs": "^0.8.2",
|
||||||
"shock-common": "29.1.0",
|
"shock-common": "30.0.0",
|
||||||
"socket.io": "2.1.1",
|
"socket.io": "2.1.1",
|
||||||
"text-encoding": "^0.7.0",
|
"text-encoding": "^0.7.0",
|
||||||
"tingodb": "^0.6.1",
|
"tingodb": "^0.6.1",
|
||||||
|
|
|
||||||
63
services/coordinates.js
Normal file
63
services/coordinates.js
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
/**
|
||||||
|
* @format
|
||||||
|
*/
|
||||||
|
|
||||||
|
const Common = require('shock-common')
|
||||||
|
const mapValues = require('lodash/mapValues')
|
||||||
|
const pickBy = require('lodash/pickBy')
|
||||||
|
const Bluebird = require('bluebird')
|
||||||
|
const Logger = require('winston')
|
||||||
|
const Key = require('../services/gunDB/contact-api/key')
|
||||||
|
|
||||||
|
const { getUser, getMySecret, mySEA } = require('./gunDB/Mediator')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} coordID
|
||||||
|
* @param {Common.Coordinate} data
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
export const writeCoordinate = async (coordID, data) => {
|
||||||
|
if (coordID !== data.id) {
|
||||||
|
throw new Error('CoordID must be equal to data.id')
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
/**
|
||||||
|
* Because there are optional properties, typescript can also allow them
|
||||||
|
* to be specified but with a value of `undefined`. Filter out these.
|
||||||
|
* @type {Record<string, number|boolean|string>}
|
||||||
|
*/
|
||||||
|
const sanitizedData = pickBy(data, v => typeof v !== 'undefined')
|
||||||
|
|
||||||
|
const encData = await Bluebird.props(
|
||||||
|
mapValues(sanitizedData, v => {
|
||||||
|
return mySEA.encrypt(v, getMySecret())
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
getUser()
|
||||||
|
.get(Key.COORDINATES)
|
||||||
|
.get(coordID)
|
||||||
|
.put(encData, ack => {
|
||||||
|
if (ack.err && typeof ack.err !== 'number') {
|
||||||
|
Logger.info(
|
||||||
|
`Error writting corrdinate, coordinate id: ${coordID}, data: ${JSON.stringify(
|
||||||
|
data,
|
||||||
|
null,
|
||||||
|
2
|
||||||
|
)}`
|
||||||
|
)
|
||||||
|
Logger.error(ack.err)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} catch (e) {
|
||||||
|
Logger.info(
|
||||||
|
`Error writing coordinate, coordinate id: ${coordID}, data: ${JSON.stringify(
|
||||||
|
data,
|
||||||
|
null,
|
||||||
|
2
|
||||||
|
)}`
|
||||||
|
)
|
||||||
|
Logger.error(e.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -11,7 +11,8 @@ const { ErrorCode } = Constants
|
||||||
|
|
||||||
const {
|
const {
|
||||||
sendPaymentV2Invoice,
|
sendPaymentV2Invoice,
|
||||||
decodePayReq
|
decodePayReq,
|
||||||
|
myLNDPub
|
||||||
} = require('../../../utils/lightningServices/v2')
|
} = require('../../../utils/lightningServices/v2')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -21,6 +22,7 @@ const {
|
||||||
const Getters = require('./getters')
|
const Getters = require('./getters')
|
||||||
const Key = require('./key')
|
const Key = require('./key')
|
||||||
const Utils = require('./utils')
|
const Utils = require('./utils')
|
||||||
|
const { writeCoordinate } = require('../../coordinates')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {import('./SimpleGUN').GUNNode} GUNNode
|
* @typedef {import('./SimpleGUN').GUNNode} GUNNode
|
||||||
|
|
@ -1074,6 +1076,26 @@ const sendSpontaneousPayment = async (
|
||||||
payment_request: orderResponse.response
|
payment_request: orderResponse.response
|
||||||
})
|
})
|
||||||
|
|
||||||
|
await writeCoordinate(payment.payment_hash, {
|
||||||
|
id: payment.payment_hash,
|
||||||
|
type: (() => {
|
||||||
|
if (opts.type === 'post') {
|
||||||
|
return 'tip'
|
||||||
|
} else if (opts.type === 'user') {
|
||||||
|
return 'spontaneousPayment'
|
||||||
|
}
|
||||||
|
// ensures we handle all possible types
|
||||||
|
/** @type {never} */
|
||||||
|
const assertNever = opts.type
|
||||||
|
|
||||||
|
return assertNever && opts.type // please TS
|
||||||
|
})(),
|
||||||
|
amount: Number(payment.value_sat),
|
||||||
|
inbound: false,
|
||||||
|
timestamp: Date.now(),
|
||||||
|
toLndPub: await myLNDPub()
|
||||||
|
})
|
||||||
|
|
||||||
return payment
|
return payment
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error('Error inside sendPayment()')
|
logger.error('Error inside sendPayment()')
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
// @ts-check
|
// @ts-check
|
||||||
const { performance } = require('perf_hooks')
|
|
||||||
const logger = require('winston')
|
const logger = require('winston')
|
||||||
const isFinite = require('lodash/isFinite')
|
const isFinite = require('lodash/isFinite')
|
||||||
const isNumber = require('lodash/isNumber')
|
const isNumber = require('lodash/isNumber')
|
||||||
|
|
@ -14,7 +13,11 @@ const {
|
||||||
} = Common
|
} = Common
|
||||||
|
|
||||||
const LightningServices = require('../../../../utils/lightningServices')
|
const LightningServices = require('../../../../utils/lightningServices')
|
||||||
|
const {
|
||||||
|
addInvoice,
|
||||||
|
myLNDPub
|
||||||
|
} = require('../../../../utils/lightningServices/v2')
|
||||||
|
const { writeCoordinate } = require('../../../coordinates')
|
||||||
const Key = require('../key')
|
const Key = require('../key')
|
||||||
const Utils = require('../utils')
|
const Utils = require('../utils')
|
||||||
|
|
||||||
|
|
@ -56,28 +59,6 @@ const ordersProcessed = new Set()
|
||||||
|
|
||||||
let currentOrderAddr = ''
|
let currentOrderAddr = ''
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {InvoiceRequest} invoiceReq
|
|
||||||
* @returns {Promise<InvoiceResponse>}
|
|
||||||
*/
|
|
||||||
const _addInvoice = invoiceReq =>
|
|
||||||
new Promise((resolve, rej) => {
|
|
||||||
const {
|
|
||||||
services: { lightning }
|
|
||||||
} = LightningServices
|
|
||||||
|
|
||||||
lightning.addInvoice(invoiceReq, (
|
|
||||||
/** @type {any} */ error,
|
|
||||||
/** @type {InvoiceResponse} */ response
|
|
||||||
) => {
|
|
||||||
if (error) {
|
|
||||||
rej(error)
|
|
||||||
} else {
|
|
||||||
resolve(response)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} addr
|
* @param {string} addr
|
||||||
* @param {ISEA} SEA
|
* @param {ISEA} SEA
|
||||||
|
|
@ -104,8 +85,6 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const listenerStartTime = performance.now()
|
|
||||||
|
|
||||||
ordersProcessed.add(orderID)
|
ordersProcessed.add(orderID)
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
|
|
@ -114,8 +93,6 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
||||||
)} -- addr: ${addr}`
|
)} -- addr: ${addr}`
|
||||||
)
|
)
|
||||||
|
|
||||||
const orderAnswerStartTime = performance.now()
|
|
||||||
|
|
||||||
const alreadyAnswered = await getUser()
|
const alreadyAnswered = await getUser()
|
||||||
.get(Key.ORDER_TO_RESPONSE)
|
.get(Key.ORDER_TO_RESPONSE)
|
||||||
.get(orderID)
|
.get(orderID)
|
||||||
|
|
@ -126,12 +103,6 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const orderAnswerEndTime = performance.now() - orderAnswerStartTime
|
|
||||||
|
|
||||||
logger.info(`[PERF] Order Already Answered: ${orderAnswerEndTime}ms`)
|
|
||||||
|
|
||||||
const decryptStartTime = performance.now()
|
|
||||||
|
|
||||||
const senderEpub = await Utils.pubToEpub(order.from)
|
const senderEpub = await Utils.pubToEpub(order.from)
|
||||||
const secret = await SEA.secret(senderEpub, getUser()._.sea)
|
const secret = await SEA.secret(senderEpub, getUser()._.sea)
|
||||||
|
|
||||||
|
|
@ -140,10 +111,6 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
||||||
SEA.decrypt(order.memo, secret)
|
SEA.decrypt(order.memo, secret)
|
||||||
])
|
])
|
||||||
|
|
||||||
const decryptEndTime = performance.now() - decryptStartTime
|
|
||||||
|
|
||||||
logger.info(`[PERF] Decrypt invoice info: ${decryptEndTime}ms`)
|
|
||||||
|
|
||||||
const amount = Number(decryptedAmount)
|
const amount = Number(decryptedAmount)
|
||||||
|
|
||||||
if (!isNumber(amount)) {
|
if (!isNumber(amount)) {
|
||||||
|
|
@ -175,26 +142,19 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
||||||
`onOrders() -> Will now create an invoice : ${JSON.stringify(invoiceReq)}`
|
`onOrders() -> Will now create an invoice : ${JSON.stringify(invoiceReq)}`
|
||||||
)
|
)
|
||||||
|
|
||||||
const invoiceStartTime = performance.now()
|
const invoice = await addInvoice(
|
||||||
|
invoiceReq.value,
|
||||||
const invoice = await _addInvoice(invoiceReq)
|
invoiceReq.memo,
|
||||||
|
true,
|
||||||
const invoiceEndTime = performance.now() - invoiceStartTime
|
invoiceReq.expiry
|
||||||
|
)
|
||||||
logger.info(`[PERF] LND Invoice created in ${invoiceEndTime}ms`)
|
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
'onOrders() -> Successfully created the invoice, will now encrypt it'
|
'onOrders() -> Successfully created the invoice, will now encrypt it'
|
||||||
)
|
)
|
||||||
|
|
||||||
const invoiceEncryptStartTime = performance.now()
|
|
||||||
|
|
||||||
const encInvoice = await SEA.encrypt(invoice.payment_request, secret)
|
const encInvoice = await SEA.encrypt(invoice.payment_request, secret)
|
||||||
|
|
||||||
const invoiceEncryptEndTime = performance.now() - invoiceEncryptStartTime
|
|
||||||
|
|
||||||
logger.info(`[PERF] Invoice encrypted in ${invoiceEncryptEndTime}ms`)
|
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
`onOrders() -> Will now place the encrypted invoice in order to response usergraph: ${addr}`
|
`onOrders() -> Will now place the encrypted invoice in order to response usergraph: ${addr}`
|
||||||
)
|
)
|
||||||
|
|
@ -205,9 +165,7 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
||||||
type: 'invoice'
|
type: 'invoice'
|
||||||
}
|
}
|
||||||
|
|
||||||
const invoicePutStartTime = performance.now()
|
await /** @type {Promise<void>} */ (new Promise((res, rej) => {
|
||||||
|
|
||||||
await new Promise((res, rej) => {
|
|
||||||
getUser()
|
getUser()
|
||||||
.get(Key.ORDER_TO_RESPONSE)
|
.get(Key.ORDER_TO_RESPONSE)
|
||||||
.get(orderID)
|
.get(orderID)
|
||||||
|
|
@ -223,9 +181,7 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
||||||
res()
|
res()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
}))
|
||||||
|
|
||||||
const invoicePutEndTime = performance.now() - invoicePutStartTime
|
|
||||||
|
|
||||||
// invoices should be settled right away so we can rely on this single
|
// invoices should be settled right away so we can rely on this single
|
||||||
// subscription instead of life-long all invoices subscription
|
// subscription instead of life-long all invoices subscription
|
||||||
|
|
@ -234,46 +190,61 @@ const listenerForAddr = (addr, SEA) => async (order, orderID) => {
|
||||||
if (!Common.isPopulatedString(postID)) {
|
if (!Common.isPopulatedString(postID)) {
|
||||||
throw new TypeError(`postID not a a populated string`)
|
throw new TypeError(`postID not a a populated string`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const { r_hash } = invoice
|
|
||||||
|
|
||||||
// A post tip order lifecycle is short enough that we can do it like this.
|
|
||||||
const stream = LightningServices.invoices.subscribeSingleInvoice({
|
|
||||||
r_hash
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {Common.InvoiceWhenListed} invoice
|
|
||||||
*/
|
|
||||||
const onData = invoice => {
|
|
||||||
if (invoice.settled) {
|
|
||||||
getUser()
|
|
||||||
.get('postToTipCount')
|
|
||||||
.get(postID)
|
|
||||||
.set(null) // each item in the set is a tip
|
|
||||||
|
|
||||||
stream.off()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stream.on('data', onData)
|
|
||||||
|
|
||||||
stream.on('status', (/** @type {any} */ status) => {
|
|
||||||
logger.info(`Post tip, post: ${postID}, invoice status:`, status)
|
|
||||||
})
|
|
||||||
stream.on('end', () => {
|
|
||||||
logger.warn(`Post tip, post: ${postID}, invoice stream ended`)
|
|
||||||
})
|
|
||||||
stream.on('error', (/** @type {any} */ e) => {
|
|
||||||
logger.warn(`Post tip, post: ${postID}, error:`, e)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(`[PERF] Added invoice to GunDB in ${invoicePutEndTime}ms`)
|
// A post tip order lifecycle is short enough that we can do it like this.
|
||||||
|
const stream = LightningServices.invoices.subscribeSingleInvoice({
|
||||||
|
r_hash: invoice.r_hash
|
||||||
|
})
|
||||||
|
|
||||||
const listenerEndTime = performance.now() - listenerStartTime
|
/** @type {Common.Coordinate} */
|
||||||
|
const coord = {
|
||||||
|
amount,
|
||||||
|
id: invoice.r_hash.toString(),
|
||||||
|
inbound: true,
|
||||||
|
timestamp: Date.now(),
|
||||||
|
type: 'invoice',
|
||||||
|
invoiceMemo: memo,
|
||||||
|
fromGunPub: order.from,
|
||||||
|
toGunPub: getUser()._.sea.pub,
|
||||||
|
toLndPub: await myLNDPub()
|
||||||
|
}
|
||||||
|
|
||||||
logger.info(`[PERF] Invoice generation completed in ${listenerEndTime}ms`)
|
if (order.targetType === 'post') {
|
||||||
|
coord.type = 'tip'
|
||||||
|
} else {
|
||||||
|
coord.type = 'spontaneousPayment'
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Common.InvoiceWhenListed} invoice
|
||||||
|
*/
|
||||||
|
const onData = invoice => {
|
||||||
|
if (invoice.settled) {
|
||||||
|
if (order.targetType === 'post') {
|
||||||
|
getUser()
|
||||||
|
.get('postToTipCount')
|
||||||
|
// CAST: Checked above.
|
||||||
|
.get(/** @type {string} */ (order.postID))
|
||||||
|
.set(null) // each item in the set is a tip
|
||||||
|
}
|
||||||
|
|
||||||
|
writeCoordinate(invoice.r_hash.toString(), coord)
|
||||||
|
stream.off()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stream.on('data', onData)
|
||||||
|
|
||||||
|
stream.on('status', (/** @type {any} */ status) => {
|
||||||
|
logger.info(`Post tip, post: ${order.postID}, invoice status:`, status)
|
||||||
|
})
|
||||||
|
stream.on('end', () => {
|
||||||
|
logger.warn(`Post tip, post: ${order.postID}, invoice stream ended`)
|
||||||
|
})
|
||||||
|
stream.on('error', (/** @type {any} */ e) => {
|
||||||
|
logger.warn(`Post tip, post: ${order.postID}, error:`, e)
|
||||||
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error(
|
logger.error(
|
||||||
`error inside onOrders, orderAddr: ${addr}, orderID: ${orderID}, order: ${JSON.stringify(
|
`error inside onOrders, orderAddr: ${addr}, orderID: ${orderID}, order: ${JSON.stringify(
|
||||||
|
|
|
||||||
|
|
@ -62,3 +62,5 @@ exports.TOTAL_TIPS = 'totalTips'
|
||||||
exports.PROFILE_BINARY = 'profileBinary'
|
exports.PROFILE_BINARY = 'profileBinary'
|
||||||
|
|
||||||
exports.POSTS_NEW = 'posts'
|
exports.POSTS_NEW = 'posts'
|
||||||
|
|
||||||
|
exports.COORDINATES = 'coordinates'
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ const logger = require('winston')
|
||||||
const Common = require('shock-common')
|
const Common = require('shock-common')
|
||||||
const Ramda = require('ramda')
|
const Ramda = require('ramda')
|
||||||
|
|
||||||
|
const { writeCoordinate } = require('../../services/coordinates')
|
||||||
|
|
||||||
const lightningServices = require('./lightning-services')
|
const lightningServices = require('./lightning-services')
|
||||||
/**
|
/**
|
||||||
* @typedef {import('./types').PaymentV2} PaymentV2
|
* @typedef {import('./types').PaymentV2} PaymentV2
|
||||||
|
|
@ -213,12 +215,50 @@ const isValidSendPaymentInvoiceParams = sendPaymentInvoiceParams => {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} payReq
|
||||||
|
* @returns {Promise<Common.Schema.InvoiceWhenDecoded>}
|
||||||
|
*/
|
||||||
|
const decodePayReq = payReq =>
|
||||||
|
Common.Utils.makePromise((res, rej) => {
|
||||||
|
lightningServices.lightning.decodePayReq(
|
||||||
|
{ pay_req: payReq },
|
||||||
|
/**
|
||||||
|
* @param {{ message: any; }} err
|
||||||
|
* @param {any} paymentRequest
|
||||||
|
*/
|
||||||
|
(err, paymentRequest) => {
|
||||||
|
if (err) {
|
||||||
|
rej(new Error(err.message))
|
||||||
|
} else {
|
||||||
|
res(paymentRequest)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns {Promise<string>}
|
||||||
|
*/
|
||||||
|
const myLNDPub = () =>
|
||||||
|
Common.makePromise((res, rej) => {
|
||||||
|
const { lightning } = lightningServices.getServices()
|
||||||
|
|
||||||
|
lightning.getInfo({}, (err, data) => {
|
||||||
|
if (err) {
|
||||||
|
rej(new Error(err.message))
|
||||||
|
} else {
|
||||||
|
res(data.identity_pubkey)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* aklssjdklasd
|
* aklssjdklasd
|
||||||
* @param {SendPaymentV2Request} sendPaymentRequest
|
* @param {SendPaymentV2Request} sendPaymentRequest
|
||||||
* @returns {Promise<PaymentV2>}
|
* @returns {Promise<PaymentV2>}
|
||||||
*/
|
*/
|
||||||
const sendPaymentV2 = sendPaymentRequest => {
|
const sendPaymentV2 = async sendPaymentRequest => {
|
||||||
const {
|
const {
|
||||||
services: { router }
|
services: { router }
|
||||||
} = lightningServices
|
} = lightningServices
|
||||||
|
|
@ -229,7 +269,10 @@ const sendPaymentV2 = sendPaymentRequest => {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Promise((res, rej) => {
|
/**
|
||||||
|
* @type {import("./types").PaymentV2}
|
||||||
|
*/
|
||||||
|
const paymentV2 = await Common.makePromise((res, rej) => {
|
||||||
const stream = router.sendPaymentV2(sendPaymentRequest)
|
const stream = router.sendPaymentV2(sendPaymentRequest)
|
||||||
|
|
||||||
stream.on(
|
stream.on(
|
||||||
|
|
@ -268,6 +311,33 @@ const sendPaymentV2 = sendPaymentRequest => {
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/** @type {Common.Coordinate} */
|
||||||
|
const coord = {
|
||||||
|
amount: Number(paymentV2.value_sat),
|
||||||
|
id: paymentV2.payment_hash,
|
||||||
|
inbound: false,
|
||||||
|
timestamp: Date.now(),
|
||||||
|
toLndPub: await myLNDPub(),
|
||||||
|
fromLndPub: undefined,
|
||||||
|
invoiceMemo: undefined,
|
||||||
|
type: 'payment'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sendPaymentRequest.payment_request) {
|
||||||
|
const invoice = await decodePayReq(sendPaymentRequest.payment_request)
|
||||||
|
|
||||||
|
coord.invoiceMemo = invoice.description
|
||||||
|
coord.toLndPub = invoice.destination
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sendPaymentRequest.dest) {
|
||||||
|
coord.toLndPub = sendPaymentRequest.dest.toString('base64')
|
||||||
|
}
|
||||||
|
|
||||||
|
await writeCoordinate(paymentV2.payment_hash, coord)
|
||||||
|
|
||||||
|
return paymentV2
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -380,28 +450,6 @@ const listPayments = req => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} payReq
|
|
||||||
* @returns {Promise<Common.Schema.InvoiceWhenDecoded>}
|
|
||||||
*/
|
|
||||||
const decodePayReq = payReq =>
|
|
||||||
Common.Utils.makePromise((res, rej) => {
|
|
||||||
lightningServices.lightning.decodePayReq(
|
|
||||||
{ pay_req: payReq },
|
|
||||||
/**
|
|
||||||
* @param {{ message: any; }} err
|
|
||||||
* @param {any} paymentRequest
|
|
||||||
*/
|
|
||||||
(err, paymentRequest) => {
|
|
||||||
if (err) {
|
|
||||||
rej(new Error(err.message))
|
|
||||||
} else {
|
|
||||||
res(paymentRequest)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {0|1} type
|
* @param {0|1} type
|
||||||
* @returns {Promise<string>}
|
* @returns {Promise<string>}
|
||||||
|
|
@ -582,5 +630,6 @@ module.exports = {
|
||||||
getChanInfo,
|
getChanInfo,
|
||||||
listPeers,
|
listPeers,
|
||||||
pendingChannels,
|
pendingChannels,
|
||||||
addInvoice
|
addInvoice,
|
||||||
|
myLNDPub
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6282,10 +6282,10 @@ shellwords@^0.1.1:
|
||||||
resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b"
|
resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b"
|
||||||
integrity sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==
|
integrity sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==
|
||||||
|
|
||||||
shock-common@29.1.0:
|
shock-common@30.0.0:
|
||||||
version "29.1.0"
|
version "30.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/shock-common/-/shock-common-29.1.0.tgz#3b6d8613fb7c73b8b76c98293a14ec168a9dc888"
|
resolved "https://registry.yarnpkg.com/shock-common/-/shock-common-30.0.0.tgz#86ee39d076fe48adf551265c55e012ab3201c8e9"
|
||||||
integrity sha512-O2tK+TShF3ioAdP4K33MB5QUDTmMqzz+pZe/HnSbi9q1DyX/zQ2Uluzol1NDE/6Z2SSnVFA7/2vJKGaCEdMKoQ==
|
integrity sha512-GgXCNOyk/iu0FBbYcfqOy7obX4RdEn3Q4y8R970CQVk7PvxYt0nZeQwKWe49esKb2B3JL1LOF/yJ7jg7tGze3w==
|
||||||
dependencies:
|
dependencies:
|
||||||
immer "^6.0.6"
|
immer "^6.0.6"
|
||||||
lodash "^4.17.19"
|
lodash "^4.17.19"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue