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 let timeoutID
const invoice = await Promise.race([ const invoice = await Promise.race([
Utils.tryAndWait( new Promise(res => {
gun => require('../Mediator')
gun .getGun()
.user(to) .user(to)
.get(Key.ORDER_TO_RESPONSE) .get(Key.ORDER_TO_RESPONSE)
.get(orderID) .get(orderID)
.then() .on(inv => {
.then(v => { if (typeof inv === 'string') {
clearTimeout(timeoutID) clearTimeout(timeoutID)
return v res(inv)
}
})
}), }),
v => typeof v !== 'string'
),
new Promise((_, rej) => { new Promise((_, rej) => {
setTimeout(() => { setTimeout(() => {
rej(new Error(ErrorCode.ORDER_NOT_ANSWERED_IN_TIME)) rej(new Error(ErrorCode.ORDER_NOT_ANSWERED_IN_TIME))