Changeset View
Changeset View
Standalone View
Standalone View
src/script/sign.cpp
Show First 20 Lines • Show All 422 Lines • ▼ Show 20 Lines | bool CreateSig(const SigningProvider &provider, | ||||
vchSig[4] = 0x01; | vchSig[4] = 0x01; | ||||
vchSig[4 + 33] = 0x02; | vchSig[4 + 33] = 0x02; | ||||
vchSig[5 + 33] = 32; | vchSig[5 + 33] = 32; | ||||
vchSig[6 + 33] = 0x01; | vchSig[6 + 33] = 0x01; | ||||
vchSig[6 + 33 + 32] = SIGHASH_ALL | SIGHASH_FORKID; | vchSig[6 + 33 + 32] = SIGHASH_ALL | SIGHASH_FORKID; | ||||
return true; | return true; | ||||
} | } | ||||
}; | }; | ||||
template <typename M, typename K, typename V> | |||||
bool LookupHelper(const M &map, const K &key, V &value) { | |||||
auto it = map.find(key); | |||||
if (it != map.end()) { | |||||
value = it->second; | |||||
return true; | |||||
} | |||||
return false; | |||||
} | |||||
} // namespace | } // namespace | ||||
const BaseSignatureCreator &DUMMY_SIGNATURE_CREATOR = DummySignatureCreator(); | const BaseSignatureCreator &DUMMY_SIGNATURE_CREATOR = DummySignatureCreator(); | ||||
const SigningProvider &DUMMY_SIGNING_PROVIDER = SigningProvider(); | const SigningProvider &DUMMY_SIGNING_PROVIDER = SigningProvider(); | ||||
bool PartiallySignedTransaction::IsNull() const { | bool PartiallySignedTransaction::IsNull() const { | ||||
return !tx && inputs.empty() && outputs.empty() && unknown.empty(); | return !tx && inputs.empty() && outputs.empty() && unknown.empty(); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 110 Lines • ▼ Show 20 Lines | bool PublicOnlySigningProvider::GetCScript(const CScriptID &scriptid, | ||||
CScript &script) const { | CScript &script) const { | ||||
return m_provider->GetCScript(scriptid, script); | return m_provider->GetCScript(scriptid, script); | ||||
} | } | ||||
bool PublicOnlySigningProvider::GetPubKey(const CKeyID &address, | bool PublicOnlySigningProvider::GetPubKey(const CKeyID &address, | ||||
CPubKey &pubkey) const { | CPubKey &pubkey) const { | ||||
return m_provider->GetPubKey(address, pubkey); | return m_provider->GetPubKey(address, pubkey); | ||||
} | } | ||||
bool FlatSigningProvider::GetCScript(const CScriptID &scriptid, | |||||
CScript &script) const { | |||||
return LookupHelper(scripts, scriptid, script); | |||||
} | |||||
bool FlatSigningProvider::GetPubKey(const CKeyID &keyid, | |||||
CPubKey &pubkey) const { | |||||
return LookupHelper(pubkeys, keyid, pubkey); | |||||
} | |||||
bool FlatSigningProvider::GetKey(const CKeyID &keyid, CKey &key) const { | |||||
return LookupHelper(keys, keyid, key); | |||||
} | |||||
FlatSigningProvider Merge(const FlatSigningProvider &a, | |||||
const FlatSigningProvider &b) { | |||||
FlatSigningProvider ret; | |||||
ret.scripts = a.scripts; | |||||
ret.scripts.insert(b.scripts.begin(), b.scripts.end()); | |||||
ret.pubkeys = a.pubkeys; | |||||
ret.pubkeys.insert(b.pubkeys.begin(), b.pubkeys.end()); | |||||
ret.keys = a.keys; | |||||
ret.keys.insert(b.keys.begin(), b.keys.end()); | |||||
return ret; | |||||
} |