1#include <test/jtx/xchain_bridge.h>
3#include <test/jtx/Account.h>
4#include <test/jtx/Env.h>
5#include <test/jtx/amount.h>
6#include <test/jtx/attester.h>
7#include <test/jtx/multisign.h>
9#include <xrpl/basics/strHex.h>
10#include <xrpl/json/json_value.h>
11#include <xrpl/protocol/AccountID.h>
12#include <xrpl/protocol/Feature.h>
13#include <xrpl/protocol/Issue.h>
14#include <xrpl/protocol/KeyType.h>
15#include <xrpl/protocol/SField.h>
16#include <xrpl/protocol/STAmount.h>
17#include <xrpl/protocol/STBase.h>
18#include <xrpl/protocol/STInteger.h>
19#include <xrpl/protocol/jss.h>
33 Account const& lockingChainDoor,
34 Issue const& lockingChainIssue,
35 Account const& issuingChainDoor,
36 Issue const& issuingChainIssue)
39 jv[jss::LockingChainDoor] = lockingChainDoor.
human();
40 jv[jss::LockingChainIssue] =
toJson(lockingChainIssue);
41 jv[jss::IssuingChainDoor] = issuingChainDoor.
human();
42 jv[jss::IssuingChainIssue] =
toJson(issuingChainIssue);
49 Account const& lockingChainDoor,
50 Issue const& lockingChainIssue,
51 Account const& issuingChainDoor,
52 Issue const& issuingChainIssue)
55 jv[jss::LockingChainDoor] = lockingChainDoor.
human();
56 jv[jss::LockingChainIssue] =
toJson(lockingChainIssue);
57 jv[jss::IssuingChainDoor] = issuingChainDoor.
human();
58 jv[jss::IssuingChainIssue] =
toJson(issuingChainIssue);
71 jv[jss::Account] = acc.
human();
72 jv[sfXChainBridge.getJsonName()] =
bridge;
76 jv[sfMinAccountCreateAmount.getJsonName()] =
80 jv[jss::TransactionType] = jss::XChainCreateBridge;
93 jv[jss::Account] = acc.
human();
94 jv[sfXChainBridge.getJsonName()] =
bridge;
99 jv[sfMinAccountCreateAmount.getJsonName()] =
103 jv[jss::TransactionType] = jss::XChainModifyBridge;
112 Account const& otherChainSource)
116 jv[jss::Account] = acc.
human();
117 jv[sfXChainBridge.getJsonName()] =
bridge;
119 jv[sfOtherChainSource.getJsonName()] = otherChainSource.
human();
121 jv[jss::TransactionType] = jss::XChainCreateClaimID;
135 jv[jss::Account] = acc.
human();
136 jv[sfXChainBridge.getJsonName()] =
bridge;
137 jv[sfXChainClaimID.getJsonName()] = claimID;
140 jv[sfOtherChainDestination.getJsonName()] = dst->human();
142 jv[jss::TransactionType] = jss::XChainCommit;
156 jv[sfAccount.getJsonName()] = acc.
human();
157 jv[sfXChainBridge.getJsonName()] =
bridge;
158 jv[sfXChainClaimID.getJsonName()] = claimID;
159 jv[sfDestination.getJsonName()] = dst.
human();
162 jv[jss::TransactionType] = jss::XChainClaim;
176 jv[sfAccount.getJsonName()] = acc.
human();
177 jv[sfXChainBridge.getJsonName()] =
bridge;
178 jv[sfDestination.getJsonName()] = dst.
human();
182 jv[jss::TransactionType] = jss::XChainAccountCreateCommit;
193 bool wasLockingChainSend,
215 result[sfAccount.getJsonName()] = submittingAccount.
human();
216 result[sfXChainBridge.getJsonName()] = jvBridge;
218 result[sfAttestationSignerAccount.getJsonName()] = signer.
account.
human();
219 result[sfPublicKey.getJsonName()] =
strHex(pk.slice());
220 result[sfSignature.getJsonName()] =
strHex(sig);
221 result[sfOtherChainSource.getJsonName()] =
toBase58(sendingAccount);
223 result[sfAttestationRewardAccount.getJsonName()] =
toBase58(rewardAccount);
224 result[sfWasLockingChainSend.getJsonName()] = wasLockingChainSend ? 1 : 0;
228 result[sfDestination.getJsonName()] =
toBase58(*dst);
230 result[jss::TransactionType] = jss::XChainAddClaimAttestation;
243 bool wasLockingChainSend,
266 result[sfAccount.getJsonName()] = submittingAccount.
human();
267 result[sfXChainBridge.getJsonName()] = jvBridge;
269 result[sfAttestationSignerAccount.getJsonName()] = signer.
account.
human();
270 result[sfPublicKey.getJsonName()] =
strHex(pk.slice());
271 result[sfSignature.getJsonName()] =
strHex(sig);
272 result[sfOtherChainSource.getJsonName()] =
toBase58(sendingAccount);
274 result[sfAttestationRewardAccount.getJsonName()] =
toBase58(rewardAccount);
275 result[sfWasLockingChainSend.getJsonName()] = wasLockingChainSend ? 1 : 0;
277 result[sfXChainAccountCreateCount.getJsonName()] =
279 result[sfDestination.getJsonName()] =
toBase58(dst);
282 result[jss::TransactionType] = jss::XChainAddAccountCreateAttestation;
294 bool wasLockingChainSend,
301 assert(fromIdx + numAtts <= rewardAccounts.
size());
302 assert(fromIdx + numAtts <=
signers.size());
305 for (
auto i = fromIdx; i < fromIdx + numAtts; ++i)
329 bool wasLockingChainSend,
336 assert(fromIdx + numAtts <= rewardAccounts.
size());
337 assert(fromIdx + numAtts <=
signers.size());
340 for (
auto i = fromIdx; i < fromIdx + numAtts; ++i)
390 for (
int i = 0; i < kNumSigners; ++i)
403 for (
int i = 0; i < kNumSigners; ++i)
423 std::vector<Account> r;
425 for (
int i = 0, e =
signers.size(); i != e; ++i)
427 using namespace std::literals;
436 , tinyReward(
drops(37))
439 , tinyRewardRemainder(
443 , xrpDust(
divide(oneXrp, STAmount(10000), oneXrp.get<Issue>()))
UInt size() const
Number of values in array or object.
A currency issued by an account.
json::Value getJson(JsonOptions=JsonOptions::Values::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 kMaster
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)
T emplace_back(T... args)
Buffer signClaimAttestation(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)
std::vector< json::Value > JValueVec
json::Value sidechainXchainAccountCreate(Account const &acc, json::Value const &bridge, Account const &dst, AnyAmount const &amt, AnyAmount const &reward)
json::Value bridgeRpc(Account const &lockingChainDoor, Issue const &lockingChainIssue, Account const &issuingChainDoor, Issue const &issuingChainIssue)
XrpT const XRP
Converts to XRP Issue or STAmount.
json::Value xchainCommit(Account const &acc, json::Value const &bridge, std::uint32_t claimID, AnyAmount const &amt, std::optional< Account > const &dst)
FeatureBitset testableAmendments()
json::Value bridgeCreate(Account const &acc, json::Value const &bridge, STAmount const &reward, std::optional< STAmount > const &minAccountCreate)
json::Value bridge(Account const &lockingChainDoor, Issue const &lockingChainIssue, Account const &issuingChainDoor, Issue const &issuingChainIssue)
constexpr std::size_t kUtXchainDefaultNumSigners
JValueVec claimAttestations(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)
Buffer signCreateAccountAttestation(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 claimAttestation(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 createAccountAttestation(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)
json::Value xchainClaim(Account const &acc, json::Value const &bridge, std::uint32_t claimID, AnyAmount const &amt, Account const &dst)
constexpr std::size_t kUtXchainDefaultQuorum
PrettyAmount drops(Integer i)
Returns an XRP PrettyAmount, which is trivially convertible to STAmount.
json::Value bridgeModify(Account const &acc, json::Value const &bridge, std::optional< STAmount > const &reward, std::optional< STAmount > const &minAccountCreate)
json::Value xchainCreateClaimId(Account const &acc, json::Value const &bridge, STAmount const &reward, Account const &otherChainSource)
json::Value signers(Account const &account, std::uint32_t quorum, std::vector< Signer > const &v)
JValueVec createAccountAttestations(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)
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.
STInteger< std::uint64_t > STUInt64
json::Value toJson(Asset const &asset)
STAmount multiply(STAmount const &amount, Number const &frac, Number::RoundingMode rm)
std::uint64_t claimID(json::Value const &jvb)
Amount specifier with an option for any issuer.
A signer in a SignerList.
void createBridgeObjects(Env &mcEnv, Env &scEnv)
void createMcBridgeObjects(Env &mcEnv)
FeatureBitset const features
void createScBridgeObjects(Env &scEnv)
std::vector< Signer > const signers
json::Value const jvXRPBridgeRPC