ttImport (#65)

Add support for Burn2Mint and key import from original XRPL network in new txn type: ttIMPORT. Needs further testing.
This commit is contained in:
RichardAH
2023-05-22 15:06:05 +02:00
committed by GitHub
parent 8b87cc291c
commit 131bd9f4b3
22 changed files with 1571 additions and 32 deletions

View File

@@ -27,6 +27,7 @@
#include <ripple/protocol/STArray.h>
#include <ripple/protocol/SystemParameters.h>
#include <ripple/protocol/nftPageMask.h>
#include <ripple/app/tx/impl/Import.h>
namespace ripple {
@@ -134,16 +135,47 @@ XRPNotCreated::visitEntry(
break;
}
}
if (!before && after->getType() == ltACCOUNT_ROOT)
accountsCreated_++;
}
bool
XRPNotCreated::finalize(
STTx const&,
STTx const& tx,
TER const,
XRPAmount const fee,
ReadView const&,
ReadView const& view,
beast::Journal const& j)
{
if (view.rules().enabled(featureImport) && tx.getTxnType() == ttIMPORT)
{
// different rules for ttIMPORT
auto const [inner, meta] = Import::getInnerTxn(tx, j);
if (!inner || !meta)
return false;
auto const result = meta->getFieldU8(sfTransactionResult);
XRPAmount dropsAdded =
result == tesSUCCESS || (result >= tecCLAIM && result <= tecLAST_POSSIBLE_ENTRY)
? inner->getFieldAmount(sfFee).xrp() // burned in PoB
: beast::zero; // if the txn didnt burn a fee we add nothing
if (accountsCreated_ == 1)
dropsAdded += Import::INITIAL_IMPORT_XRP; // welcome amount for new imports
JLOG(j.trace())
<< "Invariant XRPNotCreated Import: "
<< "dropsAdded: " << dropsAdded
<< " fee.drops(): " << fee.drops()
<< " drops_: " << drops_
<< " dropsAdded - fee.drops(): " << dropsAdded - fee.drops();
return (drops_ == dropsAdded.drops() - fee.drops());
}
// The net change should never be positive, as this would mean that the
// transaction created XRP out of thin air. That's not possible.
if (drops_ > 0)
@@ -493,7 +525,8 @@ ValidNewAccountRoot::finalize(
}
// From this point on we know exactly one account was created.
if (tx.getTxnType() == ttPAYMENT && result == tesSUCCESS)
auto tt = tx.getTxnType();
if ((tt == ttPAYMENT || tt == ttIMPORT) && result == tesSUCCESS)
{
std::uint32_t const startingSeq{
view.rules().enabled(featureDeletableAccounts) ? view.seq() : 1};