1#include <test/jtx/Env.h>
2#include <test/jtx/attester.h>
3#include <test/jtx/xchain_bridge.h>
5#include <xrpl/json/json_value.h>
6#include <xrpl/protocol/Issue.h>
7#include <xrpl/protocol/SField.h>
8#include <xrpl/protocol/STBase.h>
9#include <xrpl/protocol/STInteger.h>
10#include <xrpl/protocol/STObject.h>
11#include <xrpl/protocol/TxFlags.h>
12#include <xrpl/protocol/XChainAttestations.h>
13#include <xrpl/protocol/jss.h>
22 Account const& lockingChainDoor,
23 Issue const& lockingChainIssue,
24 Account const& issuingChainDoor,
25 Issue const& issuingChainIssue)
28 jv[jss::LockingChainDoor] = lockingChainDoor.
human();
29 jv[jss::LockingChainIssue] =
to_json(lockingChainIssue);
30 jv[jss::IssuingChainDoor] = issuingChainDoor.
human();
31 jv[jss::IssuingChainIssue] =
to_json(issuingChainIssue);
38 Account const& lockingChainDoor,
39 Issue const& lockingChainIssue,
40 Account const& issuingChainDoor,
41 Issue const& issuingChainIssue)
44 jv[jss::LockingChainDoor] = lockingChainDoor.
human();
45 jv[jss::LockingChainIssue] =
to_json(lockingChainIssue);
46 jv[jss::IssuingChainDoor] = issuingChainDoor.
human();
47 jv[jss::IssuingChainIssue] =
to_json(issuingChainIssue);
60 jv[jss::Account] = acc.
human();
61 jv[sfXChainBridge.getJsonName()] =
bridge;
64 jv[sfMinAccountCreateAmount.getJsonName()] = minAccountCreate->getJson(
JsonOptions::none);
66 jv[jss::TransactionType] = jss::XChainCreateBridge;
79 jv[jss::Account] = acc.
human();
80 jv[sfXChainBridge.getJsonName()] =
bridge;
84 jv[sfMinAccountCreateAmount.getJsonName()] = minAccountCreate->getJson(
JsonOptions::none);
86 jv[jss::TransactionType] = jss::XChainModifyBridge;
95 Account const& otherChainSource)
99 jv[jss::Account] = acc.
human();
100 jv[sfXChainBridge.getJsonName()] =
bridge;
102 jv[sfOtherChainSource.getJsonName()] = otherChainSource.
human();
104 jv[jss::TransactionType] = jss::XChainCreateClaimID;
118 jv[jss::Account] = acc.
human();
119 jv[sfXChainBridge.getJsonName()] =
bridge;
120 jv[sfXChainClaimID.getJsonName()] = claimID;
123 jv[sfOtherChainDestination.getJsonName()] = dst->human();
125 jv[jss::TransactionType] = jss::XChainCommit;
139 jv[sfAccount.getJsonName()] = acc.
human();
140 jv[sfXChainBridge.getJsonName()] =
bridge;
141 jv[sfXChainClaimID.getJsonName()] = claimID;
142 jv[sfDestination.getJsonName()] = dst.
human();
145 jv[jss::TransactionType] = jss::XChainClaim;
159 jv[sfAccount.getJsonName()] = acc.
human();
160 jv[sfXChainBridge.getJsonName()] =
bridge;
161 jv[sfDestination.getJsonName()] = dst.
human();
165 jv[jss::TransactionType] = jss::XChainAccountCreateCommit;
176 bool wasLockingChainSend,
186 pk, sk, stBridge, sendingAccount, sendingAmount.
value, rewardAccount, wasLockingChainSend, claimID, dst);
190 result[sfAccount.getJsonName()] = submittingAccount.
human();
191 result[sfXChainBridge.getJsonName()] = jvBridge;
194 result[sfPublicKey.getJsonName()] =
strHex(pk.slice());
195 result[sfSignature.getJsonName()] =
strHex(
sig);
196 result[sfOtherChainSource.getJsonName()] =
toBase58(sendingAccount);
198 result[sfAttestationRewardAccount.getJsonName()] =
toBase58(rewardAccount);
199 result[sfWasLockingChainSend.getJsonName()] = wasLockingChainSend ? 1 : 0;
203 result[sfDestination.getJsonName()] =
toBase58(*dst);
205 result[jss::TransactionType] = jss::XChainAddClaimAttestation;
218 bool wasLockingChainSend,
241 result[sfAccount.getJsonName()] = submittingAccount.
human();
242 result[sfXChainBridge.getJsonName()] = jvBridge;
245 result[sfPublicKey.getJsonName()] =
strHex(pk.slice());
246 result[sfSignature.getJsonName()] =
strHex(
sig);
247 result[sfOtherChainSource.getJsonName()] =
toBase58(sendingAccount);
249 result[sfAttestationRewardAccount.getJsonName()] =
toBase58(rewardAccount);
250 result[sfWasLockingChainSend.getJsonName()] = wasLockingChainSend ? 1 : 0;
253 result[sfDestination.getJsonName()] =
toBase58(dst);
256 result[jss::TransactionType] = jss::XChainAddAccountCreateAttestation;
268 bool wasLockingChainSend,
275 assert(fromIdx + numAtts <= rewardAccounts.
size());
279 for (
auto i = fromIdx; i < fromIdx + numAtts; ++i)
301 bool wasLockingChainSend,
308 assert(fromIdx + numAtts <= rewardAccounts.
size());
312 for (
auto i = fromIdx; i < fromIdx + numAtts; ++i)
338 , scAttester(
"scAttester")
339 , scReward(
"scReward")
341 , mcuAlice(
"mcuAlice")
343 , mcuCarol(
"mcuCarol")
346 , scuAlice(
"scuAlice")
348 , scuCarol(
"scuCarol")
360 for (
int i = 0; i < numSigners; ++i)
372 for (
int i = 0; i < numSigners; ++i)
404 , tiny_reward(
drops(37))
406 , tiny_reward_remainder(
409 , 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.
SecretKey const & sk() const
Return the secret key.
std::string const & human() const
Returns the human readable public key.
PublicKey const & pk() const
Return the public key.
static Account const master
The master account.
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)
Json::Value sidechain_xchain_account_create(Account const &acc, Json::Value const &bridge, Account const &dst, AnyAmount const &amt, AnyAmount const &reward)
constexpr std::size_t UT_XCHAIN_DEFAULT_NUM_SIGNERS
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 bridge_create(Account const &acc, Json::Value const &bridge, STAmount const &reward, std::optional< STAmount > const &minAccountCreate)
Json::Value signers(Account const &account, std::uint32_t quorum, std::vector< signer > const &v)
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_rpc(Account const &lockingChainDoor, Issue const &lockingChainIssue, Account const &issuingChainDoor, Issue const &issuingChainIssue)
Json::Value xchain_claim(Account const &acc, Json::Value const &bridge, std::uint32_t claimID, AnyAmount const &amt, Account const &dst)
XRP_t const XRP
Converts to XRP Issue or STAmount.
Json::Value bridge_modify(Account const &acc, Json::Value const &bridge, std::optional< STAmount > const &reward, std::optional< STAmount > const &minAccountCreate)
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)
FeatureBitset testable_amendments()
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)
Json::Value xchain_commit(Account const &acc, Json::Value const &bridge, std::uint32_t claimID, AnyAmount const &amt, std::optional< Account > const &dst)
Json::Value bridge(Account const &lockingChainDoor, Issue const &lockingChainIssue, Account const &issuingChainDoor, Issue const &issuingChainIssue)
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)
constexpr std::size_t UT_XCHAIN_DEFAULT_QUORUM
PrettyAmount drops(Integer i)
Returns an XRP PrettyAmount, which is trivially convertible to STAmount.
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)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
STAmount divide(STAmount const &amount, Rate const &rate)
Issue const & xrpIssue()
Returns an asset specifier that represents XRP.
std::string strHex(FwdIt begin, FwdIt end)
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
STAmount multiply(STAmount const &amount, Rate const &rate)
Json::Value to_json(Asset const &asset)
Amount specifier with an option for any issuer.
void createBridgeObjects(Env &mcEnv, Env &scEnv)
std::vector< signer > const signers
void createMcBridgeObjects(Env &mcEnv)
void createScBridgeObjects(Env &scEnv)
A signer in a SignerList.