From fde9fe1010b0da4e7bc161ba5e212aa12cf87665 Mon Sep 17 00:00:00 2001 From: Steven Roose Date: Tue, 19 Mar 2019 19:50:34 +0000 Subject: [PATCH] Add basic issuance boilerplate --- src/blind.cpp | 17 +++++++++++++++++ src/blind.h | 2 ++ src/primitives/transaction.cpp | 2 ++ src/primitives/transaction.h | 34 ++++++++++++++++++++++------------ 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/src/blind.cpp b/src/blind.cpp index 5909452784..52b53bc453 100644 --- a/src/blind.cpp +++ b/src/blind.cpp @@ -188,3 +188,20 @@ void CreateValueCommitment(CConfidentialValue& conf_value, secp256k1_pedersen_co secp256k1_pedersen_commitment_serialize(secp256k1_blind_context, conf_value.vchCommitment.data(), &value_commit); assert(conf_value.IsValid()); } + +size_t GetNumIssuances(const CTransaction& tx) +{ + unsigned int num_issuances = 0; + for (unsigned int i = 0; i < tx.vin.size(); i++) { + if (!tx.vin[i].assetIssuance.IsNull()) { + if (!tx.vin[i].assetIssuance.nAmount.IsNull()) { + num_issuances++; + } + if (!tx.vin[i].assetIssuance.nInflationKeys.IsNull()) { + num_issuances++; + } + } + } + return num_issuances; +} + diff --git a/src/blind.h b/src/blind.h index e54ce56362..e15e420ca9 100644 --- a/src/blind.h +++ b/src/blind.h @@ -35,4 +35,6 @@ void BlindAsset(CConfidentialAsset& conf_asset, secp256k1_generator& asset_gen, void CreateValueCommitment(CConfidentialValue& conf_value, secp256k1_pedersen_commitment& value_commit, const unsigned char* value_blindptr, const secp256k1_generator& asset_gen, const CAmount amount); +size_t GetNumIssuances(const CTransaction& tx); + #endif //BITCOIN_WALLET_BLIND_H diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp index d5c677de09..e22803e19f 100644 --- a/src/primitives/transaction.cpp +++ b/src/primitives/transaction.cpp @@ -41,6 +41,8 @@ std::string CTxIn::ToString() const str += strprintf(", scriptSig=%s", HexStr(scriptSig).substr(0, 24)); if (nSequence != SEQUENCE_FINAL) str += strprintf(", nSequence=%u", nSequence); + if (!assetIssuance.IsNull()) + str += strprintf(", %s", assetIssuance.ToString()); str += ")"; return str; } diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index 687682abb2..60797c4324 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -11,6 +11,7 @@ #include