Rewind the outputs to unblinded, and push placeholders for blinding info. Not exported.
| 1014 | |
| 1015 | // Rewind the outputs to unblinded, and push placeholders for blinding info. Not exported. |
| 1016 | void FillBlinds(CWallet* pwallet, CMutableTransaction& tx, std::vector<uint256>& output_value_blinds, std::vector<uint256>& output_asset_blinds, std::vector<CPubKey>& output_pubkeys, std::vector<CKey>& asset_keys, std::vector<CKey>& token_keys) { |
| 1017 | |
| 1018 | // Resize witness before doing anything |
| 1019 | tx.witness.vtxinwit.resize(tx.vin.size()); |
| 1020 | tx.witness.vtxoutwit.resize(tx.vout.size()); |
| 1021 | |
| 1022 | for (size_t nOut = 0; nOut < tx.vout.size(); ++nOut) { |
| 1023 | CTxOut& out = tx.vout[nOut]; |
| 1024 | if (out.nValue.IsExplicit()) { |
| 1025 | CPubKey pubkey(out.nNonce.vchCommitment); |
| 1026 | if (!pubkey.IsFullyValid()) { |
| 1027 | output_pubkeys.push_back(CPubKey()); |
| 1028 | } else { |
| 1029 | output_pubkeys.push_back(pubkey); |
| 1030 | } |
| 1031 | output_value_blinds.push_back(uint256()); |
| 1032 | output_asset_blinds.push_back(uint256()); |
| 1033 | } else if (out.nValue.IsCommitment()) { |
| 1034 | CTxOutWitness* ptxoutwit = &tx.witness.vtxoutwit[nOut]; |
| 1035 | uint256 blinding_factor; |
| 1036 | uint256 asset_blinding_factor; |
| 1037 | CAsset asset; |
| 1038 | CAmount amount; |
| 1039 | // This can only be used to recover things like change addresses and self-sends. |
| 1040 | if (UnblindConfidentialPair(pwallet->GetBlindingKey(&out.scriptPubKey), out.nValue, out.nAsset, out.nNonce, out.scriptPubKey, ptxoutwit->vchRangeproof, amount, blinding_factor, asset, asset_blinding_factor) != 0) { |
| 1041 | // Wipe out confidential info from output and output witness |
| 1042 | CScript scriptPubKey = tx.vout[nOut].scriptPubKey; |
| 1043 | CTxOut newOut(asset, amount, scriptPubKey); |
| 1044 | tx.vout[nOut] = newOut; |
| 1045 | ptxoutwit->SetNull(); |
| 1046 | |
| 1047 | // Mark for re-blinding with same key that deblinded it |
| 1048 | CPubKey pubkey(pwallet->GetBlindingKey(&out.scriptPubKey).GetPubKey()); |
| 1049 | output_pubkeys.push_back(pubkey); |
| 1050 | output_value_blinds.push_back(uint256()); |
| 1051 | output_asset_blinds.push_back(uint256()); |
| 1052 | } else { |
| 1053 | output_pubkeys.push_back(CPubKey()); |
| 1054 | output_value_blinds.push_back(uint256()); |
| 1055 | output_asset_blinds.push_back(uint256()); |
| 1056 | } |
| 1057 | } else { |
| 1058 | // Null or invalid, do nothing for that output |
| 1059 | output_pubkeys.push_back(CPubKey()); |
| 1060 | output_value_blinds.push_back(uint256()); |
| 1061 | output_asset_blinds.push_back(uint256()); |
| 1062 | } |
| 1063 | } |
| 1064 | |
| 1065 | // Fill out issuance blinding keys to be used directly as nonce for rangeproof |
| 1066 | for (size_t nIn = 0; nIn < tx.vin.size(); ++nIn) { |
| 1067 | CAssetIssuance& issuance = tx.vin[nIn].assetIssuance; |
| 1068 | if (issuance.IsNull()) { |
| 1069 | asset_keys.push_back(CKey()); |
| 1070 | token_keys.push_back(CKey()); |
| 1071 | continue; |
| 1072 | } |
| 1073 |
no test coverage detected