比特币完整节点,在某些区块中显示怪异的交易

问题描述 投票:3回答:1

我有一个程序,它将所有交易数据加起来并在区块中输出总比特币。它在大多数情况下运行得很完美,但是偶尔我会得到一个奇怪的交易,使我的输出中断。什么会导致这种情况发生?

每次在我的节点上运行它时,我都会得到相同的输出,但是其他块浏览器都将其显示为正常。我的节点在Ubuntu 18.04上运行Bitcoin Core Daemon版本v0.18.0.0-472733a24a9364e4c6233ccd04166a26a68cc65]

该块的输出,这个特定的块是605540。

910 0.128272 2482.385553911 0.005425 2482.390978912 0.160804 2482.551782913 0.012542 2482.564324914 -8642921084.551126 -8642918601.986803

    from bitcoinrpc.authproxy import AuthServiceProxy, JSONRPCException  
    import time

    with open(r"/home/pi/python_scripts/blockbot/keys.txt", 'r') as 
    keys_File:  
        keys = [line.rstrip('\n') for line in keys_File]

    rpc_user = keys[4]
    rpc_password = keys[5]
    block_Value = 0
    line = 0

    rpc_connection = AuthServiceProxy("http://%s:%[email protected]:8332"% 
   (rpc_user, rpc_password))

    print('Input Block for Transaction data: ')
    block_Count = int(input())
    block_Hash = rpc_connection.getblockhash(block_Count)
    latest_Block = rpc_connection.getblock(block_Hash)
    num_Trans = latest_Block['nTx']
    transactions = latest_Block['tx']
    block_Value = 0

    trans_F = open("Transactions.txt","w+")

    for txid in transactions:
        tx_Value = 0
        raw_Tx = rpc_connection.getrawtransaction(txid)
        decoded_Tx = rpc_connection.decoderawtransaction(raw_Tx)
        for output in decoded_Tx['vout']:
            tx_Value = tx_Value + output['value']
        line = line + 1
        block_Value = block_Value + tx_Value
        print(line, tx_Value, block_Value)
        trans_F.write('%d %f %f\r\n' %(line, tx_Value, block_Value))
    trans_F.close
transactions blockchain bitcoin
1个回答
0
投票

您正在尝试解析隔离交易,而没有告诉bitcoind这是隔离交易。

您在这里有两个选择:

[使用bitcoin-cli getrawtransaction 90736a2028fe2d3388820e34cd583fe9152e5932cc42522297b9b0a57f8c2fd5 1获取并解析事务-最后的1告诉比特币返回JSON响应而不是十六进制。

OR

明确告诉decoderawtransaction使用]将其视为隔离交易。>

bitcoin-cli decoderawtransaction 02000000000101105c15e86a01f4e449410c4c75fc3640827abbb3387acd87d87a5a5af4e9846f0100000017160014afc0c9d7a93b6736719f967536700d04472a9b29feffffff0212deac000000000017a914f0ba10f2a6f82f2c3b55b37b29f8dfd45adc34f287006a18000000000017a9148e5d27e3ae870f7611809635bfc1ccfed62c0c108702473044022025221370b4a334c26a267bc5ae4301c06d9e41023faafbe4902b3f7f3a5b4a590220327bc1635eefd86a57e51884277351faf8cfed4fb6a89e754dc493649e1c676b0121029d26a8dc5e3a27c571684012fbaf8c0cedad5ef4fefd6c737c2c1988d97cdadb623d0900 true

[最后的true告诉bitcoind将原始tx视为隔离交易。

您围绕bitcoind的RPC的包装器/库应该有某种方式来设置这些其他选项。

© www.soinside.com 2019 - 2024. All rights reserved.