Ejemplo n.º 1
0
    def check_tx(self, txid):
        tx_raw = rpc_conn().getrawtransaction(txid)
        tx_decoded = rpc_conn().decoderawtransaction(tx_raw)

        for vout in tx_decoded['vout']:
            node_payee = vout['scriptPubKey']['addresses'][0]
            if node_payee in self.mn_wallets:
                found_node = list(rpc_conn().masternodelist(
                    'payee', node_payee).keys())[0]
                pment_dict = {"vin": found_node, "value": vout['value']}
                return pment_dict
            else:
                continue
Ejemplo n.º 2
0
def process_latest_block():
    # Add storage and check for "last block checked" to make sure we don't ever missing blocks
    block_hash = rpc_conn().getbestblockhash()
    block_info = rpc_conn().getblock(block_hash)
    txes = block_info['tx']

    mn_payments = list()
    for tx in txes:
        if check_tx(tx) != None:
            mn_payments.append(check_tx(tx))
        else:
            continue

    pprint(mn_payments)
    return mn_payments
Ejemplo n.º 3
0
    def get_mn_list():
        try:
            mn_list = rpc_conn().masternodelist()
        except Exception as e:
            print(e)
            mn_list = []

        return mn_list
Ejemplo n.º 4
0
def check_address(wallet_address):
    # print(wallet_address)
    print(wallet_address)
    tx_list = rpc_conn().getaddresstxids({"addresses": [wallet_address]})
    coinbase_tx_count = 0
    payments_dict = dict()
    for tx in tx_list:
        coinbase_tx, tx_info = check_tx(tx)
        if coinbase_tx is True:
            # pprint(tx_info)
            payments_dict[tx] = tx_info
            # This is where we'll pull out the datetime and the payment amount
            coinbase_tx_count += 1
        else:
            continue

    # return coinbase_tx_count, payments_dict
    return payments_dict
Ejemplo n.º 5
0
def process_proregtx(protxlist):
    payment_wallets = dict()
    for node in protxlist:
        node_info = rpc_conn().protx('info', node)
        if node_info['state']['PoSePenalty'] == 0:
            vin = str(node_info['collateralHash']) + '-' + str(
                node_info['collateralIndex'])  # define vin
            # print(vin)
            payment_wallets[vin] = {
                'payoutAddress': node_info['state']['payoutAddress'],
                'ownerAddress': node_info['state']['ownerAddress'],
                'operatorReward': node_info['operatorReward']
            }
        else:
            # print("Skipping because it's not a valid node")
            pass

    return payment_wallets
Ejemplo n.º 6
0
 def refresh_mn_info(self):
     print("Refreshing MN info")
     self.mn_list = rpc_conn().masternodelist()
     self.mn_wallets = self.get_mn_wallets()
     print("MN info refreshed")
Ejemplo n.º 7
0
 def process_block(self, block_hash):
     block_info = rpc_conn().getblock(block_hash)
     # pprint(block_info)
     cb_tx = block_info['tx'][0]
     paid_mn = self.check_tx(cb_tx)
     return paid_mn
Ejemplo n.º 8
0
        for vout in tx_decoded['vout']:
            node_payee = vout['scriptPubKey']['addresses'][0]
            if node_payee in self.mn_wallets:
                found_node = list(rpc_conn().masternodelist(
                    'payee', node_payee).keys())[0]
                pment_dict = {"vin": found_node, "value": vout['value']}
                return pment_dict
            else:
                continue

    def process_block(self, block_hash):
        block_info = rpc_conn().getblock(block_hash)
        # pprint(block_info)
        cb_tx = block_info['tx'][0]
        paid_mn = self.check_tx(cb_tx)
        return paid_mn

    def refresh_mn_info(self):
        print("Refreshing MN info")
        self.mn_list = rpc_conn().masternodelist()
        self.mn_wallets = self.get_mn_wallets()
        print("MN info refreshed")


if __name__ == '__main__':
    # test_txid = '3fcc6bdaf487c6ead6b8ae17f42d6ed2dd76d728df991f98d984639d07837f3d'
    bp = BlockPayment()
    latest_block = rpc_conn().getbestblockhash()
    paid_mn = bp.process_block(latest_block)
    print(paid_mn)
Ejemplo n.º 9
0
def get_tx_timing(block_hash):
    block_info = rpc_conn().getblock(block_hash)
    return block_info['time']