This commit is contained in:
tequ
2026-03-23 12:34:33 +09:00
parent 1adaeac8a7
commit de64bc7855
2 changed files with 30 additions and 8 deletions

View File

@@ -160,16 +160,28 @@ Transactor::preflight1(PreflightContext const& ctx, std::uint32_t flagMask)
return temINVALID_FLAG;
}
if (!hasSponsor && hasSponsorFlags)
if (!hasSponsor)
{
JLOG(ctx.j.debug()) << "preflight1: sponsor flags without sponsor definition";
return temINVALID_FLAG;
}
if (hasSponsorFlags)
{
JLOG(ctx.j.debug()) << "preflight1: sponsor flags without sponsor definition";
return temINVALID_FLAG;
}
if (!hasSponsor && hasSponsorSig)
if (hasSponsorSig)
{
JLOG(ctx.j.debug()) << "preflight1: sponsor signature without sponsor definition";
return temMALFORMED;
}
}
else if (hasSponsorFlags)
{
JLOG(ctx.j.debug()) << "preflight1: sponsor signature without sponsor definition";
return temMALFORMED;
auto const sponsorFlags = ctx.tx.getFieldU32(sfSponsorFlags);
if ((sponsorFlags & ~(spfSponsorFee | spfSponsorReserve)) || sponsorFlags == 0)
{
JLOG(ctx.j.debug()) << "preflight1: invalid sponsor flags";
return temINVALID_FLAG;
}
}
if (auto const ret = preflight0(ctx, flagMask))
@@ -218,6 +230,13 @@ Transactor::preflight1(PreflightContext const& ctx, std::uint32_t flagMask)
return temMALFORMED;
}
// if (hasSponsor && hasSponsorFlags &&
// ctx.tx.getFieldU32(sfSponsorFlags) == 0)
// {
// JLOG(ctx.j.debug()) << "preflight1: sponsor with no sponsorship flags";
// return temINVALID_FLAG;
// }
return tesSUCCESS;
}

View File

@@ -360,7 +360,7 @@ public:
env.close();
// Invalid Sponsor Account (Account = Sponsor.Account)
env(noop(alice), sponsor::as(alice), ter(temMALFORMED));
env(noop(alice), sponsor::as(alice, spfSponsorFee), ter(temMALFORMED));
// Invalid Sponsor Account
// (SponsorSignature is specified but Sponsor.Account is not specified)
@@ -378,6 +378,9 @@ public:
sponsor::as(sponsor, (spfSponsorFee | spfSponsorReserve) + 1),
ter(temINVALID_FLAG));
// SponsorFlags=0 with valid sponsor (no sponsorship purpose)
env(noop(alice), sponsor::as(sponsor, 0), ter(temINVALID_FLAG));
// Invalid Flags without sponsor
auto tx = noop(alice);
tx[sfSponsorFlags.jsonName] = spfSponsorFee | spfSponsorReserve;