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.
This commit is contained in:
Nicholas Dudfield
2026-01-22 07:36:57 +07:00
parent dc6a2dc6ff
commit c86479bc58
2 changed files with 10 additions and 3 deletions

View File

@@ -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
};

View File

@@ -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);