Skip to content

Commit

Permalink
Transaction bridge: add helper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
marta-lokhova committed May 6, 2020
1 parent ac054cf commit 6f2c25d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/transactions/TransactionBridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,39 @@ getSignatures(TransactionEnvelope& env)
}
}

xdr::xvector<DecoratedSignature, 20>&
getSignaturesInner(TransactionEnvelope& env)
{
switch (env.type())
{
case ENVELOPE_TYPE_TX_V0:
return env.v0().signatures;
case ENVELOPE_TYPE_TX:
return env.v1().signatures;
case ENVELOPE_TYPE_TX_FEE_BUMP:
return env.feeBump().tx.innerTx.v1().signatures;
default:
abort();
}
}

xdr::xvector<Operation, MAX_OPS_PER_TX>&
getOperations(TransactionEnvelope& env)
{
switch (env.type())
{
case ENVELOPE_TYPE_TX_V0:
return env.v0().tx.operations;
case ENVELOPE_TYPE_TX:
return env.v1().tx.operations;
case ENVELOPE_TYPE_TX_FEE_BUMP:
assert(env.feeBump().tx.innerTx.type() == ENVELOPE_TYPE_TX);
return env.feeBump().tx.innerTx.v1().tx.operations;
default:
abort();
}
}

#ifdef BUILD_TESTS
xdr::xvector<DecoratedSignature, 20>&
getSignatures(TransactionFramePtr tx)
Expand Down
4 changes: 4 additions & 0 deletions src/transactions/TransactionBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ namespace txbridge
TransactionEnvelope convertForV13(TransactionEnvelope const& input);

xdr::xvector<DecoratedSignature, 20>& getSignatures(TransactionEnvelope& env);
xdr::xvector<DecoratedSignature, 20>&
getSignaturesInner(TransactionEnvelope& env);
xdr::xvector<Operation, MAX_OPS_PER_TX>&
getOperations(TransactionEnvelope& env);

#ifdef BUILD_TESTS
xdr::xvector<DecoratedSignature, 20>& getSignatures(TransactionFramePtr tx);
Expand Down

0 comments on commit 6f2c25d

Please sign in to comment.