Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include old_owner for transfers in StreamEvent #9

Merged
merged 3 commits into from
Jun 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/index/updater/inscription_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ mod stream {

// transfer fields
old_location: Option<SatPoint>,
old_owner: Option<Address>,
}

impl StreamEvent {
Expand Down Expand Up @@ -622,6 +623,7 @@ mod stream {
brc20: None,
domain: None,
old_location: None,
old_owner: None,
sat_details: None,
}
}
Expand Down Expand Up @@ -682,6 +684,23 @@ mod stream {
.unwrap_or_else(|_| panic!("Inscription should exist: {}", self.inscription_id))
{
self.enrich_content(inscription);
self.old_owner = index
.get_transaction(old_satpoint.outpoint.txid)
.unwrap_or(None)
.and_then(|tx| {
tx.output
.get(old_satpoint.outpoint.vout as usize)
.and_then(|txout| {
Address::from_script(&txout.script_pubkey, StreamEvent::get_network())
.map_err(|e| {
log::error!(
"StreamEvent::with_transfer could not parse old_owner address: {}",
e
);
})
.ok()
})
});
};
self
}
Expand Down