Skip to content

Commit

Permalink
update parse extra handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Acktarius committed Jan 20, 2025
1 parent 52950f0 commit 55dd43f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "cryptonote"]
path = cryptonote
url = [email protected]:Acktarius/cryptonote.git
branch = ack/fix-paimentId
1 change: 1 addition & 0 deletions cryptonote
Submodule cryptonote added at eb6f05
17 changes: 16 additions & 1 deletion src/CryptoNoteCore/TransactionExtra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,22 @@ namespace cn

bool parsePaymentId(const std::string &paymentIdString, Hash &paymentId)
{
return common::podFromHex(paymentIdString, paymentId);
// If input looks like transaction extra data (35 bytes)
if (paymentIdString.length() == 35) {
std::vector<uint8_t> extraNonce;
extraNonce.resize(paymentIdString.length() - 2); // Skip TX_EXTRA_NONCE tag
memcpy(extraNonce.data(), paymentIdString.data() + 2, paymentIdString.length() - 2);

if (getPaymentIdFromTransactionExtraNonce(extraNonce, paymentId)) {
return true;
}
}
// Try parsing as hex string
if (paymentIdString.length() == 64) {
return common::podFromHex(paymentIdString, paymentId);
}

return false;
}

bool createTxExtraWithPaymentId(const std::string &paymentIdString, std::vector<uint8_t> &extra)
Expand Down

0 comments on commit 55dd43f

Please sign in to comment.