Is there a way to safely generate many addresses via script without triggering the “used” color?
It's just telling you that the red addresses will not be automatically show when you restore the seed phrase to another Electrum or other wallets.
If one of those non-red address has received a transaction, it'll count 20 addresses below it and remove their red highlight indicating that it's now covered by most wallet's default gap limit of 20.
Based from the command, this is related your other thread where you needed to export 1000 addresses but not via xpub, here:
/index.php?topic=5561497.0If so, if online, that wallet will be able to see and spend without issues once those addresses receive any bitcoins.
If offline, it can still sign PSBT created by an online watch-only wallet whether it's beyond the gap limit, not generated yet or not. (
all it needs is the xprv key in the wallet if the PSBT is properly created)
You may increase the gap limit to 1000 to mark them green but that will always pre-generate 1000 more addresses on top of the last used one. (
in case of online wallet)
Since you only exported a specific number of addresses for that website, you don't need those extra addresses.
But if you're going to add more in the future, then go ahead; but we warned that there's a non-specific limit on how many addresses Electrum can handle.
And it's not "
unsafe" since those are all backed-up by your seed phrase.
The only issue is if you've used the <x>th address without using the previous ones then restore the seed phrase which usually only generates 20.
Like if you didn't use the first 20 previously (
0~19 address index), the wallet will miss the ones with transactions in (let's say) 20th+ index until you generate those again or increase the wallet's gap limit.
The same issue applies to both method since it's not the default gap limit used by most wallets.