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

NIP-89 Ephemeral Bitcoin Transaction Package Relay #476

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

Conversation

benthecarman
Copy link
Contributor

@benthecarman benthecarman commented Apr 27, 2023

Hacked together the transaction broadcaster real quick: https://github.com/benthecarman/nostr-tx-broadcast

@pablof7z
Copy link
Member

this is awesome, I'll be able to retire https://psbt.io

we'd need a tag like

["network", "signet"]

@benthecarman
Copy link
Contributor Author

good idea! Might be better to use network magic so we can delineate between signets as well.

@melvincarvalho
Copy link

Nice work. JS Implementation:

https://gist.github.com/melvincarvalho/70c29313554ce9d1a22ce9bf954909d9

@arcbtc
Copy link
Contributor

arcbtc commented Apr 27, 2023

Excellent work Ben!
We already have a bunch of things we wont to do with it, very useful indeed.

@melvincarvalho
Copy link

It may be worth pointing out that since every nostr account is a taproot address, this NIP allows the sending of on chain coins from any nostr account to any other, using only existing existing nostr infrastructure and potentially with increased privacy.

It would then be a fairly simple task to look up utxos for a given nostr npub and build, for example, a wallet.

@melvincarvalho
Copy link

this is awesome, I'll be able to retire https://psbt.io

we'd need a tag like

["network", "signet"]

If you add testnet and signet, it would be possible to build a web wallet and demo.

@fiatjaf
Copy link
Member

fiatjaf commented Apr 27, 2023

Can you give it a sub-100 NIP number?

@fiatjaf fiatjaf changed the title NIP-123 Epheremal bitcoin transaction broadcasting NIP-123 Ephemeral bitcoin transaction broadcasting Apr 27, 2023
@ronaldstoner
Copy link

ronaldstoner commented Apr 27, 2023

This is great to see.

EDIT: Removing other NIP draft and will re-submit.

@benthecarman benthecarman changed the title NIP-123 Ephemeral bitcoin transaction broadcasting NIP-89 Ephemeral bitcoin transaction broadcasting Apr 27, 2023
@benthecarman
Copy link
Contributor Author

Can you give it a sub-100 NIP number?

Changed to NIP-89

@benthecarman
Copy link
Contributor Author

Updated to now include network magic so we can identify which network to broadcast to

@benthecarman
Copy link
Contributor Author

@ronaldstoner that looks like you are serving a different usecase, this is purely for broadcasting transactions, not constructing them.

Copy link
Collaborator

@Semisol Semisol left a comment

Choose a reason for hiding this comment

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

Good idea.
Also, no default please, let's require the tag instead.

Another idea: We could do this but with block headers, preventing eclipse attacks? 👀

@motorina0
Copy link
Contributor

I have updated the Republish Events by Peers (NIP-705) proposal to cover any ephemeral key events (bitcoin tx broadcasting included).
NIP-705 defines a way for a client to indirectly publish events to a relay with the help of its peers.
NIP-705 improves privacy by hiding from the relay(s) the IP of the client who produced the event (bitcoin tx in this case)

PR: #430

@ekzyis
Copy link

ekzyis commented Apr 27, 2023

Sorry if being dumb, but I expected that the example content is a valid transaction. So I would expect that it has already been broadcast. However, I don't seem to find it. I did the following:

❯ echo -n "AgAAAAABAtkXo8t2LfqIwQ+BPQg/LZdqAtAb61bY0zIjFvvxMTtGAAAAAAD9////j8wvOaFL5Dz+0CTKXNKxxv1GrusMps3aodsXQGp95xgAAAAAAP3///8CLAPTBQAAAAAiUSBIKoy1/JK1GdfWhii8KLfBooZg3qT7ImuwwwC6t2eT6oiKAQAAAAAAIlEgZtFI4Bx2rDqBe4X9+lzEhh7Kxca3tNE9l/QfH/ZghQECRzBEAiBV2O5+jskV8/H+UuzgRuku2gCAwlmErieXrS5scbongAIgLWD6uN8BGpyE7gNtX4jxnkNShY8yjhdcjhsHR4RAWJEBIQLlCnhSR+K9YoAngUWj94mptHhcVYJGi+rT3lwApIekkQJHMEQCIDwrK0YHftZ2BQsBjHdJb89Tlpzvc3z8E1wGgbqIVRBQAiB6J0UXuPjib+geVmaZeoq4vYD+fDz835o5OJRg9ITFDAEhA1oq2Zj0d4XbATjc3OUSXSJDvvIosDeAsHyegwk4fkcTNAslAA==" | base64 -d > tx.dat
$ xxd tx.dat 
00000000: 0200 0000 0001 02d9 17a3 cb76 2dfa 88c1  ...........v-...
00000010: 0f81 3d08 3f2d 976a 02d0 1beb 56d8 d332  ..=.?-.j....V..2
00000020: 2316 fbf1 313b 4600 0000 0000 fdff ffff  #...1;F.........
00000030: 8fcc 2f39 a14b e43c fed0 24ca 5cd2 b1c6  ../9.K.<..$.\...
00000040: fd46 aeeb 0ca6 cdda a1db 1740 6a7d e718  .F.........@j}..
00000050: 0000 0000 00fd ffff ff02 2c03 d305 0000  ..........,.....
00000060: 0000 2251 2048 2a8c b5fc 92b5 19d7 d686  .."Q H*.........
00000070: 28bc 28b7 c1a2 8660 dea4 fb22 6bb0 c300  (.(....`..."k...
00000080: bab7 6793 ea88 8a01 0000 0000 0022 5120  ..g.........."Q 
00000090: 66d1 48e0 1c76 ac3a 817b 85fd fa5c c486  f.H..v.:.{...\..
000000a0: 1eca c5c6 b7b4 d13d 97f4 1f1f f660 8501  .......=.....`..
000000b0: 0247 3044 0220 55d8 ee7e 8ec9 15f3 f1fe  .G0D. U..~......
000000c0: 52ec e046 e92e da00 80c2 5984 ae27 97ad  R..F......Y..'..
000000d0: 2e6c 71ba 2780 0220 2d60 fab8 df01 1a9c  .lq.'.. -`......
000000e0: 84ee 036d 5f88 f19e 4352 858f 328e 175c  ...m_...CR..2..\
000000f0: 8e1b 0747 8440 5891 0121 02e5 0a78 5247  ...G.@X..!...xRG
00000100: e2bd 6280 2781 45a3 f789 a9b4 785c 5582  ..b.'.E.....x\U.
00000110: 468b ead3 de5c 00a4 87a4 9102 4730 4402  F....\......G0D.
00000120: 203c 2b2b 4607 7ed6 7605 0b01 8c77 496f   <++F.~.v....wIo
00000130: cf53 969c ef73 7cfc 135c 0681 ba88 5510  .S...s|..\....U.
00000140: 5002 207a 2745 17b8 f8e2 6fe8 1e56 6699  P. z'E....o..Vf.
00000150: 7a8a b8bd 80fe 7c3c fcdf 9a39 3894 60f4  z.....|<...98.`.
00000160: 84c5 0c01 2103 5a2a d998 f477 85db 0138  ....!.Z*...w...8
00000170: dcdc e512 5d22 43be f228 b037 80b0 7c9e  ....]"C..(.7..|.
00000180: 8309 387e 4713 340b 2500                 ..8~G.4.%.
$ sha256sum tx.dat | cut -d' ' -f1 | sha256sum
03bac0c86cae47f7813ec5841a53287c54eb43b3a153cce180b583c2b637f49d  -

But there seems to be no transaction with this ID: https://mempool.space/tx/03bac0c86cae47f7813ec5841a53287c54eb43b3a153cce180b583c2b637f49d

Am I doing something wrong?

89.md Outdated
Comment on lines 51 to 71
Clients should generate an ephemeral keypair for each transaction they want to broadcast. This keypair should only ever
be used for broadcasting that transaction. This is to best preserve the privacy of the user and to not link any extra
metadata to the transaction.

Choose a reason for hiding this comment

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

Not sure if it's worth mentioning, but less is really more when it comes to broadcasting the transaction, especially if it's for privacy reasons.

If someone is doing this for privacy reasons, broadcasting to a lot of relays will maximize the chance to broadcast to a relay that is monitoring IPs and associating events with them. For now, it might not be the case that CA companies are running relays just to eavesdrop on bitcoin transactions being broadcasted, but over time there could be a bunch of events that are juicy from an bitcoin analysis perspective.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a section about it

@benthecarman
Copy link
Contributor Author

benthecarman commented Apr 27, 2023

@ekzyis you can't just hash it with segwit txs, also it is on testnet, this is the transaction

https://mempool.space/testnet/tx/94f46759c50272034cfb00b944a8e5ef3bbff12c90b3f889acaf9bfa61c58969

@benthecarman benthecarman force-pushed the bitcoin-tx branch 2 times, most recently from 8751187 to df7938c Compare April 27, 2023 21:43
@benthecarman
Copy link
Contributor Author

Added a section about recommendation around selecting relays.

@kristapsk
Copy link

Hacked together the transaction broadcaster real quick: https://github.com/benthecarman/nostr-tx-broadcast

Why mempool.space not local bitcoind node? Doing sendrawtransaction RPC seems even simpler than mempool.space API.

@monty888
Copy link

A rough version of this at https://github.com/monty888/txbroadcastr
added endpoint to blockstream, and will add to broadcast via local bitcoind
also a poster that will monitor a given directory and post raw tx files that you drop in that directory and post them to nostr to be broadcast, for example after signing on coldcard.

@benthecarman
Copy link
Contributor Author

Why mempool.space not local bitcoind node? Doing sendrawtransaction RPC seems even simpler than mempool.space API.

Plan to add that, was just hacking it together and didn't want to deal with having to add config options

89.md Outdated
@@ -32,6 +39,10 @@ For example:
[
"magic",
"0b110907"
],
[
"parent_txs",

Choose a reason for hiding this comment

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

Why bother labeling these txes as parents and distinguishing them from the main transaction of this event? Can't you just as well do an array of transactions that are somehow related as suggested by @fiatjaf?

Also, a parent may have multiple children that only together contribute enough in fees to make mining the whole thing worthwhile?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I was overthinking this, simplified this much more to just be a list of transactions

89.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
89.md Show resolved Hide resolved
@benthecarman benthecarman force-pushed the bitcoin-tx branch 4 times, most recently from b36b032 to 502a947 Compare May 5, 2023 14:10
@benthecarman
Copy link
Contributor Author

Okay sorry for all the little pushes, should be updated for package relay now

@joostjager
Copy link

What do you think about an update to the title (#476 (comment)) ?

NIP-89 Ephemeral bitcoin transaction package broadcasting

@benthecarman benthecarman changed the title NIP-89 Ephemeral bitcoin transaction broadcasting NIP-89 Ephemeral Bitcoin Transaction Package Relay May 5, 2023
@benthecarman
Copy link
Contributor Author

What do you think about an update to the title (#476 (comment)) ?

NIP-89 Ephemeral bitcoin transaction package broadcasting

I changed it to Bitcoin Transaction Package Relay seems that is clear enough

@benthecarman
Copy link
Contributor Author

This is ready for re-review/merge

@fiatjaf
Copy link
Member

fiatjaf commented May 6, 2023

I think this is great and I dream with the day in which the Bitcoin mempool will live on Nostr, but before merging I think we should wait to see it working in the real world first, just in case. Meanwhile this stays here reserved.

89.md Outdated Show resolved Hide resolved
@benthecarman
Copy link
Contributor Author

Switched to hex encoded txs

- mainnet: f9beb4d9
- testnet3: 0b110907
- signet (default): 0a03cf40
- regtest: fabfb5da

Choose a reason for hiding this comment

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

Is it really a good idea to use these not very well-known magic hex codes here?

Copy link

Choose a reason for hiding this comment

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

Might be better to use network magic so we can delineate between signets as well.

-- #476 (comment)

Copy link

Choose a reason for hiding this comment

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

Right. But I suppose those alternative signets will also get their own name? Same as with the base64 vs hex for the txes, I think keeping this human readable is helpful in various situations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is better, this way we don't get any overlap, this could even be used for things like litecoin without needing new specifications.

I do agree just writing "mainnet" is more clear but I figured just enumerating them here would make it easy enough. Also, most bitcoin libraries will have these values available anyways.

Choose a reason for hiding this comment

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

I think chances are low that it will ever come to the point where advantage can be taken of this.


- mainnet: f9beb4d9
- testnet3: 0b110907
- signet (default): 0a03cf40

Choose a reason for hiding this comment

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

Why not make mainnet the default?

Copy link

Choose a reason for hiding this comment

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

I think since money is involved, I think it's good to be explicit when using mainnet.
Don't want someone send something on mainnet by accident. However, even addresses contain net information:

Invoice addresses on the Bitcoin Testnet are generated with a different prefix. See List of address prefixes and Testnet for more details.

-- https://en.bitcoin.it/wiki/Invoice_address#Testnet

But I think for signet and regtest this is not the case? 🤔

Choose a reason for hiding this comment

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

No objection to being explicit, but maybe then always be explicit? Signet doesn't look like such a natural choice for a default to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Signet is not meant to be the default, this is the magic bytes for the default signet. I see how that can be confusing, is there a better way to convey this?

Choose a reason for hiding this comment

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

Ah maybe just signet until an alternative signet rises and then update the NIP?

@ATXMJ
Copy link

ATXMJ commented May 15, 2023

Can you give it a sub-100 NIP number?

Changed to NIP-89

This conflicts with pre-existing PR #262

Copy link

@ATXMJ ATXMJ left a comment

Choose a reason for hiding this comment

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

There is a pre-existing PR for a NIP-89.

Please change this one.


- mainnet: f9beb4d9
- testnet3: 0b110907
- signet (default): 0a03cf40
Copy link
Collaborator

Choose a reason for hiding this comment

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

No defaults please.

Copy link

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

oh

@melvincarvalho
Copy link

melvincarvalho commented Oct 12, 2023

Gentle bump on this. Did this ever move forward. I'm at the point where I could now build a whole wallet on top of nostr, nip-07 and a nostr based send like nip89 would be the final step.

@benthecarman
Copy link
Contributor Author

Gentle bump on this. Did this ever move forward. I'm at the point where I could now build a whole wallet on top of nostr, nip-07 and a nostr based send like nip89 would be the final step.

looks like nip 89 was taken, think that was all that was really needed

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.

None yet