mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
Merge de5af41e35 into merged_master (Bitcoin PR #15452)
This commit is contained in:
commit
ff1c4012ad
9 changed files with 19 additions and 24 deletions
|
|
@ -42,8 +42,6 @@ SetupDummyInputs(CBasicKeyStore& keystoreRet, CCoinsViewCache& coinsRet)
|
|||
dummyTransactions[1].vout[0].scriptPubKey = GetScriptForDestination(PKHash(key[2].GetPubKey()));
|
||||
dummyTransactions[1].vout[1].nValue = 22 * COIN;
|
||||
dummyTransactions[1].vout[1].scriptPubKey = GetScriptForDestination(PKHash(key[3].GetPubKey()));
|
||||
//TODO(stevenroose) rebase remove
|
||||
//dummyTransactions[1].vout[1].scriptPubKey = GetScriptForDestination(key[3].GetPubKey().GetID());
|
||||
AddCoins(coinsRet, CTransaction(dummyTransactions[1]), 0);
|
||||
|
||||
return dummyTransactions;
|
||||
|
|
|
|||
|
|
@ -471,8 +471,8 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
|
|||
else if(ExtractDestination(out.txout.scriptPubKey, address))
|
||||
{
|
||||
CPubKey pubkey;
|
||||
PKHash *keyid = boost::get<PKHash>(&address);
|
||||
if (keyid && model->wallet().getPubKey(CKeyID(*keyid), pubkey))
|
||||
PKHash *pkhash = boost::get<PKHash>(&address);
|
||||
if (pkhash && model->wallet().getPubKey(CKeyID(*pkhash), pubkey))
|
||||
{
|
||||
nBytesInputs += (pubkey.IsCompressed() ? 148 : 180);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,8 +120,8 @@ void SignVerifyMessageDialog::on_signMessageButton_SM_clicked()
|
|||
ui->statusLabel_SM->setText(tr("The entered address is invalid.") + QString(" ") + tr("Please check the address and try again."));
|
||||
return;
|
||||
}
|
||||
const PKHash* keyID = boost::get<PKHash>(&destination);
|
||||
if (!keyID) {
|
||||
const PKHash* pkhash = boost::get<PKHash>(&destination);
|
||||
if (!pkhash) {
|
||||
ui->addressIn_SM->setValid(false);
|
||||
ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }");
|
||||
ui->statusLabel_SM->setText(tr("The entered address does not refer to a key.") + QString(" ") + tr("Please check the address and try again."));
|
||||
|
|
@ -137,7 +137,7 @@ void SignVerifyMessageDialog::on_signMessageButton_SM_clicked()
|
|||
}
|
||||
|
||||
CKey key;
|
||||
if (!model->wallet().getPrivKey(CKeyID(*keyID), key))
|
||||
if (!model->wallet().getPrivKey(CKeyID(*pkhash), key))
|
||||
{
|
||||
ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }");
|
||||
ui->statusLabel_SM->setText(tr("Private key for the entered address is not available."));
|
||||
|
|
@ -229,7 +229,7 @@ void SignVerifyMessageDialog::on_verifyMessageButton_VM_clicked()
|
|||
return;
|
||||
}
|
||||
|
||||
if (!(CTxDestination(PKHash(pubkey.GetID())) == destination)) {
|
||||
if (!(CTxDestination(PKHash(pubkey)) == destination)) {
|
||||
ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }");
|
||||
ui->statusLabel_VM->setText(QString("<nobr>") + tr("Message verification failed.") + QString("</nobr>"));
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -605,7 +605,7 @@ static UniValue decodescript(const JSONRPCRequest& request)
|
|||
if (type.isStr() && type.get_str() != "scripthash") {
|
||||
// P2SH cannot be wrapped in a P2SH. If this script is already a P2SH,
|
||||
// don't return the address for a P2SH of the P2SH.
|
||||
r.pushKV("p2sh", EncodeDestination(ScriptHash(CScriptID(script))));
|
||||
r.pushKV("p2sh", EncodeDestination(ScriptHash(script)));
|
||||
// P2SH and witness programs cannot be wrapped in P2WSH, if this script
|
||||
// is a witness program, don't return addresses for a segwit programs.
|
||||
if (type.get_str() == "pubkey" || type.get_str() == "pubkeyhash" || type.get_str() == "multisig" || type.get_str() == "nonstandard") {
|
||||
|
|
@ -632,7 +632,7 @@ static UniValue decodescript(const JSONRPCRequest& request)
|
|||
segwitScr = GetScriptForDestination(WitnessV0ScriptHash(script));
|
||||
}
|
||||
ScriptPubKeyToUniv(segwitScr, sr, /* fIncludeHex */ true);
|
||||
sr.pushKV("p2sh-segwit", EncodeDestination(ScriptHash(CScriptID(segwitScr))));
|
||||
sr.pushKV("p2sh-segwit", EncodeDestination(ScriptHash(segwitScr)));
|
||||
r.pushKV("segwit", sr);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -556,7 +556,7 @@ protected:
|
|||
CScript p2wpkh = GetScriptForDestination(WitnessV0KeyHash(id));
|
||||
out.scripts.emplace(CScriptID(p2wpkh), p2wpkh);
|
||||
ret.emplace_back(p2wpkh);
|
||||
ret.emplace_back(GetScriptForDestination(ScriptHash(CScriptID(p2wpkh)))); // P2SH-P2WPKH
|
||||
ret.emplace_back(GetScriptForDestination(ScriptHash(p2wpkh))); // P2SH-P2WPKH
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -579,7 +579,7 @@ public:
|
|||
class SHDescriptor final : public DescriptorImpl
|
||||
{
|
||||
protected:
|
||||
std::vector<CScript> MakeScripts(const std::vector<CPubKey>&, const CScript* script, FlatSigningProvider&) const override { return Singleton(GetScriptForDestination(ScriptHash(CScriptID(*script)))); }
|
||||
std::vector<CScript> MakeScripts(const std::vector<CPubKey>&, const CScript* script, FlatSigningProvider&) const override { return Singleton(GetScriptForDestination(ScriptHash(*script))); }
|
||||
public:
|
||||
SHDescriptor(std::unique_ptr<DescriptorImpl> desc) : DescriptorImpl({}, std::move(desc), "sh") {}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -490,7 +490,7 @@ BOOST_AUTO_TEST_CASE(script_standard_IsMine)
|
|||
{
|
||||
CBasicKeyStore keystore;
|
||||
|
||||
CScript redeemscript = GetScriptForDestination(ScriptHash(PKHash(pubkeys[0])));
|
||||
CScript redeemscript = GetScriptForDestination(PKHash(pubkeys[0]));
|
||||
CScript witnessscript = GetScriptForDestination(ScriptHash(redeemscript));
|
||||
scriptPubKey = GetScriptForDestination(WitnessV0ScriptHash(witnessscript));
|
||||
|
||||
|
|
@ -598,7 +598,7 @@ BOOST_AUTO_TEST_CASE(script_standard_IsMine)
|
|||
BOOST_CHECK(keystore.AddKey(keys[1]));
|
||||
|
||||
CScript redeemScript = GetScriptForMultisig(2, {uncompressedPubkey, pubkeys[1]});
|
||||
scriptPubKey = GetScriptForDestination(ScriptHash(CScriptID(redeemScript)));
|
||||
scriptPubKey = GetScriptForDestination(ScriptHash(redeemScript));
|
||||
|
||||
// Keystore has no redeemScript
|
||||
result = IsMine(keystore, scriptPubKey);
|
||||
|
|
|
|||
|
|
@ -810,19 +810,16 @@ UniValue dumpwallet(const JSONRPCRequest& request)
|
|||
if (!file.is_open())
|
||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file");
|
||||
|
||||
std::map<CTxDestination, int64_t> mapKeyBirth;
|
||||
std::map<CKeyID, int64_t> mapKeyBirth;
|
||||
const std::map<CKeyID, int64_t>& mapKeyPool = pwallet->GetAllReserveKeys();
|
||||
pwallet->GetKeyBirthTimes(*locked_chain, mapKeyBirth);
|
||||
|
||||
std::set<CScriptID> scripts = pwallet->GetCScripts();
|
||||
// TODO: include scripts in GetKeyBirthTimes() output instead of separate
|
||||
|
||||
// sort time/key pairs
|
||||
std::vector<std::pair<int64_t, CKeyID> > vKeyBirth;
|
||||
for (const auto& entry : mapKeyBirth) {
|
||||
if (const PKHash* keyID = boost::get<PKHash>(&entry.first)) { // set and test
|
||||
vKeyBirth.push_back(std::make_pair(entry.second, CKeyID(*keyID)));
|
||||
}
|
||||
vKeyBirth.push_back(std::make_pair(entry.second, entry.first));
|
||||
}
|
||||
mapKeyBirth.clear();
|
||||
std::sort(vKeyBirth.begin(), vKeyBirth.end());
|
||||
|
|
|
|||
|
|
@ -4372,14 +4372,14 @@ void CWallet::ListLockedCoins(std::vector<COutPoint>& vOutpts) const
|
|||
|
||||
/** @} */ // end of Actions
|
||||
|
||||
void CWallet::GetKeyBirthTimes(interfaces::Chain::Lock& locked_chain, std::map<CTxDestination, int64_t>& mapKeyBirth) const {
|
||||
void CWallet::GetKeyBirthTimes(interfaces::Chain::Lock& locked_chain, std::map<CKeyID, int64_t>& mapKeyBirth) const {
|
||||
AssertLockHeld(cs_wallet);
|
||||
mapKeyBirth.clear();
|
||||
|
||||
// get birth times for keys with metadata
|
||||
for (const auto& entry : mapKeyMetadata) {
|
||||
if (entry.second.nCreateTime) {
|
||||
mapKeyBirth[PKHash(entry.first)] = entry.second.nCreateTime;
|
||||
mapKeyBirth[entry.first] = entry.second.nCreateTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4388,7 +4388,7 @@ void CWallet::GetKeyBirthTimes(interfaces::Chain::Lock& locked_chain, std::map<C
|
|||
const int max_height = tip_height && *tip_height > 144 ? *tip_height - 144 : 0; // the tip can be reorganized; use a 144-block safety margin
|
||||
std::map<CKeyID, int> mapKeyFirstBlock;
|
||||
for (const CKeyID &keyid : GetKeys()) {
|
||||
if (mapKeyBirth.count(PKHash(keyid)) == 0)
|
||||
if (mapKeyBirth.count(keyid) == 0)
|
||||
mapKeyFirstBlock[keyid] = max_height;
|
||||
}
|
||||
|
||||
|
|
@ -4416,7 +4416,7 @@ void CWallet::GetKeyBirthTimes(interfaces::Chain::Lock& locked_chain, std::map<C
|
|||
|
||||
// Extract block timestamps for those keys
|
||||
for (const auto& entry : mapKeyFirstBlock)
|
||||
mapKeyBirth[PKHash(entry.first)] = locked_chain.getBlockTime(entry.second) - TIMESTAMP_WINDOW; // block times can be 2h off
|
||||
mapKeyBirth[entry.first] = locked_chain.getBlockTime(entry.second) - TIMESTAMP_WINDOW; // block times can be 2h off
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -983,7 +983,7 @@ public:
|
|||
bool ChangeWalletPassphrase(const SecureString& strOldWalletPassphrase, const SecureString& strNewWalletPassphrase);
|
||||
bool EncryptWallet(const SecureString& strWalletPassphrase);
|
||||
|
||||
void GetKeyBirthTimes(interfaces::Chain::Lock& locked_chain, std::map<CTxDestination, int64_t> &mapKeyBirth) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||
void GetKeyBirthTimes(interfaces::Chain::Lock& locked_chain, std::map<CKeyID, int64_t> &mapKeyBirth) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||
unsigned int ComputeTimeSmart(const CWalletTx& wtx) const;
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue