 
   #-----------------------------------
 
+  is_good_input_tx : (tx) ->
+    amt = tx.amount * SATOSHI_PER_BTC
+    (tx.address is @from_address()) and 
+      (amt >= @min_amount()) and (amt <= @max_amount()) and
+      (tx.confirmations >= @min_confirmations())
+
+  #-----------------------------------
+
   find_transaction : (cb) ->
-    cb null
-
+    esc = make_esc cb, "Runner::find_transaction"
+    await @cli.listUnspent esc defer txs
+    for tx in txs
+      if @is_good_input_tx tx
+        @input_tx = tx
+        break
+    if not @input_tx?
+      err = new Error "Couldn't find spendable input transaction"
+    cb err
 
   #-----------------------------------
 

  constructor : () ->
    @config = {}
    @bitcoin_config = {}

  #-----------------------------------



#====================================================================================

SATOSHI_PER_BTC = 100 * 1000 * 1000

#====================================================================================

exports.Runner = class Runner 

  #-----------------------------------
