| 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); |
| 2022 | |
| 2023 | // If we're signing, check that the transaction is not still in need of blinding |
| 2024 | // Also check that the amount and asset proofs are valid |
| 2025 | if (sign) { |
| 2026 | for (const PSBTOutput& o : psbtx.outputs) { |
| 2027 | if (o.IsBlinded()) { |
| 2028 | switch (VerifyBlindProofs(o)) { |
| 2029 | case BlindProofResult::OK: |
| 2030 | break; |
| 2031 | case BlindProofResult::NOT_FULLY_BLINDED: |
| 2032 | return TransactionError::BLINDING_REQUIRED; |
| 2033 | case BlindProofResult::INVALID_VALUE_PROOF: |
| 2034 | case BlindProofResult::MISSING_VALUE_PROOF: |
| 2035 | return TransactionError::INVALID_VALUE_PROOF; |
| 2036 | case BlindProofResult::INVALID_ASSET_PROOF: |
| 2037 | case BlindProofResult::MISSING_ASSET_PROOF: |
| 2038 | return TransactionError::INVALID_ASSET_PROOF; |
| 2039 | } |
| 2040 | |
| 2041 | if (o.script && IsMine(*o.script)) { |
| 2042 | CKey blinding_key; |
| 2043 | if ((blinding_key = GetBlindingKey(&*o.script)).IsValid()) { |
| 2044 | CAmount value; |
| 2045 | uint256 value_factor; |
| 2046 | CAsset asset; |
| 2047 | uint256 asset_factor; |
| 2048 | |
| 2049 | CConfidentialNonce nonce; |
| 2050 | nonce.vchCommitment.insert(nonce.vchCommitment.end(), o.m_ecdh_pubkey.begin(), o.m_ecdh_pubkey.end()); |
| 2051 | if (UnblindConfidentialPair(blinding_key, o.m_value_commitment, o.m_asset_commitment, nonce, *o.script, o.m_value_rangeproof, value, value_factor, asset, asset_factor)) { |
| 2052 | // These assertions are cryptographically impossible to trigger, as we |
| 2053 | // checked the proofs above, and then `UnblindConfidentialPair` checks |
| 2054 | // the extracted value/asset against the commitments. |
| 2055 | if (o.amount) { |
| 2056 | assert(*o.amount == value); |
| 2057 | } |
| 2058 | if (!o.m_asset.IsNull()) { |
| 2059 | assert(CAsset(o.m_asset) == asset); |
| 2060 | } |
| 2061 | } else { |
| 2062 | return TransactionError::MISSING_SIDECHANNEL_DATA; |
| 2063 | } |
| 2064 | } else { |
| 2065 | return TransactionError::MISSING_BLINDING_KEY; |
| 2066 | } |
| 2067 | } |
| 2068 | } |
| 2069 | } |
| 2070 | } |
| 2071 | |
| 2072 | if (n_signed) { |
| 2073 | *n_signed = 0; |
| 2074 | } |
| 2075 | |
| 2076 | CMutableTransaction tx = psbtx.GetUnsignedTx(); |
nothing calls this directly
no test coverage detected