Skip to content

Commit 661083d

Browse files
committed
[Core] Sign block with staking key if coinstake is 'cold' stake
1 parent f30c299 commit 661083d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/blocksignature.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ bool GetKeyIDFromUTXO(const CTxOut& txout, CKeyID& keyID)
2222
return false;
2323
if (whichType == TX_PUBKEY) {
2424
keyID = CPubKey(vSolutions[0]).GetID();
25-
} else if (whichType == TX_PUBKEYHASH) {
25+
} else if (whichType == TX_PUBKEYHASH || whichType == TX_COLDSTAKE) {
2626
keyID = CKeyID(uint160(vSolutions[0]));
27+
} else {
28+
return false;
2729
}
2830

2931
return true;
@@ -80,6 +82,12 @@ bool CheckBlockSignature(const CBlock& block)
8082
if (whichType == TX_PUBKEY || whichType == TX_PUBKEYHASH) {
8183
valtype& vchPubKey = vSolutions[0];
8284
pubkey = CPubKey(vchPubKey);
85+
} else if (whichType == TX_COLDSTAKE) {
86+
// pick the public key from the P2CS input
87+
const CTxIn& txin = block.vtx[1].vin[0];
88+
int start = 1 + (int) *txin.scriptSig.begin(); // skip sig
89+
start += 1 + (int) *(txin.scriptSig.begin()+start); // skip flag
90+
pubkey = CPubKey(txin.scriptSig.begin()+start+1, txin.scriptSig.end());
8391
}
8492
}
8593

0 commit comments

Comments
 (0)