Ironically, your question was asked nearly identically on the Bitcoin Stack Exchange:
How to "Autoforward" incoming BTC using Electrum https://bitcoin.stackexchange.com/questions/114615
Unfortunately, nobody has shared a script there that is ready to go that does that.
I see this article, ... a how-to if you are running bitcoin core, which you could then create a script to do it:
There's also this article which may be of help, for someone writing a script. Different from above in that it uses some third party API service.
Send bitcoin from your wallet using JavaScript https://blog.logrocket.com/sending-bitcoin-with-javascript/
And finally, maybe some of these scripts will help you in some way.
Various shell scripts, mainly to be used together with Bitcoin Core (bitcoind or bitcoin-qt) wallet. https://github.com/kristapsk/bitcoin-scripts
Just a caveat ... it's not that hard for a script to do something you didn't intend for it to do. Bitcoin transactions are non-reversible, as you likely know, ... so a script doing something dumb like forgetting to calculate the change amount properly would result in the change going to the miner.
So, ... use testnet if you are developing a script, and have a second set of eyes on a script before you run it live on bitcoin main.
reply