Skip to content

Commit

Permalink
FIX: race condition for address generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Overtorment committed Apr 14, 2022
1 parent 60cda5e commit fb023b0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions class/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ export class User {
return new Promise(function (resolve, reject) {
self._lightning.newAddress({ type: 0 }, async function (err, response) {
if (err) return reject('LND failure when trying to generate new address');
const addressAlreadyExists = await self.getAddress();
if (addressAlreadyExists) {
// one last final check, for a case of really long race condition
resolve();
return;
}
await self.addAddress(response.address);
if (config.bitcoind) self._bitcoindrpc.request('importaddress', [response.address, response.address, false]);
resolve();
Expand Down

0 comments on commit fb023b0

Please sign in to comment.