NUT-XX and NUT-XX+1: Mint / Melt Bitcoin On-Chain #107

Closed
ngutech21 wants to merge 17 commits from mint-melt-onchain into main
ngutech21 commented 2024-03-29 16:14:20 +00:00 (Migrated from github.com)

First draft for minting and melting tokens On-Chain.

First draft for minting and melting tokens On-Chain.
gandlafbtc commented 2024-03-29 17:03:39 +00:00 (Migrated from github.com)

looks great so far, nice work!

question about the minting

How do we know when the payment is complete? Do we just try to proceed with mint, and see if it works? Or is there a way to look up the paid status of a mintQuote?

Also, is there a way to let the client know, how many more confs are required, before the mint can take place?

Last question, what happens if the tx confirmation time exceeds the expiry?

looks great so far, nice work! question about the minting How do we know when the payment is complete? Do we just try to proceed with mint, and see if it works? Or is there a way to look up the `paid` status of a mintQuote? Also, is there a way to let the client know, how many more confs are required, before the mint can take place? Last question, what happens if the tx confirmation time exceeds the expiry?
callebtc (Migrated from github.com) reviewed 2024-03-29 19:59:42 +00:00
callebtc (Migrated from github.com) commented 2024-03-29 19:59:41 +00:00

Should be method

        "method": "btconchain",
Should be `method` ```suggestion "method": "btconchain", ```
callebtc (Migrated from github.com) reviewed 2024-03-29 20:00:15 +00:00
callebtc (Migrated from github.com) commented 2024-03-29 20:00:15 +00:00

Might be better to use a realistic minimal amount for on-chain here.

        "min_amount": 10000,
Might be better to use a realistic minimal amount for on-chain here. ```suggestion "min_amount": 10000, ```
callebtc (Migrated from github.com) reviewed 2024-03-29 20:15:08 +00:00
@ -0,0 +1,208 @@
NUT-18: Mint tokens Bitcoin On-Chain
callebtc (Migrated from github.com) commented 2024-03-29 20:15:07 +00:00

I think it's worth mentioning that there are (at least) two ways of handing the variable fee rate problem here.

One option could be that the wallet chooses a fee in PostMeltQuoteBtcOnchainRequest this would be a bit like a Lightning node choosing the max_fee for a payment. The mint could then respond with a response or an error depending on whether it agrees. I think this would have to accompanied with some info setting where the mint announces it's accepted fee range.

The other option, as you've proposed, would be for the mint to limit the users's choices by returning multiple melt quotes.

Did you consider the first option as well? I wonder if it has any benefits. Happy to hear thoughts from others on this as well.

I think it's worth mentioning that there are (at least) two ways of handing the variable fee rate problem here. One option could be that the wallet chooses a fee in `PostMeltQuoteBtcOnchainRequest` this would be a bit like a Lightning node choosing the `max_fee` for a payment. The mint could then respond with a response or an error depending on whether it agrees. I think this would have to accompanied with some info setting where the mint announces it's accepted fee range. The other option, as you've proposed, would be for the mint to limit the users's choices by returning multiple melt quotes. Did you consider the first option as well? I wonder if it has any benefits. Happy to hear thoughts from others on this as well.
callebtc commented 2024-03-29 20:45:13 +00:00 (Migrated from github.com)

How do we know when the payment is complete? Do we just try to proceed with mint, and see if it works? Or is there a way to look up the paid status of a mintQuote?

You can use the following endpoint as per 17.md:

GET https://mint.host:3338/v1/mint/quote/btconchain/{quote_id}

Also, is there a way to let the client know, how many more confs are required, before the mint can take place?

This would be cool but I suspect it won't be generally possible to determine this number with every on-chain backend. Take for example a service like Strike or Blink. Obviously, this would be possible with a bitcoin core, lnd, cln, ... on-chain wallet.

what happens if the tx confirmation time exceeds the expiry?

That's a very good question. While LN invoices can have a clear expiry, on-chain is a bit more tricky. It might be worth to consider removing this from onchain mints. I think melt expiry doesn't have this problem.

> How do we know when the payment is complete? Do we just try to proceed with mint, and see if it works? Or is there a way to look up the `paid` status of a mintQuote? You can use the following endpoint as per `17.md`: ``` GET https://mint.host:3338/v1/mint/quote/btconchain/{quote_id} ``` > Also, is there a way to let the client know, how many more confs are required, before the mint can take place? This would be cool but I suspect it won't be generally possible to determine this number with every on-chain backend. Take for example a service like Strike or Blink. Obviously, this would be possible with a bitcoin core, lnd, cln, ... on-chain wallet. > what happens if the tx confirmation time exceeds the expiry? That's a very good question. While LN invoices can have a clear expiry, on-chain is a bit more tricky. It might be worth to consider removing this from onchain mints. I think melt expiry doesn't have this problem.
callebtc (Migrated from github.com) reviewed 2024-03-29 21:44:38 +00:00
callebtc (Migrated from github.com) commented 2024-03-29 21:44:38 +00:00

This expiry field might be problematic (cf @gandlafbtc's comment).

This expiry field might be problematic (cf @gandlafbtc's comment).
callebtc commented 2024-03-29 21:45:14 +00:00 (Migrated from github.com)

Awesome NUT, feels complete! Looking forward to implementing it.

Left a few comments, I don't see any issues other than the expiry field for minting.

Awesome NUT, feels complete! Looking forward to implementing it. Left a few comments, I don't see any issues other than the `expiry` field for minting.
thesimplekid (Migrated from github.com) reviewed 2024-03-30 22:12:27 +00:00
@ -0,0 +1,208 @@
NUT-18: Mint tokens Bitcoin On-Chain
thesimplekid (Migrated from github.com) commented 2024-03-30 22:12:26 +00:00
        "method": "btconchain",
```suggestion "method": "btconchain", ```
ngutech21 (Migrated from github.com) reviewed 2024-03-31 11:02:32 +00:00
@ -0,0 +1,208 @@
NUT-18: Mint tokens Bitcoin On-Chain
ngutech21 (Migrated from github.com) commented 2024-03-31 11:02:32 +00:00

Interesting idea. No haven't thought about it yet.

Interesting idea. No haven't thought about it yet.
ngutech21 commented 2024-03-31 11:11:22 +00:00 (Migrated from github.com)

what happens if the tx confirmation time exceeds the expiry?

That's a very good question. While LN invoices can have a clear expiry, on-chain is a bit more tricky. It might be worth to consider removing this from onchain mints. I think melt expiry doesn't have this problem.

Good point. I think it's problematic in both way: A wallet could choose a fee that is to low to get in the next block before the quote expires.
On the other side it might be problematic to have a quote that never expires. The way I see a quote is an offer or a contract between the mint and the wallet. If the quote would never expire, the offer is still valid and it would not be possible for a mint to switch to a different onchain backend. I know this is a very rare case. Maybe it would be a good idea to make the expiry optional and recommend a long expiry like 14 days as default for the mint. Any other suggestions?

> > > what happens if the tx confirmation time exceeds the expiry? > > That's a very good question. While LN invoices can have a clear expiry, on-chain is a bit more tricky. It might be worth to consider removing this from onchain mints. I think melt expiry doesn't have this problem. Good point. I think it's problematic in both way: A wallet could choose a fee that is to low to get in the next block before the quote expires. On the other side it might be problematic to have a quote that never expires. The way I see a quote is an offer or a contract between the mint and the wallet. If the quote would never expire, the offer is still valid and it would not be possible for a mint to switch to a different onchain backend. I know this is a very rare case. Maybe it would be a good idea to make the expiry optional and recommend a long expiry like 14 days as default for the mint. Any other suggestions?
thesimplekid commented 2024-03-31 11:56:01 +00:00 (Migrated from github.com)

Maybe it would be a good idea to make the expiry optional and recommend a long expiry like 14 days as default for the mint.

Worth noting that for sat denominated quotes a long expiry is fine, but for units with an exchange rate (ie sat/usd) it introduces some risk to the mint where wallets could attempt to arbitrage the exchange rate since its up to them to execute the quote or not so i don't think long expiry times should be recommended for non sat units.

EDIT: Is this NUT limited to only the sat unit like NUT04? if so the above can be ignored.

> Maybe it would be a good idea to make the expiry optional and recommend a long expiry like 14 days as default for the mint. Worth noting that for sat denominated quotes a long expiry is fine, but for units with an exchange rate (ie sat/usd) it introduces some risk to the mint where wallets could attempt to arbitrage the exchange rate since its up to them to execute the quote or not so i don't think long expiry times should be recommended for non sat units. EDIT: Is this NUT limited to only the sat unit like NUT04? if so the above can be ignored.
thesimplekid (Migrated from github.com) reviewed 2024-03-31 18:20:09 +00:00
thesimplekid (Migrated from github.com) commented 2024-03-31 18:19:16 +00:00
  "17": {
```suggestion "17": { ```
@ -0,0 +1,208 @@
NUT-18: Mint tokens Bitcoin On-Chain
thesimplekid (Migrated from github.com) commented 2024-03-31 18:19:27 +00:00
  "18": {
```suggestion "18": { ```
thesimplekid (Migrated from github.com) reviewed 2024-03-31 19:40:35 +00:00
@ -0,0 +1,208 @@
NUT-18: Mint tokens Bitcoin On-Chain
thesimplekid (Migrated from github.com) commented 2024-03-31 19:40:35 +00:00

Do you have other use cases for the general description field? If its always fee rate maybe a specific fee_rate field as an int would be better?

Do you have other use cases for the general `description` field? If its always fee rate maybe a specific `fee_rate` field as an int would be better?
thesimplekid (Migrated from github.com) reviewed 2024-03-31 21:55:18 +00:00
@ -0,0 +1,208 @@
NUT-18: Mint tokens Bitcoin On-Chain
thesimplekid (Migrated from github.com) commented 2024-03-31 21:55:17 +00:00
  "txid": <str|null>

Can be null if not paid yet

```suggestion "txid": <str|null> ``` Can be null if not paid yet
thesimplekid (Migrated from github.com) reviewed 2024-05-31 20:12:17 +00:00
thesimplekid (Migrated from github.com) commented 2024-05-31 20:12:11 +00:00

What if we change this from an address to a BIP-21 URI? This would enable the mint to optionally support BIP-78 payjoins.

What if we change this from an address to a [BIP-21 URI](https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki)? This would enable the mint to optionally support [BIP-78 payjoins](https://github.com/bitcoin/bips/blob/master/bip-0078.mediawiki).
callebtc (Migrated from github.com) reviewed 2024-06-02 14:11:22 +00:00
callebtc (Migrated from github.com) commented 2024-06-02 14:11:22 +00:00

IUC, BIP-21 is meant for clickable links, additional information such as comments, amount etc, should not be part of the address field as it would introduce ambiguity. I think it's fair to assume that the backend would be able to pay most common address formats, and should error (for melt quote) if it doesn't support a particular address format.

IUC, BIP-21 is meant for clickable links, additional information such as comments, amount etc, should not be part of the `address` field as it would introduce ambiguity. I think it's fair to assume that the backend would be able to pay most common address formats, and should error (for melt quote) if it doesn't support a particular address format.
elnosh commented 2024-06-07 15:55:27 +00:00 (Migrated from github.com)

should there be a way for mints to charge a fee upfront in a mint quote request?

How do we know when the payment is complete? Do we just try to proceed with mint, and see if it works? Or is there a way to look up the paid status of a mintQuote?

Also, is there a way to let the client know, how many more confs are required, before the mint can take place?

regarding these questions, would it help or are there any concerns if the mint responded with the number of confirmations it requires to consider the mint quote paid?

should there be a way for mints to charge a fee upfront in a mint quote request? > How do we know when the payment is complete? Do we just try to proceed with mint, and see if it works? Or is there a way to look up the `paid` status of a mintQuote? > > Also, is there a way to let the client know, how many more confs are required, before the mint can take place? regarding these questions, would it help or are there any concerns if the mint responded with the number of confirmations it requires to consider the mint quote paid?
elnosh (Migrated from github.com) reviewed 2024-06-07 16:17:08 +00:00
@ -0,0 +1,208 @@
NUT-18: Mint tokens Bitcoin On-Chain
elnosh (Migrated from github.com) commented 2024-06-07 16:17:08 +00:00

is this paid field different than calling GET /v1/melt/quote/btconchain/{quote_id} and getting that paid status there?

is this `paid` field different than calling `GET /v1/melt/quote/btconchain/{quote_id}` and getting that `paid` status there?
thesimplekid (Migrated from github.com) reviewed 2024-06-07 22:45:15 +00:00
@ -0,0 +1,208 @@
NUT-18: Mint tokens Bitcoin On-Chain
thesimplekid (Migrated from github.com) commented 2024-06-07 22:45:15 +00:00

I think this should be removed. I don't see any benefit over just using GET /v1/melt/quote/btconchain/{quote_id}.

A related open question I have is should the mint broadcast the transaction as soon as it receives valid proofs for the melt, or can the mint decide to wait and include it in a batch of multiple melts?

I think this should be removed. I don't see any benefit over just using `GET /v1/melt/quote/btconchain/{quote_id}`. A related open question I have is should the mint broadcast the transaction as soon as it receives valid proofs for the melt, or can the mint decide to wait and include it in a batch of multiple melts?
thesimplekid commented 2024-06-07 22:50:08 +00:00 (Migrated from github.com)

regarding these questions, would it help or are there any concerns if the mint responded with the number of confirmations it requires to consider the mint quote paid?

The number a confs a mint needs in order to consider a transaction as final should be added to either the quote or the info endpoint under the on chain nut settings.

> regarding these questions, would it help or are there any concerns if the mint responded with the number of confirmations it requires to consider the mint quote paid? The number a confs a mint needs in order to consider a transaction as final should be added to either the quote or the `info` endpoint under the on chain nut settings.
elnosh (Migrated from github.com) reviewed 2024-06-08 15:38:18 +00:00
@ -0,0 +1,208 @@
NUT-18: Mint tokens Bitcoin On-Chain
elnosh (Migrated from github.com) commented 2024-06-08 15:38:18 +00:00

I think this should be removed. I don't see any benefit over just using GET /v1/melt/quote/btconchain/{quote_id}.

yeah

A related open question I have is should the mint broadcast the transaction as soon as it receives valid proofs for the melt, or can the mint decide to wait and include it in a batch of multiple melts?

interesting. That will require some changes to the response of the quote state call

> I think this should be removed. I don't see any benefit over just using `GET /v1/melt/quote/btconchain/{quote_id}`. yeah > A related open question I have is should the mint broadcast the transaction as soon as it receives valid proofs for the melt, or can the mint decide to wait and include it in a batch of multiple melts? interesting. That will require some changes to the response of the quote state call
ngutech21 (Migrated from github.com) reviewed 2024-06-18 14:12:46 +00:00
@ -0,0 +1,208 @@
NUT-18: Mint tokens Bitcoin On-Chain
ngutech21 (Migrated from github.com) commented 2024-06-18 14:12:46 +00:00

Other use cases are "next block" or "5 blocks" if the backend uses target blocks instead of sat per vbyte. But I think in most cases it would be sats per vbyte and therefore the description should be an optional field. What do you think?

Other use cases are "next block" or "5 blocks" if the backend uses target blocks instead of sat per vbyte. But I think in most cases it would be sats per vbyte and therefore the description should be an optional field. What do you think?
thesimplekid (Migrated from github.com) reviewed 2024-06-24 19:40:28 +00:00
@ -0,0 +1,208 @@
NUT-18: Mint tokens Bitcoin On-Chain
thesimplekid (Migrated from github.com) commented 2024-06-24 19:40:28 +00:00

Yeah I agree I don't think the description should be required. If a wallet wants to display some estimation like confirmation time it can choose an block explorer to get that from.

Yeah I agree I don't think the description should be required. If a wallet wants to display some estimation like confirmation time it can choose an block explorer to get that from.
thesimplekid (Migrated from github.com) reviewed 2024-06-24 19:41:48 +00:00
@ -0,0 +1,208 @@
NUT-18: Mint tokens Bitcoin On-Chain
thesimplekid (Migrated from github.com) commented 2024-06-24 19:41:48 +00:00

```suggestion ```
EthnTuttle commented 2024-06-26 01:28:35 +00:00 (Migrated from github.com)

No idea if this is relevant but was reviewing it and thought of this thread/PR/NUT.

The deposit flow in fedimint places the responsibility on the client to prove that a deposit is spendable by the mint. The client achieves this by generating a tweak applied to the mint's peg-in descriptor and sends funds to the tweaked address. Once the client observes enough confirmations, it will prove to the mint that the coins are spendable with the tweak and the merkle proof that the tx was included in a block. If the proof is valid, the mint will issue ecash for the deposit. With this flow, the mint won't be able to correlate user deposit activity if a new deposit address is used.
https://github.com/fedimint/fedimint/pull/5473#issuecomment-2181019654

No idea if this is relevant but was reviewing it and thought of this thread/PR/NUT. > The deposit flow in fedimint places the responsibility on the client to prove that a deposit is spendable by the mint. The client achieves this by generating a tweak applied to the mint's peg-in descriptor and sends funds to the tweaked address. Once the client observes enough confirmations, it will prove to the mint that the coins are spendable with the tweak and the merkle proof that the tx was included in a block. If the proof is valid, the mint will issue ecash for the deposit. With this flow, the mint won't be able to correlate user deposit activity if a new deposit address is used. https://github.com/fedimint/fedimint/pull/5473#issuecomment-2181019654
thesimplekid (Migrated from github.com) requested changes 2024-06-27 23:16:53 +00:00
thesimplekid (Migrated from github.com) commented 2024-06-27 22:58:12 +00:00

Note: All PostMintQuoteBtcOnchainRequest's are denominated in sat.

```suggestion ``` Note: All `PostMintQuoteBtcOnchainRequest`'s are denominated in sat.
thesimplekid (Migrated from github.com) commented 2024-06-27 23:00:38 +00:00

```json
{
  "quote": "DSGLX9kevM...",
  "address": "bc1qkyfgd7mus7ykfd7qkwakq75qsf7rtm...",
  "paid": UNPAID,
}
```suggestion ```json { "quote": "DSGLX9kevM...", "address": "bc1qkyfgd7mus7ykfd7qkwakq75qsf7rtm...", "paid": UNPAID, } ``` ```
thesimplekid (Migrated from github.com) commented 2024-06-27 23:02:31 +00:00
```json
{
  "quote": <str>,
  "address": <str>,
  "state": <str_enum[STATE]>,
}
```suggestion ```json { "quote": <str>, "address": <str>, "state": <str_enum[STATE]>, } ``` ```
thesimplekid (Migrated from github.com) commented 2024-06-27 23:03:40 +00:00
Where `quote` is the quote ID and `address` is the payment request to fulfill. 

`state` is an enum string field with possible values `"UNPAID"`, `"PAID"`, `"PENDING"`, `"ISSUED"`:
- `"UNPAID"` means that the quote's request has not been paid yet.
- `"PAID"` means that the request has been paid.
- `"PENDING"` means that the quote is currently being issued.
- `"ISSUED"` means that the quote has already been issued.

Note: `quote` is a **unique and random** id generated by the mint to internally look up the payment state. `quote` **MUST** remain a secret between user and mint and **MUST NOT** be derivable from the payment request. A third party who knows the `quote` ID can front-run and steal the tokens that this operation mints.
```suggestion Where `quote` is the quote ID and `address` is the payment request to fulfill. `state` is an enum string field with possible values `"UNPAID"`, `"PAID"`, `"PENDING"`, `"ISSUED"`: - `"UNPAID"` means that the quote's request has not been paid yet. - `"PAID"` means that the request has been paid. - `"PENDING"` means that the quote is currently being issued. - `"ISSUED"` means that the quote has already been issued. Note: `quote` is a **unique and random** id generated by the mint to internally look up the payment state. `quote` **MUST** remain a secret between user and mint and **MUST NOT** be derivable from the payment request. A third party who knows the `quote` ID can front-run and steal the tokens that this operation mints. ```
@ -0,0 +1,208 @@
NUT-18: Mint tokens Bitcoin On-Chain
thesimplekid (Migrated from github.com) commented 2024-06-27 23:08:12 +00:00
```json
{
  "state": <bool>,
  "txid": <str|null>
}

`txid` is the Bitcoin on chain transaction id of the transmitted transaction. 

`state` is an enum string field with possible values `"UNPAID"`, `"PENDING"`, `"PAID"`:
- `"UNPAID"` means that the request has not been paid yet.
- `"PENDING"` means that the request is currently being paid.
- `"PAID"` means that the request has been paid successfully.

If `state==PAID`, `Alice`'s wallet can delete the `inputs` from her database (or move them to a history). If `paid==PENDING`, `Alice` can repeat the same request again until the payment is successful.
```suggestion ```json { "state": <bool>, "txid": <str|null> } `txid` is the Bitcoin on chain transaction id of the transmitted transaction. `state` is an enum string field with possible values `"UNPAID"`, `"PENDING"`, `"PAID"`: - `"UNPAID"` means that the request has not been paid yet. - `"PENDING"` means that the request is currently being paid. - `"PAID"` means that the request has been paid successfully. If `state==PAID`, `Alice`'s wallet can delete the `inputs` from her database (or move them to a history). If `paid==PENDING`, `Alice` can repeat the same request again until the payment is successful. ```
thesimplekid (Migrated from github.com) commented 2024-06-27 23:10:05 +00:00
```json
[
  {
   "quote": <str>,
   "description": <str>,
   "amount": <int>,
   "fee": <int>,
   "state": <str_enum[STATE]>,
  }
]
```suggestion ```json [ { "quote": <str>, "description": <str>, "amount": <int>, "fee": <int>, "state": <str_enum[STATE]>, } ] ``` ```
thesimplekid (Migrated from github.com) commented 2024-06-27 23:15:56 +00:00
     "state": <str_enum[STATE]>,
```suggestion "state": <str_enum[STATE]>, ```
thesimplekid (Migrated from github.com) commented 2024-06-27 23:16:18 +00:00
   "state": <str_enum[STATE]>,
```suggestion "state": <str_enum[STATE]>, ```
ngutech21 (Migrated from github.com) reviewed 2024-07-28 13:33:03 +00:00
ngutech21 (Migrated from github.com) commented 2024-07-28 13:33:03 +00:00

Why should we remove the unit-field from the PostMintQuoteOnchainRequest? If the mint uses blink as a backend for handling the onchain transactions it can support onchain snd/receive with usd as a currency. Hopefully in the future there will be similar services. https://dev.blink.sv/api/usd-onchain-send

Why should we remove the unit-field from the PostMintQuoteOnchainRequest? If the mint uses blink as a backend for handling the onchain transactions it can support onchain snd/receive with usd as a currency. Hopefully in the future there will be similar services. https://dev.blink.sv/api/usd-onchain-send
ngutech21 (Migrated from github.com) reviewed 2024-07-28 13:46:33 +00:00
@ -0,0 +1,208 @@
NUT-18: Mint tokens Bitcoin On-Chain
ngutech21 (Migrated from github.com) commented 2024-07-28 13:46:33 +00:00

The description is now optional

The description is now optional
ngutech21 commented 2024-07-28 13:56:40 +00:00 (Migrated from github.com)

what happens if the tx confirmation time exceeds the expiry?

That's a very good question. While LN invoices can have a clear expiry, on-chain is a bit more tricky. It might be worth to consider removing this from onchain mints. I think melt expiry doesn't have this problem.

Good point. I think it's problematic in both way: A wallet could choose a fee that is to low to get in the next block before the quote expires. On the other side it might be problematic to have a quote that never expires. The way I see a quote is an offer or a contract between the mint and the wallet. If the quote would never expire, the offer is still valid and it would not be possible for a mint to switch to a different onchain backend. I know this is a very rare case. Maybe it would be a good idea to make the expiry optional and recommend a long expiry like 14 days as default for the mint. Any other suggestions?

So what should we do? I think it would be best to change the expiry for mint-requests to optional so a mint can use a expiry for usd based mints and no expiry for sat based mint requests? Any other suggestions @gandlafbtc @callebtc @thesimplekid

> > > what happens if the tx confirmation time exceeds the expiry? > > > > > > That's a very good question. While LN invoices can have a clear expiry, on-chain is a bit more tricky. It might be worth to consider removing this from onchain mints. I think melt expiry doesn't have this problem. > > Good point. I think it's problematic in both way: A wallet could choose a fee that is to low to get in the next block before the quote expires. On the other side it might be problematic to have a quote that never expires. The way I see a quote is an offer or a contract between the mint and the wallet. If the quote would never expire, the offer is still valid and it would not be possible for a mint to switch to a different onchain backend. I know this is a very rare case. Maybe it would be a good idea to make the expiry optional and recommend a long expiry like 14 days as default for the mint. Any other suggestions? So what should we do? I think it would be best to change the expiry for mint-requests to optional so a mint can use a expiry for usd based mints and no expiry for sat based mint requests? Any other suggestions @gandlafbtc @callebtc @thesimplekid
ngutech21 (Migrated from github.com) reviewed 2024-07-28 14:08:04 +00:00
ngutech21 (Migrated from github.com) commented 2024-07-28 14:08:04 +00:00

What is the difference between issued and pending? Is issued the initial state?

What is the difference between issued and pending? Is issued the initial state?
ngutech21 (Migrated from github.com) reviewed 2024-07-28 14:33:28 +00:00
@ -0,0 +1,208 @@
NUT-18: Mint tokens Bitcoin On-Chain
ngutech21 (Migrated from github.com) commented 2024-07-28 14:33:28 +00:00

Thanks for the suggestion. I replaced the boolean flag paid with the enum

Thanks for the suggestion. I replaced the boolean flag paid with the enum
thesimplekid (Migrated from github.com) reviewed 2024-07-29 02:04:21 +00:00
thesimplekid (Migrated from github.com) commented 2024-07-29 02:04:21 +00:00

This is a question of scoping this NUT. To support other units where a conversion rate is involved how expiration is handled as well as how confirmation time is defined is much more important as the conversion rate could change outside an acceptable slippage. So in order to support other units how confirmation and expiration is defined needs to be included as well.

This is a question of scoping this NUT. To support other units where a conversion rate is involved how expiration is handled as well as how confirmation time is defined is much more important as the conversion rate could change outside an acceptable slippage. So in order to support other units how confirmation and expiration is defined needs to be included as well.
thesimplekid commented 2024-07-29 02:08:55 +00:00 (Migrated from github.com)

The issue with on chain is there is no way to expire an address unlike ln, so how is a deposit after an expiration handled is it considered a donation to the mint? If that is that case I think that needs to be made explicit. I think this maybe okay since even in the case of removing expiration that is effectively the case if a deposit is made to a mint that is no longer in operation (if the mint operator still has the keys), so having the explicit handling of expiration might be an improvement.

Of course there is the opportunity for a benevolent mint operator to settle a quote paid after out of band if they are known or have contact info set in the NUT-06. I noticed this is how the strike api handles it, though that has its own trade offs.

As i mentioned above definition of confirmation needs to be included as well with the expiration to signal what needs to happen before the expiration in order for the quote to be settled, num blocks conf, transaction broadcast. This could even be split for example transaction needs to be broadcast before x time to get the exchange rate, but ecash wont be issued until x confirmations.

The issue with on chain is there is no way to expire an address unlike ln, so how is a deposit after an expiration handled is it considered a donation to the mint? If that is that case I think that needs to be made explicit. I think this maybe okay since even in the case of removing expiration that is effectively the case if a deposit is made to a mint that is no longer in operation (if the mint operator still has the keys), so having the explicit handling of expiration might be an improvement. Of course there is the opportunity for a benevolent mint operator to settle a quote paid after out of band if they are known or have contact info set in the NUT-06. I noticed this is how the [strike api](https://docs.strike.me/walkthrough/receiving-payments#4-receive-the-payment) handles it, though that has its own trade offs. As i mentioned above definition of confirmation needs to be included as well with the expiration to signal what needs to happen before the expiration in order for the quote to be settled, num blocks conf, transaction broadcast. This could even be split for example transaction needs to be broadcast before x time to get the exchange rate, but ecash wont be issued until x confirmations.
ngutech21 commented 2024-07-29 08:02:14 +00:00 (Migrated from github.com)

should there be a way for mints to charge a fee upfront in a mint quote request?

How do we know when the payment is complete? Do we just try to proceed with mint, and see if it works? Or is there a way to look up the paid status of a mintQuote?
Also, is there a way to let the client know, how many more confs are required, before the mint can take place?

regarding these questions, would it help or are there any concerns if the mint responded with the number of confirmations it requires to consider the mint quote paid?

Yes, good point. I have added min_confirmations to the info-endpoint

> should there be a way for mints to charge a fee upfront in a mint quote request? > > > How do we know when the payment is complete? Do we just try to proceed with mint, and see if it works? Or is there a way to look up the `paid` status of a mintQuote? > > Also, is there a way to let the client know, how many more confs are required, before the mint can take place? > > regarding these questions, would it help or are there any concerns if the mint responded with the number of confirmations it requires to consider the mint quote paid? Yes, good point. I have added min_confirmations to the info-endpoint
ngutech21 (Migrated from github.com) reviewed 2024-07-29 08:18:15 +00:00
@ -0,0 +1,208 @@
NUT-18: Mint tokens Bitcoin On-Chain
ngutech21 (Migrated from github.com) commented 2024-07-29 08:18:15 +00:00

I removed the redundant GET https://mint.host:3338/v1/melt/btconchain/{tx_id} endpoint

I removed the redundant GET https://mint.host:3338/v1/melt/btconchain/{tx_id} endpoint
ngutech21 (Migrated from github.com) reviewed 2024-08-01 13:11:13 +00:00
@ -0,0 +1,208 @@
NUT-18: Mint tokens Bitcoin On-Chain
ngutech21 (Migrated from github.com) commented 2024-08-01 13:11:13 +00:00

I think this should be removed. I don't see any benefit over just using GET /v1/melt/quote/btconchain/{quote_id}.

A related open question I have is should the mint broadcast the transaction as soon as it receives valid proofs for the melt, or can the mint decide to wait and include it in a batch of multiple melts?

IMO the mint can decide if it wants to batch transaction or not. This is same as centralized btc exchanges handle this. We could add a property to the info-endpoint to signal that a mint might delay the melt for batching, but I don't think this is necessary

> I think this should be removed. I don't see any benefit over just using `GET /v1/melt/quote/btconchain/{quote_id}`. > > A related open question I have is should the mint broadcast the transaction as soon as it receives valid proofs for the melt, or can the mint decide to wait and include it in a batch of multiple melts? IMO the mint can decide if it wants to batch transaction or not. This is same as centralized btc exchanges handle this. We could add a property to the info-endpoint to signal that a mint might delay the melt for batching, but I don't think this is necessary
thesimplekid (Migrated from github.com) reviewed 2024-08-01 13:30:18 +00:00
@ -0,0 +1,208 @@
NUT-18: Mint tokens Bitcoin On-Chain
thesimplekid (Migrated from github.com) commented 2024-08-01 13:30:18 +00:00

IMO the mint can decide if it wants to batch transaction or not. This is same as centralized btc exchanges handle this. We could add a property to the info-endpoint to signal that a mint might delay the melt for batching, but I don't think this is necessary

I think we do need to signal this and it needs to be more concrete then the mint may delay. I would suggest we add a time component to the MeltQuoteResponse this way if the user wants the withdrawal more quickly they will need to pay a higher fee if they are willing to wait and allow the mint to batch they can select a Quote with a lower fee and wait longer.

Allowing the mint to delay for batching but not defining what a delay means will lead to a bad user experience where they don't know when their transaction will be process and they may need it immediately and be willing to pay for that.

> IMO the mint can decide if it wants to batch transaction or not. This is same as centralized btc exchanges handle this. We could add a property to the info-endpoint to signal that a mint might delay the melt for batching, but I don't think this is necessary I think we do need to signal this and it needs to be more concrete then the mint may delay. I would suggest we add a time component to the `MeltQuoteResponse` this way if the user wants the withdrawal more quickly they will need to pay a higher fee if they are willing to wait and allow the mint to batch they can select a `Quote` with a lower fee and wait longer. Allowing the mint to delay for batching but not defining what a delay means will lead to a bad user experience where they don't know when their transaction will be process and they may need it immediately and be willing to pay for that.
davidcaseria (Migrated from github.com) reviewed 2024-08-08 15:28:17 +00:00
@ -0,0 +62,4 @@
"address": "bc1qkyfgd7mus7ykfd7qkwakq75qsf7rtm...",
"state": "UNPAID",
"expiry": 1701704757
}
davidcaseria (Migrated from github.com) commented 2024-08-08 15:28:17 +00:00

Is it worth adding the txid here?

Is it worth adding the txid here?
thesimplekid (Migrated from github.com) reviewed 2024-08-09 13:41:20 +00:00
@ -0,0 +62,4 @@
"address": "bc1qkyfgd7mus7ykfd7qkwakq75qsf7rtm...",
"state": "UNPAID",
"expiry": 1701704757
}
thesimplekid (Migrated from github.com) commented 2024-08-09 13:41:20 +00:00

It might though this question made me think what if a a quote is payed with multiple transaction, I think that should still be valid? So to cover that it would need to be a list of txid? Unless we explicitly say it MUST be paid in one tx.

It might though this question made me think what if a a quote is payed with multiple transaction, I think that should still be valid? So to cover that it would need to be a list of txid? Unless we explicitly say it **MUST** be paid in one tx.
thesimplekid (Migrated from github.com) reviewed 2024-08-09 13:52:33 +00:00
@ -0,0 +66,4 @@
```
The wallet **MUST** store the `amount` in the request and the `quote` id in the response in its database so it can later request the tokens after paying the request. After payment, the wallet continues with the next section.
thesimplekid (Migrated from github.com) commented 2024-08-09 13:52:33 +00:00

I think it would be worth adding a note here that wallets SHOULD display the quote as a BIP21 URI or BIP21 URI encoded as a QR code to the user. This would help reduce errors of underpaying or overpaying accidentally.

NOTE: There is a draft to replace BIP21 https://github.com/bitcoin/bips/pull/1555 but as its backwards compatible i suggest we say bip21 for now and can update later.

I think it would be worth adding a note here that wallets **SHOULD** display the quote as a [BIP21](https://github.com/bitcoin/bips/blob/master/bip-0021.mediawiki) URI or BIP21 URI encoded as a QR code to the user. This would help reduce errors of underpaying or overpaying accidentally. NOTE: There is a draft to replace BIP21 https://github.com/bitcoin/bips/pull/1555 but as its backwards compatible i suggest we say bip21 for now and can update later.
prusnak commented 2024-08-19 09:13:07 +00:00 (Migrated from github.com)

I wonder if we want to allow minting/melting on Liquid chain and if yes, then whether it should be part of these two nuts or a new pair of nuts.

I wonder if we want to allow minting/melting on Liquid chain and if yes, then whether it should be part of these two nuts or a new pair of nuts.
davidcaseria commented 2024-08-24 10:47:57 +00:00 (Migrated from github.com)

I wonder if we want to allow minting/melting on Liquid chain and if yes, then whether it should be part of these two nuts or a new pair of nuts.

I think it makes more sense to keep separate NUTS, especially since its support should be signaled differently by NUT-06.

> I wonder if we want to allow minting/melting on Liquid chain and if yes, then whether it should be part of these two nuts or a new pair of nuts. I think it makes more sense to keep separate NUTS, especially since its support should be signaled differently by NUT-06.
prusnak commented 2024-08-24 13:05:16 +00:00 (Migrated from github.com)

especially since its support should be signaled differently by NUT-06.

Ah yes, that is indeed a good reason.

> especially since its support should be signaled differently by NUT-06. Ah yes, that is indeed a good reason.
davidcaseria commented 2024-08-30 13:23:35 +00:00 (Migrated from github.com)

It does not necessarily impact the spec, but something like this should be the recommended way to handle address generation: https://blog.zaprite.com/optimizing-address-usage-for-the-gap-limit/

It does not necessarily impact the spec, but something like this should be the recommended way to handle address generation: https://blog.zaprite.com/optimizing-address-usage-for-the-gap-limit/
thesimplekid (Migrated from github.com) reviewed 2024-09-05 18:02:18 +00:00
@ -0,0 +42,4 @@
}
]
```
The mint can return multiple `PostMeltQuoteBtcOnchainResponse` with different `fees` and `expiry` dates. The wallet can choose which one to pay and the other ones will expire. Where `quote` is the quote ID, `amount` the amount that needs to be provided, and `fee` the additional fee that is required. The mint expects `Alice` to include `Proofs` of *at least* `total_amount = amount + fee`. `paid` indicates whether the request as been paid and `expiry` is the Unix timestamp until which the melt quote is valid.
thesimplekid (Migrated from github.com) commented 2024-09-05 18:02:18 +00:00

It maybe better if we express fee in sats but also with a time component. This would allow the mint to batch transactions. For example fee of x sats will be paid within the hour, fee of y sats within the day etc. This leaves it up to the mint to actually set the final sats per vbyte to meet whatever time period they agreed to in the quote.

It maybe better if we express fee in sats but also with a time component. This would allow the mint to batch transactions. For example fee of x sats will be paid within the hour, fee of y sats within the day etc. This leaves it up to the mint to actually set the final sats per vbyte to meet whatever time period they agreed to in the quote.
thesimplekid (Migrated from github.com) reviewed 2024-09-05 18:07:05 +00:00
@ -0,0 +34,4 @@
"state": <str_enum[STATE]>,
"expiry": <int>
}
```
thesimplekid (Migrated from github.com) commented 2024-09-05 18:07:05 +00:00

If unit is included here don't we need to add an amount in sats to the quote response so the mint can signal the exchange rate. Otherwise if it is non bitcoin unit the wallet will not know how much bitcoin to send to the address to fill the quote.

That being said because of the imprecise nature of sending a bitcoin onchain transaction I would be for removing the unit and limiting it to sat denominated quotes.

If unit is included here don't we need to add an amount in sats to the quote response so the mint can signal the exchange rate. Otherwise if it is non bitcoin unit the wallet will not know how much bitcoin to send to the address to fill the quote. That being said because of the imprecise nature of sending a bitcoin onchain transaction I would be for removing the unit and limiting it to sat denominated quotes.
davidcaseria (Migrated from github.com) reviewed 2024-09-05 23:29:08 +00:00
@ -0,0 +34,4 @@
"state": <str_enum[STATE]>,
"expiry": <int>
}
```
davidcaseria (Migrated from github.com) commented 2024-09-05 23:29:08 +00:00

I agree. I support keeping it simple to start and only supporting sats as the unit.

I agree. I support keeping it simple to start and only supporting sats as the unit.
davidcaseria (Migrated from github.com) reviewed 2024-09-05 23:34:53 +00:00
@ -0,0 +62,4 @@
"address": "bc1qkyfgd7mus7ykfd7qkwakq75qsf7rtm...",
"state": "UNPAID",
"expiry": 1701704757
}
davidcaseria (Migrated from github.com) commented 2024-09-05 23:34:53 +00:00

I think it should be explicit only one transaction is supported.

I think it should be explicit only one transaction is supported.
davidcaseria (Migrated from github.com) reviewed 2024-09-05 23:43:57 +00:00
@ -0,0 +41,4 @@
`state` is an enum string field with possible values `"UNPAID"`, `"PAID"`, `"PENDING"`, `"ISSUED"`:
- `"UNPAID"` means that the quote's request has not been paid yet.
- `"PAID"` means that the request has been paid.
- `"PENDING"` means that the quote is currently being issued.
davidcaseria (Migrated from github.com) commented 2024-09-05 23:36:22 +00:00

Is this when the transaction is still confirming?

Is this when the transaction is still confirming?
@ -0,0 +62,4 @@
"address": "bc1qkyfgd7mus7ykfd7qkwakq75qsf7rtm...",
"state": "UNPAID",
"expiry": 1701704757
}
davidcaseria (Migrated from github.com) commented 2024-09-05 23:38:39 +00:00

Should we return the number of confirmations the transaction currently has?

Should we return the number of confirmations the transaction currently has?
@ -0,0 +42,4 @@
}
]
```
The mint can return multiple `PostMeltQuoteBtcOnchainResponse` with different `fees` and `expiry` dates. The wallet can choose which one to pay and the other ones will expire. Where `quote` is the quote ID, `amount` the amount that needs to be provided, and `fee` the additional fee that is required. The mint expects `Alice` to include `Proofs` of *at least* `total_amount = amount + fee`. `paid` indicates whether the request as been paid and `expiry` is the Unix timestamp until which the melt quote is valid.
davidcaseria (Migrated from github.com) commented 2024-09-05 23:43:04 +00:00

Should the client specify how fast they want the transaction confirmed in the quote request (e.g., with a target_blocks field)?

Should the client specify how fast they want the transaction confirmed in the quote request (e.g., with a `target_blocks` field)?
thesimplekid (Migrated from github.com) reviewed 2024-09-06 06:34:48 +00:00
@ -0,0 +42,4 @@
}
]
```
The mint can return multiple `PostMeltQuoteBtcOnchainResponse` with different `fees` and `expiry` dates. The wallet can choose which one to pay and the other ones will expire. Where `quote` is the quote ID, `amount` the amount that needs to be provided, and `fee` the additional fee that is required. The mint expects `Alice` to include `Proofs` of *at least* `total_amount = amount + fee`. `paid` indicates whether the request as been paid and `expiry` is the Unix timestamp until which the melt quote is valid.
thesimplekid (Migrated from github.com) commented 2024-09-06 06:34:48 +00:00

As its currently written the mint returns a list of quotes with different fees for different speed of confirmation. That could be flipped and the client tells the mint what it wants and the mint returns only one quote for that target.

I lean towards how its currently written where the mints returns a set of options and then the client picks the one that best suits it. But as i comments i think we need a time component in addition to the fee so that could be expressed in block time.

As its currently written the mint returns a list of quotes with different fees for different speed of confirmation. That could be flipped and the client tells the mint what it wants and the mint returns only one quote for that target. I lean towards how its currently written where the mints returns a set of options and then the client picks the one that best suits it. But as i comments i think we need a time component in addition to the fee so that could be expressed in block time.
davidcaseria (Migrated from github.com) reviewed 2024-09-06 09:46:46 +00:00
@ -0,0 +42,4 @@
}
]
```
The mint can return multiple `PostMeltQuoteBtcOnchainResponse` with different `fees` and `expiry` dates. The wallet can choose which one to pay and the other ones will expire. Where `quote` is the quote ID, `amount` the amount that needs to be provided, and `fee` the additional fee that is required. The mint expects `Alice` to include `Proofs` of *at least* `total_amount = amount + fee`. `paid` indicates whether the request as been paid and `expiry` is the Unix timestamp until which the melt quote is valid.
davidcaseria (Migrated from github.com) commented 2024-09-06 09:46:46 +00:00

Should the spec offer guidance to the mint implementors on what fee rates should be returned so wallet experiences can be similar even though the wallet isn't in control of requesting its fee rate?

Should the spec offer guidance to the mint implementors on what fee rates should be returned so wallet experiences can be similar even though the wallet isn't in control of requesting its fee rate?
davidcaseria (Migrated from github.com) reviewed 2024-09-06 09:47:03 +00:00
@ -0,0 +42,4 @@
}
]
```
The mint can return multiple `PostMeltQuoteBtcOnchainResponse` with different `fees` and `expiry` dates. The wallet can choose which one to pay and the other ones will expire. Where `quote` is the quote ID, `amount` the amount that needs to be provided, and `fee` the additional fee that is required. The mint expects `Alice` to include `Proofs` of *at least* `total_amount = amount + fee`. `paid` indicates whether the request as been paid and `expiry` is the Unix timestamp until which the melt quote is valid.
davidcaseria (Migrated from github.com) commented 2024-09-06 09:47:03 +00:00

Should the spec offer guidance to the mint implementors on what fee rates should be returned so wallet experiences can be similar even though the wallet isn't in control of requesting its fee rate?

Should the spec offer guidance to the mint implementors on what fee rates should be returned so wallet experiences can be similar even though the wallet isn't in control of requesting its fee rate?
starbackr-dev commented 2024-10-12 11:32:10 +00:00 (Migrated from github.com)

All, Is there an implementation of this on-chain mint/melt? I'm thinking of starting one with nutshell. Checking to make sure I'm not duplicating work.

All, Is there an implementation of this on-chain mint/melt? I'm thinking of starting one with nutshell. Checking to make sure I'm not duplicating work.
thesimplekid commented 2024-10-12 12:45:49 +00:00 (Migrated from github.com)

All, Is there an implementation of this on-chain mint/melt? I'm thinking of starting one with nutshell. Checking to make sure I'm not duplicating work.

PR for cdk is here https://github.com/cashubtc/cdk/pull/172 haven't seen anything for nutshell.

> All, Is there an implementation of this on-chain mint/melt? I'm thinking of starting one with nutshell. Checking to make sure I'm not duplicating work. PR for cdk is here https://github.com/cashubtc/cdk/pull/172 haven't seen anything for nutshell.
starbackr-dev commented 2024-10-12 17:52:48 +00:00 (Migrated from github.com)

All, Is there an implementation of this on-chain mint/melt? I'm thinking of starting one with nutshell. Checking to make sure I'm not duplicating work.

PR for cdk is here cashubtc/cdk#172 haven't seen anything for nutshell.

great. thanks. Will start to work on Nutshell.

> > All, Is there an implementation of this on-chain mint/melt? I'm thinking of starting one with nutshell. Checking to make sure I'm not duplicating work. > > PR for cdk is here [cashubtc/cdk#172](https://github.com/cashubtc/cdk/pull/172) haven't seen anything for nutshell. great. thanks. Will start to work on Nutshell.
AngusP (Migrated from github.com) reviewed 2024-10-23 22:13:07 +00:00
@ -0,0 +34,4 @@
"state": <str_enum[STATE]>,
"expiry": <int>
}
```
AngusP (Migrated from github.com) commented 2024-10-23 22:13:07 +00:00

Feels simplest to say

  1. You can only mint BTC on-chain (sats only, no other units)
  2. You can then swap sats ecash for ecash in a different unit with the mint

So if you wanted to get e.g. "USD eCash by making an onchain tx", it's a two-step process. Has the advantage of a swap being atomic, much faster and less flaky than a mint depending on N confirmations

Feels simplest to say 1. You can only mint BTC on-chain (sats only, no other units) 2. You can then swap sats ecash for ecash in a different unit with the mint So if you wanted to get e.g. "USD eCash by making an onchain tx", it's a two-step process. Has the advantage of a swap being atomic, much faster and less flaky than a mint depending on N confirmations
AngusP (Migrated from github.com) reviewed 2024-10-23 22:20:44 +00:00
@ -0,0 +62,4 @@
"address": "bc1qkyfgd7mus7ykfd7qkwakq75qsf7rtm...",
"state": "UNPAID",
"expiry": 1701704757
}
AngusP (Migrated from github.com) commented 2024-10-23 22:20:44 +00:00

It is always going to be possible to make multiple transactions paying the same address, so someone will do that... so how to handle? Multiple transactions also make reorg risk more complex and add consolidation cost for the Mint.

Feels resonable that the requirement should be for a single transaction with one output paying the mint, anything else and the Mint can 'fail' the mint request and refund whatever it got somehow -- would need the user to provide a refund address, or the mint would have to issue an ecash claim on it (but then, consolidation cost etc., would be a 'mint with on-chain dust and then drain the mint's lightning channels' attackable behaviour)

It is always going to be *possible* to make multiple transactions paying the same address, so someone will do that... so how to handle? Multiple transactions also make reorg risk more complex and add consolidation cost for the Mint. Feels resonable that the requirement should be for a single transaction with one output paying the mint, anything else and the Mint can 'fail' the mint request and refund whatever it got *somehow* -- would need the user to provide a refund address, or the mint would have to issue an ecash claim on it (but then, consolidation cost etc., would be a 'mint with on-chain dust and then drain the mint's lightning channels' attackable behaviour)
AngusP (Migrated from github.com) reviewed 2024-10-23 22:24:19 +00:00
@ -0,0 +42,4 @@
}
]
```
The mint can return multiple `PostMeltQuoteBtcOnchainResponse` with different `fees` and `expiry` dates. The wallet can choose which one to pay and the other ones will expire. Where `quote` is the quote ID, `amount` the amount that needs to be provided, and `fee` the additional fee that is required. The mint expects `Alice` to include `Proofs` of *at least* `total_amount = amount + fee`. `paid` indicates whether the request as been paid and `expiry` is the Unix timestamp until which the melt quote is valid.
AngusP (Migrated from github.com) commented 2024-10-23 22:24:19 +00:00

what fee rates should be returned

Surely the mint should be able to pick whatever fee it wants? Needs to be flexible to feerate market swings, but also some mints might want to disincentivise on-chain melts by adding a premium, others might offer it at cost

> what fee rates should be returned Surely the mint should be able to pick whatever fee it wants? Needs to be flexible to feerate market swings, but also some mints might want to disincentivise on-chain melts by adding a premium, others might offer it at cost

Pull request closed

Sign in to join this conversation.
No description provided.