bitcoin rpc api: gettransaction

2017-11-14  本文已影响67人  已不再更新_转移到qiita
def calc_coinbase_tx_amount(node, blockhash):
  block = node.getblock(blockhash)
  coinbase_tx = block['tx'][0]
  tx_detail = node.gettransaction(coinbase_tx) # 只能获取自己钱包的数据
  amount = tx_detail['details'][0]['amount']

  return amount


def calc_coinbase_tx_amount(node, blockhash):
  block = node.getblock(blockhash)
  coinbase_tx = block['tx'][0]
  raw_tx = node.getrawtransaction(coinbase_tx) # 能获取所有的数据
  result = node.decoderawtransaction(raw_tx)
  vouts = result['vout']
  amount = 0

  for vout in vouts:
    amount += vout['value']

  return amount

上一篇 下一篇

猜你喜欢

热点阅读