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

Support custom close methods in vout-based invoices #203

Merged
merged 4 commits into from
Jun 8, 2024

Conversation

dr-orlovsky
Copy link
Member

Closes #198 and #119

I decided to address this two issues simultaneously, since it is impossible to reliable parse chunked variable-length strings; thus, in order to get chunking I had to switch to Base64 and fixed-length strings. Since we had to move from bitcoin address format with that, I used the approach as a base to add closing method in a compact form (one byte).

@dr-orlovsky dr-orlovsky added bug Something isn't working enhancement New feature or request labels May 24, 2024
@dr-orlovsky dr-orlovsky added this to the v0.11.0 milestone May 24, 2024
@dr-orlovsky dr-orlovsky requested review from nicbus and zoedberg May 24, 2024 19:05
@dr-orlovsky dr-orlovsky self-assigned this May 25, 2024
Copy link
Contributor

@zoedberg zoedberg left a comment

Choose a reason for hiding this comment

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

@dr-orlovsky To try this also rgb-runtime needs to be updated:

   Compiling rgb-runtime v0.11.0-beta.5 (/mnt/dmc/zoe/work/bitfinex/rgb-integration-tests/rgb)
error[E0308]: mismatched types
   --> rgb/src/pay.rs:208:34
    |
208 |                     Address::new(payload, invoice.address_network()),
    |                     ------------ ^^^^^^^ expected `AddressPayload`, found `Pay2Vout`
    |                     |
    |                     arguments to this function are incorrect
    |
note: associated function defined here
   --> /mnt/dmc/zoe/work/bitfinex/rgb-integration-tests/bp-std/invoice/src/address.rs:105:12
    |
105 |     pub fn new(payload: AddressPayload, network: AddressNetwork) -> Self {
    |            ^^^

error[E0599]: no method named `script_pubkey` found for struct `Pay2Vout` in the current scope
   --> rgb/src/pay.rs:224:27
    |
224 |                 Some(addr.script_pubkey())
    |                           ^^^^^^^^^^^^^ method not found in `Pay2Vout`
    |
help: one of the expressions' fields has a method of the same name
    |
224 |                 Some(addr.address.script_pubkey())
    |                           ++++++++

error[E0599]: no method named `script_pubkey` found for struct `Pay2Vout` in the current scope
   --> rgb/src/pay.rs:250:30
    |
250 |                 let s = addr.script_pubkey();
    |                              ^^^^^^^^^^^^^ method not found in `Pay2Vout`
    |
help: one of the expressions' fields has a method of the same name
    |
250 |                 let s = addr.address.script_pubkey();
    |                              ++++++++

error[E0599]: no method named `script_pubkey` found for struct `Pay2Vout` in the current scope
   --> rgb/src/pay.rs:301:30
    |
301 |                 let s = addr.script_pubkey();
    |                              ^^^^^^^^^^^^^ method not found in `Pay2Vout`
    |
help: one of the expressions' fields has a method of the same name
    |
301 |                 let s = addr.address.script_pubkey();
    |                              ++++++++

Some errors have detailed explanations: E0308, E0599.
For more information about an error, try `rustc --explain E0308`.
error: could not compile `rgb-runtime` (lib) due to 4 previous errors

@dr-orlovsky
Copy link
Member Author

I am updating it, but in the meanwhile can you say are you on with the approach?

@zoedberg
Copy link
Contributor

I am updating it, but in the meanwhile can you say are you on with the approach?

I agree with the approach

@dr-orlovsky
Copy link
Member Author

@zoedberg: here you are: RGB-WG/rgb#202

@zoedberg
Copy link
Contributor

I've tried using #203 and RGB-WG/rgb#202, now it compiles but the call to the pay method gives an error when trying to pay an invoice with a witness beneficiary.

The error appears only when a TapretFirst wallet tries to pay an invoice containing a witness benecifiary with OpretFirst as close method and when an opret wallet tries to pay an invoice containing a witness beneficiary with TapretFirst as close method.

Here the error of the first described case:

called `Result::unwrap()` on an `Err` value: Completion(Stock("outpoint bc:tapret1st:332e7bb119f871b0128cad67f2e698504669ffd95e78bf1022d256acd9ab6b57:1 is not part of the contract rgb:p7vHgbEH-mFdX8Sp-A!PIzpI-nXaEhyM-PAA6srV-PTUYqA8.\nIt may happen due to RGB standard library bug, or indicate internal stash inconsistency and compromised stash data storage."))

and here the error of the second described case:

called `Result::unwrap()` on an `Err` value: Completion(Stock("outpoint bc:opret1st:ad1afc53b6331104b75bddcb6f791231d2d60b883a94da525be209e291909b0e:0 is not part of the contract rgb:SKcxpcA2-PPfEJd!-9oFkksd-sG7P7rx-CLhcVbt-33zg8oI.\nIt may happen due to RGB standard library bug, or indicate internal stash inconsistency and compromised stash data storage."))

@dr-orlovsky
Copy link
Member Author

Can you please give me a call stack when the error does happen? I am unable to understand the reason of it so far...

@zoedberg
Copy link
Contributor

zoedberg commented Jun 3, 2024

Setting RUST_BACKTRACE gives no useful logs. But this can be easily reproduced, so I think it's faster if you see it by yourself. Here are the steps to reproduce the issue:

  • create a tapret and opret wallet
  • issue an asset with one of the wallets
  • create a witness invoice with the other wallet
  • try to pay the invoice with the wallet that issued the asset

@dr-orlovsky
Copy link
Member Author

The issue was fixed with RGB-WG/rgb@7717d24

@dr-orlovsky dr-orlovsky merged commit c3b7b4c into master Jun 8, 2024
18 of 19 checks passed
@dr-orlovsky dr-orlovsky deleted the invoice-pay2vout branch September 5, 2024 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

witness beneficiary not embedding close method
2 participants