From ad6cc8ebdbac557c89f1d1af432d852033dd2d00 Mon Sep 17 00:00:00 2001 From: Jay Graber Date: Thu, 20 Apr 2017 14:30:32 -0700 Subject: [PATCH] Check for coinbase in find_taddr_with_unspent --- pyZcash/rpc/ZDaemon.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/pyZcash/rpc/ZDaemon.py b/pyZcash/rpc/ZDaemon.py index 958c6b9..fa847ac 100644 --- a/pyZcash/rpc/ZDaemon.py +++ b/pyZcash/rpc/ZDaemon.py @@ -89,11 +89,14 @@ class ZDaemon(object): return self._call('listunspent') # Custom method to find a taddr with spendable utxos for z_sendmany - def findTaddrWithUnspent(self): + def find_taddr_with_unspent(self): unspent = self._call('listunspent') - for tx in unspent: - if tx['spendable'] == True and tx['amount'] > 0.1: - return tx['address'] + for utxo in unspent: + if utxo['spendable'] == True and utxo['amount'] > 0.1: + # Check that it's not a coinbase tx + tx = zd.gettransaction(utxo['txid']) + if 'generated' not in tx: + return tx['address'] # zaddr methods def z_getnewaddress(self):