Trait bitcoin_pool_identification::PoolIdentification [−][src]
pub trait PoolIdentification {
fn identify_pool(&self) -> Option<Pool>;
fn identify_coinbase_tag(&self) -> Option<Pool>;
fn identify_coinbase_output_address(&self) -> Option<Pool>;
fn coinbase_script_as_utf8(&self) -> String;
fn coinbase_output_addresses(&self) -> Vec<Address>;
}Trait for Bitcoin mining pool identification based on metadata like coinbase tags or coinbase output addresses.
Required methods
fn identify_pool(&self) -> Option<Pool>[src]
Checks both the coinbase output address and coinbase tags against known values to identify a mining pool. The coinbase output address is checked first, as it is harder to fake than the coinbase tag. Coinbase tags are not authenticated and can easily be faked by a malicious party.
If both methods can’t identify the pool, then None is returned.
fn identify_coinbase_tag(&self) -> Option<Pool>[src]
Checks coinbase tags from against the UTF-8 encoded coinbase script_sig to identify mining pools.
These coinbase tags are not authenticated and can easily be faked by a malicious party.
The coinbase tag for the ViaBTC pool is, for example, /ViaBTC/. An
UTF-8 encoded coinbase looks, for example, like (line breaks removed):
l</ViaBTC/Mined by leehoo4444/,��mmA�G��CT�)�טb^��̵�g��,Eܩ(
fn identify_coinbase_output_address(&self) -> Option<Pool>[src]
Checks the coinbase output address against a list of known pool
addresses and returns a found pool. If no output address matches, then
None is returned.
fn coinbase_script_as_utf8(&self) -> String[src]
Returns the coinbase script encoded as lossy UTF-8 String (any invalid UTF-8 sequences with U+FFFD REPLACEMENT CHARACTER, which looks like this: �). Line-breaks are removed as well.
fn coinbase_output_addresses(&self) -> Vec<Address>[src]
Returns the coinbase output addresses for all output types that can be represented as addresses. This excludes, for example, P2PK or OP_RETURN outputs. Addresses are ordered by value (descending).
Implementations on Foreign Types
impl PoolIdentification for Transaction[src]
impl PoolIdentification for Transaction[src]fn identify_pool(&self) -> Option<Pool>[src]
Checks both the coinbase output address and coinbase tags against known values to identify a mining pool. The coinbase output address is checked first, as it is harder to fake than the coinbase tag. Coinbase tags are not authenticated and can easily be faked by a malicious party.
If both methods can’t identify the pool, then None is returned.
Panics
The caller MUST make sure the transaction is a coinbase transaction This can be done, for example, with Transaction::is_coin_base(). This is asserted and will panic.
Examples
use bitcoin::Transaction; use bitcoin_pool_identification::{IdentificationMethod, Pool, PoolIdentification}; // Bitcoin mainnet coinbase transaction of block 670828 mined by ViaBTC: // 71093a08fe47c9d0c08921049f1a317541d78470376d7029c5e27fda2205361b let rawtx = hex::decode("010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff5f036c3c0a1c2f5669614254432f4d696e6564206279206c6565686f6f343434342f2cfabe6d6d41f647100ea398435411f0297fd9d798625e1b82c82451f7c6ccb59c0c67ec07100000000000000010d02cfe0845dca9281bb0ee077c090000ffffffff04bdb8892b000000001976a914536ffa992491508dca0354e52f32a3a7a679a53a88ac00000000000000002b6a2952534b424c4f434b3a2f21f07f3619ef6521a90de396c2617f2edc5bda4fd04aba89632f2c002f79bc0000000000000000266a24b9e11b6d2dd1c7233a019c512c5f1e105e185a6ea0a47824b5ae390cc7cec5c01714588b0000000000000000266a24aa21a9ed23418324183dba97076f21aadc97aeeb1782c6859faf8e141c601e5c856c55440120000000000000000000000000000000000000000000000000000000000000000000000000").unwrap(); let tx: Transaction = bitcoin::consensus::deserialize(&rawtx).unwrap(); let pool = tx.identify_pool(); assert_eq!( pool, Some(Pool { name: "ViaBTC".to_string(), link: Some("https://viabtc.com/".to_string()), identification_method: IdentificationMethod::Tag, }) );
fn identify_coinbase_tag(&self) -> Option<Pool>[src]
Checks coinbase tags from against the UTF-8 encoded coinbase script_sig to identify mining pools.
These coinbase tags are not authenticated and can easily be faked by a malicious party.
The coinbase tag for the ViaBTC pool is, for example, /ViaBTC/. An
UTF-8 encoded coinbase looks, for example, like (line breaks removed):
l</ViaBTC/Mined by leehoo4444/,��mmA�G��CT�)�טb^��̵�g��,Eܩ(
Panics
The caller MUST make sure the transaction is a coinbase transaction This can be done, for example, with Transaction::is_coin_base(). This is asserted and will panic.
Examples
use bitcoin::Transaction; use bitcoin_pool_identification::{Pool, PoolIdentification}; // Bitcoin mainnet coinbase transaction of block 670828 mined by ViaBTC: // 71093a08fe47c9d0c08921049f1a317541d78470376d7029c5e27fda2205361b let rawtx = hex::decode("010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff5f036c3c0a1c2f5669614254432f4d696e6564206279206c6565686f6f343434342f2cfabe6d6d41f647100ea398435411f0297fd9d798625e1b82c82451f7c6ccb59c0c67ec07100000000000000010d02cfe0845dca9281bb0ee077c090000ffffffff04bdb8892b000000001976a914536ffa992491508dca0354e52f32a3a7a679a53a88ac00000000000000002b6a2952534b424c4f434b3a2f21f07f3619ef6521a90de396c2617f2edc5bda4fd04aba89632f2c002f79bc0000000000000000266a24b9e11b6d2dd1c7233a019c512c5f1e105e185a6ea0a47824b5ae390cc7cec5c01714588b0000000000000000266a24aa21a9ed23418324183dba97076f21aadc97aeeb1782c6859faf8e141c601e5c856c55440120000000000000000000000000000000000000000000000000000000000000000000000000").unwrap(); let tx: Transaction = bitcoin::consensus::deserialize(&rawtx).unwrap(); let pool = tx.identify_coinbase_output_address(); assert_eq!(pool, None);
fn identify_coinbase_output_address(&self) -> Option<Pool>[src]
Checks the coinbase output address against a list of known pool
addresses and returns a found pool. If no output address matches, then
None is returned.
Panics
The caller MUST make sure the transaction is a coinbase transaction This can be done, for example, with Transaction::is_coin_base().
Examples
use bitcoin::Transaction; use bitcoin_pool_identification::{IdentificationMethod, Pool, PoolIdentification}; // Bitcoin mainnet coinbase transaction of block 670828 mined by ViaBTC: // 71093a08fe47c9d0c08921049f1a317541d78470376d7029c5e27fda2205361b let rawtx = hex::decode("010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff5f036c3c0a1c2f5669614254432f4d696e6564206279206c6565686f6f343434342f2cfabe6d6d41f647100ea398435411f0297fd9d798625e1b82c82451f7c6ccb59c0c67ec07100000000000000010d02cfe0845dca9281bb0ee077c090000ffffffff04bdb8892b000000001976a914536ffa992491508dca0354e52f32a3a7a679a53a88ac00000000000000002b6a2952534b424c4f434b3a2f21f07f3619ef6521a90de396c2617f2edc5bda4fd04aba89632f2c002f79bc0000000000000000266a24b9e11b6d2dd1c7233a019c512c5f1e105e185a6ea0a47824b5ae390cc7cec5c01714588b0000000000000000266a24aa21a9ed23418324183dba97076f21aadc97aeeb1782c6859faf8e141c601e5c856c55440120000000000000000000000000000000000000000000000000000000000000000000000000").unwrap(); let tx: Transaction = bitcoin::consensus::deserialize(&rawtx).unwrap(); let pool = tx.identify_coinbase_tag(); assert_eq!( pool, Some(Pool { name: "ViaBTC".to_string(), link: Some("https://viabtc.com/".to_string()), identification_method: IdentificationMethod::Tag, }) );
fn coinbase_script_as_utf8(&self) -> String[src]
Returns the coinbase script encoded as lossy UTF-8 String (any invalid UTF-8 sequences with U+FFFD REPLACEMENT CHARACTER, which looks like this: �). Line-breaks are removed as well.
Panics
The caller MUST make sure the transaction is a coinbase transaction This can be done, for example, with Transaction::is_coin_base(). This is asserted and will panic.
fn coinbase_output_addresses(&self) -> Vec<Address>[src]
Returns the coinbase output addresses for all output types that can be represented as addresses. This excludes, for example, P2PK or OP_RETURN outputs. Addresses are ordered by value (descending).
Panics
The caller MUST make sure the transaction is a coinbase transaction This can be done, for example, with Transaction::is_coin_base().
impl PoolIdentification for Block[src]
impl PoolIdentification for Block[src]fn identify_pool(&self) -> Option<Pool>[src]
Checks both the coinbase output address and coinbase tags against known values to identify a mining pool. The coinbase output address is checked first, as it is harder to fake than the coinbase tag. Coinbase tags are not authenticated and can easily be faked by a malicious party.
If both methods can’t identify the pool, then None is returned.
Examples
use bitcoin::Block; use bitcoin_pool_identification::{IdentificationMethod, Pool, PoolIdentification}; // Bitcoin mainnet block at height 670718 mined by BTC.com: // 0000000000000000000566438fa7dc31ec2b26e8cfd0a704822238ee8a40922c // Identified by both its coinbase tag and output address. let raw_block = hex::decode("00e0ff3f0c85cd07e4c8b446f64d9179ddd7627d4858f9bd07df08000000000000000000b263e9b0077a5f8ea941f8498a0df7b88d6d2077e9be4ef9d5b5f5b8e77906c9c56b2a60b9210d173aa2253a0102000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4c03fe3b0a04c16b2a6065752f4254432e636f6d2ffabe6d6d5793cfdad17c5272fca204a71fb04e88a5955239c018b8e5186ce838e789f7d4020000008e9b20aa04f5d252bb00000000000000ffffffff0340be4025000000001976a91474e878616bd5e5236ecb22667627eeecbff54b9f88ac00000000000000002b6a2952534b424c4f434b3a2dcf611172e7f2605b32915ca21102a7b0139400413995a4df47ea0b002ee6900000000000000000266a24b9e11b6d3974264c2913656ea4ee829e6327179645a5e8b4dc463914680b2003569a36e200000000").unwrap(); let block: Block = bitcoin::consensus::deserialize(&raw_block).unwrap(); let expected_id_addr = Some(Pool { name: "BTC.com".to_string(), link: Some("https://pool.btc.com".to_string()), identification_method: IdentificationMethod::Address, }); let expected_id_tag = Some(Pool { name: "BTC.com".to_string(), link: Some("https://pool.btc.com".to_string()), identification_method: IdentificationMethod::Tag, }); assert_eq!(block.identify_pool(), expected_id_addr); assert_eq!(block.identify_coinbase_output_address(), expected_id_addr); assert_eq!(block.identify_coinbase_tag(), expected_id_tag);
fn identify_coinbase_tag(&self) -> Option<Pool>[src]
Checks coinbase tags from against the UTF-8 encoded coinbase script_sig to identify mining pools.
These coinbase tags are not authenticated and can easily be faked by a malicious party.
The coinbase tag for the ViaBTC pool is, for example, /ViaBTC/. An
UTF-8 encoded coinbase looks, for example, like (line breaks removed):
l</ViaBTC/Mined by leehoo4444/,��mmA�G��CT�)�טb^��̵�g��,Eܩ(
fn identify_coinbase_output_address(&self) -> Option<Pool>[src]
Checks the coinbase output addresses against a list of known pool
addresses and returns a found pool. If no output address matches, then
None is returned.
fn coinbase_script_as_utf8(&self) -> String[src]
Returns the coinbase script encoded as lossy UTF-8 String (any invalid UTF-8 sequences with U+FFFD REPLACEMENT CHARACTER, which looks like this: �). Line-breaks are removed as well.
fn coinbase_output_addresses(&self) -> Vec<Address>[src]
Returns the coinbase output addresses for all output types that can be represented as addresses. This excludes, for example, P2PK or OP_RETURN outputs. Addresses are ordered by value (descending).