Changeset View
Changeset View
Standalone View
Standalone View
src/script/sign.cpp
Show All 10 Lines | |||||
#include "primitives/transaction.h" | #include "primitives/transaction.h" | ||||
#include "script/standard.h" | #include "script/standard.h" | ||||
#include "uint256.h" | #include "uint256.h" | ||||
typedef std::vector<uint8_t> valtype; | typedef std::vector<uint8_t> valtype; | ||||
TransactionSignatureCreator::TransactionSignatureCreator( | TransactionSignatureCreator::TransactionSignatureCreator( | ||||
const CKeyStore *keystoreIn, const CTransaction *txToIn, unsigned int nInIn, | const CKeyStore *keystoreIn, const CTransaction *txToIn, unsigned int nInIn, | ||||
const CAmount amountIn, uint32_t nHashTypeIn) | const Amount amountIn, uint32_t nHashTypeIn) | ||||
: BaseSignatureCreator(keystoreIn), txTo(txToIn), nIn(nInIn), | : BaseSignatureCreator(keystoreIn), txTo(txToIn), nIn(nInIn), | ||||
amount(amountIn), nHashType(nHashTypeIn), checker(txTo, nIn, amountIn) {} | amount(amountIn), nHashType(nHashTypeIn), checker(txTo, nIn, amountIn) {} | ||||
bool TransactionSignatureCreator::CreateSig(std::vector<uint8_t> &vchSig, | bool TransactionSignatureCreator::CreateSig(std::vector<uint8_t> &vchSig, | ||||
const CKeyID &address, | const CKeyID &address, | ||||
const CScript &scriptCode) const { | const CScript &scriptCode) const { | ||||
CKey key; | CKey key; | ||||
if (!keystore->GetKey(address, key)) { | if (!keystore->GetKey(address, key)) { | ||||
▲ Show 20 Lines • Show All 149 Lines • ▼ Show 20 Lines | |||||
void UpdateTransaction(CMutableTransaction &tx, unsigned int nIn, | void UpdateTransaction(CMutableTransaction &tx, unsigned int nIn, | ||||
const SignatureData &data) { | const SignatureData &data) { | ||||
assert(tx.vin.size() > nIn); | assert(tx.vin.size() > nIn); | ||||
tx.vin[nIn].scriptSig = data.scriptSig; | tx.vin[nIn].scriptSig = data.scriptSig; | ||||
} | } | ||||
bool SignSignature(const CKeyStore &keystore, const CScript &fromPubKey, | bool SignSignature(const CKeyStore &keystore, const CScript &fromPubKey, | ||||
CMutableTransaction &txTo, unsigned int nIn, | CMutableTransaction &txTo, unsigned int nIn, | ||||
const CAmount amount, uint32_t nHashType) { | const Amount amount, uint32_t nHashType) { | ||||
assert(nIn < txTo.vin.size()); | assert(nIn < txTo.vin.size()); | ||||
CTransaction txToConst(txTo); | CTransaction txToConst(txTo); | ||||
TransactionSignatureCreator creator(&keystore, &txToConst, nIn, amount, | TransactionSignatureCreator creator(&keystore, &txToConst, nIn, amount, | ||||
nHashType); | nHashType); | ||||
SignatureData sigdata; | SignatureData sigdata; | ||||
bool ret = ProduceSignature(creator, fromPubKey, sigdata); | bool ret = ProduceSignature(creator, fromPubKey, sigdata); | ||||
▲ Show 20 Lines • Show All 195 Lines • Show Last 20 Lines |