def main(txids, options=['PRECHECK', 'LINKABILITY', 'MERGE_INPUTS'], max_duration=600, max_txos=12, max_cj_intrafees_ratio=0): ''' Main function Parameters: txids = list of transactions txids to be processed options = options to be applied during processing max_duration = max duration allocated to processing of a single tx (in seconds) max_txos = max number of txos. Txs with more than max_txos inputs or outputs are not processed. max_cj_intrafees_ratio = max intrafees paid by the taker of a coinjoined transaction. Expressed as a percentage of the coinjoined amount. ''' # Initializes the wrapper for bci api bci_wrapper = BlockchainInfoWrapper() for txid in txids: print('\n\n--- %s -------------------------------------' % txid) # Retrieves the tx from bci try: tx = bci_wrapper.get_tx(txid) except: print('Unable to retrieve information for %s from bc.i' % txid) continue # Computes the entropy of the tx and the linkability of txos (mat_lnk, nb_cmbn, inputs, outputs, fees, intrafees) = process_tx(tx, options, max_duration, max_txos, max_cj_intrafees_ratio) # Displays the results display_results(mat_lnk, nb_cmbn, inputs, outputs, fees, intrafees)
def main(txids, rpc, testnet, smartbit, options=['PRECHECK', 'LINKABILITY', 'MERGE_INPUTS'], max_duration=600, max_txos=12, max_cj_intrafees_ratio=0): ''' Main function Parameters: txids = list of transactions txids to be processed rpc = use bitcoind's RPC interface (or blockchain.info web API) testnet = use testnet (blockchain.info by default) smartbit = use smartbit data provider options = options to be applied during processing max_duration = max duration allocated to processing of a single tx (in seconds) max_txos = max number of txos. Txs with more than max_txos inputs or outputs are not processed. max_cj_intrafees_ratio = max intrafees paid by the taker of a coinjoined transaction. Expressed as a percentage of the coinjoined amount. ''' blockchain_provider = None provider_descriptor = '' if rpc: blockchain_provider = BitcoindRPCWrapper() provider_descriptor = 'local RPC interface' else: if smartbit == True: blockchain_provider = SmartbitWrapper() provider_descriptor = 'remote Smartbit API' else: blockchain_provider = BlockchainInfoWrapper() provider_descriptor = 'remote blockchain.info API' print("DEBUG: Using %s" % provider_descriptor) for txid in txids: print('\n\n--- %s -------------------------------------' % txid) # retrieves the tx from local RPC or external data provider try: if rpc: tx = blockchain_provider.get_tx(txid) else: tx = blockchain_provider.get_tx(txid, testnet) print("DEBUG: Tx fetched: {0}".format(str(tx))) except Exception as err: print('Unable to retrieve information for %s from %s: %s %s' % (txid, provider_descriptor, err, traceback.format_exc())) continue # Computes the entropy of the tx and the linkability of txos (mat_lnk, nb_cmbn, inputs, outputs, fees, intrafees, efficiency) = process_tx(tx, options, max_duration, max_txos, max_cj_intrafees_ratio) # Displays the results display_results(mat_lnk, nb_cmbn, inputs, outputs, fees, intrafees, efficiency)