Skip to content
Open
Show file tree
Hide file tree
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
81 changes: 81 additions & 0 deletions 89.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
NIP-89
======

Bitcoin Transaction Package Relay
-------------------------

`draft` `optional` `author:benthecarman`

A special event with kind `28333`, that contains encoded bitcoin transactions.
The bitcoin transactions are encoded as a hex string, and are contained in a `transactions` tag.

The network magic is contained in the `tags` field. This is to identify the network that the transactions are for.
The common ones are:

- 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?

Copy link
Contributor

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
Contributor

Choose a reason for hiding this comment

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

oh

- 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

@joostjager joostjager May 11, 2023

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.


If another value is present it is likely a custom signet.

The `tags` field MUST contain a `transactions` tag that contains a list of bitcoin transactions encoded in hex.
These transactions should be ordered in the order that they should be broadcasted. This can be important for making sure
that the transactions are valid when doing things like Child Pays For Parent.

The content field should just be an empty string.

This is an ephemeral event, and is not stored on the server. So relays or other custom clients could receive these
events, and broadcast them to the bitcoin network.

For example:

```json
{
"kind": 28333,
"content": "",
"tags": [
[
"magic",
"0b110907"
],
[
"transactions",
"02000000000102d917a3cb762dfa88c10f813d083f2d976a02d01beb56d8d3322316fbf1313b460000000000fdffffff8fcc2f39a14be43cfed024ca5cd2b1c6fd46aeeb0ca6cddaa1db17406a7de7180000000000fdffffff022c03d30500000000225120482a8cb5fc92b519d7d68628bc28b7c1a28660dea4fb226bb0c300bab76793ea888a01000000000022512066d148e01c76ac3a817b85fdfa5cc4861ecac5c6b7b4d13d97f41f1ff660850102473044022055d8ee7e8ec915f3f1fe52ece046e92eda0080c25984ae2797ad2e6c71ba278002202d60fab8df011a9c84ee036d5f88f19e4352858f328e175c8e1b074784405891012102e50a785247e2bd6280278145a3f789a9b4785c5582468bead3de5c00a487a4910247304402203c2b2b46077ed676050b018c77496fcf53969cef737cfc135c0681ba8855105002207a274517b8f8e26fe81e5666997a8ab8bd80fe7c3cfcdf9a39389460f484c50c0121035a2ad998f47785db0138dcdce5125d2243bef228b03780b07c9e8309387e4713340b2500",
... more hex encoded transactions
]
],
...other fields
}
```

## Uses

This offers a way for users to broadcast bitcoin transactions in a private way without having to connect to the bitcoin
network directly.

Today, users have to connect to the bitcoin network directly or use an api like mempool.space to broadcast transactions.
This is not private, as you can leak your ip address to the service or a bitcoin node.

Nostr provides a better opportunity for users to broadcast transactions in a private way. Nostr relays are at most
bitcoin adjacent and have a much lower risk of being run by a chain analysis company, thus providing a possibly better
way to broadcast transactions.

Nostr being an alternative to the bitcoin p2p network provides a potentially easier way to
get [package relay](https://bitcoinops.org/en/topics/package-relay/). Not being a p2p network means that there is no
need to worry about compatibility with the bitcoin p2p network, and can be backed into by using an alternative transport
like nostr.

## Recommendations

If transactions have no relation to each other, they should be broadcasted in separate events and with separate
keypairs. This help with user privacy and to not unnecessarily link transactions together.

Clients should generate an ephemeral keypair for each package of transactions they want to broadcast.
This keypair should only ever be used for broadcasting that package. This is to best preserve the privacy of the user
and to not link any extra metadata to the transaction package.

Obviously, the user should avoid broadcasting the channel to a relay run by a chain analysis company to prevent IP
leaks. To prevent this, they should try to broadcast to a minimal amount of relays to prevent the chance of broadcasting
to a malicious relay. This is a tradeoff between privacy and reliability as your transactions have a lower chance of
being broadcasted if you broadcast to fewer relays.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ They exist to document what may be implemented by [Nostr](https://github.com/fia
- [NIP-58: Badges](58.md)
- [NIP-65: Relay List Metadata](65.md)
- [NIP-78: Application-specific data](78.md)
- [NIP-89: Bitcoin Transaction Broadcasting](89.md)
- [NIP-94: File Metadata](94.md)

## Event Kinds

| kind | description | NIP |
| ------- | -------------------------- | ----------- |
|---------|----------------------------|-------------|
| `0` | Metadata | [1](01.md) |
| `1` | Short Text Note | [1](01.md) |
| `2` | Recommend Relay | [1](01.md) |
Expand All @@ -88,6 +89,7 @@ They exist to document what may be implemented by [Nostr](https://github.com/fia
| `10002` | Relay List Metadata | [65](65.md) |
| `22242` | Client Authentication | [42](42.md) |
| `24133` | Nostr Connect | [46](46.md) |
| `28333` | Bitcoin Transactions | [89](89.md) |
| `30000` | Categorized People List | [51](51.md) |
| `30001` | Categorized Bookmark List | [51](51.md) |
| `30008` | Profile Badges | [58](58.md) |
Expand Down