Merge pull request #1470 from bigchaindb/fix/outputs-public-keys-validate

check output conditions with single statement (#1450 unrevert)
This commit is contained in:
Rodolphe Marques 2017-07-03 15:46:46 +02:00 committed by GitHub
commit e89623c836
2 changed files with 3 additions and 15 deletions

View File

@ -1,4 +1,4 @@
from bigchaindb.utils import output_has_owner
from bigchaindb.utils import condition_details_has_owner
from bigchaindb.backend import query
from bigchaindb.common.transaction import TransactionLink
@ -52,7 +52,8 @@ class FastQuery:
return [TransactionLink(tx['id'], index)
for tx in txs
for index, output in enumerate(tx['outputs'])
if output_has_owner(output, public_key)]
if condition_details_has_owner(output['condition']['details'],
public_key)]
def filter_spent_outputs(self, outputs):
"""

View File

@ -113,19 +113,6 @@ def condition_details_has_owner(condition_details, owner):
return False
def output_has_owner(output, owner):
# TODO
# Check whether it is really necessary to treat the single key case
# differently from the multiple keys case, and why not just use the same
# function for both cases.
if len(output['public_keys']) > 1:
return condition_details_has_owner(
output['condition']['details'], owner)
elif len(output['public_keys']) == 1:
return output['condition']['details']['public_key'] == owner
# TODO raise proper exception, e.g. invalid tx payload?
def is_genesis_block(block):
"""Check if the block is the genesis block.