Beispiel #1
0
 def on_receiving_btc_address_changed(self, txt):
     self.ids.receiving_btc_address_input.text = txt
     transaction_details = local_storage.read_transaction(
         self.transaction_id)
     transaction_details['buyer']['btc_address'] = txt
     local_storage.write_transaction(transaction_details['transaction_id'],
                                     transaction_details)
 def on_disable_transaction_button_clicked(self):
     transaction_id = self.ids.transactions_view.selected_item.ids.tr_id.text
     tr = local_storage.read_transaction(transaction_id)
     if not tr:
         return
     tr['void'] = True
     local_storage.write_transaction(transaction_id, tr)
     self.ids.transactions_view.populate()
Beispiel #3
0
 def on_start_transaction_button_clicked(self):
     cur_settings = local_storage.read_settings()
     t_now = datetime.datetime.now()
     btc_usd_commission_percent = float(
         cur_settings.get('btc_usd_commission_percent', '0.0'))
     btc_price_current = float(self.ids.btc_price_input.text)
     factor = (100.0 + btc_usd_commission_percent) / 100.0
     contract_btc_price = str(round(btc_price_current * factor, 2))
     transaction_details = {}
     transaction_details.update(
         dict(
             contract_type='sales',
             usd_amount=self.ids.usd_amount_input.text,
             world_btc_price=self.ids.btc_price_input.text,
             btc_price=contract_btc_price,
             btc_amount=btc_util.clean_btc_amount(
                 self.ids.btc_amount_input.text),
             fee_percent=str(
                 float(cur_settings.get('btc_usd_commission_percent',
                                        '0.0'))),
             date=t_now.strftime("%b %d %Y"),
             time=t_now.strftime("%I:%M %p"),
             seller=dict(
                 customer_id=None,
                 first_name=cur_settings.get('business_owner_first_name',
                                             ''),
                 last_name=cur_settings.get('business_owner_last_name', ''),
                 address=cur_settings.get('business_address', ''),
                 email=cur_settings.get('business_email', ''),
                 phone=cur_settings.get('business_phone', ''),
                 btc_address=(cur_settings.get('receiving_btc_address_list',
                                               [
                                                   '',
                                               ]) or [
                                                   '',
                                               ])[0],
             ),
             buyer=dict(
                 customer_id=self.selected_customer_id,
                 first_name=self.ids.person_first_name_input.text,
                 last_name=self.ids.person_last_name_input.text,
                 address=self.ids.person_address_input.text,
                 email=self.ids.person_email_input.text,
                 phone=self.ids.person_phone_input.text,
                 btc_address=self.ids.receive_address_input.text,
             ),
             company_name=cur_settings.get('business_company_name', ''),
         ))
     new_transaction_details = local_storage.create_new_transaction(
         transaction_details)
     local_storage.write_transaction(
         new_transaction_details['transaction_id'], new_transaction_details)
     self.clean_input_fields()
     self.scr('one_transaction_screen'
              ).transaction_id = new_transaction_details['transaction_id']
     self.scr_manager().current = 'one_transaction_screen'
Beispiel #4
0
 def on_start_transaction_button_clicked(self):
     cur_settings = local_storage.read_settings()
     t_now = datetime.datetime.now()
     transaction_details = {}
     transaction_details.update(
         dict(
             contract_type='purchase',
             usd_amount=self.ids.usd_amount_input.text,
             btc_price=self.ids.btc_price_input.text,
             btc_amount=self.ids.btc_amount_input.text,
             fee_percent=str(
                 float(cur_settings.get('usd_btc_commission_percent',
                                        '0.0'))),
             date=t_now.strftime("%b %d %Y"),
             time=t_now.strftime("%H:%M %p"),
             seller=dict(
                 customer_id=self.selected_customer_id,
                 first_name=self.ids.person_first_name_input.text,
                 last_name=self.ids.person_last_name_input.text,
                 btc_address=self.ids.receive_address_input.text,
                 address=self.ids.person_address_input.text,
                 email=self.ids.person_email_input.text,
                 phone=self.ids.person_phone_input.text,
             ),
             buyer=dict(
                 customer_id=None,
                 first_name=cur_settings.get('business_owner_first_name',
                                             ''),
                 last_name=cur_settings.get('business_owner_last_name', ''),
                 address=cur_settings.get('business_address', ''),
                 email=cur_settings.get('business_email', ''),
                 phone=cur_settings.get('business_phone', ''),
                 btc_address=cur_settings.get('receiving_btc_address', ''),
             ),
             company_name=cur_settings.get('business_company_name', ''),
         ))
     new_transaction_details = local_storage.create_new_transaction(
         transaction_details)
     local_storage.write_transaction(
         new_transaction_details['transaction_id'], new_transaction_details)
     self.scr('one_transaction_screen'
              ).transaction_id = new_transaction_details['transaction_id']
     self.scr_manager().current = 'one_transaction_screen'
Beispiel #5
0
 def on_verify_button_clicked(self):
     transaction_details = local_storage.read_transaction(
         self.transaction_id)
     if transaction_details.get('blockchain_status') == 'confirmed':
         return
     cur_settings = local_storage.read_settings()
     self.ids.verify_button.disabled = True
     self.ids.verify_status_label.text = '[color=#505050]requesting transactions from btc.com ...[/color]'
     matching_transactions = btc_util.verify_contract(
         contract_details=transaction_details,
         price_precision_fixed_amount=float(
             cur_settings.get('price_precision_fixed_amount', '0.0')),
         price_precision_matching_percent=float(
             cur_settings.get('price_precision_matching_percent', '0.0')),
         time_matching_seconds_before=float(
             cur_settings.get('time_matching_seconds_before', '0.0')),
         time_matching_seconds_after=float(
             cur_settings.get('time_matching_seconds_after', '0.0')),
     )
     self.ids.verify_button.disabled = False
     st = ''
     if len(matching_transactions) == 0:
         st = '[color=#505050]did not found any matching transactions for BTC address %s[/color]' % transaction_details[
             'buyer']['btc_address']
     elif len(matching_transactions) > 1:
         st = '[color=#F05050]found multiple matching transactions for BTC address %s[/color]' % transaction_details[
             'buyer']['btc_address']
     else:
         st = '[color=#70a070]found corresponding transaction of %s BTC for address %s[/color]' % (
             transaction_details['btc_amount'],
             transaction_details['buyer']['btc_address'])
         transaction_details['blockchain_status'] = 'confirmed'
         transaction_details['blockchain_tx_info'] = matching_transactions[
             0]
         local_storage.write_transaction(
             transaction_details['transaction_id'], transaction_details)
     self.ids.verify_status_label.text = st
     self.populate_fields(transaction_details)
 def verify_next_transaction(self, *args):
     if not self.transactions_to_be_verified:
         self.ids.verify_contracts_button.disabled = False
         return
     transaction_details = self.transactions_to_be_verified.pop(0)
     self.verification_progress += 1
     if _Debug:
         print('verify_next_transaction %r  progress is %r' %
               (transaction_details['transaction_id'],
                self.verification_progress))
     cur_settings = local_storage.read_settings()
     matching_transactions = btc_util.verify_contract(
         contract_details=transaction_details,
         price_precision_matching_percent=float(
             cur_settings.get('price_precision_matching_percent', '0.0')),
         price_precision_fixed_amount=float(
             cur_settings.get('price_precision_fixed_amount', '0.0')),
         time_matching_seconds_before=float(
             cur_settings.get('time_matching_seconds_before', '0.0')),
         time_matching_seconds_after=float(
             cur_settings.get('time_matching_seconds_after', '0.0')),
     )
     if len(matching_transactions) == 1:
         transaction_details['blockchain_status'] = 'confirmed'
         transaction_details['blockchain_tx_info'] = matching_transactions[
             0]
         local_storage.write_transaction(
             transaction_details['transaction_id'], transaction_details)
         for transaction_item in self.ids.transactions_view.data:
             if transaction_item['tr_id'] == transaction_details[
                     'transaction_id']:
                 transaction_item[
                     'blockchain_status'] = '[color={}][{}][/color]'.format(
                         '#60b060', 'confirmed')
                 self.ids.transactions_view.refresh_from_data()
     Clock.schedule_once(self.verify_next_transaction, 5.0)