Developer Questions
Reading a memoField in a hook ..
So i have my ascii value for my memofield ...
"rn294Ew7pGunMeYvxDo4DZLKt4c7dMFbBP"rhoHJNt6GgkJ1Xc66Z9eV25LYwirTiktkX\x02
Which is made up of 2 xrpl addess's lets say a DAO address and a seller address the last 4 characters are \x02.
What i am interested in in the last two characters 02 as their represent the % amount that can be sent to the dao account and can be 00 to 99.
This is then encoded and sent as part of the transaction.
"Memos": [
{
"Memo": {
"MemoData": "22726e3239344577377047756e4d65597678446f34445a4c4b74346337644d466242502272686f484a4e743647676b4a31586336365a39655632354c5977697254696b746b5820783032",
"MemoFormat": "",
"MemoType": ""
}
}
]
}
I can successfully read both of the accounts and move the payload_ptr to that last 4 bytes ie 20783032
sellerAccount[sellerAccountLength] = '\0';
payload_ptr += sellerAccountLength;
but i now need to read the contribution value of 02 ie 2 % and just cant figure out how to do it as the pointer always seems to hold 4 bytes and read the first ones - even if i move the pointer on +2 it doesnt read 02
TRACESTR("Data Pointer Position Before Contribution: ");
TRACEHEX(payload_ptr); // = 20783032
// if i then do
uint8_t contribution = *payload_ptr;
// the contribution is 36 as i should imagine its reading the first bytes
//1. I tried
int8_t contribution = *payload_ptr +2; // =3032
//2. I tried to get the last bytes like this but that didnt work
uint8_t contribution_low = payload_ptr[2]; // Read the high nibble (first byte)
uint8_t contribution_high = payload_ptr[3];
In essence the question is if the pointer is looking at 4 bytes and the last 2 represent two numeric digits in ascii that i need to calculate a contribution how do i access those values and store them in a variable like ..
uint8_t contribution = *payload_ptr;
.... i have spent most the day try to figure it out with chatgpt but i think that is stumped on this one ...