| 1982 | } |
| 1983 | |
| 1984 | BlindingStatus CWallet::WalletBlindPSBT(PartiallySignedTransaction& psbtx) const |
| 1985 | { |
| 1986 | // Gather our input data |
| 1987 | LOCK(cs_wallet); |
| 1988 | std::map<uint32_t, std::tuple<CAmount, CAsset, uint256, uint256>> our_input_data; |
| 1989 | std::map<uint32_t, std::pair<CKey, CKey>> our_issuances_to_blind; |
| 1990 | for (unsigned int i = 0; i < psbtx.inputs.size(); ++i) { |
| 1991 | PSBTInput& input = psbtx.inputs[i]; |
| 1992 | |
| 1993 | if (input.m_peg_in_value && !input.m_peg_in_claim_script.empty()) { |
| 1994 | if (!this->IsMine(CTxOut(Params().GetConsensus().pegged_asset, *input.m_peg_in_value, input.m_peg_in_claim_script))) continue; |
| 1995 | our_input_data[i] = std::make_tuple(*input.m_peg_in_value, Params().GetConsensus().pegged_asset, uint256(), uint256()); |
| 1996 | } else { |
| 1997 | if (!InputIsMine(*this, COutPoint(input.prev_txid, *input.prev_out))) continue; |
| 1998 | const CWalletTx* wtx = GetWalletTx(input.prev_txid); |
| 1999 | if (!wtx) continue; |
| 2000 | CPubKey blinding_pubkey; |
| 2001 | CAmount amount; |
| 2002 | uint256 value_blinder; |
| 2003 | CAsset asset; |
| 2004 | uint256 asset_blinder; |
| 2005 | wtx->GetNonIssuanceBlindingData(*this, *input.prev_out, &blinding_pubkey, &amount, &value_blinder, &asset, &asset_blinder); |
| 2006 | our_input_data[i] = std::make_tuple(amount, asset, asset_blinder, value_blinder); |
| 2007 | } |
| 2008 | |
| 2009 | // Blind issuances on our inputs if at least one commitment was provided. |
| 2010 | if (input.m_issuance_value_commitment.IsCommitment() || input.m_issuance_inflation_keys_commitment.IsCommitment()) { |
| 2011 | CScript blinding_script(CScript() << OP_RETURN << std::vector<unsigned char>(input.prev_txid.begin(), input.prev_txid.end()) << *input.prev_out); |
| 2012 | our_issuances_to_blind[i] = std::make_pair(GetBlindingKey(&blinding_script), GetBlindingKey(&blinding_script)); |
| 2013 | } |
| 2014 | } |
| 2015 | |
| 2016 | // Blind the PSBT |
| 2017 | return BlindPSBT(psbtx, our_input_data, our_issuances_to_blind); |
| 2018 | } |
| 2019 | TransactionError CWallet::SignPSBT(PartiallySignedTransaction& psbtx, bool& complete, int sighash_type, bool sign, bool imbalance_ok, bool bip32derivs, size_t* n_signed, bool finalize) const |
| 2020 | { |
| 2021 | LOCK(cs_wallet); |
no test coverage detected