示例#1
0
  def sign_now(self, tx):
    # sign now signs the transaction and broadcasts it over the network

    inputs, outputs = self.btc.get_inputs_outputs(tx)

    rq_hash = self.get_tx_hash(tx)

    rq_data = self.kv.get_by_section_key('signable', rq_hash)
    if rq_data is None:
      logging.debug("not scheduled to sign this")
      return

    inputs = rq_data['inputs']
    sigs_so_far = rq_data['sigs_so_far']
    req_sigs = rq_data['req_sigs']

    assert( self.is_proper_transaction(tx, inputs) )

    tx_sigs_count = self.btc.signatures_count(
        tx,
        inputs)

    logging.debug("sigs count so far: %r; req_sigs: %r" % (tx_sigs_count, req_sigs))

    if sigs_so_far > tx_sigs_count: # or > not >=? TODO
      logging.debug('already signed a transaction with more sigs')
      return

    rq_data['sigs_so_far'] = tx_sigs_count
    self.kv.update('signable', rq_hash, rq_data)
    # ^ let's remember the tx with most sigs that we've seen.

    if tx_sigs_count >= req_sigs:
      logging.debug('already signed with enough keys')
      return

    pwtxid = rq_data['pwtxid']

    signed_transaction = self.btc.sign_transaction(tx, inputs)

    tx_new_sigs_count = self.btc.signatures_count(signed_transaction, inputs)

    if (tx_new_sigs_count == tx_sigs_count):
      logging.debug('failed signing transaction. already signed by me? aborting')
      return

    tx_sigs_count += 1

    body = { 'pwtxid': pwtxid, 'operation':'sign', 'transaction': signed_transaction, 'sigs': tx_sigs_count, 'req_sigs': req_sigs }
    logging.debug('broadcasting: %r' % body)
    self.oracle.broadcast_with_fastcast(json.dumps(body))

    if tx_sigs_count == req_sigs:
      safe_pushtx(signed_transaction)
      self.oracle.btc.send_transaction(signed_transaction)

    rq_data['sigs_so_far'] = tx_sigs_count
    self.kv.update('signable', rq_hash, rq_data)
示例#2
0
def pushtx(args):
    tx = args[0]
    print safe_pushtx(tx)
示例#3
0
文件: main.py 项目: Gricha/orisi
def pushtx(args):
  tx = args[0]
  print safe_pushtx(tx)
示例#4
0
    def sign_now(self, tx):
        # sign now signs the transaction and broadcasts it over the network

        inputs, outputs = self.btc.get_inputs_outputs(tx)

        rq_hash = self.get_tx_hash(tx)

        rq_data = self.kv.get_by_section_key('signable', rq_hash)
        if rq_data is None:
            logging.debug("not scheduled to sign this")
            return

        inputs = rq_data['inputs']
        sigs_so_far = rq_data['sigs_so_far']
        req_sigs = rq_data['req_sigs']

        assert (self.is_proper_transaction(tx, inputs))

        tx_sigs_count = self.btc.signatures_count(tx, inputs)

        logging.debug("sigs count so far: %r; req_sigs: %r" %
                      (tx_sigs_count, req_sigs))

        if sigs_so_far > tx_sigs_count:  # or > not >=? TODO
            logging.debug('already signed a transaction with more sigs')
            return

        rq_data['sigs_so_far'] = tx_sigs_count
        self.kv.update('signable', rq_hash, rq_data)
        # ^ let's remember the tx with most sigs that we've seen.

        if tx_sigs_count >= req_sigs:
            logging.debug('already signed with enough keys')
            return

        pwtxid = rq_data['pwtxid']

        signed_transaction = self.btc.sign_transaction(tx, inputs)

        tx_new_sigs_count = self.btc.signatures_count(signed_transaction,
                                                      inputs)

        if (tx_new_sigs_count == tx_sigs_count):
            logging.debug(
                'failed signing transaction. already signed by me? aborting')
            return

        tx_sigs_count += 1

        body = {
            'pwtxid': pwtxid,
            'operation': 'sign',
            'transaction': signed_transaction,
            'sigs': tx_sigs_count,
            'req_sigs': req_sigs
        }
        logging.debug('broadcasting: %r' % body)
        self.oracle.broadcast_with_fastcast(json.dumps(body))

        if tx_sigs_count == req_sigs:
            safe_pushtx(signed_transaction)
            self.oracle.btc.send_transaction(signed_transaction)

        rq_data['sigs_so_far'] = tx_sigs_count
        self.kv.update('signable', rq_hash, rq_data)
示例#5
0
 def broadcast_transaction(self, transaction):
   logging.info("Broadcasting transaction")
   safe_pushtx(transaction)
   self.oracle.btc.send_transaction(transaction)