add additional checks to emit, fix incorrect sfSignature -> sfTxnSignature

This commit is contained in:
Richard Holland
2023-07-17 10:09:04 +00:00
parent 53a7408f18
commit c96d1386a1
2 changed files with 29 additions and 5 deletions

View File

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

View File

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