Bitcoin Forum
May 24, 2024, 08:02:50 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Automated Bitcoin Payments  (Read 147 times)
cryptocentralized (OP)
Newbie
*
Offline Offline

Activity: 11
Merit: 0


View Profile
January 24, 2018, 07:00:06 AM
 #1

Hi all,

I want to run a script once a week that sends an amount to a specific address. The amount sent is decided by how much was deposited into the account during the week. For instance the wallet must always have 1 BTC in it and anything over that is sent to the new address each week.

The OS i am using in ubuntu on a Raspberry Pi 3 and i know how to schedule the job using crontab but i do not know how to write the bash script. The bitcoin daemon and bitcoin-cli are all hosted on the same machine as the script.

so far this is what i have.

#!/bin/bash
if [ $(echo "$(bitcoin-cli getbalance) > 1" | bc) -eq 1 ];
then
      bitcoin-cli sendtoaddress ADDRESS $(bitcoin-cli getbalance - 1) "Automated Payment"
fi

Does anyone have any suggestions on how to improve this?

Thanks
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!