mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-02 08:25:55 +00:00
ensure that emitted txns don't need to specify network id
This commit is contained in:
@@ -46,25 +46,32 @@ namespace ripple {
|
||||
NotTEC
|
||||
preflight0(PreflightContext const& ctx)
|
||||
{
|
||||
uint32_t nodeNID = ctx.app.config().NETWORK_ID;
|
||||
std::optional<uint32_t> txNID = ctx.tx[~sfNetworkID];
|
||||
|
||||
if (nodeNID <= 1024)
|
||||
if (ctx.tx.isFieldPresent(sfEmitDetails))
|
||||
{
|
||||
// legacy networks have ids less than 1024, these networks cannot
|
||||
// specify NetworkID in txn
|
||||
if (txNID)
|
||||
return telNETWORK_ID_MAKES_TX_NON_CANONICAL;
|
||||
// all emitted transactions are free to pass, do not need network id
|
||||
}
|
||||
else
|
||||
{
|
||||
// new networks both require the field to be present and require it to
|
||||
// match
|
||||
if (!txNID)
|
||||
return telREQUIRES_NETWORK_ID;
|
||||
uint32_t nodeNID = ctx.app.config().NETWORK_ID;
|
||||
std::optional<uint32_t> txNID = ctx.tx[~sfNetworkID];
|
||||
|
||||
if (*txNID != nodeNID)
|
||||
return telWRONG_NETWORK;
|
||||
if (nodeNID <= 1024)
|
||||
{
|
||||
// legacy networks have ids less than 1024, these networks cannot
|
||||
// specify NetworkID in txn
|
||||
if (txNID)
|
||||
return telNETWORK_ID_MAKES_TX_NON_CANONICAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
// new networks both require the field to be present and require it to
|
||||
// match
|
||||
if (!txNID)
|
||||
return telREQUIRES_NETWORK_ID;
|
||||
|
||||
if (*txNID != nodeNID)
|
||||
return telWRONG_NETWORK;
|
||||
}
|
||||
}
|
||||
|
||||
auto const txID = ctx.tx.getTransactionID();
|
||||
|
||||
Reference in New Issue
Block a user