Skip to content

Commit

Permalink
pos: dont pass the SignatureData
Browse files Browse the repository at this point in the history
  • Loading branch information
reddink committed Jan 29, 2024
1 parent c1e5fa7 commit 6682aab
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
22 changes: 22 additions & 0 deletions src/script/sign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,28 @@ bool SignSignature(const SigningProvider &provider, const CTransaction& txFrom,
return SignSignature(provider, txout.scriptPubKey, txTo, nIn, txout.nValue, nHashType, sig_data);
}

bool SignSignature(const SigningProvider &provider, const CScript& fromPubKey, CMutableTransaction& txTo, unsigned int nIn, const CAmount& amount, int nHashType)
{
assert(nIn < txTo.vin.size());

MutableTransactionSignatureCreator creator(txTo, nIn, amount, nHashType);

SignatureData sigdata;
bool ret = ProduceSignature(provider, creator, fromPubKey, sigdata);
UpdateInput(txTo.vin.at(nIn), sigdata);
return ret;
}

bool SignSignature(const SigningProvider &provider, const CTransaction& txFrom, CMutableTransaction& txTo, unsigned int nIn, int nHashType)
{
assert(nIn < txTo.vin.size());
const CTxIn& txin = txTo.vin[nIn];
assert(txin.prevout.n < txFrom.vout.size());
const CTxOut& txout = txFrom.vout[txin.prevout.n];

return SignSignature(provider, txout.scriptPubKey, txTo, nIn, txout.nValue, nHashType);
}

bool VerifySignature(const Coin& coin, const uint256 txFromHash, const CTransaction& txTo, unsigned int nIn, unsigned int flags)
{
TransactionSignatureChecker checker(&txTo, nIn, 0, MissingDataBehavior::FAIL);
Expand Down
4 changes: 4 additions & 0 deletions src/script/sign.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ bool SignSignature(const SigningProvider &provider, const CScript& fromPubKey, C
unsigned int nIn, const CAmount& amount, int nHashType, SignatureData& sig_data);
bool SignSignature(const SigningProvider &provider, const CTransaction& txFrom, CMutableTransaction& txTo,
unsigned int nIn, int nHashType, SignatureData& sig_data);
bool SignSignature(const SigningProvider &provider, const CScript& fromPubKey, CMutableTransaction& txTo,
unsigned int nIn, const CAmount& amount, int nHashType);
bool SignSignature(const SigningProvider &provider, const CTransaction& txFrom, CMutableTransaction& txTo,
unsigned int nIn, int nHashType);
bool VerifySignature(const Coin& coin, uint256 txFromHash, const CTransaction& txTo, unsigned int nIn, unsigned int flags);
bool VerifySignature(const CScript& fromPubKey, uint256 txFromHash, const CTransaction& txTo, unsigned int nIn, unsigned int flags);

Expand Down
3 changes: 1 addition & 2 deletions src/wallet/staking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,11 +478,10 @@ bool CreateCoinStake(CWallet& wallet, unsigned int nBits, int64_t nSearchInterva

// Sign
int nIn = 0;
SignatureData empty;

if (wallet.IsLegacy()) {
for (const auto &pcoin : vwtxPrev) {
if (!SignSignature(*wallet.GetLegacyScriptPubKeyMan(), *pcoin, txNew, nIn++, SIGHASH_ALL, empty))
if (!SignSignature(*wallet.GetLegacyScriptPubKeyMan(), *pcoin, txNew, nIn++, SIGHASH_ALL))
return error("CreateCoinStake : failed to sign coinstake");
}
}
Expand Down

0 comments on commit 6682aab

Please sign in to comment.