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

Add blockchain.outpoint.subscribe RPC #454

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

romanz
Copy link
Owner

@romanz romanz commented Aug 13, 2021

Following #444 (see the specification here).

Blocked until Electrum client is released with support of 1.5 protocol.

src/electrum.rs Outdated Show resolved Hide resolved
@Pantamis
Copy link
Contributor

Code looks very good to me (much better than mine in #446 obviously) and I successfully use it with janoside/btc-rpc-explorer#356

This "test" doesn't use the notification part however !

@romanz
Copy link
Owner Author

romanz commented Aug 15, 2021

Thanks for testing!

@Pantamis
Copy link
Contributor

Pantamis commented Sep 9, 2021

Would it be possible to rebase this PR with current p2p branch ?

I would like to try #468 with my PR in the bitcoin explorer janoside/btc-rpc-explorer#356
Thanks :)

@romanz
Copy link
Owner Author

romanz commented Sep 9, 2021

Thanks for the heads-up!
Rebased aec27af.

@romanz romanz force-pushed the p2p-outpoint-rpc branch 2 times, most recently from eae0905 to 7b728d4 Compare September 16, 2021 07:03
@romanz romanz force-pushed the p2p-outpoint-rpc branch 3 times, most recently from 78e62ab to 30f7401 Compare September 18, 2021 06:46
@romanz romanz deleted the branch master September 18, 2021 06:47
@romanz romanz closed this Sep 18, 2021
@Pantamis
Copy link
Contributor

I suppose you will reopen this PR once Electrum 1.5 spec are merged ?

Great work on the p2p branch !

@Kixunil
Copy link
Contributor

Kixunil commented Sep 18, 2021

I think this was the same GitHub confusion as in #455

@romanz
Copy link
Owner Author

romanz commented Sep 18, 2021

I think this was the same GitHub confusion as in #455

Yes, reopening now :)

@romanz romanz reopened this Sep 18, 2021
@romanz romanz changed the base branch from p2p to master September 18, 2021 10:53
@romanz romanz force-pushed the p2p-outpoint-rpc branch 2 times, most recently from cd42567 to f9239e0 Compare September 23, 2021 19:24
@romanz romanz force-pushed the p2p-outpoint-rpc branch 2 times, most recently from 7db0b8c to 049df10 Compare October 15, 2021 14:16
@Pantamis
Copy link
Contributor

Pantamis commented Nov 1, 2022

Hi !

Just for information:

This PR still work as expected when cherry picked from master. This is mandatory since #783

The only thing that must be changed to make it compiling is BlockHash::default() to BlockHash::all_zeros() in OutpointStatus struct.

I re tACK this with janoside/btc-rpc-explorer/pull/356

for tx in block.txdata {
let txid = tx.txid();
let output_len = u32::try_from(tx.output.len()).unwrap();
if self.outpoint.txid == txid && self.outpoint.vout < output_len {
Copy link
Contributor

Choose a reason for hiding this comment

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

self.outpoint.vout < output_len

maybe i am missing something, but for what reason is this check here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Clearly this avoids out-of-bounds access.

Copy link
Contributor

@antonilol antonilol Nov 21, 2022

Choose a reason for hiding this comment

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

hmm i tried to find where self.outpoint.vout is used to index tx.output, but could not find it, self.outpoint.vout is not used after this here, which made sense after i thought of this: this code checks for output funding, it doesnt matter which output index is subscribed to, as long as it is in the transaction (self.outpoint.vout < output_len)

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, interesting, this is not even required for double-spend handling since a double-spent transaction would have a different txid.

Maybe there would be a value in having a sanity check with a warning? It'd be best to also check scripts then.

Copy link
Owner Author

Choose a reason for hiding this comment

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

It's indeed a sanity check - in case the user tries to subscribe to a non-existing outpoint (by specifying a vout larger than the actual # of txid outputs).

Copy link
Contributor

Choose a reason for hiding this comment

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

What I'm trying to say is that it now silently ignores the transaction instead of printing a warning and a warning would be helpful because doing this is a bug and without a message it could be hard to analyze.

@romanz romanz force-pushed the p2p-outpoint-rpc branch 2 times, most recently from c77b4d6 to e11fff1 Compare June 16, 2023 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.5 enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants