20#include <test/jtx/Env.h>
21#include <test/jtx/attester.h>
22#include <test/jtx/xchain_bridge.h>
23#include <xrpl/json/json_value.h>
24#include <xrpl/protocol/Issue.h>
25#include <xrpl/protocol/SField.h>
26#include <xrpl/protocol/STBase.h>
27#include <xrpl/protocol/STInteger.h>
28#include <xrpl/protocol/STObject.h>
29#include <xrpl/protocol/TxFlags.h>
30#include <xrpl/protocol/XChainAttestations.h>
31#include <xrpl/protocol/jss.h>
40 Account const& lockingChainDoor,
41 Issue const& lockingChainIssue,
42 Account const& issuingChainDoor,
43 Issue const& issuingChainIssue)
46 jv[sfLockingChainDoor.getJsonName()] = lockingChainDoor.
human();
47 jv[sfLockingChainIssue.getJsonName()] =
to_json(lockingChainIssue);
48 jv[sfIssuingChainDoor.getJsonName()] = issuingChainDoor.
human();
49 jv[sfIssuingChainIssue.getJsonName()] =
to_json(issuingChainIssue);
56 Account const& lockingChainDoor,
57 Issue const& lockingChainIssue,
58 Account const& issuingChainDoor,
59 Issue const& issuingChainIssue)
62 jv[sfLockingChainDoor.getJsonName()] = lockingChainDoor.
human();
63 jv[sfLockingChainIssue.getJsonName()] =
to_json(lockingChainIssue);
64 jv[sfIssuingChainDoor.getJsonName()] = issuingChainDoor.
human();
65 jv[sfIssuingChainIssue.getJsonName()] =
to_json(issuingChainIssue);
78 jv[jss::Account] = acc.
human();
79 jv[sfXChainBridge.getJsonName()] =
bridge;
82 jv[sfMinAccountCreateAmount.getJsonName()] =
85 jv[jss::TransactionType] = jss::XChainCreateBridge;
99 jv[jss::Account] = acc.
human();
100 jv[sfXChainBridge.getJsonName()] =
bridge;
102 jv[sfSignatureReward.getJsonName()] =
104 if (minAccountCreate)
105 jv[sfMinAccountCreateAmount.getJsonName()] =
108 jv[jss::TransactionType] = jss::XChainModifyBridge;
118 Account const& otherChainSource)
122 jv[jss::Account] = acc.
human();
123 jv[sfXChainBridge.getJsonName()] =
bridge;
125 jv[sfOtherChainSource.getJsonName()] = otherChainSource.
human();
127 jv[jss::TransactionType] = jss::XChainCreateClaimID;
142 jv[jss::Account] = acc.
human();
143 jv[sfXChainBridge.getJsonName()] =
bridge;
144 jv[sfXChainClaimID.getJsonName()] = claimID;
147 jv[sfOtherChainDestination.getJsonName()] = dst->human();
149 jv[jss::TransactionType] = jss::XChainCommit;
164 jv[sfAccount.getJsonName()] = acc.
human();
165 jv[sfXChainBridge.getJsonName()] =
bridge;
166 jv[sfXChainClaimID.getJsonName()] = claimID;
167 jv[sfDestination.getJsonName()] = dst.
human();
170 jv[jss::TransactionType] = jss::XChainClaim;
185 jv[sfAccount.getJsonName()] = acc.
human();
186 jv[sfXChainBridge.getJsonName()] =
bridge;
187 jv[sfDestination.getJsonName()] = dst.
human();
189 jv[sfSignatureReward.getJsonName()] =
192 jv[jss::TransactionType] = jss::XChainAccountCreateCommit;
204 bool wasLockingChainSend,
226 result[sfAccount.getJsonName()] = submittingAccount.
human();
227 result[sfXChainBridge.getJsonName()] = jvBridge;
230 result[sfPublicKey.getJsonName()] =
strHex(pk.slice());
231 result[sfSignature.getJsonName()] =
strHex(
sig);
232 result[sfOtherChainSource.getJsonName()] =
toBase58(sendingAccount);
233 result[sfAmount.getJsonName()] =
235 result[sfAttestationRewardAccount.getJsonName()] =
toBase58(rewardAccount);
236 result[sfWasLockingChainSend.getJsonName()] = wasLockingChainSend ? 1 : 0;
238 result[sfXChainClaimID.getJsonName()] =
241 result[sfDestination.getJsonName()] =
toBase58(*dst);
243 result[jss::TransactionType] = jss::XChainAddClaimAttestation;
257 bool wasLockingChainSend,
280 result[sfAccount.getJsonName()] = submittingAccount.
human();
281 result[sfXChainBridge.getJsonName()] = jvBridge;
284 result[sfPublicKey.getJsonName()] =
strHex(pk.slice());
285 result[sfSignature.getJsonName()] =
strHex(
sig);
286 result[sfOtherChainSource.getJsonName()] =
toBase58(sendingAccount);
287 result[sfAmount.getJsonName()] =
289 result[sfAttestationRewardAccount.getJsonName()] =
toBase58(rewardAccount);
290 result[sfWasLockingChainSend.getJsonName()] = wasLockingChainSend ? 1 : 0;
292 result[sfXChainAccountCreateCount.getJsonName()] =
294 result[sfDestination.getJsonName()] =
toBase58(dst);
295 result[sfSignatureReward.getJsonName()] =
298 result[jss::TransactionType] = jss::XChainAddAccountCreateAttestation;
311 bool wasLockingChainSend,
318 assert(fromIdx + numAtts <= rewardAccounts.size());
322 for (
auto i = fromIdx; i < fromIdx + numAtts; ++i)
344 bool wasLockingChainSend,
351 assert(fromIdx + numAtts <= rewardAccounts.size());
355 for (
auto i = fromIdx; i < fromIdx + numAtts; ++i)
381 , scAttester(
"scAttester")
382 , scReward(
"scReward")
384 , mcuAlice(
"mcuAlice")
386 , mcuCarol(
"mcuCarol")
389 , scuAlice(
"scuAlice")
391 , scuCarol(
"scuCarol")
404 for (
int i = 0; i < numSigners; ++i)
406 using namespace std::literals;
418 for (
int i = 0; i < numSigners; ++i)
420 using namespace std::literals;
433 r.push_back(scReward);
442 using namespace std::literals;
443 auto const a = Account(
"reward_"s + std::to_string(i));
450 , split_reward_quorum(
452 , split_reward_everyone(
divide(
456 , tiny_reward(
drops(37))
457 , tiny_reward_split((
divide(
460 tiny_reward.issue())))
461 , tiny_reward_remainder(
466 tiny_reward.issue()))
468 , xrp_dust(
divide(one_xrp, STAmount(10000), one_xrp.issue()))
UInt size() const
Number of values in array or object.
A currency issued by an account.
Json::Value getJson(JsonOptions) const override
Immutable cryptographic account descriptor.
PublicKey const & pk() const
Return the public key.
static Account const master
The master account.
SecretKey const & sk() const
Return the secret key.
std::string const & human() const
Returns the human readable public key.
A transaction testing environment.
bool close(NetClock::time_point closeTime, std::optional< std::chrono::milliseconds > consensusDelay=std::nullopt)
Close and advance the ledger.
void fund(bool setDefaultRipple, STAmount const &amount, Account const &account)
Set the regular signature on a JTx.
T emplace_back(T... args)
constexpr std::size_t UT_XCHAIN_DEFAULT_QUORUM
Json::Value create_account_attestation(jtx::Account const &submittingAccount, Json::Value const &jvBridge, jtx::Account const &sendingAccount, jtx::AnyAmount const &sendingAmount, jtx::AnyAmount const &rewardAmount, jtx::Account const &rewardAccount, bool wasLockingChainSend, std::uint64_t createCount, jtx::Account const &dst, jtx::signer const &signer)
JValueVec claim_attestations(jtx::Account const &submittingAccount, Json::Value const &jvBridge, jtx::Account const &sendingAccount, jtx::AnyAmount const &sendingAmount, std::vector< jtx::Account > const &rewardAccounts, bool wasLockingChainSend, std::uint64_t claimID, std::optional< jtx::Account > const &dst, std::vector< jtx::signer > const &signers, std::size_t const numAtts, std::size_t const fromIdx)
Json::Value bridge_create(Account const &acc, Json::Value const &bridge, STAmount const &reward, std::optional< STAmount > const &minAccountCreate)
Json::Value claim_attestation(jtx::Account const &submittingAccount, Json::Value const &jvBridge, jtx::Account const &sendingAccount, jtx::AnyAmount const &sendingAmount, jtx::Account const &rewardAccount, bool wasLockingChainSend, std::uint64_t claimID, std::optional< jtx::Account > const &dst, jtx::signer const &signer)
Json::Value bridge(Account const &lockingChainDoor, Issue const &lockingChainIssue, Account const &issuingChainDoor, Issue const &issuingChainIssue)
Json::Value signers(Account const &account, std::uint32_t quorum, std::vector< signer > const &v)
PrettyAmount drops(Integer i)
Returns an XRP PrettyAmount, which is trivially convertible to STAmount.
Json::Value sidechain_xchain_account_create(Account const &acc, Json::Value const &bridge, Account const &dst, AnyAmount const &amt, AnyAmount const &reward)
Json::Value xchain_claim(Account const &acc, Json::Value const &bridge, std::uint32_t claimID, AnyAmount const &amt, Account const &dst)
constexpr std::size_t UT_XCHAIN_DEFAULT_NUM_SIGNERS
JValueVec create_account_attestations(jtx::Account const &submittingAccount, Json::Value const &jvBridge, jtx::Account const &sendingAccount, jtx::AnyAmount const &sendingAmount, jtx::AnyAmount const &rewardAmount, std::vector< jtx::Account > const &rewardAccounts, bool wasLockingChainSend, std::uint64_t createCount, jtx::Account const &dst, std::vector< jtx::signer > const &signers, std::size_t const numAtts, std::size_t const fromIdx)
Json::Value xchain_create_claim_id(Account const &acc, Json::Value const &bridge, STAmount const &reward, Account const &otherChainSource)
Json::Value bridge_modify(Account const &acc, Json::Value const &bridge, std::optional< STAmount > const &reward, std::optional< STAmount > const &minAccountCreate)
Buffer sign_claim_attestation(PublicKey const &pk, SecretKey const &sk, STXChainBridge const &bridge, AccountID const &sendingAccount, STAmount const &sendingAmount, AccountID const &rewardAccount, bool wasLockingChainSend, std::uint64_t claimID, std::optional< AccountID > const &dst)
Json::Value xchain_commit(Account const &acc, Json::Value const &bridge, std::uint32_t claimID, AnyAmount const &amt, std::optional< Account > const &dst)
Buffer sign_create_account_attestation(PublicKey const &pk, SecretKey const &sk, STXChainBridge const &bridge, AccountID const &sendingAccount, STAmount const &sendingAmount, STAmount const &rewardAmount, AccountID const &rewardAccount, bool wasLockingChainSend, std::uint64_t createCount, AccountID const &dst)
XRP_t const XRP
Converts to XRP Issue or STAmount.
FeatureBitset supported_amendments()
Json::Value bridge_rpc(Account const &lockingChainDoor, Issue const &lockingChainIssue, Account const &issuingChainDoor, Issue const &issuingChainIssue)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Issue const & xrpIssue()
Returns an asset specifier that represents XRP.
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
STAmount divide(STAmount const &amount, Rate const &rate)
STAmount multiply(STAmount const &amount, Rate const &rate)
Json::Value to_json(Asset const &asset)
std::string strHex(FwdIt begin, FwdIt end)
constexpr std::uint32_t tfUniversal
Amount specifier with an option for any issuer.
void createScBridgeObjects(Env &scEnv)
void createMcBridgeObjects(Env &mcEnv)
std::vector< signer > const signers
void createBridgeObjects(Env &mcEnv, Env &scEnv)
A signer in a SignerList.