3
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
4
5
5
#include < blind.h>
6
+ #include < chainparams.h>
6
7
7
8
#include < hash.h>
8
9
#include < primitives/transaction.h>
@@ -157,11 +158,6 @@ bool UnblindConfidentialPair(const CKey& blinding_key, const CConfidentialValue&
157
158
return false ;
158
159
}
159
160
160
- // Value sidechannel must be a transaction-valid amount (should be belt-and-suspenders check)
161
- if (amount > (uint64_t )MAX_MONEY || !MoneyRange ((CAmount)amount)) {
162
- return false ;
163
- }
164
-
165
161
// Convenience pointers to starting point of each recovered 32 byte message
166
162
unsigned char *asset_type = msg;
167
163
unsigned char *asset_blinder = msg+32 ;
@@ -172,6 +168,13 @@ bool UnblindConfidentialPair(const CKey& blinding_key, const CConfidentialValue&
172
168
return false ;
173
169
}
174
170
171
+ CAsset asset{std::vector<unsigned char >{asset_type, asset_type + 32 }};
172
+
173
+ // Value sidechannel must be a transaction-valid amount (should be belt-and-suspenders check)
174
+ if ((!committedScript.IsUnspendable () && amount == 0 ) || (asset == Params ().GetConsensus ().pegged_asset && (amount > (uint64_t )MAX_MONEY || !MoneyRange ((CAmount)amount)))) {
175
+ return false ;
176
+ }
177
+
175
178
// Serialize both generators then compare
176
179
unsigned char observed_generator[33 ];
177
180
unsigned char derived_generator[33 ];
@@ -182,7 +185,7 @@ bool UnblindConfidentialPair(const CKey& blinding_key, const CConfidentialValue&
182
185
}
183
186
184
187
amount_out = (CAmount)amount;
185
- asset_out = CAsset (std::vector< unsigned char >(asset_type, asset_type+ 32 )) ;
188
+ asset_out = asset ;
186
189
asset_blinding_factor_out = uint256 (std::vector<unsigned char >(asset_blinder, asset_blinder+32 ));
187
190
return true ;
188
191
}
0 commit comments