diff --git a/src/blind.cpp b/src/blind.cpp index 0cb30a41c0..e9db1a034f 100644 --- a/src/blind.cpp +++ b/src/blind.cpp @@ -206,28 +206,12 @@ void CreateValueCommitment(CConfidentialValue& conf_value, secp256k1_pedersen_co 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; -} - int BlindTransaction(std::vector& input_value_blinding_factors, const std::vector& input_asset_blinding_factors, const std::vector& input_assets, const std::vector& input_amounts, std::vector& out_val_blind_factors, std::vector& out_asset_blind_factors, const std::vector& output_pubkeys, const std::vector& issuance_blinding_privkey, const std::vector& token_blinding_privkey, CMutableTransaction& tx, std::vector >* auxiliary_generators) { // Sanity check input data and output_pubkey size, clear other output data assert(tx.vout.size() >= output_pubkeys.size()); - assert(tx.vin.size()+GetNumIssuances(CTransaction(tx)) >= issuance_blinding_privkey.size()); - assert(tx.vin.size()+GetNumIssuances(CTransaction(tx)) >= token_blinding_privkey.size()); + assert(tx.vin.size() >= issuance_blinding_privkey.size()); + assert(tx.vin.size() >= token_blinding_privkey.size()); out_val_blind_factors.clear(); out_val_blind_factors.resize(tx.vout.size()); out_asset_blind_factors.clear(); diff --git a/src/blind.h b/src/blind.h index 650f933a27..4d9bb67c68 100644 --- a/src/blind.h +++ b/src/blind.h @@ -61,6 +61,4 @@ int BlindTransaction(std::vector& input_value_blinding_factors, const */ void RawFillBlinds(CMutableTransaction& tx, std::vector& output_value_blinds, std::vector& output_asset_blinds, std::vector& output_pubkeys); -size_t GetNumIssuances(const CTransaction& tx); - #endif //BITCOIN_BLIND_H diff --git a/src/issuance.cpp b/src/issuance.cpp index abf7061032..cba4432558 100644 --- a/src/issuance.cpp +++ b/src/issuance.cpp @@ -4,6 +4,22 @@ #include #include +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; +} + void GenerateAssetEntropy(uint256& entropy, const COutPoint& prevout, const uint256& contracthash) { // E : entropy diff --git a/src/issuance.h b/src/issuance.h index b64ec8b75a..709416e68a 100644 --- a/src/issuance.h +++ b/src/issuance.h @@ -7,6 +7,11 @@ #include #include +/** + * Get the number of issuances in the given transaction. + */ +size_t GetNumIssuances(const CTransaction& tx); + /** * Calculate the asset entropy from an COutPoint and a tx-author specified * Ricardian contract. See Definition 18 of the confidential assets paper.