You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
741 B

require 'yaml'
require "./zcash"
# hex2ascii
def decode_memo(hex_msg)
hex_msg.scan(/\\x(..)/).map{|a| a.first.to_i(16).chr}.join
nodes = YAML.load("sentinel.sample.yml"))
board = nodes['BoardNode']
Zcash.z_importviewingkey board['viewing_key']
loop true
transfers = Zcash.z_listreceivedbyaddress(board['zaddr'])
# todo: just act for new transfers, caching last execution datetime.
transfers.each |transfer|
memo = decode_memo transfer["memo"]
# sample: memo = {action: "reply", to: "$txid", msg: "$msg"}
if memo.key?(:action) && action = memo[:action]
# execute related action
cmd = board["actions"][action]["run"]
puts "Executing: #{cmd}"
sleep 30