20#include <test/jtx/Env.h>
21#include <test/jtx/attester.h>
22#include <test/jtx/xchain_bridge.h>
24#include <xrpl/json/json_value.h>
25#include <xrpl/protocol/Issue.h>
26#include <xrpl/protocol/SField.h>
27#include <xrpl/protocol/STBase.h>
28#include <xrpl/protocol/STInteger.h>
29#include <xrpl/protocol/STObject.h>
30#include <xrpl/protocol/TxFlags.h>
31#include <xrpl/protocol/XChainAttestations.h>
32#include <xrpl/protocol/jss.h>
41 Account const& lockingChainDoor,
42 Issue const& lockingChainIssue,
43 Account const& issuingChainDoor,
44 Issue const& issuingChainIssue)
47 jv[sfLockingChainDoor.getJsonName()] = lockingChainDoor.
human();
48 jv[sfLockingChainIssue.getJsonName()] =
to_json(lockingChainIssue);
49 jv[sfIssuingChainDoor.getJsonName()] = issuingChainDoor.
human();
50 jv[sfIssuingChainIssue.getJsonName()] =
to_json(issuingChainIssue);
57 Account const& lockingChainDoor,
58 Issue const& lockingChainIssue,
59 Account const& issuingChainDoor,
60 Issue const& issuingChainIssue)
63 jv[sfLockingChainDoor.getJsonName()] = lockingChainDoor.
human();
64 jv[sfLockingChainIssue.getJsonName()] =
to_json(lockingChainIssue);
65 jv[sfIssuingChainDoor.getJsonName()] = issuingChainDoor.
human();
66 jv[sfIssuingChainIssue.getJsonName()] =
to_json(issuingChainIssue);
79 jv[jss::Account] = acc.
human();
80 jv[sfXChainBridge.getJsonName()] =
bridge;
83 jv[sfMinAccountCreateAmount.getJsonName()] =
86 jv[jss::TransactionType] = jss::XChainCreateBridge;
100 jv[jss::Account] = acc.
human();
101 jv[sfXChainBridge.getJsonName()] =
bridge;
103 jv[sfSignatureReward.getJsonName()] =
105 if (minAccountCreate)
106 jv[sfMinAccountCreateAmount.getJsonName()] =
109 jv[jss::TransactionType] = jss::XChainModifyBridge;
119 Account const& otherChainSource)
123 jv[jss::Account] = acc.
human();
124 jv[sfXChainBridge.getJsonName()] =
bridge;
126 jv[sfOtherChainSource.getJsonName()] = otherChainSource.
human();
128 jv[jss::TransactionType] = jss::XChainCreateClaimID;
143 jv[jss::Account] = acc.
human();
144 jv[sfXChainBridge.getJsonName()] =
bridge;
145 jv[sfXChainClaimID.getJsonName()] = claimID;
148 jv[sfOtherChainDestination.getJsonName()] = dst->human();
150 jv[jss::TransactionType] = jss::XChainCommit;
165 jv[sfAccount.getJsonName()] = acc.
human();
166 jv[sfXChainBridge.getJsonName()] =
bridge;
167 jv[sfXChainClaimID.getJsonName()] = claimID;
168 jv[sfDestination.getJsonName()] = dst.
human();
171 jv[jss::TransactionType] = jss::XChainClaim;
186 jv[sfAccount.getJsonName()] = acc.
human();
187 jv[sfXChainBridge.getJsonName()] =
bridge;
188 jv[sfDestination.getJsonName()] = dst.
human();
190 jv[sfSignatureReward.getJsonName()] =
193 jv[jss::TransactionType] = jss::XChainAccountCreateCommit;
205 bool wasLockingChainSend,
227 result[sfAccount.getJsonName()] = submittingAccount.
human();
228 result[sfXChainBridge.getJsonName()] = jvBridge;
231 result[sfPublicKey.getJsonName()] =
strHex(pk.slice());
232 result[sfSignature.getJsonName()] =
strHex(
sig);
233 result[sfOtherChainSource.getJsonName()] =
toBase58(sendingAccount);
234 result[sfAmount.getJsonName()] =
236 result[sfAttestationRewardAccount.getJsonName()] =
toBase58(rewardAccount);
237 result[sfWasLockingChainSend.getJsonName()] = wasLockingChainSend ? 1 : 0;
239 result[sfXChainClaimID.getJsonName()] =
242 result[sfDestination.getJsonName()] =
toBase58(*dst);
244 result[jss::TransactionType] = jss::XChainAddClaimAttestation;
258 bool wasLockingChainSend,
281 result[sfAccount.getJsonName()] = submittingAccount.
human();
282 result[sfXChainBridge.getJsonName()] = jvBridge;
285 result[sfPublicKey.getJsonName()] =
strHex(pk.slice());
286 result[sfSignature.getJsonName()] =
strHex(
sig);
287 result[sfOtherChainSource.getJsonName()] =
toBase58(sendingAccount);
288 result[sfAmount.getJsonName()] =
290 result[sfAttestationRewardAccount.getJsonName()] =
toBase58(rewardAccount);
291 result[sfWasLockingChainSend.getJsonName()] = wasLockingChainSend ? 1 : 0;
293 result[sfXChainAccountCreateCount.getJsonName()] =
295 result[sfDestination.getJsonName()] =
toBase58(dst);
296 result[sfSignatureReward.getJsonName()] =
299 result[jss::TransactionType] = jss::XChainAddAccountCreateAttestation;
312 bool wasLockingChainSend,
319 assert(fromIdx + numAtts <= rewardAccounts.size());
323 for (
auto i = fromIdx; i < fromIdx + numAtts; ++i)
345 bool wasLockingChainSend,
352 assert(fromIdx + numAtts <= rewardAccounts.size());
356 for (
auto i = fromIdx; i < fromIdx + numAtts; ++i)
382 , scAttester(
"scAttester")
383 , scReward(
"scReward")
385 , mcuAlice(
"mcuAlice")
387 , mcuCarol(
"mcuCarol")
390 , scuAlice(
"scuAlice")
392 , scuCarol(
"scuCarol")
405 for (
int i = 0; i < numSigners; ++i)
407 using namespace std::literals;
419 for (
int i = 0; i < numSigners; ++i)
421 using namespace std::literals;
434 r.push_back(scReward);
443 using namespace std::literals;
444 auto const a = Account(
"reward_"s + std::to_string(i));
451 , split_reward_quorum(
453 , split_reward_everyone(
divide(
457 , tiny_reward(
drops(37))
458 , tiny_reward_split((
divide(
461 tiny_reward.issue())))
462 , tiny_reward_remainder(
467 tiny_reward.issue()))
469 , 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=JsonOptions::none) 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.