Skip to content

Commit

Permalink
feat: differentiate spent in fees and burnt
Browse files Browse the repository at this point in the history
  • Loading branch information
Ludo Galabru committed Nov 1, 2023
1 parent e880cf9 commit bebe429
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 18 deletions.
84 changes: 74 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion components/ordhook-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ redis = "0.21.5"
serde-redis = "0.12.0"
hex = "0.4.3"
rand = "0.8.5"
chainhook-sdk = { version = "=0.10.1", default-features = false, features = ["zeromq", "log"] }
chainhook-sdk = { version = "=0.10.3", features = ["zeromq"] }
# chainhook-sdk = { version = "=0.10.1", path = "../../../chainhook/components/chainhook-sdk", default-features = false, features = ["zeromq", "log"] }
hiro-system-kit = "0.3.1"
reqwest = { version = "0.11", default-features = false, features = ["stream", "json", "rustls-tls"] }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use chainhook_sdk::{
bitcoincore_rpc_json::bitcoin::{hashes::hex::FromHex, Address, Network, Script},
types::{
BitcoinBlockData, BitcoinNetwork, BitcoinTransactionData, BlockIdentifier,
OrdinalInscriptionTransferData, OrdinalOperation, TransactionIdentifier,
OrdinalInscriptionTransferData, OrdinalOperation, TransactionIdentifier, OrdinalInscriptionTransferDestination,
},
utils::Context,
};
Expand Down Expand Up @@ -114,7 +114,7 @@ pub fn augment_transaction_with_ordinals_transfers_data(
let (
outpoint_post_transfer,
offset_post_transfer,
updated_address,
destination,
post_transfer_output_value,
) = match post_transfer_data {
SatPosition::Output((output_index, offset)) => {
Expand All @@ -124,7 +124,7 @@ pub fn augment_transaction_with_ordinals_transfers_data(
tx.metadata.outputs[output_index].get_script_pubkey_hex();
let updated_address = match Script::from_hex(&script_pub_key_hex) {
Ok(script) => match Address::from_script(&script, network.clone()) {
Ok(address) => Some(address.to_string()),
Ok(address) => OrdinalInscriptionTransferDestination::Transferred(address.to_string()),
Err(e) => {
ctx.try_log(|logger| {
warn!(
Expand All @@ -133,7 +133,7 @@ pub fn augment_transaction_with_ordinals_transfers_data(
e.to_string()
)
});
None
OrdinalInscriptionTransferDestination::Burnt(script.to_string())
}
},
Err(e) => {
Expand All @@ -144,7 +144,7 @@ pub fn augment_transaction_with_ordinals_transfers_data(
e.to_string()
)
});
None
OrdinalInscriptionTransferDestination::Burnt(script_pub_key_hex.to_string())
}
};

Expand Down Expand Up @@ -181,7 +181,7 @@ pub fn augment_transaction_with_ordinals_transfers_data(
offset
)
});
(outpoint, total_offset, None, None)
(outpoint, total_offset, OrdinalInscriptionTransferDestination::SpentInFees, None)
}
};

Expand All @@ -190,7 +190,7 @@ pub fn augment_transaction_with_ordinals_transfers_data(

let transfer_data = OrdinalInscriptionTransferData {
inscription_id: watched_satpoint.inscription_id.clone(),
updated_address,
destination,
tx_index,
satpoint_pre_transfer,
satpoint_post_transfer,
Expand Down

0 comments on commit bebe429

Please sign in to comment.