比特币全节点,部分区块出现异常交易

Bitcoin full node, showing weird transaction in some blocks

我有一个程序可以将所有交易数据相加并输出区块中的比特币总数。它 运行 大多数时候都是完美的,但每隔一段时间我就会收到一个奇怪的交易,它会影响我的输出。什么会导致这种情况发生?

每次我 运行 它针对我的节点我得到相同的输出,但其他区块浏览器显示它正常。我的节点是 运行ning 比特币核心守护程序版本 v0.18.0.0-472733a24a9364e4c6233ccd04166a26a68cc65 Ubuntu 18.04

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

910 0.128272 2482.385553
911 0.005425 2482.390978
912 0.160804 2482.551782
913 0.012542 2482.564324
914 -8642921084.551126 -8642918601.986803 <--------违规交易
915 0.027132 -8642918601.959671
916 0.014252 -8642918601.945419
917 0.013913 -8642918601.931505
918 2.845980 -8642918599.085526
919 0.404175 -8642918598.681351

    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:%s@127.0.0.1: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

你试图在不告诉 bitcoind 这是一个隔离见证交易的情况下解析一个隔离见证交易。

这里有两个选择:

使用 bitcoin-cli getrawtransaction 90736a2028fe2d3388820e34cd583fe9152e5932cc42522297b9b0a57f8c2fd5 1 获取并解析交易 - 最后的 1 告诉 bitcoind return JSON 响应而不是十六进制。

使用

明确告诉 decoderawtransaction 将其视为 segwit 交易
bitcoin-cli decoderawtransaction 02000000000101105c15e86a01f4e449410c4c75fc3640827abbb3387acd87d87a5a5af4e9846f0100000017160014afc0c9d7a93b6736719f967536700d04472a9b29feffffff0212deac000000000017a914f0ba10f2a6f82f2c3b55b37b29f8dfd45adc34f287006a18000000000017a9148e5d27e3ae870f7611809635bfc1ccfed62c0c108702473044022025221370b4a334c26a267bc5ae4301c06d9e41023faafbe4902b3f7f3a5b4a590220327bc1635eefd86a57e51884277351faf8cfed4fb6a89e754dc493649e1c676b0121029d26a8dc5e3a27c571684012fbaf8c0cedad5ef4fefd6c737c2c1988d97cdadb623d0900 true

末尾的 true 告诉 bitcoind 将原始 tx 视为 segwit 交易。

你的 wrapper/library 围绕 bitcoind 的 RPC 应该有一些方法来设置这些额外的选项。