objects/btc.rb
# Returns TRUE if transaction with this hash, amount, and target address exists
Returns TRUE if transaction with this hash, amount, and target address exists
Returns TRUE if transaction with this hash amount and target address exists
def exists?(hash, amount, address, confirmations)
    attempt = 0
    begin
      res = Zold::Http.new(uri: "https://blockchain.info/rawtx/#{hash}").get
      raise "Invalid response code #{res.status}" unless res.status == 200
      txn = Zold::JsonPage.new(res.body).to_hash
      return false if txn['out'].find { |t| t['addr'] == address && t['value'] == amount }.nil?
      return false if confirmations.zero?
      return false if confirmations < 2 && amount > 100_000 
      return false if confirmations < 3 && amount > 1_000_000 
      return false if confirmations < 4 && amount > 10_000_000 
      return false if confirmations < 5 && amount > 100_000_000 
      true
    rescue StandardError => e
      attempt += 1
      if attempt < 3
        sleep 0.5
        retry
      end
      @log.error(Backtrace.new(e))
      false
    end
  end
def exists? ( hash , amount , address , confirmations ) attempt = 0 begin res = Zold :: Http . new ( uri : "https://blockchain.info/rawtx/#{hash}" ) . get raise "Invalid response code #{res.status}" unless res . status == 200 txn = Zold :: JsonPage . new ( res . body ) . to_hash return false if txn [ 'out' ] . find { | t | t [ 'addr' ] == address && t [ 'value' ] == amount } . nil? return false if confirmations . zero? return false if confirmations < 2 && amount > 100_000 return false if confirmations < 3 && amount > 1_000_000 return false if confirmations < 4 && amount > 10_000_000 return false if confirmations < 5 && amount > 100_000_000 true rescue StandardError => e attempt += 1 if attempt < 3 sleep 0.5 retry end @log . error ( Backtrace . new ( e ) ) false end end
Returns TRUE if transaction with this hash, amount, and target address exists
Returns TRUE if transaction with this hash amount and target address exists
# 0.001 BTC # 0.01 BTC # 0.1 BTC # 1 BTC
hash
amount
address
confirmations