Closed eauxxs closed 4 months ago
wpkh script: 00148833bd1dc92076f2ad60c4061c57667d8a62657d
// origin
&origin = Pay2Vout {
method: OpretFirst,
address: Wpkh(
WPubkeyHash(
Array<20>(8833bd1dc92076f2ad60c4061c57667d8a62657d),
),
),
}
// tmp = Pay2Vout::from(&origin.to_string())
&tmp = Pay2Vout {
method: OpretFirst,
address: Wpkh(
WPubkeyHash(
Array<20>(00148833bd1dc92076f2ad60c4061c57667d8a62),
),
),
@zoedberg thanks for your review. By the way, I have adapted the latest rgb beta6 for rgb-lib, and it has passed all tests after this pr. So if you need it, I can try to raise a PR, and hope to reduce your work.
@zoedberg thanks for your review. By the way, I have adapted the latest rgb beta6 for rgb-lib, and it has passed all tests after this pr. So if you need it, I can try to raise a PR, and hope to reduce your work.
Thanks for the offer but I've already updated rgb-lib to the beta 6 (as told you here https://github.com/RGB-Tools/rgb-lib/issues/48). Anyway, we'll not publish that commit since the tests with witness transfers are not working. We'll wait for beta 7
@dr-orlovsky Because address.script_pubkey() does not return only the payload as you think, ScriptPubkey::as_slice contains prefixes, such as OP_0 and OP_PUSHBYTE_20.
So we should use the match method to extract the payload inside. Because of the special nature of the tr address, its processing should apply for a 32-byte memory in the stack to store the payload, and cannot directly as_ref<[u8]>.
@eauxxs can you please rebase this on top of the master which now contains the length and offset fixes - to see what specifically we need to fix in order to get P2TR working
@dr-orlovsky Sorry, I am very confused. This fix for pay2vout conflicts with #214. I think #214 is wrong, I don't know why you would merge that PR after I explained the main error to you.
here is test code, you can run it:
#[test]
fn pay2vout_parse() {
use crate::AddressPayload;
let p = Pay2Vout {
method: bp::dbc::Method::OpretFirst,
address: AddressPayload::Pkh([0xff; 20].into()),
};
assert_eq!(Pay2Vout::from_str(&p.to_string()).unwrap(), p);
}
---- parse::test::pay2vout_parse stdout ----
thread 'parse::test::pay2vout_parse' panicked at invoice/src/parse.rs:757:9:
assertion `left == right` failed
left: Pay2Vout { method: OpretFirst, address: Pkh(PubkeyHash(Array<20>(14ffffffffffffffffffffffffffffffffffffff))) }
right: Pay2Vout { method: OpretFirst, address: Pkh(PubkeyHash(Array<20>(ffffffffffffffffffffffffffffffffffffffff))) }
If you must use self.address.script_pubkey().as_slice(), for p2pkh addresses, you should skip the first 3 bytes, because the prefix of p2pkh is OP_DUP OP_Hash160 OP_PUSHBYTES_20.
@dr-orlovsky My pleasure. Doctor. I love rgb and hope it better 💕
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Additional details and impacted files
```diff @@ Coverage Diff @@ ## master #210 +/- ## ======================================== + Coverage 16.3% 17.1% +0.8% ======================================== Files 37 37 Lines 7296 7334 +38 ======================================== + Hits 1190 1257 +67 + Misses 6106 6077 -29 ``` | [Flag](https://app.codecov.io/gh/RGB-WG/rgb-std/pull/210/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=RGB-WG) | Coverage Δ | | |---|---|---| | [rust](https://app.codecov.io/gh/RGB-WG/rgb-std/pull/210/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=RGB-WG) | `17.1% <100.0%> (+0.8%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=RGB-WG#carryforward-flags-in-the-pull-request-comment) to find out more.:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.