This commit is contained in:
Daniel Lugo 2020-02-28 16:52:51 -04:00
parent ad61133efe
commit 7ddf7c82f3

View file

@ -958,19 +958,19 @@ const sendPayment = async (to, amount, memo) => {
let timeoutID
const invoice = await Promise.race([
Utils.tryAndWait(
gun =>
gun
new Promise(res => {
require('../Mediator')
.getGun()
.user(to)
.get(Key.ORDER_TO_RESPONSE)
.get(orderID)
.then()
.then(v => {
.on(inv => {
if (typeof inv === 'string') {
clearTimeout(timeoutID)
return v
res(inv)
}
})
}),
v => typeof v !== 'string'
),
new Promise((_, rej) => {
setTimeout(() => {
rej(new Error(ErrorCode.ORDER_NOT_ANSWERED_IN_TIME))