From c96d1386a1a2806ccca1eeebc046244b9ff18949 Mon Sep 17 00:00:00 2001 From: Richard Holland Date: Mon, 17 Jul 2023 10:09:04 +0000 Subject: [PATCH] add additional checks to emit, fix incorrect sfSignature -> sfTxnSignature --- src/ripple/app/hook/impl/applyHook.cpp | 32 ++++++++++++++++++++++---- src/ripple/app/tx/impl/apply.cpp | 2 +- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/ripple/app/hook/impl/applyHook.cpp b/src/ripple/app/hook/impl/applyHook.cpp index 30e3e60ae..d05b78cf4 100644 --- a/src/ripple/app/hook/impl/applyHook.cpp +++ b/src/ripple/app/hook/impl/applyHook.cpp @@ -3067,7 +3067,7 @@ DEFINE_HOOK_FUNCTION( * 1. Sequence: 0 * 2. PubSigningKey: 000000000000000 * 3. sfEmitDetails present and valid - * 4. No sfSignature + * 4. No sfTxnSignature * 5. LastLedgerSeq > current ledger, > firstledgerseq & LastLedgerSeq < seq + 5 * 6. FirstLedgerSeq > current ledger * 7. Fee must be correctly high @@ -3115,6 +3115,30 @@ DEFINE_HOOK_FUNCTION( return EMISSION_FAILURE; } + // rule 2.a: no signers + if (stpTrans->isFieldPresent(sfSigners)) + { + JLOG(j.trace()) + << "HookEmit[" << HC_ACC() << "]: sfSigners not allowed in emitted txns."; + return EMISSION_FAILURE; + } + + // rule 2.b: ticketseq cannot be used + if (stpTrans->isFieldPresent(sfTicketSequence)) + { + JLOG(j.trace()) + << "HookEmit[" << HC_ACC() << "]: sfTicketSequence not allowed in emitted txns."; + return EMISSION_FAILURE; + } + + // rule 2.c sfAccountTxnID not allowed + if (stpTrans->isFieldPresent(sfAccountTxnID)) + { + JLOG(j.trace()) + << "HookEmit[" << HC_ACC() << "]: sfAccountTxnID not allowed in emitted txns."; + return EMISSION_FAILURE; + } + // rule 3: sfEmitDetails must be present and valid if (!stpTrans->isFieldPresent(sfEmitDetails)) { @@ -3208,11 +3232,11 @@ DEFINE_HOOK_FUNCTION( return EMISSION_FAILURE; } - // rule 4: sfSignature must be absent - if (stpTrans->isFieldPresent(sfSignature)) + // rule 4: sfTxnSignature must be absent + if (stpTrans->isFieldPresent(sfTxnSignature)) { JLOG(j.trace()) << - "HookEmit[" << HC_ACC() << "]: sfSignature is present but should not be"; + "HookEmit[" << HC_ACC() << "]: sfTxnSignature is present but should not be"; return EMISSION_FAILURE; } diff --git a/src/ripple/app/tx/impl/apply.cpp b/src/ripple/app/tx/impl/apply.cpp index 930959621..f7fd4d1c9 100644 --- a/src/ripple/app/tx/impl/apply.cpp +++ b/src/ripple/app/tx/impl/apply.cpp @@ -47,7 +47,7 @@ checkValidity( if (rules.enabled(featureHooks) && tx.isFieldPresent(sfEmitDetails)) { // emitted transactions do not contain signatures - if (tx.isFieldPresent(sfSignature)) + if (tx.isFieldPresent(sfTxnSignature)) return {Validity::SigBad, "Emitted txn contains signature."}; // and they must be either emitted here on this node