Skip to content

Expose Block Height to TxHandle#34

Merged
arminsabouri merged 1 commit intopayjoin:masterfrom
bc1cindy:blockheight
Apr 3, 2026
Merged

Expose Block Height to TxHandle#34
arminsabouri merged 1 commit intopayjoin:masterfrom
bc1cindy:blockheight

Conversation

@bc1cindy
Copy link
Copy Markdown
Contributor

@bc1cindy bc1cindy commented Mar 30, 2026

adds block_height to TxHandle via TxIoIndex, allowing heuristics to query the confirmed block height of a transaction.

block_of_tx now returns the absolute chain height instead of a range-relative index, by storing range.start as an offset in DenseStorage at index time

part of #5

@bc1cindy
Copy link
Copy Markdown
Contributor Author

part of #26

@bc1cindy
Copy link
Copy Markdown
Contributor Author

initially I exposed height_offset as an explicit parameter, but made sense to move to block_of_tx to have less surface area for callers to get wrong

@arminsabouri arminsabouri self-requested a review March 31, 2026 12:41
tx.input[vin].script_sig.to_bytes()
}

fn block_height(&self, txid: &AnyTxId) -> Option<u64> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this not return None if id type is loose? This question related to #35 . There are way too many foot guns with the way unified storage is written today

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that's the idea, but this is changing with #38 to be more explicit, so I'll leave this PR as a draft until we merge

Comment thread src/crates/primitives/src/dense/mod.rs Outdated
)?;
let storage = DenseStorage {
blocks_dir: parser.blocks_dir().to_path_buf(),
block_height_offset: height_offset,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid assignment

Suggested change
block_height_offset: height_offset,
block_height_offset: range.start

@bc1cindy bc1cindy marked this pull request as draft April 1, 2026 22:39
@bc1cindy bc1cindy marked this pull request as ready for review April 3, 2026 12:28
@bc1cindy bc1cindy requested a review from arminsabouri April 3, 2026 12:28
@arminsabouri arminsabouri merged commit 4ee9d7c into payjoin:master Apr 3, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants