MCPcopy Create free account
hub / github.com/ElementsProject/elements / GetBlindingData

Method GetBlindingData

src/wallet/wallet.cpp:3590–3644  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3588}
3589
3590void CWalletTx::GetBlindingData(const CWallet& wallet, const unsigned int map_index, const std::vector<unsigned char>& vchRangeproof, const CConfidentialValue& conf_value, const CConfidentialAsset& conf_asset, const CConfidentialNonce nonce, const CScript& scriptPubKey, CPubKey* blinding_pubkey_out, CAmount* value_out, uint256* value_factor_out, CAsset* asset_out, uint256* asset_factor_out) const
3591{
3592 // Blinding data is cached in a serialized record mapWallet["blindingdata"].
3593 // It contains a concatenation byte vectors, 74 bytes per txout or pseudo-input.
3594 // Each consists of:
3595 // * 1 byte boolean marker (has the output been computed)?
3596 // * 8 bytes value (-1 if unknown)
3597 // * 32 bytes value blinding factor
3598 // * 32 bytes asset blinding factor
3599 // * 32 bytes asset
3600 // * 33 bytes blinding pubkey (ECDH pubkey of the destination)
3601 // This is really ugly, and should use CDataStream serialization instead.
3602
3603 if (mapValue["blindingdata"].size() < (map_index + 1) * 138) {
3604 mapValue["blindingdata"].resize((tx->vout.size() + GetNumIssuances(*tx)) * 138);
3605 }
3606
3607 unsigned char* it = (unsigned char*)(&mapValue["blindingdata"][0]) + 138 * map_index;
3608
3609 CAmount amount = -1;
3610 CPubKey pubkey;
3611 uint256 value_factor;
3612 CAsset asset_tag;
3613 uint256 asset_factor;
3614
3615 if (*it == 1) {
3616 memcpy(&amount, &*(it + 1), 8);
3617 memcpy(value_factor.begin(), &*(it + 9), 32);
3618 memcpy(asset_factor.begin(), &*(it + 41), 32);
3619 memcpy(asset_tag.begin(), &*(it + 73), 32);
3620 pubkey.Set(it + 105, it + 138);
3621
3622 if (amount != -1 && conf_value.IsExplicit()) {
3623 assert(conf_value.GetAmount() == amount);
3624 }
3625 } else {
3626 wallet.ComputeBlindingData(conf_value, conf_asset, nonce, scriptPubKey, vchRangeproof, amount, pubkey, value_factor, asset_tag, asset_factor);
3627 *it = 1;
3628 memcpy(&*(it + 1), &amount, 8);
3629 memcpy(&*(it + 9), value_factor.begin(), 32);
3630 memcpy(&*(it + 41), asset_factor.begin(), 32);
3631 memcpy(&*(it + 73), asset_tag.begin(), 32);
3632 if (pubkey.IsFullyValid()) {
3633 memcpy(&*(it + 105), pubkey.begin(), 33);
3634 } else {
3635 memset(&*(it + 105), 0, 33);
3636 }
3637 }
3638
3639 if (value_out) *value_out = amount;
3640 if (blinding_pubkey_out) *blinding_pubkey_out = pubkey;
3641 if (value_factor_out) *value_factor_out = value_factor;
3642 if (asset_factor_out) *asset_factor_out = asset_factor;
3643 if (asset_out) *asset_out = asset_tag;
3644}
3645
3646void CWalletTx::GetNonIssuanceBlindingData(const CWallet& wallet, const unsigned int output_index, CPubKey* blinding_pubkey_out, CAmount* value_out, uint256* value_factor_out, CAsset* asset_out, uint256* asset_factor_out) const {
3647 assert(output_index < tx->vout.size());

Callers

nothing calls this directly

Calls 9

GetNumIssuancesFunction · 0.85
IsExplicitMethod · 0.80
GetAmountMethod · 0.80
ComputeBlindingDataMethod · 0.80
IsFullyValidMethod · 0.80
sizeMethod · 0.45
resizeMethod · 0.45
beginMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected