Skip to content

Commit

Permalink
fix allow no recipient (only for sell offer now)
Browse files Browse the repository at this point in the history
  • Loading branch information
grazcoin committed Feb 26, 2014
1 parent b62be51 commit ecbcf84
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions msc_parse.py
Expand Up @@ -77,7 +77,7 @@ def parse():
starting_block_height=requested_block_height

# to catch chain reorgs, check 5 blocks back
starting_block_height -= 5
starting_block_height = int(starting_block_height) - 5

archive=options.archive

Expand Down Expand Up @@ -218,7 +218,7 @@ def parse():
debug('skip bootstrap basic tx with less than 3 outputs '+tx_hash)
else: # multisig
if num_of_outputs == 2: # depracated simple version of multisig or sell offer with no change
parsed=parse_multisig(raw_tx, tx_hash, allow_no_recipient=True)
parsed=parse_multisig(raw_tx, tx_hash)
if len(parsed) == 0:
continue
parsed['method']='multisig'
Expand Down
19 changes: 12 additions & 7 deletions msc_utils_parsing.py
Expand Up @@ -255,7 +255,7 @@ def get_obfus_str_list(address, length):
obfus_str_list.append(get_sha256(obfus_str_list[i].upper())) # i'th obfus is sha256 of upper prev
return obfus_str_list

def parse_multisig(tx, tx_hash='unknown', allow_no_recipient=False):
def parse_multisig(tx, tx_hash='unknown'):
if multisig_disabled:
info('multisig is disabled: '+tx_hash)
return {}
Expand All @@ -280,11 +280,6 @@ def parse_multisig(tx, tx_hash='unknown', allow_no_recipient=False):
to_address=o['address']
continue

# no recipient?
if not allow_no_recipient and to_address=='unknown':
info('no recipient tx '+tx_hash)
return {'tx_hash':tx_hash, 'invalid':(True, 'no recipient')}

for o in outputs_list_no_exodus:
if o['address']==None: # This should be the multisig
script=o['script']
Expand Down Expand Up @@ -333,6 +328,12 @@ def parse_multisig(tx, tx_hash='unknown', allow_no_recipient=False):
data_dict=parse_data_script(dataHex_deobfuscated_list[0])
except IndexError:
error('cannot parse dataHex_deobfuscated_list')

# no recipient? allow for sell offer
if to_address=='unknown' and data_dict['transactionType'] != '0014':
info('no recipient tx '+tx_hash)
return {'tx_hash':tx_hash, 'invalid':(True, 'no recipient')}

if len(data_dict) >= 6: # at least 6 basic fields got parse on the first dataHex
amount=int(data_dict['amount'],16)/100000000.0
parse_dict=data_dict
Expand Down Expand Up @@ -367,7 +368,11 @@ def parse_multisig(tx, tx_hash='unknown', allow_no_recipient=False):
price_per_coin=bitcoin_amount_desired/amount
else:
price_per_coin=0
parse_dict['invalid']=(True,'non positive sell offer amount')
if amount == 0 and data_dict['transactionVersion']=='0000':
# cancel sell order
pass
else:
parse_dict['invalid']=(True,'non positive sell offer amount')
# duplicate with another name
parse_dict['formatted_amount_available'] = parse_dict['formatted_amount']
# format fields
Expand Down

0 comments on commit ecbcf84

Please sign in to comment.