|
@ -95,13 +95,13 @@ async function genChannelAndConfirmAccounting(acc: Accounting) { |
|
|
console.log("[WATCH]=> CHANNEL OPENED!", r) |
|
|
console.log("[WATCH]=> CHANNEL OPENED!", r) |
|
|
await models.Accounting.update({ |
|
|
await models.Accounting.update({ |
|
|
status: constants.statuses.confirmed, |
|
|
status: constants.statuses.confirmed, |
|
|
fudingTxid: r.funding_txid_str |
|
|
fundingTxid: r.funding_txid_str |
|
|
},{ |
|
|
}, { |
|
|
where: {id: acc.id} |
|
|
where: { id: acc.id } |
|
|
}) |
|
|
}) |
|
|
console.log("[WATCH]=> ACCOUNTINGS UPDATED!") |
|
|
console.log("[WATCH]=> ACCOUNTINGS UPDATED!") |
|
|
} catch (e) { |
|
|
} catch (e) { |
|
|
console.log('[ACCOUNTING] error creating channel',e) |
|
|
console.log('[ACCOUNTING] error creating channel', e) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -110,7 +110,7 @@ async function pollUTXOs() { |
|
|
const accs: Accounting[] = await getPendingAccountings() |
|
|
const accs: Accounting[] = await getPendingAccountings() |
|
|
if (!accs) return |
|
|
if (!accs) return |
|
|
console.log("[WATCH]=> accs", accs.length) |
|
|
console.log("[WATCH]=> accs", accs.length) |
|
|
asyncForEach(accs, async (acc:Accounting)=>{ |
|
|
asyncForEach(accs, async (acc: Accounting) => { |
|
|
if (acc.confirmations <= 0) return // needs confs
|
|
|
if (acc.confirmations <= 0) return // needs confs
|
|
|
if (acc.amount <= 0) return // needs amount
|
|
|
if (acc.amount <= 0) return // needs amount
|
|
|
if (!acc.pubkey) return // this shouldnt happen
|
|
|
if (!acc.pubkey) return // this shouldnt happen
|
|
@ -242,7 +242,7 @@ export const receiveQueryResponse = async (payload) => { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
async function asyncForEach(array, callback) { |
|
|
async function asyncForEach(array, callback) { |
|
|
for (let index = 0; index < array.length; index++) { |
|
|
for (let index = 0; index < array.length; index++) { |
|
|
await callback(array[index], index, array); |
|
|
await callback(array[index], index, array); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |