コード例 #1
0
ファイル: vaultdb.py プロジェクト: obulpathi/reversecoin
 def removeconfirmedvaulttxs(self, txs):
     if not txs:
         return
     # remove confirmed transactions from VaultDB
     self.logger.debug('Removing confirmed transactions from VaultDB')
     connection = sqlite.connect(self.vaultfile)
     cursor = connection.cursor()
     cmd_confirmed = "DELETE FROM vaults WHERE txhash = (?)"
     cmd_override = "DELETE FROM vaults WHERE fromaddress = (?)"
     for tx in txs:
         if tx.is_coinbase():
             continue
         for txin in tx.vin:
             if txin.scriptSig[0] == chr(script.OP_VAULT_CONFIRM):
                 newtx = core.CTransaction()
                 newtx.copy(tx)
                 # TODO: assuming only one input
                 newtx.vin[0].scriptSig = chr(script.OP_VAULT_WITHDRAW) + \
                     txin.scriptSig[1:]
                 newtx.calc_sha256()
                 values = (str(newtx.sha256),)
                 cursor.execute(cmd_confirmed, values)
             elif txin.scriptSig[0] == chr(script.OP_VAULT_OVERRIDE):
                 fromaddress = str(utils.scriptSig_to_vault_address(txin.scriptSig))
                 values = (fromaddress,)
                 cursor.execute(cmd_override, values)
     connection.commit()
     connection.close()
     self.logger.debug('Removed confirmed transactions from VaultDB')
コード例 #2
0
ファイル: vaultdb.py プロジェクト: fmfmartins/reversecoin
 def removeconfirmedvaulttxs(self, txs):
     if not txs:
         return
     # remove confirmed transactions from VaultDB
     self.logger.debug('Removing confirmed transactions from VaultDB')
     connection = sqlite.connect(self.vaultfile)
     cursor = connection.cursor()
     cmd_confirmed = "DELETE FROM vaults WHERE txhash = (?)"
     cmd_override = "DELETE FROM vaults WHERE fromaddress = (?)"
     for tx in txs:
         if tx.is_coinbase():
             continue
         for txin in tx.vin:
             if txin.scriptSig[0] == chr(script.OP_VAULT_CONFIRM):
                 newtx = core.CTransaction()
                 newtx.copy(tx)
                 # TODO: assuming only one input
                 newtx.vin[0].scriptSig = chr(script.OP_VAULT_WITHDRAW) + \
                     txin.scriptSig[1:]
                 newtx.calc_sha256()
                 values = (str(newtx.sha256), )
                 cursor.execute(cmd_confirmed, values)
             elif txin.scriptSig[0] == chr(script.OP_VAULT_OVERRIDE):
                 fromaddress = str(
                     utils.scriptSig_to_vault_address(txin.scriptSig))
                 values = (fromaddress, )
                 cursor.execute(cmd_override, values)
     connection.commit()
     connection.close()
     self.logger.debug('Removed confirmed transactions from VaultDB')
コード例 #3
0
ファイル: chaindb.py プロジェクト: justdvnsh/Nell-MDCoin
    def listallreceivedbyvault(self, vault_address):
        scriptPubKey = utils.vault_address_to_pay_to_vault_script( \
            vault_address)
        txouts = {}
        end_height = self.getheight()

        for height in range(end_height + 1):
            data = self.db.Get('height:' + str(height))
            heightidx = HeightIdx()
            heightidx.deserialize(data)
            blkhash = heightidx.blocks[0]
            block = self.getblock(blkhash)

            for tx in block.vtx:
                # if its a coinbase transaction, skip
                if tx.is_coinbase():
                    continue
                is_tx_vault_withdraw = False
                for txin in tx.vin:
                    if txin.scriptSig[0] == chr(OP_VAULT_WITHDRAW):
                        is_tx_vault_withdraw = True
                    if not ord(txin.scriptSig[0]) in [
                            OP_VAULT_CONFIRM, OP_VAULT_FAST_WITHDRAW
                    ]:
                        continue
                    # remove if a transaction is spent
                    from_vault_address = utils.scriptSig_to_vault_address(
                        txin.scriptSig)
                    if vault_address == from_vault_address:
                        self.logger.debug("Vault spent %064x" %
                                          txin.prevout.hash)
                        del txouts[txin.prevout.hash]

                if is_tx_vault_withdraw:
                    continue

                for n, txout in enumerate(tx.vout):
                    # add if a transaction is received
                    if scriptPubKey == txout.scriptPubKey:
                        tx.calc_sha256()
                        self.logger.debug("Vault input txhash: %d %d %064x %s" \
                                       % (height, n, tx.sha256, tx))
                        txouts[tx.sha256] = {'txhash': tx.sha256, \
                                             'n': n, \
                                             'value': txout.nValue, \
                                             'scriptPubKey': txout.scriptPubKey}
        return txouts
コード例 #4
0
ファイル: chaindb.py プロジェクト: obulpathi/reversecoin
    def listallreceivedbyvault(self, vault_address):
        scriptPubKey = utils.vault_address_to_pay_to_vault_script( \
            vault_address)
        txouts = {}
        end_height = self.getheight()

        for height in xrange(end_height+1):
            data = self.db.Get('height:' + str(height))
            heightidx = HeightIdx()
            heightidx.deserialize(data)
            blkhash = heightidx.blocks[0]
            block = self.getblock(blkhash)

            for tx in block.vtx:
                # if its a coinbase transaction, skip
                if tx.is_coinbase():
                    continue
                is_tx_vault_withdraw = False
                for txin in tx.vin:
                    if txin.scriptSig[0] == chr(OP_VAULT_WITHDRAW):
                        is_tx_vault_withdraw = True
                    if not ord(txin.scriptSig[0]) in [OP_VAULT_CONFIRM,
                        OP_VAULT_FAST_WITHDRAW]:
                        continue
                    # remove if a transaction is spent
                    from_vault_address = utils.scriptSig_to_vault_address(txin.scriptSig)
                    if vault_address == from_vault_address:
                        self.logger.debug("Vault spent %064x" % txin.prevout.hash)
                        del txouts[txin.prevout.hash]

                if is_tx_vault_withdraw:
                    continue

                for n, txout in enumerate(tx.vout):
                    # add if a transaction is received
                    if scriptPubKey == txout.scriptPubKey:
                        tx.calc_sha256()
                        self.logger.debug("Vault input txhash: %d %d %064x %s" \
                                       % (height, n, tx.sha256, tx))
                        txouts[tx.sha256] = {'txhash': tx.sha256, \
                                             'n': n, \
                                             'value': txout.nValue, \
                                             'scriptPubKey': txout.scriptPubKey}
        return txouts
コード例 #5
0
 def getpendingtransactions(self):
     pending_txs = {}
     txhashs = self.listpendingtxhashes()
     for i, txhash in enumerate(txhashs):
         pending_tx = {}
         tx = self.gettx(txhash)
         inputs = []
         for txin in tx.vin:
             inputs.append(utils.scriptSig_to_vault_address(txin.scriptSig))
         pending_tx['inputs'] = inputs
         outputs = []
         for n, txout in enumerate(tx.vout):
             output = {
                 'toaddress': utils.pending_tx_output_script_to_address(
                                 txout.scriptPubKey),
                 'amount': txout.nValue}
             outputs.append(output)
         pending_tx['outputs'] = outputs
         pending_txs[str(n)] = pending_tx
     return pending_txs