aboutsummaryrefslogtreecommitdiff
path: root/src/script/sign.cpp
diff options
context:
space:
mode:
authorJohnson Lau <jl2012@xbt.hk>2016-10-02 01:19:33 +0800
committerJohnson Lau <jl2012@xbt.hk>2016-10-16 23:53:35 +0800
commit4c0c25a604cec39675187507df423cff5d707ab5 (patch)
treeefdefd6a50693257a234ebf9a8988c306a54a12b /src/script/sign.cpp
parent3ade2f64cfe43ab53e4869ffc35d5fd23201e1c1 (diff)
Require compressed keys in segwit as policy and disable signing with uncompressed keys for segwit scripts
Diffstat (limited to 'src/script/sign.cpp')
-rw-r--r--src/script/sign.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/script/sign.cpp b/src/script/sign.cpp
index 87f38d9c72..f552ad5bba 100644
--- a/src/script/sign.cpp
+++ b/src/script/sign.cpp
@@ -1,5 +1,5 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
-// Copyright (c) 2009-2015 The Bitcoin Core developers
+// Copyright (c) 2009-2016 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
@@ -26,6 +26,10 @@ bool TransactionSignatureCreator::CreateSig(std::vector<unsigned char>& vchSig,
if (!keystore->GetKey(address, key))
return false;
+ // Signing with uncompressed keys is disabled in witness scripts
+ if (sigversion == SIGVERSION_WITNESS_V0 && !key.IsCompressed())
+ return false;
+
uint256 hash = SignatureHash(scriptCode, *txTo, nIn, nHashType, amount, sigversion);
if (!key.Sign(hash, vchSig))
return false;