# --- Estimate transaction fees --- srv = Service(network=network) if args.fee_per_kb: fee_per_kb = args.fee_per_kb else: fee_per_kb = srv.estimatefee() if not srv.results: raise IOError("No response from services, could not determine estimated transaction fees. " "You can use --fee-per-kb option to determine fee manually and avoid this error.") tr_size = 100 + (1 * 150) + (len(outputs_arr) * 50) estimated_fee = int((tr_size / 1024) * fee_per_kb) if estimated_fee < 0: raise IOError("No valid response from any service provider, could not determine estimated transaction fees. " "You can use --fee-per-kb option to determine fee manually and avoid this error.") print("Estimated fee is for this transaction is %s (%d satoshis/kb)" % (network_obj.print_value(estimated_fee), fee_per_kb)) print("Total value of outputs is %s" % network_obj.print_value(total_amount)) total_transaction = total_amount + estimated_fee # --- Check for UTXO's and create transaction and Paper wallets input_key = wallet.keys(name="Input", is_active=None)[0] wallet.utxos_update(account_id=0) print("\nTotal wallet balance: %s" % wallet.balance(as_string=True)) input_key = wallet.keys(name="Input", is_active=None)[0] enough_balance = bool(input_key.balance >= total_transaction) if not enough_balance and not args.print: remaining_balance = total_transaction - input_key.balance file_inputcode = os.path.join(WALLET_DIR, str(wallet.wallet_id) + '-input-address-qrcode.png') networklink = network if networklink == 'testnet': networklink = 'bitcoin'
else: fee_per_kb = srv.estimatefee() if not srv.results: raise IOError( "No response from services, could not determine estimated transaction fees. " "You can use --fee-per-kb option to determine fee manually and avoid this error." ) tr_size = 100 + (1 * 150) + (len(outputs_arr) * 50) estimated_fee = int((tr_size / 1024) * fee_per_kb) if estimated_fee < 0: raise IOError( "No valid response from any service provider, could not determine estimated transaction fees. " "You can use --fee-per-kb option to determine fee manually and avoid this error." ) print("Estimated fee is for this transaction is %s (%d satoshis/kb)" % (network_obj.print_value(estimated_fee), fee_per_kb)) print("Total value of outputs is %s" % network_obj.print_value(total_amount)) total_transaction = total_amount + estimated_fee # --- Check for UTXO's and create transaction and Paper wallets input_key = wallet.keys(name="Input", is_active=None)[0] wallet.utxos_update(account_id=0) print("\nTotal wallet balance: %s" % wallet.balance(as_string=True)) input_key = wallet.keys(name="Input", is_active=None)[0] enough_balance = bool(input_key.balance < total_transaction) if not enough_balance and not args.print: remaining_balance = total_transaction - input_key.balance file_inputcode = os.path.join( WALLET_DIR, str(wallet.wallet_id) + '-input-address-qrcode.png')
def test_networks_print_value(self): network = Network('dash') self.assertEqual(network.print_value(10000), '0.00010000 DASH')