From c86479bc581075413af80ae7f604be8290076bfc Mon Sep 17 00:00:00 2001 From: Nicholas Dudfield Date: Thu, 22 Jan 2026 07:36:57 +0700 Subject: [PATCH] fix: correct xport api signature and sfExportedTxn type usage - Fix xport hook API whitelist to declare 4 args (I32, I32, I32, I32) instead of 2, matching the actual implementation signature - Fix TxQ.cpp to use emplace_back with STObject for sfExportedTxn instead of setFieldVL, since sfExportedTxn is OBJECT type not VL. The previous code would throw "Wrong field type" at runtime. --- src/ripple/app/hook/Enum.h | 2 +- src/ripple/app/misc/impl/TxQ.cpp | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ripple/app/hook/Enum.h b/src/ripple/app/hook/Enum.h index 70b29f269..927fe536b 100644 --- a/src/ripple/app/hook/Enum.h +++ b/src/ripple/app/hook/Enum.h @@ -480,7 +480,7 @@ static const APIWhitelist import_whitelist_1{ //@@start import-whitelist-2 static const APIWhitelist import_whitelist_2{ // clang-format off - HOOK_API_DEFINITION(I64, xport, (I32, I32)), + HOOK_API_DEFINITION(I64, xport, (I32, I32, I32, I32)), HOOK_API_DEFINITION(I64, xport_reserve, (I32)), // clang-format on }; diff --git a/src/ripple/app/misc/impl/TxQ.cpp b/src/ripple/app/misc/impl/TxQ.cpp index 929d6f164..25665cb5c 100644 --- a/src/ripple/app/misc/impl/TxQ.cpp +++ b/src/ripple/app/misc/impl/TxQ.cpp @@ -1683,10 +1683,17 @@ TxQ::accept(Application& app, OpenView& view) stpTrans->setFieldArray(sfSigners, signers); - Blob const& blob = stpTrans->getSerializer().peekData(); + // Serialize the inner transaction and create an + // STObject from it. sfExportedTxn is OBJECT type, not + // VL, so we must use emplace_back with STObject, not + // setFieldVL. + ripple::Serializer exportedSer; + stpTrans->add(exportedSer); + SerialIter exportedSit(exportedSer.slice()); STTx exportTx(ttEXPORT, [&](auto& obj) { - obj.setFieldVL(sfExportedTxn, blob); + obj.emplace_back( + ripple::STObject(exportedSit, sfExportedTxn)); obj.setFieldU32(sfLedgerSequence, seq); obj.setFieldH256(sfTransactionHash, txnHash); obj.setFieldArray(sfSigners, signers);