xrpld
Loading...
Searching...
No Matches
sig.cpp
1#include <test/jtx/sig.h>
2
3#include <test/jtx/Env.h>
4#include <test/jtx/JTx.h>
5#include <test/jtx/utility.h>
6
7#include <xrpl/protocol/Sign.h>
8
9namespace xrpl::test::jtx {
10
11void
13{
14 if (!manual_)
15 return;
16 if (subField_ == nullptr)
17 jt.fillSig = false;
18 if (account_)
19 {
20 // VFALCO Inefficient pre-C++14
21 auto const account = *account_;
22 auto callback = [subField = subField_, account](Env& env, JTx& jtx) {
23 // Where to put the signature. Supports sfCounterPartySignature and sfSponsorSignature.
24 auto& sigObject = subField ? jtx[*subField] : jtx.jv;
25
27 jtx.jv,
28 account,
29 sigObject,
30 signingPrefix(jtx::signatureRole(subField), false, env.current()->rules()));
31 };
32 if (subField_ == nullptr)
33 {
34 jt.mainSigners.emplace_back(callback);
35 }
36 else
37 {
38 jt.postSigners.emplace_back(callback);
39 }
40 }
41}
42
43} // namespace xrpl::test::jtx
A transaction testing environment.
Definition Env.h:161
std::optional< Account > account_
Account that will generate the signature.
Definition sig.h:34
SField const *const subField_
Alternative transaction object field in which to place the signature.
Definition sig.h:27
void operator()(Env &, JTx &jt) const
Definition sig.cpp:12
void sign(json::Value &jv, Account const &account, json::Value &sigObject, HashPrefix prefix)
Sign automatically into a specific Json field of the jv object.
Definition utility.cpp:52
SignatureRole signatureRole(SField const *subField)
The role that signs into an optional signature subfield.
Definition utility.cpp:42
HashPrefix signingPrefix(SignatureRole role, bool multiSigning, Rules const &rules)
The hash prefix that binds a transaction signature to the role that made it.
Execution context for applying a JSON transaction.
Definition JTx.h:27
std::vector< std::function< void(Env &, JTx &)> > postSigners
Definition JTx.h:42
std::vector< std::function< void(Env &, JTx &)> > mainSigners
Definition JTx.h:39