diff --git a/src/gtest/test_transaction_builder.cpp b/src/gtest/test_transaction_builder.cpp index 3755dbf7f..90cfef008 100644 --- a/src/gtest/test_transaction_builder.cpp +++ b/src/gtest/test_transaction_builder.cpp @@ -5,10 +5,11 @@ #include "transaction_builder.h" #include "zcash/Address.hpp" -#include #include +#include -TEST(TransactionBuilder, Invoke) { +TEST(TransactionBuilder, Invoke) +{ SelectParams(CBaseChainParams::REGTEST); UpdateNetworkUpgradeParameters(Consensus::UPGRADE_OVERWINTER, Consensus::NetworkUpgrade::ALWAYS_ACTIVE); UpdateNetworkUpgradeParameters(Consensus::UPGRADE_SAPLING, Consensus::NetworkUpgrade::ALWAYS_ACTIVE); @@ -45,8 +46,7 @@ TEST(TransactionBuilder, Invoke) { // Prepare to spend the note that was just created auto maybe_pt = libzcash::SaplingNotePlaintext::decrypt( - tx1.vShieldedOutput[0].encCiphertext, ivk, tx1.vShieldedOutput[0].ephemeralKey - ); + tx1.vShieldedOutput[0].encCiphertext, ivk, tx1.vShieldedOutput[0].ephemeralKey); ASSERT_EQ(static_cast(maybe_pt), true); auto maybe_note = maybe_pt.get().note(ivk); ASSERT_EQ(static_cast(maybe_note), true); diff --git a/src/transaction_builder.cpp b/src/transaction_builder.cpp index 1e4d266d0..0a6add6e7 100644 --- a/src/transaction_builder.cpp +++ b/src/transaction_builder.cpp @@ -14,15 +14,14 @@ SpendDescriptionInfo::SpendDescriptionInfo( libzcash::SaplingExpandedSpendingKey xsk, libzcash::SaplingNote note, uint256 anchor, - ZCSaplingIncrementalWitness witness -) : xsk(xsk), note(note), anchor(anchor), witness(witness) + ZCSaplingIncrementalWitness witness) : xsk(xsk), note(note), anchor(anchor), witness(witness) { librustzcash_sapling_generate_r(alpha.begin()); } TransactionBuilder::TransactionBuilder( - const Consensus::Params& consensusParams, int nHeight -) : consensusParams(consensusParams), nHeight(nHeight) + const Consensus::Params& consensusParams, + int nHeight) : consensusParams(consensusParams), nHeight(nHeight) { mtx = CreateNewContextualCMutableTransaction(consensusParams, nHeight); } @@ -49,8 +48,8 @@ void TransactionBuilder::AddSaplingOutput( libzcash::SaplingFullViewingKey from, libzcash::SaplingPaymentAddress to, CAmount value, - std::array memo -) { + std::array memo) +{ auto note = libzcash::SaplingNote(to, value); outputs.emplace_back(from.ovk, note, memo); mtx.valueBalance -= value; @@ -76,19 +75,18 @@ boost::optional TransactionBuilder::Build() SpendDescription sdesc; if (!librustzcash_sapling_spend_proof( - ctx, - spend.xsk.full_viewing_key().ak.begin(), - spend.xsk.nsk.begin(), - spend.note.d.data(), - spend.note.r.begin(), - spend.alpha.begin(), - spend.note.value(), - spend.anchor.begin(), - witness.data(), - sdesc.cv.begin(), - sdesc.rk.begin(), - sdesc.zkproof.data() - )) { + ctx, + spend.xsk.full_viewing_key().ak.begin(), + spend.xsk.nsk.begin(), + spend.note.d.data(), + spend.note.r.begin(), + spend.alpha.begin(), + spend.note.value(), + spend.anchor.begin(), + witness.data(), + sdesc.cv.begin(), + sdesc.rk.begin(), + sdesc.zkproof.data())) { librustzcash_sapling_proving_ctx_free(ctx); return boost::none; } @@ -118,15 +116,14 @@ boost::optional TransactionBuilder::Build() OutputDescription odesc; if (!librustzcash_sapling_output_proof( - ctx, - encryptor.get_esk().begin(), - output.note.d.data(), - output.note.pk_d.begin(), - output.note.r.begin(), - output.note.value(), - odesc.cv.begin(), - odesc.zkproof.begin() - )) { + ctx, + encryptor.get_esk().begin(), + output.note.d.data(), + output.note.pk_d.begin(), + output.note.r.begin(), + output.note.value(), + odesc.cv.begin(), + odesc.zkproof.begin())) { librustzcash_sapling_proving_ctx_free(ctx); return boost::none; } @@ -140,8 +137,7 @@ boost::optional TransactionBuilder::Build() output.ovk, odesc.cv, odesc.cm, - encryptor - ); + encryptor); mtx.vShieldedOutput.push_back(odesc); } diff --git a/src/transaction_builder.h b/src/transaction_builder.h index 2279bae6c..30567b9e0 100644 --- a/src/transaction_builder.h +++ b/src/transaction_builder.h @@ -15,8 +15,7 @@ #include -struct SpendDescriptionInfo -{ +struct SpendDescriptionInfo { libzcash::SaplingExpandedSpendingKey xsk; libzcash::SaplingNote note; uint256 alpha; @@ -30,8 +29,7 @@ struct SpendDescriptionInfo ZCSaplingIncrementalWitness witness); }; -struct OutputDescriptionInfo -{ +struct OutputDescriptionInfo { uint256 ovk; libzcash::SaplingNote note; std::array memo;