| 37 | } |
| 38 | |
| 39 | bool MutableTransactionSignatureCreator::CreateSig(const SigningProvider& provider, std::vector<unsigned char>& vchSig, const CKeyID& address, const CScript& scriptCode, SigVersion sigversion, unsigned int flags) const |
| 40 | { |
| 41 | assert(sigversion == SigVersion::BASE || sigversion == SigVersion::WITNESS_V0); |
| 42 | |
| 43 | CKey key; |
| 44 | if (!provider.GetKey(address, key)) |
| 45 | return false; |
| 46 | |
| 47 | // Signing with uncompressed keys is disabled in witness scripts |
| 48 | if (sigversion == SigVersion::WITNESS_V0 && !key.IsCompressed()) |
| 49 | return false; |
| 50 | |
| 51 | // Signing without known amount does not work in witness scripts. |
| 52 | if (sigversion == SigVersion::WITNESS_V0 && amount.IsNull()) return false; |
| 53 | |
| 54 | // BASE/WITNESS_V0 signatures don't support explicit SIGHASH_DEFAULT, use SIGHASH_ALL instead. |
| 55 | const int hashtype = nHashType == SIGHASH_DEFAULT ? SIGHASH_ALL : nHashType; |
| 56 | |
| 57 | uint256 hash = SignatureHash(scriptCode, *txTo, nIn, hashtype, amount, sigversion, flags, m_txdata); |
| 58 | if (!key.Sign(hash, vchSig)) |
| 59 | return false; |
| 60 | vchSig.push_back((unsigned char)hashtype); |
| 61 | return true; |
| 62 | } |
| 63 | |
| 64 | bool MutableTransactionSignatureCreator::CreateSchnorrSig(const SigningProvider& provider, std::vector<unsigned char>& sig, const XOnlyPubKey& pubkey, const uint256* leaf_hash, const uint256* merkle_root, SigVersion sigversion) const |
| 65 | { |