-
Notifications
You must be signed in to change notification settings - Fork 48
Useful Utility functions
Jörn Franke edited this page Feb 16, 2018
·
11 revisions
The hadoopcryptoledger library has some useful utility methods that are relevant when working with cryptoledgers.
- Bitcoin
- getTransactionHash to calculate the hash of a transaction (txid). This is useful to link addresses from transaction inputs to addresses for transaction output.
- getTransactionHashSegwit to calculate the hash of a transaction including Segwit information (wtxid). This cannot be used to link transactions.
- reverseByteArray to reverse the order of a given byte array. For example, if you want to search for a transaction hash provided by getTransactionHash in a public blockchain explorer (e.g. http://blockchain.info) then you need to reverse it
- getPaymentDestination to get the payment destination described in the output script of a transaction
- Namecoin
- getNameOperation - to get the type of Namecoin name operation (e.g. new, firstupdate or update) in a transaction. Note that not all Namecoin transactions contain name operations.
- extractNamecoinField - in case the transaction contains a Namecoin name operation of type firstupdate or update then this method enables you to pull further information, such as domain name or identity (e.g. d/example) as well as the associated configuration (e.g. ip addresses, sub domains etc.).
- Ethereum
- getTransactionHash - to get the transaction hash of an EthereumTransaction. You can search for this hash in Ethereum block explorers, such as https://etherscan.io/
- getSendAddress - to get the sendaddress (from) for an EthereumTransaction. You need to specify the chainId (1 Frontier, 2 Morden, 3 Ropsten or any of the Altcoins) for EIP-155 transactions) You can search for this address in Ethereum block explorers, such as https://etherscan.io/
- calculateChainId - to calculate the chainid of an EthereumTransaction