Add DepositPreauth ledger type and transaction (RIPD-1624):

The lsfDepositAuth flag limits the AccountIDs that can deposit into
the account that has the flag set.  The original design only
allowed deposits to complete if the account with the flag set also
signed the transaction that caused the deposit.

The DepositPreauth ledger type allows an account with the
lsfDepositAuth flag set to preauthorize additional accounts.
This preauthorization allows them to sign deposits as well.  An
account can add DepositPreauth objects to the ledger (and remove
them as well) using the DepositPreauth transaction.
This commit is contained in:
Scott Schurr
2018-04-20 13:16:17 -07:00
committed by seelabs
parent b444196bf9
commit 008ff67ac2
56 changed files with 1589 additions and 177 deletions

View File

@@ -355,6 +355,7 @@ public:
BEAST_EXPECT (acct_objs_is_size (acct_objs (gw, jss::account), 0));
BEAST_EXPECT (acct_objs_is_size (acct_objs (gw, jss::amendments), 0));
BEAST_EXPECT (acct_objs_is_size (acct_objs (gw, jss::check), 0));
BEAST_EXPECT (acct_objs_is_size (acct_objs (gw, jss::deposit_preauth), 0));
BEAST_EXPECT (acct_objs_is_size (acct_objs (gw, jss::directory), 0));
BEAST_EXPECT (acct_objs_is_size (acct_objs (gw, jss::escrow), 0));
BEAST_EXPECT (acct_objs_is_size (acct_objs (gw, jss::fee), 0));
@@ -400,6 +401,18 @@ public:
BEAST_EXPECT (check[sfDestination.jsonName] == alice.human());
BEAST_EXPECT (check[sfSendMax.jsonName][jss::value].asUInt() == 10);
}
// gw preauthorizes payments from alice.
env (deposit::auth (gw, alice));
env.close();
{
// Find the preauthorization.
Json::Value const resp = acct_objs (gw, jss::deposit_preauth);
BEAST_EXPECT (acct_objs_is_size (resp, 1));
auto const& preauth = resp[jss::result][jss::account_objects][0u];
BEAST_EXPECT (preauth[sfAccount.jsonName] == gw.human());
BEAST_EXPECT (preauth[sfAuthorize.jsonName] == alice.human());
}
{
// gw creates an escrow that we can look for in the ledger.
Json::Value jvEscrow;
@@ -485,7 +498,7 @@ public:
auto const& ticket = resp[jss::result][jss::account_objects][0u];
BEAST_EXPECT (ticket[sfAccount.jsonName] == gw.human());
BEAST_EXPECT (ticket[sfLedgerEntryType.jsonName] == "Ticket");
BEAST_EXPECT (ticket[sfSequence.jsonName].asUInt() == 8);
BEAST_EXPECT (ticket[sfSequence.jsonName].asUInt() == 9);
}
// Run up the number of directory entries so gw has two
// directory nodes.