next dogecoin/src/test/script_tests.cpp:479 │ bitcoin/src/test/script_tests.cpp:457
│
const KeyData keys; │ const KeyData keys;
│
std::vector<TestBuilder> tests; │ std::vector<TestBuilder> tests;
│
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG,
"P2PK", 0 │ "P2PK", 0
).PushSig(keys.key0)); │ ).PushSig(keys.key0));
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG,
"P2PK, bad sig", 0 │ "P2PK, bad sig", 0
).PushSig(keys.key0).DamagePush(10).ScriptError(SCRIPT_ER │ ).PushSig(keys.key0).DamagePush(10).ScriptError(SCRIPT_ER
│
tests.push_back(TestBuilder(CScript() << OP_DUP << OP_HASH160 << ToByteVector(keys.p │ tests.push_back(TestBuilder(CScript() << OP_DUP << OP_HASH160 << ToByteVector(keys.p
"P2PKH", 0 │ "P2PKH", 0
).PushSig(keys.key1).Push(keys.pubkey1C)); │ ).PushSig(keys.key1).Push(keys.pubkey1C));
tests.push_back(TestBuilder(CScript() << OP_DUP << OP_HASH160 << ToByteVector(keys.p │ tests.push_back(TestBuilder(CScript() << OP_DUP << OP_HASH160 << ToByteVector(keys.p
"P2PKH, bad pubkey", 0 │ "P2PKH, bad pubkey", 0
).PushSig(keys.key2).Push(keys.pubkey2C).DamagePush(5).Sc │ ).PushSig(keys.key2).Push(keys.pubkey2C).DamagePush(5).Sc
│
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1) << OP_CHECKSIG,
"P2PK anyonecanpay", 0 │ "P2PK anyonecanpay", 0
).PushSig(keys.key1, SIGHASH_ALL | SIGHASH_ANYONECANPAY)) │ ).PushSig(keys.key1, SIGHASH_ALL | SIGHASH_ANYONECANPAY))
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1) << OP_CHECKSIG,
"P2PK anyonecanpay marked with normal hashtype", 0 │ "P2PK anyonecanpay marked with normal hashtype", 0
).PushSig(keys.key1, SIGHASH_ALL | SIGHASH_ANYONECANPAY). │ ).PushSig(keys.key1, SIGHASH_ALL | SIGHASH_ANYONECANPAY).
│
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0C) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0C) << OP_CHECKSIG,
"P2SH(P2PK)", SCRIPT_VERIFY_P2SH, true │ "P2SH(P2PK)", SCRIPT_VERIFY_P2SH, true
).PushSig(keys.key0).PushRedeem()); │ ).PushSig(keys.key0).PushRedeem());
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0C) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0C) << OP_CHECKSIG,
"P2SH(P2PK), bad redeemscript", SCRIPT_VERIFY_P2SH, true │ "P2SH(P2PK), bad redeemscript", SCRIPT_VERIFY_P2SH, true
).PushSig(keys.key0).PushRedeem().DamagePush(10).ScriptEr │ ).PushSig(keys.key0).PushRedeem().DamagePush(10).ScriptEr
│
tests.push_back(TestBuilder(CScript() << OP_DUP << OP_HASH160 << ToByteVector(keys.p │ tests.push_back(TestBuilder(CScript() << OP_DUP << OP_HASH160 << ToByteVector(keys.p
"P2SH(P2PKH)", SCRIPT_VERIFY_P2SH, true │ "P2SH(P2PKH)", SCRIPT_VERIFY_P2SH, true
).PushSig(keys.key0).Push(keys.pubkey0).PushRedeem()); │ ).PushSig(keys.key0).Push(keys.pubkey0).PushRedeem());
tests.push_back(TestBuilder(CScript() << OP_DUP << OP_HASH160 << ToByteVector(keys.p │ tests.push_back(TestBuilder(CScript() << OP_DUP << OP_HASH160 << ToByteVector(keys.p
"P2SH(P2PKH), bad sig but no VERIFY_P2SH", 0, true │ "P2SH(P2PKH), bad sig but no VERIFY_P2SH", 0, true
).PushSig(keys.key0).DamagePush(10).PushRedeem()); │ ).PushSig(keys.key0).DamagePush(10).PushRedeem());
tests.push_back(TestBuilder(CScript() << OP_DUP << OP_HASH160 << ToByteVector(keys.p │ tests.push_back(TestBuilder(CScript() << OP_DUP << OP_HASH160 << ToByteVector(keys.p
"P2SH(P2PKH), bad sig", SCRIPT_VERIFY_P2SH, true │ "P2SH(P2PKH), bad sig", SCRIPT_VERIFY_P2SH, true
).PushSig(keys.key0).DamagePush(10).PushRedeem().ScriptEr │ ).PushSig(keys.key0).DamagePush(10).PushRedeem().ScriptEr
│
tests.push_back(TestBuilder(CScript() << OP_3 << ToByteVector(keys.pubkey0C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_3 << ToByteVector(keys.pubkey0C) << ToBy
"3-of-3", 0 │ "3-of-3", 0
).Num(0).PushSig(keys.key0).PushSig(keys.key1).PushSig(ke │ ).Num(0).PushSig(keys.key0).PushSig(keys.key1).PushSig(ke
tests.push_back(TestBuilder(CScript() << OP_3 << ToByteVector(keys.pubkey0C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_3 << ToByteVector(keys.pubkey0C) << ToBy
"3-of-3, 2 sigs", 0 │ "3-of-3, 2 sigs", 0
).Num(0).PushSig(keys.key0).PushSig(keys.key1).Num(0).Scr │ ).Num(0).PushSig(keys.key0).PushSig(keys.key1).Num(0).Scr
│
tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey0C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey0C) << ToBy
"P2SH(2-of-3)", SCRIPT_VERIFY_P2SH, true │ "P2SH(2-of-3)", SCRIPT_VERIFY_P2SH, true
).Num(0).PushSig(keys.key1).PushSig(keys.key2).PushRedeem │ ).Num(0).PushSig(keys.key1).PushSig(keys.key2).PushRedeem
tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey0C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey0C) << ToBy
"P2SH(2-of-3), 1 sig", SCRIPT_VERIFY_P2SH, true │ "P2SH(2-of-3), 1 sig", SCRIPT_VERIFY_P2SH, true
).Num(0).PushSig(keys.key1).Num(0).PushRedeem().ScriptErr │ ).Num(0).PushSig(keys.key1).Num(0).PushRedeem().ScriptErr
│
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG,
"P2PK with too much R padding but no DERSIG", 0 │ "P2PK with too much R padding but no DERSIG", 0
).PushSig(keys.key1, SIGHASH_ALL, 31, 32).EditPush(1, "43 │ ).PushSig(keys.key1, SIGHASH_ALL, 31, 32).EditPush(1, "43
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG,
"P2PK with too much R padding", SCRIPT_VERIFY_DERSIG │ "P2PK with too much R padding", SCRIPT_VERIFY_DERSIG
).PushSig(keys.key1, SIGHASH_ALL, 31, 32).EditPush(1, "43 │ ).PushSig(keys.key1, SIGHASH_ALL, 31, 32).EditPush(1, "43
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG,
"P2PK with too much S padding but no DERSIG", 0 │ "P2PK with too much S padding but no DERSIG", 0
).PushSig(keys.key1, SIGHASH_ALL).EditPush(1, "44", "45") │ ).PushSig(keys.key1, SIGHASH_ALL).EditPush(1, "44", "45")
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG,
"P2PK with too much S padding", SCRIPT_VERIFY_DERSIG │ "P2PK with too much S padding", SCRIPT_VERIFY_DERSIG
).PushSig(keys.key1, SIGHASH_ALL).EditPush(1, "44", "45") │ ).PushSig(keys.key1, SIGHASH_ALL).EditPush(1, "44", "45")
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG,
"P2PK with too little R padding but no DERSIG", 0 │ "P2PK with too little R padding but no DERSIG", 0
).PushSig(keys.key1, SIGHASH_ALL, 33, 32).EditPush(1, "45 │ ).PushSig(keys.key1, SIGHASH_ALL, 33, 32).EditPush(1, "45
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG,
"P2PK with too little R padding", SCRIPT_VERIFY_DERSIG │ "P2PK with too little R padding", SCRIPT_VERIFY_DERSIG
).PushSig(keys.key1, SIGHASH_ALL, 33, 32).EditPush(1, "45 │ ).PushSig(keys.key1, SIGHASH_ALL, 33, 32).EditPush(1, "45
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey2C) << OP_CHECKSIG │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey2C) << OP_CHECKSIG
"P2PK NOT with bad sig with too much R padding but no DE │ "P2PK NOT with bad sig with too much R padding but no DE
).PushSig(keys.key2, SIGHASH_ALL, 31, 32).EditPush(1, "43 │ ).PushSig(keys.key2, SIGHASH_ALL, 31, 32).EditPush(1, "43
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey2C) << OP_CHECKSIG │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey2C) << OP_CHECKSIG
"P2PK NOT with bad sig with too much R padding", SCRIPT_ │ "P2PK NOT with bad sig with too much R padding", SCRIPT_
).PushSig(keys.key2, SIGHASH_ALL, 31, 32).EditPush(1, "43 │ ).PushSig(keys.key2, SIGHASH_ALL, 31, 32).EditPush(1, "43
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey2C) << OP_CHECKSIG │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey2C) << OP_CHECKSIG
"P2PK NOT with too much R padding but no DERSIG", 0 │ "P2PK NOT with too much R padding but no DERSIG", 0
).PushSig(keys.key2, SIGHASH_ALL, 31, 32).EditPush(1, "43 │ ).PushSig(keys.key2, SIGHASH_ALL, 31, 32).EditPush(1, "43
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey2C) << OP_CHECKSIG │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey2C) << OP_CHECKSIG
"P2PK NOT with too much R padding", SCRIPT_VERIFY_DERSIG │ "P2PK NOT with too much R padding", SCRIPT_VERIFY_DERSIG
).PushSig(keys.key2, SIGHASH_ALL, 31, 32).EditPush(1, "43 │ ).PushSig(keys.key2, SIGHASH_ALL, 31, 32).EditPush(1, "43
│
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG,
"BIP66 example 1, without DERSIG", 0 │ "BIP66 example 1, without DERSIG", 0
).PushSig(keys.key1, SIGHASH_ALL, 33, 32).EditPush(1, "45 │ ).PushSig(keys.key1, SIGHASH_ALL, 33, 32).EditPush(1, "45
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG,
"BIP66 example 1, with DERSIG", SCRIPT_VERIFY_DERSIG │ "BIP66 example 1, with DERSIG", SCRIPT_VERIFY_DERSIG
).PushSig(keys.key1, SIGHASH_ALL, 33, 32).EditPush(1, "45 │ ).PushSig(keys.key1, SIGHASH_ALL, 33, 32).EditPush(1, "45
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG
"BIP66 example 2, without DERSIG", 0 │ "BIP66 example 2, without DERSIG", 0
).PushSig(keys.key1, SIGHASH_ALL, 33, 32).EditPush(1, "45 │ ).PushSig(keys.key1, SIGHASH_ALL, 33, 32).EditPush(1, "45
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG
"BIP66 example 2, with DERSIG", SCRIPT_VERIFY_DERSIG │ "BIP66 example 2, with DERSIG", SCRIPT_VERIFY_DERSIG
).PushSig(keys.key1, SIGHASH_ALL, 33, 32).EditPush(1, "45 │ ).PushSig(keys.key1, SIGHASH_ALL, 33, 32).EditPush(1, "45
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG,
"BIP66 example 3, without DERSIG", 0 │ "BIP66 example 3, without DERSIG", 0
).Num(0).ScriptError(SCRIPT_ERR_EVAL_FALSE)); │ ).Num(0).ScriptError(SCRIPT_ERR_EVAL_FALSE));
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG,
"BIP66 example 3, with DERSIG", SCRIPT_VERIFY_DERSIG │ "BIP66 example 3, with DERSIG", SCRIPT_VERIFY_DERSIG
).Num(0).ScriptError(SCRIPT_ERR_EVAL_FALSE)); │ ).Num(0).ScriptError(SCRIPT_ERR_EVAL_FALSE));
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG
"BIP66 example 4, without DERSIG", 0 │ "BIP66 example 4, without DERSIG", 0
).Num(0)); │ ).Num(0));
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG
"BIP66 example 4, with DERSIG", SCRIPT_VERIFY_DERSIG │ "BIP66 example 4, with DERSIG", SCRIPT_VERIFY_DERSIG
).Num(0)); │ ).Num(0));
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG,
"BIP66 example 5, without DERSIG", 0 │ "BIP66 example 5, without DERSIG", 0
).Num(1).ScriptError(SCRIPT_ERR_EVAL_FALSE)); │ ).Num(1).ScriptError(SCRIPT_ERR_EVAL_FALSE));
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG,
"BIP66 example 5, with DERSIG", SCRIPT_VERIFY_DERSIG │ "BIP66 example 5, with DERSIG", SCRIPT_VERIFY_DERSIG
).Num(1).ScriptError(SCRIPT_ERR_SIG_DER)); │ ).Num(1).ScriptError(SCRIPT_ERR_SIG_DER));
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG
"BIP66 example 6, without DERSIG", 0 │ "BIP66 example 6, without DERSIG", 0
).Num(1)); │ ).Num(1));
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1C) << OP_CHECKSIG
"BIP66 example 6, with DERSIG", SCRIPT_VERIFY_DERSIG │ "BIP66 example 6, with DERSIG", SCRIPT_VERIFY_DERSIG
).Num(1).ScriptError(SCRIPT_ERR_SIG_DER)); │ ).Num(1).ScriptError(SCRIPT_ERR_SIG_DER));
tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy
"BIP66 example 7, without DERSIG", 0 │ "BIP66 example 7, without DERSIG", 0
).Num(0).PushSig(keys.key1, SIGHASH_ALL, 33, 32).EditPush │ ).Num(0).PushSig(keys.key1, SIGHASH_ALL, 33, 32).EditPush
tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy
"BIP66 example 7, with DERSIG", SCRIPT_VERIFY_DERSIG │ "BIP66 example 7, with DERSIG", SCRIPT_VERIFY_DERSIG
).Num(0).PushSig(keys.key1, SIGHASH_ALL, 33, 32).EditPush │ ).Num(0).PushSig(keys.key1, SIGHASH_ALL, 33, 32).EditPush
tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy
"BIP66 example 8, without DERSIG", 0 │ "BIP66 example 8, without DERSIG", 0
).Num(0).PushSig(keys.key1, SIGHASH_ALL, 33, 32).EditPush │ ).Num(0).PushSig(keys.key1, SIGHASH_ALL, 33, 32).EditPush
tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy
"BIP66 example 8, with DERSIG", SCRIPT_VERIFY_DERSIG │ "BIP66 example 8, with DERSIG", SCRIPT_VERIFY_DERSIG
).Num(0).PushSig(keys.key1, SIGHASH_ALL, 33, 32).EditPush │ ).Num(0).PushSig(keys.key1, SIGHASH_ALL, 33, 32).EditPush
tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy
"BIP66 example 9, without DERSIG", 0 │ "BIP66 example 9, without DERSIG", 0
).Num(0).Num(0).PushSig(keys.key2, SIGHASH_ALL, 33, 32).E │ ).Num(0).Num(0).PushSig(keys.key2, SIGHASH_ALL, 33, 32).E
tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy
"BIP66 example 9, with DERSIG", SCRIPT_VERIFY_DERSIG │ "BIP66 example 9, with DERSIG", SCRIPT_VERIFY_DERSIG
).Num(0).Num(0).PushSig(keys.key2, SIGHASH_ALL, 33, 32).E │ ).Num(0).Num(0).PushSig(keys.key2, SIGHASH_ALL, 33, 32).E
tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy
"BIP66 example 10, without DERSIG", 0 │ "BIP66 example 10, without DERSIG", 0
).Num(0).Num(0).PushSig(keys.key2, SIGHASH_ALL, 33, 32).E │ ).Num(0).Num(0).PushSig(keys.key2, SIGHASH_ALL, 33, 32).E
tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy
"BIP66 example 10, with DERSIG", SCRIPT_VERIFY_DERSIG │ "BIP66 example 10, with DERSIG", SCRIPT_VERIFY_DERSIG
).Num(0).Num(0).PushSig(keys.key2, SIGHASH_ALL, 33, 32).E │ ).Num(0).Num(0).PushSig(keys.key2, SIGHASH_ALL, 33, 32).E
tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy
"BIP66 example 11, without DERSIG", 0 │ "BIP66 example 11, without DERSIG", 0
).Num(0).PushSig(keys.key1, SIGHASH_ALL, 33, 32).EditPush │ ).Num(0).PushSig(keys.key1, SIGHASH_ALL, 33, 32).EditPush
tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy
"BIP66 example 11, with DERSIG", SCRIPT_VERIFY_DERSIG │ "BIP66 example 11, with DERSIG", SCRIPT_VERIFY_DERSIG
).Num(0).PushSig(keys.key1, SIGHASH_ALL, 33, 32).EditPush │ ).Num(0).PushSig(keys.key1, SIGHASH_ALL, 33, 32).EditPush
tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy
"BIP66 example 12, without DERSIG", 0 │ "BIP66 example 12, without DERSIG", 0
).Num(0).PushSig(keys.key1, SIGHASH_ALL, 33, 32).EditPush │ ).Num(0).PushSig(keys.key1, SIGHASH_ALL, 33, 32).EditPush
tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy
"BIP66 example 12, with DERSIG", SCRIPT_VERIFY_DERSIG │ "BIP66 example 12, with DERSIG", SCRIPT_VERIFY_DERSIG
).Num(0).PushSig(keys.key1, SIGHASH_ALL, 33, 32).EditPush │ ).Num(0).PushSig(keys.key1, SIGHASH_ALL, 33, 32).EditPush
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey2C) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey2C) << OP_CHECKSIG,
"P2PK with multi-byte hashtype, without DERSIG", 0 │ "P2PK with multi-byte hashtype, without DERSIG", 0
).PushSig(keys.key2, SIGHASH_ALL).EditPush(70, "01", "010 │ ).PushSig(keys.key2, SIGHASH_ALL).EditPush(70, "01", "010
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey2C) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey2C) << OP_CHECKSIG,
"P2PK with multi-byte hashtype, with DERSIG", SCRIPT_VER │ "P2PK with multi-byte hashtype, with DERSIG", SCRIPT_VER
).PushSig(keys.key2, SIGHASH_ALL).EditPush(70, "01", "010 │ ).PushSig(keys.key2, SIGHASH_ALL).EditPush(70, "01", "010
│
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey2C) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey2C) << OP_CHECKSIG,
"P2PK with high S but no LOW_S", 0 │ "P2PK with high S but no LOW_S", 0
).PushSig(keys.key2, SIGHASH_ALL, 32, 33)); │ ).PushSig(keys.key2, SIGHASH_ALL, 32, 33));
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey2C) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey2C) << OP_CHECKSIG,
"P2PK with high S", SCRIPT_VERIFY_LOW_S │ "P2PK with high S", SCRIPT_VERIFY_LOW_S
).PushSig(keys.key2, SIGHASH_ALL, 32, 33).ScriptError(SCR │ ).PushSig(keys.key2, SIGHASH_ALL, 32, 33).ScriptError(SCR
│
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0H) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0H) << OP_CHECKSIG,
"P2PK with hybrid pubkey but no STRICTENC", 0 │ "P2PK with hybrid pubkey but no STRICTENC", 0
).PushSig(keys.key0, SIGHASH_ALL)); │ ).PushSig(keys.key0, SIGHASH_ALL));
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0H) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0H) << OP_CHECKSIG,
"P2PK with hybrid pubkey", SCRIPT_VERIFY_STRICTENC │ "P2PK with hybrid pubkey", SCRIPT_VERIFY_STRICTENC
).PushSig(keys.key0, SIGHASH_ALL).ScriptError(SCRIPT_ERR_ │ ).PushSig(keys.key0, SIGHASH_ALL).ScriptError(SCRIPT_ERR_
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0H) << OP_CHECKSIG │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0H) << OP_CHECKSIG
"P2PK NOT with hybrid pubkey but no STRICTENC", 0 │ "P2PK NOT with hybrid pubkey but no STRICTENC", 0
).PushSig(keys.key0, SIGHASH_ALL).ScriptError(SCRIPT_ERR_ │ ).PushSig(keys.key0, SIGHASH_ALL).ScriptError(SCRIPT_ERR_
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0H) << OP_CHECKSIG │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0H) << OP_CHECKSIG
"P2PK NOT with hybrid pubkey", SCRIPT_VERIFY_STRICTENC │ "P2PK NOT with hybrid pubkey", SCRIPT_VERIFY_STRICTENC
).PushSig(keys.key0, SIGHASH_ALL).ScriptError(SCRIPT_ERR_ │ ).PushSig(keys.key0, SIGHASH_ALL).ScriptError(SCRIPT_ERR_
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0H) << OP_CHECKSIG │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0H) << OP_CHECKSIG
"P2PK NOT with invalid hybrid pubkey but no STRICTENC", │ "P2PK NOT with invalid hybrid pubkey but no STRICTENC",
).PushSig(keys.key0, SIGHASH_ALL).DamagePush(10)); │ ).PushSig(keys.key0, SIGHASH_ALL).DamagePush(10));
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0H) << OP_CHECKSIG │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0H) << OP_CHECKSIG
"P2PK NOT with invalid hybrid pubkey", SCRIPT_VERIFY_STR │ "P2PK NOT with invalid hybrid pubkey", SCRIPT_VERIFY_STR
).PushSig(keys.key0, SIGHASH_ALL).DamagePush(10).ScriptEr │ ).PushSig(keys.key0, SIGHASH_ALL).DamagePush(10).ScriptEr
tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey0H) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey0H) << ToBy
"1-of-2 with the second 1 hybrid pubkey and no STRICTENC │ "1-of-2 with the second 1 hybrid pubkey and no STRICTENC
).Num(0).PushSig(keys.key1, SIGHASH_ALL)); │ ).Num(0).PushSig(keys.key1, SIGHASH_ALL));
tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey0H) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey0H) << ToBy
"1-of-2 with the second 1 hybrid pubkey", SCRIPT_VERIFY_ │ "1-of-2 with the second 1 hybrid pubkey", SCRIPT_VERIFY_
).Num(0).PushSig(keys.key1, SIGHASH_ALL)); │ ).Num(0).PushSig(keys.key1, SIGHASH_ALL));
tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1C) << ToBy
"1-of-2 with the first 1 hybrid pubkey", SCRIPT_VERIFY_S │ "1-of-2 with the first 1 hybrid pubkey", SCRIPT_VERIFY_S
).Num(0).PushSig(keys.key1, SIGHASH_ALL).ScriptError(SCRI │ ).Num(0).PushSig(keys.key1, SIGHASH_ALL).ScriptError(SCRI
│
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1) << OP_CHECKSIG,
"P2PK with undefined hashtype but no STRICTENC", 0 │ "P2PK with undefined hashtype but no STRICTENC", 0
).PushSig(keys.key1, 5)); │ ).PushSig(keys.key1, 5));
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1) << OP_CHECKSIG,
"P2PK with undefined hashtype", SCRIPT_VERIFY_STRICTENC │ "P2PK with undefined hashtype", SCRIPT_VERIFY_STRICTENC
).PushSig(keys.key1, 5).ScriptError(SCRIPT_ERR_SIG_HASHTY │ ).PushSig(keys.key1, 5).ScriptError(SCRIPT_ERR_SIG_HASHTY
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1) << OP_CHECKSIG < │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1) << OP_CHECKSIG <
"P2PK NOT with invalid sig and undefined hashtype but no │ "P2PK NOT with invalid sig and undefined hashtype but no
).PushSig(keys.key1, 5).DamagePush(10)); │ ).PushSig(keys.key1, 5).DamagePush(10));
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1) << OP_CHECKSIG < │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1) << OP_CHECKSIG <
"P2PK NOT with invalid sig and undefined hashtype", SCRI │ "P2PK NOT with invalid sig and undefined hashtype", SCRI
).PushSig(keys.key1, 5).DamagePush(10).ScriptError(SCRIPT │ ).PushSig(keys.key1, 5).DamagePush(10).ScriptError(SCRIPT
│
tests.push_back(TestBuilder(CScript() << OP_3 << ToByteVector(keys.pubkey0C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_3 << ToByteVector(keys.pubkey0C) << ToBy
"3-of-3 with nonzero dummy but no NULLDUMMY", 0 │ "3-of-3 with nonzero dummy but no NULLDUMMY", 0
).Num(1).PushSig(keys.key0).PushSig(keys.key1).PushSig(ke │ ).Num(1).PushSig(keys.key0).PushSig(keys.key1).PushSig(ke
tests.push_back(TestBuilder(CScript() << OP_3 << ToByteVector(keys.pubkey0C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_3 << ToByteVector(keys.pubkey0C) << ToBy
"3-of-3 with nonzero dummy", SCRIPT_VERIFY_NULLDUMMY │ "3-of-3 with nonzero dummy", SCRIPT_VERIFY_NULLDUMMY
).Num(1).PushSig(keys.key0).PushSig(keys.key1).PushSig(ke │ ).Num(1).PushSig(keys.key0).PushSig(keys.key1).PushSig(ke
tests.push_back(TestBuilder(CScript() << OP_3 << ToByteVector(keys.pubkey0C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_3 << ToByteVector(keys.pubkey0C) << ToBy
"3-of-3 NOT with invalid sig and nonzero dummy but no NU │ "3-of-3 NOT with invalid sig and nonzero dummy but no NU
).Num(1).PushSig(keys.key0).PushSig(keys.key1).PushSig(ke │ ).Num(1).PushSig(keys.key0).PushSig(keys.key1).PushSig(ke
tests.push_back(TestBuilder(CScript() << OP_3 << ToByteVector(keys.pubkey0C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_3 << ToByteVector(keys.pubkey0C) << ToBy
"3-of-3 NOT with invalid sig with nonzero dummy", SCRIPT │ "3-of-3 NOT with invalid sig with nonzero dummy", SCRIPT
).Num(1).PushSig(keys.key0).PushSig(keys.key1).PushSig(ke │ ).Num(1).PushSig(keys.key0).PushSig(keys.key1).PushSig(ke
│
tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy
"2-of-2 with two identical keys and sigs pushed using OP │ "2-of-2 with two identical keys and sigs pushed using OP
).Num(0).PushSig(keys.key1).Add(CScript() << OP_DUP)); │ ).Num(0).PushSig(keys.key1).Opcode(OP_DUP));
tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy
"2-of-2 with two identical keys and sigs pushed using OP │ "2-of-2 with two identical keys and sigs pushed using OP
).Num(0).PushSig(keys.key1).Add(CScript() << OP_DUP).Scri │ ).Num(0).PushSig(keys.key1).Opcode(OP_DUP).ScriptError(SC
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey2C) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey2C) << OP_CHECKSIG,
"P2SH(P2PK) with non-push scriptSig but no P2SH or SIGPU │ "P2SH(P2PK) with non-push scriptSig but no P2SH or SIGPU
).PushSig(keys.key2).Add(CScript() << OP_NOP8).PushRedeem │ ).PushSig(keys.key2).Opcode(OP_NOP8).PushRedeem());
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey2C) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey2C) << OP_CHECKSIG,
"P2PK with non-push scriptSig but with P2SH validation", │ "P2PK with non-push scriptSig but with P2SH validation",
).PushSig(keys.key2).Add(CScript() << OP_NOP8)); │ ).PushSig(keys.key2).Opcode(OP_NOP8));
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey2C) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey2C) << OP_CHECKSIG,
"P2SH(P2PK) with non-push scriptSig but no SIGPUSHONLY", │ "P2SH(P2PK) with non-push scriptSig but no SIGPUSHONLY",
).PushSig(keys.key2).Add(CScript() << OP_NOP8).PushRedeem │ ).PushSig(keys.key2).Opcode(OP_NOP8).PushRedeem().ScriptE
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey2C) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey2C) << OP_CHECKSIG,
"P2SH(P2PK) with non-push scriptSig but not P2SH", SCRIP │ "P2SH(P2PK) with non-push scriptSig but not P2SH", SCRIP
).PushSig(keys.key2).Add(CScript() << OP_NOP8).PushRedeem │ ).PushSig(keys.key2).Opcode(OP_NOP8).PushRedeem().ScriptE
tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_2 << ToByteVector(keys.pubkey1C) << ToBy
"2-of-2 with two identical keys and sigs pushed", SCRIPT │ "2-of-2 with two identical keys and sigs pushed", SCRIPT
).Num(0).PushSig(keys.key1).PushSig(keys.key1)); │ ).Num(0).PushSig(keys.key1).PushSig(keys.key1));
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG,
"P2PK with unnecessary input but no CLEANSTACK", SCRIPT_ │ "P2PK with unnecessary input but no CLEANSTACK", SCRIPT_
).Num(11).PushSig(keys.key0)); │ ).Num(11).PushSig(keys.key0));
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG,
"P2PK with unnecessary input", SCRIPT_VERIFY_CLEANSTACK │ "P2PK with unnecessary input", SCRIPT_VERIFY_CLEANSTACK
).Num(11).PushSig(keys.key0).ScriptError(SCRIPT_ERR_CLEAN │ ).Num(11).PushSig(keys.key0).ScriptError(SCRIPT_ERR_CLEAN
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG,
"P2SH with unnecessary input but no CLEANSTACK", SCRIPT_ │ "P2SH with unnecessary input but no CLEANSTACK", SCRIPT_
).Num(11).PushSig(keys.key0).PushRedeem()); │ ).Num(11).PushSig(keys.key0).PushRedeem());
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG,
"P2SH with unnecessary input", SCRIPT_VERIFY_CLEANSTACK │ "P2SH with unnecessary input", SCRIPT_VERIFY_CLEANSTACK
).Num(11).PushSig(keys.key0).PushRedeem().ScriptError(SCR │ ).Num(11).PushSig(keys.key0).PushRedeem().ScriptError(SCR
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG,
"P2SH with CLEANSTACK", SCRIPT_VERIFY_CLEANSTACK | SCRIP │ "P2SH with CLEANSTACK", SCRIPT_VERIFY_CLEANSTACK | SCRIP
).PushSig(keys.key0).PushRedeem()); │ ).PushSig(keys.key0).PushRedeem());
│
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG,
"Basic P2WSH", SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2S │ "Basic P2WSH", SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2S
0, 1).PushWitSig(keys.key0).PushWitRedeem()); │ 0, 1).PushWitSig(keys.key0).PushWitRedeem());
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0), │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0),
"Basic P2WPKH", SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2 │ "Basic P2WPKH", SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2
0, 1).PushWitSig(keys.key0).Push(keys.pubkey0).AsWit()); │ 0, 1).PushWitSig(keys.key0).Push(keys.pubkey0).AsWit());
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG,
"Basic P2SH(P2WSH)", SCRIPT_VERIFY_WITNESS | SCRIPT_VERI │ "Basic P2SH(P2WSH)", SCRIPT_VERIFY_WITNESS | SCRIPT_VERI
0, 1).PushWitSig(keys.key0).PushWitRedeem().PushRedeem() │ 0, 1).PushWitSig(keys.key0).PushWitRedeem().PushRedeem()
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0), │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0),
"Basic P2SH(P2WPKH)", SCRIPT_VERIFY_WITNESS | SCRIPT_VER │ "Basic P2SH(P2WPKH)", SCRIPT_VERIFY_WITNESS | SCRIPT_VER
0, 1).PushWitSig(keys.key0).Push(keys.pubkey0).AsWit().P │ 0, 1).PushWitSig(keys.key0).Push(keys.pubkey0).AsWit().P
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1) << OP_CHECKSIG,
"Basic P2WSH with the wrong key", SCRIPT_VERIFY_WITNESS │ "Basic P2WSH with the wrong key", SCRIPT_VERIFY_WITNESS
).PushWitSig(keys.key0).PushWitRedeem().ScriptError(SCRIP │ ).PushWitSig(keys.key0).PushWitRedeem().ScriptError(SCRIP
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1), │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1),
"Basic P2WPKH with the wrong key", SCRIPT_VERIFY_WITNESS │ "Basic P2WPKH with the wrong key", SCRIPT_VERIFY_WITNESS
).PushWitSig(keys.key0).Push(keys.pubkey1).AsWit().Script │ ).PushWitSig(keys.key0).Push(keys.pubkey1).AsWit().Script
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1) << OP_CHECKSIG,
"Basic P2SH(P2WSH) with the wrong key", SCRIPT_VERIFY_WI │ "Basic P2SH(P2WSH) with the wrong key", SCRIPT_VERIFY_WI
).PushWitSig(keys.key0).PushWitRedeem().PushRedeem().Scri │ ).PushWitSig(keys.key0).PushWitRedeem().PushRedeem().Scri
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1), │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1),
"Basic P2SH(P2WPKH) with the wrong key", SCRIPT_VERIFY_W │ "Basic P2SH(P2WPKH) with the wrong key", SCRIPT_VERIFY_W
).PushWitSig(keys.key0).Push(keys.pubkey1).AsWit().PushRe │ ).PushWitSig(keys.key0).Push(keys.pubkey1).AsWit().PushRe
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1) << OP_CHECKSIG,
"Basic P2WSH with the wrong key but no WITNESS", SCRIPT_ │ "Basic P2WSH with the wrong key but no WITNESS", SCRIPT_
).PushWitSig(keys.key0).PushWitRedeem()); │ ).PushWitSig(keys.key0).PushWitRedeem());
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1), │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1),
"Basic P2WPKH with the wrong key but no WITNESS", SCRIPT │ "Basic P2WPKH with the wrong key but no WITNESS", SCRIPT
).PushWitSig(keys.key0).Push(keys.pubkey1).AsWit()); │ ).PushWitSig(keys.key0).Push(keys.pubkey1).AsWit());
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1) << OP_CHECKSIG,
"Basic P2SH(P2WSH) with the wrong key but no WITNESS", S │ "Basic P2SH(P2WSH) with the wrong key but no WITNESS", S
).PushWitSig(keys.key0).PushWitRedeem().PushRedeem()); │ ).PushWitSig(keys.key0).PushWitRedeem().PushRedeem());
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1), │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1),
"Basic P2SH(P2WPKH) with the wrong key but no WITNESS", │ "Basic P2SH(P2WPKH) with the wrong key but no WITNESS",
).PushWitSig(keys.key0).Push(keys.pubkey1).AsWit().PushRe │ ).PushWitSig(keys.key0).Push(keys.pubkey1).AsWit().PushRe
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG,
"Basic P2WSH with wrong value", SCRIPT_VERIFY_WITNESS | │ "Basic P2WSH with wrong value", SCRIPT_VERIFY_WITNESS |
0, 0).PushWitSig(keys.key0, 1).PushWitRedeem().ScriptErr │ 0, 0).PushWitSig(keys.key0, 1).PushWitRedeem().ScriptErr
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0), │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0),
"Basic P2WPKH with wrong value", SCRIPT_VERIFY_WITNESS | │ "Basic P2WPKH with wrong value", SCRIPT_VERIFY_WITNESS |
0, 0).PushWitSig(keys.key0, 1).Push(keys.pubkey0).AsWit( │ 0, 0).PushWitSig(keys.key0, 1).Push(keys.pubkey0).AsWit(
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG,
"Basic P2SH(P2WSH) with wrong value", SCRIPT_VERIFY_WITN │ "Basic P2SH(P2WSH) with wrong value", SCRIPT_VERIFY_WITN
0, 0).PushWitSig(keys.key0, 1).PushWitRedeem().PushRedee │ 0, 0).PushWitSig(keys.key0, 1).PushWitRedeem().PushRedee
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0), │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0),
"Basic P2SH(P2WPKH) with wrong value", SCRIPT_VERIFY_WIT │ "Basic P2SH(P2WPKH) with wrong value", SCRIPT_VERIFY_WIT
0, 0).PushWitSig(keys.key0, 1).Push(keys.pubkey0).AsWit( │ 0, 0).PushWitSig(keys.key0, 1).Push(keys.pubkey0).AsWit(
│
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0), │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0),
"P2WPKH with future witness version", SCRIPT_VERIFY_WITN │ "P2WPKH with future witness version", SCRIPT_VERIFY_WITN
SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM, fal │ SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM, fal
).PushWitSig(keys.key0).Push(keys.pubkey0).AsWit().Script │ ).PushWitSig(keys.key0).Push(keys.pubkey0).AsWit().Script
{ │ {
CScript witscript = CScript() << ToByteVector(keys.pubkey0); │ CScript witscript = CScript() << ToByteVector(keys.pubkey0);
uint256 hash; │ uint256 hash;
CSHA256().Write(&witscript[0], witscript.size()).Finalize(hash.begin()); │ CSHA256().Write(witscript.data(), witscript.size()).Finalize(hash.begin());
std::vector<unsigned char> hashBytes = ToByteVector(hash); │ std::vector<unsigned char> hashBytes = ToByteVector(hash);
hashBytes.pop_back(); │ hashBytes.pop_back();
tests.push_back(TestBuilder(CScript() << OP_0 << hashBytes, │ tests.push_back(TestBuilder(CScript() << OP_0 << hashBytes,
"P2WPKH with wrong witness program length", SCRIPT_V │ "P2WPKH with wrong witness program length", SCRIPT_V
).PushWitSig(keys.key0).Push(keys.pubkey0).AsWit().Sc │ ).PushWitSig(keys.key0).Push(keys.pubkey0).AsWit().Sc
} │ }
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG,
"P2WSH with empty witness", SCRIPT_VERIFY_WITNESS | SCRI │ "P2WSH with empty witness", SCRIPT_VERIFY_WITNESS | SCRI
).ScriptError(SCRIPT_ERR_WITNESS_PROGRAM_WITNESS_EMPTY)); │ ).ScriptError(SCRIPT_ERR_WITNESS_PROGRAM_WITNESS_EMPTY));
{ │ {
CScript witscript = CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG; │ CScript witscript = CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG;
tests.push_back(TestBuilder(witscript, │ tests.push_back(TestBuilder(witscript,
"P2WSH with witness program mismatch", SCRIPT_VERIFY │ "P2WSH with witness program mismatch", SCRIPT_VERIFY
).PushWitSig(keys.key0).Push(witscript).DamagePush(0) │ ).PushWitSig(keys.key0).Push(witscript).DamagePush(0)
} │ }
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0), │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0),
"P2WPKH with witness program mismatch", SCRIPT_VERIFY_WI │ "P2WPKH with witness program mismatch", SCRIPT_VERIFY_WI
).PushWitSig(keys.key0).Push(keys.pubkey0).AsWit().Push(" │ ).PushWitSig(keys.key0).Push(keys.pubkey0).AsWit().Push("
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0), │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0),
"P2WPKH with non-empty scriptSig", SCRIPT_VERIFY_WITNESS │ "P2WPKH with non-empty scriptSig", SCRIPT_VERIFY_WITNESS
).PushWitSig(keys.key0).Push(keys.pubkey0).AsWit().Num(11 │ ).PushWitSig(keys.key0).Push(keys.pubkey0).AsWit().Num(11
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1), │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey1),
"P2SH(P2WPKH) with superfluous push in scriptSig", SCRIP │ "P2SH(P2WPKH) with superfluous push in scriptSig", SCRIP
).PushWitSig(keys.key0).Push(keys.pubkey1).AsWit().Num(11 │ ).PushWitSig(keys.key0).Push(keys.pubkey1).AsWit().Num(11
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG,
"P2PK with witness", SCRIPT_VERIFY_WITNESS | SCRIPT_VERI │ "P2PK with witness", SCRIPT_VERIFY_WITNESS | SCRIPT_VERI
).PushSig(keys.key0).Push("0").AsWit().ScriptError(SCRIPT │ ).PushSig(keys.key0).Push("0").AsWit().ScriptError(SCRIPT
│
// Compressed keys should pass SCRIPT_VERIFY_WITNESS_PUBKEYTYPE │ // Compressed keys should pass SCRIPT_VERIFY_WITNESS_PUBKEYTYPE
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0C) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0C) << OP_CHECKSIG,
"Basic P2WSH with compressed key", SCRIPT_VERIFY_WITNESS │ "Basic P2WSH with compressed key", SCRIPT_VERIFY_WITNESS
0, 1).PushWitSig(keys.key0C).PushWitRedeem()); │ 0, 1).PushWitSig(keys.key0C).PushWitRedeem());
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0C), │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0C),
"Basic P2WPKH with compressed key", SCRIPT_VERIFY_WITNES │ "Basic P2WPKH with compressed key", SCRIPT_VERIFY_WITNES
0, 1).PushWitSig(keys.key0C).Push(keys.pubkey0C).AsWit() │ 0, 1).PushWitSig(keys.key0C).Push(keys.pubkey0C).AsWit()
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0C) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0C) << OP_CHECKSIG,
"Basic P2SH(P2WSH) with compressed key", SCRIPT_VERIFY_W │ "Basic P2SH(P2WSH) with compressed key", SCRIPT_VERIFY_W
0, 1).PushWitSig(keys.key0C).PushWitRedeem().PushRedeem( │ 0, 1).PushWitSig(keys.key0C).PushWitRedeem().PushRedeem(
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0C), │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0C),
"Basic P2SH(P2WPKH) with compressed key", SCRIPT_VERIFY_ │ "Basic P2SH(P2WPKH) with compressed key", SCRIPT_VERIFY_
0, 1).PushWitSig(keys.key0C).Push(keys.pubkey0C).AsWit() │ 0, 1).PushWitSig(keys.key0C).Push(keys.pubkey0C).AsWit()
│
// Testing uncompressed key in witness with SCRIPT_VERIFY_WITNESS_PUBKEYTYPE │ // Testing uncompressed key in witness with SCRIPT_VERIFY_WITNESS_PUBKEYTYPE
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG,
"Basic P2WSH", SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2S │ "Basic P2WSH", SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2S
0, 1).PushWitSig(keys.key0).PushWitRedeem().ScriptError( │ 0, 1).PushWitSig(keys.key0).PushWitRedeem().ScriptError(
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0), │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0),
"Basic P2WPKH", SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2 │ "Basic P2WPKH", SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2
0, 1).PushWitSig(keys.key0).Push(keys.pubkey0).AsWit().S │ 0, 1).PushWitSig(keys.key0).Push(keys.pubkey0).AsWit().S
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG, │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0) << OP_CHECKSIG,
"Basic P2SH(P2WSH)", SCRIPT_VERIFY_WITNESS | SCRIPT_VERI │ "Basic P2SH(P2WSH)", SCRIPT_VERIFY_WITNESS | SCRIPT_VERI
0, 1).PushWitSig(keys.key0).PushWitRedeem().PushRedeem() │ 0, 1).PushWitSig(keys.key0).PushWitRedeem().PushRedeem()
tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0), │ tests.push_back(TestBuilder(CScript() << ToByteVector(keys.pubkey0),
"Basic P2SH(P2WPKH)", SCRIPT_VERIFY_WITNESS | SCRIPT_VER │ "Basic P2SH(P2WPKH)", SCRIPT_VERIFY_WITNESS | SCRIPT_VER
0, 1).PushWitSig(keys.key0).Push(keys.pubkey0).AsWit().P │ 0, 1).PushWitSig(keys.key0).Push(keys.pubkey0).AsWit().P
│
// P2WSH 1-of-2 multisig with compressed keys │ // P2WSH 1-of-2 multisig with compressed keys
tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1C) << ToBy
"P2WSH CHECKMULTISIG with compressed keys", SCRIPT_VERIF │ "P2WSH CHECKMULTISIG with compressed keys", SCRIPT_VERIF
0, 1).Push(CScript()).AsWit().PushWitSig(keys.key0C).Pus │ 0, 1).Push(CScript()).AsWit().PushWitSig(keys.key0C).Pus
tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1C) << ToBy
"P2SH(P2WSH) CHECKMULTISIG with compressed keys", SCRIPT │ "P2SH(P2WSH) CHECKMULTISIG with compressed keys", SCRIPT
0, 1).Push(CScript()).AsWit().PushWitSig(keys.key0C).Pus │ 0, 1).Push(CScript()).AsWit().PushWitSig(keys.key0C).Pus
tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1C) << ToBy
"P2WSH CHECKMULTISIG with compressed keys", SCRIPT_VERIF │ "P2WSH CHECKMULTISIG with compressed keys", SCRIPT_VERIF
0, 1).Push(CScript()).AsWit().PushWitSig(keys.key1C).Pus │ 0, 1).Push(CScript()).AsWit().PushWitSig(keys.key1C).Pus
tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1C) << ToBy
"P2SH(P2WSH) CHECKMULTISIG with compressed keys", SCRIPT │ "P2SH(P2WSH) CHECKMULTISIG with compressed keys", SCRIPT
0, 1).Push(CScript()).AsWit().PushWitSig(keys.key1C).Pus │ 0, 1).Push(CScript()).AsWit().PushWitSig(keys.key1C).Pus
│
// P2WSH 1-of-2 multisig with first key uncompressed │ // P2WSH 1-of-2 multisig with first key uncompressed
tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1C) << ToBy
"P2WSH CHECKMULTISIG with first key uncompressed and sig │ "P2WSH CHECKMULTISIG with first key uncompressed and sig
0, 1).Push(CScript()).AsWit().PushWitSig(keys.key0).Push │ 0, 1).Push(CScript()).AsWit().PushWitSig(keys.key0).Push
tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1C) << ToBy
"P2SH(P2WSH) CHECKMULTISIG first key uncompressed and si │ "P2SH(P2WSH) CHECKMULTISIG first key uncompressed and si
0, 1).Push(CScript()).AsWit().PushWitSig(keys.key0).Push │ 0, 1).Push(CScript()).AsWit().PushWitSig(keys.key0).Push
tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1C) << ToBy
"P2WSH CHECKMULTISIG with first key uncompressed and sig │ "P2WSH CHECKMULTISIG with first key uncompressed and sig
0, 1).Push(CScript()).AsWit().PushWitSig(keys.key0).Push │ 0, 1).Push(CScript()).AsWit().PushWitSig(keys.key0).Push
tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1C) << ToBy
"P2SH(P2WSH) CHECKMULTISIG with first key uncompressed a │ "P2SH(P2WSH) CHECKMULTISIG with first key uncompressed a
0, 1).Push(CScript()).AsWit().PushWitSig(keys.key0).Push │ 0, 1).Push(CScript()).AsWit().PushWitSig(keys.key0).Push
tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1C) << ToBy
"P2WSH CHECKMULTISIG with first key uncompressed and sig │ "P2WSH CHECKMULTISIG with first key uncompressed and sig
0, 1).Push(CScript()).AsWit().PushWitSig(keys.key1C).Pus │ 0, 1).Push(CScript()).AsWit().PushWitSig(keys.key1C).Pus
tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1C) << ToBy
"P2SH(P2WSH) CHECKMULTISIG with first key uncompressed a │ "P2SH(P2WSH) CHECKMULTISIG with first key uncompressed a
0, 1).Push(CScript()).AsWit().PushWitSig(keys.key1C).Pus │ 0, 1).Push(CScript()).AsWit().PushWitSig(keys.key1C).Pus
tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1C) << ToBy
"P2WSH CHECKMULTISIG with first key uncompressed and sig │ "P2WSH CHECKMULTISIG with first key uncompressed and sig
0, 1).Push(CScript()).AsWit().PushWitSig(keys.key1C).Pus │ 0, 1).Push(CScript()).AsWit().PushWitSig(keys.key1C).Pus
tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1C) << ToBy │ tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1C) << ToBy
"P2SH(P2WSH) CHECKMULTISIG with first key uncompressed a │ "P2SH(P2WSH) CHECKMULTISIG with first key uncompressed a
0, 1).Push(CScript()).AsWit().PushWitSig(keys.key1C).Pus │ 0, 1).Push(CScript()).AsWit().PushWitSig(keys.key1C).Pus
// P2WSH 1-of-2 multisig with second key uncompressed │ // P2WSH 1-of-2 multisig with second key uncompressed
tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1) << ToByt │ tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1) << ToByt
"P2WSH CHECKMULTISIG with second key uncompressed and si │ "P2WSH CHECKMULTISIG with second key uncompressed and si
0, 1).Push(CScript()).AsWit().PushWitSig(keys.key0C).Pus │ 0, 1).Push(CScript()).AsWit().PushWitSig(keys.key0C).Pus
tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1) << ToByt │ tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1) << ToByt
"P2SH(P2WSH) CHECKMULTISIG second key uncompressed and s │ "P2SH(P2WSH) CHECKMULTISIG second key uncompressed and s
0, 1).Push(CScript()).AsWit().PushWitSig(keys.key0C).Pus │ 0, 1).Push(CScript()).AsWit().PushWitSig(keys.key0C).Pus
tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1) << ToByt │ tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1) << ToByt
"P2WSH CHECKMULTISIG with second key uncompressed and si │ "P2WSH CHECKMULTISIG with second key uncompressed and si
0, 1).Push(CScript()).AsWit().PushWitSig(keys.key0C).Pus │ 0, 1).Push(CScript()).AsWit().PushWitSig(keys.key0C).Pus
tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1) << ToByt │ tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1) << ToByt
"P2SH(P2WSH) CHECKMULTISIG with second key uncompressed │ "P2SH(P2WSH) CHECKMULTISIG with second key uncompressed
0, 1).Push(CScript()).AsWit().PushWitSig(keys.key0C).Pus │ 0, 1).Push(CScript()).AsWit().PushWitSig(keys.key0C).Pus
tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1) << ToByt │ tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1) << ToByt
"P2WSH CHECKMULTISIG with second key uncompressed and si │ "P2WSH CHECKMULTISIG with second key uncompressed and si
0, 1).Push(CScript()).AsWit().PushWitSig(keys.key1).Push │ 0, 1).Push(CScript()).AsWit().PushWitSig(keys.key1).Push
tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1) << ToByt │ tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1) << ToByt
"P2SH(P2WSH) CHECKMULTISIG with second key uncompressed │ "P2SH(P2WSH) CHECKMULTISIG with second key uncompressed
0, 1).Push(CScript()).AsWit().PushWitSig(keys.key1).Push │ 0, 1).Push(CScript()).AsWit().PushWitSig(keys.key1).Push
tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1) << ToByt │ tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1) << ToByt
"P2WSH CHECKMULTISIG with second key uncompressed and si │ "P2WSH CHECKMULTISIG with second key uncompressed and si
0, 1).Push(CScript()).AsWit().PushWitSig(keys.key1).Push │ 0, 1).Push(CScript()).AsWit().PushWitSig(keys.key1).Push
tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1) << ToByt │ tests.push_back(TestBuilder(CScript() << OP_1 << ToByteVector(keys.pubkey1) << ToByt
"P2SH(P2WSH) CHECKMULTISIG with second key uncompressed │ "P2SH(P2WSH) CHECKMULTISIG with second key uncompressed
0, 1).Push(CScript()).AsWit().PushWitSig(keys.key1).Push │ 0, 1).Push(CScript()).AsWit().PushWitSig(keys.key1).Push
│
std::set<std::string> tests_set; │ std::set<std::string> tests_set;
│
{ │ {
UniValue json_tests = read_json(std::string(json_tests::script_tests, json_tests │ UniValue json_tests = read_json(std::string(json_tests::script_tests, json_tests
│
for (unsigned int idx = 0; idx < json_tests.size(); idx++) { │ for (unsigned int idx = 0; idx < json_tests.size(); idx++) {
const UniValue& tv = json_tests[idx]; │ const UniValue& tv = json_tests[idx];
tests_set.insert(JSONPrettyPrint(tv.get_array())); │ tests_set.insert(JSONPrettyPrint(tv.get_array()));
} │ }
} │ }
│
│ #ifdef UPDATE_JSON_TESTS
std::string strGen; │ std::string strGen;
│ #endif
BOOST_FOREACH(TestBuilder& test, tests) { │ for (TestBuilder& test : tests) {
test.Test(); │ test.Test();
std::string str = JSONPrettyPrint(test.GetJSON()); │ std::string str = JSONPrettyPrint(test.GetJSON());
#ifndef UPDATE_JSON_TESTS │ #ifdef UPDATE_JSON_TESTS
│ strGen += str + ",\n";
│ #else
if (tests_set.count(str) == 0) { │ if (tests_set.count(str) == 0) {
BOOST_CHECK_MESSAGE(false, "Missing auto script_valid test: " + test.GetComm │ BOOST_CHECK_MESSAGE(false, "Missing auto script_valid test: " + test.GetComm
} │ }
#endif │ #endif
strGen += str + ",\n"; │
} │ }
│
#ifdef UPDATE_JSON_TESTS │ #ifdef UPDATE_JSON_TESTS
FILE* file = fopen("script_tests.json.gen", "w"); │ FILE* file = fsbridge::fopen("script_tests.json.gen", "w");
fputs(strGen.c_str(), file); │ fputs(strGen.c_str(), file);
fclose(file); │ fclose(file);
#endif │ #endif
} │
next prev up bitcoin/src/crypto/sha256_sse41.cpp:68 │ bitcoin/src/crypto/sha256_avx2.cpp:76
│
// Transform 1 │ // Transform 1
__m128i a = K(0x6a09e667ul); │ __m256i a = K(0x6a09e667ul);
__m128i b = K(0xbb67ae85ul); │ __m256i b = K(0xbb67ae85ul);
__m128i c = K(0x3c6ef372ul); │ __m256i c = K(0x3c6ef372ul);
__m128i d = K(0xa54ff53aul); │ __m256i d = K(0xa54ff53aul);
__m128i e = K(0x510e527ful); │ __m256i e = K(0x510e527ful);
__m128i f = K(0x9b05688cul); │ __m256i f = K(0x9b05688cul);
__m128i g = K(0x1f83d9abul); │ __m256i g = K(0x1f83d9abul);
__m128i h = K(0x5be0cd19ul); │ __m256i h = K(0x5be0cd19ul);
│
__m128i w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15; │ __m256i w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15;
│
Round(a, b, c, d, e, f, g, h, Add(K(0x428a2f98ul), w0 = Read4(in, 0))); │ Round(a, b, c, d, e, f, g, h, Add(K(0x428a2f98ul), w0 = Read8(in, 0)));
Round(h, a, b, c, d, e, f, g, Add(K(0x71374491ul), w1 = Read4(in, 4))); │ Round(h, a, b, c, d, e, f, g, Add(K(0x71374491ul), w1 = Read8(in, 4)));
Round(g, h, a, b, c, d, e, f, Add(K(0xb5c0fbcful), w2 = Read4(in, 8))); │ Round(g, h, a, b, c, d, e, f, Add(K(0xb5c0fbcful), w2 = Read8(in, 8)));
Round(f, g, h, a, b, c, d, e, Add(K(0xe9b5dba5ul), w3 = Read4(in, 12))); │ Round(f, g, h, a, b, c, d, e, Add(K(0xe9b5dba5ul), w3 = Read8(in, 12)));
Round(e, f, g, h, a, b, c, d, Add(K(0x3956c25bul), w4 = Read4(in, 16))); │ Round(e, f, g, h, a, b, c, d, Add(K(0x3956c25bul), w4 = Read8(in, 16)));
Round(d, e, f, g, h, a, b, c, Add(K(0x59f111f1ul), w5 = Read4(in, 20))); │ Round(d, e, f, g, h, a, b, c, Add(K(0x59f111f1ul), w5 = Read8(in, 20)));
Round(c, d, e, f, g, h, a, b, Add(K(0x923f82a4ul), w6 = Read4(in, 24))); │ Round(c, d, e, f, g, h, a, b, Add(K(0x923f82a4ul), w6 = Read8(in, 24)));
Round(b, c, d, e, f, g, h, a, Add(K(0xab1c5ed5ul), w7 = Read4(in, 28))); │ Round(b, c, d, e, f, g, h, a, Add(K(0xab1c5ed5ul), w7 = Read8(in, 28)));
Round(a, b, c, d, e, f, g, h, Add(K(0xd807aa98ul), w8 = Read4(in, 32))); │ Round(a, b, c, d, e, f, g, h, Add(K(0xd807aa98ul), w8 = Read8(in, 32)));
Round(h, a, b, c, d, e, f, g, Add(K(0x12835b01ul), w9 = Read4(in, 36))); │ Round(h, a, b, c, d, e, f, g, Add(K(0x12835b01ul), w9 = Read8(in, 36)));
Round(g, h, a, b, c, d, e, f, Add(K(0x243185beul), w10 = Read4(in, 40))); │ Round(g, h, a, b, c, d, e, f, Add(K(0x243185beul), w10 = Read8(in, 40)));
Round(f, g, h, a, b, c, d, e, Add(K(0x550c7dc3ul), w11 = Read4(in, 44))); │ Round(f, g, h, a, b, c, d, e, Add(K(0x550c7dc3ul), w11 = Read8(in, 44)));
Round(e, f, g, h, a, b, c, d, Add(K(0x72be5d74ul), w12 = Read4(in, 48))); │ Round(e, f, g, h, a, b, c, d, Add(K(0x72be5d74ul), w12 = Read8(in, 48)));
Round(d, e, f, g, h, a, b, c, Add(K(0x80deb1feul), w13 = Read4(in, 52))); │ Round(d, e, f, g, h, a, b, c, Add(K(0x80deb1feul), w13 = Read8(in, 52)));
Round(c, d, e, f, g, h, a, b, Add(K(0x9bdc06a7ul), w14 = Read4(in, 56))); │ Round(c, d, e, f, g, h, a, b, Add(K(0x9bdc06a7ul), w14 = Read8(in, 56)));
Round(b, c, d, e, f, g, h, a, Add(K(0xc19bf174ul), w15 = Read4(in, 60))); │ Round(b, c, d, e, f, g, h, a, Add(K(0xc19bf174ul), w15 = Read8(in, 60)));
Round(a, b, c, d, e, f, g, h, Add(K(0xe49b69c1ul), Inc(w0, sigma1(w14), w9, sigma0(w │ Round(a, b, c, d, e, f, g, h, Add(K(0xe49b69c1ul), Inc(w0, sigma1(w14), w9, sigma0(w
Round(h, a, b, c, d, e, f, g, Add(K(0xefbe4786ul), Inc(w1, sigma1(w15), w10, sigma0( │ Round(h, a, b, c, d, e, f, g, Add(K(0xefbe4786ul), Inc(w1, sigma1(w15), w10, sigma0(
Round(g, h, a, b, c, d, e, f, Add(K(0x0fc19dc6ul), Inc(w2, sigma1(w0), w11, sigma0(w │ Round(g, h, a, b, c, d, e, f, Add(K(0x0fc19dc6ul), Inc(w2, sigma1(w0), w11, sigma0(w
Round(f, g, h, a, b, c, d, e, Add(K(0x240ca1ccul), Inc(w3, sigma1(w1), w12, sigma0(w │ Round(f, g, h, a, b, c, d, e, Add(K(0x240ca1ccul), Inc(w3, sigma1(w1), w12, sigma0(w
Round(e, f, g, h, a, b, c, d, Add(K(0x2de92c6ful), Inc(w4, sigma1(w2), w13, sigma0(w │ Round(e, f, g, h, a, b, c, d, Add(K(0x2de92c6ful), Inc(w4, sigma1(w2), w13, sigma0(w
Round(d, e, f, g, h, a, b, c, Add(K(0x4a7484aaul), Inc(w5, sigma1(w3), w14, sigma0(w │ Round(d, e, f, g, h, a, b, c, Add(K(0x4a7484aaul), Inc(w5, sigma1(w3), w14, sigma0(w
Round(c, d, e, f, g, h, a, b, Add(K(0x5cb0a9dcul), Inc(w6, sigma1(w4), w15, sigma0(w │ Round(c, d, e, f, g, h, a, b, Add(K(0x5cb0a9dcul), Inc(w6, sigma1(w4), w15, sigma0(w
Round(b, c, d, e, f, g, h, a, Add(K(0x76f988daul), Inc(w7, sigma1(w5), w0, sigma0(w8 │ Round(b, c, d, e, f, g, h, a, Add(K(0x76f988daul), Inc(w7, sigma1(w5), w0, sigma0(w8
Round(a, b, c, d, e, f, g, h, Add(K(0x983e5152ul), Inc(w8, sigma1(w6), w1, sigma0(w9 │ Round(a, b, c, d, e, f, g, h, Add(K(0x983e5152ul), Inc(w8, sigma1(w6), w1, sigma0(w9
Round(h, a, b, c, d, e, f, g, Add(K(0xa831c66dul), Inc(w9, sigma1(w7), w2, sigma0(w1 │ Round(h, a, b, c, d, e, f, g, Add(K(0xa831c66dul), Inc(w9, sigma1(w7), w2, sigma0(w1
Round(g, h, a, b, c, d, e, f, Add(K(0xb00327c8ul), Inc(w10, sigma1(w8), w3, sigma0(w │ Round(g, h, a, b, c, d, e, f, Add(K(0xb00327c8ul), Inc(w10, sigma1(w8), w3, sigma0(w
Round(f, g, h, a, b, c, d, e, Add(K(0xbf597fc7ul), Inc(w11, sigma1(w9), w4, sigma0(w │ Round(f, g, h, a, b, c, d, e, Add(K(0xbf597fc7ul), Inc(w11, sigma1(w9), w4, sigma0(w
Round(e, f, g, h, a, b, c, d, Add(K(0xc6e00bf3ul), Inc(w12, sigma1(w10), w5, sigma0( │ Round(e, f, g, h, a, b, c, d, Add(K(0xc6e00bf3ul), Inc(w12, sigma1(w10), w5, sigma0(
Round(d, e, f, g, h, a, b, c, Add(K(0xd5a79147ul), Inc(w13, sigma1(w11), w6, sigma0( │ Round(d, e, f, g, h, a, b, c, Add(K(0xd5a79147ul), Inc(w13, sigma1(w11), w6, sigma0(
Round(c, d, e, f, g, h, a, b, Add(K(0x06ca6351ul), Inc(w14, sigma1(w12), w7, sigma0( │ Round(c, d, e, f, g, h, a, b, Add(K(0x06ca6351ul), Inc(w14, sigma1(w12), w7, sigma0(
Round(b, c, d, e, f, g, h, a, Add(K(0x14292967ul), Inc(w15, sigma1(w13), w8, sigma0( │ Round(b, c, d, e, f, g, h, a, Add(K(0x14292967ul), Inc(w15, sigma1(w13), w8, sigma0(
Round(a, b, c, d, e, f, g, h, Add(K(0x27b70a85ul), Inc(w0, sigma1(w14), w9, sigma0(w │ Round(a, b, c, d, e, f, g, h, Add(K(0x27b70a85ul), Inc(w0, sigma1(w14), w9, sigma0(w
Round(h, a, b, c, d, e, f, g, Add(K(0x2e1b2138ul), Inc(w1, sigma1(w15), w10, sigma0( │ Round(h, a, b, c, d, e, f, g, Add(K(0x2e1b2138ul), Inc(w1, sigma1(w15), w10, sigma0(
Round(g, h, a, b, c, d, e, f, Add(K(0x4d2c6dfcul), Inc(w2, sigma1(w0), w11, sigma0(w │ Round(g, h, a, b, c, d, e, f, Add(K(0x4d2c6dfcul), Inc(w2, sigma1(w0), w11, sigma0(w
Round(f, g, h, a, b, c, d, e, Add(K(0x53380d13ul), Inc(w3, sigma1(w1), w12, sigma0(w │ Round(f, g, h, a, b, c, d, e, Add(K(0x53380d13ul), Inc(w3, sigma1(w1), w12, sigma0(w
Round(e, f, g, h, a, b, c, d, Add(K(0x650a7354ul), Inc(w4, sigma1(w2), w13, sigma0(w │ Round(e, f, g, h, a, b, c, d, Add(K(0x650a7354ul), Inc(w4, sigma1(w2), w13, sigma0(w
Round(d, e, f, g, h, a, b, c, Add(K(0x766a0abbul), Inc(w5, sigma1(w3), w14, sigma0(w │ Round(d, e, f, g, h, a, b, c, Add(K(0x766a0abbul), Inc(w5, sigma1(w3), w14, sigma0(w
Round(c, d, e, f, g, h, a, b, Add(K(0x81c2c92eul), Inc(w6, sigma1(w4), w15, sigma0(w │ Round(c, d, e, f, g, h, a, b, Add(K(0x81c2c92eul), Inc(w6, sigma1(w4), w15, sigma0(w
Round(b, c, d, e, f, g, h, a, Add(K(0x92722c85ul), Inc(w7, sigma1(w5), w0, sigma0(w8 │ Round(b, c, d, e, f, g, h, a, Add(K(0x92722c85ul), Inc(w7, sigma1(w5), w0, sigma0(w8
Round(a, b, c, d, e, f, g, h, Add(K(0xa2bfe8a1ul), Inc(w8, sigma1(w6), w1, sigma0(w9 │ Round(a, b, c, d, e, f, g, h, Add(K(0xa2bfe8a1ul), Inc(w8, sigma1(w6), w1, sigma0(w9
Round(h, a, b, c, d, e, f, g, Add(K(0xa81a664bul), Inc(w9, sigma1(w7), w2, sigma0(w1 │ Round(h, a, b, c, d, e, f, g, Add(K(0xa81a664bul), Inc(w9, sigma1(w7), w2, sigma0(w1
Round(g, h, a, b, c, d, e, f, Add(K(0xc24b8b70ul), Inc(w10, sigma1(w8), w3, sigma0(w │ Round(g, h, a, b, c, d, e, f, Add(K(0xc24b8b70ul), Inc(w10, sigma1(w8), w3, sigma0(w
Round(f, g, h, a, b, c, d, e, Add(K(0xc76c51a3ul), Inc(w11, sigma1(w9), w4, sigma0(w │ Round(f, g, h, a, b, c, d, e, Add(K(0xc76c51a3ul), Inc(w11, sigma1(w9), w4, sigma0(w
Round(e, f, g, h, a, b, c, d, Add(K(0xd192e819ul), Inc(w12, sigma1(w10), w5, sigma0( │ Round(e, f, g, h, a, b, c, d, Add(K(0xd192e819ul), Inc(w12, sigma1(w10), w5, sigma0(
Round(d, e, f, g, h, a, b, c, Add(K(0xd6990624ul), Inc(w13, sigma1(w11), w6, sigma0( │ Round(d, e, f, g, h, a, b, c, Add(K(0xd6990624ul), Inc(w13, sigma1(w11), w6, sigma0(
Round(c, d, e, f, g, h, a, b, Add(K(0xf40e3585ul), Inc(w14, sigma1(w12), w7, sigma0( │ Round(c, d, e, f, g, h, a, b, Add(K(0xf40e3585ul), Inc(w14, sigma1(w12), w7, sigma0(
Round(b, c, d, e, f, g, h, a, Add(K(0x106aa070ul), Inc(w15, sigma1(w13), w8, sigma0( │ Round(b, c, d, e, f, g, h, a, Add(K(0x106aa070ul), Inc(w15, sigma1(w13), w8, sigma0(
Round(a, b, c, d, e, f, g, h, Add(K(0x19a4c116ul), Inc(w0, sigma1(w14), w9, sigma0(w │ Round(a, b, c, d, e, f, g, h, Add(K(0x19a4c116ul), Inc(w0, sigma1(w14), w9, sigma0(w
Round(h, a, b, c, d, e, f, g, Add(K(0x1e376c08ul), Inc(w1, sigma1(w15), w10, sigma0( │ Round(h, a, b, c, d, e, f, g, Add(K(0x1e376c08ul), Inc(w1, sigma1(w15), w10, sigma0(
Round(g, h, a, b, c, d, e, f, Add(K(0x2748774cul), Inc(w2, sigma1(w0), w11, sigma0(w │ Round(g, h, a, b, c, d, e, f, Add(K(0x2748774cul), Inc(w2, sigma1(w0), w11, sigma0(w
Round(f, g, h, a, b, c, d, e, Add(K(0x34b0bcb5ul), Inc(w3, sigma1(w1), w12, sigma0(w │ Round(f, g, h, a, b, c, d, e, Add(K(0x34b0bcb5ul), Inc(w3, sigma1(w1), w12, sigma0(w
Round(e, f, g, h, a, b, c, d, Add(K(0x391c0cb3ul), Inc(w4, sigma1(w2), w13, sigma0(w │ Round(e, f, g, h, a, b, c, d, Add(K(0x391c0cb3ul), Inc(w4, sigma1(w2), w13, sigma0(w
Round(d, e, f, g, h, a, b, c, Add(K(0x4ed8aa4aul), Inc(w5, sigma1(w3), w14, sigma0(w │ Round(d, e, f, g, h, a, b, c, Add(K(0x4ed8aa4aul), Inc(w5, sigma1(w3), w14, sigma0(w
Round(c, d, e, f, g, h, a, b, Add(K(0x5b9cca4ful), Inc(w6, sigma1(w4), w15, sigma0(w │ Round(c, d, e, f, g, h, a, b, Add(K(0x5b9cca4ful), Inc(w6, sigma1(w4), w15, sigma0(w
Round(b, c, d, e, f, g, h, a, Add(K(0x682e6ff3ul), Inc(w7, sigma1(w5), w0, sigma0(w8 │ Round(b, c, d, e, f, g, h, a, Add(K(0x682e6ff3ul), Inc(w7, sigma1(w5), w0, sigma0(w8
Round(a, b, c, d, e, f, g, h, Add(K(0x748f82eeul), Inc(w8, sigma1(w6), w1, sigma0(w9 │ Round(a, b, c, d, e, f, g, h, Add(K(0x748f82eeul), Inc(w8, sigma1(w6), w1, sigma0(w9
Round(h, a, b, c, d, e, f, g, Add(K(0x78a5636ful), Inc(w9, sigma1(w7), w2, sigma0(w1 │ Round(h, a, b, c, d, e, f, g, Add(K(0x78a5636ful), Inc(w9, sigma1(w7), w2, sigma0(w1
Round(g, h, a, b, c, d, e, f, Add(K(0x84c87814ul), Inc(w10, sigma1(w8), w3, sigma0(w │ Round(g, h, a, b, c, d, e, f, Add(K(0x84c87814ul), Inc(w10, sigma1(w8), w3, sigma0(w
Round(f, g, h, a, b, c, d, e, Add(K(0x8cc70208ul), Inc(w11, sigma1(w9), w4, sigma0(w │ Round(f, g, h, a, b, c, d, e, Add(K(0x8cc70208ul), Inc(w11, sigma1(w9), w4, sigma0(w
Round(e, f, g, h, a, b, c, d, Add(K(0x90befffaul), Inc(w12, sigma1(w10), w5, sigma0( │ Round(e, f, g, h, a, b, c, d, Add(K(0x90befffaul), Inc(w12, sigma1(w10), w5, sigma0(
Round(d, e, f, g, h, a, b, c, Add(K(0xa4506cebul), Inc(w13, sigma1(w11), w6, sigma0( │ Round(d, e, f, g, h, a, b, c, Add(K(0xa4506cebul), Inc(w13, sigma1(w11), w6, sigma0(
Round(c, d, e, f, g, h, a, b, Add(K(0xbef9a3f7ul), Inc(w14, sigma1(w12), w7, sigma0( │ Round(c, d, e, f, g, h, a, b, Add(K(0xbef9a3f7ul), Inc(w14, sigma1(w12), w7, sigma0(
Round(b, c, d, e, f, g, h, a, Add(K(0xc67178f2ul), Inc(w15, sigma1(w13), w8, sigma0( │ Round(b, c, d, e, f, g, h, a, Add(K(0xc67178f2ul), Inc(w15, sigma1(w13), w8, sigma0(
│
a = Add(a, K(0x6a09e667ul)); │ a = Add(a, K(0x6a09e667ul));
b = Add(b, K(0xbb67ae85ul)); │ b = Add(b, K(0xbb67ae85ul));
c = Add(c, K(0x3c6ef372ul)); │ c = Add(c, K(0x3c6ef372ul));
d = Add(d, K(0xa54ff53aul)); │ d = Add(d, K(0xa54ff53aul));
e = Add(e, K(0x510e527ful)); │ e = Add(e, K(0x510e527ful));
f = Add(f, K(0x9b05688cul)); │ f = Add(f, K(0x9b05688cul));
g = Add(g, K(0x1f83d9abul)); │ g = Add(g, K(0x1f83d9abul));
h = Add(h, K(0x5be0cd19ul)); │ h = Add(h, K(0x5be0cd19ul));
│
__m128i t0 = a, t1 = b, t2 = c, t3 = d, t4 = e, t5 = f, t6 = g, t7 = h; │ __m256i t0 = a, t1 = b, t2 = c, t3 = d, t4 = e, t5 = f, t6 = g, t7 = h;
│
// Transform 2 │ // Transform 2
Round(a, b, c, d, e, f, g, h, K(0xc28a2f98ul)); │ Round(a, b, c, d, e, f, g, h, K(0xc28a2f98ul));
Round(h, a, b, c, d, e, f, g, K(0x71374491ul)); │ Round(h, a, b, c, d, e, f, g, K(0x71374491ul));
Round(g, h, a, b, c, d, e, f, K(0xb5c0fbcful)); │ Round(g, h, a, b, c, d, e, f, K(0xb5c0fbcful));
Round(f, g, h, a, b, c, d, e, K(0xe9b5dba5ul)); │ Round(f, g, h, a, b, c, d, e, K(0xe9b5dba5ul));
Round(e, f, g, h, a, b, c, d, K(0x3956c25bul)); │ Round(e, f, g, h, a, b, c, d, K(0x3956c25bul));
Round(d, e, f, g, h, a, b, c, K(0x59f111f1ul)); │ Round(d, e, f, g, h, a, b, c, K(0x59f111f1ul));
Round(c, d, e, f, g, h, a, b, K(0x923f82a4ul)); │ Round(c, d, e, f, g, h, a, b, K(0x923f82a4ul));
Round(b, c, d, e, f, g, h, a, K(0xab1c5ed5ul)); │ Round(b, c, d, e, f, g, h, a, K(0xab1c5ed5ul));
Round(a, b, c, d, e, f, g, h, K(0xd807aa98ul)); │ Round(a, b, c, d, e, f, g, h, K(0xd807aa98ul));
Round(h, a, b, c, d, e, f, g, K(0x12835b01ul)); │ Round(h, a, b, c, d, e, f, g, K(0x12835b01ul));
Round(g, h, a, b, c, d, e, f, K(0x243185beul)); │ Round(g, h, a, b, c, d, e, f, K(0x243185beul));
Round(f, g, h, a, b, c, d, e, K(0x550c7dc3ul)); │ Round(f, g, h, a, b, c, d, e, K(0x550c7dc3ul));
Round(e, f, g, h, a, b, c, d, K(0x72be5d74ul)); │ Round(e, f, g, h, a, b, c, d, K(0x72be5d74ul));
Round(d, e, f, g, h, a, b, c, K(0x80deb1feul)); │ Round(d, e, f, g, h, a, b, c, K(0x80deb1feul));
Round(c, d, e, f, g, h, a, b, K(0x9bdc06a7ul)); │ Round(c, d, e, f, g, h, a, b, K(0x9bdc06a7ul));
Round(b, c, d, e, f, g, h, a, K(0xc19bf374ul)); │ Round(b, c, d, e, f, g, h, a, K(0xc19bf374ul));
Round(a, b, c, d, e, f, g, h, K(0x649b69c1ul)); │ Round(a, b, c, d, e, f, g, h, K(0x649b69c1ul));
Round(h, a, b, c, d, e, f, g, K(0xf0fe4786ul)); │ Round(h, a, b, c, d, e, f, g, K(0xf0fe4786ul));
Round(g, h, a, b, c, d, e, f, K(0x0fe1edc6ul)); │ Round(g, h, a, b, c, d, e, f, K(0x0fe1edc6ul));
Round(f, g, h, a, b, c, d, e, K(0x240cf254ul)); │ Round(f, g, h, a, b, c, d, e, K(0x240cf254ul));
Round(e, f, g, h, a, b, c, d, K(0x4fe9346ful)); │ Round(e, f, g, h, a, b, c, d, K(0x4fe9346ful));
Round(d, e, f, g, h, a, b, c, K(0x6cc984beul)); │ Round(d, e, f, g, h, a, b, c, K(0x6cc984beul));
Round(c, d, e, f, g, h, a, b, K(0x61b9411eul)); │ Round(c, d, e, f, g, h, a, b, K(0x61b9411eul));
Round(b, c, d, e, f, g, h, a, K(0x16f988faul)); │ Round(b, c, d, e, f, g, h, a, K(0x16f988faul));
Round(a, b, c, d, e, f, g, h, K(0xf2c65152ul)); │ Round(a, b, c, d, e, f, g, h, K(0xf2c65152ul));
Round(h, a, b, c, d, e, f, g, K(0xa88e5a6dul)); │ Round(h, a, b, c, d, e, f, g, K(0xa88e5a6dul));
Round(g, h, a, b, c, d, e, f, K(0xb019fc65ul)); │ Round(g, h, a, b, c, d, e, f, K(0xb019fc65ul));
Round(f, g, h, a, b, c, d, e, K(0xb9d99ec7ul)); │ Round(f, g, h, a, b, c, d, e, K(0xb9d99ec7ul));
Round(e, f, g, h, a, b, c, d, K(0x9a1231c3ul)); │ Round(e, f, g, h, a, b, c, d, K(0x9a1231c3ul));
Round(d, e, f, g, h, a, b, c, K(0xe70eeaa0ul)); │ Round(d, e, f, g, h, a, b, c, K(0xe70eeaa0ul));
Round(c, d, e, f, g, h, a, b, K(0xfdb1232bul)); │ Round(c, d, e, f, g, h, a, b, K(0xfdb1232bul));
Round(b, c, d, e, f, g, h, a, K(0xc7353eb0ul)); │ Round(b, c, d, e, f, g, h, a, K(0xc7353eb0ul));
Round(a, b, c, d, e, f, g, h, K(0x3069bad5ul)); │ Round(a, b, c, d, e, f, g, h, K(0x3069bad5ul));
Round(h, a, b, c, d, e, f, g, K(0xcb976d5ful)); │ Round(h, a, b, c, d, e, f, g, K(0xcb976d5ful));
Round(g, h, a, b, c, d, e, f, K(0x5a0f118ful)); │ Round(g, h, a, b, c, d, e, f, K(0x5a0f118ful));
Round(f, g, h, a, b, c, d, e, K(0xdc1eeefdul)); │ Round(f, g, h, a, b, c, d, e, K(0xdc1eeefdul));
Round(e, f, g, h, a, b, c, d, K(0x0a35b689ul)); │ Round(e, f, g, h, a, b, c, d, K(0x0a35b689ul));
Round(d, e, f, g, h, a, b, c, K(0xde0b7a04ul)); │ Round(d, e, f, g, h, a, b, c, K(0xde0b7a04ul));
Round(c, d, e, f, g, h, a, b, K(0x58f4ca9dul)); │ Round(c, d, e, f, g, h, a, b, K(0x58f4ca9dul));
Round(b, c, d, e, f, g, h, a, K(0xe15d5b16ul)); │ Round(b, c, d, e, f, g, h, a, K(0xe15d5b16ul));
Round(a, b, c, d, e, f, g, h, K(0x007f3e86ul)); │ Round(a, b, c, d, e, f, g, h, K(0x007f3e86ul));
Round(h, a, b, c, d, e, f, g, K(0x37088980ul)); │ Round(h, a, b, c, d, e, f, g, K(0x37088980ul));
Round(g, h, a, b, c, d, e, f, K(0xa507ea32ul)); │ Round(g, h, a, b, c, d, e, f, K(0xa507ea32ul));
Round(f, g, h, a, b, c, d, e, K(0x6fab9537ul)); │ Round(f, g, h, a, b, c, d, e, K(0x6fab9537ul));
Round(e, f, g, h, a, b, c, d, K(0x17406110ul)); │ Round(e, f, g, h, a, b, c, d, K(0x17406110ul));
Round(d, e, f, g, h, a, b, c, K(0x0d8cd6f1ul)); │ Round(d, e, f, g, h, a, b, c, K(0x0d8cd6f1ul));
Round(c, d, e, f, g, h, a, b, K(0xcdaa3b6dul)); │ Round(c, d, e, f, g, h, a, b, K(0xcdaa3b6dul));
Round(b, c, d, e, f, g, h, a, K(0xc0bbbe37ul)); │ Round(b, c, d, e, f, g, h, a, K(0xc0bbbe37ul));
Round(a, b, c, d, e, f, g, h, K(0x83613bdaul)); │ Round(a, b, c, d, e, f, g, h, K(0x83613bdaul));
Round(h, a, b, c, d, e, f, g, K(0xdb48a363ul)); │ Round(h, a, b, c, d, e, f, g, K(0xdb48a363ul));
Round(g, h, a, b, c, d, e, f, K(0x0b02e931ul)); │ Round(g, h, a, b, c, d, e, f, K(0x0b02e931ul));
Round(f, g, h, a, b, c, d, e, K(0x6fd15ca7ul)); │ Round(f, g, h, a, b, c, d, e, K(0x6fd15ca7ul));
Round(e, f, g, h, a, b, c, d, K(0x521afacaul)); │ Round(e, f, g, h, a, b, c, d, K(0x521afacaul));
Round(d, e, f, g, h, a, b, c, K(0x31338431ul)); │ Round(d, e, f, g, h, a, b, c, K(0x31338431ul));
Round(c, d, e, f, g, h, a, b, K(0x6ed41a95ul)); │ Round(c, d, e, f, g, h, a, b, K(0x6ed41a95ul));
Round(b, c, d, e, f, g, h, a, K(0x6d437890ul)); │ Round(b, c, d, e, f, g, h, a, K(0x6d437890ul));
Round(a, b, c, d, e, f, g, h, K(0xc39c91f2ul)); │ Round(a, b, c, d, e, f, g, h, K(0xc39c91f2ul));
Round(h, a, b, c, d, e, f, g, K(0x9eccabbdul)); │ Round(h, a, b, c, d, e, f, g, K(0x9eccabbdul));
Round(g, h, a, b, c, d, e, f, K(0xb5c9a0e6ul)); │ Round(g, h, a, b, c, d, e, f, K(0xb5c9a0e6ul));
Round(f, g, h, a, b, c, d, e, K(0x532fb63cul)); │ Round(f, g, h, a, b, c, d, e, K(0x532fb63cul));
Round(e, f, g, h, a, b, c, d, K(0xd2c741c6ul)); │ Round(e, f, g, h, a, b, c, d, K(0xd2c741c6ul));
Round(d, e, f, g, h, a, b, c, K(0x07237ea3ul)); │ Round(d, e, f, g, h, a, b, c, K(0x07237ea3ul));
Round(c, d, e, f, g, h, a, b, K(0xa4954b68ul)); │ Round(c, d, e, f, g, h, a, b, K(0xa4954b68ul));
Round(b, c, d, e, f, g, h, a, K(0x4c191d76ul)); │ Round(b, c, d, e, f, g, h, a, K(0x4c191d76ul));
│
w0 = Add(t0, a); │ w0 = Add(t0, a);
w1 = Add(t1, b); │ w1 = Add(t1, b);
w2 = Add(t2, c); │ w2 = Add(t2, c);
w3 = Add(t3, d); │ w3 = Add(t3, d);
w4 = Add(t4, e); │ w4 = Add(t4, e);
w5 = Add(t5, f); │ w5 = Add(t5, f);
w6 = Add(t6, g); │ w6 = Add(t6, g);
w7 = Add(t7, h); │ w7 = Add(t7, h);
│
// Transform 3 │ // Transform 3
a = K(0x6a09e667ul); │ a = K(0x6a09e667ul);
b = K(0xbb67ae85ul); │ b = K(0xbb67ae85ul);
c = K(0x3c6ef372ul); │ c = K(0x3c6ef372ul);
d = K(0xa54ff53aul); │ d = K(0xa54ff53aul);
e = K(0x510e527ful); │ e = K(0x510e527ful);
f = K(0x9b05688cul); │ f = K(0x9b05688cul);
g = K(0x1f83d9abul); │ g = K(0x1f83d9abul);
h = K(0x5be0cd19ul); │ h = K(0x5be0cd19ul);
│
Round(a, b, c, d, e, f, g, h, Add(K(0x428a2f98ul), w0)); │ Round(a, b, c, d, e, f, g, h, Add(K(0x428a2f98ul), w0));
Round(h, a, b, c, d, e, f, g, Add(K(0x71374491ul), w1)); │ Round(h, a, b, c, d, e, f, g, Add(K(0x71374491ul), w1));
Round(g, h, a, b, c, d, e, f, Add(K(0xb5c0fbcful), w2)); │ Round(g, h, a, b, c, d, e, f, Add(K(0xb5c0fbcful), w2));
Round(f, g, h, a, b, c, d, e, Add(K(0xe9b5dba5ul), w3)); │ Round(f, g, h, a, b, c, d, e, Add(K(0xe9b5dba5ul), w3));
Round(e, f, g, h, a, b, c, d, Add(K(0x3956c25bul), w4)); │ Round(e, f, g, h, a, b, c, d, Add(K(0x3956c25bul), w4));
Round(d, e, f, g, h, a, b, c, Add(K(0x59f111f1ul), w5)); │ Round(d, e, f, g, h, a, b, c, Add(K(0x59f111f1ul), w5));
Round(c, d, e, f, g, h, a, b, Add(K(0x923f82a4ul), w6)); │ Round(c, d, e, f, g, h, a, b, Add(K(0x923f82a4ul), w6));
Round(b, c, d, e, f, g, h, a, Add(K(0xab1c5ed5ul), w7)); │ Round(b, c, d, e, f, g, h, a, Add(K(0xab1c5ed5ul), w7));
Round(a, b, c, d, e, f, g, h, K(0x5807aa98ul)); │ Round(a, b, c, d, e, f, g, h, K(0x5807aa98ul));
Round(h, a, b, c, d, e, f, g, K(0x12835b01ul)); │ Round(h, a, b, c, d, e, f, g, K(0x12835b01ul));
Round(g, h, a, b, c, d, e, f, K(0x243185beul)); │ Round(g, h, a, b, c, d, e, f, K(0x243185beul));
Round(f, g, h, a, b, c, d, e, K(0x550c7dc3ul)); │ Round(f, g, h, a, b, c, d, e, K(0x550c7dc3ul));
Round(e, f, g, h, a, b, c, d, K(0x72be5d74ul)); │ Round(e, f, g, h, a, b, c, d, K(0x72be5d74ul));
Round(d, e, f, g, h, a, b, c, K(0x80deb1feul)); │ Round(d, e, f, g, h, a, b, c, K(0x80deb1feul));
Round(c, d, e, f, g, h, a, b, K(0x9bdc06a7ul)); │ Round(c, d, e, f, g, h, a, b, K(0x9bdc06a7ul));
Round(b, c, d, e, f, g, h, a, K(0xc19bf274ul)); │ Round(b, c, d, e, f, g, h, a, K(0xc19bf274ul));
Round(a, b, c, d, e, f, g, h, Add(K(0xe49b69c1ul), Inc(w0, sigma0(w1)))); │ Round(a, b, c, d, e, f, g, h, Add(K(0xe49b69c1ul), Inc(w0, sigma0(w1))));
Round(h, a, b, c, d, e, f, g, Add(K(0xefbe4786ul), Inc(w1, K(0xa00000ul), sigma0(w2) │ Round(h, a, b, c, d, e, f, g, Add(K(0xefbe4786ul), Inc(w1, K(0xa00000ul), sigma0(w2)
Round(g, h, a, b, c, d, e, f, Add(K(0x0fc19dc6ul), Inc(w2, sigma1(w0), sigma0(w3)))) │ Round(g, h, a, b, c, d, e, f, Add(K(0x0fc19dc6ul), Inc(w2, sigma1(w0), sigma0(w3))))
Round(f, g, h, a, b, c, d, e, Add(K(0x240ca1ccul), Inc(w3, sigma1(w1), sigma0(w4)))) │ Round(f, g, h, a, b, c, d, e, Add(K(0x240ca1ccul), Inc(w3, sigma1(w1), sigma0(w4))))
Round(e, f, g, h, a, b, c, d, Add(K(0x2de92c6ful), Inc(w4, sigma1(w2), sigma0(w5)))) │ Round(e, f, g, h, a, b, c, d, Add(K(0x2de92c6ful), Inc(w4, sigma1(w2), sigma0(w5))))
Round(d, e, f, g, h, a, b, c, Add(K(0x4a7484aaul), Inc(w5, sigma1(w3), sigma0(w6)))) │ Round(d, e, f, g, h, a, b, c, Add(K(0x4a7484aaul), Inc(w5, sigma1(w3), sigma0(w6))))
Round(c, d, e, f, g, h, a, b, Add(K(0x5cb0a9dcul), Inc(w6, sigma1(w4), K(0x100ul), s │ Round(c, d, e, f, g, h, a, b, Add(K(0x5cb0a9dcul), Inc(w6, sigma1(w4), K(0x100ul), s
Round(b, c, d, e, f, g, h, a, Add(K(0x76f988daul), Inc(w7, sigma1(w5), w0, K(0x11002 │ Round(b, c, d, e, f, g, h, a, Add(K(0x76f988daul), Inc(w7, sigma1(w5), w0, K(0x11002
Round(a, b, c, d, e, f, g, h, Add(K(0x983e5152ul), w8 = Add(K(0x80000000ul), sigma1( │ Round(a, b, c, d, e, f, g, h, Add(K(0x983e5152ul), w8 = Add(K(0x80000000ul), sigma1(
Round(h, a, b, c, d, e, f, g, Add(K(0xa831c66dul), w9 = Add(sigma1(w7), w2))); │ Round(h, a, b, c, d, e, f, g, Add(K(0xa831c66dul), w9 = Add(sigma1(w7), w2)));
Round(g, h, a, b, c, d, e, f, Add(K(0xb00327c8ul), w10 = Add(sigma1(w8), w3))); │ Round(g, h, a, b, c, d, e, f, Add(K(0xb00327c8ul), w10 = Add(sigma1(w8), w3)));
Round(f, g, h, a, b, c, d, e, Add(K(0xbf597fc7ul), w11 = Add(sigma1(w9), w4))); │ Round(f, g, h, a, b, c, d, e, Add(K(0xbf597fc7ul), w11 = Add(sigma1(w9), w4)));
Round(e, f, g, h, a, b, c, d, Add(K(0xc6e00bf3ul), w12 = Add(sigma1(w10), w5))); │ Round(e, f, g, h, a, b, c, d, Add(K(0xc6e00bf3ul), w12 = Add(sigma1(w10), w5)));
Round(d, e, f, g, h, a, b, c, Add(K(0xd5a79147ul), w13 = Add(sigma1(w11), w6))); │ Round(d, e, f, g, h, a, b, c, Add(K(0xd5a79147ul), w13 = Add(sigma1(w11), w6)));
Round(c, d, e, f, g, h, a, b, Add(K(0x06ca6351ul), w14 = Add(sigma1(w12), w7, K(0x40 │ Round(c, d, e, f, g, h, a, b, Add(K(0x06ca6351ul), w14 = Add(sigma1(w12), w7, K(0x40
Round(b, c, d, e, f, g, h, a, Add(K(0x14292967ul), w15 = Add(K(0x100ul), sigma1(w13) │ Round(b, c, d, e, f, g, h, a, Add(K(0x14292967ul), w15 = Add(K(0x100ul), sigma1(w13)
Round(a, b, c, d, e, f, g, h, Add(K(0x27b70a85ul), Inc(w0, sigma1(w14), w9, sigma0(w │ Round(a, b, c, d, e, f, g, h, Add(K(0x27b70a85ul), Inc(w0, sigma1(w14), w9, sigma0(w
Round(h, a, b, c, d, e, f, g, Add(K(0x2e1b2138ul), Inc(w1, sigma1(w15), w10, sigma0( │ Round(h, a, b, c, d, e, f, g, Add(K(0x2e1b2138ul), Inc(w1, sigma1(w15), w10, sigma0(
Round(g, h, a, b, c, d, e, f, Add(K(0x4d2c6dfcul), Inc(w2, sigma1(w0), w11, sigma0(w │ Round(g, h, a, b, c, d, e, f, Add(K(0x4d2c6dfcul), Inc(w2, sigma1(w0), w11, sigma0(w
Round(f, g, h, a, b, c, d, e, Add(K(0x53380d13ul), Inc(w3, sigma1(w1), w12, sigma0(w │ Round(f, g, h, a, b, c, d, e, Add(K(0x53380d13ul), Inc(w3, sigma1(w1), w12, sigma0(w
Round(e, f, g, h, a, b, c, d, Add(K(0x650a7354ul), Inc(w4, sigma1(w2), w13, sigma0(w │ Round(e, f, g, h, a, b, c, d, Add(K(0x650a7354ul), Inc(w4, sigma1(w2), w13, sigma0(w
Round(d, e, f, g, h, a, b, c, Add(K(0x766a0abbul), Inc(w5, sigma1(w3), w14, sigma0(w │ Round(d, e, f, g, h, a, b, c, Add(K(0x766a0abbul), Inc(w5, sigma1(w3), w14, sigma0(w
Round(c, d, e, f, g, h, a, b, Add(K(0x81c2c92eul), Inc(w6, sigma1(w4), w15, sigma0(w │ Round(c, d, e, f, g, h, a, b, Add(K(0x81c2c92eul), Inc(w6, sigma1(w4), w15, sigma0(w
Round(b, c, d, e, f, g, h, a, Add(K(0x92722c85ul), Inc(w7, sigma1(w5), w0, sigma0(w8 │ Round(b, c, d, e, f, g, h, a, Add(K(0x92722c85ul), Inc(w7, sigma1(w5), w0, sigma0(w8
Round(a, b, c, d, e, f, g, h, Add(K(0xa2bfe8a1ul), Inc(w8, sigma1(w6), w1, sigma0(w9 │ Round(a, b, c, d, e, f, g, h, Add(K(0xa2bfe8a1ul), Inc(w8, sigma1(w6), w1, sigma0(w9
Round(h, a, b, c, d, e, f, g, Add(K(0xa81a664bul), Inc(w9, sigma1(w7), w2, sigma0(w1 │ Round(h, a, b, c, d, e, f, g, Add(K(0xa81a664bul), Inc(w9, sigma1(w7), w2, sigma0(w1
Round(g, h, a, b, c, d, e, f, Add(K(0xc24b8b70ul), Inc(w10, sigma1(w8), w3, sigma0(w │ Round(g, h, a, b, c, d, e, f, Add(K(0xc24b8b70ul), Inc(w10, sigma1(w8), w3, sigma0(w
Round(f, g, h, a, b, c, d, e, Add(K(0xc76c51a3ul), Inc(w11, sigma1(w9), w4, sigma0(w │ Round(f, g, h, a, b, c, d, e, Add(K(0xc76c51a3ul), Inc(w11, sigma1(w9), w4, sigma0(w
Round(e, f, g, h, a, b, c, d, Add(K(0xd192e819ul), Inc(w12, sigma1(w10), w5, sigma0( │ Round(e, f, g, h, a, b, c, d, Add(K(0xd192e819ul), Inc(w12, sigma1(w10), w5, sigma0(
Round(d, e, f, g, h, a, b, c, Add(K(0xd6990624ul), Inc(w13, sigma1(w11), w6, sigma0( │ Round(d, e, f, g, h, a, b, c, Add(K(0xd6990624ul), Inc(w13, sigma1(w11), w6, sigma0(
Round(c, d, e, f, g, h, a, b, Add(K(0xf40e3585ul), Inc(w14, sigma1(w12), w7, sigma0( │ Round(c, d, e, f, g, h, a, b, Add(K(0xf40e3585ul), Inc(w14, sigma1(w12), w7, sigma0(
Round(b, c, d, e, f, g, h, a, Add(K(0x106aa070ul), Inc(w15, sigma1(w13), w8, sigma0( │ Round(b, c, d, e, f, g, h, a, Add(K(0x106aa070ul), Inc(w15, sigma1(w13), w8, sigma0(
Round(a, b, c, d, e, f, g, h, Add(K(0x19a4c116ul), Inc(w0, sigma1(w14), w9, sigma0(w │ Round(a, b, c, d, e, f, g, h, Add(K(0x19a4c116ul), Inc(w0, sigma1(w14), w9, sigma0(w
Round(h, a, b, c, d, e, f, g, Add(K(0x1e376c08ul), Inc(w1, sigma1(w15), w10, sigma0( │ Round(h, a, b, c, d, e, f, g, Add(K(0x1e376c08ul), Inc(w1, sigma1(w15), w10, sigma0(
Round(g, h, a, b, c, d, e, f, Add(K(0x2748774cul), Inc(w2, sigma1(w0), w11, sigma0(w │ Round(g, h, a, b, c, d, e, f, Add(K(0x2748774cul), Inc(w2, sigma1(w0), w11, sigma0(w
Round(f, g, h, a, b, c, d, e, Add(K(0x34b0bcb5ul), Inc(w3, sigma1(w1), w12, sigma0(w │ Round(f, g, h, a, b, c, d, e, Add(K(0x34b0bcb5ul), Inc(w3, sigma1(w1), w12, sigma0(w
Round(e, f, g, h, a, b, c, d, Add(K(0x391c0cb3ul), Inc(w4, sigma1(w2), w13, sigma0(w │ Round(e, f, g, h, a, b, c, d, Add(K(0x391c0cb3ul), Inc(w4, sigma1(w2), w13, sigma0(w
Round(d, e, f, g, h, a, b, c, Add(K(0x4ed8aa4aul), Inc(w5, sigma1(w3), w14, sigma0(w │ Round(d, e, f, g, h, a, b, c, Add(K(0x4ed8aa4aul), Inc(w5, sigma1(w3), w14, sigma0(w
Round(c, d, e, f, g, h, a, b, Add(K(0x5b9cca4ful), Inc(w6, sigma1(w4), w15, sigma0(w │ Round(c, d, e, f, g, h, a, b, Add(K(0x5b9cca4ful), Inc(w6, sigma1(w4), w15, sigma0(w
Round(b, c, d, e, f, g, h, a, Add(K(0x682e6ff3ul), Inc(w7, sigma1(w5), w0, sigma0(w8 │ Round(b, c, d, e, f, g, h, a, Add(K(0x682e6ff3ul), Inc(w7, sigma1(w5), w0, sigma0(w8
Round(a, b, c, d, e, f, g, h, Add(K(0x748f82eeul), Inc(w8, sigma1(w6), w1, sigma0(w9 │ Round(a, b, c, d, e, f, g, h, Add(K(0x748f82eeul), Inc(w8, sigma1(w6), w1, sigma0(w9
Round(h, a, b, c, d, e, f, g, Add(K(0x78a5636ful), Inc(w9, sigma1(w7), w2, sigma0(w1 │ Round(h, a, b, c, d, e, f, g, Add(K(0x78a5636ful), Inc(w9, sigma1(w7), w2, sigma0(w1
Round(g, h, a, b, c, d, e, f, Add(K(0x84c87814ul), Inc(w10, sigma1(w8), w3, sigma0(w │ Round(g, h, a, b, c, d, e, f, Add(K(0x84c87814ul), Inc(w10, sigma1(w8), w3, sigma0(w
Round(f, g, h, a, b, c, d, e, Add(K(0x8cc70208ul), Inc(w11, sigma1(w9), w4, sigma0(w │ Round(f, g, h, a, b, c, d, e, Add(K(0x8cc70208ul), Inc(w11, sigma1(w9), w4, sigma0(w
Round(e, f, g, h, a, b, c, d, Add(K(0x90befffaul), Inc(w12, sigma1(w10), w5, sigma0( │ Round(e, f, g, h, a, b, c, d, Add(K(0x90befffaul), Inc(w12, sigma1(w10), w5, sigma0(
Round(d, e, f, g, h, a, b, c, Add(K(0xa4506cebul), Inc(w13, sigma1(w11), w6, sigma0( │ Round(d, e, f, g, h, a, b, c, Add(K(0xa4506cebul), Inc(w13, sigma1(w11), w6, sigma0(
Round(c, d, e, f, g, h, a, b, Add(K(0xbef9a3f7ul), w14, sigma1(w12), w7, sigma0(w15) │ Round(c, d, e, f, g, h, a, b, Add(K(0xbef9a3f7ul), w14, sigma1(w12), w7, sigma0(w15)
Round(b, c, d, e, f, g, h, a, Add(K(0xc67178f2ul), w15, sigma1(w13), w8, sigma0(w0)) │ Round(b, c, d, e, f, g, h, a, Add(K(0xc67178f2ul), w15, sigma1(w13), w8, sigma0(w0))
│
// Output │ // Output
Write4(out, 0, Add(a, K(0x6a09e667ul))); │ Write8(out, 0, Add(a, K(0x6a09e667ul)));
Write4(out, 4, Add(b, K(0xbb67ae85ul))); │ Write8(out, 4, Add(b, K(0xbb67ae85ul)));
Write4(out, 8, Add(c, K(0x3c6ef372ul))); │ Write8(out, 8, Add(c, K(0x3c6ef372ul)));
Write4(out, 12, Add(d, K(0xa54ff53aul))); │ Write8(out, 12, Add(d, K(0xa54ff53aul)));
Write4(out, 16, Add(e, K(0x510e527ful))); │ Write8(out, 16, Add(e, K(0x510e527ful)));
Write4(out, 20, Add(f, K(0x9b05688cul))); │ Write8(out, 20, Add(f, K(0x9b05688cul)));
Write4(out, 24, Add(g, K(0x1f83d9abul))); │ Write8(out, 24, Add(g, K(0x1f83d9abul)));
Write4(out, 28, Add(h, K(0x5be0cd19ul))); │ Write8(out, 28, Add(h, K(0x5be0cd19ul)));
} │
next prev up dogecoin/src/qt/transactiondesc.cpp:52 │ bitcoin/src/qt/transactiondesc.cpp:79
│
│ int numBlocks;
│ interfaces::WalletTxStatus status;
│ interfaces::WalletOrderForm orderForm;
│ bool inMempool;
│ interfaces::WalletTx wtx = wallet.getWalletTxDetails(rec->hash, status, orderForm, i
│
QString strHTML; │ QString strHTML;
│
LOCK2(cs_main, wallet->cs_wallet); │
strHTML.reserve(4000); │ strHTML.reserve(4000);
strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>"; │ strHTML += "<html><font face='verdana, arial, helvetica, sans-serif'>";
│
int64_t nTime = wtx.GetTxTime(); │ int64_t nTime = wtx.time;
CAmount nCredit = wtx.GetCredit(ISMINE_ALL); │ CAmount nCredit = wtx.credit;
CAmount nDebit = wtx.GetDebit(ISMINE_ALL); │ CAmount nDebit = wtx.debit;
CAmount nNet = nCredit - nDebit; │ CAmount nNet = nCredit - nDebit;
│
strHTML += "<b>" + tr("Status") + ":</b> " + FormatTxStatus(wtx); │ strHTML += "<b>" + tr("Status") + ":</b> " + FormatTxStatus(status, inMempool);
int nRequests = wtx.GetRequestCount(); │
if (nRequests != -1) │
{ │
if (nRequests == 0) │
strHTML += tr(", has not been successfully broadcast yet"); │
else if (nRequests > 0) │
strHTML += tr(", broadcast through %n node(s)", "", nRequests); │
} │
strHTML += "<br>"; │ strHTML += "<br>";
│
strHTML += "<b>" + tr("Date") + ":</b> " + (nTime ? GUIUtil::dateTimeStr(nTime) : "" │ strHTML += "<b>" + tr("Date") + ":</b> " + (nTime ? GUIUtil::dateTimeStr(nTime) : ""
│
// │ //
// From │ // From
// │ //
if (wtx.IsCoinBase()) │ if (wtx.is_coinbase)
{ │ {
strHTML += "<b>" + tr("Source") + ":</b> " + tr("Generated") + "<br>"; │ strHTML += "<b>" + tr("Source") + ":</b> " + tr("Generated") + "<br>";
} │ }
else if (wtx.mapValue.count("from") && !wtx.mapValue["from"].empty()) │ else if (wtx.value_map.count("from") && !wtx.value_map["from"].empty())
{ │ {
// Online transaction │ // Online transaction
strHTML += "<b>" + tr("From") + ":</b> " + GUIUtil::HtmlEscape(wtx.mapValue["fro │ strHTML += "<b>" + tr("From") + ":</b> " + GUIUtil::HtmlEscape(wtx.value_map["fr
} │ }
else │ else
{ │ {
// Offline transaction │ // Offline transaction
if (nNet > 0) │ if (nNet > 0)
{ │ {
// Credit │ // Credit
if (CBitcoinAddress(rec->address).IsValid()) │ CTxDestination address = DecodeDestination(rec->address);
{ │ if (IsValidDestination(address)) {
CTxDestination address = CBitcoinAddress(rec->address).Get(); │ std::string name;
if (wallet->mapAddressBook.count(address)) │ isminetype ismine;
│ if (wallet.getAddress(address, &name, &ismine, /* purpose= */ nullptr))
{ │ {
strHTML += "<b>" + tr("From") + ":</b> " + tr("unknown") + "<br>"; │ strHTML += "<b>" + tr("From") + ":</b> " + tr("unknown") + "<br>";
strHTML += "<b>" + tr("To") + ":</b> "; │ strHTML += "<b>" + tr("To") + ":</b> ";
strHTML += GUIUtil::HtmlEscape(rec->address); │ strHTML += GUIUtil::HtmlEscape(rec->address);
QString addressOwned = (::IsMine(*wallet, address) == ISMINE_SPENDAB │ QString addressOwned = ismine == ISMINE_SPENDABLE ? tr("own address"
if (!wallet->mapAddressBook[address].name.empty()) │ if (!name.empty())
strHTML += " (" + addressOwned + ", " + tr("label") + ": " + GUI │ strHTML += " (" + addressOwned + ", " + tr("label") + ": " + GUI
else │ else
strHTML += " (" + addressOwned + ")"; │ strHTML += " (" + addressOwned + ")";
strHTML += "<br>"; │ strHTML += "<br>";
} │ }
} │ }
} │ }
} │ }
│
// │ //
// To │ // To
// │ //
if (wtx.mapValue.count("to") && !wtx.mapValue["to"].empty()) │ if (wtx.value_map.count("to") && !wtx.value_map["to"].empty())
{ │ {
// Online transaction │ // Online transaction
std::string strAddress = wtx.mapValue["to"]; │ std::string strAddress = wtx.value_map["to"];
strHTML += "<b>" + tr("To") + ":</b> "; │ strHTML += "<b>" + tr("To") + ":</b> ";
CTxDestination dest = CBitcoinAddress(strAddress).Get(); │ CTxDestination dest = DecodeDestination(strAddress);
if (wallet->mapAddressBook.count(dest) && !wallet->mapAddressBook[dest].name.emp │ std::string name;
strHTML += GUIUtil::HtmlEscape(wallet->mapAddressBook[dest].name) + " "; │ if (wallet.getAddress(
│ dest, &name, /* is_mine= */ nullptr, /* purpose= */ nullptr) && !name.em
│ strHTML += GUIUtil::HtmlEscape(name) + " ";
strHTML += GUIUtil::HtmlEscape(strAddress) + "<br>"; │ strHTML += GUIUtil::HtmlEscape(strAddress) + "<br>";
} │ }
│
// │ //
// Amount │ // Amount
// │ //
if (wtx.IsCoinBase() && nCredit == 0) │ if (wtx.is_coinbase && nCredit == 0)
{ │ {
// │ //
// Coinbase │ // Coinbase
// │ //
CAmount nUnmatured = 0; │ CAmount nUnmatured = 0;
BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout) │ for (const CTxOut& txout : wtx.tx->vout)
nUnmatured += wallet->GetCredit(txout, ISMINE_ALL); │ nUnmatured += wallet.getCredit(txout, ISMINE_ALL);
strHTML += "<b>" + tr("Credit") + ":</b> "; │ strHTML += "<b>" + tr("Credit") + ":</b> ";
if (wtx.IsInMainChain()) │ if (status.is_in_main_chain)
strHTML += BitcoinUnits::formatHtmlWithUnit(unit, nUnmatured)+ " (" + tr("ma │ strHTML += BitcoinUnits::formatHtmlWithUnit(unit, nUnmatured)+ " (" + tr("ma
else │ else
strHTML += "(" + tr("not accepted") + ")"; │ strHTML += "(" + tr("not accepted") + ")";
strHTML += "<br>"; │ strHTML += "<br>";
} │ }
else if (nNet > 0) │ else if (nNet > 0)
{ │ {
// │ //
// Credit │ // Credit
// │ //
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(un │ strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(un
} │ }
else │ else
{ │ {
isminetype fAllFromMe = ISMINE_SPENDABLE; │ isminetype fAllFromMe = ISMINE_SPENDABLE;
BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin) │ for (const isminetype mine : wtx.txin_is_mine)
{ │ {
isminetype mine = wallet->IsMine(txin); │
if(fAllFromMe > mine) fAllFromMe = mine; │ if(fAllFromMe > mine) fAllFromMe = mine;
} │ }
│
isminetype fAllToMe = ISMINE_SPENDABLE; │ isminetype fAllToMe = ISMINE_SPENDABLE;
BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout) │ for (const isminetype mine : wtx.txout_is_mine)
{ │ {
isminetype mine = wallet->IsMine(txout); │
if(fAllToMe > mine) fAllToMe = mine; │ if(fAllToMe > mine) fAllToMe = mine;
} │ }
│
if (fAllFromMe) │ if (fAllFromMe)
{ │ {
if(fAllFromMe & ISMINE_WATCH_ONLY) │ if(fAllFromMe & ISMINE_WATCH_ONLY)
strHTML += "<b>" + tr("From") + ":</b> " + tr("watch-only") + "<br>"; │ strHTML += "<b>" + tr("From") + ":</b> " + tr("watch-only") + "<br>";
│
// │ //
// Debit │ // Debit
// │ //
BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout) │ auto mine = wtx.txout_is_mine.begin();
│ for (const CTxOut& txout : wtx.tx->vout)
{ │ {
// Ignore change │ // Ignore change
isminetype toSelf = wallet->IsMine(txout); │ isminetype toSelf = *(mine++);
if ((toSelf == ISMINE_SPENDABLE) && (fAllFromMe == ISMINE_SPENDABLE)) │ if ((toSelf == ISMINE_SPENDABLE) && (fAllFromMe == ISMINE_SPENDABLE))
continue; │ continue;
│
if (!wtx.mapValue.count("to") || wtx.mapValue["to"].empty()) │ if (!wtx.value_map.count("to") || wtx.value_map["to"].empty())
{ │ {
// Offline transaction │ // Offline transaction
CTxDestination address; │ CTxDestination address;
if (ExtractDestination(txout.scriptPubKey, address)) │ if (ExtractDestination(txout.scriptPubKey, address))
{ │ {
strHTML += "<b>" + tr("To") + ":</b> "; │ strHTML += "<b>" + tr("To") + ":</b> ";
if (wallet->mapAddressBook.count(address) && !wallet->mapAddress │ std::string name;
strHTML += GUIUtil::HtmlEscape(wallet->mapAddressBook[addres │ if (wallet.getAddress(
strHTML += GUIUtil::HtmlEscape(CBitcoinAddress(address).ToString │ address, &name, /* is_mine= */ nullptr, /* purpose= */ n
│ strHTML += GUIUtil::HtmlEscape(name) + " ";
│ strHTML += GUIUtil::HtmlEscape(EncodeDestination(address));
if(toSelf == ISMINE_SPENDABLE) │ if(toSelf == ISMINE_SPENDABLE)
strHTML += " (" + tr("own address") + ")"; │ strHTML += " (own address)";
else if(toSelf & ISMINE_WATCH_ONLY) │ else if(toSelf & ISMINE_WATCH_ONLY)
strHTML += " (" + tr("watch-only") + ")"; │ strHTML += " (watch-only)";
strHTML += "<br>"; │ strHTML += "<br>";
} │ }
} │ }
│
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatHtmlWith │ strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatHtmlWith
if(toSelf) │ if(toSelf)
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtm │ strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtm
} │ }
│
if (fAllToMe) │ if (fAllToMe)
{ │ {
// Payment to self │ // Payment to self
CAmount nChange = wtx.GetChange(); │ CAmount nChange = wtx.change;
CAmount nValue = nCredit - nChange; │ CAmount nValue = nCredit - nChange;
strHTML += "<b>" + tr("Total debit") + ":</b> " + BitcoinUnits::formatHt │ strHTML += "<b>" + tr("Total debit") + ":</b> " + BitcoinUnits::formatHt
strHTML += "<b>" + tr("Total credit") + ":</b> " + BitcoinUnits::formatH │ strHTML += "<b>" + tr("Total credit") + ":</b> " + BitcoinUnits::formatH
} │ }
│
CAmount nTxFee = nDebit - wtx.tx->GetValueOut(); │ CAmount nTxFee = nDebit - wtx.tx->GetValueOut();
if (nTxFee > 0) │ if (nTxFee > 0)
strHTML += "<b>" + tr("Transaction fee") + ":</b> " + BitcoinUnits::form │ strHTML += "<b>" + tr("Transaction fee") + ":</b> " + BitcoinUnits::form
} │ }
else │ else
{ │ {
// │ //
// Mixed debit transaction │ // Mixed debit transaction
// │ //
BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin) │ auto mine = wtx.txin_is_mine.begin();
if (wallet->IsMine(txin)) │ for (const CTxIn& txin : wtx.tx->vin) {
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatHtml │ if (*(mine++)) {
BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout) │ strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatHtml
if (wallet->IsMine(txout)) │ }
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtm │ }
│ mine = wtx.txout_is_mine.begin();
│ for (const CTxOut& txout : wtx.tx->vout) {
│ if (*(mine++)) {
│ strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtm
│ }
│ }
} │ }
} │ }
│
strHTML += "<b>" + tr("Net amount") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(un │ strHTML += "<b>" + tr("Net amount") + ":</b> " + BitcoinUnits::formatHtmlWithUnit(un
│
// │ //
// Message │ // Message
// │ //
if (wtx.mapValue.count("message") && !wtx.mapValue["message"].empty()) │ if (wtx.value_map.count("message") && !wtx.value_map["message"].empty())
strHTML += "<br><b>" + tr("Message") + ":</b><br>" + GUIUtil::HtmlEscape(wtx.map │ strHTML += "<br><b>" + tr("Message") + ":</b><br>" + GUIUtil::HtmlEscape(wtx.val
if (wtx.mapValue.count("comment") && !wtx.mapValue["comment"].empty()) │ if (wtx.value_map.count("comment") && !wtx.value_map["comment"].empty())
strHTML += "<br><b>" + tr("Comment") + ":</b><br>" + GUIUtil::HtmlEscape(wtx.map │ strHTML += "<br><b>" + tr("Comment") + ":</b><br>" + GUIUtil::HtmlEscape(wtx.val
│
strHTML += "<b>" + tr("Transaction ID") + ":</b> " + rec->getTxID() + "<br>"; │ strHTML += "<b>" + tr("Transaction ID") + ":</b> " + rec->getTxHash() + "<br>";
strHTML += "<b>" + tr("Transaction total size") + ":</b> " + QString::number(wtx.tx- │ strHTML += "<b>" + tr("Transaction total size") + ":</b> " + QString::number(wtx.tx-
│ strHTML += "<b>" + tr("Transaction virtual size") + ":</b> " + QString::number(GetVi
strHTML += "<b>" + tr("Output index") + ":</b> " + QString::number(rec->getOutputInd │ strHTML += "<b>" + tr("Output index") + ":</b> " + QString::number(rec->getOutputInd
│
// Message from normal bitcoin:URI (bitcoin:123...?message=example) │ // Message from normal bitcoin:URI (bitcoin:123...?message=example)
Q_FOREACH (const PAIRTYPE(std::string, std::string)& r, wtx.vOrderForm) │ for (const std::pair<std::string, std::string>& r : orderForm) {
if (r.first == "Message") │ if (r.first == "Message")
strHTML += "<br><b>" + tr("Message") + ":</b><br>" + GUIUtil::HtmlEscape(r.s │ strHTML += "<br><b>" + tr("Message") + ":</b><br>" + GUIUtil::HtmlEscape(r.s
│
// │ //
// PaymentRequest info: │ // PaymentRequest info:
// │ //
Q_FOREACH (const PAIRTYPE(std::string, std::string)& r, wtx.vOrderForm) │
{ │
if (r.first == "PaymentRequest") │ if (r.first == "PaymentRequest")
{ │ {
PaymentRequestPlus req; │
req.parse(QByteArray::fromRawData(r.second.data(), r.second.size())); │
QString merchant; │ QString merchant;
if (req.getMerchant(PaymentServer::getCertStore(), merchant)) │ if (!GetPaymentRequestMerchant(r.second, merchant)) {
│ merchant.clear();
│ } else {
│ merchant += tr(" (Certificate was not verified)");
│ }
│ if (!merchant.isNull()) {
strHTML += "<b>" + tr("Merchant") + ":</b> " + GUIUtil::HtmlEscape(merch │ strHTML += "<b>" + tr("Merchant") + ":</b> " + GUIUtil::HtmlEscape(merch
│ }
} │ }
} │ }
│
if (wtx.IsCoinBase()) │ if (wtx.is_coinbase)
{ │ {
quint32 nCoinbaseMaturity = Params().GetConsensus(chainActive.Height()).nCoinbas │ quint32 numBlocksToMaturity = COINBASE_MATURITY + 1;
strHTML += "<br>" + tr("Generated coins must mature %1 blocks before they can be │ strHTML += "<br>" + tr("Generated coins must mature %1 blocks before they can be
} │ }
│
// │ //
// Debug view │ // Debug view
// │ //
if (fDebug) │ if (node.getLogCategories() != BCLog::NONE)
{ │ {
strHTML += "<hr><br>" + tr("Debug information") + "<br><br>"; │ strHTML += "<hr><br>" + tr("Debug information") + "<br><br>";
BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin) │ for (const CTxIn& txin : wtx.tx->vin)
if(wallet->IsMine(txin)) │ if(wallet.txinIsMine(txin))
strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatHtmlWith │ strHTML += "<b>" + tr("Debit") + ":</b> " + BitcoinUnits::formatHtmlWith
BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout) │ for (const CTxOut& txout : wtx.tx->vout)
if(wallet->IsMine(txout)) │ if(wallet.txoutIsMine(txout))
strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtmlWit │ strHTML += "<b>" + tr("Credit") + ":</b> " + BitcoinUnits::formatHtmlWit
│
strHTML += "<br><b>" + tr("Transaction") + ":</b><br>"; │ strHTML += "<br><b>" + tr("Transaction") + ":</b><br>";
strHTML += GUIUtil::HtmlEscape(wtx.tx->ToString(), true); │ strHTML += GUIUtil::HtmlEscape(wtx.tx->ToString(), true);
│
strHTML += "<br><b>" + tr("Inputs") + ":</b>"; │ strHTML += "<br><b>" + tr("Inputs") + ":</b>";
strHTML += "<ul>"; │ strHTML += "<ul>";
│
BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin) │ for (const CTxIn& txin : wtx.tx->vin)
{ │ {
COutPoint prevout = txin.prevout; │ COutPoint prevout = txin.prevout;
│
CCoins prev; │ Coin prev;
if(pcoinsTip->GetCoins(prevout.hash, prev)) │ if(node.getUnspentOutput(prevout, prev))
{ │ {
if (prevout.n < prev.vout.size()) │
{ │ {
strHTML += "<li>"; │ strHTML += "<li>";
const CTxOut &vout = prev.vout[prevout.n]; │ const CTxOut &vout = prev.out;
CTxDestination address; │ CTxDestination address;
if (ExtractDestination(vout.scriptPubKey, address)) │ if (ExtractDestination(vout.scriptPubKey, address))
{ │ {
if (wallet->mapAddressBook.count(address) && !wallet->mapAddress │ std::string name;
strHTML += GUIUtil::HtmlEscape(wallet->mapAddressBook[addres │ if (wallet.getAddress(address, &name, /* is_mine= */ nullptr, /*
strHTML += QString::fromStdString(CBitcoinAddress(address).ToStr │ strHTML += GUIUtil::HtmlEscape(name) + " ";
│ strHTML += QString::fromStdString(EncodeDestination(address));
} │ }
strHTML = strHTML + " " + tr("Amount") + "=" + BitcoinUnits::formatH │ strHTML = strHTML + " " + tr("Amount") + "=" + BitcoinUnits::formatH
strHTML = strHTML + " IsMine=" + (wallet->IsMine(vout) & ISMINE_SPEN │ strHTML = strHTML + " IsMine=" + (wallet.txoutIsMine(vout) & ISMINE_
strHTML = strHTML + " IsWatchOnly=" + (wallet->IsMine(vout) & ISMINE │ strHTML = strHTML + " IsWatchOnly=" + (wallet.txoutIsMine(vout) & IS
} │ }
} │ }
} │ }
│
strHTML += "</ul>"; │ strHTML += "</ul>";
} │ }
│
strHTML += "</font></html>"; │ strHTML += "</font></html>";
return strHTML; │ return strHTML;
} │
next prev up dogecoin/src/crypto/ripemd160.cpp:13 │ bitcoin/src/crypto/ripemd160.cpp:13
│
/// Internal RIPEMD-160 implementation. │ /// Internal RIPEMD-160 implementation.
namespace ripemd160 │ namespace ripemd160
{ │ {
uint32_t inline f1(uint32_t x, uint32_t y, uint32_t z) { return x ^ y ^ z; } │ uint32_t inline f1(uint32_t x, uint32_t y, uint32_t z) { return x ^ y ^ z; }
uint32_t inline f2(uint32_t x, uint32_t y, uint32_t z) { return (x & y) | (~x & z); } │ uint32_t inline f2(uint32_t x, uint32_t y, uint32_t z) { return (x & y) | (~x & z); }
uint32_t inline f3(uint32_t x, uint32_t y, uint32_t z) { return (x | ~y) ^ z; } │ uint32_t inline f3(uint32_t x, uint32_t y, uint32_t z) { return (x | ~y) ^ z; }
uint32_t inline f4(uint32_t x, uint32_t y, uint32_t z) { return (x & z) | (y & ~z); } │ uint32_t inline f4(uint32_t x, uint32_t y, uint32_t z) { return (x & z) | (y & ~z); }
uint32_t inline f5(uint32_t x, uint32_t y, uint32_t z) { return x ^ (y | ~z); } │ uint32_t inline f5(uint32_t x, uint32_t y, uint32_t z) { return x ^ (y | ~z); }
│
/** Initialize RIPEMD-160 state. */ │ /** Initialize RIPEMD-160 state. */
void inline Initialize(uint32_t* s) │ void inline Initialize(uint32_t* s)
{ │ {
s[0] = 0x67452301ul; │ s[0] = 0x67452301ul;
s[1] = 0xEFCDAB89ul; │ s[1] = 0xEFCDAB89ul;
s[2] = 0x98BADCFEul; │ s[2] = 0x98BADCFEul;
s[3] = 0x10325476ul; │ s[3] = 0x10325476ul;
s[4] = 0xC3D2E1F0ul; │ s[4] = 0xC3D2E1F0ul;
} │ }
│
uint32_t inline rol(uint32_t x, int i) { return (x << i) | (x >> (32 - i)); } │ uint32_t inline rol(uint32_t x, int i) { return (x << i) | (x >> (32 - i)); }
│
void inline Round(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t │ void inline Round(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t
{ │ {
a = rol(a + f + x + k, r) + e; │ a = rol(a + f + x + k, r) + e;
c = rol(c, 10); │ c = rol(c, 10);
} │ }
│
void inline R11(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x │ void inline R11(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x
void inline R21(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x │ void inline R21(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x
void inline R31(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x │ void inline R31(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x
void inline R41(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x │ void inline R41(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x
void inline R51(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x │ void inline R51(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x
│
void inline R12(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x │ void inline R12(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x
void inline R22(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x │ void inline R22(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x
void inline R32(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x │ void inline R32(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x
void inline R42(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x │ void inline R42(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x
void inline R52(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x │ void inline R52(uint32_t& a, uint32_t b, uint32_t& c, uint32_t d, uint32_t e, uint32_t x
│
/** Perform a RIPEMD-160 transformation, processing a 64-byte chunk. */ │ /** Perform a RIPEMD-160 transformation, processing a 64-byte chunk. */
void Transform(uint32_t* s, const unsigned char* chunk) │ void Transform(uint32_t* s, const unsigned char* chunk)
{ │ {
uint32_t a1 = s[0], b1 = s[1], c1 = s[2], d1 = s[3], e1 = s[4]; │ uint32_t a1 = s[0], b1 = s[1], c1 = s[2], d1 = s[3], e1 = s[4];
uint32_t a2 = a1, b2 = b1, c2 = c1, d2 = d1, e2 = e1; │ uint32_t a2 = a1, b2 = b1, c2 = c1, d2 = d1, e2 = e1;
uint32_t w0 = ReadLE32(chunk + 0), w1 = ReadLE32(chunk + 4), w2 = ReadLE32(chunk + 8 │ uint32_t w0 = ReadLE32(chunk + 0), w1 = ReadLE32(chunk + 4), w2 = ReadLE32(chunk + 8
uint32_t w4 = ReadLE32(chunk + 16), w5 = ReadLE32(chunk + 20), w6 = ReadLE32(chunk + │ uint32_t w4 = ReadLE32(chunk + 16), w5 = ReadLE32(chunk + 20), w6 = ReadLE32(chunk +
uint32_t w8 = ReadLE32(chunk + 32), w9 = ReadLE32(chunk + 36), w10 = ReadLE32(chunk │ uint32_t w8 = ReadLE32(chunk + 32), w9 = ReadLE32(chunk + 36), w10 = ReadLE32(chunk
uint32_t w12 = ReadLE32(chunk + 48), w13 = ReadLE32(chunk + 52), w14 = ReadLE32(chun │ uint32_t w12 = ReadLE32(chunk + 48), w13 = ReadLE32(chunk + 52), w14 = ReadLE32(chun
│
R11(a1, b1, c1, d1, e1, w0, 11); │ R11(a1, b1, c1, d1, e1, w0, 11);
R12(a2, b2, c2, d2, e2, w5, 8); │ R12(a2, b2, c2, d2, e2, w5, 8);
R11(e1, a1, b1, c1, d1, w1, 14); │ R11(e1, a1, b1, c1, d1, w1, 14);
R12(e2, a2, b2, c2, d2, w14, 9); │ R12(e2, a2, b2, c2, d2, w14, 9);
R11(d1, e1, a1, b1, c1, w2, 15); │ R11(d1, e1, a1, b1, c1, w2, 15);
R12(d2, e2, a2, b2, c2, w7, 9); │ R12(d2, e2, a2, b2, c2, w7, 9);
R11(c1, d1, e1, a1, b1, w3, 12); │ R11(c1, d1, e1, a1, b1, w3, 12);
R12(c2, d2, e2, a2, b2, w0, 11); │ R12(c2, d2, e2, a2, b2, w0, 11);
R11(b1, c1, d1, e1, a1, w4, 5); │ R11(b1, c1, d1, e1, a1, w4, 5);
R12(b2, c2, d2, e2, a2, w9, 13); │ R12(b2, c2, d2, e2, a2, w9, 13);
R11(a1, b1, c1, d1, e1, w5, 8); │ R11(a1, b1, c1, d1, e1, w5, 8);
R12(a2, b2, c2, d2, e2, w2, 15); │ R12(a2, b2, c2, d2, e2, w2, 15);
R11(e1, a1, b1, c1, d1, w6, 7); │ R11(e1, a1, b1, c1, d1, w6, 7);
R12(e2, a2, b2, c2, d2, w11, 15); │ R12(e2, a2, b2, c2, d2, w11, 15);
R11(d1, e1, a1, b1, c1, w7, 9); │ R11(d1, e1, a1, b1, c1, w7, 9);
R12(d2, e2, a2, b2, c2, w4, 5); │ R12(d2, e2, a2, b2, c2, w4, 5);
R11(c1, d1, e1, a1, b1, w8, 11); │ R11(c1, d1, e1, a1, b1, w8, 11);
R12(c2, d2, e2, a2, b2, w13, 7); │ R12(c2, d2, e2, a2, b2, w13, 7);
R11(b1, c1, d1, e1, a1, w9, 13); │ R11(b1, c1, d1, e1, a1, w9, 13);
R12(b2, c2, d2, e2, a2, w6, 7); │ R12(b2, c2, d2, e2, a2, w6, 7);
R11(a1, b1, c1, d1, e1, w10, 14); │ R11(a1, b1, c1, d1, e1, w10, 14);
R12(a2, b2, c2, d2, e2, w15, 8); │ R12(a2, b2, c2, d2, e2, w15, 8);
R11(e1, a1, b1, c1, d1, w11, 15); │ R11(e1, a1, b1, c1, d1, w11, 15);
R12(e2, a2, b2, c2, d2, w8, 11); │ R12(e2, a2, b2, c2, d2, w8, 11);
R11(d1, e1, a1, b1, c1, w12, 6); │ R11(d1, e1, a1, b1, c1, w12, 6);
R12(d2, e2, a2, b2, c2, w1, 14); │ R12(d2, e2, a2, b2, c2, w1, 14);
R11(c1, d1, e1, a1, b1, w13, 7); │ R11(c1, d1, e1, a1, b1, w13, 7);
R12(c2, d2, e2, a2, b2, w10, 14); │ R12(c2, d2, e2, a2, b2, w10, 14);
R11(b1, c1, d1, e1, a1, w14, 9); │ R11(b1, c1, d1, e1, a1, w14, 9);
R12(b2, c2, d2, e2, a2, w3, 12); │ R12(b2, c2, d2, e2, a2, w3, 12);
R11(a1, b1, c1, d1, e1, w15, 8); │ R11(a1, b1, c1, d1, e1, w15, 8);
R12(a2, b2, c2, d2, e2, w12, 6); │ R12(a2, b2, c2, d2, e2, w12, 6);
│
R21(e1, a1, b1, c1, d1, w7, 7); │ R21(e1, a1, b1, c1, d1, w7, 7);
R22(e2, a2, b2, c2, d2, w6, 9); │ R22(e2, a2, b2, c2, d2, w6, 9);
R21(d1, e1, a1, b1, c1, w4, 6); │ R21(d1, e1, a1, b1, c1, w4, 6);
R22(d2, e2, a2, b2, c2, w11, 13); │ R22(d2, e2, a2, b2, c2, w11, 13);
R21(c1, d1, e1, a1, b1, w13, 8); │ R21(c1, d1, e1, a1, b1, w13, 8);
R22(c2, d2, e2, a2, b2, w3, 15); │ R22(c2, d2, e2, a2, b2, w3, 15);
R21(b1, c1, d1, e1, a1, w1, 13); │ R21(b1, c1, d1, e1, a1, w1, 13);
R22(b2, c2, d2, e2, a2, w7, 7); │ R22(b2, c2, d2, e2, a2, w7, 7);
R21(a1, b1, c1, d1, e1, w10, 11); │ R21(a1, b1, c1, d1, e1, w10, 11);
R22(a2, b2, c2, d2, e2, w0, 12); │ R22(a2, b2, c2, d2, e2, w0, 12);
R21(e1, a1, b1, c1, d1, w6, 9); │ R21(e1, a1, b1, c1, d1, w6, 9);
R22(e2, a2, b2, c2, d2, w13, 8); │ R22(e2, a2, b2, c2, d2, w13, 8);
R21(d1, e1, a1, b1, c1, w15, 7); │ R21(d1, e1, a1, b1, c1, w15, 7);
R22(d2, e2, a2, b2, c2, w5, 9); │ R22(d2, e2, a2, b2, c2, w5, 9);
R21(c1, d1, e1, a1, b1, w3, 15); │ R21(c1, d1, e1, a1, b1, w3, 15);
R22(c2, d2, e2, a2, b2, w10, 11); │ R22(c2, d2, e2, a2, b2, w10, 11);
R21(b1, c1, d1, e1, a1, w12, 7); │ R21(b1, c1, d1, e1, a1, w12, 7);
R22(b2, c2, d2, e2, a2, w14, 7); │ R22(b2, c2, d2, e2, a2, w14, 7);
R21(a1, b1, c1, d1, e1, w0, 12); │ R21(a1, b1, c1, d1, e1, w0, 12);
R22(a2, b2, c2, d2, e2, w15, 7); │ R22(a2, b2, c2, d2, e2, w15, 7);
R21(e1, a1, b1, c1, d1, w9, 15); │ R21(e1, a1, b1, c1, d1, w9, 15);
R22(e2, a2, b2, c2, d2, w8, 12); │ R22(e2, a2, b2, c2, d2, w8, 12);
R21(d1, e1, a1, b1, c1, w5, 9); │ R21(d1, e1, a1, b1, c1, w5, 9);
R22(d2, e2, a2, b2, c2, w12, 7); │ R22(d2, e2, a2, b2, c2, w12, 7);
R21(c1, d1, e1, a1, b1, w2, 11); │ R21(c1, d1, e1, a1, b1, w2, 11);
R22(c2, d2, e2, a2, b2, w4, 6); │ R22(c2, d2, e2, a2, b2, w4, 6);
R21(b1, c1, d1, e1, a1, w14, 7); │ R21(b1, c1, d1, e1, a1, w14, 7);
R22(b2, c2, d2, e2, a2, w9, 15); │ R22(b2, c2, d2, e2, a2, w9, 15);
R21(a1, b1, c1, d1, e1, w11, 13); │ R21(a1, b1, c1, d1, e1, w11, 13);
R22(a2, b2, c2, d2, e2, w1, 13); │ R22(a2, b2, c2, d2, e2, w1, 13);
R21(e1, a1, b1, c1, d1, w8, 12); │ R21(e1, a1, b1, c1, d1, w8, 12);
R22(e2, a2, b2, c2, d2, w2, 11); │ R22(e2, a2, b2, c2, d2, w2, 11);
│
R31(d1, e1, a1, b1, c1, w3, 11); │ R31(d1, e1, a1, b1, c1, w3, 11);
R32(d2, e2, a2, b2, c2, w15, 9); │ R32(d2, e2, a2, b2, c2, w15, 9);
R31(c1, d1, e1, a1, b1, w10, 13); │ R31(c1, d1, e1, a1, b1, w10, 13);
R32(c2, d2, e2, a2, b2, w5, 7); │ R32(c2, d2, e2, a2, b2, w5, 7);
R31(b1, c1, d1, e1, a1, w14, 6); │ R31(b1, c1, d1, e1, a1, w14, 6);
R32(b2, c2, d2, e2, a2, w1, 15); │ R32(b2, c2, d2, e2, a2, w1, 15);
R31(a1, b1, c1, d1, e1, w4, 7); │ R31(a1, b1, c1, d1, e1, w4, 7);
R32(a2, b2, c2, d2, e2, w3, 11); │ R32(a2, b2, c2, d2, e2, w3, 11);
R31(e1, a1, b1, c1, d1, w9, 14); │ R31(e1, a1, b1, c1, d1, w9, 14);
R32(e2, a2, b2, c2, d2, w7, 8); │ R32(e2, a2, b2, c2, d2, w7, 8);
R31(d1, e1, a1, b1, c1, w15, 9); │ R31(d1, e1, a1, b1, c1, w15, 9);
R32(d2, e2, a2, b2, c2, w14, 6); │ R32(d2, e2, a2, b2, c2, w14, 6);
R31(c1, d1, e1, a1, b1, w8, 13); │ R31(c1, d1, e1, a1, b1, w8, 13);
R32(c2, d2, e2, a2, b2, w6, 6); │ R32(c2, d2, e2, a2, b2, w6, 6);
R31(b1, c1, d1, e1, a1, w1, 15); │ R31(b1, c1, d1, e1, a1, w1, 15);
R32(b2, c2, d2, e2, a2, w9, 14); │ R32(b2, c2, d2, e2, a2, w9, 14);
R31(a1, b1, c1, d1, e1, w2, 14); │ R31(a1, b1, c1, d1, e1, w2, 14);
R32(a2, b2, c2, d2, e2, w11, 12); │ R32(a2, b2, c2, d2, e2, w11, 12);
R31(e1, a1, b1, c1, d1, w7, 8); │ R31(e1, a1, b1, c1, d1, w7, 8);
R32(e2, a2, b2, c2, d2, w8, 13); │ R32(e2, a2, b2, c2, d2, w8, 13);
R31(d1, e1, a1, b1, c1, w0, 13); │ R31(d1, e1, a1, b1, c1, w0, 13);
R32(d2, e2, a2, b2, c2, w12, 5); │ R32(d2, e2, a2, b2, c2, w12, 5);
R31(c1, d1, e1, a1, b1, w6, 6); │ R31(c1, d1, e1, a1, b1, w6, 6);
R32(c2, d2, e2, a2, b2, w2, 14); │ R32(c2, d2, e2, a2, b2, w2, 14);
R31(b1, c1, d1, e1, a1, w13, 5); │ R31(b1, c1, d1, e1, a1, w13, 5);
R32(b2, c2, d2, e2, a2, w10, 13); │ R32(b2, c2, d2, e2, a2, w10, 13);
R31(a1, b1, c1, d1, e1, w11, 12); │ R31(a1, b1, c1, d1, e1, w11, 12);
R32(a2, b2, c2, d2, e2, w0, 13); │ R32(a2, b2, c2, d2, e2, w0, 13);
R31(e1, a1, b1, c1, d1, w5, 7); │ R31(e1, a1, b1, c1, d1, w5, 7);
R32(e2, a2, b2, c2, d2, w4, 7); │ R32(e2, a2, b2, c2, d2, w4, 7);
R31(d1, e1, a1, b1, c1, w12, 5); │ R31(d1, e1, a1, b1, c1, w12, 5);
R32(d2, e2, a2, b2, c2, w13, 5); │ R32(d2, e2, a2, b2, c2, w13, 5);
│
R41(c1, d1, e1, a1, b1, w1, 11); │ R41(c1, d1, e1, a1, b1, w1, 11);
R42(c2, d2, e2, a2, b2, w8, 15); │ R42(c2, d2, e2, a2, b2, w8, 15);
R41(b1, c1, d1, e1, a1, w9, 12); │ R41(b1, c1, d1, e1, a1, w9, 12);
R42(b2, c2, d2, e2, a2, w6, 5); │ R42(b2, c2, d2, e2, a2, w6, 5);
R41(a1, b1, c1, d1, e1, w11, 14); │ R41(a1, b1, c1, d1, e1, w11, 14);
R42(a2, b2, c2, d2, e2, w4, 8); │ R42(a2, b2, c2, d2, e2, w4, 8);
R41(e1, a1, b1, c1, d1, w10, 15); │ R41(e1, a1, b1, c1, d1, w10, 15);
R42(e2, a2, b2, c2, d2, w1, 11); │ R42(e2, a2, b2, c2, d2, w1, 11);
R41(d1, e1, a1, b1, c1, w0, 14); │ R41(d1, e1, a1, b1, c1, w0, 14);
R42(d2, e2, a2, b2, c2, w3, 14); │ R42(d2, e2, a2, b2, c2, w3, 14);
R41(c1, d1, e1, a1, b1, w8, 15); │ R41(c1, d1, e1, a1, b1, w8, 15);
R42(c2, d2, e2, a2, b2, w11, 14); │ R42(c2, d2, e2, a2, b2, w11, 14);
R41(b1, c1, d1, e1, a1, w12, 9); │ R41(b1, c1, d1, e1, a1, w12, 9);
R42(b2, c2, d2, e2, a2, w15, 6); │ R42(b2, c2, d2, e2, a2, w15, 6);
R41(a1, b1, c1, d1, e1, w4, 8); │ R41(a1, b1, c1, d1, e1, w4, 8);
R42(a2, b2, c2, d2, e2, w0, 14); │ R42(a2, b2, c2, d2, e2, w0, 14);
R41(e1, a1, b1, c1, d1, w13, 9); │ R41(e1, a1, b1, c1, d1, w13, 9);
R42(e2, a2, b2, c2, d2, w5, 6); │ R42(e2, a2, b2, c2, d2, w5, 6);
R41(d1, e1, a1, b1, c1, w3, 14); │ R41(d1, e1, a1, b1, c1, w3, 14);
R42(d2, e2, a2, b2, c2, w12, 9); │ R42(d2, e2, a2, b2, c2, w12, 9);
R41(c1, d1, e1, a1, b1, w7, 5); │ R41(c1, d1, e1, a1, b1, w7, 5);
R42(c2, d2, e2, a2, b2, w2, 12); │ R42(c2, d2, e2, a2, b2, w2, 12);
R41(b1, c1, d1, e1, a1, w15, 6); │ R41(b1, c1, d1, e1, a1, w15, 6);
R42(b2, c2, d2, e2, a2, w13, 9); │ R42(b2, c2, d2, e2, a2, w13, 9);
R41(a1, b1, c1, d1, e1, w14, 8); │ R41(a1, b1, c1, d1, e1, w14, 8);
R42(a2, b2, c2, d2, e2, w9, 12); │ R42(a2, b2, c2, d2, e2, w9, 12);
R41(e1, a1, b1, c1, d1, w5, 6); │ R41(e1, a1, b1, c1, d1, w5, 6);
R42(e2, a2, b2, c2, d2, w7, 5); │ R42(e2, a2, b2, c2, d2, w7, 5);
R41(d1, e1, a1, b1, c1, w6, 5); │ R41(d1, e1, a1, b1, c1, w6, 5);
R42(d2, e2, a2, b2, c2, w10, 15); │ R42(d2, e2, a2, b2, c2, w10, 15);
R41(c1, d1, e1, a1, b1, w2, 12); │ R41(c1, d1, e1, a1, b1, w2, 12);
R42(c2, d2, e2, a2, b2, w14, 8); │ R42(c2, d2, e2, a2, b2, w14, 8);
│
R51(b1, c1, d1, e1, a1, w4, 9); │ R51(b1, c1, d1, e1, a1, w4, 9);
R52(b2, c2, d2, e2, a2, w12, 8); │ R52(b2, c2, d2, e2, a2, w12, 8);
R51(a1, b1, c1, d1, e1, w0, 15); │ R51(a1, b1, c1, d1, e1, w0, 15);
R52(a2, b2, c2, d2, e2, w15, 5); │ R52(a2, b2, c2, d2, e2, w15, 5);
R51(e1, a1, b1, c1, d1, w5, 5); │ R51(e1, a1, b1, c1, d1, w5, 5);
R52(e2, a2, b2, c2, d2, w10, 12); │ R52(e2, a2, b2, c2, d2, w10, 12);
R51(d1, e1, a1, b1, c1, w9, 11); │ R51(d1, e1, a1, b1, c1, w9, 11);
R52(d2, e2, a2, b2, c2, w4, 9); │ R52(d2, e2, a2, b2, c2, w4, 9);
R51(c1, d1, e1, a1, b1, w7, 6); │ R51(c1, d1, e1, a1, b1, w7, 6);
R52(c2, d2, e2, a2, b2, w1, 12); │ R52(c2, d2, e2, a2, b2, w1, 12);
R51(b1, c1, d1, e1, a1, w12, 8); │ R51(b1, c1, d1, e1, a1, w12, 8);
R52(b2, c2, d2, e2, a2, w5, 5); │ R52(b2, c2, d2, e2, a2, w5, 5);
R51(a1, b1, c1, d1, e1, w2, 13); │ R51(a1, b1, c1, d1, e1, w2, 13);
R52(a2, b2, c2, d2, e2, w8, 14); │ R52(a2, b2, c2, d2, e2, w8, 14);
R51(e1, a1, b1, c1, d1, w10, 12); │ R51(e1, a1, b1, c1, d1, w10, 12);
R52(e2, a2, b2, c2, d2, w7, 6); │ R52(e2, a2, b2, c2, d2, w7, 6);
R51(d1, e1, a1, b1, c1, w14, 5); │ R51(d1, e1, a1, b1, c1, w14, 5);
R52(d2, e2, a2, b2, c2, w6, 8); │ R52(d2, e2, a2, b2, c2, w6, 8);
R51(c1, d1, e1, a1, b1, w1, 12); │ R51(c1, d1, e1, a1, b1, w1, 12);
R52(c2, d2, e2, a2, b2, w2, 13); │ R52(c2, d2, e2, a2, b2, w2, 13);
R51(b1, c1, d1, e1, a1, w3, 13); │ R51(b1, c1, d1, e1, a1, w3, 13);
R52(b2, c2, d2, e2, a2, w13, 6); │ R52(b2, c2, d2, e2, a2, w13, 6);
R51(a1, b1, c1, d1, e1, w8, 14); │ R51(a1, b1, c1, d1, e1, w8, 14);
R52(a2, b2, c2, d2, e2, w14, 5); │ R52(a2, b2, c2, d2, e2, w14, 5);
R51(e1, a1, b1, c1, d1, w11, 11); │ R51(e1, a1, b1, c1, d1, w11, 11);
R52(e2, a2, b2, c2, d2, w0, 15); │ R52(e2, a2, b2, c2, d2, w0, 15);
R51(d1, e1, a1, b1, c1, w6, 8); │ R51(d1, e1, a1, b1, c1, w6, 8);
R52(d2, e2, a2, b2, c2, w3, 13); │ R52(d2, e2, a2, b2, c2, w3, 13);
R51(c1, d1, e1, a1, b1, w15, 5); │ R51(c1, d1, e1, a1, b1, w15, 5);
R52(c2, d2, e2, a2, b2, w9, 11); │ R52(c2, d2, e2, a2, b2, w9, 11);
R51(b1, c1, d1, e1, a1, w13, 6); │ R51(b1, c1, d1, e1, a1, w13, 6);
R52(b2, c2, d2, e2, a2, w11, 11); │ R52(b2, c2, d2, e2, a2, w11, 11);
│
uint32_t t = s[0]; │ uint32_t t = s[0];
s[0] = s[1] + c1 + d2; │ s[0] = s[1] + c1 + d2;
s[1] = s[2] + d1 + e2; │ s[1] = s[2] + d1 + e2;
s[2] = s[3] + e1 + a2; │ s[2] = s[3] + e1 + a2;
s[3] = s[4] + a1 + b2; │ s[3] = s[4] + a1 + b2;
s[4] = t + b1 + c2; │ s[4] = t + b1 + c2;
} │ }
│
} // namespace ripemd160 │ } // namespace ripemd160
│
} │
next prev up bitcoin/src/crypto/sha512.cpp:16 │ dogecoin/src/crypto/sha512.cpp:22
│
│ #ifndef USE_AVX2
uint64_t inline Ch(uint64_t x, uint64_t y, uint64_t z) { return z ^ (x & (y ^ z)); } │ uint64_t inline Ch(uint64_t x, uint64_t y, uint64_t z) { return z ^ (x & (y ^ z)); }
uint64_t inline Maj(uint64_t x, uint64_t y, uint64_t z) { return (x & y) | (z & (x | y)) │ uint64_t inline Maj(uint64_t x, uint64_t y, uint64_t z) { return (x & y) | (z & (x | y))
uint64_t inline Sigma0(uint64_t x) { return (x >> 28 | x << 36) ^ (x >> 34 | x << 30) ^ │ uint64_t inline Sigma0(uint64_t x) { return (x >> 28 | x << 36) ^ (x >> 34 | x << 30) ^
uint64_t inline Sigma1(uint64_t x) { return (x >> 14 | x << 50) ^ (x >> 18 | x << 46) ^ │ uint64_t inline Sigma1(uint64_t x) { return (x >> 14 | x << 50) ^ (x >> 18 | x << 46) ^
uint64_t inline sigma0(uint64_t x) { return (x >> 1 | x << 63) ^ (x >> 8 | x << 56) ^ (x │ uint64_t inline sigma0(uint64_t x) { return (x >> 1 | x << 63) ^ (x >> 8 | x << 56) ^ (x
uint64_t inline sigma1(uint64_t x) { return (x >> 19 | x << 45) ^ (x >> 61 | x << 3) ^ ( │ uint64_t inline sigma1(uint64_t x) { return (x >> 19 | x << 45) ^ (x >> 61 | x << 3) ^ (
│
/** One round of SHA-512. */ │ /** One round of SHA-512. */
void inline Round(uint64_t a, uint64_t b, uint64_t c, uint64_t& d, uint64_t e, uint64_t │ void inline Round(uint64_t a, uint64_t b, uint64_t c, uint64_t& d, uint64_t e, uint64_t
{ │ {
uint64_t t1 = h + Sigma1(e) + Ch(e, f, g) + k + w; │ uint64_t t1 = h + Sigma1(e) + Ch(e, f, g) + k + w;
uint64_t t2 = Sigma0(a) + Maj(a, b, c); │ uint64_t t2 = Sigma0(a) + Maj(a, b, c);
d += t1; │ d += t1;
h = t1 + t2; │ h = t1 + t2;
} │ }
│ #endif
│
/** Initialize SHA-256 state. */ │ /** Initialize SHA-256 state. */
void inline Initialize(uint64_t* s) │ void inline Initialize(uint64_t* s)
{ │ {
s[0] = 0x6a09e667f3bcc908ull; │ s[0] = 0x6a09e667f3bcc908ull;
s[1] = 0xbb67ae8584caa73bull; │ s[1] = 0xbb67ae8584caa73bull;
s[2] = 0x3c6ef372fe94f82bull; │ s[2] = 0x3c6ef372fe94f82bull;
s[3] = 0xa54ff53a5f1d36f1ull; │ s[3] = 0xa54ff53a5f1d36f1ull;
s[4] = 0x510e527fade682d1ull; │ s[4] = 0x510e527fade682d1ull;
s[5] = 0x9b05688c2b3e6c1full; │ s[5] = 0x9b05688c2b3e6c1full;
s[6] = 0x1f83d9abfb41bd6bull; │ s[6] = 0x1f83d9abfb41bd6bull;
s[7] = 0x5be0cd19137e2179ull; │ s[7] = 0x5be0cd19137e2179ull;
} │ }
│
/** Perform one SHA-512 transformation, processing a 128-byte chunk. */ │ /** Perform one SHA-512 transformation, processing a 128-byte chunk. */
void Transform(uint64_t* s, const unsigned char* chunk) │ void Transform(uint64_t* s, const unsigned char* chunk)
{ │ {
│ #ifdef USE_AVX2
│ // Perform SHA512 one block (Intel AVX2)
│ sha512_one_block_avx2(chunk, s);
│ #else
│ // Perform SHA512 one block (legacy)
uint64_t a = s[0], b = s[1], c = s[2], d = s[3], e = s[4], f = s[5], g = s[6], h = s │ uint64_t a = s[0], b = s[1], c = s[2], d = s[3], e = s[4], f = s[5], g = s[6], h = s
uint64_t w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15; │ uint64_t w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15;
│
Round(a, b, c, d, e, f, g, h, 0x428a2f98d728ae22ull, w0 = ReadBE64(chunk + 0)); │ Round(a, b, c, d, e, f, g, h, 0x428a2f98d728ae22ull, w0 = ReadBE64(chunk + 0));
Round(h, a, b, c, d, e, f, g, 0x7137449123ef65cdull, w1 = ReadBE64(chunk + 8)); │ Round(h, a, b, c, d, e, f, g, 0x7137449123ef65cdull, w1 = ReadBE64(chunk + 8));
Round(g, h, a, b, c, d, e, f, 0xb5c0fbcfec4d3b2full, w2 = ReadBE64(chunk + 16)); │ Round(g, h, a, b, c, d, e, f, 0xb5c0fbcfec4d3b2full, w2 = ReadBE64(chunk + 16));
Round(f, g, h, a, b, c, d, e, 0xe9b5dba58189dbbcull, w3 = ReadBE64(chunk + 24)); │ Round(f, g, h, a, b, c, d, e, 0xe9b5dba58189dbbcull, w3 = ReadBE64(chunk + 24));
Round(e, f, g, h, a, b, c, d, 0x3956c25bf348b538ull, w4 = ReadBE64(chunk + 32)); │ Round(e, f, g, h, a, b, c, d, 0x3956c25bf348b538ull, w4 = ReadBE64(chunk + 32));
Round(d, e, f, g, h, a, b, c, 0x59f111f1b605d019ull, w5 = ReadBE64(chunk + 40)); │ Round(d, e, f, g, h, a, b, c, 0x59f111f1b605d019ull, w5 = ReadBE64(chunk + 40));
Round(c, d, e, f, g, h, a, b, 0x923f82a4af194f9bull, w6 = ReadBE64(chunk + 48)); │ Round(c, d, e, f, g, h, a, b, 0x923f82a4af194f9bull, w6 = ReadBE64(chunk + 48));
Round(b, c, d, e, f, g, h, a, 0xab1c5ed5da6d8118ull, w7 = ReadBE64(chunk + 56)); │ Round(b, c, d, e, f, g, h, a, 0xab1c5ed5da6d8118ull, w7 = ReadBE64(chunk + 56));
Round(a, b, c, d, e, f, g, h, 0xd807aa98a3030242ull, w8 = ReadBE64(chunk + 64)); │ Round(a, b, c, d, e, f, g, h, 0xd807aa98a3030242ull, w8 = ReadBE64(chunk + 64));
Round(h, a, b, c, d, e, f, g, 0x12835b0145706fbeull, w9 = ReadBE64(chunk + 72)); │ Round(h, a, b, c, d, e, f, g, 0x12835b0145706fbeull, w9 = ReadBE64(chunk + 72));
Round(g, h, a, b, c, d, e, f, 0x243185be4ee4b28cull, w10 = ReadBE64(chunk + 80)); │ Round(g, h, a, b, c, d, e, f, 0x243185be4ee4b28cull, w10 = ReadBE64(chunk + 80));
Round(f, g, h, a, b, c, d, e, 0x550c7dc3d5ffb4e2ull, w11 = ReadBE64(chunk + 88)); │ Round(f, g, h, a, b, c, d, e, 0x550c7dc3d5ffb4e2ull, w11 = ReadBE64(chunk + 88));
Round(e, f, g, h, a, b, c, d, 0x72be5d74f27b896full, w12 = ReadBE64(chunk + 96)); │ Round(e, f, g, h, a, b, c, d, 0x72be5d74f27b896full, w12 = ReadBE64(chunk + 96));
Round(d, e, f, g, h, a, b, c, 0x80deb1fe3b1696b1ull, w13 = ReadBE64(chunk + 104)); │ Round(d, e, f, g, h, a, b, c, 0x80deb1fe3b1696b1ull, w13 = ReadBE64(chunk + 104));
Round(c, d, e, f, g, h, a, b, 0x9bdc06a725c71235ull, w14 = ReadBE64(chunk + 112)); │ Round(c, d, e, f, g, h, a, b, 0x9bdc06a725c71235ull, w14 = ReadBE64(chunk + 112));
Round(b, c, d, e, f, g, h, a, 0xc19bf174cf692694ull, w15 = ReadBE64(chunk + 120)); │ Round(b, c, d, e, f, g, h, a, 0xc19bf174cf692694ull, w15 = ReadBE64(chunk + 120));
│
Round(a, b, c, d, e, f, g, h, 0xe49b69c19ef14ad2ull, w0 += sigma1(w14) + w9 + sigma0 │ Round(a, b, c, d, e, f, g, h, 0xe49b69c19ef14ad2ull, w0 += sigma1(w14) + w9 + sigma0
Round(h, a, b, c, d, e, f, g, 0xefbe4786384f25e3ull, w1 += sigma1(w15) + w10 + sigma │ Round(h, a, b, c, d, e, f, g, 0xefbe4786384f25e3ull, w1 += sigma1(w15) + w10 + sigma
Round(g, h, a, b, c, d, e, f, 0x0fc19dc68b8cd5b5ull, w2 += sigma1(w0) + w11 + sigma0 │ Round(g, h, a, b, c, d, e, f, 0x0fc19dc68b8cd5b5ull, w2 += sigma1(w0) + w11 + sigma0
Round(f, g, h, a, b, c, d, e, 0x240ca1cc77ac9c65ull, w3 += sigma1(w1) + w12 + sigma0 │ Round(f, g, h, a, b, c, d, e, 0x240ca1cc77ac9c65ull, w3 += sigma1(w1) + w12 + sigma0
Round(e, f, g, h, a, b, c, d, 0x2de92c6f592b0275ull, w4 += sigma1(w2) + w13 + sigma0 │ Round(e, f, g, h, a, b, c, d, 0x2de92c6f592b0275ull, w4 += sigma1(w2) + w13 + sigma0
Round(d, e, f, g, h, a, b, c, 0x4a7484aa6ea6e483ull, w5 += sigma1(w3) + w14 + sigma0 │ Round(d, e, f, g, h, a, b, c, 0x4a7484aa6ea6e483ull, w5 += sigma1(w3) + w14 + sigma0
Round(c, d, e, f, g, h, a, b, 0x5cb0a9dcbd41fbd4ull, w6 += sigma1(w4) + w15 + sigma0 │ Round(c, d, e, f, g, h, a, b, 0x5cb0a9dcbd41fbd4ull, w6 += sigma1(w4) + w15 + sigma0
Round(b, c, d, e, f, g, h, a, 0x76f988da831153b5ull, w7 += sigma1(w5) + w0 + sigma0( │ Round(b, c, d, e, f, g, h, a, 0x76f988da831153b5ull, w7 += sigma1(w5) + w0 + sigma0(
Round(a, b, c, d, e, f, g, h, 0x983e5152ee66dfabull, w8 += sigma1(w6) + w1 + sigma0( │ Round(a, b, c, d, e, f, g, h, 0x983e5152ee66dfabull, w8 += sigma1(w6) + w1 + sigma0(
Round(h, a, b, c, d, e, f, g, 0xa831c66d2db43210ull, w9 += sigma1(w7) + w2 + sigma0( │ Round(h, a, b, c, d, e, f, g, 0xa831c66d2db43210ull, w9 += sigma1(w7) + w2 + sigma0(
Round(g, h, a, b, c, d, e, f, 0xb00327c898fb213full, w10 += sigma1(w8) + w3 + sigma0 │ Round(g, h, a, b, c, d, e, f, 0xb00327c898fb213full, w10 += sigma1(w8) + w3 + sigma0
Round(f, g, h, a, b, c, d, e, 0xbf597fc7beef0ee4ull, w11 += sigma1(w9) + w4 + sigma0 │ Round(f, g, h, a, b, c, d, e, 0xbf597fc7beef0ee4ull, w11 += sigma1(w9) + w4 + sigma0
Round(e, f, g, h, a, b, c, d, 0xc6e00bf33da88fc2ull, w12 += sigma1(w10) + w5 + sigma │ Round(e, f, g, h, a, b, c, d, 0xc6e00bf33da88fc2ull, w12 += sigma1(w10) + w5 + sigma
Round(d, e, f, g, h, a, b, c, 0xd5a79147930aa725ull, w13 += sigma1(w11) + w6 + sigma │ Round(d, e, f, g, h, a, b, c, 0xd5a79147930aa725ull, w13 += sigma1(w11) + w6 + sigma
Round(c, d, e, f, g, h, a, b, 0x06ca6351e003826full, w14 += sigma1(w12) + w7 + sigma │ Round(c, d, e, f, g, h, a, b, 0x06ca6351e003826full, w14 += sigma1(w12) + w7 + sigma
Round(b, c, d, e, f, g, h, a, 0x142929670a0e6e70ull, w15 += sigma1(w13) + w8 + sigma │ Round(b, c, d, e, f, g, h, a, 0x142929670a0e6e70ull, w15 += sigma1(w13) + w8 + sigma
│
Round(a, b, c, d, e, f, g, h, 0x27b70a8546d22ffcull, w0 += sigma1(w14) + w9 + sigma0 │ Round(a, b, c, d, e, f, g, h, 0x27b70a8546d22ffcull, w0 += sigma1(w14) + w9 + sigma0
Round(h, a, b, c, d, e, f, g, 0x2e1b21385c26c926ull, w1 += sigma1(w15) + w10 + sigma │ Round(h, a, b, c, d, e, f, g, 0x2e1b21385c26c926ull, w1 += sigma1(w15) + w10 + sigma
Round(g, h, a, b, c, d, e, f, 0x4d2c6dfc5ac42aedull, w2 += sigma1(w0) + w11 + sigma0 │ Round(g, h, a, b, c, d, e, f, 0x4d2c6dfc5ac42aedull, w2 += sigma1(w0) + w11 + sigma0
Round(f, g, h, a, b, c, d, e, 0x53380d139d95b3dfull, w3 += sigma1(w1) + w12 + sigma0 │ Round(f, g, h, a, b, c, d, e, 0x53380d139d95b3dfull, w3 += sigma1(w1) + w12 + sigma0
Round(e, f, g, h, a, b, c, d, 0x650a73548baf63deull, w4 += sigma1(w2) + w13 + sigma0 │ Round(e, f, g, h, a, b, c, d, 0x650a73548baf63deull, w4 += sigma1(w2) + w13 + sigma0
Round(d, e, f, g, h, a, b, c, 0x766a0abb3c77b2a8ull, w5 += sigma1(w3) + w14 + sigma0 │ Round(d, e, f, g, h, a, b, c, 0x766a0abb3c77b2a8ull, w5 += sigma1(w3) + w14 + sigma0
Round(c, d, e, f, g, h, a, b, 0x81c2c92e47edaee6ull, w6 += sigma1(w4) + w15 + sigma0 │ Round(c, d, e, f, g, h, a, b, 0x81c2c92e47edaee6ull, w6 += sigma1(w4) + w15 + sigma0
Round(b, c, d, e, f, g, h, a, 0x92722c851482353bull, w7 += sigma1(w5) + w0 + sigma0( │ Round(b, c, d, e, f, g, h, a, 0x92722c851482353bull, w7 += sigma1(w5) + w0 + sigma0(
Round(a, b, c, d, e, f, g, h, 0xa2bfe8a14cf10364ull, w8 += sigma1(w6) + w1 + sigma0( │ Round(a, b, c, d, e, f, g, h, 0xa2bfe8a14cf10364ull, w8 += sigma1(w6) + w1 + sigma0(
Round(h, a, b, c, d, e, f, g, 0xa81a664bbc423001ull, w9 += sigma1(w7) + w2 + sigma0( │ Round(h, a, b, c, d, e, f, g, 0xa81a664bbc423001ull, w9 += sigma1(w7) + w2 + sigma0(
Round(g, h, a, b, c, d, e, f, 0xc24b8b70d0f89791ull, w10 += sigma1(w8) + w3 + sigma0 │ Round(g, h, a, b, c, d, e, f, 0xc24b8b70d0f89791ull, w10 += sigma1(w8) + w3 + sigma0
Round(f, g, h, a, b, c, d, e, 0xc76c51a30654be30ull, w11 += sigma1(w9) + w4 + sigma0 │ Round(f, g, h, a, b, c, d, e, 0xc76c51a30654be30ull, w11 += sigma1(w9) + w4 + sigma0
Round(e, f, g, h, a, b, c, d, 0xd192e819d6ef5218ull, w12 += sigma1(w10) + w5 + sigma │ Round(e, f, g, h, a, b, c, d, 0xd192e819d6ef5218ull, w12 += sigma1(w10) + w5 + sigma
Round(d, e, f, g, h, a, b, c, 0xd69906245565a910ull, w13 += sigma1(w11) + w6 + sigma │ Round(d, e, f, g, h, a, b, c, 0xd69906245565a910ull, w13 += sigma1(w11) + w6 + sigma
Round(c, d, e, f, g, h, a, b, 0xf40e35855771202aull, w14 += sigma1(w12) + w7 + sigma │ Round(c, d, e, f, g, h, a, b, 0xf40e35855771202aull, w14 += sigma1(w12) + w7 + sigma
Round(b, c, d, e, f, g, h, a, 0x106aa07032bbd1b8ull, w15 += sigma1(w13) + w8 + sigma │ Round(b, c, d, e, f, g, h, a, 0x106aa07032bbd1b8ull, w15 += sigma1(w13) + w8 + sigma
│
Round(a, b, c, d, e, f, g, h, 0x19a4c116b8d2d0c8ull, w0 += sigma1(w14) + w9 + sigma0 │ Round(a, b, c, d, e, f, g, h, 0x19a4c116b8d2d0c8ull, w0 += sigma1(w14) + w9 + sigma0
Round(h, a, b, c, d, e, f, g, 0x1e376c085141ab53ull, w1 += sigma1(w15) + w10 + sigma │ Round(h, a, b, c, d, e, f, g, 0x1e376c085141ab53ull, w1 += sigma1(w15) + w10 + sigma
Round(g, h, a, b, c, d, e, f, 0x2748774cdf8eeb99ull, w2 += sigma1(w0) + w11 + sigma0 │ Round(g, h, a, b, c, d, e, f, 0x2748774cdf8eeb99ull, w2 += sigma1(w0) + w11 + sigma0
Round(f, g, h, a, b, c, d, e, 0x34b0bcb5e19b48a8ull, w3 += sigma1(w1) + w12 + sigma0 │ Round(f, g, h, a, b, c, d, e, 0x34b0bcb5e19b48a8ull, w3 += sigma1(w1) + w12 + sigma0
Round(e, f, g, h, a, b, c, d, 0x391c0cb3c5c95a63ull, w4 += sigma1(w2) + w13 + sigma0 │ Round(e, f, g, h, a, b, c, d, 0x391c0cb3c5c95a63ull, w4 += sigma1(w2) + w13 + sigma0
Round(d, e, f, g, h, a, b, c, 0x4ed8aa4ae3418acbull, w5 += sigma1(w3) + w14 + sigma0 │ Round(d, e, f, g, h, a, b, c, 0x4ed8aa4ae3418acbull, w5 += sigma1(w3) + w14 + sigma0
Round(c, d, e, f, g, h, a, b, 0x5b9cca4f7763e373ull, w6 += sigma1(w4) + w15 + sigma0 │ Round(c, d, e, f, g, h, a, b, 0x5b9cca4f7763e373ull, w6 += sigma1(w4) + w15 + sigma0
Round(b, c, d, e, f, g, h, a, 0x682e6ff3d6b2b8a3ull, w7 += sigma1(w5) + w0 + sigma0( │ Round(b, c, d, e, f, g, h, a, 0x682e6ff3d6b2b8a3ull, w7 += sigma1(w5) + w0 + sigma0(
Round(a, b, c, d, e, f, g, h, 0x748f82ee5defb2fcull, w8 += sigma1(w6) + w1 + sigma0( │ Round(a, b, c, d, e, f, g, h, 0x748f82ee5defb2fcull, w8 += sigma1(w6) + w1 + sigma0(
Round(h, a, b, c, d, e, f, g, 0x78a5636f43172f60ull, w9 += sigma1(w7) + w2 + sigma0( │ Round(h, a, b, c, d, e, f, g, 0x78a5636f43172f60ull, w9 += sigma1(w7) + w2 + sigma0(
Round(g, h, a, b, c, d, e, f, 0x84c87814a1f0ab72ull, w10 += sigma1(w8) + w3 + sigma0 │ Round(g, h, a, b, c, d, e, f, 0x84c87814a1f0ab72ull, w10 += sigma1(w8) + w3 + sigma0
Round(f, g, h, a, b, c, d, e, 0x8cc702081a6439ecull, w11 += sigma1(w9) + w4 + sigma0 │ Round(f, g, h, a, b, c, d, e, 0x8cc702081a6439ecull, w11 += sigma1(w9) + w4 + sigma0
Round(e, f, g, h, a, b, c, d, 0x90befffa23631e28ull, w12 += sigma1(w10) + w5 + sigma │ Round(e, f, g, h, a, b, c, d, 0x90befffa23631e28ull, w12 += sigma1(w10) + w5 + sigma
Round(d, e, f, g, h, a, b, c, 0xa4506cebde82bde9ull, w13 += sigma1(w11) + w6 + sigma │ Round(d, e, f, g, h, a, b, c, 0xa4506cebde82bde9ull, w13 += sigma1(w11) + w6 + sigma
Round(c, d, e, f, g, h, a, b, 0xbef9a3f7b2c67915ull, w14 += sigma1(w12) + w7 + sigma │ Round(c, d, e, f, g, h, a, b, 0xbef9a3f7b2c67915ull, w14 += sigma1(w12) + w7 + sigma
Round(b, c, d, e, f, g, h, a, 0xc67178f2e372532bull, w15 += sigma1(w13) + w8 + sigma │ Round(b, c, d, e, f, g, h, a, 0xc67178f2e372532bull, w15 += sigma1(w13) + w8 + sigma
│
Round(a, b, c, d, e, f, g, h, 0xca273eceea26619cull, w0 += sigma1(w14) + w9 + sigma0 │ Round(a, b, c, d, e, f, g, h, 0xca273eceea26619cull, w0 += sigma1(w14) + w9 + sigma0
Round(h, a, b, c, d, e, f, g, 0xd186b8c721c0c207ull, w1 += sigma1(w15) + w10 + sigma │ Round(h, a, b, c, d, e, f, g, 0xd186b8c721c0c207ull, w1 += sigma1(w15) + w10 + sigma
Round(g, h, a, b, c, d, e, f, 0xeada7dd6cde0eb1eull, w2 += sigma1(w0) + w11 + sigma0 │ Round(g, h, a, b, c, d, e, f, 0xeada7dd6cde0eb1eull, w2 += sigma1(w0) + w11 + sigma0
Round(f, g, h, a, b, c, d, e, 0xf57d4f7fee6ed178ull, w3 += sigma1(w1) + w12 + sigma0 │ Round(f, g, h, a, b, c, d, e, 0xf57d4f7fee6ed178ull, w3 += sigma1(w1) + w12 + sigma0
Round(e, f, g, h, a, b, c, d, 0x06f067aa72176fbaull, w4 += sigma1(w2) + w13 + sigma0 │ Round(e, f, g, h, a, b, c, d, 0x06f067aa72176fbaull, w4 += sigma1(w2) + w13 + sigma0
Round(d, e, f, g, h, a, b, c, 0x0a637dc5a2c898a6ull, w5 += sigma1(w3) + w14 + sigma0 │ Round(d, e, f, g, h, a, b, c, 0x0a637dc5a2c898a6ull, w5 += sigma1(w3) + w14 + sigma0
Round(c, d, e, f, g, h, a, b, 0x113f9804bef90daeull, w6 += sigma1(w4) + w15 + sigma0 │ Round(c, d, e, f, g, h, a, b, 0x113f9804bef90daeull, w6 += sigma1(w4) + w15 + sigma0
Round(b, c, d, e, f, g, h, a, 0x1b710b35131c471bull, w7 += sigma1(w5) + w0 + sigma0( │ Round(b, c, d, e, f, g, h, a, 0x1b710b35131c471bull, w7 += sigma1(w5) + w0 + sigma0(
Round(a, b, c, d, e, f, g, h, 0x28db77f523047d84ull, w8 += sigma1(w6) + w1 + sigma0( │ Round(a, b, c, d, e, f, g, h, 0x28db77f523047d84ull, w8 += sigma1(w6) + w1 + sigma0(
Round(h, a, b, c, d, e, f, g, 0x32caab7b40c72493ull, w9 += sigma1(w7) + w2 + sigma0( │ Round(h, a, b, c, d, e, f, g, 0x32caab7b40c72493ull, w9 += sigma1(w7) + w2 + sigma0(
Round(g, h, a, b, c, d, e, f, 0x3c9ebe0a15c9bebcull, w10 += sigma1(w8) + w3 + sigma0 │ Round(g, h, a, b, c, d, e, f, 0x3c9ebe0a15c9bebcull, w10 += sigma1(w8) + w3 + sigma0
Round(f, g, h, a, b, c, d, e, 0x431d67c49c100d4cull, w11 += sigma1(w9) + w4 + sigma0 │ Round(f, g, h, a, b, c, d, e, 0x431d67c49c100d4cull, w11 += sigma1(w9) + w4 + sigma0
Round(e, f, g, h, a, b, c, d, 0x4cc5d4becb3e42b6ull, w12 += sigma1(w10) + w5 + sigma │ Round(e, f, g, h, a, b, c, d, 0x4cc5d4becb3e42b6ull, w12 += sigma1(w10) + w5 + sigma
Round(d, e, f, g, h, a, b, c, 0x597f299cfc657e2aull, w13 += sigma1(w11) + w6 + sigma │ Round(d, e, f, g, h, a, b, c, 0x597f299cfc657e2aull, w13 += sigma1(w11) + w6 + sigma
Round(c, d, e, f, g, h, a, b, 0x5fcb6fab3ad6faecull, w14 + sigma1(w12) + w7 + sigma0 │ Round(c, d, e, f, g, h, a, b, 0x5fcb6fab3ad6faecull, w14 + sigma1(w12) + w7 + sigma0
Round(b, c, d, e, f, g, h, a, 0x6c44198c4a475817ull, w15 + sigma1(w13) + w8 + sigma0 │ Round(b, c, d, e, f, g, h, a, 0x6c44198c4a475817ull, w15 + sigma1(w13) + w8 + sigma0
│
s[0] += a; │ s[0] += a;
s[1] += b; │ s[1] += b;
s[2] += c; │ s[2] += c;
s[3] += d; │ s[3] += d;
s[4] += e; │ s[4] += e;
s[5] += f; │ s[5] += f;
s[6] += g; │ s[6] += g;
s[7] += h; │ s[7] += h;
│ #endif
} │ }
│
} │
next prev up dogecoin/src/net_processing.cpp:2964 │ bitcoin/src/net_processing.cpp:4716
│
// If we have less than MAX_BLOCKS_TO_ANNOUNCE in our │ // If we have less than MAX_BLOCKS_TO_ANNOUNCE in our
// list of block hashes we're relaying, and our peer wants │ // list of block hashes we're relaying, and our peer wants
// headers announcements, then find the first header │ // headers announcements, then find the first header
// not yet known to our peer but would connect, and send. │ // not yet known to our peer but would connect, and send.
// If no header would connect, or if we have too many │ // If no header would connect, or if we have too many
// blocks, or if the peer doesn't want headers, just │ // blocks, or if the peer doesn't want headers, just
// add all to the inv queue. │ // add all to the inv queue.
LOCK(pto->cs_inventory); │ LOCK(peer->m_block_inv_mutex);
std::vector<CBlock> vHeaders; │ std::vector<CBlock> vHeaders;
bool fRevertToInv = ((!state.fPreferHeaders && │ bool fRevertToInv = ((!state.fPreferHeaders &&
(!state.fPreferHeaderAndIDs || pto->vBlockHashesToAnnou │ (!state.fPreferHeaderAndIDs || peer->m_blocks_for_heade
pto->vBlockHashesToAnnounce.size() > MAX_BLOCKS_TO_ANNOU │ peer->m_blocks_for_headers_relay.size() > MAX_BLOCKS_TO
const CBlockIndex *pBestIndex = NULL; // last header queued for delivery │ const CBlockIndex *pBestIndex = nullptr; // last header queued for delivery
ProcessBlockAvailability(pto->id); // ensure pindexBestKnownBlock is up-to-d │ ProcessBlockAvailability(pto->GetId()); // ensure pindexBestKnownBlock is up
│
if (!fRevertToInv) { │ if (!fRevertToInv) {
bool fFoundStartingHeader = false; │ bool fFoundStartingHeader = false;
// Try to find first header that our peer doesn't have, and │ // Try to find first header that our peer doesn't have, and
// then send all headers past that one. If we come across any │ // then send all headers past that one. If we come across any
// headers that aren't on chainActive, give up. │ // headers that aren't on m_chainman.ActiveChain(), give up.
BOOST_FOREACH(const uint256 &hash, pto->vBlockHashesToAnnounce) { │ for (const uint256& hash : peer->m_blocks_for_headers_relay) {
BlockMap::iterator mi = mapBlockIndex.find(hash); │ const CBlockIndex* pindex = m_chainman.m_blockman.LookupBlockIndex(h
assert(mi != mapBlockIndex.end()); │ assert(pindex);
const CBlockIndex *pindex = mi->second; │ if (m_chainman.ActiveChain()[pindex->nHeight] != pindex) {
if (chainActive[pindex->nHeight] != pindex) { │
// Bail out if we reorged away from this block │ // Bail out if we reorged away from this block
fRevertToInv = true; │ fRevertToInv = true;
break; │ break;
} │ }
if (pBestIndex != NULL && pindex->pprev != pBestIndex) { │ if (pBestIndex != nullptr && pindex->pprev != pBestIndex) {
// This means that the list of blocks to announce don't │ // This means that the list of blocks to announce don't
// connect to each other. │ // connect to each other.
// This shouldn't really be possible to hit during │ // This shouldn't really be possible to hit during
// regular operation (because reorgs should take us to │ // regular operation (because reorgs should take us to
// a chain that has some block not on the prior chain, │ // a chain that has some block not on the prior chain,
// which should be caught by the prior check), but one │ // which should be caught by the prior check), but one
// way this could happen is by using invalidateblock / │ // way this could happen is by using invalidateblock /
// reconsiderblock repeatedly on the tip, causing it to │ // reconsiderblock repeatedly on the tip, causing it to
// be added multiple times to vBlockHashesToAnnounce. │ // be added multiple times to m_blocks_for_headers_relay.
// Robustly deal with this rare situation by reverting │ // Robustly deal with this rare situation by reverting
// to an inv. │ // to an inv.
fRevertToInv = true; │ fRevertToInv = true;
break; │ break;
} │ }
pBestIndex = pindex; │ pBestIndex = pindex;
if (fFoundStartingHeader) { │ if (fFoundStartingHeader) {
// add this to the headers message │ // add this to the headers message
vHeaders.push_back(pindex->GetBlockHeader(consensusParams, false │ vHeaders.push_back(pindex->GetBlockHeader());
} else if (PeerHasHeader(&state, pindex)) { │ } else if (PeerHasHeader(&state, pindex)) {
continue; // keep looking for the first new block │ continue; // keep looking for the first new block
} else if (pindex->pprev == NULL || PeerHasHeader(&state, pindex->pp │ } else if (pindex->pprev == nullptr || PeerHasHeader(&state, pindex-
// Peer doesn't have this header but they do have the prior one. │ // Peer doesn't have this header but they do have the prior one.
// Start sending headers. │ // Start sending headers.
fFoundStartingHeader = true; │ fFoundStartingHeader = true;
vHeaders.push_back(pindex->GetBlockHeader(consensusParams, false │ vHeaders.push_back(pindex->GetBlockHeader());
} else { │ } else {
// Peer doesn't have this header or the prior one -- nothing wil │ // Peer doesn't have this header or the prior one -- nothing wil
// connect, so bail out. │ // connect, so bail out.
fRevertToInv = true; │ fRevertToInv = true;
break; │ break;
} │ }
} │ }
} │ }
if (!fRevertToInv && !vHeaders.empty()) { │ if (!fRevertToInv && !vHeaders.empty()) {
if (vHeaders.size() == 1 && state.fPreferHeaderAndIDs) { │ if (vHeaders.size() == 1 && state.fPreferHeaderAndIDs) {
// We only send up to 1 block as header-and-ids, as otherwise │ // We only send up to 1 block as header-and-ids, as otherwise
// probably means we're doing an initial-ish-sync or they're slow │ // probably means we're doing an initial-ish-sync or they're slow
LogPrint("net", "%s sending header-and-ids %s to peer=%d\n", __func_ │ LogPrint(BCLog::NET, "%s sending header-and-ids %s to peer=%d\n", __
vHeaders.front().GetHash().ToString(), pto->id); │ vHeaders.front().GetHash().ToString(), pto->GetId());
│
int nSendFlags = state.fWantsCmpctWitness ? 0 : SERIALIZE_TRANSACTIO │ int nSendFlags = state.fWantsCmpctWitness ? 0 : SERIALIZE_TRANSACTIO
│
bool fGotBlockFromCache = false; │ bool fGotBlockFromCache = false;
{ │ {
LOCK(cs_most_recent_block); │ LOCK(m_most_recent_block_mutex);
if (most_recent_block_hash == pBestIndex->GetBlockHash()) { │ if (m_most_recent_block_hash == pBestIndex->GetBlockHash()) {
if (state.fWantsCmpctWitness) │ if (state.fWantsCmpctWitness || !m_most_recent_compact_block
connman.PushMessage(pto, msgMaker.Make(nSendFlags, NetMs │ m_connman.PushMessage(pto, msgMaker.Make(nSendFlags, Net
else { │ else {
CBlockHeaderAndShortTxIDs cmpctblock(*most_recent_block, │ CBlockHeaderAndShortTxIDs cmpctblock(*m_most_recent_bloc
connman.PushMessage(pto, msgMaker.Make(nSendFlags, NetMs │ m_connman.PushMessage(pto, msgMaker.Make(nSendFlags, Net
} │ }
fGotBlockFromCache = true; │ fGotBlockFromCache = true;
} │ }
} │ }
if (!fGotBlockFromCache) { │ if (!fGotBlockFromCache) {
CBlock block; │ CBlock block;
bool ret = ReadBlockFromDisk(block, pBestIndex, consensusParams, │ bool ret = ReadBlockFromDisk(block, pBestIndex, consensusParams)
assert(ret); │ assert(ret);
CBlockHeaderAndShortTxIDs cmpctblock(block, state.fWantsCmpctWit │ CBlockHeaderAndShortTxIDs cmpctblock(block, state.fWantsCmpctWit
connman.PushMessage(pto, msgMaker.Make(nSendFlags, NetMsgType::C │ m_connman.PushMessage(pto, msgMaker.Make(nSendFlags, NetMsgType:
} │ }
state.pindexBestHeaderSent = pBestIndex; │ state.pindexBestHeaderSent = pBestIndex;
} else if (state.fPreferHeaders) { │ } else if (state.fPreferHeaders) {
if (vHeaders.size() > 1) { │ if (vHeaders.size() > 1) {
LogPrint("net", "%s: %u headers, range (%s, %s), to peer=%d\n", │ LogPrint(BCLog::NET, "%s: %u headers, range (%s, %s), to peer=%d
vHeaders.size(), │ vHeaders.size(),
vHeaders.front().GetHash().ToString(), │ vHeaders.front().GetHash().ToString(),
vHeaders.back().GetHash().ToString(), pto->id); │ vHeaders.back().GetHash().ToString(), pto->GetId());
} else { │ } else {
LogPrint("net", "%s: sending header %s to peer=%d\n", __func__, │ LogPrint(BCLog::NET, "%s: sending header %s to peer=%d\n", __fun
vHeaders.front().GetHash().ToString(), pto->id); │ vHeaders.front().GetHash().ToString(), pto->GetId());
} │ }
connman.PushMessage(pto, msgMaker.Make(NetMsgType::HEADERS, vHeaders │ m_connman.PushMessage(pto, msgMaker.Make(NetMsgType::HEADERS, vHeade
state.pindexBestHeaderSent = pBestIndex; │ state.pindexBestHeaderSent = pBestIndex;
} else │ } else
fRevertToInv = true; │ fRevertToInv = true;
} │ }
if (fRevertToInv) { │ if (fRevertToInv) {
// If falling back to using an inv, just try to inv the tip. │ // If falling back to using an inv, just try to inv the tip.
// The last entry in vBlockHashesToAnnounce was our tip at some point │ // The last entry in m_blocks_for_headers_relay was our tip at some poin
// in the past. │ // in the past.
if (!pto->vBlockHashesToAnnounce.empty()) { │ if (!peer->m_blocks_for_headers_relay.empty()) {
const uint256 &hashToAnnounce = pto->vBlockHashesToAnnounce.back(); │ const uint256& hashToAnnounce = peer->m_blocks_for_headers_relay.bac
BlockMap::iterator mi = mapBlockIndex.find(hashToAnnounce); │ const CBlockIndex* pindex = m_chainman.m_blockman.LookupBlockIndex(h
assert(mi != mapBlockIndex.end()); │ assert(pindex);
const CBlockIndex *pindex = mi->second; │
│
// Warn if we're announcing a block that is not on the main chain. │ // Warn if we're announcing a block that is not on the main chain.
// This should be very rare and could be optimized out. │ // This should be very rare and could be optimized out.
// Just log for now. │ // Just log for now.
if (chainActive[pindex->nHeight] != pindex) { │ if (m_chainman.ActiveChain()[pindex->nHeight] != pindex) {
LogPrint("net", "Announcing block %s not on main chain (tip=%s)\ │ LogPrint(BCLog::NET, "Announcing block %s not on main chain (tip
hashToAnnounce.ToString(), chainActive.Tip()->GetBlockHash() │ hashToAnnounce.ToString(), m_chainman.ActiveChain().Tip()->G
} │ }
│
// If the peer's chain has this block, don't inv it back. │ // If the peer's chain has this block, don't inv it back.
if (!PeerHasHeader(&state, pindex)) { │ if (!PeerHasHeader(&state, pindex)) {
pto->PushInventory(CInv(MSG_BLOCK, hashToAnnounce)); │ peer->m_blocks_for_inv_relay.push_back(hashToAnnounce);
LogPrint("net", "%s: sending inv peer=%d hash=%s\n", __func__, │ LogPrint(BCLog::NET, "%s: sending inv peer=%d hash=%s\n", __func
pto->id, hashToAnnounce.ToString()); │ pto->GetId(), hashToAnnounce.ToString());
} │ }
} │ }
} │ }
pto->vBlockHashesToAnnounce.clear(); │ peer->m_blocks_for_headers_relay.clear();
} │
next prev up bitcoin/src/test/script_tests.cpp:209 │ dogecoin/src/test/script_tests.cpp:226
│
const unsigned char vchKey0[32] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 │ const unsigned char vchKey0[32] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
const unsigned char vchKey1[32] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 │ const unsigned char vchKey1[32] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
const unsigned char vchKey2[32] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 │ const unsigned char vchKey2[32] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
│
struct KeyData │ struct KeyData
{ │ {
CKey key0, key0C, key1, key1C, key2, key2C; │ CKey key0, key0C, key1, key1C, key2, key2C;
CPubKey pubkey0, pubkey0C, pubkey0H; │ CPubKey pubkey0, pubkey0C, pubkey0H;
CPubKey pubkey1, pubkey1C; │ CPubKey pubkey1, pubkey1C;
CPubKey pubkey2, pubkey2C; │ CPubKey pubkey2, pubkey2C;
│
KeyData() │ KeyData()
{ │ {
│
key0.Set(vchKey0, vchKey0 + 32, false); │ key0.Set(vchKey0, vchKey0 + 32, false);
key0C.Set(vchKey0, vchKey0 + 32, true); │ key0C.Set(vchKey0, vchKey0 + 32, true);
pubkey0 = key0.GetPubKey(); │ pubkey0 = key0.GetPubKey();
pubkey0H = key0.GetPubKey(); │ pubkey0H = key0.GetPubKey();
pubkey0C = key0C.GetPubKey(); │ pubkey0C = key0C.GetPubKey();
*const_cast<unsigned char*>(pubkey0H.data()) = 0x06 | (pubkey0H[64] & 1); │ *const_cast<unsigned char*>(&pubkey0H[0]) = 0x06 | (pubkey0H[64] & 1);
│
key1.Set(vchKey1, vchKey1 + 32, false); │ key1.Set(vchKey1, vchKey1 + 32, false);
key1C.Set(vchKey1, vchKey1 + 32, true); │ key1C.Set(vchKey1, vchKey1 + 32, true);
pubkey1 = key1.GetPubKey(); │ pubkey1 = key1.GetPubKey();
pubkey1C = key1C.GetPubKey(); │ pubkey1C = key1C.GetPubKey();
│
key2.Set(vchKey2, vchKey2 + 32, false); │ key2.Set(vchKey2, vchKey2 + 32, false);
key2C.Set(vchKey2, vchKey2 + 32, true); │ key2C.Set(vchKey2, vchKey2 + 32, true);
pubkey2 = key2.GetPubKey(); │ pubkey2 = key2.GetPubKey();
pubkey2C = key2C.GetPubKey(); │ pubkey2C = key2C.GetPubKey();
} │ }
}; │ };
│
enum class WitnessMode { │ enum WitnessMode {
NONE, │ WITNESS_NONE,
PKH, │ WITNESS_PKH,
SH │ WITNESS_SH
}; │ };
│
class TestBuilder │ class TestBuilder
{ │ {
private: │ private:
//! Actually executed script │ //! Actually executed script
CScript script; │ CScript script;
//! The P2SH redeemscript │ //! The P2SH redeemscript
CScript redeemscript; │ CScript redeemscript;
//! The Witness embedded script │ //! The Witness embedded script
CScript witscript; │ CScript witscript;
CScriptWitness scriptWitness; │ CScriptWitness scriptWitness;
CTransactionRef creditTx; │ CTransactionRef creditTx;
CMutableTransaction spendTx; │ CMutableTransaction spendTx;
bool havePush; │ bool havePush;
std::vector<unsigned char> push; │ std::vector<unsigned char> push;
std::string comment; │ std::string comment;
uint32_t flags; │ int flags;
int scriptError; │ int scriptError;
CAmount nValue; │ CAmount nValue;
│
void DoPush() │ void DoPush()
{ │ {
if (havePush) { │ if (havePush) {
spendTx.vin[0].scriptSig << push; │ spendTx.vin[0].scriptSig << push;
havePush = false; │ havePush = false;
} │ }
} │ }
│
void DoPush(const std::vector<unsigned char>& data) │ void DoPush(const std::vector<unsigned char>& data)
{ │ {
DoPush(); │ DoPush();
push = data; │ push = data;
havePush = true; │ havePush = true;
} │ }
│
public: │ public:
TestBuilder(const CScript& script_, const std::string& comment_, uint32_t flags_, bo │ TestBuilder(const CScript& script_, const std::string& comment_, int flags_, bool P2
{ │ {
CScript scriptPubKey = script; │ CScript scriptPubKey = script;
if (wm == WitnessMode::PKH) { │ if (wm == WITNESS_PKH) {
uint160 hash; │ uint160 hash;
CHash160().Write(Span{script}.subspan(1)).Finalize(hash); │ CHash160().Write(&script[1], script.size() - 1).Finalize(hash.begin());
script = CScript() << OP_DUP << OP_HASH160 << ToByteVector(hash) << OP_EQUAL │ script = CScript() << OP_DUP << OP_HASH160 << ToByteVector(hash) << OP_EQUAL
scriptPubKey = CScript() << witnessversion << ToByteVector(hash); │ scriptPubKey = CScript() << witnessversion << ToByteVector(hash);
} else if (wm == WitnessMode::SH) { │ } else if (wm == WITNESS_SH) {
witscript = scriptPubKey; │ witscript = scriptPubKey;
uint256 hash; │ uint256 hash;
CSHA256().Write(witscript.data(), witscript.size()).Finalize(hash.begin()); │ CSHA256().Write(&witscript[0], witscript.size()).Finalize(hash.begin());
scriptPubKey = CScript() << witnessversion << ToByteVector(hash); │ scriptPubKey = CScript() << witnessversion << ToByteVector(hash);
} │ }
if (P2SH) { │ if (P2SH) {
redeemscript = scriptPubKey; │ redeemscript = scriptPubKey;
scriptPubKey = CScript() << OP_HASH160 << ToByteVector(CScriptID(redeemscrip │ scriptPubKey = CScript() << OP_HASH160 << ToByteVector(CScriptID(redeemscrip
} │ }
creditTx = MakeTransactionRef(BuildCreditingTransaction(scriptPubKey, nValue)); │ creditTx = MakeTransactionRef(BuildCreditingTransaction(scriptPubKey, nValue));
spendTx = BuildSpendingTransaction(CScript(), CScriptWitness(), *creditTx); │ spendTx = BuildSpendingTransaction(CScript(), CScriptWitness(), *creditTx);
} │ }
│
TestBuilder& ScriptError(ScriptError_t err) │ TestBuilder& ScriptError(ScriptError_t err)
{ │ {
scriptError = err; │ scriptError = err;
return *this; │ return *this;
} │ }
│
TestBuilder& Opcode(const opcodetype& _op) │ TestBuilder& Add(const CScript& _script)
{ │ {
DoPush(); │ DoPush();
spendTx.vin[0].scriptSig << _op; │ spendTx.vin[0].scriptSig += _script;
return *this; │ return *this;
} │ }
│
TestBuilder& Num(int num) │ TestBuilder& Num(int num)
{ │ {
DoPush(); │ DoPush();
spendTx.vin[0].scriptSig << num; │ spendTx.vin[0].scriptSig << num;
return *this; │ return *this;
} │ }
│
TestBuilder& Push(const std::string& hex) │ TestBuilder& Push(const std::string& hex)
{ │ {
DoPush(ParseHex(hex)); │ DoPush(ParseHex(hex));
return *this; │ return *this;
} │ }
│
TestBuilder& Push(const CScript& _script) │ TestBuilder& Push(const CScript& _script) {
{ │ DoPush(std::vector<unsigned char>(_script.begin(), _script.end()));
DoPush(std::vector<unsigned char>(_script.begin(), _script.end())); │
return *this; │ return *this;
} │ }
│
TestBuilder& PushSig(const CKey& key, int nHashType = SIGHASH_ALL, unsigned int lenR │ TestBuilder& PushSig(const CKey& key, int nHashType = SIGHASH_ALL, unsigned int lenR
{ │ {
uint256 hash = SignatureHash(script, spendTx, 0, nHashType, amount, sigversion); │ uint256 hash = SignatureHash(script, spendTx, 0, nHashType, amount, sigversion);
std::vector<unsigned char> vchSig, r, s; │ std::vector<unsigned char> vchSig, r, s;
uint32_t iter = 0; │ uint32_t iter = 0;
do { │ do {
key.Sign(hash, vchSig, false, iter++); │ key.Sign(hash, vchSig, iter++);
if ((lenS == 33) != (vchSig[5 + vchSig[3]] == 33)) { │ if ((lenS == 33) != (vchSig[5 + vchSig[3]] == 33)) {
NegateSignatureS(vchSig); │ NegateSignatureS(vchSig);
} │ }
r = std::vector<unsigned char>(vchSig.begin() + 4, vchSig.begin() + 4 + vchS │ r = std::vector<unsigned char>(vchSig.begin() + 4, vchSig.begin() + 4 + vchS
s = std::vector<unsigned char>(vchSig.begin() + 6 + vchSig[3], vchSig.begin( │ s = std::vector<unsigned char>(vchSig.begin() + 6 + vchSig[3], vchSig.begin(
} while (lenR != r.size() || lenS != s.size()); │ } while (lenR != r.size() || lenS != s.size());
vchSig.push_back(static_cast<unsigned char>(nHashType)); │ vchSig.push_back(static_cast<unsigned char>(nHashType));
DoPush(vchSig); │ DoPush(vchSig);
return *this; │ return *this;
} │ }
│
TestBuilder& PushWitSig(const CKey& key, CAmount amount = -1, int nHashType = SIGHAS │ TestBuilder& PushWitSig(const CKey& key, CAmount amount = -1, int nHashType = SIGHAS
{ │ {
if (amount == -1) │ if (amount == -1)
amount = nValue; │ amount = nValue;
return PushSig(key, nHashType, lenR, lenS, sigversion, amount).AsWit(); │ return PushSig(key, nHashType, lenR, lenS, sigversion, amount).AsWit();
} │ }
│
TestBuilder& Push(const CPubKey& pubkey) │ TestBuilder& Push(const CPubKey& pubkey)
{ │ {
DoPush(std::vector<unsigned char>(pubkey.begin(), pubkey.end())); │ DoPush(std::vector<unsigned char>(pubkey.begin(), pubkey.end()));
return *this; │ return *this;
} │ }
│
TestBuilder& PushRedeem() │ TestBuilder& PushRedeem()
{ │ {
DoPush(std::vector<unsigned char>(redeemscript.begin(), redeemscript.end())); │ DoPush(std::vector<unsigned char>(redeemscript.begin(), redeemscript.end()));
return *this; │ return *this;
} │ }
│
TestBuilder& PushWitRedeem() │ TestBuilder& PushWitRedeem()
{ │ {
DoPush(std::vector<unsigned char>(witscript.begin(), witscript.end())); │ DoPush(std::vector<unsigned char>(witscript.begin(), witscript.end()));
return AsWit(); │ return AsWit();
} │ }
│
TestBuilder& EditPush(unsigned int pos, const std::string& hexin, const std::string& │ TestBuilder& EditPush(unsigned int pos, const std::string& hexin, const std::string&
{ │ {
assert(havePush); │ assert(havePush);
std::vector<unsigned char> datain = ParseHex(hexin); │ std::vector<unsigned char> datain = ParseHex(hexin);
std::vector<unsigned char> dataout = ParseHex(hexout); │ std::vector<unsigned char> dataout = ParseHex(hexout);
assert(pos + datain.size() <= push.size()); │ assert(pos + datain.size() <= push.size());
BOOST_CHECK_MESSAGE(std::vector<unsigned char>(push.begin() + pos, push.begin() │ BOOST_CHECK_MESSAGE(std::vector<unsigned char>(push.begin() + pos, push.begin()
push.erase(push.begin() + pos, push.begin() + pos + datain.size()); │ push.erase(push.begin() + pos, push.begin() + pos + datain.size());
push.insert(push.begin() + pos, dataout.begin(), dataout.end()); │ push.insert(push.begin() + pos, dataout.begin(), dataout.end());
return *this; │ return *this;
} │ }
│
TestBuilder& DamagePush(unsigned int pos) │ TestBuilder& DamagePush(unsigned int pos)
{ │ {
assert(havePush); │ assert(havePush);
assert(pos < push.size()); │ assert(pos < push.size());
push[pos] ^= 1; │ push[pos] ^= 1;
return *this; │ return *this;
} │ }
│
TestBuilder& Test() │ TestBuilder& Test()
{ │ {
TestBuilder copy = *this; // Make a copy so we can rollback the push. │ TestBuilder copy = *this; // Make a copy so we can rollback the push.
DoPush(); │ DoPush();
DoTest(creditTx->vout[0].scriptPubKey, spendTx.vin[0].scriptSig, scriptWitness, │ DoTest(creditTx->vout[0].scriptPubKey, spendTx.vin[0].scriptSig, scriptWitness,
*this = copy; │ *this = copy;
return *this; │ return *this;
} │ }
│
TestBuilder& AsWit() │ TestBuilder& AsWit()
{ │ {
assert(havePush); │ assert(havePush);
scriptWitness.stack.push_back(push); │ scriptWitness.stack.push_back(push);
havePush = false; │ havePush = false;
return *this; │ return *this;
} │ }
│
UniValue GetJSON() │ UniValue GetJSON()
{ │ {
DoPush(); │ DoPush();
UniValue array(UniValue::VARR); │ UniValue array(UniValue::VARR);
if (!scriptWitness.stack.empty()) { │ if (!scriptWitness.stack.empty()) {
UniValue wit(UniValue::VARR); │ UniValue wit(UniValue::VARR);
for (unsigned i = 0; i < scriptWitness.stack.size(); i++) { │ for (unsigned i = 0; i < scriptWitness.stack.size(); i++) {
wit.push_back(HexStr(scriptWitness.stack[i])); │ wit.push_back(HexStr(scriptWitness.stack[i]));
} │ }
wit.push_back(ValueFromAmount(nValue)); │ wit.push_back(ValueFromAmount(nValue));
array.push_back(wit); │ array.push_back(wit);
} │ }
array.push_back(FormatScript(spendTx.vin[0].scriptSig)); │ array.push_back(FormatScript(spendTx.vin[0].scriptSig));
array.push_back(FormatScript(creditTx->vout[0].scriptPubKey)); │ array.push_back(FormatScript(creditTx->vout[0].scriptPubKey));
array.push_back(FormatScriptFlags(flags)); │ array.push_back(FormatScriptFlags(flags));
array.push_back(FormatScriptError((ScriptError_t)scriptError)); │ array.push_back(FormatScriptError((ScriptError_t)scriptError));
array.push_back(comment); │ array.push_back(comment);
return array; │ return array;
} │ }
│
std::string GetComment() const │ std::string GetComment()
{ │ {
return comment; │ return comment;
│ }
│
│ const CScript& GetScriptPubKey()
│ {
│ return creditTx->vout[0].scriptPubKey;
} │ }
}; │ };
│
std::string JSONPrettyPrint(const UniValue& univalue) │ std::string JSONPrettyPrint(const UniValue& univalue)
{ │ {
std::string ret = univalue.write(4); │ std::string ret = univalue.write(4);
// Workaround for libunivalue pretty printer, which puts a space between commas and │ // Workaround for libunivalue pretty printer, which puts a space between commas and
size_t pos = 0; │ size_t pos = 0;
while ((pos = ret.find(" \n", pos)) != std::string::npos) { │ while ((pos = ret.find(" \n", pos)) != std::string::npos) {
ret.replace(pos, 2, "\n"); │ ret.replace(pos, 2, "\n");
pos++; │ pos++;
} │ }
return ret; │ return ret;
} │ }
} │
next prev up bitcoin/src/rest.cpp:700 │ dogecoin/src/rest.cpp:406
│
if (!CheckWarmup(req)) │ if (!CheckWarmup(req))
return false; │ return false;
std::string param; │ std::string param;
const RESTResponseFormat rf = ParseDataFormat(param, strURIPart); │ const RetFormat rf = ParseDataFormat(param, strURIPart);
│
std::vector<std::string> uriParts; │ std::vector<std::string> uriParts;
if (param.length() > 1) │ if (param.length() > 1)
{ │ {
std::string strUriParams = param.substr(1); │ std::string strUriParams = param.substr(1);
uriParts = SplitString(strUriParams, '/'); │ boost::split(uriParts, strUriParams, boost::is_any_of("/"));
} │ }
│
// throw exception in case of an empty request │ // throw exception in case of a empty request
std::string strRequestMutable = req->ReadBody(); │ std::string strRequestMutable = req->ReadBody();
if (strRequestMutable.length() == 0 && uriParts.size() == 0) │ if (strRequestMutable.length() == 0 && uriParts.size() == 0)
return RESTERR(req, HTTP_BAD_REQUEST, "Error: empty request"); │ return RESTERR(req, HTTP_BAD_REQUEST, "Error: empty request");
│
bool fInputParsed = false; │ bool fInputParsed = false;
bool fCheckMemPool = false; │ bool fCheckMemPool = false;
std::vector<COutPoint> vOutPoints; │ std::vector<COutPoint> vOutPoints;
│
// parse/deserialize input │ // parse/deserialize input
// input-format = output-format, rest/getutxos/bin requires binary input, gives bina │ // input-format = output-format, rest/getutxos/bin requires binary input, gives bina
│
if (uriParts.size() > 0) │ if (uriParts.size() > 0)
{ │ {
│
//inputs is sent over URI scheme (/rest/getutxos/checkmempool/txid1-n/txid2-n/.. │ //inputs is sent over URI scheme (/rest/getutxos/checkmempool/txid1-n/txid2-n/..
if (uriParts[0] == "checkmempool") fCheckMemPool = true; │ if (uriParts.size() > 0 && uriParts[0] == "checkmempool")
│ fCheckMemPool = true;
│
for (size_t i = (fCheckMemPool) ? 1 : 0; i < uriParts.size(); i++) │ for (size_t i = (fCheckMemPool) ? 1 : 0; i < uriParts.size(); i++)
{ │ {
uint256 txid; │ uint256 txid;
int32_t nOutput; │ int32_t nOutput;
std::string strTxid = uriParts[i].substr(0, uriParts[i].find('-')); │ std::string strTxid = uriParts[i].substr(0, uriParts[i].find("-"));
std::string strOutput = uriParts[i].substr(uriParts[i].find('-')+1); │ std::string strOutput = uriParts[i].substr(uriParts[i].find("-")+1);
│
if (!ParseInt32(strOutput, &nOutput) || !IsHex(strTxid)) │ if (!ParseInt32(strOutput, &nOutput) || !IsHex(strTxid))
return RESTERR(req, HTTP_BAD_REQUEST, "Parse error"); │ return RESTERR(req, HTTP_BAD_REQUEST, "Parse error");
│
txid.SetHex(strTxid); │ txid.SetHex(strTxid);
vOutPoints.push_back(COutPoint(txid, (uint32_t)nOutput)); │ vOutPoints.push_back(COutPoint(txid, (uint32_t)nOutput));
} │ }
│
if (vOutPoints.size() > 0) │ if (vOutPoints.size() > 0)
fInputParsed = true; │ fInputParsed = true;
else │ else
return RESTERR(req, HTTP_BAD_REQUEST, "Error: empty request"); │ return RESTERR(req, HTTP_BAD_REQUEST, "Error: empty request");
} │ }
│
switch (rf) { │ switch (rf) {
case RESTResponseFormat::HEX: { │ case RF_HEX: {
// convert hex to bin, continue then with bin part │ // convert hex to bin, continue then with bin part
std::vector<unsigned char> strRequestV = ParseHex(strRequestMutable); │ std::vector<unsigned char> strRequestV = ParseHex(strRequestMutable);
strRequestMutable.assign(strRequestV.begin(), strRequestV.end()); │ strRequestMutable.assign(strRequestV.begin(), strRequestV.end());
[[fallthrough]]; │
} │ }
│ // Falls through
│
case RESTResponseFormat::BINARY: { │ case RF_BINARY: {
try { │ try {
//deserialize only if user sent a request │ //deserialize only if user sent a request
if (strRequestMutable.size() > 0) │ if (strRequestMutable.size() > 0)
{ │ {
if (fInputParsed) //don't allow sending input over URI and HTTP RAW DATA │ if (fInputParsed) //don't allow sending input over URI and HTTP RAW DATA
return RESTERR(req, HTTP_BAD_REQUEST, "Combination of URI scheme inp │ return RESTERR(req, HTTP_BAD_REQUEST, "Combination of URI scheme inp
│
CDataStream oss(SER_NETWORK, PROTOCOL_VERSION); │ CDataStream oss(SER_NETWORK, PROTOCOL_VERSION);
oss << strRequestMutable; │ oss << strRequestMutable;
oss >> fCheckMemPool; │ oss >> fCheckMemPool;
oss >> vOutPoints; │ oss >> vOutPoints;
} │ }
} catch (const std::ios_base::failure&) { │ } catch (const std::ios_base::failure& e) {
// abort in case of unreadable binary data │ // abort in case of unreadable binary data
return RESTERR(req, HTTP_BAD_REQUEST, "Parse error"); │ return RESTERR(req, HTTP_BAD_REQUEST, "Parse error");
} │ }
break; │ break;
} │ }
│
case RESTResponseFormat::JSON: { │ case RF_JSON: {
if (!fInputParsed) │ if (!fInputParsed)
return RESTERR(req, HTTP_BAD_REQUEST, "Error: empty request"); │ return RESTERR(req, HTTP_BAD_REQUEST, "Error: empty request");
break; │ break;
} │ }
default: { │ default: {
return RESTERR(req, HTTP_NOT_FOUND, "output format not found (available: " + Ava │ return RESTERR(req, HTTP_NOT_FOUND, "output format not found (available: " + Ava
} │ }
} │ }
│
// limit max outpoints │ // limit max outpoints
if (vOutPoints.size() > MAX_GETUTXOS_OUTPOINTS) │ if (vOutPoints.size() > MAX_GETUTXOS_OUTPOINTS)
return RESTERR(req, HTTP_BAD_REQUEST, strprintf("Error: max outpoints exceeded ( │ return RESTERR(req, HTTP_BAD_REQUEST, strprintf("Error: max outpoints exceeded (
│
// check spentness and form a bitmap (as well as a JSON capable human-readable strin │ // check spentness and form a bitmap (as well as a JSON capable human-readable strin
std::vector<unsigned char> bitmap; │ std::vector<unsigned char> bitmap;
std::vector<CCoin> outs; │ std::vector<CCoin> outs;
std::string bitmapStringRepresentation; │ std::string bitmapStringRepresentation;
std::vector<bool> hits; │ std::vector<bool> hits;
bitmap.resize((vOutPoints.size() + 7) / 8); │ bitmap.resize((vOutPoints.size() + 7) / 8);
ChainstateManager* maybe_chainman = GetChainman(context, req); │
if (!maybe_chainman) return false; │
ChainstateManager& chainman = *maybe_chainman; │
{ │ {
auto process_utxos = [&vOutPoints, &outs, &hits](const CCoinsView& view, const C │ LOCK2(cs_main, mempool.cs);
for (const COutPoint& vOutPoint : vOutPoints) { │
Coin coin; │
bool hit = !mempool.isSpent(vOutPoint) && view.GetCoin(vOutPoint, coin); │
hits.push_back(hit); │
if (hit) outs.emplace_back(std::move(coin)); │
} │
}; │
│
if (fCheckMemPool) { │ CCoinsView viewDummy;
const CTxMemPool* mempool = GetMemPool(context, req); │ CCoinsViewCache view(&viewDummy);
if (!mempool) return false; │
// use db+mempool as cache backend in case user likes to query mempool │ CCoinsViewCache& viewChain = *pcoinsTip;
LOCK2(cs_main, mempool->cs); │ CCoinsViewMemPool viewMempool(&viewChain, mempool);
CCoinsViewCache& viewChain = chainman.ActiveChainstate().CoinsTip(); │
CCoinsViewMemPool viewMempool(&viewChain, *mempool); │
process_utxos(viewMempool, *mempool); │
} else { │
LOCK(cs_main); // no need to lock mempool! │
process_utxos(chainman.ActiveChainstate().CoinsTip(), CTxMemPool()); │
} │
│
for (size_t i = 0; i < hits.size(); ++i) { │ if (fCheckMemPool)
const bool hit = hits[i]; │ view.SetBackend(viewMempool); // switch cache backend to db+mempool in case
│
│ for (size_t i = 0; i < vOutPoints.size(); i++) {
│ CCoins coins;
│ uint256 hash = vOutPoints[i].hash;
│ bool hit = false;
│ if (view.GetCoins(hash, coins)) {
│ mempool.pruneSpent(hash, coins);
│ if (coins.IsAvailable(vOutPoints[i].n)) {
│ hit = true;
│ // Safe to index into vout here because IsAvailable checked if it's
│ // n is valid but points to an already spent output (IsNull).
│ CCoin coin;
│ coin.nTxVer = coins.nVersion;
│ coin.nHeight = coins.nHeight;
│ coin.out = coins.vout.at(vOutPoints[i].n);
│ assert(!coin.out.IsNull());
│ outs.push_back(coin);
│ }
│ }
│
│ hits.push_back(hit);
bitmapStringRepresentation.append(hit ? "1" : "0"); // form a binary string │ bitmapStringRepresentation.append(hit ? "1" : "0"); // form a binary string
bitmap[i / 8] |= ((uint8_t)hit) << (i % 8); │ bitmap[i / 8] |= ((uint8_t)hit) << (i % 8);
} │ }
} │ }
│
switch (rf) { │ switch (rf) {
case RESTResponseFormat::BINARY: { │ case RF_BINARY: {
// serialize data │ // serialize data
// use exact same output as mentioned in Bip64 │ // use exact same output as mentioned in Bip64
CDataStream ssGetUTXOResponse(SER_NETWORK, PROTOCOL_VERSION); │ CDataStream ssGetUTXOResponse(SER_NETWORK, PROTOCOL_VERSION);
ssGetUTXOResponse << chainman.ActiveChain().Height() << chainman.ActiveChain().T │ ssGetUTXOResponse << chainActive.Height() << chainActive.Tip()->GetBlockHash() <
std::string ssGetUTXOResponseString = ssGetUTXOResponse.str(); │ std::string ssGetUTXOResponseString = ssGetUTXOResponse.str();
│
req->WriteHeader("Content-Type", "application/octet-stream"); │ req->WriteHeader("Content-Type", "application/octet-stream");
req->WriteReply(HTTP_OK, ssGetUTXOResponseString); │ req->WriteReply(HTTP_OK, ssGetUTXOResponseString);
return true; │ return true;
} │ }
│
case RESTResponseFormat::HEX: { │ case RF_HEX: {
CDataStream ssGetUTXOResponse(SER_NETWORK, PROTOCOL_VERSION); │ CDataStream ssGetUTXOResponse(SER_NETWORK, PROTOCOL_VERSION);
ssGetUTXOResponse << chainman.ActiveChain().Height() << chainman.ActiveChain().T │ ssGetUTXOResponse << chainActive.Height() << chainActive.Tip()->GetBlockHash() <
std::string strHex = HexStr(ssGetUTXOResponse) + "\n"; │ std::string strHex = HexStr(ssGetUTXOResponse.begin(), ssGetUTXOResponse.end())
│
req->WriteHeader("Content-Type", "text/plain"); │ req->WriteHeader("Content-Type", "text/plain");
req->WriteReply(HTTP_OK, strHex); │ req->WriteReply(HTTP_OK, strHex);
return true; │ return true;
} │ }
│
case RESTResponseFormat::JSON: { │ case RF_JSON: {
UniValue objGetUTXOResponse(UniValue::VOBJ); │ UniValue objGetUTXOResponse(UniValue::VOBJ);
│
// pack in some essentials │ // pack in some essentials
// use more or less the same output as mentioned in Bip64 │ // use more or less the same output as mentioned in Bip64
objGetUTXOResponse.pushKV("chainHeight", chainman.ActiveChain().Height()); │ objGetUTXOResponse.pushKV("chainHeight", chainActive.Height());
objGetUTXOResponse.pushKV("chaintipHash", chainman.ActiveChain().Tip()->GetBlock │ objGetUTXOResponse.pushKV("chaintipHash", chainActive.Tip()->GetBlockHash().GetH
objGetUTXOResponse.pushKV("bitmap", bitmapStringRepresentation); │ objGetUTXOResponse.pushKV("bitmap", bitmapStringRepresentation);
│
UniValue utxos(UniValue::VARR); │ UniValue utxos(UniValue::VARR);
for (const CCoin& coin : outs) { │ BOOST_FOREACH (const CCoin& coin, outs) {
UniValue utxo(UniValue::VOBJ); │ UniValue utxo(UniValue::VOBJ);
│ utxo.pushKV("txvers", (int32_t)coin.nTxVer);
utxo.pushKV("height", (int32_t)coin.nHeight); │ utxo.pushKV("height", (int32_t)coin.nHeight);
utxo.pushKV("value", ValueFromAmount(coin.out.nValue)); │ utxo.pushKV("value", ValueFromAmount(coin.out.nValue));
│
// include the script in a json output │ // include the script in a json output
UniValue o(UniValue::VOBJ); │ UniValue o(UniValue::VOBJ);
ScriptToUniv(coin.out.scriptPubKey, /*out=*/o, /*include_hex=*/true, /*inclu │ ScriptPubKeyToJSON(coin.out.scriptPubKey, o, true);
utxo.pushKV("scriptPubKey", o); │ utxo.pushKV("scriptPubKey", o);
utxos.push_back(utxo); │ utxos.push_back(utxo);
} │ }
objGetUTXOResponse.pushKV("utxos", utxos); │ objGetUTXOResponse.pushKV("utxos", utxos);
│
// return json string │ // return json string
std::string strJSON = objGetUTXOResponse.write() + "\n"; │ std::string strJSON = objGetUTXOResponse.write() + "\n";
req->WriteHeader("Content-Type", "application/json"); │ req->WriteHeader("Content-Type", "application/json");
req->WriteReply(HTTP_OK, strJSON); │ req->WriteReply(HTTP_OK, strJSON);
return true; │ return true;
} │ }
default: { │ default: {
return RESTERR(req, HTTP_NOT_FOUND, "output format not found (available: " + Ava │ return RESTERR(req, HTTP_NOT_FOUND, "output format not found (available: " + Ava
} │ }
} │ }
│
│ // not reached
│ return true; // continue to process further HTTP reqs on this cxn
} │
next prev up bitcoin/src/crypto/sha1.cpp:13 │ dogecoin/src/crypto/sha1.cpp:19
│
/// Internal SHA-1 implementation. │ /// Internal SHA-1 implementation.
namespace sha1 │ namespace sha1
{ │ {
│
│ #ifndef USE_AVX2
/** One round of SHA-1. */ │ /** One round of SHA-1. */
void inline Round(uint32_t a, uint32_t& b, uint32_t c, uint32_t d, uint32_t& e, uint32_t │ void inline Round(uint32_t a, uint32_t& b, uint32_t c, uint32_t d, uint32_t& e, uint32_t
{ │ {
e += ((a << 5) | (a >> 27)) + f + k + w; │ e += ((a << 5) | (a >> 27)) + f + k + w;
b = (b << 30) | (b >> 2); │ b = (b << 30) | (b >> 2);
} │ }
│
uint32_t inline f1(uint32_t b, uint32_t c, uint32_t d) { return d ^ (b & (c ^ d)); } │ uint32_t inline f1(uint32_t b, uint32_t c, uint32_t d) { return d ^ (b & (c ^ d)); }
uint32_t inline f2(uint32_t b, uint32_t c, uint32_t d) { return b ^ c ^ d; } │ uint32_t inline f2(uint32_t b, uint32_t c, uint32_t d) { return b ^ c ^ d; }
uint32_t inline f3(uint32_t b, uint32_t c, uint32_t d) { return (b & c) | (d & (b | c)); │ uint32_t inline f3(uint32_t b, uint32_t c, uint32_t d) { return (b & c) | (d & (b | c));
│
uint32_t inline left(uint32_t x) { return (x << 1) | (x >> 31); } │ uint32_t inline left(uint32_t x) { return (x << 1) | (x >> 31); }
│ #endif
│
/** Initialize SHA-1 state. */ │ /** Initialize SHA-1 state. */
void inline Initialize(uint32_t* s) │ void inline Initialize(uint32_t* s)
{ │ {
s[0] = 0x67452301ul; │ s[0] = 0x67452301ul;
s[1] = 0xEFCDAB89ul; │ s[1] = 0xEFCDAB89ul;
s[2] = 0x98BADCFEul; │ s[2] = 0x98BADCFEul;
s[3] = 0x10325476ul; │ s[3] = 0x10325476ul;
s[4] = 0xC3D2E1F0ul; │ s[4] = 0xC3D2E1F0ul;
} │ }
│
const uint32_t k1 = 0x5A827999ul; │ const uint32_t k1 = 0x5A827999ul;
const uint32_t k2 = 0x6ED9EBA1ul; │ const uint32_t k2 = 0x6ED9EBA1ul;
const uint32_t k3 = 0x8F1BBCDCul; │ const uint32_t k3 = 0x8F1BBCDCul;
const uint32_t k4 = 0xCA62C1D6ul; │ const uint32_t k4 = 0xCA62C1D6ul;
│
/** Perform a SHA-1 transformation, processing a 64-byte chunk. */ │ /** Perform a SHA-1 transformation, processing a 64-byte chunk. */
void Transform(uint32_t* s, const unsigned char* chunk) │ void Transform(uint32_t* s, const unsigned char* chunk)
{ │ {
│ #ifdef USE_AVX2
│ // Perform SHA1 one block (Intel AVX2)
│ sha1_one_block_avx2(chunk, s);
│ #else
│ // Perform SHA one block (legacy)
│
uint32_t a = s[0], b = s[1], c = s[2], d = s[3], e = s[4]; │ uint32_t a = s[0], b = s[1], c = s[2], d = s[3], e = s[4];
uint32_t w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15; │ uint32_t w0, w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13, w14, w15;
│
Round(a, b, c, d, e, f1(b, c, d), k1, w0 = ReadBE32(chunk + 0)); │ Round(a, b, c, d, e, f1(b, c, d), k1, w0 = ReadBE32(chunk + 0));
Round(e, a, b, c, d, f1(a, b, c), k1, w1 = ReadBE32(chunk + 4)); │ Round(e, a, b, c, d, f1(a, b, c), k1, w1 = ReadBE32(chunk + 4));
Round(d, e, a, b, c, f1(e, a, b), k1, w2 = ReadBE32(chunk + 8)); │ Round(d, e, a, b, c, f1(e, a, b), k1, w2 = ReadBE32(chunk + 8));
Round(c, d, e, a, b, f1(d, e, a), k1, w3 = ReadBE32(chunk + 12)); │ Round(c, d, e, a, b, f1(d, e, a), k1, w3 = ReadBE32(chunk + 12));
Round(b, c, d, e, a, f1(c, d, e), k1, w4 = ReadBE32(chunk + 16)); │ Round(b, c, d, e, a, f1(c, d, e), k1, w4 = ReadBE32(chunk + 16));
Round(a, b, c, d, e, f1(b, c, d), k1, w5 = ReadBE32(chunk + 20)); │ Round(a, b, c, d, e, f1(b, c, d), k1, w5 = ReadBE32(chunk + 20));
Round(e, a, b, c, d, f1(a, b, c), k1, w6 = ReadBE32(chunk + 24)); │ Round(e, a, b, c, d, f1(a, b, c), k1, w6 = ReadBE32(chunk + 24));
Round(d, e, a, b, c, f1(e, a, b), k1, w7 = ReadBE32(chunk + 28)); │ Round(d, e, a, b, c, f1(e, a, b), k1, w7 = ReadBE32(chunk + 28));
Round(c, d, e, a, b, f1(d, e, a), k1, w8 = ReadBE32(chunk + 32)); │ Round(c, d, e, a, b, f1(d, e, a), k1, w8 = ReadBE32(chunk + 32));
Round(b, c, d, e, a, f1(c, d, e), k1, w9 = ReadBE32(chunk + 36)); │ Round(b, c, d, e, a, f1(c, d, e), k1, w9 = ReadBE32(chunk + 36));
Round(a, b, c, d, e, f1(b, c, d), k1, w10 = ReadBE32(chunk + 40)); │ Round(a, b, c, d, e, f1(b, c, d), k1, w10 = ReadBE32(chunk + 40));
Round(e, a, b, c, d, f1(a, b, c), k1, w11 = ReadBE32(chunk + 44)); │ Round(e, a, b, c, d, f1(a, b, c), k1, w11 = ReadBE32(chunk + 44));
Round(d, e, a, b, c, f1(e, a, b), k1, w12 = ReadBE32(chunk + 48)); │ Round(d, e, a, b, c, f1(e, a, b), k1, w12 = ReadBE32(chunk + 48));
Round(c, d, e, a, b, f1(d, e, a), k1, w13 = ReadBE32(chunk + 52)); │ Round(c, d, e, a, b, f1(d, e, a), k1, w13 = ReadBE32(chunk + 52));
Round(b, c, d, e, a, f1(c, d, e), k1, w14 = ReadBE32(chunk + 56)); │ Round(b, c, d, e, a, f1(c, d, e), k1, w14 = ReadBE32(chunk + 56));
Round(a, b, c, d, e, f1(b, c, d), k1, w15 = ReadBE32(chunk + 60)); │ Round(a, b, c, d, e, f1(b, c, d), k1, w15 = ReadBE32(chunk + 60));
│
Round(e, a, b, c, d, f1(a, b, c), k1, w0 = left(w0 ^ w13 ^ w8 ^ w2)); │ Round(e, a, b, c, d, f1(a, b, c), k1, w0 = left(w0 ^ w13 ^ w8 ^ w2));
Round(d, e, a, b, c, f1(e, a, b), k1, w1 = left(w1 ^ w14 ^ w9 ^ w3)); │ Round(d, e, a, b, c, f1(e, a, b), k1, w1 = left(w1 ^ w14 ^ w9 ^ w3));
Round(c, d, e, a, b, f1(d, e, a), k1, w2 = left(w2 ^ w15 ^ w10 ^ w4)); │ Round(c, d, e, a, b, f1(d, e, a), k1, w2 = left(w2 ^ w15 ^ w10 ^ w4));
Round(b, c, d, e, a, f1(c, d, e), k1, w3 = left(w3 ^ w0 ^ w11 ^ w5)); │ Round(b, c, d, e, a, f1(c, d, e), k1, w3 = left(w3 ^ w0 ^ w11 ^ w5));
Round(a, b, c, d, e, f2(b, c, d), k2, w4 = left(w4 ^ w1 ^ w12 ^ w6)); │ Round(a, b, c, d, e, f2(b, c, d), k2, w4 = left(w4 ^ w1 ^ w12 ^ w6));
Round(e, a, b, c, d, f2(a, b, c), k2, w5 = left(w5 ^ w2 ^ w13 ^ w7)); │ Round(e, a, b, c, d, f2(a, b, c), k2, w5 = left(w5 ^ w2 ^ w13 ^ w7));
Round(d, e, a, b, c, f2(e, a, b), k2, w6 = left(w6 ^ w3 ^ w14 ^ w8)); │ Round(d, e, a, b, c, f2(e, a, b), k2, w6 = left(w6 ^ w3 ^ w14 ^ w8));
Round(c, d, e, a, b, f2(d, e, a), k2, w7 = left(w7 ^ w4 ^ w15 ^ w9)); │ Round(c, d, e, a, b, f2(d, e, a), k2, w7 = left(w7 ^ w4 ^ w15 ^ w9));
Round(b, c, d, e, a, f2(c, d, e), k2, w8 = left(w8 ^ w5 ^ w0 ^ w10)); │ Round(b, c, d, e, a, f2(c, d, e), k2, w8 = left(w8 ^ w5 ^ w0 ^ w10));
Round(a, b, c, d, e, f2(b, c, d), k2, w9 = left(w9 ^ w6 ^ w1 ^ w11)); │ Round(a, b, c, d, e, f2(b, c, d), k2, w9 = left(w9 ^ w6 ^ w1 ^ w11));
Round(e, a, b, c, d, f2(a, b, c), k2, w10 = left(w10 ^ w7 ^ w2 ^ w12)); │ Round(e, a, b, c, d, f2(a, b, c), k2, w10 = left(w10 ^ w7 ^ w2 ^ w12));
Round(d, e, a, b, c, f2(e, a, b), k2, w11 = left(w11 ^ w8 ^ w3 ^ w13)); │ Round(d, e, a, b, c, f2(e, a, b), k2, w11 = left(w11 ^ w8 ^ w3 ^ w13));
Round(c, d, e, a, b, f2(d, e, a), k2, w12 = left(w12 ^ w9 ^ w4 ^ w14)); │ Round(c, d, e, a, b, f2(d, e, a), k2, w12 = left(w12 ^ w9 ^ w4 ^ w14));
Round(b, c, d, e, a, f2(c, d, e), k2, w13 = left(w13 ^ w10 ^ w5 ^ w15)); │ Round(b, c, d, e, a, f2(c, d, e), k2, w13 = left(w13 ^ w10 ^ w5 ^ w15));
Round(a, b, c, d, e, f2(b, c, d), k2, w14 = left(w14 ^ w11 ^ w6 ^ w0)); │ Round(a, b, c, d, e, f2(b, c, d), k2, w14 = left(w14 ^ w11 ^ w6 ^ w0));
Round(e, a, b, c, d, f2(a, b, c), k2, w15 = left(w15 ^ w12 ^ w7 ^ w1)); │ Round(e, a, b, c, d, f2(a, b, c), k2, w15 = left(w15 ^ w12 ^ w7 ^ w1));
│
Round(d, e, a, b, c, f2(e, a, b), k2, w0 = left(w0 ^ w13 ^ w8 ^ w2)); │ Round(d, e, a, b, c, f2(e, a, b), k2, w0 = left(w0 ^ w13 ^ w8 ^ w2));
Round(c, d, e, a, b, f2(d, e, a), k2, w1 = left(w1 ^ w14 ^ w9 ^ w3)); │ Round(c, d, e, a, b, f2(d, e, a), k2, w1 = left(w1 ^ w14 ^ w9 ^ w3));
Round(b, c, d, e, a, f2(c, d, e), k2, w2 = left(w2 ^ w15 ^ w10 ^ w4)); │ Round(b, c, d, e, a, f2(c, d, e), k2, w2 = left(w2 ^ w15 ^ w10 ^ w4));
Round(a, b, c, d, e, f2(b, c, d), k2, w3 = left(w3 ^ w0 ^ w11 ^ w5)); │ Round(a, b, c, d, e, f2(b, c, d), k2, w3 = left(w3 ^ w0 ^ w11 ^ w5));
Round(e, a, b, c, d, f2(a, b, c), k2, w4 = left(w4 ^ w1 ^ w12 ^ w6)); │ Round(e, a, b, c, d, f2(a, b, c), k2, w4 = left(w4 ^ w1 ^ w12 ^ w6));
Round(d, e, a, b, c, f2(e, a, b), k2, w5 = left(w5 ^ w2 ^ w13 ^ w7)); │ Round(d, e, a, b, c, f2(e, a, b), k2, w5 = left(w5 ^ w2 ^ w13 ^ w7));
Round(c, d, e, a, b, f2(d, e, a), k2, w6 = left(w6 ^ w3 ^ w14 ^ w8)); │ Round(c, d, e, a, b, f2(d, e, a), k2, w6 = left(w6 ^ w3 ^ w14 ^ w8));
Round(b, c, d, e, a, f2(c, d, e), k2, w7 = left(w7 ^ w4 ^ w15 ^ w9)); │ Round(b, c, d, e, a, f2(c, d, e), k2, w7 = left(w7 ^ w4 ^ w15 ^ w9));
Round(a, b, c, d, e, f3(b, c, d), k3, w8 = left(w8 ^ w5 ^ w0 ^ w10)); │ Round(a, b, c, d, e, f3(b, c, d), k3, w8 = left(w8 ^ w5 ^ w0 ^ w10));
Round(e, a, b, c, d, f3(a, b, c), k3, w9 = left(w9 ^ w6 ^ w1 ^ w11)); │ Round(e, a, b, c, d, f3(a, b, c), k3, w9 = left(w9 ^ w6 ^ w1 ^ w11));
Round(d, e, a, b, c, f3(e, a, b), k3, w10 = left(w10 ^ w7 ^ w2 ^ w12)); │ Round(d, e, a, b, c, f3(e, a, b), k3, w10 = left(w10 ^ w7 ^ w2 ^ w12));
Round(c, d, e, a, b, f3(d, e, a), k3, w11 = left(w11 ^ w8 ^ w3 ^ w13)); │ Round(c, d, e, a, b, f3(d, e, a), k3, w11 = left(w11 ^ w8 ^ w3 ^ w13));
Round(b, c, d, e, a, f3(c, d, e), k3, w12 = left(w12 ^ w9 ^ w4 ^ w14)); │ Round(b, c, d, e, a, f3(c, d, e), k3, w12 = left(w12 ^ w9 ^ w4 ^ w14));
Round(a, b, c, d, e, f3(b, c, d), k3, w13 = left(w13 ^ w10 ^ w5 ^ w15)); │ Round(a, b, c, d, e, f3(b, c, d), k3, w13 = left(w13 ^ w10 ^ w5 ^ w15));
Round(e, a, b, c, d, f3(a, b, c), k3, w14 = left(w14 ^ w11 ^ w6 ^ w0)); │ Round(e, a, b, c, d, f3(a, b, c), k3, w14 = left(w14 ^ w11 ^ w6 ^ w0));
Round(d, e, a, b, c, f3(e, a, b), k3, w15 = left(w15 ^ w12 ^ w7 ^ w1)); │ Round(d, e, a, b, c, f3(e, a, b), k3, w15 = left(w15 ^ w12 ^ w7 ^ w1));
│
Round(c, d, e, a, b, f3(d, e, a), k3, w0 = left(w0 ^ w13 ^ w8 ^ w2)); │ Round(c, d, e, a, b, f3(d, e, a), k3, w0 = left(w0 ^ w13 ^ w8 ^ w2));
Round(b, c, d, e, a, f3(c, d, e), k3, w1 = left(w1 ^ w14 ^ w9 ^ w3)); │ Round(b, c, d, e, a, f3(c, d, e), k3, w1 = left(w1 ^ w14 ^ w9 ^ w3));
Round(a, b, c, d, e, f3(b, c, d), k3, w2 = left(w2 ^ w15 ^ w10 ^ w4)); │ Round(a, b, c, d, e, f3(b, c, d), k3, w2 = left(w2 ^ w15 ^ w10 ^ w4));
Round(e, a, b, c, d, f3(a, b, c), k3, w3 = left(w3 ^ w0 ^ w11 ^ w5)); │ Round(e, a, b, c, d, f3(a, b, c), k3, w3 = left(w3 ^ w0 ^ w11 ^ w5));
Round(d, e, a, b, c, f3(e, a, b), k3, w4 = left(w4 ^ w1 ^ w12 ^ w6)); │ Round(d, e, a, b, c, f3(e, a, b), k3, w4 = left(w4 ^ w1 ^ w12 ^ w6));
Round(c, d, e, a, b, f3(d, e, a), k3, w5 = left(w5 ^ w2 ^ w13 ^ w7)); │ Round(c, d, e, a, b, f3(d, e, a), k3, w5 = left(w5 ^ w2 ^ w13 ^ w7));
Round(b, c, d, e, a, f3(c, d, e), k3, w6 = left(w6 ^ w3 ^ w14 ^ w8)); │ Round(b, c, d, e, a, f3(c, d, e), k3, w6 = left(w6 ^ w3 ^ w14 ^ w8));
Round(a, b, c, d, e, f3(b, c, d), k3, w7 = left(w7 ^ w4 ^ w15 ^ w9)); │ Round(a, b, c, d, e, f3(b, c, d), k3, w7 = left(w7 ^ w4 ^ w15 ^ w9));
Round(e, a, b, c, d, f3(a, b, c), k3, w8 = left(w8 ^ w5 ^ w0 ^ w10)); │ Round(e, a, b, c, d, f3(a, b, c), k3, w8 = left(w8 ^ w5 ^ w0 ^ w10));
Round(d, e, a, b, c, f3(e, a, b), k3, w9 = left(w9 ^ w6 ^ w1 ^ w11)); │ Round(d, e, a, b, c, f3(e, a, b), k3, w9 = left(w9 ^ w6 ^ w1 ^ w11));
Round(c, d, e, a, b, f3(d, e, a), k3, w10 = left(w10 ^ w7 ^ w2 ^ w12)); │ Round(c, d, e, a, b, f3(d, e, a), k3, w10 = left(w10 ^ w7 ^ w2 ^ w12));
Round(b, c, d, e, a, f3(c, d, e), k3, w11 = left(w11 ^ w8 ^ w3 ^ w13)); │ Round(b, c, d, e, a, f3(c, d, e), k3, w11 = left(w11 ^ w8 ^ w3 ^ w13));
Round(a, b, c, d, e, f2(b, c, d), k4, w12 = left(w12 ^ w9 ^ w4 ^ w14)); │ Round(a, b, c, d, e, f2(b, c, d), k4, w12 = left(w12 ^ w9 ^ w4 ^ w14));
Round(e, a, b, c, d, f2(a, b, c), k4, w13 = left(w13 ^ w10 ^ w5 ^ w15)); │ Round(e, a, b, c, d, f2(a, b, c), k4, w13 = left(w13 ^ w10 ^ w5 ^ w15));
Round(d, e, a, b, c, f2(e, a, b), k4, w14 = left(w14 ^ w11 ^ w6 ^ w0)); │ Round(d, e, a, b, c, f2(e, a, b), k4, w14 = left(w14 ^ w11 ^ w6 ^ w0));
Round(c, d, e, a, b, f2(d, e, a), k4, w15 = left(w15 ^ w12 ^ w7 ^ w1)); │ Round(c, d, e, a, b, f2(d, e, a), k4, w15 = left(w15 ^ w12 ^ w7 ^ w1));
│
Round(b, c, d, e, a, f2(c, d, e), k4, w0 = left(w0 ^ w13 ^ w8 ^ w2)); │ Round(b, c, d, e, a, f2(c, d, e), k4, w0 = left(w0 ^ w13 ^ w8 ^ w2));
Round(a, b, c, d, e, f2(b, c, d), k4, w1 = left(w1 ^ w14 ^ w9 ^ w3)); │ Round(a, b, c, d, e, f2(b, c, d), k4, w1 = left(w1 ^ w14 ^ w9 ^ w3));
Round(e, a, b, c, d, f2(a, b, c), k4, w2 = left(w2 ^ w15 ^ w10 ^ w4)); │ Round(e, a, b, c, d, f2(a, b, c), k4, w2 = left(w2 ^ w15 ^ w10 ^ w4));
Round(d, e, a, b, c, f2(e, a, b), k4, w3 = left(w3 ^ w0 ^ w11 ^ w5)); │ Round(d, e, a, b, c, f2(e, a, b), k4, w3 = left(w3 ^ w0 ^ w11 ^ w5));
Round(c, d, e, a, b, f2(d, e, a), k4, w4 = left(w4 ^ w1 ^ w12 ^ w6)); │ Round(c, d, e, a, b, f2(d, e, a), k4, w4 = left(w4 ^ w1 ^ w12 ^ w6));
Round(b, c, d, e, a, f2(c, d, e), k4, w5 = left(w5 ^ w2 ^ w13 ^ w7)); │ Round(b, c, d, e, a, f2(c, d, e), k4, w5 = left(w5 ^ w2 ^ w13 ^ w7));
Round(a, b, c, d, e, f2(b, c, d), k4, w6 = left(w6 ^ w3 ^ w14 ^ w8)); │ Round(a, b, c, d, e, f2(b, c, d), k4, w6 = left(w6 ^ w3 ^ w14 ^ w8));
Round(e, a, b, c, d, f2(a, b, c), k4, w7 = left(w7 ^ w4 ^ w15 ^ w9)); │ Round(e, a, b, c, d, f2(a, b, c), k4, w7 = left(w7 ^ w4 ^ w15 ^ w9));
Round(d, e, a, b, c, f2(e, a, b), k4, w8 = left(w8 ^ w5 ^ w0 ^ w10)); │ Round(d, e, a, b, c, f2(e, a, b), k4, w8 = left(w8 ^ w5 ^ w0 ^ w10));
Round(c, d, e, a, b, f2(d, e, a), k4, w9 = left(w9 ^ w6 ^ w1 ^ w11)); │ Round(c, d, e, a, b, f2(d, e, a), k4, w9 = left(w9 ^ w6 ^ w1 ^ w11));
Round(b, c, d, e, a, f2(c, d, e), k4, w10 = left(w10 ^ w7 ^ w2 ^ w12)); │ Round(b, c, d, e, a, f2(c, d, e), k4, w10 = left(w10 ^ w7 ^ w2 ^ w12));
Round(a, b, c, d, e, f2(b, c, d), k4, w11 = left(w11 ^ w8 ^ w3 ^ w13)); │ Round(a, b, c, d, e, f2(b, c, d), k4, w11 = left(w11 ^ w8 ^ w3 ^ w13));
Round(e, a, b, c, d, f2(a, b, c), k4, w12 = left(w12 ^ w9 ^ w4 ^ w14)); │ Round(e, a, b, c, d, f2(a, b, c), k4, w12 = left(w12 ^ w9 ^ w4 ^ w14));
Round(d, e, a, b, c, f2(e, a, b), k4, left(w13 ^ w10 ^ w5 ^ w15)); │ Round(d, e, a, b, c, f2(e, a, b), k4, left(w13 ^ w10 ^ w5 ^ w15));
Round(c, d, e, a, b, f2(d, e, a), k4, left(w14 ^ w11 ^ w6 ^ w0)); │ Round(c, d, e, a, b, f2(d, e, a), k4, left(w14 ^ w11 ^ w6 ^ w0));
Round(b, c, d, e, a, f2(c, d, e), k4, left(w15 ^ w12 ^ w7 ^ w1)); │ Round(b, c, d, e, a, f2(c, d, e), k4, left(w15 ^ w12 ^ w7 ^ w1));
│
s[0] += a; │ s[0] += a;
s[1] += b; │ s[1] += b;
s[2] += c; │ s[2] += c;
s[3] += d; │ s[3] += d;
s[4] += e; │ s[4] += e;
│
│ #endif
│
} │ }
│
} // namespace sha1 │ } // namespace sha1
│
} │
next prev up dogecoin/src/test/bloom_tests.cpp:374 │ bitcoin/src/test/bloom_tests.cpp:353
│
// Random real block (000000000000b731f2eef9e8c63173adfb07e41bd53eb0ef0a6b720d6cb6de │ // Random real block (000000000000b731f2eef9e8c63173adfb07e41bd53eb0ef0a6b720d6cb6de
// With 7 txes │ // With 7 txes
CBlock block; │ CBlock block;
CDataStream stream(ParseHex("0100000082bb869cf3a793432a66e826e05a6fc37469f8efb7421dc │ CDataStream stream(ParseHex("0100000082bb869cf3a793432a66e826e05a6fc37469f8efb7421dc
stream >> block; │ stream >> block;
│
CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_ALL); │ CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
// Match the last transaction │ // Match the last transaction
filter.insert(uint256S("0x0a2a92f0bda4727d0a13eaddf4dd9ac6b5c61a1429e6b2b818f19b15df │ filter.insert(uint256S("0x0a2a92f0bda4727d0a13eaddf4dd9ac6b5c61a1429e6b2b818f19b15df
│
CMerkleBlock merkleBlock(block, filter); │ CMerkleBlock merkleBlock(block, filter);
BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); │ BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());
│
BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 1); │ BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 1);
std::pair<unsigned int, uint256> pair = merkleBlock.vMatchedTxn[0]; │ std::pair<unsigned int, uint256> pair = merkleBlock.vMatchedTxn[0];
│
BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0x0a2a92f0bda4727d0a13ead │ BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0x0a2a92f0bda4727d0a13ead
BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 6); │ BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 6);
│
std::vector<uint256> vMatched; │ std::vector<uint256> vMatched;
std::vector<unsigned int> vIndex; │ std::vector<unsigned int> vIndex;
BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot │ BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot
BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size()); │ BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size());
for (unsigned int i = 0; i < vMatched.size(); i++) │ for (unsigned int i = 0; i < vMatched.size(); i++)
BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second); │ BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second);
│
// Also match the 4th transaction │ // Also match the 4th transaction
filter.insert(uint256S("0x02981fa052f0481dbc5868f4fc2166035a10f27a03cfd2de67326471df │ filter.insert(uint256S("0x02981fa052f0481dbc5868f4fc2166035a10f27a03cfd2de67326471df
merkleBlock = CMerkleBlock(block, filter); │ merkleBlock = CMerkleBlock(block, filter);
BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); │ BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());
│
BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 2); │ BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 2);
│
BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0x02981fa052f0481dbc5868f │ BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0x02981fa052f0481dbc5868f
BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 3); │ BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 3);
│
BOOST_CHECK(merkleBlock.vMatchedTxn[1] == pair); │ BOOST_CHECK(merkleBlock.vMatchedTxn[1] == pair);
│
BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot │ BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot
BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size()); │ BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size());
for (unsigned int i = 0; i < vMatched.size(); i++) │ for (unsigned int i = 0; i < vMatched.size(); i++)
BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second); │ BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second);
} │
next prev up bitcoin/src/test/mempool_tests.cpp:425 │ dogecoin/src/test/mempool_tests.cpp:434
│
CTxMemPool pool; │ CTxMemPool pool(CFeeRate(COIN / 1000));
LOCK2(cs_main, pool.cs); │
TestMemPoolEntryHelper entry; │ TestMemPoolEntryHelper entry;
│ entry.dPriority = 10.0;
│
CMutableTransaction tx1 = CMutableTransaction(); │ CMutableTransaction tx1 = CMutableTransaction();
tx1.vin.resize(1); │ tx1.vin.resize(1);
tx1.vin[0].scriptSig = CScript() << OP_1; │ tx1.vin[0].scriptSig = CScript() << OP_1;
tx1.vout.resize(1); │ tx1.vout.resize(1);
tx1.vout[0].scriptPubKey = CScript() << OP_1 << OP_EQUAL; │ tx1.vout[0].scriptPubKey = CScript() << OP_1 << OP_EQUAL;
tx1.vout[0].nValue = 10 * COIN; │ tx1.vout[0].nValue = 10 * COIN;
pool.addUnchecked(entry.Fee(10000LL).FromTx(tx1)); │ pool.addUnchecked(tx1.GetHash(), entry.Fee(COIN / 100).FromTx(tx1, &pool));
│
CMutableTransaction tx2 = CMutableTransaction(); │ CMutableTransaction tx2 = CMutableTransaction();
tx2.vin.resize(1); │ tx2.vin.resize(1);
tx2.vin[0].scriptSig = CScript() << OP_2; │ tx2.vin[0].scriptSig = CScript() << OP_2;
tx2.vout.resize(1); │ tx2.vout.resize(1);
tx2.vout[0].scriptPubKey = CScript() << OP_2 << OP_EQUAL; │ tx2.vout[0].scriptPubKey = CScript() << OP_2 << OP_EQUAL;
tx2.vout[0].nValue = 10 * COIN; │ tx2.vout[0].nValue = 10 * COIN;
pool.addUnchecked(entry.Fee(5000LL).FromTx(tx2)); │ pool.addUnchecked(tx2.GetHash(), entry.Fee(COIN / 200).FromTx(tx2, &pool));
│
pool.TrimToSize(pool.DynamicMemoryUsage()); // should do nothing │ pool.TrimToSize(pool.DynamicMemoryUsage()); // should do nothing
BOOST_CHECK(pool.exists(GenTxid::Txid(tx1.GetHash()))); │ BOOST_CHECK(pool.exists(tx1.GetHash()));
BOOST_CHECK(pool.exists(GenTxid::Txid(tx2.GetHash()))); │ BOOST_CHECK(pool.exists(tx2.GetHash()));
│
pool.TrimToSize(pool.DynamicMemoryUsage() * 3 / 4); // should remove the lower-feera │ pool.TrimToSize(pool.DynamicMemoryUsage() * 3 / 4); // should remove the lower-feera
BOOST_CHECK(pool.exists(GenTxid::Txid(tx1.GetHash()))); │ BOOST_CHECK(pool.exists(tx1.GetHash()));
BOOST_CHECK(!pool.exists(GenTxid::Txid(tx2.GetHash()))); │ BOOST_CHECK(!pool.exists(tx2.GetHash()));
│
pool.addUnchecked(entry.FromTx(tx2)); │ pool.addUnchecked(tx2.GetHash(), entry.FromTx(tx2, &pool));
CMutableTransaction tx3 = CMutableTransaction(); │ CMutableTransaction tx3 = CMutableTransaction();
tx3.vin.resize(1); │ tx3.vin.resize(1);
tx3.vin[0].prevout = COutPoint(tx2.GetHash(), 0); │ tx3.vin[0].prevout = COutPoint(tx2.GetHash(), 0);
tx3.vin[0].scriptSig = CScript() << OP_2; │ tx3.vin[0].scriptSig = CScript() << OP_2;
tx3.vout.resize(1); │ tx3.vout.resize(1);
tx3.vout[0].scriptPubKey = CScript() << OP_3 << OP_EQUAL; │ tx3.vout[0].scriptPubKey = CScript() << OP_3 << OP_EQUAL;
tx3.vout[0].nValue = 10 * COIN; │ tx3.vout[0].nValue = 10 * COIN;
pool.addUnchecked(entry.Fee(20000LL).FromTx(tx3)); │ pool.addUnchecked(tx3.GetHash(), entry.Fee(COIN / 50).FromTx(tx3, &pool));
│
pool.TrimToSize(pool.DynamicMemoryUsage() * 3 / 4); // tx3 should pay for tx2 (CPFP) │ pool.TrimToSize(pool.DynamicMemoryUsage() * 3 / 4); // tx3 should pay for tx2 (CPFP)
BOOST_CHECK(!pool.exists(GenTxid::Txid(tx1.GetHash()))); │ BOOST_CHECK(!pool.exists(tx1.GetHash()));
BOOST_CHECK(pool.exists(GenTxid::Txid(tx2.GetHash()))); │ BOOST_CHECK(pool.exists(tx2.GetHash()));
BOOST_CHECK(pool.exists(GenTxid::Txid(tx3.GetHash()))); │ BOOST_CHECK(pool.exists(tx3.GetHash()));
│
pool.TrimToSize(GetVirtualTransactionSize(CTransaction(tx1))); // mempool is limited │ pool.TrimToSize(GetVirtualTransactionSize(tx1)); // mempool is limited to tx1's size
BOOST_CHECK(!pool.exists(GenTxid::Txid(tx1.GetHash()))); │ BOOST_CHECK(!pool.exists(tx1.GetHash()));
BOOST_CHECK(!pool.exists(GenTxid::Txid(tx2.GetHash()))); │ BOOST_CHECK(!pool.exists(tx2.GetHash()));
BOOST_CHECK(!pool.exists(GenTxid::Txid(tx3.GetHash()))); │ BOOST_CHECK(!pool.exists(tx3.GetHash()));
│
CFeeRate maxFeeRateRemoved(25000, GetVirtualTransactionSize(CTransaction(tx3)) + Get │ CFeeRate maxFeeRateRemoved(COIN / 1000 * 25, GetVirtualTransactionSize(tx3) + GetVir
BOOST_CHECK_EQUAL(pool.GetMinFee(1).GetFeePerK(), maxFeeRateRemoved.GetFeePerK() + 1 │ BOOST_CHECK_EQUAL(pool.GetMinFee(1).GetFeePerK(), maxFeeRateRemoved.GetFeePerK() + D
│
CMutableTransaction tx4 = CMutableTransaction(); │ CMutableTransaction tx4 = CMutableTransaction();
tx4.vin.resize(2); │ tx4.vin.resize(2);
tx4.vin[0].prevout.SetNull(); │ tx4.vin[0].prevout.SetNull();
tx4.vin[0].scriptSig = CScript() << OP_4; │ tx4.vin[0].scriptSig = CScript() << OP_4;
tx4.vin[1].prevout.SetNull(); │ tx4.vin[1].prevout.SetNull();
tx4.vin[1].scriptSig = CScript() << OP_4; │ tx4.vin[1].scriptSig = CScript() << OP_4;
tx4.vout.resize(2); │ tx4.vout.resize(2);
tx4.vout[0].scriptPubKey = CScript() << OP_4 << OP_EQUAL; │ tx4.vout[0].scriptPubKey = CScript() << OP_4 << OP_EQUAL;
tx4.vout[0].nValue = 10 * COIN; │ tx4.vout[0].nValue = 10 * COIN;
tx4.vout[1].scriptPubKey = CScript() << OP_4 << OP_EQUAL; │ tx4.vout[1].scriptPubKey = CScript() << OP_4 << OP_EQUAL;
tx4.vout[1].nValue = 10 * COIN; │ tx4.vout[1].nValue = 10 * COIN;
│
CMutableTransaction tx5 = CMutableTransaction(); │ CMutableTransaction tx5 = CMutableTransaction();
tx5.vin.resize(2); │ tx5.vin.resize(2);
tx5.vin[0].prevout = COutPoint(tx4.GetHash(), 0); │ tx5.vin[0].prevout = COutPoint(tx4.GetHash(), 0);
tx5.vin[0].scriptSig = CScript() << OP_4; │ tx5.vin[0].scriptSig = CScript() << OP_4;
tx5.vin[1].prevout.SetNull(); │ tx5.vin[1].prevout.SetNull();
tx5.vin[1].scriptSig = CScript() << OP_5; │ tx5.vin[1].scriptSig = CScript() << OP_5;
tx5.vout.resize(2); │ tx5.vout.resize(2);
tx5.vout[0].scriptPubKey = CScript() << OP_5 << OP_EQUAL; │ tx5.vout[0].scriptPubKey = CScript() << OP_5 << OP_EQUAL;
tx5.vout[0].nValue = 10 * COIN; │ tx5.vout[0].nValue = 10 * COIN;
tx5.vout[1].scriptPubKey = CScript() << OP_5 << OP_EQUAL; │ tx5.vout[1].scriptPubKey = CScript() << OP_5 << OP_EQUAL;
tx5.vout[1].nValue = 10 * COIN; │ tx5.vout[1].nValue = 10 * COIN;
│
CMutableTransaction tx6 = CMutableTransaction(); │ CMutableTransaction tx6 = CMutableTransaction();
tx6.vin.resize(2); │ tx6.vin.resize(2);
tx6.vin[0].prevout = COutPoint(tx4.GetHash(), 1); │ tx6.vin[0].prevout = COutPoint(tx4.GetHash(), 1);
tx6.vin[0].scriptSig = CScript() << OP_4; │ tx6.vin[0].scriptSig = CScript() << OP_4;
tx6.vin[1].prevout.SetNull(); │ tx6.vin[1].prevout.SetNull();
tx6.vin[1].scriptSig = CScript() << OP_6; │ tx6.vin[1].scriptSig = CScript() << OP_6;
tx6.vout.resize(2); │ tx6.vout.resize(2);
tx6.vout[0].scriptPubKey = CScript() << OP_6 << OP_EQUAL; │ tx6.vout[0].scriptPubKey = CScript() << OP_6 << OP_EQUAL;
tx6.vout[0].nValue = 10 * COIN; │ tx6.vout[0].nValue = 10 * COIN;
tx6.vout[1].scriptPubKey = CScript() << OP_6 << OP_EQUAL; │ tx6.vout[1].scriptPubKey = CScript() << OP_6 << OP_EQUAL;
tx6.vout[1].nValue = 10 * COIN; │ tx6.vout[1].nValue = 10 * COIN;
│
CMutableTransaction tx7 = CMutableTransaction(); │ CMutableTransaction tx7 = CMutableTransaction();
tx7.vin.resize(2); │ tx7.vin.resize(2);
tx7.vin[0].prevout = COutPoint(tx5.GetHash(), 0); │ tx7.vin[0].prevout = COutPoint(tx5.GetHash(), 0);
tx7.vin[0].scriptSig = CScript() << OP_5; │ tx7.vin[0].scriptSig = CScript() << OP_5;
tx7.vin[1].prevout = COutPoint(tx6.GetHash(), 0); │ tx7.vin[1].prevout = COutPoint(tx6.GetHash(), 0);
tx7.vin[1].scriptSig = CScript() << OP_6; │ tx7.vin[1].scriptSig = CScript() << OP_6;
tx7.vout.resize(2); │ tx7.vout.resize(2);
tx7.vout[0].scriptPubKey = CScript() << OP_7 << OP_EQUAL; │ tx7.vout[0].scriptPubKey = CScript() << OP_7 << OP_EQUAL;
tx7.vout[0].nValue = 10 * COIN; │ tx7.vout[0].nValue = 10 * COIN;
tx7.vout[1].scriptPubKey = CScript() << OP_7 << OP_EQUAL; │ tx7.vout[1].scriptPubKey = CScript() << OP_7 << OP_EQUAL;
tx7.vout[1].nValue = 10 * COIN; │ tx7.vout[1].nValue = 10 * COIN;
│
pool.addUnchecked(entry.Fee(7000LL).FromTx(tx4)); │ pool.addUnchecked(tx4.GetHash(), entry.Fee(COIN / 1000 * 7).FromTx(tx4, &pool));
pool.addUnchecked(entry.Fee(1000LL).FromTx(tx5)); │ pool.addUnchecked(tx5.GetHash(), entry.Fee(COIN / 1000).FromTx(tx5, &pool));
pool.addUnchecked(entry.Fee(1100LL).FromTx(tx6)); │ pool.addUnchecked(tx6.GetHash(), entry.Fee(COIN / 10000 * 11).FromTx(tx6, &pool));
pool.addUnchecked(entry.Fee(9000LL).FromTx(tx7)); │ pool.addUnchecked(tx7.GetHash(), entry.Fee(COIN / 1000 * 9).FromTx(tx7, &pool));
│
// we only require this to remove, at max, 2 txn, because it's not clear what we're │ // we only require this remove, at max, 2 txn, because its not clear what we're real
pool.TrimToSize(pool.DynamicMemoryUsage() - 1); │ pool.TrimToSize(pool.DynamicMemoryUsage() - 1);
BOOST_CHECK(pool.exists(GenTxid::Txid(tx4.GetHash()))); │ BOOST_CHECK(pool.exists(tx4.GetHash()));
BOOST_CHECK(pool.exists(GenTxid::Txid(tx6.GetHash()))); │ BOOST_CHECK(pool.exists(tx6.GetHash()));
BOOST_CHECK(!pool.exists(GenTxid::Txid(tx7.GetHash()))); │ BOOST_CHECK(!pool.exists(tx7.GetHash()));
│
if (!pool.exists(GenTxid::Txid(tx5.GetHash()))) │ if (!pool.exists(tx5.GetHash()))
pool.addUnchecked(entry.Fee(1000LL).FromTx(tx5)); │ pool.addUnchecked(tx5.GetHash(), entry.Fee(COIN / 1000).FromTx(tx5, &pool));
pool.addUnchecked(entry.Fee(9000LL).FromTx(tx7)); │ pool.addUnchecked(tx7.GetHash(), entry.Fee(COIN / 1000 * 9).FromTx(tx7, &pool));
│
pool.TrimToSize(pool.DynamicMemoryUsage() / 2); // should maximize mempool size by o │ pool.TrimToSize(pool.DynamicMemoryUsage() / 2); // should maximize mempool size by o
BOOST_CHECK(pool.exists(GenTxid::Txid(tx4.GetHash()))); │ BOOST_CHECK(pool.exists(tx4.GetHash()));
BOOST_CHECK(!pool.exists(GenTxid::Txid(tx5.GetHash()))); │ BOOST_CHECK(!pool.exists(tx5.GetHash()));
BOOST_CHECK(pool.exists(GenTxid::Txid(tx6.GetHash()))); │ BOOST_CHECK(pool.exists(tx6.GetHash()));
BOOST_CHECK(!pool.exists(GenTxid::Txid(tx7.GetHash()))); │ BOOST_CHECK(!pool.exists(tx7.GetHash()));
│
pool.addUnchecked(entry.Fee(1000LL).FromTx(tx5)); │ pool.addUnchecked(tx5.GetHash(), entry.Fee(COIN / 1000).FromTx(tx5, &pool));
pool.addUnchecked(entry.Fee(9000LL).FromTx(tx7)); │ pool.addUnchecked(tx7.GetHash(), entry.Fee(COIN / 1000 * 9).FromTx(tx7, &pool));
│
std::vector<CTransactionRef> vtx; │ std::vector<CTransactionRef> vtx;
SetMockTime(42); │ SetMockTime(42);
SetMockTime(42 + CTxMemPool::ROLLING_FEE_HALFLIFE); │ SetMockTime(42 + CTxMemPool::ROLLING_FEE_HALFLIFE);
BOOST_CHECK_EQUAL(pool.GetMinFee(1).GetFeePerK(), maxFeeRateRemoved.GetFeePerK() + 1 │ BOOST_CHECK_EQUAL(pool.GetMinFee(1).GetFeePerK(), maxFeeRateRemoved.GetFeePerK() + D
// ... we should keep the same min fee until we get a block │ // ... we should keep the same min fee until we get a block
pool.removeForBlock(vtx, 1); │ pool.removeForBlock(vtx, 1);
SetMockTime(42 + 2*CTxMemPool::ROLLING_FEE_HALFLIFE); │ SetMockTime(42 + 2*CTxMemPool::ROLLING_FEE_HALFLIFE);
BOOST_CHECK_EQUAL(pool.GetMinFee(1).GetFeePerK(), llround((maxFeeRateRemoved.GetFeeP │ BOOST_CHECK_EQUAL(pool.GetMinFee(1).GetFeePerK(), (maxFeeRateRemoved.GetFeePerK() +
// ... then feerate should drop 1/2 each halflife │ // ... then feerate should drop 1/2 each halflife
│
SetMockTime(42 + 2*CTxMemPool::ROLLING_FEE_HALFLIFE + CTxMemPool::ROLLING_FEE_HALFLI │ SetMockTime(42 + 2*CTxMemPool::ROLLING_FEE_HALFLIFE + CTxMemPool::ROLLING_FEE_HALFLI
BOOST_CHECK_EQUAL(pool.GetMinFee(pool.DynamicMemoryUsage() * 5 / 2).GetFeePerK(), ll │ BOOST_CHECK_EQUAL(pool.GetMinFee(pool.DynamicMemoryUsage() * 5 / 2).GetFeePerK(), (m
// ... with a 1/2 halflife when mempool is < 1/2 its target size │ // ... with a 1/2 halflife when mempool is < 1/2 its target size
│
SetMockTime(42 + 2*CTxMemPool::ROLLING_FEE_HALFLIFE + CTxMemPool::ROLLING_FEE_HALFLI │ SetMockTime(42 + 2*CTxMemPool::ROLLING_FEE_HALFLIFE + CTxMemPool::ROLLING_FEE_HALFLI
BOOST_CHECK_EQUAL(pool.GetMinFee(pool.DynamicMemoryUsage() * 9 / 2).GetFeePerK(), ll │ BOOST_CHECK_EQUAL(pool.GetMinFee(pool.DynamicMemoryUsage() * 9 / 2).GetFeePerK(), (m
// ... with a 1/4 halflife when mempool is < 1/4 its target size │ // ... with a 1/4 halflife when mempool is < 1/4 its target size
│
SetMockTime(42 + 7*CTxMemPool::ROLLING_FEE_HALFLIFE + CTxMemPool::ROLLING_FEE_HALFLI │ SetMockTime(42 + 10*CTxMemPool::ROLLING_FEE_HALFLIFE + CTxMemPool::ROLLING_FEE_HALFL
BOOST_CHECK_EQUAL(pool.GetMinFee(1).GetFeePerK(), 1000); │ BOOST_CHECK_EQUAL(pool.GetMinFee(1).GetFeePerK(), DEFAULT_INCREMENTAL_RELAY_FEE);
// ... but feerate should never drop below 1000 │ // ... but feerate should never drop below DEFAULT_INCREMENTAL_RELAY_FEE
│
SetMockTime(42 + 8*CTxMemPool::ROLLING_FEE_HALFLIFE + CTxMemPool::ROLLING_FEE_HALFLI │ SetMockTime(42 + 11*CTxMemPool::ROLLING_FEE_HALFLIFE + CTxMemPool::ROLLING_FEE_HALFL
BOOST_CHECK_EQUAL(pool.GetMinFee(1).GetFeePerK(), 0); │ BOOST_CHECK_EQUAL(pool.GetMinFee(1).GetFeePerK(), 0);
// ... unless it has gone all the way to 0 (after getting past 1000/2) │ // ... unless it has gone all the way to 0 (after getting past DEFAULT_INCREMENTAL_R
│
│ SetMockTime(0);
} │
next prev up bitcoin/src/script/script.cpp:13 │ dogecoin/src/script/script.cpp:14
│
switch (opcode) │ switch (opcode)
{ │ {
// push value │ // push value
case OP_0 : return "0"; │ case OP_0 : return "0";
case OP_PUSHDATA1 : return "OP_PUSHDATA1"; │ case OP_PUSHDATA1 : return "OP_PUSHDATA1";
case OP_PUSHDATA2 : return "OP_PUSHDATA2"; │ case OP_PUSHDATA2 : return "OP_PUSHDATA2";
case OP_PUSHDATA4 : return "OP_PUSHDATA4"; │ case OP_PUSHDATA4 : return "OP_PUSHDATA4";
case OP_1NEGATE : return "-1"; │ case OP_1NEGATE : return "-1";
case OP_RESERVED : return "OP_RESERVED"; │ case OP_RESERVED : return "OP_RESERVED";
case OP_1 : return "1"; │ case OP_1 : return "1";
case OP_2 : return "2"; │ case OP_2 : return "2";
case OP_3 : return "3"; │ case OP_3 : return "3";
case OP_4 : return "4"; │ case OP_4 : return "4";
case OP_5 : return "5"; │ case OP_5 : return "5";
case OP_6 : return "6"; │ case OP_6 : return "6";
case OP_7 : return "7"; │ case OP_7 : return "7";
case OP_8 : return "8"; │ case OP_8 : return "8";
case OP_9 : return "9"; │ case OP_9 : return "9";
case OP_10 : return "10"; │ case OP_10 : return "10";
case OP_11 : return "11"; │ case OP_11 : return "11";
case OP_12 : return "12"; │ case OP_12 : return "12";
case OP_13 : return "13"; │ case OP_13 : return "13";
case OP_14 : return "14"; │ case OP_14 : return "14";
case OP_15 : return "15"; │ case OP_15 : return "15";
case OP_16 : return "16"; │ case OP_16 : return "16";
│
// control │ // control
case OP_NOP : return "OP_NOP"; │ case OP_NOP : return "OP_NOP";
case OP_VER : return "OP_VER"; │ case OP_VER : return "OP_VER";
case OP_IF : return "OP_IF"; │ case OP_IF : return "OP_IF";
case OP_NOTIF : return "OP_NOTIF"; │ case OP_NOTIF : return "OP_NOTIF";
case OP_VERIF : return "OP_VERIF"; │ case OP_VERIF : return "OP_VERIF";
case OP_VERNOTIF : return "OP_VERNOTIF"; │ case OP_VERNOTIF : return "OP_VERNOTIF";
case OP_ELSE : return "OP_ELSE"; │ case OP_ELSE : return "OP_ELSE";
case OP_ENDIF : return "OP_ENDIF"; │ case OP_ENDIF : return "OP_ENDIF";
case OP_VERIFY : return "OP_VERIFY"; │ case OP_VERIFY : return "OP_VERIFY";
case OP_RETURN : return "OP_RETURN"; │ case OP_RETURN : return "OP_RETURN";
│
// stack ops │ // stack ops
case OP_TOALTSTACK : return "OP_TOALTSTACK"; │ case OP_TOALTSTACK : return "OP_TOALTSTACK";
case OP_FROMALTSTACK : return "OP_FROMALTSTACK"; │ case OP_FROMALTSTACK : return "OP_FROMALTSTACK";
case OP_2DROP : return "OP_2DROP"; │ case OP_2DROP : return "OP_2DROP";
case OP_2DUP : return "OP_2DUP"; │ case OP_2DUP : return "OP_2DUP";
case OP_3DUP : return "OP_3DUP"; │ case OP_3DUP : return "OP_3DUP";
case OP_2OVER : return "OP_2OVER"; │ case OP_2OVER : return "OP_2OVER";
case OP_2ROT : return "OP_2ROT"; │ case OP_2ROT : return "OP_2ROT";
case OP_2SWAP : return "OP_2SWAP"; │ case OP_2SWAP : return "OP_2SWAP";
case OP_IFDUP : return "OP_IFDUP"; │ case OP_IFDUP : return "OP_IFDUP";
case OP_DEPTH : return "OP_DEPTH"; │ case OP_DEPTH : return "OP_DEPTH";
case OP_DROP : return "OP_DROP"; │ case OP_DROP : return "OP_DROP";
case OP_DUP : return "OP_DUP"; │ case OP_DUP : return "OP_DUP";
case OP_NIP : return "OP_NIP"; │ case OP_NIP : return "OP_NIP";
case OP_OVER : return "OP_OVER"; │ case OP_OVER : return "OP_OVER";
case OP_PICK : return "OP_PICK"; │ case OP_PICK : return "OP_PICK";
case OP_ROLL : return "OP_ROLL"; │ case OP_ROLL : return "OP_ROLL";
case OP_ROT : return "OP_ROT"; │ case OP_ROT : return "OP_ROT";
case OP_SWAP : return "OP_SWAP"; │ case OP_SWAP : return "OP_SWAP";
case OP_TUCK : return "OP_TUCK"; │ case OP_TUCK : return "OP_TUCK";
│
// splice ops │ // splice ops
case OP_CAT : return "OP_CAT"; │ case OP_CAT : return "OP_CAT";
case OP_SUBSTR : return "OP_SUBSTR"; │ case OP_SUBSTR : return "OP_SUBSTR";
case OP_LEFT : return "OP_LEFT"; │ case OP_LEFT : return "OP_LEFT";
case OP_RIGHT : return "OP_RIGHT"; │ case OP_RIGHT : return "OP_RIGHT";
case OP_SIZE : return "OP_SIZE"; │ case OP_SIZE : return "OP_SIZE";
│
// bit logic │ // bit logic
case OP_INVERT : return "OP_INVERT"; │ case OP_INVERT : return "OP_INVERT";
case OP_AND : return "OP_AND"; │ case OP_AND : return "OP_AND";
case OP_OR : return "OP_OR"; │ case OP_OR : return "OP_OR";
case OP_XOR : return "OP_XOR"; │ case OP_XOR : return "OP_XOR";
case OP_EQUAL : return "OP_EQUAL"; │ case OP_EQUAL : return "OP_EQUAL";
case OP_EQUALVERIFY : return "OP_EQUALVERIFY"; │ case OP_EQUALVERIFY : return "OP_EQUALVERIFY";
case OP_RESERVED1 : return "OP_RESERVED1"; │ case OP_RESERVED1 : return "OP_RESERVED1";
case OP_RESERVED2 : return "OP_RESERVED2"; │ case OP_RESERVED2 : return "OP_RESERVED2";
│
// numeric │ // numeric
case OP_1ADD : return "OP_1ADD"; │ case OP_1ADD : return "OP_1ADD";
case OP_1SUB : return "OP_1SUB"; │ case OP_1SUB : return "OP_1SUB";
case OP_2MUL : return "OP_2MUL"; │ case OP_2MUL : return "OP_2MUL";
case OP_2DIV : return "OP_2DIV"; │ case OP_2DIV : return "OP_2DIV";
case OP_NEGATE : return "OP_NEGATE"; │ case OP_NEGATE : return "OP_NEGATE";
case OP_ABS : return "OP_ABS"; │ case OP_ABS : return "OP_ABS";
case OP_NOT : return "OP_NOT"; │ case OP_NOT : return "OP_NOT";
case OP_0NOTEQUAL : return "OP_0NOTEQUAL"; │ case OP_0NOTEQUAL : return "OP_0NOTEQUAL";
case OP_ADD : return "OP_ADD"; │ case OP_ADD : return "OP_ADD";
case OP_SUB : return "OP_SUB"; │ case OP_SUB : return "OP_SUB";
case OP_MUL : return "OP_MUL"; │ case OP_MUL : return "OP_MUL";
case OP_DIV : return "OP_DIV"; │ case OP_DIV : return "OP_DIV";
case OP_MOD : return "OP_MOD"; │ case OP_MOD : return "OP_MOD";
case OP_LSHIFT : return "OP_LSHIFT"; │ case OP_LSHIFT : return "OP_LSHIFT";
case OP_RSHIFT : return "OP_RSHIFT"; │ case OP_RSHIFT : return "OP_RSHIFT";
case OP_BOOLAND : return "OP_BOOLAND"; │ case OP_BOOLAND : return "OP_BOOLAND";
case OP_BOOLOR : return "OP_BOOLOR"; │ case OP_BOOLOR : return "OP_BOOLOR";
case OP_NUMEQUAL : return "OP_NUMEQUAL"; │ case OP_NUMEQUAL : return "OP_NUMEQUAL";
case OP_NUMEQUALVERIFY : return "OP_NUMEQUALVERIFY"; │ case OP_NUMEQUALVERIFY : return "OP_NUMEQUALVERIFY";
case OP_NUMNOTEQUAL : return "OP_NUMNOTEQUAL"; │ case OP_NUMNOTEQUAL : return "OP_NUMNOTEQUAL";
case OP_LESSTHAN : return "OP_LESSTHAN"; │ case OP_LESSTHAN : return "OP_LESSTHAN";
case OP_GREATERTHAN : return "OP_GREATERTHAN"; │ case OP_GREATERTHAN : return "OP_GREATERTHAN";
case OP_LESSTHANOREQUAL : return "OP_LESSTHANOREQUAL"; │ case OP_LESSTHANOREQUAL : return "OP_LESSTHANOREQUAL";
case OP_GREATERTHANOREQUAL : return "OP_GREATERTHANOREQUAL"; │ case OP_GREATERTHANOREQUAL : return "OP_GREATERTHANOREQUAL";
case OP_MIN : return "OP_MIN"; │ case OP_MIN : return "OP_MIN";
case OP_MAX : return "OP_MAX"; │ case OP_MAX : return "OP_MAX";
case OP_WITHIN : return "OP_WITHIN"; │ case OP_WITHIN : return "OP_WITHIN";
│
// crypto │ // crypto
case OP_RIPEMD160 : return "OP_RIPEMD160"; │ case OP_RIPEMD160 : return "OP_RIPEMD160";
case OP_SHA1 : return "OP_SHA1"; │ case OP_SHA1 : return "OP_SHA1";
case OP_SHA256 : return "OP_SHA256"; │ case OP_SHA256 : return "OP_SHA256";
case OP_HASH160 : return "OP_HASH160"; │ case OP_HASH160 : return "OP_HASH160";
case OP_HASH256 : return "OP_HASH256"; │ case OP_HASH256 : return "OP_HASH256";
case OP_CODESEPARATOR : return "OP_CODESEPARATOR"; │ case OP_CODESEPARATOR : return "OP_CODESEPARATOR";
case OP_CHECKSIG : return "OP_CHECKSIG"; │ case OP_CHECKSIG : return "OP_CHECKSIG";
case OP_CHECKSIGVERIFY : return "OP_CHECKSIGVERIFY"; │ case OP_CHECKSIGVERIFY : return "OP_CHECKSIGVERIFY";
case OP_CHECKMULTISIG : return "OP_CHECKMULTISIG"; │ case OP_CHECKMULTISIG : return "OP_CHECKMULTISIG";
case OP_CHECKMULTISIGVERIFY : return "OP_CHECKMULTISIGVERIFY"; │ case OP_CHECKMULTISIGVERIFY : return "OP_CHECKMULTISIGVERIFY";
│
// expansion │ // expansion
case OP_NOP1 : return "OP_NOP1"; │ case OP_NOP1 : return "OP_NOP1";
case OP_CHECKLOCKTIMEVERIFY : return "OP_CHECKLOCKTIMEVERIFY"; │ case OP_CHECKLOCKTIMEVERIFY : return "OP_CHECKLOCKTIMEVERIFY";
case OP_CHECKSEQUENCEVERIFY : return "OP_CHECKSEQUENCEVERIFY"; │ case OP_CHECKSEQUENCEVERIFY : return "OP_CHECKSEQUENCEVERIFY";
case OP_NOP4 : return "OP_NOP4"; │ case OP_NOP4 : return "OP_NOP4";
case OP_NOP5 : return "OP_NOP5"; │ case OP_NOP5 : return "OP_NOP5";
case OP_NOP6 : return "OP_NOP6"; │ case OP_NOP6 : return "OP_NOP6";
case OP_NOP7 : return "OP_NOP7"; │ case OP_NOP7 : return "OP_NOP7";
case OP_NOP8 : return "OP_NOP8"; │ case OP_NOP8 : return "OP_NOP8";
case OP_NOP9 : return "OP_NOP9"; │ case OP_NOP9 : return "OP_NOP9";
case OP_NOP10 : return "OP_NOP10"; │ case OP_NOP10 : return "OP_NOP10";
│
// Opcode added by BIP 342 (Tapscript) │
case OP_CHECKSIGADD : return "OP_CHECKSIGADD"; │
│
case OP_INVALIDOPCODE : return "OP_INVALIDOPCODE"; │ case OP_INVALIDOPCODE : return "OP_INVALIDOPCODE";
│
│ // Note:
│ // The template matching params OP_SMALLINTEGER/etc are defined in opcodetype enum
│ // as kind of implementation hack, they are *NOT* real opcodes. If found in real
│ // Script, just let the default: case deal with them.
│
default: │ default:
return "OP_UNKNOWN"; │ return "OP_UNKNOWN";
} │ }
} │
next prev up dogecoin/src/test/sigopcount_tests.cpp:109 │ bitcoin/src/test/sigopcount_tests.cpp:109
│
// Transaction creates outputs │ // Transaction creates outputs
CMutableTransaction creationTx; │ CMutableTransaction creationTx;
// Transaction that spends outputs and whose │ // Transaction that spends outputs and whose
// sig op cost is going to be tested │ // sig op cost is going to be tested
CMutableTransaction spendingTx; │ CMutableTransaction spendingTx;
│
// Create utxo set │ // Create utxo set
CCoinsView coinsDummy; │ CCoinsView coinsDummy;
CCoinsViewCache coins(&coinsDummy); │ CCoinsViewCache coins(&coinsDummy);
// Create key │ // Create key
CKey key; │ CKey key;
key.MakeNewKey(true); │ key.MakeNewKey(true);
CPubKey pubkey = key.GetPubKey(); │ CPubKey pubkey = key.GetPubKey();
// Default flags │ // Default flags
int flags = SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2SH; │ const uint32_t flags{SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2SH};
│
// Multisig script (legacy counting) │ // Multisig script (legacy counting)
{ │ {
CScript scriptPubKey = CScript() << 1 << ToByteVector(pubkey) << ToByteVector(pu │ CScript scriptPubKey = CScript() << 1 << ToByteVector(pubkey) << ToByteVector(pu
// Do not use a valid signature to avoid using wallet operations. │ // Do not use a valid signature to avoid using wallet operations.
CScript scriptSig = CScript() << OP_0 << OP_0; │ CScript scriptSig = CScript() << OP_0 << OP_0;
│
BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, CScriptWitness( │ BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, CScriptWitness(
// Legacy counting only includes signature operations in scriptSigs and scriptPu │ // Legacy counting only includes signature operations in scriptSigs and scriptPu
// of a transaction and does not take the actual executed sig operations into ac │ // of a transaction and does not take the actual executed sig operations into ac
// spendingTx in itself does not contain a signature operation. │ // spendingTx in itself does not contain a signature operation.
assert(GetTransactionSigOpCost(CTransaction(spendingTx), coins, flags) == 0); │ assert(GetTransactionSigOpCost(CTransaction(spendingTx), coins, flags) == 0);
// creationTx contains two signature operations in its scriptPubKey, but legacy │ // creationTx contains two signature operations in its scriptPubKey, but legacy
// is not accurate. │ // is not accurate.
assert(GetTransactionSigOpCost(CTransaction(creationTx), coins, flags) == MAX_PU │ assert(GetTransactionSigOpCost(CTransaction(creationTx), coins, flags) == MAX_PU
// Sanity check: script verification fails because of an invalid signature. │ // Sanity check: script verification fails because of an invalid signature.
assert(VerifyWithFlag(creationTx, spendingTx, flags) == SCRIPT_ERR_CHECKMULTISIG │ assert(VerifyWithFlag(CTransaction(creationTx), spendingTx, flags) == SCRIPT_ERR
} │ }
│
// Multisig nested in P2SH │ // Multisig nested in P2SH
{ │ {
CScript redeemScript = CScript() << 1 << ToByteVector(pubkey) << ToByteVector(pu │ CScript redeemScript = CScript() << 1 << ToByteVector(pubkey) << ToByteVector(pu
CScript scriptPubKey = GetScriptForDestination(CScriptID(redeemScript)); │ CScript scriptPubKey = GetScriptForDestination(ScriptHash(redeemScript));
CScript scriptSig = CScript() << OP_0 << OP_0 << ToByteVector(redeemScript); │ CScript scriptSig = CScript() << OP_0 << OP_0 << ToByteVector(redeemScript);
│
BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, CScriptWitness( │ BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, CScriptWitness(
assert(GetTransactionSigOpCost(CTransaction(spendingTx), coins, flags) == 2 * WI │ assert(GetTransactionSigOpCost(CTransaction(spendingTx), coins, flags) == 2 * WI
assert(VerifyWithFlag(creationTx, spendingTx, flags) == SCRIPT_ERR_CHECKMULTISIG │ assert(VerifyWithFlag(CTransaction(creationTx), spendingTx, flags) == SCRIPT_ERR
} │ }
│
// P2WPKH witness program │ // P2WPKH witness program
{ │ {
CScript p2pk = CScript() << ToByteVector(pubkey) << OP_CHECKSIG; │ CScript scriptPubKey = GetScriptForDestination(WitnessV0KeyHash(pubkey));
CScript scriptPubKey = GetScriptForWitness(p2pk); │
CScript scriptSig = CScript(); │ CScript scriptSig = CScript();
CScriptWitness scriptWitness; │ CScriptWitness scriptWitness;
scriptWitness.stack.push_back(std::vector<unsigned char>(0)); │ scriptWitness.stack.push_back(std::vector<unsigned char>(0));
scriptWitness.stack.push_back(std::vector<unsigned char>(0)); │ scriptWitness.stack.push_back(std::vector<unsigned char>(0));
│
│
BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, scriptWitness); │ BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, scriptWitness);
assert(GetTransactionSigOpCost(CTransaction(spendingTx), coins, flags) == 1); │ assert(GetTransactionSigOpCost(CTransaction(spendingTx), coins, flags) == 1);
// No signature operations if we don't verify the witness. │ // No signature operations if we don't verify the witness.
assert(GetTransactionSigOpCost(CTransaction(spendingTx), coins, flags & ~SCRIPT_ │ assert(GetTransactionSigOpCost(CTransaction(spendingTx), coins, flags & ~SCRIPT_
assert(VerifyWithFlag(creationTx, spendingTx, flags) == SCRIPT_ERR_EQUALVERIFY); │ assert(VerifyWithFlag(CTransaction(creationTx), spendingTx, flags) == SCRIPT_ERR
│
// The sig op cost for witness version != 0 is zero. │ // The sig op cost for witness version != 0 is zero.
assert(scriptPubKey[0] == 0x00); │ assert(scriptPubKey[0] == 0x00);
scriptPubKey[0] = 0x51; │ scriptPubKey[0] = 0x51;
BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, scriptWitness); │ BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, scriptWitness);
assert(GetTransactionSigOpCost(CTransaction(spendingTx), coins, flags) == 0); │ assert(GetTransactionSigOpCost(CTransaction(spendingTx), coins, flags) == 0);
scriptPubKey[0] = 0x00; │ scriptPubKey[0] = 0x00;
BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, scriptWitness); │ BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, scriptWitness);
│
// The witness of a coinbase transaction is not taken into account. │ // The witness of a coinbase transaction is not taken into account.
spendingTx.vin[0].prevout.SetNull(); │ spendingTx.vin[0].prevout.SetNull();
assert(GetTransactionSigOpCost(CTransaction(spendingTx), coins, flags) == 0); │ assert(GetTransactionSigOpCost(CTransaction(spendingTx), coins, flags) == 0);
} │ }
│
// P2WPKH nested in P2SH │ // P2WPKH nested in P2SH
{ │ {
CScript p2pk = CScript() << ToByteVector(pubkey) << OP_CHECKSIG; │ CScript scriptSig = GetScriptForDestination(WitnessV0KeyHash(pubkey));
CScript scriptSig = GetScriptForWitness(p2pk); │ CScript scriptPubKey = GetScriptForDestination(ScriptHash(scriptSig));
CScript scriptPubKey = GetScriptForDestination(CScriptID(scriptSig)); │
scriptSig = CScript() << ToByteVector(scriptSig); │ scriptSig = CScript() << ToByteVector(scriptSig);
CScriptWitness scriptWitness; │ CScriptWitness scriptWitness;
scriptWitness.stack.push_back(std::vector<unsigned char>(0)); │ scriptWitness.stack.push_back(std::vector<unsigned char>(0));
scriptWitness.stack.push_back(std::vector<unsigned char>(0)); │ scriptWitness.stack.push_back(std::vector<unsigned char>(0));
│
BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, scriptWitness); │ BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, scriptWitness);
assert(GetTransactionSigOpCost(CTransaction(spendingTx), coins, flags) == 1); │ assert(GetTransactionSigOpCost(CTransaction(spendingTx), coins, flags) == 1);
assert(VerifyWithFlag(creationTx, spendingTx, flags) == SCRIPT_ERR_EQUALVERIFY); │ assert(VerifyWithFlag(CTransaction(creationTx), spendingTx, flags) == SCRIPT_ERR
} │ }
│
// P2WSH witness program │ // P2WSH witness program
{ │ {
CScript witnessScript = CScript() << 1 << ToByteVector(pubkey) << ToByteVector(p │ CScript witnessScript = CScript() << 1 << ToByteVector(pubkey) << ToByteVector(p
CScript scriptPubKey = GetScriptForWitness(witnessScript); │ CScript scriptPubKey = GetScriptForDestination(WitnessV0ScriptHash(witnessScript
CScript scriptSig = CScript(); │ CScript scriptSig = CScript();
CScriptWitness scriptWitness; │ CScriptWitness scriptWitness;
scriptWitness.stack.push_back(std::vector<unsigned char>(0)); │ scriptWitness.stack.push_back(std::vector<unsigned char>(0));
scriptWitness.stack.push_back(std::vector<unsigned char>(0)); │ scriptWitness.stack.push_back(std::vector<unsigned char>(0));
scriptWitness.stack.push_back(std::vector<unsigned char>(witnessScript.begin(), │ scriptWitness.stack.push_back(std::vector<unsigned char>(witnessScript.begin(),
│
BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, scriptWitness); │ BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, scriptWitness);
assert(GetTransactionSigOpCost(CTransaction(spendingTx), coins, flags) == 2); │ assert(GetTransactionSigOpCost(CTransaction(spendingTx), coins, flags) == 2);
assert(GetTransactionSigOpCost(CTransaction(spendingTx), coins, flags & ~SCRIPT_ │ assert(GetTransactionSigOpCost(CTransaction(spendingTx), coins, flags & ~SCRIPT_
assert(VerifyWithFlag(creationTx, spendingTx, flags) == SCRIPT_ERR_CHECKMULTISIG │ assert(VerifyWithFlag(CTransaction(creationTx), spendingTx, flags) == SCRIPT_ERR
} │ }
│
// P2WSH nested in P2SH │ // P2WSH nested in P2SH
{ │ {
CScript witnessScript = CScript() << 1 << ToByteVector(pubkey) << ToByteVector(p │ CScript witnessScript = CScript() << 1 << ToByteVector(pubkey) << ToByteVector(p
CScript redeemScript = GetScriptForWitness(witnessScript); │ CScript redeemScript = GetScriptForDestination(WitnessV0ScriptHash(witnessScript
CScript scriptPubKey = GetScriptForDestination(CScriptID(redeemScript)); │ CScript scriptPubKey = GetScriptForDestination(ScriptHash(redeemScript));
CScript scriptSig = CScript() << ToByteVector(redeemScript); │ CScript scriptSig = CScript() << ToByteVector(redeemScript);
CScriptWitness scriptWitness; │ CScriptWitness scriptWitness;
scriptWitness.stack.push_back(std::vector<unsigned char>(0)); │ scriptWitness.stack.push_back(std::vector<unsigned char>(0));
scriptWitness.stack.push_back(std::vector<unsigned char>(0)); │ scriptWitness.stack.push_back(std::vector<unsigned char>(0));
scriptWitness.stack.push_back(std::vector<unsigned char>(witnessScript.begin(), │ scriptWitness.stack.push_back(std::vector<unsigned char>(witnessScript.begin(),
│
BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, scriptWitness); │ BuildTxs(spendingTx, coins, creationTx, scriptPubKey, scriptSig, scriptWitness);
assert(GetTransactionSigOpCost(CTransaction(spendingTx), coins, flags) == 2); │ assert(GetTransactionSigOpCost(CTransaction(spendingTx), coins, flags) == 2);
assert(VerifyWithFlag(creationTx, spendingTx, flags) == SCRIPT_ERR_CHECKMULTISIG │ assert(VerifyWithFlag(CTransaction(creationTx), spendingTx, flags) == SCRIPT_ERR
} │ }
} │
next prev up dogecoin/src/test/bloom_tests.cpp:113 │ bitcoin/src/test/bloom_tests.cpp:100
│
// Random real transaction (b4749f017444b051c44dfd2720e88f314ff94f3dd6d56d40ef65854f │ // Random real transaction (b4749f017444b051c44dfd2720e88f314ff94f3dd6d56d40ef65854f
CDataStream stream(ParseHex("01000000010b26e9b7735eb6aabdf358bab62f9816a21ba9ebdb719 │ CDataStream stream(ParseHex("01000000010b26e9b7735eb6aabdf358bab62f9816a21ba9ebdb719
CTransaction tx(deserialize, stream); │ CTransaction tx(deserialize, stream);
│
// and one which spends it (e2769b09e784f32f62ef849763d4f45b98e07ba658647343b915ff83 │ // and one which spends it (e2769b09e784f32f62ef849763d4f45b98e07ba658647343b915ff83
unsigned char ch[] = {0x01, 0x00, 0x00, 0x00, 0x01, 0x6b, 0xff, 0x7f, 0xcd, 0x4f, 0x │ unsigned char ch[] = {0x01, 0x00, 0x00, 0x00, 0x01, 0x6b, 0xff, 0x7f, 0xcd, 0x4f, 0x
std::vector<unsigned char> vch(ch, ch + sizeof(ch) -1); │ std::vector<unsigned char> vch(ch, ch + sizeof(ch) -1);
CDataStream spendStream(vch, SER_DISK, CLIENT_VERSION); │ CDataStream spendStream(vch, SER_DISK, CLIENT_VERSION);
CTransaction spendingTx(deserialize, spendStream); │ CTransaction spendingTx(deserialize, spendStream);
│
CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_ALL); │ CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
filter.insert(uint256S("0xb4749f017444b051c44dfd2720e88f314ff94f3dd6d56d40ef65854fcd │ filter.insert(uint256S("0xb4749f017444b051c44dfd2720e88f314ff94f3dd6d56d40ef65854fcd
BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't matc │ BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't matc
│
filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL); │ filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
// byte-reversed tx hash │ // byte-reversed tx hash
filter.insert(ParseHex("6bff7fcd4f8565ef406dd5d63d4ff94f318fe82027fd4dc451b04474019f │ filter.insert(ParseHex("6bff7fcd4f8565ef406dd5d63d4ff94f318fe82027fd4dc451b04474019f
BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't matc │ BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't matc
│
filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL); │ filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
filter.insert(ParseHex("30450220070aca44506c5cef3a16ed519d7c3c39f8aab192c4e1c90d065f │ filter.insert(ParseHex("30450220070aca44506c5cef3a16ed519d7c3c39f8aab192c4e1c90d065f
BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't matc │ BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't matc
│
filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL); │ filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
filter.insert(ParseHex("046d11fee51b0e60666d5049a9101a72741df480b96ee26488a4d3466b95 │ filter.insert(ParseHex("046d11fee51b0e60666d5049a9101a72741df480b96ee26488a4d3466b95
BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't matc │ BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't matc
│
filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL); │ filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
filter.insert(ParseHex("04943fdd508053c75000106d3bc6e2754dbcff19")); │ filter.insert(ParseHex("04943fdd508053c75000106d3bc6e2754dbcff19"));
BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't matc │ BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't matc
BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(spendingTx), "Simple Bloom filter did │ BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(spendingTx), "Simple Bloom filter did
│
filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL); │ filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
filter.insert(ParseHex("a266436d2965547608b9e15d9032a7b9d64fa431")); │ filter.insert(ParseHex("a266436d2965547608b9e15d9032a7b9d64fa431"));
BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't matc │ BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't matc
│
filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL); │ filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
filter.insert(COutPoint(uint256S("0x90c122d70786e899529d71dbeba91ba216982fb6ba58f3bd │ filter.insert(COutPoint(uint256S("0x90c122d70786e899529d71dbeba91ba216982fb6ba58f3bd
BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't matc │ BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't matc
│
filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL); │ filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
COutPoint prevOutPoint(uint256S("0x90c122d70786e899529d71dbeba91ba216982fb6ba58f3bda │ COutPoint prevOutPoint(uint256S("0x90c122d70786e899529d71dbeba91ba216982fb6ba58f3bda
{ │ {
std::vector<unsigned char> data(32 + sizeof(unsigned int)); │ std::vector<unsigned char> data(32 + sizeof(unsigned int));
memcpy(&data[0], prevOutPoint.hash.begin(), 32); │ memcpy(data.data(), prevOutPoint.hash.begin(), 32);
memcpy(&data[32], &prevOutPoint.n, sizeof(unsigned int)); │ memcpy(data.data()+32, &prevOutPoint.n, sizeof(unsigned int));
filter.insert(data); │ filter.insert(data);
} │ }
BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't matc │ BOOST_CHECK_MESSAGE(filter.IsRelevantAndUpdate(tx), "Simple Bloom filter didn't matc
│
filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL); │ filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
filter.insert(uint256S("00000009e784f32f62ef849763d4f45b98e07ba658647343b915ff832b11 │ filter.insert(uint256S("00000009e784f32f62ef849763d4f45b98e07ba658647343b915ff832b11
BOOST_CHECK_MESSAGE(!filter.IsRelevantAndUpdate(tx), "Simple Bloom filter matched ra │ BOOST_CHECK_MESSAGE(!filter.IsRelevantAndUpdate(tx), "Simple Bloom filter matched ra
│
filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL); │ filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
filter.insert(ParseHex("0000006d2965547608b9e15d9032a7b9d64fa431")); │ filter.insert(ParseHex("0000006d2965547608b9e15d9032a7b9d64fa431"));
BOOST_CHECK_MESSAGE(!filter.IsRelevantAndUpdate(tx), "Simple Bloom filter matched ra │ BOOST_CHECK_MESSAGE(!filter.IsRelevantAndUpdate(tx), "Simple Bloom filter matched ra
│
filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL); │ filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
filter.insert(COutPoint(uint256S("0x90c122d70786e899529d71dbeba91ba216982fb6ba58f3bd │ filter.insert(COutPoint(uint256S("0x90c122d70786e899529d71dbeba91ba216982fb6ba58f3bd
BOOST_CHECK_MESSAGE(!filter.IsRelevantAndUpdate(tx), "Simple Bloom filter matched CO │ BOOST_CHECK_MESSAGE(!filter.IsRelevantAndUpdate(tx), "Simple Bloom filter matched CO
│
filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL); │ filter = CBloomFilter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
filter.insert(COutPoint(uint256S("0x000000d70786e899529d71dbeba91ba216982fb6ba58f3bd │ filter.insert(COutPoint(uint256S("0x000000d70786e899529d71dbeba91ba216982fb6ba58f3bd
BOOST_CHECK_MESSAGE(!filter.IsRelevantAndUpdate(tx), "Simple Bloom filter matched CO │ BOOST_CHECK_MESSAGE(!filter.IsRelevantAndUpdate(tx), "Simple Bloom filter matched CO
} │
next prev up bitcoin/src/blockencodings.cpp:49 │ dogecoin/src/blockencodings.cpp:50
│
if (cmpctblock.header.IsNull() || (cmpctblock.shorttxids.empty() && cmpctblock.prefi │ if (cmpctblock.header.IsNull() || (cmpctblock.shorttxids.empty() && cmpctblock.prefi
return READ_STATUS_INVALID; │ return READ_STATUS_INVALID;
if (cmpctblock.shorttxids.size() + cmpctblock.prefilledtxn.size() > MAX_BLOCK_WEIGHT │ if (cmpctblock.shorttxids.size() + cmpctblock.prefilledtxn.size() > MAX_BLOCK_BASE_S
return READ_STATUS_INVALID; │ return READ_STATUS_INVALID;
│
assert(header.IsNull() && txn_available.empty()); │ assert(header.IsNull() && txn_available.empty());
header = cmpctblock.header; │ header = cmpctblock.header;
txn_available.resize(cmpctblock.BlockTxCount()); │ txn_available.resize(cmpctblock.BlockTxCount());
│
int32_t lastprefilledindex = -1; │ int32_t lastprefilledindex = -1;
for (size_t i = 0; i < cmpctblock.prefilledtxn.size(); i++) { │ for (size_t i = 0; i < cmpctblock.prefilledtxn.size(); i++) {
if (cmpctblock.prefilledtxn[i].tx->IsNull()) │ if (cmpctblock.prefilledtxn[i].tx->IsNull())
return READ_STATUS_INVALID; │ return READ_STATUS_INVALID;
│
lastprefilledindex += cmpctblock.prefilledtxn[i].index + 1; //index is a uint16_ │ lastprefilledindex += cmpctblock.prefilledtxn[i].index + 1; //index is a uint16_
if (lastprefilledindex > std::numeric_limits<uint16_t>::max()) │ if (lastprefilledindex > std::numeric_limits<uint16_t>::max())
return READ_STATUS_INVALID; │ return READ_STATUS_INVALID;
if ((uint32_t)lastprefilledindex > cmpctblock.shorttxids.size() + i) { │ if ((uint32_t)lastprefilledindex > cmpctblock.shorttxids.size() + i) {
// If we are inserting a tx at an index greater than our full list of shortt │ // If we are inserting a tx at an index greater than our full list of shortt
// plus the number of prefilled txn we've inserted, then we have txn for whi │ // plus the number of prefilled txn we've inserted, then we have txn for whi
// have neither a prefilled txn or a shorttxid! │ // have neither a prefilled txn or a shorttxid!
return READ_STATUS_INVALID; │ return READ_STATUS_INVALID;
} │ }
txn_available[lastprefilledindex] = cmpctblock.prefilledtxn[i].tx; │ txn_available[lastprefilledindex] = cmpctblock.prefilledtxn[i].tx;
} │ }
prefilled_count = cmpctblock.prefilledtxn.size(); │ prefilled_count = cmpctblock.prefilledtxn.size();
│
// Calculate map of txids -> positions and check mempool to see what we have (or don │ // Calculate map of txids -> positions and check mempool to see what we have (or don
// Because well-formed cmpctblock messages will have a (relatively) uniform distribu │ // Because well-formed cmpctblock messages will have a (relatively) uniform distribu
// of short IDs, any highly-uneven distribution of elements can be safely treated as │ // of short IDs, any highly-uneven distribution of elements can be safely treated as
// READ_STATUS_FAILED. │ // READ_STATUS_FAILED.
std::unordered_map<uint64_t, uint16_t> shorttxids(cmpctblock.shorttxids.size()); │ std::unordered_map<uint64_t, uint16_t> shorttxids(cmpctblock.shorttxids.size());
uint16_t index_offset = 0; │ uint16_t index_offset = 0;
for (size_t i = 0; i < cmpctblock.shorttxids.size(); i++) { │ for (size_t i = 0; i < cmpctblock.shorttxids.size(); i++) {
while (txn_available[i + index_offset]) │ while (txn_available[i + index_offset])
index_offset++; │ index_offset++;
shorttxids[cmpctblock.shorttxids[i]] = i + index_offset; │ shorttxids[cmpctblock.shorttxids[i]] = i + index_offset;
// To determine the chance that the number of entries in a bucket exceeds N, │ // To determine the chance that the number of entries in a bucket exceeds N,
// we use the fact that the number of elements in a single bucket is │ // we use the fact that the number of elements in a single bucket is
// binomially distributed (with n = the number of shorttxids S, and p = │ // binomially distributed (with n = the number of shorttxids S, and p =
// 1 / the number of buckets), that in the worst case the number of buckets is │ // 1 / the number of buckets), that in the worst case the number of buckets is
// equal to S (due to std::unordered_map having a default load factor of 1.0), │ // equal to S (due to std::unordered_map having a default load factor of 1.0),
// and that the chance for any bucket to exceed N elements is at most │ // and that the chance for any bucket to exceed N elements is at most
// buckets * (the chance that any given bucket is above N elements). │ // buckets * (the chance that any given bucket is above N elements).
// Thus: P(max_elements_per_bucket > N) <= S * (1 - cdf(binomial(n=S,p=1/S), N)) │ // Thus: P(max_elements_per_bucket > N) <= S * (1 - cdf(binomial(n=S,p=1/S), N))
// If we assume blocks of up to 16000, allowing 12 elements per bucket should │ // If we assume blocks of up to 16000, allowing 12 elements per bucket should
// only fail once per ~1 million block transfers (per peer and connection). │ // only fail once per ~1 million block transfers (per peer and connection).
if (shorttxids.bucket_size(shorttxids.bucket(cmpctblock.shorttxids[i])) > 12) │ if (shorttxids.bucket_size(shorttxids.bucket(cmpctblock.shorttxids[i])) > 12)
return READ_STATUS_FAILED; │ return READ_STATUS_FAILED;
} │ }
// TODO: in the shortid-collision case, we should instead request both transactions │ // TODO: in the shortid-collision case, we should instead request both transactions
// which collided. Falling back to full-block-request here is overkill. │ // which collided. Falling back to full-block-request here is overkill.
if (shorttxids.size() != cmpctblock.shorttxids.size()) │ if (shorttxids.size() != cmpctblock.shorttxids.size())
return READ_STATUS_FAILED; // Short ID collision │ return READ_STATUS_FAILED; // Short ID collision
│
std::vector<bool> have_txn(txn_available.size()); │ std::vector<bool> have_txn(txn_available.size());
{ │ {
LOCK(pool->cs); │ LOCK(pool->cs);
for (size_t i = 0; i < pool->vTxHashes.size(); i++) { │ const std::vector<std::pair<uint256, CTxMemPool::txiter> >& vTxHashes = pool->vTxHas
uint64_t shortid = cmpctblock.GetShortID(pool->vTxHashes[i].first); │ for (size_t i = 0; i < vTxHashes.size(); i++) {
│ uint64_t shortid = cmpctblock.GetShortID(vTxHashes[i].first);
std::unordered_map<uint64_t, uint16_t>::iterator idit = shorttxids.find(shortid) │ std::unordered_map<uint64_t, uint16_t>::iterator idit = shorttxids.find(shortid)
if (idit != shorttxids.end()) { │ if (idit != shorttxids.end()) {
if (!have_txn[idit->second]) { │ if (!have_txn[idit->second]) {
txn_available[idit->second] = pool->vTxHashes[i].second->GetSharedTx(); │ txn_available[idit->second] = vTxHashes[i].second->GetSharedTx();
have_txn[idit->second] = true; │ have_txn[idit->second] = true;
mempool_count++; │ mempool_count++;
} else { │ } else {
// If we find two mempool txn that match the short id, just request it. │ // If we find two mempool txn that match the short id, just request it.
// This should be rare enough that the extra bandwidth doesn't matter, │ // This should be rare enough that the extra bandwidth doesn't matter,
// but eating a round-trip due to FillBlock failure would be annoying │ // but eating a round-trip due to FillBlock failure would be annoying
if (txn_available[idit->second]) { │ if (txn_available[idit->second]) {
txn_available[idit->second].reset(); │ txn_available[idit->second].reset();
mempool_count--; │ mempool_count--;
} │ }
} │ }
} │ }
// Though ideally we'd continue scanning for the two-txn-match-shortid case, │ // Though ideally we'd continue scanning for the two-txn-match-shortid case,
// the performance win of an early exit here is too good to pass up and worth │ // the performance win of an early exit here is too good to pass up and worth
// the extra risk. │ // the extra risk.
if (mempool_count == shorttxids.size()) │ if (mempool_count == shorttxids.size())
break; │ break;
} │ }
} │ }
│
for (size_t i = 0; i < extra_txn.size(); i++) { │ for (size_t i = 0; i < extra_txn.size(); i++) {
uint64_t shortid = cmpctblock.GetShortID(extra_txn[i].first); │ uint64_t shortid = cmpctblock.GetShortID(extra_txn[i].first);
std::unordered_map<uint64_t, uint16_t>::iterator idit = shorttxids.find(shortid) │ std::unordered_map<uint64_t, uint16_t>::iterator idit = shorttxids.find(shortid)
if (idit != shorttxids.end()) { │ if (idit != shorttxids.end()) {
if (!have_txn[idit->second]) { │ if (!have_txn[idit->second]) {
txn_available[idit->second] = extra_txn[i].second; │ txn_available[idit->second] = extra_txn[i].second;
have_txn[idit->second] = true; │ have_txn[idit->second] = true;
mempool_count++; │ mempool_count++;
extra_count++; │ extra_count++;
} else { │ } else {
// If we find two mempool/extra txn that match the short id, just │ // If we find two mempool/extra txn that match the short id, just
// request it. │ // request it.
// This should be rare enough that the extra bandwidth doesn't matter, │ // This should be rare enough that the extra bandwidth doesn't matter,
// but eating a round-trip due to FillBlock failure would be annoying │ // but eating a round-trip due to FillBlock failure would be annoying
// Note that we don't want duplication between extra_txn and mempool to │ // Note that we dont want duplication between extra_txn and mempool to
// trigger this case, so we compare witness hashes first │ // trigger this case, so we compare witness hashes first
if (txn_available[idit->second] && │ if (txn_available[idit->second] &&
txn_available[idit->second]->GetWitnessHash() != extra_txn[i].se │ txn_available[idit->second]->GetWitnessHash() != extra_txn[i].se
txn_available[idit->second].reset(); │ txn_available[idit->second].reset();
mempool_count--; │ mempool_count--;
extra_count--; │ extra_count--;
} │ }
} │ }
} │ }
// Though ideally we'd continue scanning for the two-txn-match-shortid case, │ // Though ideally we'd continue scanning for the two-txn-match-shortid case,
// the performance win of an early exit here is too good to pass up and worth │ // the performance win of an early exit here is too good to pass up and worth
// the extra risk. │ // the extra risk.
if (mempool_count == shorttxids.size()) │ if (mempool_count == shorttxids.size())
break; │ break;
} │ }
│
LogPrint(BCLog::CMPCTBLOCK, "Initialized PartiallyDownloadedBlock for block %s using │ LogPrint("cmpctblock", "Initialized PartiallyDownloadedBlock for block %s using a cm
│
return READ_STATUS_OK; │ return READ_STATUS_OK;
} │
next prev up bitcoin/src/net_processing.cpp:3595 │ dogecoin/src/net_processing.cpp:2027
│
LOCK2(cs_main, g_cs_orphans); │ LOCK(cs_main);
// If AcceptBlockHeader returned true, it set pindex │ // If AcceptBlockHeader returned true, it set pindex
assert(pindex); │ assert(pindex);
UpdateBlockAvailability(pfrom.GetId(), pindex->GetBlockHash()); │ UpdateBlockAvailability(pfrom->GetId(), pindex->GetBlockHash());
│
CNodeState *nodestate = State(pfrom.GetId()); │
│
// If this was a new header with more work than our tip, update the │
// peer's last block announcement time │
if (received_new_header && pindex->nChainWork > m_chainman.ActiveChain().Tip()-> │
nodestate->m_last_block_announcement = GetTime(); │
} │
│
std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator> >::iterato │ std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator> >::iterato
bool fAlreadyInFlight = blockInFlightIt != mapBlocksInFlight.end(); │ bool fAlreadyInFlight = blockInFlightIt != mapBlocksInFlight.end();
│
if (pindex->nStatus & BLOCK_HAVE_DATA) // Nothing to do here │ if (pindex->nStatus & BLOCK_HAVE_DATA) // Nothing to do here
return; │ return true;
│
if (pindex->nChainWork <= m_chainman.ActiveChain().Tip()->nChainWork || // We kn │ if (pindex->nChainWork <= chainActive.Tip()->nChainWork || // We know something
pindex->nTx != 0) { // We had this block at some point, but pruned it │ pindex->nTx != 0) { // We had this block at some point, but pruned it
if (fAlreadyInFlight) { │ if (fAlreadyInFlight) {
// We requested this block for some reason, but our mempool will probabl │ // We requested this block for some reason, but our mempool will probabl
// so we just grab the block via normal getdata │ // so we just grab the block via normal getdata
std::vector<CInv> vInv(1); │ std::vector<CInv> vInv(1);
vInv[0] = CInv(MSG_BLOCK | GetFetchFlags(pfrom), cmpctblock.header.GetHa │ vInv[0] = CInv(MSG_BLOCK | GetFetchFlags(pfrom, pindex->pprev, chainpara
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::GETDATA, vInv)); │ connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::GETDATA, vInv));
} │ }
return; │ return true;
} │ }
│
// If we're not close to tip yet, give up and let parallel block fetch work its │ // If we're not close to tip yet, give up and let parallel block fetch work its
if (!fAlreadyInFlight && !CanDirectFetch()) { │ if (!fAlreadyInFlight && !CanDirectFetch(chainparams.GetConsensus(pindex->pprev-
return; │ return true;
} │
│ CNodeState *nodestate = State(pfrom->GetId());
│
if (DeploymentActiveAt(*pindex, m_chainparams.GetConsensus(), Consensus::DEPLOYM │ if (IsWitnessEnabled(pindex->pprev, chainparams.GetConsensus(pindex->pprev->nHei
// Don't bother trying to process compact blocks from v1 peers │ // Don't bother trying to process compact blocks from v1 peers
// after segwit activates. │ // after segwit activates.
return; │ return true;
} │ }
│
// We want to be a bit conservative just to be extra careful about DoS │ // We want to be a bit conservative just to be extra careful about DoS
// possibilities in compact block processing... │ // possibilities in compact block processing...
if (pindex->nHeight <= m_chainman.ActiveChain().Height() + 2) { │ if (pindex->nHeight <= chainActive.Height() + 2) {
if ((!fAlreadyInFlight && nodestate->nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT │ if ((!fAlreadyInFlight && nodestate->nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT
(fAlreadyInFlight && blockInFlightIt->second.first == pfrom.GetId())) { │ (fAlreadyInFlight && blockInFlightIt->second.first == pfrom->GetId()))
std::list<QueuedBlock>::iterator* queuedBlockIt = nullptr; │ std::list<QueuedBlock>::iterator* queuedBlockIt = NULL;
if (!BlockRequested(pfrom.GetId(), *pindex, &queuedBlockIt)) { │ if (!MarkBlockAsInFlight(pfrom->GetId(), pindex->GetBlockHash(), chainpa
if (!(*queuedBlockIt)->partialBlock) │ if (!(*queuedBlockIt)->partialBlock)
(*queuedBlockIt)->partialBlock.reset(new PartiallyDownloadedBloc │ (*queuedBlockIt)->partialBlock.reset(new PartiallyDownloadedBloc
else { │ else {
// The block was already in flight using compact blocks from the │ // The block was already in flight using compact blocks from the
LogPrint(BCLog::NET, "Peer sent us compact block we were already │ LogPrint("net", "Peer sent us compact block we were already sync
return; │ return true;
} │ }
} │ }
│
PartiallyDownloadedBlock& partialBlock = *(*queuedBlockIt)->partialBlock │ PartiallyDownloadedBlock& partialBlock = *(*queuedBlockIt)->partialBlock
ReadStatus status = partialBlock.InitData(cmpctblock, vExtraTxnForCompac │ ReadStatus status = partialBlock.InitData(cmpctblock, vExtraTxnForCompac
if (status == READ_STATUS_INVALID) { │ if (status == READ_STATUS_INVALID) {
RemoveBlockRequest(pindex->GetBlockHash()); // Reset in-flight state │ MarkBlockAsReceived(pindex->GetBlockHash()); // Reset in-flight stat
Misbehaving(pfrom.GetId(), 100, "invalid compact block"); │ Misbehaving(pfrom->GetId(), 100);
return; │ LogPrintf("Peer %d sent us invalid compact block\n", pfrom->id);
│ return true;
} else if (status == READ_STATUS_FAILED) { │ } else if (status == READ_STATUS_FAILED) {
// Duplicate txindexes, the block is now in-flight, so just request │ // Duplicate txindexes, the block is now in-flight, so just request
std::vector<CInv> vInv(1); │ std::vector<CInv> vInv(1);
vInv[0] = CInv(MSG_BLOCK | GetFetchFlags(pfrom), cmpctblock.header.G │ vInv[0] = CInv(MSG_BLOCK | GetFetchFlags(pfrom, pindex->pprev, chain
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::GETDATA, vIn │ connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::GETDATA, vInv))
return; │ return true;
} │ }
│
BlockTransactionsRequest req; │ BlockTransactionsRequest req;
for (size_t i = 0; i < cmpctblock.BlockTxCount(); i++) { │ for (size_t i = 0; i < cmpctblock.BlockTxCount(); i++) {
if (!partialBlock.IsTxAvailable(i)) │ if (!partialBlock.IsTxAvailable(i))
req.indexes.push_back(i); │ req.indexes.push_back(i);
} │ }
if (req.indexes.empty()) { │ if (req.indexes.empty()) {
// Dirty hack to jump to BLOCKTXN code (TODO: move message handling │ // Dirty hack to jump to BLOCKTXN code (TODO: move message handling
BlockTransactions txn; │ BlockTransactions txn;
txn.blockhash = cmpctblock.header.GetHash(); │ txn.blockhash = cmpctblock.header.GetHash();
blockTxnMsg << txn; │ blockTxnMsg << txn;
fProcessBLOCKTXN = true; │ fProcessBLOCKTXN = true;
} else { │ } else {
req.blockhash = pindex->GetBlockHash(); │ req.blockhash = pindex->GetBlockHash();
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::GETBLOCKTXN, │ connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::GETBLOCKTXN, re
} │ }
} else { │ } else {
// This block is either already in flight from a different │ // This block is either already in flight from a different
// peer, or this peer has too many blocks outstanding to │ // peer, or this peer has too many blocks outstanding to
// download from. │ // download from.
// Optimistically try to reconstruct anyway since we might be │ // Optimistically try to reconstruct anyway since we might be
// able to without any round trips. │ // able to without any round trips.
PartiallyDownloadedBlock tempBlock(&m_mempool); │ PartiallyDownloadedBlock tempBlock(&mempool);
ReadStatus status = tempBlock.InitData(cmpctblock, vExtraTxnForCompact); │ ReadStatus status = tempBlock.InitData(cmpctblock, vExtraTxnForCompact);
if (status != READ_STATUS_OK) { │ if (status != READ_STATUS_OK) {
// TODO: don't ignore failures │ // TODO: don't ignore failures
return; │ return true;
} │ }
std::vector<CTransactionRef> dummy; │ std::vector<CTransactionRef> dummy;
status = tempBlock.FillBlock(*pblock, dummy); │ status = tempBlock.FillBlock(*pblock, dummy);
if (status == READ_STATUS_OK) { │ if (status == READ_STATUS_OK) {
fBlockReconstructed = true; │ fBlockReconstructed = true;
} │ }
} │ }
} else { │ } else {
if (fAlreadyInFlight) { │ if (fAlreadyInFlight) {
// We requested this block, but its far into the future, so our │ // We requested this block, but its far into the future, so our
// mempool will probably be useless - request the block normally │ // mempool will probably be useless - request the block normally
std::vector<CInv> vInv(1); │ std::vector<CInv> vInv(1);
vInv[0] = CInv(MSG_BLOCK | GetFetchFlags(pfrom), cmpctblock.header.GetHa │ vInv[0] = CInv(MSG_BLOCK | GetFetchFlags(pfrom, pindex->pprev, chainpara
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::GETDATA, vInv)); │ connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::GETDATA, vInv));
return; │ return true;
} else { │ } else {
// If this was an announce-cmpctblock, we want the same treatment as a h │ // If this was an announce-cmpctblock, we want the same treatment as a h
│ // Dirty hack to process as if it were just a headers message (TODO: mov
│ std::vector<CBlock> headers;
│ headers.push_back(cmpctblock.header);
│ vHeadersMsg << headers;
fRevertToHeaderProcessing = true; │ fRevertToHeaderProcessing = true;
} │ }
} │ }
} │
next prev up dogecoin/src/test/bloom_tests.cpp:420 │ bitcoin/src/test/bloom_tests.cpp:399
│
// Random real block (000000000000b731f2eef9e8c63173adfb07e41bd53eb0ef0a6b720d6cb6de │ // Random real block (000000000000b731f2eef9e8c63173adfb07e41bd53eb0ef0a6b720d6cb6de
// With 7 txes │ // With 7 txes
CBlock block; │ CBlock block;
CDataStream stream(ParseHex("0100000082bb869cf3a793432a66e826e05a6fc37469f8efb7421dc │ CDataStream stream(ParseHex("0100000082bb869cf3a793432a66e826e05a6fc37469f8efb7421dc
stream >> block; │ stream >> block;
│
CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_P2PUBKEY_ONLY); │ CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_P2PUBKEY_ONLY);
// Match the generation pubkey │ // Match the generation pubkey
filter.insert(ParseHex("04eaafc2314def4ca98ac970241bcab022b9c1e1f4ea423a20f134c876f2 │ filter.insert(ParseHex("04eaafc2314def4ca98ac970241bcab022b9c1e1f4ea423a20f134c876f2
// ...and the output address of the 4th transaction │ // ...and the output address of the 4th transaction
filter.insert(ParseHex("b6efd80d99179f4f4ff6f4dd0a007d018c385d21")); │ filter.insert(ParseHex("b6efd80d99179f4f4ff6f4dd0a007d018c385d21"));
│
CMerkleBlock merkleBlock(block, filter); │ CMerkleBlock merkleBlock(block, filter);
BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); │ BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());
│
// We should match the generation outpoint │ // We should match the generation outpoint
BOOST_CHECK(filter.contains(COutPoint(uint256S("0x147caa76786596590baa4e98f5d9f48b86 │ BOOST_CHECK(filter.contains(COutPoint(uint256S("0x147caa76786596590baa4e98f5d9f48b86
// ... but not the 4th transaction's output (its not pay-2-pubkey) │ // ... but not the 4th transaction's output (its not pay-2-pubkey)
BOOST_CHECK(!filter.contains(COutPoint(uint256S("0x02981fa052f0481dbc5868f4fc2166035 │ BOOST_CHECK(!filter.contains(COutPoint(uint256S("0x02981fa052f0481dbc5868f4fc2166035
} │
next prev up dogecoin/src/qt/rpcconsole.cpp:207 │ bitcoin/src/qt/rpcconsole.cpp:231
│
case STATE_COMMAND_EXECUTED_INNER: │ case STATE_COMMAND_EXECUTED_INNER:
case STATE_COMMAND_EXECUTED: │ case STATE_COMMAND_EXECUTED:
{ │ {
bool breakParsing = true; │ bool breakParsing = true;
switch(ch) │ switch(ch)
{ │ {
case '[': curarg.clear(); state = STATE_COMMAND_EXECUTED_INNER; brea │ case '[': curarg.clear(); state = STATE_COMMAND_EXECUTED_INNER; brea
default: │ default:
if (state == STATE_COMMAND_EXECUTED_INNER) │ if (state == STATE_COMMAND_EXECUTED_INNER)
{ │ {
if (ch != ']') │ if (ch != ']')
{ │ {
// append char to the current argument (which is also us │ // append char to the current argument (which is also us
curarg += ch; │ curarg += ch;
break; │ break;
} │ }
if (curarg.size() && fExecute) │ if (curarg.size() && fExecute)
{ │ {
// if we have a value query, query arrays with index and │ // if we have a value query, query arrays with index and
UniValue subelement; │ UniValue subelement;
if (lastResult.isArray()) │ if (lastResult.isArray())
{ │ {
for(char argch: curarg) │ const auto parsed{ToIntegral<size_t>(curarg)};
if (!std::isdigit(argch)) │ if (!parsed) {
throw std::runtime_error("Invalid result que │ throw std::runtime_error("Invalid result query")
subelement = lastResult[atoi(curarg.c_str())]; │ }
│ subelement = lastResult[parsed.value()];
} │ }
else if (lastResult.isObject()) │ else if (lastResult.isObject())
subelement = find_value(lastResult, curarg); │ subelement = find_value(lastResult, curarg);
else │ else
throw std::runtime_error("Invalid result query"); // │ throw std::runtime_error("Invalid result query"); //
lastResult = subelement; │ lastResult = subelement;
} │ }
│
state = STATE_COMMAND_EXECUTED; │ state = STATE_COMMAND_EXECUTED;
break; │ break;
} │ }
// don't break parsing when the char is required for the next ar │ // don't break parsing when the char is required for the next ar
breakParsing = false; │ breakParsing = false;
│
// pop the stack and return the result to the current command ar │ // pop the stack and return the result to the current command ar
close_out_params(); │ close_out_params();
│
// don't stringify the json in case of a string to avoid doubleq │ // don't stringify the json in case of a string to avoid doubleq
if (lastResult.isStr()) │ if (lastResult.isStr())
curarg = lastResult.get_str(); │ curarg = lastResult.get_str();
else │ else
curarg = lastResult.write(2); │ curarg = lastResult.write(2);
│
// if we have a non empty result, use it as stack argument other │ // if we have a non empty result, use it as stack argument other
if (curarg.size()) │ if (curarg.size())
{ │ {
if (stack.size()) │ if (stack.size())
add_to_current_stack(curarg); │ add_to_current_stack(curarg);
else │ else
strResult = curarg; │ strResult = curarg;
} │ }
curarg.clear(); │ curarg.clear();
// assume eating space state │ // assume eating space state
state = STATE_EATING_SPACES; │ state = STATE_EATING_SPACES;
} │ }
if (breakParsing) │ if (breakParsing)
break; │ break;
│ [[fallthrough]];
} │ }
// Falls through │
case STATE_ARGUMENT: // In or after argument │ case STATE_ARGUMENT: // In or after argument
case STATE_EATING_SPACES_IN_ARG: │ case STATE_EATING_SPACES_IN_ARG:
case STATE_EATING_SPACES_IN_BRACKETS: │ case STATE_EATING_SPACES_IN_BRACKETS:
case STATE_EATING_SPACES: // Handle runs of whitespace │ case STATE_EATING_SPACES: // Handle runs of whitespace
switch(ch) │ switch(ch)
{ │ {
case '"': state = STATE_DOUBLEQUOTED; break; │ case '"': state = STATE_DOUBLEQUOTED; break;
case '\'': state = STATE_SINGLEQUOTED; break; │ case '\'': state = STATE_SINGLEQUOTED; break;
case '\\': state = STATE_ESCAPE_OUTER; break; │ case '\\': state = STATE_ESCAPE_OUTER; break;
case '(': case ')': case '\n': │ case '(': case ')': case '\n':
if (state == STATE_EATING_SPACES_IN_ARG) │ if (state == STATE_EATING_SPACES_IN_ARG)
throw std::runtime_error("Invalid Syntax"); │ throw std::runtime_error("Invalid Syntax");
if (state == STATE_ARGUMENT) │ if (state == STATE_ARGUMENT)
{ │ {
if (ch == '(' && stack.size() && stack.back().size() > 0) │ if (ch == '(' && stack.size() && stack.back().size() > 0)
{ │ {
if (nDepthInsideSensitive) { │ if (nDepthInsideSensitive) {
++nDepthInsideSensitive; │ ++nDepthInsideSensitive;
} │ }
stack.push_back(std::vector<std::string>()); │ stack.push_back(std::vector<std::string>());
} │ }
│
// don't allow commands after executed commands on baselevel │ // don't allow commands after executed commands on baselevel
if (!stack.size()) │ if (!stack.size())
throw std::runtime_error("Invalid Syntax"); │ throw std::runtime_error("Invalid Syntax");
│
add_to_current_stack(curarg); │ add_to_current_stack(curarg);
curarg.clear(); │ curarg.clear();
state = STATE_EATING_SPACES_IN_BRACKETS; │ state = STATE_EATING_SPACES_IN_BRACKETS;
} │ }
if ((ch == ')' || ch == '\n') && stack.size() > 0) │ if ((ch == ')' || ch == '\n') && stack.size() > 0)
{ │ {
if (fExecute) { │ if (fExecute) {
// Convert argument list to JSON objects in method-dependent │ // Convert argument list to JSON objects in method-dependent
// and pass it along with the method name to the dispatcher. │ // and pass it along with the method name to the dispatcher.
JSONRPCRequest req; │ UniValue params = RPCConvertValues(stack.back()[0], std::vec
req.params = RPCConvertValues(stack.back()[0], std::vector<s │ std::string method = stack.back()[0];
req.strMethod = stack.back()[0]; │ std::string uri;
lastResult = tableRPC.execute(req); │ #ifdef ENABLE_WALLET
│ if (wallet_model) {
│ QByteArray encodedName = QUrl::toPercentEncoding(wallet_
│ uri = "/wallet/"+std::string(encodedName.constData(), en
│ }
│ #endif
│ assert(node);
│ lastResult = node->executeRpc(method, params, uri);
} │ }
│
state = STATE_COMMAND_EXECUTED; │ state = STATE_COMMAND_EXECUTED;
curarg.clear(); │ curarg.clear();
} │ }
break; │ break;
case ' ': case ',': case '\t': │ case ' ': case ',': case '\t':
if(state == STATE_EATING_SPACES_IN_ARG && curarg.empty() && ch == ', │ if(state == STATE_EATING_SPACES_IN_ARG && curarg.empty() && ch == ',
throw std::runtime_error("Invalid Syntax"); │ throw std::runtime_error("Invalid Syntax");
│
else if(state == STATE_ARGUMENT) // Space ends argument │ else if(state == STATE_ARGUMENT) // Space ends argument
{ │ {
add_to_current_stack(curarg); │ add_to_current_stack(curarg);
curarg.clear(); │ curarg.clear();
} │ }
if ((state == STATE_EATING_SPACES_IN_BRACKETS || state == STATE_ARGU │ if ((state == STATE_EATING_SPACES_IN_BRACKETS || state == STATE_ARGU
{ │ {
state = STATE_EATING_SPACES_IN_ARG; │ state = STATE_EATING_SPACES_IN_ARG;
break; │ break;
} │ }
state = STATE_EATING_SPACES; │ state = STATE_EATING_SPACES;
break; │ break;
default: curarg += ch; state = STATE_ARGUMENT; │ default: curarg += ch; state = STATE_ARGUMENT;
} │
next prev up bitcoin/src/test/bloom_tests.cpp:422 │ bitcoin/src/test/bloom_tests.cpp:399
│
// Random real block (000000000000b731f2eef9e8c63173adfb07e41bd53eb0ef0a6b720d6cb6de │ // Random real block (000000000000b731f2eef9e8c63173adfb07e41bd53eb0ef0a6b720d6cb6de
// With 7 txes │ // With 7 txes
CBlock block; │ CBlock block;
CDataStream stream(ParseHex("0100000082bb869cf3a793432a66e826e05a6fc37469f8efb7421dc │ CDataStream stream(ParseHex("0100000082bb869cf3a793432a66e826e05a6fc37469f8efb7421dc
stream >> block; │ stream >> block;
│
CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_NONE); │ CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_P2PUBKEY_ONLY);
// Match the generation pubkey │ // Match the generation pubkey
filter.insert(ParseHex("04eaafc2314def4ca98ac970241bcab022b9c1e1f4ea423a20f134c876f2 │ filter.insert(ParseHex("04eaafc2314def4ca98ac970241bcab022b9c1e1f4ea423a20f134c876f2
// ...and the output address of the 4th transaction │ // ...and the output address of the 4th transaction
filter.insert(ParseHex("b6efd80d99179f4f4ff6f4dd0a007d018c385d21")); │ filter.insert(ParseHex("b6efd80d99179f4f4ff6f4dd0a007d018c385d21"));
│
CMerkleBlock merkleBlock(block, filter); │ CMerkleBlock merkleBlock(block, filter);
BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); │ BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());
│
// We shouldn't match any outpoints (UPDATE_NONE) │ // We should match the generation outpoint
BOOST_CHECK(!filter.contains(COutPoint(uint256S("0x147caa76786596590baa4e98f5d9f48b8 │ BOOST_CHECK(filter.contains(COutPoint(uint256S("0x147caa76786596590baa4e98f5d9f48b86
│ // ... but not the 4th transaction's output (its not pay-2-pubkey)
BOOST_CHECK(!filter.contains(COutPoint(uint256S("0x02981fa052f0481dbc5868f4fc2166035 │ BOOST_CHECK(!filter.contains(COutPoint(uint256S("0x02981fa052f0481dbc5868f4fc2166035
} │
next prev up dogecoin/src/test/bloom_tests.cpp:443 │ bitcoin/src/test/bloom_tests.cpp:399
│
// Random real block (000000000000b731f2eef9e8c63173adfb07e41bd53eb0ef0a6b720d6cb6de │ // Random real block (000000000000b731f2eef9e8c63173adfb07e41bd53eb0ef0a6b720d6cb6de
// With 7 txes │ // With 7 txes
CBlock block; │ CBlock block;
CDataStream stream(ParseHex("0100000082bb869cf3a793432a66e826e05a6fc37469f8efb7421dc │ CDataStream stream(ParseHex("0100000082bb869cf3a793432a66e826e05a6fc37469f8efb7421dc
stream >> block; │ stream >> block;
│
CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_NONE); │ CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_P2PUBKEY_ONLY);
// Match the generation pubkey │ // Match the generation pubkey
filter.insert(ParseHex("04eaafc2314def4ca98ac970241bcab022b9c1e1f4ea423a20f134c876f2 │ filter.insert(ParseHex("04eaafc2314def4ca98ac970241bcab022b9c1e1f4ea423a20f134c876f2
// ...and the output address of the 4th transaction │ // ...and the output address of the 4th transaction
filter.insert(ParseHex("b6efd80d99179f4f4ff6f4dd0a007d018c385d21")); │ filter.insert(ParseHex("b6efd80d99179f4f4ff6f4dd0a007d018c385d21"));
│
CMerkleBlock merkleBlock(block, filter); │ CMerkleBlock merkleBlock(block, filter);
BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); │ BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());
│
// We shouldn't match any outpoints (UPDATE_NONE) │ // We should match the generation outpoint
BOOST_CHECK(!filter.contains(COutPoint(uint256S("0x147caa76786596590baa4e98f5d9f48b8 │ BOOST_CHECK(filter.contains(COutPoint(uint256S("0x147caa76786596590baa4e98f5d9f48b86
│ // ... but not the 4th transaction's output (its not pay-2-pubkey)
BOOST_CHECK(!filter.contains(COutPoint(uint256S("0x02981fa052f0481dbc5868f4fc2166035 │ BOOST_CHECK(!filter.contains(COutPoint(uint256S("0x02981fa052f0481dbc5868f4fc2166035
} │
next prev up bitcoin/src/test/bloom_tests.cpp:422 │ dogecoin/src/test/bloom_tests.cpp:420
│
// Random real block (000000000000b731f2eef9e8c63173adfb07e41bd53eb0ef0a6b720d6cb6de │ // Random real block (000000000000b731f2eef9e8c63173adfb07e41bd53eb0ef0a6b720d6cb6de
// With 7 txes │ // With 7 txes
CBlock block; │ CBlock block;
CDataStream stream(ParseHex("0100000082bb869cf3a793432a66e826e05a6fc37469f8efb7421dc │ CDataStream stream(ParseHex("0100000082bb869cf3a793432a66e826e05a6fc37469f8efb7421dc
stream >> block; │ stream >> block;
│
CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_NONE); │ CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_P2PUBKEY_ONLY);
// Match the generation pubkey │ // Match the generation pubkey
filter.insert(ParseHex("04eaafc2314def4ca98ac970241bcab022b9c1e1f4ea423a20f134c876f2 │ filter.insert(ParseHex("04eaafc2314def4ca98ac970241bcab022b9c1e1f4ea423a20f134c876f2
// ...and the output address of the 4th transaction │ // ...and the output address of the 4th transaction
filter.insert(ParseHex("b6efd80d99179f4f4ff6f4dd0a007d018c385d21")); │ filter.insert(ParseHex("b6efd80d99179f4f4ff6f4dd0a007d018c385d21"));
│
CMerkleBlock merkleBlock(block, filter); │ CMerkleBlock merkleBlock(block, filter);
BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); │ BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());
│
// We shouldn't match any outpoints (UPDATE_NONE) │ // We should match the generation outpoint
BOOST_CHECK(!filter.contains(COutPoint(uint256S("0x147caa76786596590baa4e98f5d9f48b8 │ BOOST_CHECK(filter.contains(COutPoint(uint256S("0x147caa76786596590baa4e98f5d9f48b86
│ // ... but not the 4th transaction's output (its not pay-2-pubkey)
BOOST_CHECK(!filter.contains(COutPoint(uint256S("0x02981fa052f0481dbc5868f4fc2166035 │ BOOST_CHECK(!filter.contains(COutPoint(uint256S("0x02981fa052f0481dbc5868f4fc2166035
} │
next prev up dogecoin/src/test/bloom_tests.cpp:443 │ dogecoin/src/test/bloom_tests.cpp:420
│
// Random real block (000000000000b731f2eef9e8c63173adfb07e41bd53eb0ef0a6b720d6cb6de │ // Random real block (000000000000b731f2eef9e8c63173adfb07e41bd53eb0ef0a6b720d6cb6de
// With 7 txes │ // With 7 txes
CBlock block; │ CBlock block;
CDataStream stream(ParseHex("0100000082bb869cf3a793432a66e826e05a6fc37469f8efb7421dc │ CDataStream stream(ParseHex("0100000082bb869cf3a793432a66e826e05a6fc37469f8efb7421dc
stream >> block; │ stream >> block;
│
CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_NONE); │ CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_P2PUBKEY_ONLY);
// Match the generation pubkey │ // Match the generation pubkey
filter.insert(ParseHex("04eaafc2314def4ca98ac970241bcab022b9c1e1f4ea423a20f134c876f2 │ filter.insert(ParseHex("04eaafc2314def4ca98ac970241bcab022b9c1e1f4ea423a20f134c876f2
// ...and the output address of the 4th transaction │ // ...and the output address of the 4th transaction
filter.insert(ParseHex("b6efd80d99179f4f4ff6f4dd0a007d018c385d21")); │ filter.insert(ParseHex("b6efd80d99179f4f4ff6f4dd0a007d018c385d21"));
│
CMerkleBlock merkleBlock(block, filter); │ CMerkleBlock merkleBlock(block, filter);
BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); │ BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());
│
// We shouldn't match any outpoints (UPDATE_NONE) │ // We should match the generation outpoint
BOOST_CHECK(!filter.contains(COutPoint(uint256S("0x147caa76786596590baa4e98f5d9f48b8 │ BOOST_CHECK(filter.contains(COutPoint(uint256S("0x147caa76786596590baa4e98f5d9f48b86
│ // ... but not the 4th transaction's output (its not pay-2-pubkey)
BOOST_CHECK(!filter.contains(COutPoint(uint256S("0x02981fa052f0481dbc5868f4fc2166035 │ BOOST_CHECK(!filter.contains(COutPoint(uint256S("0x02981fa052f0481dbc5868f4fc2166035
} │
next prev up dogecoin/src/test/bloom_tests.cpp:443 │ bitcoin/src/test/bloom_tests.cpp:422
│
// Random real block (000000000000b731f2eef9e8c63173adfb07e41bd53eb0ef0a6b720d6cb6de │ // Random real block (000000000000b731f2eef9e8c63173adfb07e41bd53eb0ef0a6b720d6cb6de
// With 7 txes │ // With 7 txes
CBlock block; │ CBlock block;
CDataStream stream(ParseHex("0100000082bb869cf3a793432a66e826e05a6fc37469f8efb7421dc │ CDataStream stream(ParseHex("0100000082bb869cf3a793432a66e826e05a6fc37469f8efb7421dc
stream >> block; │ stream >> block;
│
CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_NONE); │ CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_NONE);
// Match the generation pubkey │ // Match the generation pubkey
filter.insert(ParseHex("04eaafc2314def4ca98ac970241bcab022b9c1e1f4ea423a20f134c876f2 │ filter.insert(ParseHex("04eaafc2314def4ca98ac970241bcab022b9c1e1f4ea423a20f134c876f2
// ...and the output address of the 4th transaction │ // ...and the output address of the 4th transaction
filter.insert(ParseHex("b6efd80d99179f4f4ff6f4dd0a007d018c385d21")); │ filter.insert(ParseHex("b6efd80d99179f4f4ff6f4dd0a007d018c385d21"));
│
CMerkleBlock merkleBlock(block, filter); │ CMerkleBlock merkleBlock(block, filter);
BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); │ BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());
│
// We shouldn't match any outpoints (UPDATE_NONE) │ // We shouldn't match any outpoints (UPDATE_NONE)
BOOST_CHECK(!filter.contains(COutPoint(uint256S("0x147caa76786596590baa4e98f5d9f48b8 │ BOOST_CHECK(!filter.contains(COutPoint(uint256S("0x147caa76786596590baa4e98f5d9f48b8
BOOST_CHECK(!filter.contains(COutPoint(uint256S("0x02981fa052f0481dbc5868f4fc2166035 │ BOOST_CHECK(!filter.contains(COutPoint(uint256S("0x02981fa052f0481dbc5868f4fc2166035
} │
next prev up dogecoin/src/test/arith_uint256_tests.cpp:413 │ bitcoin/src/test/arith_uint256_tests.cpp:407
│
arith_uint256 num; │ arith_uint256 num;
bool fNegative; │ bool fNegative;
bool fOverflow; │ bool fOverflow;
num.SetCompact(0, &fNegative, &fOverflow); │ num.SetCompact(0, &fNegative, &fOverflow);
BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000 │ BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000
BOOST_CHECK_EQUAL(num.GetCompact(), 0U); │ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
BOOST_CHECK_EQUAL(fNegative, false); │ BOOST_CHECK_EQUAL(fNegative, false);
BOOST_CHECK_EQUAL(fOverflow, false); │ BOOST_CHECK_EQUAL(fOverflow, false);
│
num.SetCompact(0x00123456, &fNegative, &fOverflow); │ num.SetCompact(0x00123456, &fNegative, &fOverflow);
BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000 │ BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000
BOOST_CHECK_EQUAL(num.GetCompact(), 0U); │ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
BOOST_CHECK_EQUAL(fNegative, false); │ BOOST_CHECK_EQUAL(fNegative, false);
BOOST_CHECK_EQUAL(fOverflow, false); │ BOOST_CHECK_EQUAL(fOverflow, false);
│
num.SetCompact(0x01003456, &fNegative, &fOverflow); │ num.SetCompact(0x01003456, &fNegative, &fOverflow);
BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000 │ BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000
BOOST_CHECK_EQUAL(num.GetCompact(), 0U); │ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
BOOST_CHECK_EQUAL(fNegative, false); │ BOOST_CHECK_EQUAL(fNegative, false);
BOOST_CHECK_EQUAL(fOverflow, false); │ BOOST_CHECK_EQUAL(fOverflow, false);
│
num.SetCompact(0x02000056, &fNegative, &fOverflow); │ num.SetCompact(0x02000056, &fNegative, &fOverflow);
BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000 │ BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000
BOOST_CHECK_EQUAL(num.GetCompact(), 0U); │ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
BOOST_CHECK_EQUAL(fNegative, false); │ BOOST_CHECK_EQUAL(fNegative, false);
BOOST_CHECK_EQUAL(fOverflow, false); │ BOOST_CHECK_EQUAL(fOverflow, false);
│
num.SetCompact(0x03000000, &fNegative, &fOverflow); │ num.SetCompact(0x03000000, &fNegative, &fOverflow);
BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000 │ BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000
BOOST_CHECK_EQUAL(num.GetCompact(), 0U); │ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
BOOST_CHECK_EQUAL(fNegative, false); │ BOOST_CHECK_EQUAL(fNegative, false);
BOOST_CHECK_EQUAL(fOverflow, false); │ BOOST_CHECK_EQUAL(fOverflow, false);
│
num.SetCompact(0x04000000, &fNegative, &fOverflow); │ num.SetCompact(0x04000000, &fNegative, &fOverflow);
BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000 │ BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000
BOOST_CHECK_EQUAL(num.GetCompact(), 0U); │ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
BOOST_CHECK_EQUAL(fNegative, false); │ BOOST_CHECK_EQUAL(fNegative, false);
BOOST_CHECK_EQUAL(fOverflow, false); │ BOOST_CHECK_EQUAL(fOverflow, false);
│
num.SetCompact(0x00923456, &fNegative, &fOverflow); │ num.SetCompact(0x00923456, &fNegative, &fOverflow);
BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000 │ BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000
BOOST_CHECK_EQUAL(num.GetCompact(), 0U); │ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
BOOST_CHECK_EQUAL(fNegative, false); │ BOOST_CHECK_EQUAL(fNegative, false);
BOOST_CHECK_EQUAL(fOverflow, false); │ BOOST_CHECK_EQUAL(fOverflow, false);
│
num.SetCompact(0x01803456, &fNegative, &fOverflow); │ num.SetCompact(0x01803456, &fNegative, &fOverflow);
BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000 │ BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000
BOOST_CHECK_EQUAL(num.GetCompact(), 0U); │ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
BOOST_CHECK_EQUAL(fNegative, false); │ BOOST_CHECK_EQUAL(fNegative, false);
BOOST_CHECK_EQUAL(fOverflow, false); │ BOOST_CHECK_EQUAL(fOverflow, false);
│
num.SetCompact(0x02800056, &fNegative, &fOverflow); │ num.SetCompact(0x02800056, &fNegative, &fOverflow);
BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000 │ BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000
BOOST_CHECK_EQUAL(num.GetCompact(), 0U); │ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
BOOST_CHECK_EQUAL(fNegative, false); │ BOOST_CHECK_EQUAL(fNegative, false);
BOOST_CHECK_EQUAL(fOverflow, false); │ BOOST_CHECK_EQUAL(fOverflow, false);
│
num.SetCompact(0x03800000, &fNegative, &fOverflow); │ num.SetCompact(0x03800000, &fNegative, &fOverflow);
BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000 │ BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000
BOOST_CHECK_EQUAL(num.GetCompact(), 0U); │ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
BOOST_CHECK_EQUAL(fNegative, false); │ BOOST_CHECK_EQUAL(fNegative, false);
BOOST_CHECK_EQUAL(fOverflow, false); │ BOOST_CHECK_EQUAL(fOverflow, false);
│
num.SetCompact(0x04800000, &fNegative, &fOverflow); │ num.SetCompact(0x04800000, &fNegative, &fOverflow);
BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000 │ BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000
BOOST_CHECK_EQUAL(num.GetCompact(), 0U); │ BOOST_CHECK_EQUAL(num.GetCompact(), 0U);
BOOST_CHECK_EQUAL(fNegative, false); │ BOOST_CHECK_EQUAL(fNegative, false);
BOOST_CHECK_EQUAL(fOverflow, false); │ BOOST_CHECK_EQUAL(fOverflow, false);
│
num.SetCompact(0x01123456, &fNegative, &fOverflow); │ num.SetCompact(0x01123456, &fNegative, &fOverflow);
BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000 │ BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000
BOOST_CHECK_EQUAL(num.GetCompact(), 0x01120000U); │ BOOST_CHECK_EQUAL(num.GetCompact(), 0x01120000U);
BOOST_CHECK_EQUAL(fNegative, false); │ BOOST_CHECK_EQUAL(fNegative, false);
BOOST_CHECK_EQUAL(fOverflow, false); │ BOOST_CHECK_EQUAL(fOverflow, false);
│
// Make sure that we don't generate compacts with the 0x00800000 bit set │ // Make sure that we don't generate compacts with the 0x00800000 bit set
num = 0x80; │ num = 0x80;
BOOST_CHECK_EQUAL(num.GetCompact(), 0x02008000U); │ BOOST_CHECK_EQUAL(num.GetCompact(), 0x02008000U);
│
num.SetCompact(0x01fedcba, &fNegative, &fOverflow); │ num.SetCompact(0x01fedcba, &fNegative, &fOverflow);
BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000 │ BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000
BOOST_CHECK_EQUAL(num.GetCompact(true), 0x01fe0000U); │ BOOST_CHECK_EQUAL(num.GetCompact(true), 0x01fe0000U);
BOOST_CHECK_EQUAL(fNegative, true); │ BOOST_CHECK_EQUAL(fNegative, true);
BOOST_CHECK_EQUAL(fOverflow, false); │ BOOST_CHECK_EQUAL(fOverflow, false);
│
num.SetCompact(0x02123456, &fNegative, &fOverflow); │ num.SetCompact(0x02123456, &fNegative, &fOverflow);
BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000 │ BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000
BOOST_CHECK_EQUAL(num.GetCompact(), 0x02123400U); │ BOOST_CHECK_EQUAL(num.GetCompact(), 0x02123400U);
BOOST_CHECK_EQUAL(fNegative, false); │ BOOST_CHECK_EQUAL(fNegative, false);
BOOST_CHECK_EQUAL(fOverflow, false); │ BOOST_CHECK_EQUAL(fOverflow, false);
│
num.SetCompact(0x03123456, &fNegative, &fOverflow); │ num.SetCompact(0x03123456, &fNegative, &fOverflow);
BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000 │ BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000
BOOST_CHECK_EQUAL(num.GetCompact(), 0x03123456U); │ BOOST_CHECK_EQUAL(num.GetCompact(), 0x03123456U);
BOOST_CHECK_EQUAL(fNegative, false); │ BOOST_CHECK_EQUAL(fNegative, false);
BOOST_CHECK_EQUAL(fOverflow, false); │ BOOST_CHECK_EQUAL(fOverflow, false);
│
num.SetCompact(0x04123456, &fNegative, &fOverflow); │ num.SetCompact(0x04123456, &fNegative, &fOverflow);
BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000 │ BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000
BOOST_CHECK_EQUAL(num.GetCompact(), 0x04123456U); │ BOOST_CHECK_EQUAL(num.GetCompact(), 0x04123456U);
BOOST_CHECK_EQUAL(fNegative, false); │ BOOST_CHECK_EQUAL(fNegative, false);
BOOST_CHECK_EQUAL(fOverflow, false); │ BOOST_CHECK_EQUAL(fOverflow, false);
│
num.SetCompact(0x04923456, &fNegative, &fOverflow); │ num.SetCompact(0x04923456, &fNegative, &fOverflow);
BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000 │ BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000
BOOST_CHECK_EQUAL(num.GetCompact(true), 0x04923456U); │ BOOST_CHECK_EQUAL(num.GetCompact(true), 0x04923456U);
BOOST_CHECK_EQUAL(fNegative, true); │ BOOST_CHECK_EQUAL(fNegative, true);
BOOST_CHECK_EQUAL(fOverflow, false); │ BOOST_CHECK_EQUAL(fOverflow, false);
│
num.SetCompact(0x05009234, &fNegative, &fOverflow); │ num.SetCompact(0x05009234, &fNegative, &fOverflow);
BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000 │ BOOST_CHECK_EQUAL(num.GetHex(), "000000000000000000000000000000000000000000000000000
BOOST_CHECK_EQUAL(num.GetCompact(), 0x05009234U); │ BOOST_CHECK_EQUAL(num.GetCompact(), 0x05009234U);
BOOST_CHECK_EQUAL(fNegative, false); │ BOOST_CHECK_EQUAL(fNegative, false);
BOOST_CHECK_EQUAL(fOverflow, false); │ BOOST_CHECK_EQUAL(fOverflow, false);
│
num.SetCompact(0x20123456, &fNegative, &fOverflow); │ num.SetCompact(0x20123456, &fNegative, &fOverflow);
BOOST_CHECK_EQUAL(num.GetHex(), "123456000000000000000000000000000000000000000000000 │ BOOST_CHECK_EQUAL(num.GetHex(), "123456000000000000000000000000000000000000000000000
BOOST_CHECK_EQUAL(num.GetCompact(), 0x20123456U); │ BOOST_CHECK_EQUAL(num.GetCompact(), 0x20123456U);
BOOST_CHECK_EQUAL(fNegative, false); │ BOOST_CHECK_EQUAL(fNegative, false);
BOOST_CHECK_EQUAL(fOverflow, false); │ BOOST_CHECK_EQUAL(fOverflow, false);
│
num.SetCompact(0xff123456, &fNegative, &fOverflow); │ num.SetCompact(0xff123456, &fNegative, &fOverflow);
BOOST_CHECK_EQUAL(fNegative, false); │ BOOST_CHECK_EQUAL(fNegative, false);
BOOST_CHECK_EQUAL(fOverflow, true); │ BOOST_CHECK_EQUAL(fOverflow, true);
} │
next prev up bitcoin/src/qt/coincontroldialog.cpp:581 │ dogecoin/src/qt/coincontroldialog.cpp:636
│
if (!model || !model->getOptionsModel() || !model->getAddressTableModel()) │ if (!model || !model->getOptionsModel() || !model->getAddressTableModel())
return; │ return;
│
bool treeMode = ui->radioTreeMode->isChecked(); │ bool treeMode = ui->radioTreeMode->isChecked();
│
ui->treeWidget->clear(); │ ui->treeWidget->clear();
ui->treeWidget->setEnabled(false); // performance, otherwise updateLabels would be c │ ui->treeWidget->setEnabled(false); // performance, otherwise updateLabels would be c
ui->treeWidget->setAlternatingRowColors(!treeMode); │ ui->treeWidget->setAlternatingRowColors(!treeMode);
QFlags<Qt::ItemFlag> flgCheckbox = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::It │ QFlags<Qt::ItemFlag> flgCheckbox = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::It
QFlags<Qt::ItemFlag> flgTristate = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::It │ QFlags<Qt::ItemFlag> flgTristate = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::It
│
BitcoinUnit nDisplayUnit = model->getOptionsModel()->getDisplayUnit(); │ int nDisplayUnit = model->getOptionsModel()->getDisplayUnit();
│
for (const auto& coins : model->wallet().listCoins()) { │ std::map<QString, std::vector<COutput> > mapCoins;
CCoinControlWidgetItem* itemWalletAddress{nullptr}; │ model->listCoins(mapCoins);
QString sWalletAddress = QString::fromStdString(EncodeDestination(coins.first)); │
│ BOOST_FOREACH(const PAIRTYPE(QString, std::vector<COutput>)& coins, mapCoins) {
│ CCoinControlWidgetItem *itemWalletAddress = new CCoinControlWidgetItem();
│ itemWalletAddress->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked);
│ QString sWalletAddress = coins.first;
QString sWalletLabel = model->getAddressTableModel()->labelForAddress(sWalletAdd │ QString sWalletLabel = model->getAddressTableModel()->labelForAddress(sWalletAdd
if (sWalletLabel.isEmpty()) │ if (sWalletLabel.isEmpty())
sWalletLabel = tr("(no label)"); │ sWalletLabel = tr("(no label)");
│
if (treeMode) │ if (treeMode)
{ │ {
// wallet address │ // wallet address
itemWalletAddress = new CCoinControlWidgetItem(ui->treeWidget); │ ui->treeWidget->addTopLevelItem(itemWalletAddress);
│
itemWalletAddress->setFlags(flgTristate); │ itemWalletAddress->setFlags(flgTristate);
itemWalletAddress->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked); │ itemWalletAddress->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked);
│
// label │ // label
itemWalletAddress->setText(COLUMN_LABEL, sWalletLabel); │ itemWalletAddress->setText(COLUMN_LABEL, sWalletLabel);
│
// address │ // address
itemWalletAddress->setText(COLUMN_ADDRESS, sWalletAddress); │ itemWalletAddress->setText(COLUMN_ADDRESS, sWalletAddress);
} │ }
│
CAmount nSum = 0; │ CAmount nSum = 0;
int nChildren = 0; │ int nChildren = 0;
for (const auto& outpair : coins.second) { │ BOOST_FOREACH(const COutput& out, coins.second) {
const COutPoint& output = std::get<0>(outpair); │ nSum += out.tx->tx->vout[out.i].nValue;
const interfaces::WalletTxOut& out = std::get<1>(outpair); │
nSum += out.txout.nValue; │
nChildren++; │ nChildren++;
│
CCoinControlWidgetItem *itemOutput; │ CCoinControlWidgetItem *itemOutput;
if (treeMode) itemOutput = new CCoinControlWidgetItem(itemWalletAddress); │ if (treeMode) itemOutput = new CCoinControlWidgetItem(itemWalletAddress);
else itemOutput = new CCoinControlWidgetItem(ui->treeWidget); │ else itemOutput = new CCoinControlWidgetItem(ui->treeWidget);
itemOutput->setFlags(flgCheckbox); │ itemOutput->setFlags(flgCheckbox);
itemOutput->setCheckState(COLUMN_CHECKBOX,Qt::Unchecked); │ itemOutput->setCheckState(COLUMN_CHECKBOX,Qt::Unchecked);
│
// address │ // address
CTxDestination outputAddress; │ CTxDestination outputAddress;
QString sAddress = ""; │ QString sAddress = "";
if(ExtractDestination(out.txout.scriptPubKey, outputAddress)) │ if(ExtractDestination(out.tx->tx->vout[out.i].scriptPubKey, outputAddress))
{ │ {
sAddress = QString::fromStdString(EncodeDestination(outputAddress)); │ sAddress = QString::fromStdString(CBitcoinAddress(outputAddress).ToStrin
│
// if listMode or change => show bitcoin address. In tree mode, address │ // if listMode or change => show bitcoin address. In tree mode, address
if (!treeMode || (!(sAddress == sWalletAddress))) │ if (!treeMode || (!(sAddress == sWalletAddress)))
itemOutput->setText(COLUMN_ADDRESS, sAddress); │ itemOutput->setText(COLUMN_ADDRESS, sAddress);
} │ }
│
// label │ // label
if (!(sAddress == sWalletAddress)) // change │ if (!(sAddress == sWalletAddress)) // change
{ │ {
// tooltip from where the change comes from │ // tooltip from where the change comes from
itemOutput->setToolTip(COLUMN_LABEL, tr("change from %1 (%2)").arg(sWall │ itemOutput->setToolTip(COLUMN_LABEL, tr("change from %1 (%2)").arg(sWall
itemOutput->setText(COLUMN_LABEL, tr("(change)")); │ itemOutput->setText(COLUMN_LABEL, tr("(change)"));
} │ }
else if (!treeMode) │ else if (!treeMode)
{ │ {
QString sLabel = model->getAddressTableModel()->labelForAddress(sAddress │ QString sLabel = model->getAddressTableModel()->labelForAddress(sAddress
if (sLabel.isEmpty()) │ if (sLabel.isEmpty())
sLabel = tr("(no label)"); │ sLabel = tr("(no label)");
itemOutput->setText(COLUMN_LABEL, sLabel); │ itemOutput->setText(COLUMN_LABEL, sLabel);
} │ }
│
// amount │ // amount
itemOutput->setText(COLUMN_AMOUNT, BitcoinUnits::format(nDisplayUnit, out.tx │ itemOutput->setText(COLUMN_AMOUNT, BitcoinUnits::format(nDisplayUnit, out.tx
itemOutput->setData(COLUMN_AMOUNT, Qt::UserRole, QVariant((qlonglong)out.txo │ itemOutput->setData(COLUMN_AMOUNT, Qt::UserRole, QVariant((qlonglong)out.tx-
│
// date │ // date
itemOutput->setText(COLUMN_DATE, GUIUtil::dateTimeStr(out.time)); │ itemOutput->setText(COLUMN_DATE, GUIUtil::dateTimeStr(out.tx->GetTxTime()));
itemOutput->setData(COLUMN_DATE, Qt::UserRole, QVariant((qlonglong)out.time) │ itemOutput->setData(COLUMN_DATE, Qt::UserRole, QVariant((qlonglong)out.tx->G
│
// confirmations │ // confirmations
itemOutput->setText(COLUMN_CONFIRMATIONS, QString::number(out.depth_in_main_ │ itemOutput->setText(COLUMN_CONFIRMATIONS, QString::number(out.nDepth));
itemOutput->setData(COLUMN_CONFIRMATIONS, Qt::UserRole, QVariant((qlonglong) │ itemOutput->setData(COLUMN_CONFIRMATIONS, Qt::UserRole, QVariant((qlonglong)
│
// transaction hash │ // transaction hash
itemOutput->setData(COLUMN_ADDRESS, TxHashRole, QString::fromStdString(outpu │ uint256 txhash = out.tx->GetHash();
│ itemOutput->setText(COLUMN_TXHASH, QString::fromStdString(txhash.GetHex()));
│
// vout index │ // vout index
itemOutput->setData(COLUMN_ADDRESS, VOutRole, output.n); │ itemOutput->setText(COLUMN_VOUT_INDEX, QString::number(out.i));
│
// disable locked coins │ // disable locked coins
if (model->wallet().isLockedCoin(output)) │ if (model->isLockedCoin(txhash, out.i))
{ │ {
m_coin_control.UnSelect(output); // just to be sure │ COutPoint outpt(txhash, out.i);
│ coinControl->UnSelect(outpt); // just to be sure
itemOutput->setDisabled(true); │ itemOutput->setDisabled(true);
itemOutput->setIcon(COLUMN_CHECKBOX, platformStyle->SingleColorIcon(":/i │ itemOutput->setIcon(COLUMN_CHECKBOX, platformStyle->SingleColorIcon(":/i
} │ }
│
// set checkbox │ // set checkbox
if (m_coin_control.IsSelected(output)) │ if (coinControl->IsSelected(COutPoint(txhash, out.i)))
itemOutput->setCheckState(COLUMN_CHECKBOX, Qt::Checked); │ itemOutput->setCheckState(COLUMN_CHECKBOX, Qt::Checked);
} │ }
│
// amount │ // amount
if (treeMode) │ if (treeMode)
{ │ {
itemWalletAddress->setText(COLUMN_CHECKBOX, "(" + QString::number(nChildren) │ itemWalletAddress->setText(COLUMN_CHECKBOX, "(" + QString::number(nChildren)
itemWalletAddress->setText(COLUMN_AMOUNT, BitcoinUnits::format(nDisplayUnit, │ itemWalletAddress->setText(COLUMN_AMOUNT, BitcoinUnits::format(nDisplayUnit,
itemWalletAddress->setData(COLUMN_AMOUNT, Qt::UserRole, QVariant((qlonglong) │ itemWalletAddress->setData(COLUMN_AMOUNT, Qt::UserRole, QVariant((qlonglong)
} │ }
} │ }
│
// expand all partially selected │ // expand all partially selected
if (treeMode) │ if (treeMode)
{ │ {
for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++) │ for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++)
if (ui->treeWidget->topLevelItem(i)->checkState(COLUMN_CHECKBOX) == Qt::Part │ if (ui->treeWidget->topLevelItem(i)->checkState(COLUMN_CHECKBOX) == Qt::Part
ui->treeWidget->topLevelItem(i)->setExpanded(true); │ ui->treeWidget->topLevelItem(i)->setExpanded(true);
} │ }
│
// sort view │ // sort view
sortView(sortColumn, sortOrder); │ sortView(sortColumn, sortOrder);
ui->treeWidget->setEnabled(true); │ ui->treeWidget->setEnabled(true);
} │
next prev up dogecoin/src/test/bloom_tests.cpp:228 │ bitcoin/src/test/bloom_tests.cpp:210
│
// Random real block (000000005a4ded781e667e06ceefafb71410b511fe0d5adc3e5a27ecbec34a │ // Random real block (000000005a4ded781e667e06ceefafb71410b511fe0d5adc3e5a27ecbec34a
// With 4 txes │ // With 4 txes
CBlock block; │ CBlock block;
CDataStream stream(ParseHex("0100000075616236cc2126035fadb38deb65b9102cc2c41c09cdf29 │ CDataStream stream(ParseHex("0100000075616236cc2126035fadb38deb65b9102cc2c41c09cdf29
stream >> block; │ stream >> block;
│
CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_ALL); │ CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
// Match the first transaction │ // Match the first transaction
filter.insert(uint256S("0xe980fe9f792d014e73b95203dc1335c5f9ce19ac537a419e6df5b47aec │ filter.insert(uint256S("0xe980fe9f792d014e73b95203dc1335c5f9ce19ac537a419e6df5b47aec
│
CMerkleBlock merkleBlock(block, filter); │ CMerkleBlock merkleBlock(block, filter);
BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); │ BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());
│
BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 1); │ BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 1);
std::pair<unsigned int, uint256> pair = merkleBlock.vMatchedTxn[0]; │ std::pair<unsigned int, uint256> pair = merkleBlock.vMatchedTxn[0];
│
BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0xe980fe9f792d014e73b9520 │ BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0xe980fe9f792d014e73b9520
BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 0); │ BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 0);
│
std::vector<uint256> vMatched; │ std::vector<uint256> vMatched;
std::vector<unsigned int> vIndex; │ std::vector<unsigned int> vIndex;
BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot │ BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot
BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size()); │ BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size());
for (unsigned int i = 0; i < vMatched.size(); i++) │ for (unsigned int i = 0; i < vMatched.size(); i++)
BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second); │ BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second);
│
// Match an output from the second transaction (the pubkey for address 1DZTzaBHUDM7T │ // Match an output from the second transaction (the pubkey for address 1DZTzaBHUDM7T
// This should match the third transaction because it spends the output matched │ // This should match the third transaction because it spends the output matched
// It also matches the fourth transaction, which spends to the pubkey again │ // It also matches the fourth transaction, which spends to the pubkey again
filter.insert(ParseHex("044a656f065871a353f216ca26cef8dde2f03e8c16202d2e8ad769f02032 │ filter.insert(ParseHex("044a656f065871a353f216ca26cef8dde2f03e8c16202d2e8ad769f02032
│
merkleBlock = CMerkleBlock(block, filter); │ merkleBlock = CMerkleBlock(block, filter);
BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); │ BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());
│
BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 4); │ BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 4);
│
BOOST_CHECK(pair == merkleBlock.vMatchedTxn[0]); │ BOOST_CHECK(pair == merkleBlock.vMatchedTxn[0]);
│
BOOST_CHECK(merkleBlock.vMatchedTxn[1].second == uint256S("0x28204cad1d7fc1d199e8ef4 │ BOOST_CHECK(merkleBlock.vMatchedTxn[1].second == uint256S("0x28204cad1d7fc1d199e8ef4
BOOST_CHECK(merkleBlock.vMatchedTxn[1].first == 1); │ BOOST_CHECK(merkleBlock.vMatchedTxn[1].first == 1);
│
BOOST_CHECK(merkleBlock.vMatchedTxn[2].second == uint256S("0x6b0f8a73a56c04b519f1883 │ BOOST_CHECK(merkleBlock.vMatchedTxn[2].second == uint256S("0x6b0f8a73a56c04b519f1883
BOOST_CHECK(merkleBlock.vMatchedTxn[2].first == 2); │ BOOST_CHECK(merkleBlock.vMatchedTxn[2].first == 2);
│
BOOST_CHECK(merkleBlock.vMatchedTxn[3].second == uint256S("0x3c1d7e82342158e4109df2e │ BOOST_CHECK(merkleBlock.vMatchedTxn[3].second == uint256S("0x3c1d7e82342158e4109df2e
BOOST_CHECK(merkleBlock.vMatchedTxn[3].first == 3); │ BOOST_CHECK(merkleBlock.vMatchedTxn[3].first == 3);
│
BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot │ BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot
BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size()); │ BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size());
for (unsigned int i = 0; i < vMatched.size(); i++) │ for (unsigned int i = 0; i < vMatched.size(); i++)
BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second); │ BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second);
} │
next prev up bitcoin/src/test/bloom_tests.cpp:265 │ bitcoin/src/test/bloom_tests.cpp:210
│
// Random real block (000000005a4ded781e667e06ceefafb71410b511fe0d5adc3e5a27ecbec34a │ // Random real block (000000005a4ded781e667e06ceefafb71410b511fe0d5adc3e5a27ecbec34a
// With 4 txes │ // With 4 txes
CBlock block; │ CBlock block;
CDataStream stream(ParseHex("0100000075616236cc2126035fadb38deb65b9102cc2c41c09cdf29 │ CDataStream stream(ParseHex("0100000075616236cc2126035fadb38deb65b9102cc2c41c09cdf29
stream >> block; │ stream >> block;
│
CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_NONE); │ CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
// Match the first transaction │ // Match the first transaction
filter.insert(uint256S("0xe980fe9f792d014e73b95203dc1335c5f9ce19ac537a419e6df5b47aec │ filter.insert(uint256S("0xe980fe9f792d014e73b95203dc1335c5f9ce19ac537a419e6df5b47aec
│
CMerkleBlock merkleBlock(block, filter); │ CMerkleBlock merkleBlock(block, filter);
BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); │ BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());
│
BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 1); │ BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 1);
std::pair<unsigned int, uint256> pair = merkleBlock.vMatchedTxn[0]; │ std::pair<unsigned int, uint256> pair = merkleBlock.vMatchedTxn[0];
│
BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0xe980fe9f792d014e73b9520 │ BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0xe980fe9f792d014e73b9520
BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 0); │ BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 0);
│
std::vector<uint256> vMatched; │ std::vector<uint256> vMatched;
std::vector<unsigned int> vIndex; │ std::vector<unsigned int> vIndex;
BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot │ BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot
BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size()); │ BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size());
for (unsigned int i = 0; i < vMatched.size(); i++) │ for (unsigned int i = 0; i < vMatched.size(); i++)
BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second); │ BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second);
│
// Match an output from the second transaction (the pubkey for address 1DZTzaBHUDM7T │ // Match an output from the second transaction (the pubkey for address 1DZTzaBHUDM7T
// This should not match the third transaction though it spends the output matched │ // This should match the third transaction because it spends the output matched
// It will match the fourth transaction, which has another pay-to-pubkey output to t │ // It also matches the fourth transaction, which spends to the pubkey again
filter.insert(ParseHex("044a656f065871a353f216ca26cef8dde2f03e8c16202d2e8ad769f02032 │ filter.insert(ParseHex("044a656f065871a353f216ca26cef8dde2f03e8c16202d2e8ad769f02032
│
merkleBlock = CMerkleBlock(block, filter); │ merkleBlock = CMerkleBlock(block, filter);
BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); │ BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());
│
BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 3); │ BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 4);
│
BOOST_CHECK(pair == merkleBlock.vMatchedTxn[0]); │ BOOST_CHECK(pair == merkleBlock.vMatchedTxn[0]);
│
BOOST_CHECK(merkleBlock.vMatchedTxn[1].second == uint256S("0x28204cad1d7fc1d199e8ef4 │ BOOST_CHECK(merkleBlock.vMatchedTxn[1].second == uint256S("0x28204cad1d7fc1d199e8ef4
BOOST_CHECK(merkleBlock.vMatchedTxn[1].first == 1); │ BOOST_CHECK(merkleBlock.vMatchedTxn[1].first == 1);
│
BOOST_CHECK(merkleBlock.vMatchedTxn[2].second == uint256S("0x3c1d7e82342158e4109df2e │ BOOST_CHECK(merkleBlock.vMatchedTxn[2].second == uint256S("0x6b0f8a73a56c04b519f1883
BOOST_CHECK(merkleBlock.vMatchedTxn[2].first == 3); │ BOOST_CHECK(merkleBlock.vMatchedTxn[2].first == 2);
│
│ BOOST_CHECK(merkleBlock.vMatchedTxn[3].second == uint256S("0x3c1d7e82342158e4109df2e
│ BOOST_CHECK(merkleBlock.vMatchedTxn[3].first == 3);
│
BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot │ BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot
BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size()); │ BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size());
for (unsigned int i = 0; i < vMatched.size(); i++) │ for (unsigned int i = 0; i < vMatched.size(); i++)
BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second); │ BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second);
} │
next prev up dogecoin/src/test/bloom_tests.cpp:283 │ bitcoin/src/test/bloom_tests.cpp:210
│
// Random real block (000000005a4ded781e667e06ceefafb71410b511fe0d5adc3e5a27ecbec34a │ // Random real block (000000005a4ded781e667e06ceefafb71410b511fe0d5adc3e5a27ecbec34a
// With 4 txes │ // With 4 txes
CBlock block; │ CBlock block;
CDataStream stream(ParseHex("0100000075616236cc2126035fadb38deb65b9102cc2c41c09cdf29 │ CDataStream stream(ParseHex("0100000075616236cc2126035fadb38deb65b9102cc2c41c09cdf29
stream >> block; │ stream >> block;
│
CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_NONE); │ CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
// Match the first transaction │ // Match the first transaction
filter.insert(uint256S("0xe980fe9f792d014e73b95203dc1335c5f9ce19ac537a419e6df5b47aec │ filter.insert(uint256S("0xe980fe9f792d014e73b95203dc1335c5f9ce19ac537a419e6df5b47aec
│
CMerkleBlock merkleBlock(block, filter); │ CMerkleBlock merkleBlock(block, filter);
BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); │ BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());
│
BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 1); │ BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 1);
std::pair<unsigned int, uint256> pair = merkleBlock.vMatchedTxn[0]; │ std::pair<unsigned int, uint256> pair = merkleBlock.vMatchedTxn[0];
│
BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0xe980fe9f792d014e73b9520 │ BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0xe980fe9f792d014e73b9520
BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 0); │ BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 0);
│
std::vector<uint256> vMatched; │ std::vector<uint256> vMatched;
std::vector<unsigned int> vIndex; │ std::vector<unsigned int> vIndex;
BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot │ BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot
BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size()); │ BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size());
for (unsigned int i = 0; i < vMatched.size(); i++) │ for (unsigned int i = 0; i < vMatched.size(); i++)
BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second); │ BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second);
│
// Match an output from the second transaction (the pubkey for address 1DZTzaBHUDM7T │ // Match an output from the second transaction (the pubkey for address 1DZTzaBHUDM7T
// This should not match the third transaction though it spends the output matched │ // This should match the third transaction because it spends the output matched
// It will match the fourth transaction, which has another pay-to-pubkey output to t │ // It also matches the fourth transaction, which spends to the pubkey again
filter.insert(ParseHex("044a656f065871a353f216ca26cef8dde2f03e8c16202d2e8ad769f02032 │ filter.insert(ParseHex("044a656f065871a353f216ca26cef8dde2f03e8c16202d2e8ad769f02032
│
merkleBlock = CMerkleBlock(block, filter); │ merkleBlock = CMerkleBlock(block, filter);
BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); │ BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());
│
BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 3); │ BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 4);
│
BOOST_CHECK(pair == merkleBlock.vMatchedTxn[0]); │ BOOST_CHECK(pair == merkleBlock.vMatchedTxn[0]);
│
BOOST_CHECK(merkleBlock.vMatchedTxn[1].second == uint256S("0x28204cad1d7fc1d199e8ef4 │ BOOST_CHECK(merkleBlock.vMatchedTxn[1].second == uint256S("0x28204cad1d7fc1d199e8ef4
BOOST_CHECK(merkleBlock.vMatchedTxn[1].first == 1); │ BOOST_CHECK(merkleBlock.vMatchedTxn[1].first == 1);
│
BOOST_CHECK(merkleBlock.vMatchedTxn[2].second == uint256S("0x3c1d7e82342158e4109df2e │ BOOST_CHECK(merkleBlock.vMatchedTxn[2].second == uint256S("0x6b0f8a73a56c04b519f1883
BOOST_CHECK(merkleBlock.vMatchedTxn[2].first == 3); │ BOOST_CHECK(merkleBlock.vMatchedTxn[2].first == 2);
│
│ BOOST_CHECK(merkleBlock.vMatchedTxn[3].second == uint256S("0x3c1d7e82342158e4109df2e
│ BOOST_CHECK(merkleBlock.vMatchedTxn[3].first == 3);
│
BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot │ BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot
BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size()); │ BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size());
for (unsigned int i = 0; i < vMatched.size(); i++) │ for (unsigned int i = 0; i < vMatched.size(); i++)
BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second); │ BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second);
} │
next prev up bitcoin/src/test/bloom_tests.cpp:265 │ dogecoin/src/test/bloom_tests.cpp:228
│
// Random real block (000000005a4ded781e667e06ceefafb71410b511fe0d5adc3e5a27ecbec34a │ // Random real block (000000005a4ded781e667e06ceefafb71410b511fe0d5adc3e5a27ecbec34a
// With 4 txes │ // With 4 txes
CBlock block; │ CBlock block;
CDataStream stream(ParseHex("0100000075616236cc2126035fadb38deb65b9102cc2c41c09cdf29 │ CDataStream stream(ParseHex("0100000075616236cc2126035fadb38deb65b9102cc2c41c09cdf29
stream >> block; │ stream >> block;
│
CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_NONE); │ CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
// Match the first transaction │ // Match the first transaction
filter.insert(uint256S("0xe980fe9f792d014e73b95203dc1335c5f9ce19ac537a419e6df5b47aec │ filter.insert(uint256S("0xe980fe9f792d014e73b95203dc1335c5f9ce19ac537a419e6df5b47aec
│
CMerkleBlock merkleBlock(block, filter); │ CMerkleBlock merkleBlock(block, filter);
BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); │ BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());
│
BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 1); │ BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 1);
std::pair<unsigned int, uint256> pair = merkleBlock.vMatchedTxn[0]; │ std::pair<unsigned int, uint256> pair = merkleBlock.vMatchedTxn[0];
│
BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0xe980fe9f792d014e73b9520 │ BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0xe980fe9f792d014e73b9520
BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 0); │ BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 0);
│
std::vector<uint256> vMatched; │ std::vector<uint256> vMatched;
std::vector<unsigned int> vIndex; │ std::vector<unsigned int> vIndex;
BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot │ BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot
BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size()); │ BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size());
for (unsigned int i = 0; i < vMatched.size(); i++) │ for (unsigned int i = 0; i < vMatched.size(); i++)
BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second); │ BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second);
│
// Match an output from the second transaction (the pubkey for address 1DZTzaBHUDM7T │ // Match an output from the second transaction (the pubkey for address 1DZTzaBHUDM7T
// This should not match the third transaction though it spends the output matched │ // This should match the third transaction because it spends the output matched
// It will match the fourth transaction, which has another pay-to-pubkey output to t │ // It also matches the fourth transaction, which spends to the pubkey again
filter.insert(ParseHex("044a656f065871a353f216ca26cef8dde2f03e8c16202d2e8ad769f02032 │ filter.insert(ParseHex("044a656f065871a353f216ca26cef8dde2f03e8c16202d2e8ad769f02032
│
merkleBlock = CMerkleBlock(block, filter); │ merkleBlock = CMerkleBlock(block, filter);
BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); │ BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());
│
BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 3); │ BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 4);
│
BOOST_CHECK(pair == merkleBlock.vMatchedTxn[0]); │ BOOST_CHECK(pair == merkleBlock.vMatchedTxn[0]);
│
BOOST_CHECK(merkleBlock.vMatchedTxn[1].second == uint256S("0x28204cad1d7fc1d199e8ef4 │ BOOST_CHECK(merkleBlock.vMatchedTxn[1].second == uint256S("0x28204cad1d7fc1d199e8ef4
BOOST_CHECK(merkleBlock.vMatchedTxn[1].first == 1); │ BOOST_CHECK(merkleBlock.vMatchedTxn[1].first == 1);
│
BOOST_CHECK(merkleBlock.vMatchedTxn[2].second == uint256S("0x3c1d7e82342158e4109df2e │ BOOST_CHECK(merkleBlock.vMatchedTxn[2].second == uint256S("0x6b0f8a73a56c04b519f1883
BOOST_CHECK(merkleBlock.vMatchedTxn[2].first == 3); │ BOOST_CHECK(merkleBlock.vMatchedTxn[2].first == 2);
│
│ BOOST_CHECK(merkleBlock.vMatchedTxn[3].second == uint256S("0x3c1d7e82342158e4109df2e
│ BOOST_CHECK(merkleBlock.vMatchedTxn[3].first == 3);
│
BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot │ BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot
BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size()); │ BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size());
for (unsigned int i = 0; i < vMatched.size(); i++) │ for (unsigned int i = 0; i < vMatched.size(); i++)
BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second); │ BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second);
} │
next prev up dogecoin/src/test/bloom_tests.cpp:283 │ dogecoin/src/test/bloom_tests.cpp:228
│
// Random real block (000000005a4ded781e667e06ceefafb71410b511fe0d5adc3e5a27ecbec34a │ // Random real block (000000005a4ded781e667e06ceefafb71410b511fe0d5adc3e5a27ecbec34a
// With 4 txes │ // With 4 txes
CBlock block; │ CBlock block;
CDataStream stream(ParseHex("0100000075616236cc2126035fadb38deb65b9102cc2c41c09cdf29 │ CDataStream stream(ParseHex("0100000075616236cc2126035fadb38deb65b9102cc2c41c09cdf29
stream >> block; │ stream >> block;
│
CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_NONE); │ CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
// Match the first transaction │ // Match the first transaction
filter.insert(uint256S("0xe980fe9f792d014e73b95203dc1335c5f9ce19ac537a419e6df5b47aec │ filter.insert(uint256S("0xe980fe9f792d014e73b95203dc1335c5f9ce19ac537a419e6df5b47aec
│
CMerkleBlock merkleBlock(block, filter); │ CMerkleBlock merkleBlock(block, filter);
BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); │ BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());
│
BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 1); │ BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 1);
std::pair<unsigned int, uint256> pair = merkleBlock.vMatchedTxn[0]; │ std::pair<unsigned int, uint256> pair = merkleBlock.vMatchedTxn[0];
│
BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0xe980fe9f792d014e73b9520 │ BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0xe980fe9f792d014e73b9520
BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 0); │ BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 0);
│
std::vector<uint256> vMatched; │ std::vector<uint256> vMatched;
std::vector<unsigned int> vIndex; │ std::vector<unsigned int> vIndex;
BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot │ BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot
BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size()); │ BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size());
for (unsigned int i = 0; i < vMatched.size(); i++) │ for (unsigned int i = 0; i < vMatched.size(); i++)
BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second); │ BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second);
│
// Match an output from the second transaction (the pubkey for address 1DZTzaBHUDM7T │ // Match an output from the second transaction (the pubkey for address 1DZTzaBHUDM7T
// This should not match the third transaction though it spends the output matched │ // This should match the third transaction because it spends the output matched
// It will match the fourth transaction, which has another pay-to-pubkey output to t │ // It also matches the fourth transaction, which spends to the pubkey again
filter.insert(ParseHex("044a656f065871a353f216ca26cef8dde2f03e8c16202d2e8ad769f02032 │ filter.insert(ParseHex("044a656f065871a353f216ca26cef8dde2f03e8c16202d2e8ad769f02032
│
merkleBlock = CMerkleBlock(block, filter); │ merkleBlock = CMerkleBlock(block, filter);
BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); │ BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());
│
BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 3); │ BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 4);
│
BOOST_CHECK(pair == merkleBlock.vMatchedTxn[0]); │ BOOST_CHECK(pair == merkleBlock.vMatchedTxn[0]);
│
BOOST_CHECK(merkleBlock.vMatchedTxn[1].second == uint256S("0x28204cad1d7fc1d199e8ef4 │ BOOST_CHECK(merkleBlock.vMatchedTxn[1].second == uint256S("0x28204cad1d7fc1d199e8ef4
BOOST_CHECK(merkleBlock.vMatchedTxn[1].first == 1); │ BOOST_CHECK(merkleBlock.vMatchedTxn[1].first == 1);
│
BOOST_CHECK(merkleBlock.vMatchedTxn[2].second == uint256S("0x3c1d7e82342158e4109df2e │ BOOST_CHECK(merkleBlock.vMatchedTxn[2].second == uint256S("0x6b0f8a73a56c04b519f1883
BOOST_CHECK(merkleBlock.vMatchedTxn[2].first == 3); │ BOOST_CHECK(merkleBlock.vMatchedTxn[2].first == 2);
│
│ BOOST_CHECK(merkleBlock.vMatchedTxn[3].second == uint256S("0x3c1d7e82342158e4109df2e
│ BOOST_CHECK(merkleBlock.vMatchedTxn[3].first == 3);
│
BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot │ BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot
BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size()); │ BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size());
for (unsigned int i = 0; i < vMatched.size(); i++) │ for (unsigned int i = 0; i < vMatched.size(); i++)
BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second); │ BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second);
} │
next prev up dogecoin/src/test/bloom_tests.cpp:283 │ bitcoin/src/test/bloom_tests.cpp:265
│
// Random real block (000000005a4ded781e667e06ceefafb71410b511fe0d5adc3e5a27ecbec34a │ // Random real block (000000005a4ded781e667e06ceefafb71410b511fe0d5adc3e5a27ecbec34a
// With 4 txes │ // With 4 txes
CBlock block; │ CBlock block;
CDataStream stream(ParseHex("0100000075616236cc2126035fadb38deb65b9102cc2c41c09cdf29 │ CDataStream stream(ParseHex("0100000075616236cc2126035fadb38deb65b9102cc2c41c09cdf29
stream >> block; │ stream >> block;
│
CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_NONE); │ CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_NONE);
// Match the first transaction │ // Match the first transaction
filter.insert(uint256S("0xe980fe9f792d014e73b95203dc1335c5f9ce19ac537a419e6df5b47aec │ filter.insert(uint256S("0xe980fe9f792d014e73b95203dc1335c5f9ce19ac537a419e6df5b47aec
│
CMerkleBlock merkleBlock(block, filter); │ CMerkleBlock merkleBlock(block, filter);
BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); │ BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());
│
BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 1); │ BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 1);
std::pair<unsigned int, uint256> pair = merkleBlock.vMatchedTxn[0]; │ std::pair<unsigned int, uint256> pair = merkleBlock.vMatchedTxn[0];
│
BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0xe980fe9f792d014e73b9520 │ BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0xe980fe9f792d014e73b9520
BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 0); │ BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 0);
│
std::vector<uint256> vMatched; │ std::vector<uint256> vMatched;
std::vector<unsigned int> vIndex; │ std::vector<unsigned int> vIndex;
BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot │ BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot
BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size()); │ BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size());
for (unsigned int i = 0; i < vMatched.size(); i++) │ for (unsigned int i = 0; i < vMatched.size(); i++)
BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second); │ BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second);
│
// Match an output from the second transaction (the pubkey for address 1DZTzaBHUDM7T │ // Match an output from the second transaction (the pubkey for address 1DZTzaBHUDM7T
// This should not match the third transaction though it spends the output matched │ // This should not match the third transaction though it spends the output matched
// It will match the fourth transaction, which has another pay-to-pubkey output to t │ // It will match the fourth transaction, which has another pay-to-pubkey output to t
filter.insert(ParseHex("044a656f065871a353f216ca26cef8dde2f03e8c16202d2e8ad769f02032 │ filter.insert(ParseHex("044a656f065871a353f216ca26cef8dde2f03e8c16202d2e8ad769f02032
│
merkleBlock = CMerkleBlock(block, filter); │ merkleBlock = CMerkleBlock(block, filter);
BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); │ BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());
│
BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 3); │ BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 3);
│
BOOST_CHECK(pair == merkleBlock.vMatchedTxn[0]); │ BOOST_CHECK(pair == merkleBlock.vMatchedTxn[0]);
│
BOOST_CHECK(merkleBlock.vMatchedTxn[1].second == uint256S("0x28204cad1d7fc1d199e8ef4 │ BOOST_CHECK(merkleBlock.vMatchedTxn[1].second == uint256S("0x28204cad1d7fc1d199e8ef4
BOOST_CHECK(merkleBlock.vMatchedTxn[1].first == 1); │ BOOST_CHECK(merkleBlock.vMatchedTxn[1].first == 1);
│
BOOST_CHECK(merkleBlock.vMatchedTxn[2].second == uint256S("0x3c1d7e82342158e4109df2e │ BOOST_CHECK(merkleBlock.vMatchedTxn[2].second == uint256S("0x3c1d7e82342158e4109df2e
BOOST_CHECK(merkleBlock.vMatchedTxn[2].first == 3); │ BOOST_CHECK(merkleBlock.vMatchedTxn[2].first == 3);
│
BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot │ BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot
BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size()); │ BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size());
for (unsigned int i = 0; i < vMatched.size(); i++) │ for (unsigned int i = 0; i < vMatched.size(); i++)
BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second); │ BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second);
} │
next prev up dogecoin/src/univalue/lib/univalue_read.cpp:260 │ bitcoin/src/univalue/lib/univalue_read.cpp:260
│
clear(); │ clear();
│
uint32_t expectMask = 0; │ uint32_t expectMask = 0;
std::vector<UniValue*> stack; │ std::vector<UniValue*> stack;
│
std::string tokenVal; │ std::string tokenVal;
unsigned int consumed; │ unsigned int consumed;
enum jtokentype tok = JTOK_NONE; │ enum jtokentype tok = JTOK_NONE;
enum jtokentype last_tok = JTOK_NONE; │ enum jtokentype last_tok = JTOK_NONE;
const char* end = raw + size; │ const char* end = raw + size;
do { │ do {
last_tok = tok; │ last_tok = tok;
│
tok = getJsonToken(tokenVal, consumed, raw, end); │ tok = getJsonToken(tokenVal, consumed, raw, end);
if (tok == JTOK_NONE || tok == JTOK_ERR) │ if (tok == JTOK_NONE || tok == JTOK_ERR)
return false; │ return false;
raw += consumed; │ raw += consumed;
│
bool isValueOpen = jsonTokenIsValue(tok) || │ bool isValueOpen = jsonTokenIsValue(tok) ||
tok == JTOK_OBJ_OPEN || tok == JTOK_ARR_OPEN; │ tok == JTOK_OBJ_OPEN || tok == JTOK_ARR_OPEN;
│
if (expect(VALUE)) { │ if (expect(VALUE)) {
if (!isValueOpen) │ if (!isValueOpen)
return false; │ return false;
clearExpect(VALUE); │ clearExpect(VALUE);
│
} else if (expect(ARR_VALUE)) { │ } else if (expect(ARR_VALUE)) {
bool isArrValue = isValueOpen || (tok == JTOK_ARR_CLOSE); │ bool isArrValue = isValueOpen || (tok == JTOK_ARR_CLOSE);
if (!isArrValue) │ if (!isArrValue)
return false; │ return false;
│
clearExpect(ARR_VALUE); │ clearExpect(ARR_VALUE);
│
} else if (expect(OBJ_NAME)) { │ } else if (expect(OBJ_NAME)) {
bool isObjName = (tok == JTOK_OBJ_CLOSE || tok == JTOK_STRING); │ bool isObjName = (tok == JTOK_OBJ_CLOSE || tok == JTOK_STRING);
if (!isObjName) │ if (!isObjName)
return false; │ return false;
│
} else if (expect(COLON)) { │ } else if (expect(COLON)) {
if (tok != JTOK_COLON) │ if (tok != JTOK_COLON)
return false; │ return false;
clearExpect(COLON); │ clearExpect(COLON);
│
} else if (!expect(COLON) && (tok == JTOK_COLON)) { │ } else if (!expect(COLON) && (tok == JTOK_COLON)) {
return false; │ return false;
} │ }
│
if (expect(NOT_VALUE)) { │ if (expect(NOT_VALUE)) {
if (isValueOpen) │ if (isValueOpen)
return false; │ return false;
clearExpect(NOT_VALUE); │ clearExpect(NOT_VALUE);
} │ }
│
switch (tok) { │ switch (tok) {
│
case JTOK_OBJ_OPEN: │ case JTOK_OBJ_OPEN:
case JTOK_ARR_OPEN: { │ case JTOK_ARR_OPEN: {
VType utyp = (tok == JTOK_OBJ_OPEN ? VOBJ : VARR); │ VType utyp = (tok == JTOK_OBJ_OPEN ? VOBJ : VARR);
if (!stack.size()) { │ if (!stack.size()) {
if (utyp == VOBJ) │ if (utyp == VOBJ)
setObject(); │ setObject();
else │ else
setArray(); │ setArray();
stack.push_back(this); │ stack.push_back(this);
} else { │ } else {
UniValue tmpVal(utyp); │ UniValue tmpVal(utyp);
UniValue *top = stack.back(); │ UniValue *top = stack.back();
top->values.push_back(tmpVal); │ top->values.push_back(tmpVal);
│
UniValue *newTop = &(top->values.back()); │ UniValue *newTop = &(top->values.back());
stack.push_back(newTop); │ stack.push_back(newTop);
} │ }
│
if (stack.size() > MAX_JSON_DEPTH) │ if (stack.size() > MAX_JSON_DEPTH)
return false; │ return false;
│
if (utyp == VOBJ) │ if (utyp == VOBJ)
setExpect(OBJ_NAME); │ setExpect(OBJ_NAME);
else │ else
setExpect(ARR_VALUE); │ setExpect(ARR_VALUE);
break; │ break;
} │ }
│
case JTOK_OBJ_CLOSE: │ case JTOK_OBJ_CLOSE:
case JTOK_ARR_CLOSE: { │ case JTOK_ARR_CLOSE: {
if (!stack.size() || (last_tok == JTOK_COMMA)) │ if (!stack.size() || (last_tok == JTOK_COMMA))
return false; │ return false;
│
VType utyp = (tok == JTOK_OBJ_CLOSE ? VOBJ : VARR); │ VType utyp = (tok == JTOK_OBJ_CLOSE ? VOBJ : VARR);
UniValue *top = stack.back(); │ UniValue *top = stack.back();
if (utyp != top->getType()) │ if (utyp != top->getType())
return false; │ return false;
│
stack.pop_back(); │ stack.pop_back();
clearExpect(OBJ_NAME); │ clearExpect(OBJ_NAME);
setExpect(NOT_VALUE); │ setExpect(NOT_VALUE);
break; │ break;
} │ }
│
case JTOK_COLON: { │ case JTOK_COLON: {
if (!stack.size()) │ if (!stack.size())
return false; │ return false;
│
UniValue *top = stack.back(); │ UniValue *top = stack.back();
if (top->getType() != VOBJ) │ if (top->getType() != VOBJ)
return false; │ return false;
│
setExpect(VALUE); │ setExpect(VALUE);
break; │ break;
} │ }
│
case JTOK_COMMA: { │ case JTOK_COMMA: {
if (!stack.size() || │ if (!stack.size() ||
(last_tok == JTOK_COMMA) || (last_tok == JTOK_ARR_OPEN)) │ (last_tok == JTOK_COMMA) || (last_tok == JTOK_ARR_OPEN))
return false; │ return false;
│
UniValue *top = stack.back(); │ UniValue *top = stack.back();
if (top->getType() == VOBJ) │ if (top->getType() == VOBJ)
setExpect(OBJ_NAME); │ setExpect(OBJ_NAME);
else │ else
setExpect(ARR_VALUE); │ setExpect(ARR_VALUE);
break; │ break;
} │ }
│
case JTOK_KW_NULL: │ case JTOK_KW_NULL:
case JTOK_KW_TRUE: │ case JTOK_KW_TRUE:
case JTOK_KW_FALSE: { │ case JTOK_KW_FALSE: {
UniValue tmpVal; │ UniValue tmpVal;
switch (tok) { │ switch (tok) {
case JTOK_KW_NULL: │ case JTOK_KW_NULL:
// do nothing more │ // do nothing more
break; │ break;
case JTOK_KW_TRUE: │ case JTOK_KW_TRUE:
tmpVal.setBool(true); │ tmpVal.setBool(true);
break; │ break;
case JTOK_KW_FALSE: │ case JTOK_KW_FALSE:
tmpVal.setBool(false); │ tmpVal.setBool(false);
break; │ break;
default: /* impossible */ break; │ default: /* impossible */ break;
} │ }
│
if (!stack.size()) { │ if (!stack.size()) {
*this = tmpVal; │ *this = tmpVal;
break; │ break;
} │ }
│
UniValue *top = stack.back(); │ UniValue *top = stack.back();
top->values.push_back(tmpVal); │ top->values.push_back(tmpVal);
│
setExpect(NOT_VALUE); │ setExpect(NOT_VALUE);
break; │ break;
} │ }
│
case JTOK_NUMBER: { │ case JTOK_NUMBER: {
UniValue tmpVal(VNUM, tokenVal); │ UniValue tmpVal(VNUM, tokenVal);
if (!stack.size()) { │ if (!stack.size()) {
*this = tmpVal; │ *this = tmpVal;
break; │ break;
} │ }
│
UniValue *top = stack.back(); │ UniValue *top = stack.back();
top->values.push_back(tmpVal); │ top->values.push_back(tmpVal);
│
setExpect(NOT_VALUE); │ setExpect(NOT_VALUE);
break; │ break;
} │ }
│
case JTOK_STRING: { │ case JTOK_STRING: {
if (expect(OBJ_NAME)) { │ if (expect(OBJ_NAME)) {
UniValue *top = stack.back(); │ UniValue *top = stack.back();
top->keys.push_back(tokenVal); │ top->keys.push_back(tokenVal);
clearExpect(OBJ_NAME); │ clearExpect(OBJ_NAME);
setExpect(COLON); │ setExpect(COLON);
} else { │ } else {
UniValue tmpVal(VSTR, tokenVal); │ UniValue tmpVal(VSTR, tokenVal);
if (!stack.size()) { │ if (!stack.size()) {
*this = tmpVal; │ *this = tmpVal;
break; │ break;
} │ }
UniValue *top = stack.back(); │ UniValue *top = stack.back();
top->values.push_back(tmpVal); │ top->values.push_back(tmpVal);
} │ }
│
setExpect(NOT_VALUE); │ setExpect(NOT_VALUE);
break; │ break;
} │ }
│
default: │ default:
return false; │ return false;
} │ }
} while (!stack.empty ()); │ } while (!stack.empty ());
│
/* Check that nothing follows the initial construct (parsed above). */ │ /* Check that nothing follows the initial construct (parsed above). */
tok = getJsonToken(tokenVal, consumed, raw, end); │ tok = getJsonToken(tokenVal, consumed, raw, end);
if (tok != JTOK_NONE) │ if (tok != JTOK_NONE)
return false; │ return false;
│
return true; │ return true;
} │
next prev up dogecoin/src/script/interpreter.cpp:922 │ bitcoin/src/script/interpreter.cpp:1106
│
│ if (sigversion == SigVersion::TAPSCRIPT) return set_error(serror, SC
│
// ([sig ...] num_of_signatures [pubkey ...] num_of_pubkeys -- bool) │ // ([sig ...] num_of_signatures [pubkey ...] num_of_pubkeys -- bool)
│
int i = 1; │ int i = 1;
if ((int)stack.size() < i) │ if ((int)stack.size() < i)
return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); │ return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION);
│
int nKeysCount = CScriptNum(stacktop(-i), fRequireMinimal).getint(); │ int nKeysCount = CScriptNum(stacktop(-i), fRequireMinimal).getint();
if (nKeysCount < 0 || nKeysCount > MAX_PUBKEYS_PER_MULTISIG) │ if (nKeysCount < 0 || nKeysCount > MAX_PUBKEYS_PER_MULTISIG)
return set_error(serror, SCRIPT_ERR_PUBKEY_COUNT); │ return set_error(serror, SCRIPT_ERR_PUBKEY_COUNT);
nOpCount += nKeysCount; │ nOpCount += nKeysCount;
if (nOpCount > MAX_OPS_PER_SCRIPT) │ if (nOpCount > MAX_OPS_PER_SCRIPT)
return set_error(serror, SCRIPT_ERR_OP_COUNT); │ return set_error(serror, SCRIPT_ERR_OP_COUNT);
int ikey = ++i; │ int ikey = ++i;
// ikey2 is the position of last non-signature item in the stack. To │ // ikey2 is the position of last non-signature item in the stack. To
// With SCRIPT_VERIFY_NULLFAIL, this is used for cleanup if operatio │ // With SCRIPT_VERIFY_NULLFAIL, this is used for cleanup if operatio
int ikey2 = nKeysCount + 2; │ int ikey2 = nKeysCount + 2;
i += nKeysCount; │ i += nKeysCount;
if ((int)stack.size() < i) │ if ((int)stack.size() < i)
return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); │ return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION);
│
int nSigsCount = CScriptNum(stacktop(-i), fRequireMinimal).getint(); │ int nSigsCount = CScriptNum(stacktop(-i), fRequireMinimal).getint();
if (nSigsCount < 0 || nSigsCount > nKeysCount) │ if (nSigsCount < 0 || nSigsCount > nKeysCount)
return set_error(serror, SCRIPT_ERR_SIG_COUNT); │ return set_error(serror, SCRIPT_ERR_SIG_COUNT);
int isig = ++i; │ int isig = ++i;
i += nSigsCount; │ i += nSigsCount;
if ((int)stack.size() < i) │ if ((int)stack.size() < i)
return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); │ return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION);
│
// Subset of script starting at the most recent codeseparator │ // Subset of script starting at the most recent codeseparator
CScript scriptCode(pbegincodehash, pend); │ CScript scriptCode(pbegincodehash, pend);
│
// Drop the signature in pre-segwit scripts but not segwit scripts │ // Drop the signature in pre-segwit scripts but not segwit scripts
for (int k = 0; k < nSigsCount; k++) │ for (int k = 0; k < nSigsCount; k++)
{ │ {
valtype& vchSig = stacktop(-isig-k); │ valtype& vchSig = stacktop(-isig-k);
if (sigversion == SIGVERSION_BASE) { │ if (sigversion == SigVersion::BASE) {
scriptCode.FindAndDelete(CScript(vchSig)); │ int found = FindAndDelete(scriptCode, CScript() << vchSig);
│ if (found > 0 && (flags & SCRIPT_VERIFY_CONST_SCRIPTCODE))
│ return set_error(serror, SCRIPT_ERR_SIG_FINDANDDELETE);
} │ }
} │ }
│
bool fSuccess = true; │ bool fSuccess = true;
while (fSuccess && nSigsCount > 0) │ while (fSuccess && nSigsCount > 0)
{ │ {
valtype& vchSig = stacktop(-isig); │ valtype& vchSig = stacktop(-isig);
valtype& vchPubKey = stacktop(-ikey); │ valtype& vchPubKey = stacktop(-ikey);
│
// Note how this makes the exact order of pubkey/signature evalu │ // Note how this makes the exact order of pubkey/signature evalu
// distinguishable by CHECKMULTISIG NOT if the STRICTENC flag is │ // distinguishable by CHECKMULTISIG NOT if the STRICTENC flag is
// See the script_(in)valid tests for details. │ // See the script_(in)valid tests for details.
if (!CheckSignatureEncoding(vchSig, flags, serror) || !CheckPubK │ if (!CheckSignatureEncoding(vchSig, flags, serror) || !CheckPubK
// serror is set │ // serror is set
return false; │ return false;
} │ }
│
// Check signature │ // Check signature
bool fOk = checker.CheckSig(vchSig, vchPubKey, scriptCode, sigve │ bool fOk = checker.CheckECDSASignature(vchSig, vchPubKey, script
│
if (fOk) { │ if (fOk) {
isig++; │ isig++;
nSigsCount--; │ nSigsCount--;
} │ }
ikey++; │ ikey++;
nKeysCount--; │ nKeysCount--;
│
// If there are more signatures left than keys left, │ // If there are more signatures left than keys left,
// then too many signatures have failed. Exit early, │ // then too many signatures have failed. Exit early,
// without checking any further signatures. │ // without checking any further signatures.
if (nSigsCount > nKeysCount) │ if (nSigsCount > nKeysCount)
fSuccess = false; │ fSuccess = false;
} │ }
│
// Clean up stack of actual arguments │ // Clean up stack of actual arguments
while (i-- > 1) { │ while (i-- > 1) {
// If the operation failed, we require that all signatures must │ // If the operation failed, we require that all signatures must
if (!fSuccess && (flags & SCRIPT_VERIFY_NULLFAIL) && !ikey2 && s │ if (!fSuccess && (flags & SCRIPT_VERIFY_NULLFAIL) && !ikey2 && s
return set_error(serror, SCRIPT_ERR_SIG_NULLFAIL); │ return set_error(serror, SCRIPT_ERR_SIG_NULLFAIL);
if (ikey2 > 0) │ if (ikey2 > 0)
ikey2--; │ ikey2--;
popstack(stack); │ popstack(stack);
} │ }
│
// A bug causes CHECKMULTISIG to consume one extra argument │ // A bug causes CHECKMULTISIG to consume one extra argument
// whose contents were not checked in any way. │ // whose contents were not checked in any way.
// │ //
// Unfortunately this is a potential source of mutability, │ // Unfortunately this is a potential source of mutability,
// so optionally verify it is exactly equal to zero prior │ // so optionally verify it is exactly equal to zero prior
// to removing it from the stack. │ // to removing it from the stack.
if (stack.size() < 1) │ if (stack.size() < 1)
return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); │ return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION);
if ((flags & SCRIPT_VERIFY_NULLDUMMY) && stacktop(-1).size()) │ if ((flags & SCRIPT_VERIFY_NULLDUMMY) && stacktop(-1).size())
return set_error(serror, SCRIPT_ERR_SIG_NULLDUMMY); │ return set_error(serror, SCRIPT_ERR_SIG_NULLDUMMY);
popstack(stack); │ popstack(stack);
│
stack.push_back(fSuccess ? vchTrue : vchFalse); │ stack.push_back(fSuccess ? vchTrue : vchFalse);
│
if (opcode == OP_CHECKMULTISIGVERIFY) │ if (opcode == OP_CHECKMULTISIGVERIFY)
{ │ {
if (fSuccess) │ if (fSuccess)
popstack(stack); │ popstack(stack);
else │ else
return set_error(serror, SCRIPT_ERR_CHECKMULTISIGVERIFY); │ return set_error(serror, SCRIPT_ERR_CHECKMULTISIGVERIFY);
} │ }
} │
next prev up dogecoin/src/test/miner_tests.cpp:81 │ bitcoin/src/test/miner_tests.cpp:92
│
// Test the ancestor feerate transaction selection. │ // Test the ancestor feerate transaction selection.
TestMemPoolEntryHelper entry; │ TestMemPoolEntryHelper entry;
│
// Test that a medium fee transaction will be selected after a higher fee │ // Test that a medium fee transaction will be selected after a higher fee
// rate package with a low fee rate parent. │ // rate package with a low fee rate parent.
CMutableTransaction tx; │ CMutableTransaction tx;
tx.vin.resize(1); │ tx.vin.resize(1);
tx.vin[0].scriptSig = CScript() << OP_1; │ tx.vin[0].scriptSig = CScript() << OP_1;
tx.vin[0].prevout.hash = txFirst[0]->GetHash(); │ tx.vin[0].prevout.hash = txFirst[0]->GetHash();
tx.vin[0].prevout.n = 0; │ tx.vin[0].prevout.n = 0;
tx.vout.resize(1); │ tx.vout.resize(1);
tx.vout[0].nValue = 5000000000LL - 1000; │ tx.vout[0].nValue = 5000000000LL - 1000;
// This tx has a low fee: 1000 satoshis │ // This tx has a low fee: 1000 satoshis
uint256 hashParentTx = tx.GetHash(); // save this txid for later use │ uint256 hashParentTx = tx.GetHash(); // save this txid for later use
mempool.addUnchecked(hashParentTx, entry.Fee(1000).Time(GetTime()).SpendsCoinbase(tr │ m_node.mempool->addUnchecked(entry.Fee(1000).Time(GetTime()).SpendsCoinbase(true).Fr
│
// This tx has a medium fee: 10000 satoshis │ // This tx has a medium fee: 10000 satoshis
tx.vin[0].prevout.hash = txFirst[1]->GetHash(); │ tx.vin[0].prevout.hash = txFirst[1]->GetHash();
tx.vout[0].nValue = 5000000000LL - 10000; │ tx.vout[0].nValue = 5000000000LL - 10000;
uint256 hashMediumFeeTx = tx.GetHash(); │ uint256 hashMediumFeeTx = tx.GetHash();
mempool.addUnchecked(hashMediumFeeTx, entry.Fee(10000).Time(GetTime()).SpendsCoinbas │ m_node.mempool->addUnchecked(entry.Fee(10000).Time(GetTime()).SpendsCoinbase(true).F
│
// This tx has a high fee, but depends on the first transaction │ // This tx has a high fee, but depends on the first transaction
tx.vin[0].prevout.hash = hashParentTx; │ tx.vin[0].prevout.hash = hashParentTx;
tx.vout[0].nValue = 5000000000LL - 1000 - 50000; // 50k satoshi fee │ tx.vout[0].nValue = 5000000000LL - 1000 - 50000; // 50k satoshi fee
uint256 hashHighFeeTx = tx.GetHash(); │ uint256 hashHighFeeTx = tx.GetHash();
mempool.addUnchecked(hashHighFeeTx, entry.Fee(50000).Time(GetTime()).SpendsCoinbase( │ m_node.mempool->addUnchecked(entry.Fee(50000).Time(GetTime()).SpendsCoinbase(false).
│
std::unique_ptr<CBlockTemplate> pblocktemplate = BlockAssembler(chainparams).CreateN │ std::unique_ptr<CBlockTemplate> pblocktemplate = AssemblerForTest(chainparams).Creat
│ BOOST_REQUIRE_EQUAL(pblocktemplate->block.vtx.size(), 4U);
BOOST_CHECK(pblocktemplate->block.vtx[1]->GetHash() == hashParentTx); │ BOOST_CHECK(pblocktemplate->block.vtx[1]->GetHash() == hashParentTx);
BOOST_CHECK(pblocktemplate->block.vtx[2]->GetHash() == hashHighFeeTx); │ BOOST_CHECK(pblocktemplate->block.vtx[2]->GetHash() == hashHighFeeTx);
BOOST_CHECK(pblocktemplate->block.vtx[3]->GetHash() == hashMediumFeeTx); │ BOOST_CHECK(pblocktemplate->block.vtx[3]->GetHash() == hashMediumFeeTx);
│
// Test that a package below the block min tx fee doesn't get included │ // Test that a package below the block min tx fee doesn't get included
tx.vin[0].prevout.hash = hashHighFeeTx; │ tx.vin[0].prevout.hash = hashHighFeeTx;
tx.vout[0].nValue = 5000000000LL - 1000 - 50000; // 0 fee │ tx.vout[0].nValue = 5000000000LL - 1000 - 50000; // 0 fee
uint256 hashFreeTx = tx.GetHash(); │ uint256 hashFreeTx = tx.GetHash();
mempool.addUnchecked(hashFreeTx, entry.Fee(0).FromTx(tx)); │ m_node.mempool->addUnchecked(entry.Fee(0).FromTx(tx));
size_t freeTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); │ size_t freeTxSize = ::GetSerializeSize(tx, PROTOCOL_VERSION);
│
// Calculate a fee on child transaction that will put the package just │ // Calculate a fee on child transaction that will put the package just
// below the block min tx fee (assuming 1 child tx of the same size). │ // below the block min tx fee (assuming 1 child tx of the same size).
CAmount feeToUse = blockMinFeeRate.GetFee(2*freeTxSize) - 1; │ CAmount feeToUse = blockMinFeeRate.GetFee(2*freeTxSize) - 1;
│
tx.vin[0].prevout.hash = hashFreeTx; │ tx.vin[0].prevout.hash = hashFreeTx;
tx.vout[0].nValue = 5000000000LL - 1000 - 50000 - feeToUse; │ tx.vout[0].nValue = 5000000000LL - 1000 - 50000 - feeToUse;
uint256 hashLowFeeTx = tx.GetHash(); │ uint256 hashLowFeeTx = tx.GetHash();
mempool.addUnchecked(hashLowFeeTx, entry.Fee(feeToUse).FromTx(tx)); │ m_node.mempool->addUnchecked(entry.Fee(feeToUse).FromTx(tx));
pblocktemplate = BlockAssembler(chainparams).CreateNewBlock(scriptPubKey, true); │ pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey);
// Verify that the free tx and the low fee tx didn't get selected │ // Verify that the free tx and the low fee tx didn't get selected
for (size_t i=0; i<pblocktemplate->block.vtx.size(); ++i) { │ for (size_t i=0; i<pblocktemplate->block.vtx.size(); ++i) {
BOOST_CHECK(pblocktemplate->block.vtx[i]->GetHash() != hashFreeTx); │ BOOST_CHECK(pblocktemplate->block.vtx[i]->GetHash() != hashFreeTx);
BOOST_CHECK(pblocktemplate->block.vtx[i]->GetHash() != hashLowFeeTx); │ BOOST_CHECK(pblocktemplate->block.vtx[i]->GetHash() != hashLowFeeTx);
} │ }
│
// Test that packages above the min relay fee do get included, even if one │ // Test that packages above the min relay fee do get included, even if one
// of the transactions is below the min relay fee │ // of the transactions is below the min relay fee
// Remove the low fee transaction and replace with a higher fee transaction │ // Remove the low fee transaction and replace with a higher fee transaction
mempool.removeRecursive(tx); │ m_node.mempool->removeRecursive(CTransaction(tx), MemPoolRemovalReason::REPLACED);
tx.vout[0].nValue -= 2; // Now we should be just over the min relay fee │ tx.vout[0].nValue -= 2; // Now we should be just over the min relay fee
hashLowFeeTx = tx.GetHash(); │ hashLowFeeTx = tx.GetHash();
mempool.addUnchecked(hashLowFeeTx, entry.Fee(feeToUse+2).FromTx(tx)); │ m_node.mempool->addUnchecked(entry.Fee(feeToUse+2).FromTx(tx));
pblocktemplate = BlockAssembler(chainparams).CreateNewBlock(scriptPubKey, true); │ pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey);
│ BOOST_REQUIRE_EQUAL(pblocktemplate->block.vtx.size(), 6U);
BOOST_CHECK(pblocktemplate->block.vtx[4]->GetHash() == hashFreeTx); │ BOOST_CHECK(pblocktemplate->block.vtx[4]->GetHash() == hashFreeTx);
BOOST_CHECK(pblocktemplate->block.vtx[5]->GetHash() == hashLowFeeTx); │ BOOST_CHECK(pblocktemplate->block.vtx[5]->GetHash() == hashLowFeeTx);
│
// Test that transaction selection properly updates ancestor fee │ // Test that transaction selection properly updates ancestor fee
// calculations as ancestor transactions get included in a block. │ // calculations as ancestor transactions get included in a block.
// Add a 0-fee transaction that has 2 outputs. │ // Add a 0-fee transaction that has 2 outputs.
tx.vin[0].prevout.hash = txFirst[2]->GetHash(); │ tx.vin[0].prevout.hash = txFirst[2]->GetHash();
tx.vout.resize(2); │ tx.vout.resize(2);
tx.vout[0].nValue = 5000000000LL - 100000000; │ tx.vout[0].nValue = 5000000000LL - 100000000;
tx.vout[1].nValue = 100000000; // 1BTC output │ tx.vout[1].nValue = 100000000; // 1BTC output
uint256 hashFreeTx2 = tx.GetHash(); │ uint256 hashFreeTx2 = tx.GetHash();
mempool.addUnchecked(hashFreeTx2, entry.Fee(0).SpendsCoinbase(true).FromTx(tx)); │ m_node.mempool->addUnchecked(entry.Fee(0).SpendsCoinbase(true).FromTx(tx));
│
// This tx can't be mined by itself │ // This tx can't be mined by itself
tx.vin[0].prevout.hash = hashFreeTx2; │ tx.vin[0].prevout.hash = hashFreeTx2;
tx.vout.resize(1); │ tx.vout.resize(1);
feeToUse = blockMinFeeRate.GetFee(freeTxSize); │ feeToUse = blockMinFeeRate.GetFee(freeTxSize);
tx.vout[0].nValue = 5000000000LL - 100000000 - feeToUse; │ tx.vout[0].nValue = 5000000000LL - 100000000 - feeToUse;
uint256 hashLowFeeTx2 = tx.GetHash(); │ uint256 hashLowFeeTx2 = tx.GetHash();
mempool.addUnchecked(hashLowFeeTx2, entry.Fee(feeToUse).SpendsCoinbase(false).FromTx │ m_node.mempool->addUnchecked(entry.Fee(feeToUse).SpendsCoinbase(false).FromTx(tx));
pblocktemplate = BlockAssembler(chainparams).CreateNewBlock(scriptPubKey, true); │ pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey);
│
// Verify that this tx isn't selected. │ // Verify that this tx isn't selected.
for (size_t i=0; i<pblocktemplate->block.vtx.size(); ++i) { │ for (size_t i=0; i<pblocktemplate->block.vtx.size(); ++i) {
BOOST_CHECK(pblocktemplate->block.vtx[i]->GetHash() != hashFreeTx2); │ BOOST_CHECK(pblocktemplate->block.vtx[i]->GetHash() != hashFreeTx2);
BOOST_CHECK(pblocktemplate->block.vtx[i]->GetHash() != hashLowFeeTx2); │ BOOST_CHECK(pblocktemplate->block.vtx[i]->GetHash() != hashLowFeeTx2);
} │ }
│
// This tx will be mineable, and should cause hashLowFeeTx2 to be selected │ // This tx will be mineable, and should cause hashLowFeeTx2 to be selected
// as well. │ // as well.
tx.vin[0].prevout.n = 1; │ tx.vin[0].prevout.n = 1;
tx.vout[0].nValue = 100000000 - 10000; // 10k satoshi fee │ tx.vout[0].nValue = 100000000 - 10000; // 10k satoshi fee
mempool.addUnchecked(tx.GetHash(), entry.Fee(10000).FromTx(tx)); │ m_node.mempool->addUnchecked(entry.Fee(10000).FromTx(tx));
pblocktemplate = BlockAssembler(chainparams).CreateNewBlock(scriptPubKey, true); │ pblocktemplate = AssemblerForTest(chainparams).CreateNewBlock(scriptPubKey);
│ BOOST_REQUIRE_EQUAL(pblocktemplate->block.vtx.size(), 9U);
BOOST_CHECK(pblocktemplate->block.vtx[8]->GetHash() == hashLowFeeTx2); │ BOOST_CHECK(pblocktemplate->block.vtx[8]->GetHash() == hashLowFeeTx2);
} │
next prev up dogecoin/src/univalue/lib/univalue_read.cpp:53 │ bitcoin/src/univalue/lib/univalue_read.cpp:53
│
tokenVal.clear(); │ tokenVal.clear();
consumed = 0; │ consumed = 0;
│
const char *rawStart = raw; │ const char *rawStart = raw;
│
while (raw < end && (json_isspace(*raw))) // skip whitespace │ while (raw < end && (json_isspace(*raw))) // skip whitespace
raw++; │ raw++;
│
if (raw >= end) │ if (raw >= end)
return JTOK_NONE; │ return JTOK_NONE;
│
switch (*raw) { │ switch (*raw) {
│
case '{': │ case '{':
raw++; │ raw++;
consumed = (raw - rawStart); │ consumed = (raw - rawStart);
return JTOK_OBJ_OPEN; │ return JTOK_OBJ_OPEN;
case '}': │ case '}':
raw++; │ raw++;
consumed = (raw - rawStart); │ consumed = (raw - rawStart);
return JTOK_OBJ_CLOSE; │ return JTOK_OBJ_CLOSE;
case '[': │ case '[':
raw++; │ raw++;
consumed = (raw - rawStart); │ consumed = (raw - rawStart);
return JTOK_ARR_OPEN; │ return JTOK_ARR_OPEN;
case ']': │ case ']':
raw++; │ raw++;
consumed = (raw - rawStart); │ consumed = (raw - rawStart);
return JTOK_ARR_CLOSE; │ return JTOK_ARR_CLOSE;
│
case ':': │ case ':':
raw++; │ raw++;
consumed = (raw - rawStart); │ consumed = (raw - rawStart);
return JTOK_COLON; │ return JTOK_COLON;
case ',': │ case ',':
raw++; │ raw++;
consumed = (raw - rawStart); │ consumed = (raw - rawStart);
return JTOK_COMMA; │ return JTOK_COMMA;
│
case 'n': │ case 'n':
case 't': │ case 't':
case 'f': │ case 'f':
if (!strncmp(raw, "null", 4)) { │ if (!strncmp(raw, "null", 4)) {
raw += 4; │ raw += 4;
consumed = (raw - rawStart); │ consumed = (raw - rawStart);
return JTOK_KW_NULL; │ return JTOK_KW_NULL;
} else if (!strncmp(raw, "true", 4)) { │ } else if (!strncmp(raw, "true", 4)) {
raw += 4; │ raw += 4;
consumed = (raw - rawStart); │ consumed = (raw - rawStart);
return JTOK_KW_TRUE; │ return JTOK_KW_TRUE;
} else if (!strncmp(raw, "false", 5)) { │ } else if (!strncmp(raw, "false", 5)) {
raw += 5; │ raw += 5;
consumed = (raw - rawStart); │ consumed = (raw - rawStart);
return JTOK_KW_FALSE; │ return JTOK_KW_FALSE;
} else │ } else
return JTOK_ERR; │ return JTOK_ERR;
│
case '-': │ case '-':
case '0': │ case '0':
case '1': │ case '1':
case '2': │ case '2':
case '3': │ case '3':
case '4': │ case '4':
case '5': │ case '5':
case '6': │ case '6':
case '7': │ case '7':
case '8': │ case '8':
case '9': { │ case '9': {
// part 1: int │ // part 1: int
std::string numStr; │ std::string numStr;
│
const char *first = raw; │ const char *first = raw;
│
const char *firstDigit = first; │ const char *firstDigit = first;
if (!json_isdigit(*firstDigit)) │ if (!json_isdigit(*firstDigit))
firstDigit++; │ firstDigit++;
if ((*firstDigit == '0') && json_isdigit(firstDigit[1])) │ if ((*firstDigit == '0') && json_isdigit(firstDigit[1]))
return JTOK_ERR; │ return JTOK_ERR;
│
numStr += *raw; // copy first char │ numStr += *raw; // copy first char
raw++; │ raw++;
│
if ((*first == '-') && (raw < end) && (!json_isdigit(*raw))) │ if ((*first == '-') && (raw < end) && (!json_isdigit(*raw)))
return JTOK_ERR; │ return JTOK_ERR;
│
while (raw < end && json_isdigit(*raw)) { // copy digits │ while (raw < end && json_isdigit(*raw)) { // copy digits
numStr += *raw; │ numStr += *raw;
raw++; │ raw++;
} │ }
│
// part 2: frac │ // part 2: frac
if (raw < end && *raw == '.') { │ if (raw < end && *raw == '.') {
numStr += *raw; // copy . │ numStr += *raw; // copy .
raw++; │ raw++;
│
if (raw >= end || !json_isdigit(*raw)) │ if (raw >= end || !json_isdigit(*raw))
return JTOK_ERR; │ return JTOK_ERR;
while (raw < end && json_isdigit(*raw)) { // copy digits │ while (raw < end && json_isdigit(*raw)) { // copy digits
numStr += *raw; │ numStr += *raw;
raw++; │ raw++;
} │ }
} │ }
│
// part 3: exp │ // part 3: exp
if (raw < end && (*raw == 'e' || *raw == 'E')) { │ if (raw < end && (*raw == 'e' || *raw == 'E')) {
numStr += *raw; // copy E │ numStr += *raw; // copy E
raw++; │ raw++;
│
if (raw < end && (*raw == '-' || *raw == '+')) { // copy +/- │ if (raw < end && (*raw == '-' || *raw == '+')) { // copy +/-
numStr += *raw; │ numStr += *raw;
raw++; │ raw++;
} │ }
│
if (raw >= end || !json_isdigit(*raw)) │ if (raw >= end || !json_isdigit(*raw))
return JTOK_ERR; │ return JTOK_ERR;
while (raw < end && json_isdigit(*raw)) { // copy digits │ while (raw < end && json_isdigit(*raw)) { // copy digits
numStr += *raw; │ numStr += *raw;
raw++; │ raw++;
} │ }
} │ }
│
tokenVal = numStr; │ tokenVal = numStr;
consumed = (raw - rawStart); │ consumed = (raw - rawStart);
return JTOK_NUMBER; │ return JTOK_NUMBER;
} │ }
│
case '"': { │ case '"': {
raw++; // skip " │ raw++; // skip "
│
std::string valStr; │ std::string valStr;
JSONUTF8StringFilter writer(valStr); │ JSONUTF8StringFilter writer(valStr);
│
while (true) { │ while (true) {
if (raw >= end || (unsigned char)*raw < 0x20) │ if (raw >= end || (unsigned char)*raw < 0x20)
return JTOK_ERR; │ return JTOK_ERR;
│
else if (*raw == '\\') { │ else if (*raw == '\\') {
raw++; // skip backslash │ raw++; // skip backslash
│
if (raw >= end) │ if (raw >= end)
return JTOK_ERR; │ return JTOK_ERR;
│
switch (*raw) { │ switch (*raw) {
case '"': writer.push_back('\"'); break; │ case '"': writer.push_back('\"'); break;
case '\\': writer.push_back('\\'); break; │ case '\\': writer.push_back('\\'); break;
case '/': writer.push_back('/'); break; │ case '/': writer.push_back('/'); break;
case 'b': writer.push_back('\b'); break; │ case 'b': writer.push_back('\b'); break;
case 'f': writer.push_back('\f'); break; │ case 'f': writer.push_back('\f'); break;
case 'n': writer.push_back('\n'); break; │ case 'n': writer.push_back('\n'); break;
case 'r': writer.push_back('\r'); break; │ case 'r': writer.push_back('\r'); break;
case 't': writer.push_back('\t'); break; │ case 't': writer.push_back('\t'); break;
│
case 'u': { │ case 'u': {
unsigned int codepoint; │ unsigned int codepoint;
if (raw + 1 + 4 >= end || │ if (raw + 1 + 4 >= end ||
hatoui(raw + 1, raw + 1 + 4, codepoint) != │ hatoui(raw + 1, raw + 1 + 4, codepoint) !=
raw + 1 + 4) │ raw + 1 + 4)
return JTOK_ERR; │ return JTOK_ERR;
writer.push_back_u(codepoint); │ writer.push_back_u(codepoint);
raw += 4; │ raw += 4;
break; │ break;
} │ }
default: │ default:
return JTOK_ERR; │ return JTOK_ERR;
│
} │ }
│
raw++; // skip esc'd char │ raw++; // skip esc'd char
} │ }
│
else if (*raw == '"') { │ else if (*raw == '"') {
raw++; // skip " │ raw++; // skip "
break; // stop scanning │ break; // stop scanning
} │ }
│
else { │ else {
writer.push_back(static_cast<unsigned char>(*raw)); │ writer.push_back(static_cast<unsigned char>(*raw));
raw++; │ raw++;
} │ }
} │ }
│
if (!writer.finalize()) │ if (!writer.finalize())
return JTOK_ERR; │ return JTOK_ERR;
tokenVal = valStr; │ tokenVal = valStr;
consumed = (raw - rawStart); │ consumed = (raw - rawStart);
return JTOK_STRING; │ return JTOK_STRING;
} │ }
│
default: │ default:
return JTOK_ERR; │ return JTOK_ERR;
} │ }
} │
next prev up dogecoin/src/script/interpreter.cpp:1410 │ bitcoin/src/script/interpreter.cpp:1948
│
static const CScriptWitness emptyWitness; │ static const CScriptWitness emptyWitness;
if (witness == NULL) { │ if (witness == nullptr) {
witness = &emptyWitness; │ witness = &emptyWitness;
} │ }
bool hadWitness = false; │ bool hadWitness = false;
│
set_error(serror, SCRIPT_ERR_UNKNOWN_ERROR); │ set_error(serror, SCRIPT_ERR_UNKNOWN_ERROR);
│
if ((flags & SCRIPT_VERIFY_SIGPUSHONLY) != 0 && !scriptSig.IsPushOnly()) { │ if ((flags & SCRIPT_VERIFY_SIGPUSHONLY) != 0 && !scriptSig.IsPushOnly()) {
return set_error(serror, SCRIPT_ERR_SIG_PUSHONLY); │ return set_error(serror, SCRIPT_ERR_SIG_PUSHONLY);
} │ }
│
vector<vector<unsigned char> > stack, stackCopy; │ // scriptSig and scriptPubKey must be evaluated sequentially on the same stack
if (!EvalScript(stack, scriptSig, flags, checker, SIGVERSION_BASE, serror)) │ // rather than being simply concatenated (see CVE-2010-5141)
│ std::vector<std::vector<unsigned char> > stack, stackCopy;
│ if (!EvalScript(stack, scriptSig, flags, checker, SigVersion::BASE, serror))
// serror is set │ // serror is set
return false; │ return false;
if (flags & SCRIPT_VERIFY_P2SH) │ if (flags & SCRIPT_VERIFY_P2SH)
stackCopy = stack; │ stackCopy = stack;
if (!EvalScript(stack, scriptPubKey, flags, checker, SIGVERSION_BASE, serror)) │ if (!EvalScript(stack, scriptPubKey, flags, checker, SigVersion::BASE, serror))
// serror is set │ // serror is set
return false; │ return false;
if (stack.empty()) │ if (stack.empty())
return set_error(serror, SCRIPT_ERR_EVAL_FALSE); │ return set_error(serror, SCRIPT_ERR_EVAL_FALSE);
if (CastToBool(stack.back()) == false) │ if (CastToBool(stack.back()) == false)
return set_error(serror, SCRIPT_ERR_EVAL_FALSE); │ return set_error(serror, SCRIPT_ERR_EVAL_FALSE);
│
// Bare witness programs │ // Bare witness programs
int witnessversion; │ int witnessversion;
std::vector<unsigned char> witnessprogram; │ std::vector<unsigned char> witnessprogram;
if (flags & SCRIPT_VERIFY_WITNESS) { │ if (flags & SCRIPT_VERIFY_WITNESS) {
if (scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram)) { │ if (scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram)) {
hadWitness = true; │ hadWitness = true;
if (scriptSig.size() != 0) { │ if (scriptSig.size() != 0) {
// The scriptSig must be _exactly_ CScript(), otherwise we reintroduce m │ // The scriptSig must be _exactly_ CScript(), otherwise we reintroduce m
return set_error(serror, SCRIPT_ERR_WITNESS_MALLEATED); │ return set_error(serror, SCRIPT_ERR_WITNESS_MALLEATED);
} │ }
if (!VerifyWitnessProgram(*witness, witnessversion, witnessprogram, flags, c │ if (!VerifyWitnessProgram(*witness, witnessversion, witnessprogram, flags, c
return false; │ return false;
} │ }
// Bypass the cleanstack check at the end. The actual stack is obviously not │ // Bypass the cleanstack check at the end. The actual stack is obviously not
// for witness programs. │ // for witness programs.
stack.resize(1); │ stack.resize(1);
} │ }
} │ }
│
// Additional validation for spend-to-script-hash transactions: │ // Additional validation for spend-to-script-hash transactions:
if ((flags & SCRIPT_VERIFY_P2SH) && scriptPubKey.IsPayToScriptHash()) │ if ((flags & SCRIPT_VERIFY_P2SH) && scriptPubKey.IsPayToScriptHash())
{ │ {
// scriptSig must be literals-only or validation fails │ // scriptSig must be literals-only or validation fails
if (!scriptSig.IsPushOnly()) │ if (!scriptSig.IsPushOnly())
return set_error(serror, SCRIPT_ERR_SIG_PUSHONLY); │ return set_error(serror, SCRIPT_ERR_SIG_PUSHONLY);
│
// Restore stack. │ // Restore stack.
swap(stack, stackCopy); │ swap(stack, stackCopy);
│
// stack cannot be empty here, because if it was the │ // stack cannot be empty here, because if it was the
// P2SH HASH <> EQUAL scriptPubKey would be evaluated with │ // P2SH HASH <> EQUAL scriptPubKey would be evaluated with
// an empty stack and the EvalScript above would return false. │ // an empty stack and the EvalScript above would return false.
assert(!stack.empty()); │ assert(!stack.empty());
│
const valtype& pubKeySerialized = stack.back(); │ const valtype& pubKeySerialized = stack.back();
CScript pubKey2(pubKeySerialized.begin(), pubKeySerialized.end()); │ CScript pubKey2(pubKeySerialized.begin(), pubKeySerialized.end());
popstack(stack); │ popstack(stack);
│
if (!EvalScript(stack, pubKey2, flags, checker, SIGVERSION_BASE, serror)) │ if (!EvalScript(stack, pubKey2, flags, checker, SigVersion::BASE, serror))
// serror is set │ // serror is set
return false; │ return false;
if (stack.empty()) │ if (stack.empty())
return set_error(serror, SCRIPT_ERR_EVAL_FALSE); │ return set_error(serror, SCRIPT_ERR_EVAL_FALSE);
if (!CastToBool(stack.back())) │ if (!CastToBool(stack.back()))
return set_error(serror, SCRIPT_ERR_EVAL_FALSE); │ return set_error(serror, SCRIPT_ERR_EVAL_FALSE);
│
// P2SH witness program │ // P2SH witness program
if (flags & SCRIPT_VERIFY_WITNESS) { │ if (flags & SCRIPT_VERIFY_WITNESS) {
if (pubKey2.IsWitnessProgram(witnessversion, witnessprogram)) { │ if (pubKey2.IsWitnessProgram(witnessversion, witnessprogram)) {
hadWitness = true; │ hadWitness = true;
if (scriptSig != CScript() << std::vector<unsigned char>(pubKey2.begin() │ if (scriptSig != CScript() << std::vector<unsigned char>(pubKey2.begin()
// The scriptSig must be _exactly_ a single push of the redeemScript │ // The scriptSig must be _exactly_ a single push of the redeemScript
// reintroduce malleability. │ // reintroduce malleability.
return set_error(serror, SCRIPT_ERR_WITNESS_MALLEATED_P2SH); │ return set_error(serror, SCRIPT_ERR_WITNESS_MALLEATED_P2SH);
} │ }
if (!VerifyWitnessProgram(*witness, witnessversion, witnessprogram, flag │ if (!VerifyWitnessProgram(*witness, witnessversion, witnessprogram, flag
return false; │ return false;
} │ }
// Bypass the cleanstack check at the end. The actual stack is obviously │ // Bypass the cleanstack check at the end. The actual stack is obviously
// for witness programs. │ // for witness programs.
stack.resize(1); │ stack.resize(1);
} │ }
} │ }
} │ }
│
// The CLEANSTACK check is only performed after potential P2SH evaluation, │ // The CLEANSTACK check is only performed after potential P2SH evaluation,
// as the non-P2SH evaluation of a P2SH script will obviously not result in │ // as the non-P2SH evaluation of a P2SH script will obviously not result in
// a clean stack (the P2SH inputs remain). The same holds for witness evaluation. │ // a clean stack (the P2SH inputs remain). The same holds for witness evaluation.
if ((flags & SCRIPT_VERIFY_CLEANSTACK) != 0) { │ if ((flags & SCRIPT_VERIFY_CLEANSTACK) != 0) {
// Disallow CLEANSTACK without P2SH, as otherwise a switch CLEANSTACK->P2SH+CLEA │ // Disallow CLEANSTACK without P2SH, as otherwise a switch CLEANSTACK->P2SH+CLEA
// would be possible, which is not a softfork (and P2SH should be one). │ // would be possible, which is not a softfork (and P2SH should be one).
assert((flags & SCRIPT_VERIFY_P2SH) != 0); │ assert((flags & SCRIPT_VERIFY_P2SH) != 0);
assert((flags & SCRIPT_VERIFY_WITNESS) != 0); │ assert((flags & SCRIPT_VERIFY_WITNESS) != 0);
if (stack.size() != 1) { │ if (stack.size() != 1) {
return set_error(serror, SCRIPT_ERR_CLEANSTACK); │ return set_error(serror, SCRIPT_ERR_CLEANSTACK);
} │ }
} │ }
│
if (flags & SCRIPT_VERIFY_WITNESS) { │ if (flags & SCRIPT_VERIFY_WITNESS) {
// We can't check for correct unexpected witness data if P2SH was off, so requir │ // We can't check for correct unexpected witness data if P2SH was off, so requir
// that WITNESS implies P2SH. Otherwise, going from WITNESS->P2SH+WITNESS would │ // that WITNESS implies P2SH. Otherwise, going from WITNESS->P2SH+WITNESS would
// possible, which is not a softfork. │ // possible, which is not a softfork.
assert((flags & SCRIPT_VERIFY_P2SH) != 0); │ assert((flags & SCRIPT_VERIFY_P2SH) != 0);
if (!hadWitness && !witness->IsNull()) { │ if (!hadWitness && !witness->IsNull()) {
return set_error(serror, SCRIPT_ERR_WITNESS_UNEXPECTED); │ return set_error(serror, SCRIPT_ERR_WITNESS_UNEXPECTED);
} │ }
} │ }
│
return set_success(serror); │ return set_success(serror);
} │
next prev up dogecoin/src/test/coins_tests.cpp:811 │ bitcoin/src/test/coins_tests.cpp:816
│
/* Check BatchWrite behavior, flushing one entry from a child cache to a │ /* Check BatchWrite behavior, flushing one entry from a child cache to a
* parent cache, and checking the resulting entry in the parent cache │ * parent cache, and checking the resulting entry in the parent cache
* after the write. │ * after the write.
* │ *
* Parent Child Result Parent Child Result │ * Parent Child Result Parent Child Result
* Value Value Value Flags Flags Flags │ * Value Value Value Flags Flags Flags
*/ │ */
CheckWriteCoins(ABSENT, ABSENT, ABSENT, NO_ENTRY , NO_ENTRY , NO_ENTRY ); │ CheckWriteCoins(ABSENT, ABSENT, ABSENT, NO_ENTRY , NO_ENTRY , NO_ENTRY );
CheckWriteCoins(ABSENT, PRUNED, PRUNED, NO_ENTRY , DIRTY , DIRTY ); │ CheckWriteCoins(ABSENT, SPENT , SPENT , NO_ENTRY , DIRTY , DIRTY );
CheckWriteCoins(ABSENT, PRUNED, ABSENT, NO_ENTRY , DIRTY|FRESH, NO_ENTRY ); │ CheckWriteCoins(ABSENT, SPENT , ABSENT, NO_ENTRY , DIRTY|FRESH, NO_ENTRY );
CheckWriteCoins(ABSENT, VALUE2, VALUE2, NO_ENTRY , DIRTY , DIRTY ); │ CheckWriteCoins(ABSENT, VALUE2, VALUE2, NO_ENTRY , DIRTY , DIRTY );
CheckWriteCoins(ABSENT, VALUE2, VALUE2, NO_ENTRY , DIRTY|FRESH, DIRTY|FRESH); │ CheckWriteCoins(ABSENT, VALUE2, VALUE2, NO_ENTRY , DIRTY|FRESH, DIRTY|FRESH);
CheckWriteCoins(PRUNED, ABSENT, PRUNED, 0 , NO_ENTRY , 0 ); │ CheckWriteCoins(SPENT , ABSENT, SPENT , 0 , NO_ENTRY , 0 );
CheckWriteCoins(PRUNED, ABSENT, PRUNED, FRESH , NO_ENTRY , FRESH ); │ CheckWriteCoins(SPENT , ABSENT, SPENT , FRESH , NO_ENTRY , FRESH );
CheckWriteCoins(PRUNED, ABSENT, PRUNED, DIRTY , NO_ENTRY , DIRTY ); │ CheckWriteCoins(SPENT , ABSENT, SPENT , DIRTY , NO_ENTRY , DIRTY );
CheckWriteCoins(PRUNED, ABSENT, PRUNED, DIRTY|FRESH, NO_ENTRY , DIRTY|FRESH); │ CheckWriteCoins(SPENT , ABSENT, SPENT , DIRTY|FRESH, NO_ENTRY , DIRTY|FRESH);
CheckWriteCoins(PRUNED, PRUNED, PRUNED, 0 , DIRTY , DIRTY ); │ CheckWriteCoins(SPENT , SPENT , SPENT , 0 , DIRTY , DIRTY );
CheckWriteCoins(PRUNED, PRUNED, PRUNED, 0 , DIRTY|FRESH, DIRTY ); │ CheckWriteCoins(SPENT , SPENT , SPENT , 0 , DIRTY|FRESH, DIRTY );
CheckWriteCoins(PRUNED, PRUNED, ABSENT, FRESH , DIRTY , NO_ENTRY ); │ CheckWriteCoins(SPENT , SPENT , ABSENT, FRESH , DIRTY , NO_ENTRY );
CheckWriteCoins(PRUNED, PRUNED, ABSENT, FRESH , DIRTY|FRESH, NO_ENTRY ); │ CheckWriteCoins(SPENT , SPENT , ABSENT, FRESH , DIRTY|FRESH, NO_ENTRY );
CheckWriteCoins(PRUNED, PRUNED, PRUNED, DIRTY , DIRTY , DIRTY ); │ CheckWriteCoins(SPENT , SPENT , SPENT , DIRTY , DIRTY , DIRTY );
CheckWriteCoins(PRUNED, PRUNED, PRUNED, DIRTY , DIRTY|FRESH, DIRTY ); │ CheckWriteCoins(SPENT , SPENT , SPENT , DIRTY , DIRTY|FRESH, DIRTY );
CheckWriteCoins(PRUNED, PRUNED, ABSENT, DIRTY|FRESH, DIRTY , NO_ENTRY ); │ CheckWriteCoins(SPENT , SPENT , ABSENT, DIRTY|FRESH, DIRTY , NO_ENTRY );
CheckWriteCoins(PRUNED, PRUNED, ABSENT, DIRTY|FRESH, DIRTY|FRESH, NO_ENTRY ); │ CheckWriteCoins(SPENT , SPENT , ABSENT, DIRTY|FRESH, DIRTY|FRESH, NO_ENTRY );
CheckWriteCoins(PRUNED, VALUE2, VALUE2, 0 , DIRTY , DIRTY ); │ CheckWriteCoins(SPENT , VALUE2, VALUE2, 0 , DIRTY , DIRTY );
CheckWriteCoins(PRUNED, VALUE2, VALUE2, 0 , DIRTY|FRESH, DIRTY ); │ CheckWriteCoins(SPENT , VALUE2, VALUE2, 0 , DIRTY|FRESH, DIRTY );
CheckWriteCoins(PRUNED, VALUE2, VALUE2, FRESH , DIRTY , DIRTY|FRESH); │ CheckWriteCoins(SPENT , VALUE2, VALUE2, FRESH , DIRTY , DIRTY|FRESH);
CheckWriteCoins(PRUNED, VALUE2, VALUE2, FRESH , DIRTY|FRESH, DIRTY|FRESH); │ CheckWriteCoins(SPENT , VALUE2, VALUE2, FRESH , DIRTY|FRESH, DIRTY|FRESH);
CheckWriteCoins(PRUNED, VALUE2, VALUE2, DIRTY , DIRTY , DIRTY ); │ CheckWriteCoins(SPENT , VALUE2, VALUE2, DIRTY , DIRTY , DIRTY );
CheckWriteCoins(PRUNED, VALUE2, VALUE2, DIRTY , DIRTY|FRESH, DIRTY ); │ CheckWriteCoins(SPENT , VALUE2, VALUE2, DIRTY , DIRTY|FRESH, DIRTY );
CheckWriteCoins(PRUNED, VALUE2, VALUE2, DIRTY|FRESH, DIRTY , DIRTY|FRESH); │ CheckWriteCoins(SPENT , VALUE2, VALUE2, DIRTY|FRESH, DIRTY , DIRTY|FRESH);
CheckWriteCoins(PRUNED, VALUE2, VALUE2, DIRTY|FRESH, DIRTY|FRESH, DIRTY|FRESH); │ CheckWriteCoins(SPENT , VALUE2, VALUE2, DIRTY|FRESH, DIRTY|FRESH, DIRTY|FRESH);
CheckWriteCoins(VALUE1, ABSENT, VALUE1, 0 , NO_ENTRY , 0 ); │ CheckWriteCoins(VALUE1, ABSENT, VALUE1, 0 , NO_ENTRY , 0 );
CheckWriteCoins(VALUE1, ABSENT, VALUE1, FRESH , NO_ENTRY , FRESH ); │ CheckWriteCoins(VALUE1, ABSENT, VALUE1, FRESH , NO_ENTRY , FRESH );
CheckWriteCoins(VALUE1, ABSENT, VALUE1, DIRTY , NO_ENTRY , DIRTY ); │ CheckWriteCoins(VALUE1, ABSENT, VALUE1, DIRTY , NO_ENTRY , DIRTY );
CheckWriteCoins(VALUE1, ABSENT, VALUE1, DIRTY|FRESH, NO_ENTRY , DIRTY|FRESH); │ CheckWriteCoins(VALUE1, ABSENT, VALUE1, DIRTY|FRESH, NO_ENTRY , DIRTY|FRESH);
CheckWriteCoins(VALUE1, PRUNED, PRUNED, 0 , DIRTY , DIRTY ); │ CheckWriteCoins(VALUE1, SPENT , SPENT , 0 , DIRTY , DIRTY );
CheckWriteCoins(VALUE1, PRUNED, FAIL , 0 , DIRTY|FRESH, NO_ENTRY ); │ CheckWriteCoins(VALUE1, SPENT , FAIL , 0 , DIRTY|FRESH, NO_ENTRY );
CheckWriteCoins(VALUE1, PRUNED, ABSENT, FRESH , DIRTY , NO_ENTRY ); │ CheckWriteCoins(VALUE1, SPENT , ABSENT, FRESH , DIRTY , NO_ENTRY );
CheckWriteCoins(VALUE1, PRUNED, FAIL , FRESH , DIRTY|FRESH, NO_ENTRY ); │ CheckWriteCoins(VALUE1, SPENT , FAIL , FRESH , DIRTY|FRESH, NO_ENTRY );
CheckWriteCoins(VALUE1, PRUNED, PRUNED, DIRTY , DIRTY , DIRTY ); │ CheckWriteCoins(VALUE1, SPENT , SPENT , DIRTY , DIRTY , DIRTY );
CheckWriteCoins(VALUE1, PRUNED, FAIL , DIRTY , DIRTY|FRESH, NO_ENTRY ); │ CheckWriteCoins(VALUE1, SPENT , FAIL , DIRTY , DIRTY|FRESH, NO_ENTRY );
CheckWriteCoins(VALUE1, PRUNED, ABSENT, DIRTY|FRESH, DIRTY , NO_ENTRY ); │ CheckWriteCoins(VALUE1, SPENT , ABSENT, DIRTY|FRESH, DIRTY , NO_ENTRY );
CheckWriteCoins(VALUE1, PRUNED, FAIL , DIRTY|FRESH, DIRTY|FRESH, NO_ENTRY ); │ CheckWriteCoins(VALUE1, SPENT , FAIL , DIRTY|FRESH, DIRTY|FRESH, NO_ENTRY );
CheckWriteCoins(VALUE1, VALUE2, VALUE2, 0 , DIRTY , DIRTY ); │ CheckWriteCoins(VALUE1, VALUE2, VALUE2, 0 , DIRTY , DIRTY );
CheckWriteCoins(VALUE1, VALUE2, FAIL , 0 , DIRTY|FRESH, NO_ENTRY ); │ CheckWriteCoins(VALUE1, VALUE2, FAIL , 0 , DIRTY|FRESH, NO_ENTRY );
CheckWriteCoins(VALUE1, VALUE2, VALUE2, FRESH , DIRTY , DIRTY|FRESH); │ CheckWriteCoins(VALUE1, VALUE2, VALUE2, FRESH , DIRTY , DIRTY|FRESH);
CheckWriteCoins(VALUE1, VALUE2, FAIL , FRESH , DIRTY|FRESH, NO_ENTRY ); │ CheckWriteCoins(VALUE1, VALUE2, FAIL , FRESH , DIRTY|FRESH, NO_ENTRY );
CheckWriteCoins(VALUE1, VALUE2, VALUE2, DIRTY , DIRTY , DIRTY ); │ CheckWriteCoins(VALUE1, VALUE2, VALUE2, DIRTY , DIRTY , DIRTY );
CheckWriteCoins(VALUE1, VALUE2, FAIL , DIRTY , DIRTY|FRESH, NO_ENTRY ); │ CheckWriteCoins(VALUE1, VALUE2, FAIL , DIRTY , DIRTY|FRESH, NO_ENTRY );
CheckWriteCoins(VALUE1, VALUE2, VALUE2, DIRTY|FRESH, DIRTY , DIRTY|FRESH); │ CheckWriteCoins(VALUE1, VALUE2, VALUE2, DIRTY|FRESH, DIRTY , DIRTY|FRESH);
CheckWriteCoins(VALUE1, VALUE2, FAIL , DIRTY|FRESH, DIRTY|FRESH, NO_ENTRY ); │ CheckWriteCoins(VALUE1, VALUE2, FAIL , DIRTY|FRESH, DIRTY|FRESH, NO_ENTRY );
│
// The checks above omit cases where the child flags are not DIRTY, since │ // The checks above omit cases where the child flags are not DIRTY, since
// they would be too repetitive (the parent cache is never updated in these │ // they would be too repetitive (the parent cache is never updated in these
// cases). The loop below covers these cases and makes sure the parent cache │ // cases). The loop below covers these cases and makes sure the parent cache
// is always left unchanged. │ // is always left unchanged.
for (CAmount parent_value : {ABSENT, PRUNED, VALUE1}) │ for (const CAmount parent_value : {ABSENT, SPENT, VALUE1})
for (CAmount child_value : {ABSENT, PRUNED, VALUE2}) │ for (const CAmount child_value : {ABSENT, SPENT, VALUE2})
for (char parent_flags : parent_value == ABSENT ? ABSENT_FLAGS : FLAGS) │ for (const char parent_flags : parent_value == ABSENT ? ABSENT_FLAGS : FLAGS
for (char child_flags : child_value == ABSENT ? ABSENT_FLAGS : CLEAN_FLA │ for (const char child_flags : child_value == ABSENT ? ABSENT_FLAGS : CLE
CheckWriteCoins(parent_value, child_value, parent_value, parent_flag │ CheckWriteCoins(parent_value, child_value, parent_value, parent_flag
} │
next prev up dogecoin/src/test/script_P2SH_tests.cpp:258 │ bitcoin/src/test/script_p2sh_tests.cpp:265
│
LOCK(cs_main); │ LOCK(cs_main);
CCoinsView coinsDummy; │ CCoinsView coinsDummy;
CCoinsViewCache coins(&coinsDummy); │ CCoinsViewCache coins(&coinsDummy);
CBasicKeyStore keystore; │ FillableSigningProvider keystore;
CKey key[6]; │ CKey key[6];
std::vector<CPubKey> keys; │ std::vector<CPubKey> keys;
for (int i = 0; i < 6; i++) │ for (int i = 0; i < 6; i++)
{ │ {
key[i].MakeNewKey(true); │ key[i].MakeNewKey(true);
keystore.AddKey(key[i]); │ BOOST_CHECK(keystore.AddKey(key[i]));
} │ }
for (int i = 0; i < 3; i++) │ for (int i = 0; i < 3; i++)
keys.push_back(key[i].GetPubKey()); │ keys.push_back(key[i].GetPubKey());
│
CMutableTransaction txFrom; │ CMutableTransaction txFrom;
txFrom.vout.resize(7); │ txFrom.vout.resize(7);
│
// First three are standard: │ // First three are standard:
CScript pay1 = GetScriptForDestination(key[0].GetPubKey().GetID()); │ CScript pay1 = GetScriptForDestination(PKHash(key[0].GetPubKey()));
keystore.AddCScript(pay1); │ BOOST_CHECK(keystore.AddCScript(pay1));
CScript pay1of3 = GetScriptForMultisig(1, keys); │ CScript pay1of3 = GetScriptForMultisig(1, keys);
│
txFrom.vout[0].scriptPubKey = GetScriptForDestination(CScriptID(pay1)); // P2SH (OP_ │ txFrom.vout[0].scriptPubKey = GetScriptForDestination(ScriptHash(pay1)); // P2SH (OP
txFrom.vout[0].nValue = 1000; │ txFrom.vout[0].nValue = 1000;
txFrom.vout[1].scriptPubKey = pay1; // ordinary OP_CHECKSIG │ txFrom.vout[1].scriptPubKey = pay1; // ordinary OP_CHECKSIG
txFrom.vout[1].nValue = 2000; │ txFrom.vout[1].nValue = 2000;
txFrom.vout[2].scriptPubKey = pay1of3; // ordinary OP_CHECKMULTISIG │ txFrom.vout[2].scriptPubKey = pay1of3; // ordinary OP_CHECKMULTISIG
txFrom.vout[2].nValue = 3000; │ txFrom.vout[2].nValue = 3000;
│
// vout[3] is complicated 1-of-3 AND 2-of-3 │ // vout[3] is complicated 1-of-3 AND 2-of-3
// ... that is OK if wrapped in P2SH: │ // ... that is OK if wrapped in P2SH:
CScript oneAndTwo; │ CScript oneAndTwo;
oneAndTwo << OP_1 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetPubK │ oneAndTwo << OP_1 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetPubK
oneAndTwo << OP_3 << OP_CHECKMULTISIGVERIFY; │ oneAndTwo << OP_3 << OP_CHECKMULTISIGVERIFY;
oneAndTwo << OP_2 << ToByteVector(key[3].GetPubKey()) << ToByteVector(key[4].GetPubK │ oneAndTwo << OP_2 << ToByteVector(key[3].GetPubKey()) << ToByteVector(key[4].GetPubK
oneAndTwo << OP_3 << OP_CHECKMULTISIG; │ oneAndTwo << OP_3 << OP_CHECKMULTISIG;
keystore.AddCScript(oneAndTwo); │ BOOST_CHECK(keystore.AddCScript(oneAndTwo));
txFrom.vout[3].scriptPubKey = GetScriptForDestination(CScriptID(oneAndTwo)); │ txFrom.vout[3].scriptPubKey = GetScriptForDestination(ScriptHash(oneAndTwo));
txFrom.vout[3].nValue = 4000; │ txFrom.vout[3].nValue = 4000;
│
// vout[4] is max sigops: │ // vout[4] is max sigops:
CScript fifteenSigops; fifteenSigops << OP_1; │ CScript fifteenSigops; fifteenSigops << OP_1;
for (unsigned i = 0; i < MAX_P2SH_SIGOPS; i++) │ for (unsigned i = 0; i < MAX_P2SH_SIGOPS; i++)
fifteenSigops << ToByteVector(key[i%3].GetPubKey()); │ fifteenSigops << ToByteVector(key[i%3].GetPubKey());
fifteenSigops << OP_15 << OP_CHECKMULTISIG; │ fifteenSigops << OP_15 << OP_CHECKMULTISIG;
keystore.AddCScript(fifteenSigops); │ BOOST_CHECK(keystore.AddCScript(fifteenSigops));
txFrom.vout[4].scriptPubKey = GetScriptForDestination(CScriptID(fifteenSigops)); │ txFrom.vout[4].scriptPubKey = GetScriptForDestination(ScriptHash(fifteenSigops));
txFrom.vout[4].nValue = 5000; │ txFrom.vout[4].nValue = 5000;
│
// vout[5/6] are non-standard because they exceed MAX_P2SH_SIGOPS │ // vout[5/6] are non-standard because they exceed MAX_P2SH_SIGOPS
CScript sixteenSigops; sixteenSigops << OP_16 << OP_CHECKMULTISIG; │ CScript sixteenSigops; sixteenSigops << OP_16 << OP_CHECKMULTISIG;
keystore.AddCScript(sixteenSigops); │ BOOST_CHECK(keystore.AddCScript(sixteenSigops));
txFrom.vout[5].scriptPubKey = GetScriptForDestination(CScriptID(fifteenSigops)); │ txFrom.vout[5].scriptPubKey = GetScriptForDestination(ScriptHash(sixteenSigops));
txFrom.vout[5].nValue = 5000; │ txFrom.vout[5].nValue = 5000;
CScript twentySigops; twentySigops << OP_CHECKMULTISIG; │ CScript twentySigops; twentySigops << OP_CHECKMULTISIG;
keystore.AddCScript(twentySigops); │ BOOST_CHECK(keystore.AddCScript(twentySigops));
txFrom.vout[6].scriptPubKey = GetScriptForDestination(CScriptID(twentySigops)); │ txFrom.vout[6].scriptPubKey = GetScriptForDestination(ScriptHash(twentySigops));
txFrom.vout[6].nValue = 6000; │ txFrom.vout[6].nValue = 6000;
│
coins.ModifyCoins(txFrom.GetHash())->FromTx(txFrom, 0); │ AddCoins(coins, CTransaction(txFrom), 0);
│
CMutableTransaction txTo; │ CMutableTransaction txTo;
txTo.vout.resize(1); │ txTo.vout.resize(1);
txTo.vout[0].scriptPubKey = GetScriptForDestination(key[1].GetPubKey().GetID()); │ txTo.vout[0].scriptPubKey = GetScriptForDestination(PKHash(key[1].GetPubKey()));
│
txTo.vin.resize(5); │ txTo.vin.resize(5);
for (int i = 0; i < 5; i++) │ for (int i = 0; i < 5; i++)
{ │ {
txTo.vin[i].prevout.n = i; │ txTo.vin[i].prevout.n = i;
txTo.vin[i].prevout.hash = txFrom.GetHash(); │ txTo.vin[i].prevout.hash = txFrom.GetHash();
} │ }
BOOST_CHECK(SignSignature(keystore, txFrom, txTo, 0, SIGHASH_ALL)); │ BOOST_CHECK(SignSignature(keystore, CTransaction(txFrom), txTo, 0, SIGHASH_ALL));
BOOST_CHECK(SignSignature(keystore, txFrom, txTo, 1, SIGHASH_ALL)); │ BOOST_CHECK(SignSignature(keystore, CTransaction(txFrom), txTo, 1, SIGHASH_ALL));
BOOST_CHECK(SignSignature(keystore, txFrom, txTo, 2, SIGHASH_ALL)); │ BOOST_CHECK(SignSignature(keystore, CTransaction(txFrom), txTo, 2, SIGHASH_ALL));
// SignSignature doesn't know how to sign these. We're │ // SignSignature doesn't know how to sign these. We're
// not testing validating signatures, so just create │ // not testing validating signatures, so just create
// dummy signatures that DO include the correct P2SH scripts: │ // dummy signatures that DO include the correct P2SH scripts:
txTo.vin[3].scriptSig << OP_11 << OP_11 << std::vector<unsigned char>(oneAndTwo.begi │ txTo.vin[3].scriptSig << OP_11 << OP_11 << std::vector<unsigned char>(oneAndTwo.begi
txTo.vin[4].scriptSig << std::vector<unsigned char>(fifteenSigops.begin(), fifteenSi │ txTo.vin[4].scriptSig << std::vector<unsigned char>(fifteenSigops.begin(), fifteenSi
│
BOOST_CHECK(::AreInputsStandard(txTo, coins)); │ BOOST_CHECK(::AreInputsStandard(CTransaction(txTo), coins));
// 22 P2SH sigops for all inputs (1 for vin[0], 6 for vin[3], 15 for vin[4] │ // 22 P2SH sigops for all inputs (1 for vin[0], 6 for vin[3], 15 for vin[4]
BOOST_CHECK_EQUAL(GetP2SHSigOpCount(txTo, coins), 22U); │ BOOST_CHECK_EQUAL(GetP2SHSigOpCount(CTransaction(txTo), coins), 22U);
│
CMutableTransaction txToNonStd1; │ CMutableTransaction txToNonStd1;
txToNonStd1.vout.resize(1); │ txToNonStd1.vout.resize(1);
txToNonStd1.vout[0].scriptPubKey = GetScriptForDestination(key[1].GetPubKey().GetID( │ txToNonStd1.vout[0].scriptPubKey = GetScriptForDestination(PKHash(key[1].GetPubKey()
txToNonStd1.vout[0].nValue = 1000; │ txToNonStd1.vout[0].nValue = 1000;
txToNonStd1.vin.resize(1); │ txToNonStd1.vin.resize(1);
txToNonStd1.vin[0].prevout.n = 5; │ txToNonStd1.vin[0].prevout.n = 5;
txToNonStd1.vin[0].prevout.hash = txFrom.GetHash(); │ txToNonStd1.vin[0].prevout.hash = txFrom.GetHash();
txToNonStd1.vin[0].scriptSig << std::vector<unsigned char>(sixteenSigops.begin(), si │ txToNonStd1.vin[0].scriptSig << std::vector<unsigned char>(sixteenSigops.begin(), si
│
BOOST_CHECK(!::AreInputsStandard(txToNonStd1, coins)); │ BOOST_CHECK(!::AreInputsStandard(CTransaction(txToNonStd1), coins));
BOOST_CHECK_EQUAL(GetP2SHSigOpCount(txToNonStd1, coins), 16U); │ BOOST_CHECK_EQUAL(GetP2SHSigOpCount(CTransaction(txToNonStd1), coins), 16U);
│
CMutableTransaction txToNonStd2; │ CMutableTransaction txToNonStd2;
txToNonStd2.vout.resize(1); │ txToNonStd2.vout.resize(1);
txToNonStd2.vout[0].scriptPubKey = GetScriptForDestination(key[1].GetPubKey().GetID( │ txToNonStd2.vout[0].scriptPubKey = GetScriptForDestination(PKHash(key[1].GetPubKey()
txToNonStd2.vout[0].nValue = 1000; │ txToNonStd2.vout[0].nValue = 1000;
txToNonStd2.vin.resize(1); │ txToNonStd2.vin.resize(1);
txToNonStd2.vin[0].prevout.n = 6; │ txToNonStd2.vin[0].prevout.n = 6;
txToNonStd2.vin[0].prevout.hash = txFrom.GetHash(); │ txToNonStd2.vin[0].prevout.hash = txFrom.GetHash();
txToNonStd2.vin[0].scriptSig << std::vector<unsigned char>(twentySigops.begin(), twe │ txToNonStd2.vin[0].scriptSig << std::vector<unsigned char>(twentySigops.begin(), twe
│
BOOST_CHECK(!::AreInputsStandard(txToNonStd2, coins)); │ BOOST_CHECK(!::AreInputsStandard(CTransaction(txToNonStd2), coins));
BOOST_CHECK_EQUAL(GetP2SHSigOpCount(txToNonStd2, coins), 20U); │ BOOST_CHECK_EQUAL(GetP2SHSigOpCount(CTransaction(txToNonStd2), coins), 20U);
} │
next prev up dogecoin/src/qt/transactiontablemodel.cpp:523 │ bitcoin/src/qt/transactiontablemodel.cpp:522
│
if(!index.isValid()) │ if(!index.isValid())
return QVariant(); │ return QVariant();
TransactionRecord *rec = static_cast<TransactionRecord*>(index.internalPointer()); │ TransactionRecord *rec = static_cast<TransactionRecord*>(index.internalPointer());
│
switch(role) │ const auto column = static_cast<ColumnIndex>(index.column());
{ │ switch (role) {
case RawDecorationRole: │ case RawDecorationRole:
switch(index.column()) │ switch (column) {
{ │
case Status: │ case Status:
return txStatusDecoration(rec); │ return txStatusDecoration(rec);
case Watchonly: │ case Watchonly:
return txWatchonlyDecoration(rec); │ return txWatchonlyDecoration(rec);
│ case Date: return {};
│ case Type: return {};
case ToAddress: │ case ToAddress:
return txAddressDecoration(rec); │ return txAddressDecoration(rec);
} │ case Amount: return {};
break; │ } // no default case, so the compiler can warn about missing cases
│ assert(false);
case Qt::DecorationRole: │ case Qt::DecorationRole:
{ │ {
QIcon icon = qvariant_cast<QIcon>(index.data(RawDecorationRole)); │ QIcon icon = qvariant_cast<QIcon>(index.data(RawDecorationRole));
return platformStyle->TextColorIcon(icon); │ return platformStyle->TextColorIcon(icon);
} │ }
case Qt::DisplayRole: │ case Qt::DisplayRole:
switch(index.column()) │ switch (column) {
{ │ case Status: return {};
│ case Watchonly: return {};
case Date: │ case Date:
return formatTxDate(rec); │ return formatTxDate(rec);
case Type: │ case Type:
return formatTxType(rec); │ return formatTxType(rec);
case ToAddress: │ case ToAddress:
return formatTxToAddress(rec, false); │ return formatTxToAddress(rec, false);
case Amount: │ case Amount:
return formatTxAmount(rec, true, BitcoinUnits::separatorAlways); │ return formatTxAmount(rec, true, BitcoinUnits::SeparatorStyle::ALWAYS);
} │ } // no default case, so the compiler can warn about missing cases
break; │ assert(false);
case Qt::EditRole: │ case Qt::EditRole:
// Edit role is used for sorting, so return the unformatted values │ // Edit role is used for sorting, so return the unformatted values
switch(index.column()) │ switch (column) {
{ │
case Status: │ case Status:
return QString::fromStdString(rec->status.sortKey); │ return QString::fromStdString(rec->status.sortKey);
case Date: │ case Date:
return rec->time; │ return rec->time;
case Type: │ case Type:
return formatTxType(rec); │ return formatTxType(rec);
case Watchonly: │ case Watchonly:
return (rec->involvesWatchAddress ? 1 : 0); │ return (rec->involvesWatchAddress ? 1 : 0);
case ToAddress: │ case ToAddress:
return formatTxToAddress(rec, true); │ return formatTxToAddress(rec, true);
case Amount: │ case Amount:
return qint64(rec->credit + rec->debit); │ return qint64(rec->credit + rec->debit);
} │ } // no default case, so the compiler can warn about missing cases
break; │ assert(false);
case Qt::ToolTipRole: │ case Qt::ToolTipRole:
return formatTooltip(rec); │ return formatTooltip(rec);
case Qt::TextAlignmentRole: │ case Qt::TextAlignmentRole:
return column_alignments[index.column()]; │ return column_alignments[index.column()];
case Qt::ForegroundRole: │ case Qt::ForegroundRole:
// Use the "danger" color for abandoned transactions │ // Use the "danger" color for abandoned transactions
if(rec->status.status == TransactionStatus::Abandoned) │ if(rec->status.status == TransactionStatus::Abandoned)
{ │ {
return COLOR_TX_STATUS_DANGER; │ return COLOR_TX_STATUS_DANGER;
} │ }
// Non-confirmed (but not immature) as transactions are grey │ // Non-confirmed (but not immature) as transactions are grey
if(!rec->status.countsForBalance && rec->status.status != TransactionStatus::Imm │ if(!rec->status.countsForBalance && rec->status.status != TransactionStatus::Imm
{ │ {
return COLOR_UNCONFIRMED; │ return COLOR_UNCONFIRMED;
} │ }
if(index.column() == Amount && (rec->credit+rec->debit) < 0) │ if(index.column() == Amount && (rec->credit+rec->debit) < 0)
{ │ {
return COLOR_NEGATIVE; │ return COLOR_NEGATIVE;
} │ }
if(index.column() == ToAddress) │ if(index.column() == ToAddress)
{ │ {
return addressColor(rec); │ return addressColor(rec);
} │ }
break; │ break;
case TypeRole: │ case TypeRole:
return rec->type; │ return rec->type;
case DateRole: │ case DateRole:
return QDateTime::fromTime_t(static_cast<uint>(rec->time)); │ return QDateTime::fromSecsSinceEpoch(rec->time);
case WatchonlyRole: │ case WatchonlyRole:
return rec->involvesWatchAddress; │ return rec->involvesWatchAddress;
case WatchonlyDecorationRole: │ case WatchonlyDecorationRole:
return txWatchonlyDecoration(rec); │ return txWatchonlyDecoration(rec);
case LongDescriptionRole: │ case LongDescriptionRole:
return priv->describe(rec, walletModel->getOptionsModel()->getDisplayUnit()); │ return priv->describe(walletModel->node(), walletModel->wallet(), rec, walletMod
case AddressRole: │ case AddressRole:
return QString::fromStdString(rec->address); │ return QString::fromStdString(rec->address);
case LabelRole: │ case LabelRole:
return walletModel->getAddressTableModel()->labelForAddress(QString::fromStdStri │ return walletModel->getAddressTableModel()->labelForAddress(QString::fromStdStri
case AmountRole: │ case AmountRole:
return qint64(rec->credit + rec->debit); │ return qint64(rec->credit + rec->debit);
case TxIDRole: │
return rec->getTxID(); │
case TxHashRole: │ case TxHashRole:
return QString::fromStdString(rec->hash.ToString()); │ return rec->getTxHash();
case TxHexRole: │ case TxHexRole:
return priv->getTxHex(rec); │ return priv->getTxHex(walletModel->wallet(), rec);
case TxPlainTextRole: │ case TxPlainTextRole:
{ │ {
QString details; │ QString details;
QDateTime date = QDateTime::fromTime_t(static_cast<uint>(rec->time)); │ QDateTime date = QDateTime::fromSecsSinceEpoch(rec->time);
QString txLabel = walletModel->getAddressTableModel()->labelForAddress(QStri │ QString txLabel = walletModel->getAddressTableModel()->labelForAddress(QStri
│
details.append(date.toString("M/d/yy HH:mm")); │ details.append(date.toString("M/d/yy HH:mm"));
details.append(" "); │ details.append(" ");
details.append(formatTxStatus(rec)); │ details.append(formatTxStatus(rec));
details.append(". "); │ details.append(". ");
if(!formatTxType(rec).isEmpty()) { │ if(!formatTxType(rec).isEmpty()) {
details.append(formatTxType(rec)); │ details.append(formatTxType(rec));
details.append(" "); │ details.append(" ");
} │ }
if(!rec->address.empty()) { │ if(!rec->address.empty()) {
if(txLabel.isEmpty()) │ if(txLabel.isEmpty())
details.append(tr("(no label)") + " "); │ details.append(tr("(no label)") + " ");
else { │ else {
details.append("("); │ details.append("(");
details.append(txLabel); │ details.append(txLabel);
details.append(") "); │ details.append(") ");
} │ }
details.append(QString::fromStdString(rec->address)); │ details.append(QString::fromStdString(rec->address));
details.append(" "); │ details.append(" ");
} │ }
details.append(formatTxAmount(rec, false, BitcoinUnits::separatorNever)); │ details.append(formatTxAmount(rec, false, BitcoinUnits::SeparatorStyle::NEVE
return details; │ return details;
} │ }
case ConfirmedRole: │ case ConfirmedRole:
return rec->status.countsForBalance; │ return rec->status.status == TransactionStatus::Status::Confirming || rec->statu
case FormattedAmountRole: │ case FormattedAmountRole:
// Used for copy/export, so don't include separators │ // Used for copy/export, so don't include separators
return formatTxAmount(rec, false, BitcoinUnits::separatorNever); │ return formatTxAmount(rec, false, BitcoinUnits::SeparatorStyle::NEVER);
case StatusRole: │ case StatusRole:
return rec->status.status; │ return rec->status.status;
} │ }
return QVariant(); │ return QVariant();
} │
next prev up bitcoin/src/qt/transactionrecord.cpp:33 │ dogecoin/src/qt/transactionrecord.cpp:36
│
QList<TransactionRecord> parts; │ QList<TransactionRecord> parts;
int64_t nTime = wtx.time; │ int64_t nTime = wtx.GetTxTime();
CAmount nCredit = wtx.credit; │ CAmount nCredit = wtx.GetCredit(ISMINE_ALL);
CAmount nDebit = wtx.debit; │ CAmount nDebit = wtx.GetDebit(ISMINE_ALL);
CAmount nNet = nCredit - nDebit; │ CAmount nNet = nCredit - nDebit;
uint256 hash = wtx.tx->GetHash(); │ uint256 hash = wtx.GetHash();
std::map<std::string, std::string> mapValue = wtx.value_map; │ std::map<std::string, std::string> mapValue = wtx.mapValue;
│
if (nNet > 0 || wtx.is_coinbase) │ if (nNet > 0 || wtx.IsCoinBase())
{ │ {
// │ //
// Credit │ // Credit
// │ //
for(unsigned int i = 0; i < wtx.tx->vout.size(); i++) │ for(unsigned int i = 0; i < wtx.tx->vout.size(); i++)
{ │ {
const CTxOut& txout = wtx.tx->vout[i]; │ const CTxOut& txout = wtx.tx->vout[i];
isminetype mine = wtx.txout_is_mine[i]; │ isminetype mine = wallet->IsMine(txout);
if(mine) │ if(mine)
{ │ {
TransactionRecord sub(hash, nTime); │ TransactionRecord sub(hash, nTime);
│ CTxDestination address;
sub.idx = i; // vout index │ sub.idx = i; // vout index
sub.credit = txout.nValue; │ sub.credit = txout.nValue;
sub.involvesWatchAddress = mine & ISMINE_WATCH_ONLY; │ sub.involvesWatchAddress = mine & ISMINE_WATCH_ONLY;
if (wtx.txout_address_is_mine[i]) │ if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, a
{ │ {
// Received by Bitcoin Address │ // Received by Bitcoin Address
sub.type = TransactionRecord::RecvWithAddress; │ sub.type = TransactionRecord::RecvWithAddress;
sub.address = EncodeDestination(wtx.txout_address[i]); │ sub.address = CBitcoinAddress(address).ToString();
} │ }
else │ else
{ │ {
// Received by IP connection (deprecated features), or a multisignat │ // Received by IP connection (deprecated features), or a multisignat
sub.type = TransactionRecord::RecvFromOther; │ sub.type = TransactionRecord::RecvFromOther;
sub.address = mapValue["from"]; │ sub.address = mapValue["from"];
} │ }
if (wtx.is_coinbase) │ if (wtx.IsCoinBase())
{ │ {
// Generated │ // Generated
sub.type = TransactionRecord::Generated; │ sub.type = TransactionRecord::Generated;
} │ }
│
parts.append(sub); │ parts.append(sub);
} │ }
} │ }
} │ }
else │ else
{ │ {
bool involvesWatchAddress = false; │ bool involvesWatchAddress = false;
isminetype fAllFromMe = ISMINE_SPENDABLE; │ isminetype fAllFromMe = ISMINE_SPENDABLE;
for (const isminetype mine : wtx.txin_is_mine) │ BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin)
{ │ {
│ isminetype mine = wallet->IsMine(txin);
if(mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true; │ if(mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true;
if(fAllFromMe > mine) fAllFromMe = mine; │ if(fAllFromMe > mine) fAllFromMe = mine;
} │ }
│
isminetype fAllToMe = ISMINE_SPENDABLE; │ isminetype fAllToMe = ISMINE_SPENDABLE;
for (const isminetype mine : wtx.txout_is_mine) │ BOOST_FOREACH(const CTxOut& txout, wtx.tx->vout)
{ │ {
│ isminetype mine = wallet->IsMine(txout);
if(mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true; │ if(mine & ISMINE_WATCH_ONLY) involvesWatchAddress = true;
if(fAllToMe > mine) fAllToMe = mine; │ if(fAllToMe > mine) fAllToMe = mine;
} │ }
│
if (fAllFromMe && fAllToMe) │ if (fAllFromMe && fAllToMe)
{ │ {
// Payment to self │ // Payment to self
std::string address; │ CAmount nChange = wtx.GetChange();
for (auto it = wtx.txout_address.begin(); it != wtx.txout_address.end(); ++i │
if (it != wtx.txout_address.begin()) address += ", "; │
address += EncodeDestination(*it); │
} │
│
CAmount nChange = wtx.change; │ parts.append(TransactionRecord(hash, nTime, TransactionRecord::SendToSelf, "
parts.append(TransactionRecord(hash, nTime, TransactionRecord::SendToSelf, a │ -(nDebit - nChange), nCredit - nChange));
parts.last().involvesWatchAddress = involvesWatchAddress; // maybe pass to │ parts.last().involvesWatchAddress = involvesWatchAddress; // maybe pass to
} │ }
else if (fAllFromMe) │ else if (fAllFromMe)
{ │ {
// │ //
// Debit │ // Debit
// │ //
CAmount nTxFee = nDebit - wtx.tx->GetValueOut(); │ CAmount nTxFee = nDebit - wtx.tx->GetValueOut();
│
for (unsigned int nOut = 0; nOut < wtx.tx->vout.size(); nOut++) │ for (unsigned int nOut = 0; nOut < wtx.tx->vout.size(); nOut++)
{ │ {
const CTxOut& txout = wtx.tx->vout[nOut]; │ const CTxOut& txout = wtx.tx->vout[nOut];
TransactionRecord sub(hash, nTime); │ TransactionRecord sub(hash, nTime);
sub.idx = nOut; │ sub.idx = nOut;
sub.involvesWatchAddress = involvesWatchAddress; │ sub.involvesWatchAddress = involvesWatchAddress;
│
if(wtx.txout_is_mine[nOut]) │ if(wallet->IsMine(txout))
{ │ {
// Ignore parts sent to self, as this is usually the change │ // Ignore parts sent to self, as this is usually the change
// from a transaction sent back to our own address. │ // from a transaction sent back to our own address.
continue; │ continue;
} │ }
│
if (!std::get_if<CNoDestination>(&wtx.txout_address[nOut])) │ CTxDestination address;
│ if (ExtractDestination(txout.scriptPubKey, address))
{ │ {
// Sent to Bitcoin Address │ // Sent to Bitcoin Address
sub.type = TransactionRecord::SendToAddress; │ sub.type = TransactionRecord::SendToAddress;
sub.address = EncodeDestination(wtx.txout_address[nOut]); │ sub.address = CBitcoinAddress(address).ToString();
} │ }
else │ else
{ │ {
// Sent to IP, or other non-address transaction like OP_EVAL │ // Sent to IP, or other non-address transaction like OP_EVAL
sub.type = TransactionRecord::SendToOther; │ sub.type = TransactionRecord::SendToOther;
sub.address = mapValue["to"]; │ sub.address = mapValue["to"];
} │ }
│
CAmount nValue = txout.nValue; │ CAmount nValue = txout.nValue;
/* Add fee to first output */ │ /* Add fee to first output */
if (nTxFee > 0) │ if (nTxFee > 0)
{ │ {
nValue += nTxFee; │ nValue += nTxFee;
nTxFee = 0; │ nTxFee = 0;
} │ }
sub.debit = -nValue; │ sub.debit = -nValue;
│
parts.append(sub); │ parts.append(sub);
} │ }
} │ }
else │ else
{ │ {
// │ //
// Mixed debit transaction, can't break down payees │ // Mixed debit transaction, can't break down payees
// │ //
parts.append(TransactionRecord(hash, nTime, TransactionRecord::Other, "", nN │ parts.append(TransactionRecord(hash, nTime, TransactionRecord::Other, "", nN
parts.last().involvesWatchAddress = involvesWatchAddress; │ parts.last().involvesWatchAddress = involvesWatchAddress;
} │ }
} │ }
│
return parts; │ return parts;
} │
next prev up dogecoin/src/qt/askpassphrasedialog.cpp:90 │ bitcoin/src/qt/askpassphrasedialog.cpp:87
│
SecureString oldpass, newpass1, newpass2; │ SecureString oldpass, newpass1, newpass2;
if(!model) │ if (!model && mode != Encrypt)
return; │ return;
oldpass.reserve(MAX_PASSPHRASE_SIZE); │ oldpass.reserve(MAX_PASSPHRASE_SIZE);
newpass1.reserve(MAX_PASSPHRASE_SIZE); │ newpass1.reserve(MAX_PASSPHRASE_SIZE);
newpass2.reserve(MAX_PASSPHRASE_SIZE); │ newpass2.reserve(MAX_PASSPHRASE_SIZE);
// TODO: get rid of this .c_str() by implementing SecureString::operator=(std::strin │ // TODO: get rid of this .c_str() by implementing SecureString::operator=(std::strin
// Alternately, find a way to make this input mlock()'d to begin with. │ // Alternately, find a way to make this input mlock()'d to begin with.
oldpass.assign(ui->passEdit1->text().toStdString().c_str()); │ oldpass.assign(ui->passEdit1->text().toStdString().c_str());
newpass1.assign(ui->passEdit2->text().toStdString().c_str()); │ newpass1.assign(ui->passEdit2->text().toStdString().c_str());
newpass2.assign(ui->passEdit3->text().toStdString().c_str()); │ newpass2.assign(ui->passEdit3->text().toStdString().c_str());
│
secureClearPassFields(); │ secureClearPassFields();
│
switch(mode) │ switch(mode)
{ │ {
case Encrypt: { │ case Encrypt: {
if(newpass1.empty() || newpass2.empty()) │ if(newpass1.empty() || newpass2.empty())
{ │ {
// Cannot encrypt with empty passphrase │ // Cannot encrypt with empty passphrase
break; │ break;
} │ }
QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm wal │ QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm wal
tr("Warning: If you encrypt your wallet and lose your passphrase, you w │ tr("Warning: If you encrypt your wallet and lose your passphrase, you w
QMessageBox::Yes|QMessageBox::Cancel, │ QMessageBox::Yes|QMessageBox::Cancel,
QMessageBox::Cancel); │ QMessageBox::Cancel);
if(retval == QMessageBox::Yes) │ if(retval == QMessageBox::Yes)
{ │ {
if(newpass1 == newpass2) │ if(newpass1 == newpass2)
{ │ {
if(model->setWalletEncrypted(true, newpass1)) │ QString encryption_reminder = tr("Remember that encrypting your wallet c
{ │ "your bitcoins from being stolen by malware infecting your computer.");
QMessageBox::warning(this, tr("Wallet encrypted"), │ if (m_passphrase_out) {
│ m_passphrase_out->assign(newpass1);
│ QMessageBox::warning(this, tr("Wallet to be encrypted"),
"<qt>" + │ "<qt>" +
tr("%1 will close now to finish the encryption │ tr("Your wallet is about to be encrypted. ") +
"Remember that encrypting your wallet cannot fu │
"your dogecoins from being stolen by malware in │
"<br><br><b>" + │
tr("IMPORTANT: Any previous backups you have ma │
"should be replaced with the newly generated, e │
"For security reasons, previous backups of the │
"will become useless as soon as you start using │
"</b></qt>"); │ "</b></qt>");
QApplication::quit(); │ } else {
} │ assert(model != nullptr);
else │ if (model->setWalletEncrypted(newpass1)) {
{ │ QMessageBox::warning(this, tr("Wallet encrypted"),
QMessageBox::critical(this, tr("Wallet encryption failed"), │ "<qt>" +
tr("Wallet encryption failed due to an internal │ tr("Your wallet is now encrypted. ") + encr
│ "<br><br><b>" +
│ tr("IMPORTANT: Any previous backups you hav
│ "should be replaced with the newly generate
│ "For security reasons, previous backups of
│ "will become useless as soon as you start u
│ "</b></qt>");
│ } else {
│ QMessageBox::critical(this, tr("Wallet encryption failed"),
│ tr("Wallet encryption failed due to an inte
│ }
} │ }
QDialog::accept(); // Success │ QDialog::accept(); // Success
} │ }
else │ else
{ │ {
QMessageBox::critical(this, tr("Wallet encryption failed"), │ QMessageBox::critical(this, tr("Wallet encryption failed"),
tr("The supplied passphrases do not match.")); │ tr("The supplied passphrases do not match."));
} │ }
} │ }
else │ else
{ │ {
QDialog::reject(); // Cancelled │ QDialog::reject(); // Cancelled
} │ }
} break; │ } break;
case Unlock: │ case Unlock:
if(!model->setWalletLocked(false, oldpass)) │ try {
{ │ if (!model->setWalletLocked(false, oldpass)) {
QMessageBox::critical(this, tr("Wallet unlock failed"), │ QMessageBox::critical(this, tr("Wallet unlock failed"),
tr("The passphrase entered for the wallet decryption w │ tr("The passphrase entered for the wallet decrypti
} │ } else {
else │ QDialog::accept(); // Success
{ │ }
QDialog::accept(); // Success │ } catch (const std::runtime_error& e) {
} │ QMessageBox::critical(this, tr("Wallet unlock failed"), e.what());
break; │
case Decrypt: │
if(!model->setWalletEncrypted(false, oldpass)) │
{ │
QMessageBox::critical(this, tr("Wallet decryption failed"), │
tr("The passphrase entered for the wallet decryption w │
} │
else │
{ │
QDialog::accept(); // Success │
} │ }
break; │ break;
case ChangePass: │ case ChangePass:
if(newpass1 == newpass2) │ if(newpass1 == newpass2)
{ │ {
if(model->changePassphrase(oldpass, newpass1)) │ if(model->changePassphrase(oldpass, newpass1))
{ │ {
QMessageBox::information(this, tr("Wallet encrypted"), │ QMessageBox::information(this, tr("Wallet encrypted"),
tr("Wallet passphrase was successfully changed.")); │ tr("Wallet passphrase was successfully changed."));
QDialog::accept(); // Success │ QDialog::accept(); // Success
} │ }
else │ else
{ │ {
QMessageBox::critical(this, tr("Wallet encryption failed"), │ QMessageBox::critical(this, tr("Wallet encryption failed"),
tr("The passphrase entered for the wallet decryptio │ tr("The passphrase entered for the wallet decryptio
} │ }
} │ }
else │ else
{ │ {
QMessageBox::critical(this, tr("Wallet encryption failed"), │ QMessageBox::critical(this, tr("Wallet encryption failed"),
tr("The supplied passphrases do not match.")); │ tr("The supplied passphrases do not match."));
} │ }
break; │ break;
} │ }
} │
next prev up bitcoin/src/validation.cpp:3498 │ dogecoin/src/validation.cpp:3114
│
const int nHeight = pindexPrev == nullptr ? 0 : pindexPrev->nHeight + 1; │ const int nHeight = pindexPrev == NULL ? 0 : pindexPrev->nHeight + 1;
│ const CChainParams& chainParams = Params();
│ const Consensus::Params& consensusParams = chainParams.GetConsensus(nHeight);
│
// Enforce BIP113 (Median Time Past). │ // Start enforcing BIP113 (Median Time Past) using versionbits logic.
│ // Dogecoin: We probably want to disable this
int nLockTimeFlags = 0; │ int nLockTimeFlags = 0;
if (DeploymentActiveAfter(pindexPrev, consensusParams, Consensus::DEPLOYMENT_CSV)) { │ if (VersionBitsState(pindexPrev, consensusParams, Consensus::DEPLOYMENT_CSV, version
assert(pindexPrev != nullptr); │
nLockTimeFlags |= LOCKTIME_MEDIAN_TIME_PAST; │ nLockTimeFlags |= LOCKTIME_MEDIAN_TIME_PAST;
} │ }
│
int64_t nLockTimeCutoff = (nLockTimeFlags & LOCKTIME_MEDIAN_TIME_PAST) │ int64_t nLockTimeCutoff = (nLockTimeFlags & LOCKTIME_MEDIAN_TIME_PAST)
? pindexPrev->GetMedianTimePast() │ ? pindexPrev->GetMedianTimePast()
: block.GetBlockTime(); │ : block.GetBlockTime();
│
// Check that all transactions are finalized │ // Check that all transactions are finalized
for (const auto& tx : block.vtx) { │ for (const auto& tx : block.vtx) {
if (!IsFinalTx(*tx, nHeight, nLockTimeCutoff)) { │ if (!IsFinalTx(*tx, nHeight, nLockTimeCutoff)) {
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-txns-nonfi │ return state.DoS(10, false, REJECT_INVALID, "bad-txns-nonfinal", false, "non
} │ }
} │ }
│
// Enforce rule that the coinbase starts with serialized block height │ // Enforce rule that the coinbase starts with serialized block height
if (DeploymentActiveAfter(pindexPrev, consensusParams, Consensus::DEPLOYMENT_HEIGHTI │ if (nHeight >= consensusParams.BIP34Height)
{ │ {
CScript expect = CScript() << nHeight; │ CScript expect = CScript() << nHeight;
if (block.vtx[0]->vin[0].scriptSig.size() < expect.size() || │ if (block.vtx[0]->vin[0].scriptSig.size() < expect.size() ||
!std::equal(expect.begin(), expect.end(), block.vtx[0]->vin[0].scriptSig.beg │ !std::equal(expect.begin(), expect.end(), block.vtx[0]->vin[0].scriptSig.beg
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-cb-height" │ return state.DoS(100, false, REJECT_INVALID, "bad-cb-height", false, "block
} │ }
} │ }
│
// Validation for witness commitments. │ // Validation for witness commitments.
// * We compute the witness hash (which is the hash including witnesses) of all the │ // * We compute the witness hash (which is the hash including witnesses) of all the
// coinbase (where 0x0000....0000 is used instead). │ // coinbase (where 0x0000....0000 is used instead).
// * The coinbase scriptWitness is a stack of a single 32-byte vector, containing a │ // * The coinbase scriptWitness is a stack of a single 32-byte vector, containing a
// * We build a merkle tree with all those witness hashes as leaves (similar to the │ // * We build a merkle tree with all those witness hashes as leaves (similar to the
// * There must be at least one output whose scriptPubKey is a single 36-byte push, │ // * There must be at least one output whose scriptPubKey is a single 36-byte push,
// {0xaa, 0x21, 0xa9, 0xed}, and the following 32 bytes are SHA256^2(witness root, │ // {0xaa, 0x21, 0xa9, 0xed}, and the following 32 bytes are SHA256^2(witness root,
// multiple, the last one is used. │ // multiple, the last one is used.
bool fHaveWitness = false; │ bool fHaveWitness = false;
if (DeploymentActiveAfter(pindexPrev, consensusParams, Consensus::DEPLOYMENT_SEGWIT) │ if (VersionBitsState(pindexPrev, consensusParams, Consensus::DEPLOYMENT_SEGWIT, vers
int commitpos = GetWitnessCommitmentIndex(block); │ int commitpos = GetWitnessCommitmentIndex(block);
if (commitpos != NO_WITNESS_COMMITMENT) { │ if (commitpos != -1) {
bool malleated = false; │ bool malleated = false;
uint256 hashWitness = BlockWitnessMerkleRoot(block, &malleated); │ uint256 hashWitness = BlockWitnessMerkleRoot(block, &malleated);
// The malleation check is ignored; as the transaction tree itself │ // The malleation check is ignored; as the transaction tree itself
// already does not permit it, it is impossible to trigger in the │ // already does not permit it, it is impossible to trigger in the
// witness tree. │ // witness tree.
if (block.vtx[0]->vin[0].scriptWitness.stack.size() != 1 || block.vtx[0]->vi │ if (block.vtx[0]->vin[0].scriptWitness.stack.size() != 1 || block.vtx[0]->vi
return state.Invalid(BlockValidationResult::BLOCK_MUTATED, "bad-witness- │ return state.DoS(100, false, REJECT_INVALID, "bad-witness-nonce-size", t
} │ }
CHash256().Write(hashWitness).Write(block.vtx[0]->vin[0].scriptWitness.stack │ CHash256().Write(hashWitness.begin(), 32).Write(&block.vtx[0]->vin[0].script
if (memcmp(hashWitness.begin(), &block.vtx[0]->vout[commitpos].scriptPubKey[ │ if (memcmp(hashWitness.begin(), &block.vtx[0]->vout[commitpos].scriptPubKey[
return state.Invalid(BlockValidationResult::BLOCK_MUTATED, "bad-witness- │ return state.DoS(100, false, REJECT_INVALID, "bad-witness-merkle-match",
} │ }
fHaveWitness = true; │ fHaveWitness = true;
} │ }
} │ }
│
// No witness data is allowed in blocks that don't commit to witness data, as this w │ // No witness data is allowed in blocks that don't commit to witness data, as this w
if (!fHaveWitness) { │ if (!fHaveWitness) {
for (const auto& tx : block.vtx) { │ for (size_t i = 0; i < block.vtx.size(); i++) {
if (tx->HasWitness()) { │ if (block.vtx[i]->HasWitness()) {
return state.Invalid(BlockValidationResult::BLOCK_MUTATED, "unexpected-w │ return state.DoS(100, false, REJECT_INVALID, "unexpected-witness", true,
} │ }
} │ }
} │ }
│
// After the coinbase witness reserved value and commitment are verified, │ // After the coinbase witness nonce and commitment are verified,
// we can check if the block weight passes (before we've checked the │ // we can check if the block weight passes (before we've checked the
// coinbase witness, it would be possible for the weight to be too │ // coinbase witness, it would be possible for the weight to be too
// large by filling up the coinbase witness, which doesn't change │ // large by filling up the coinbase witness, which doesn't change
// the block hash, so we couldn't mark the block as permanently │ // the block hash, so we couldn't mark the block as permanently
// failed). │ // failed).
if (GetBlockWeight(block) > MAX_BLOCK_WEIGHT) { │ if (GetBlockWeight(block) > MAX_BLOCK_WEIGHT) {
return state.Invalid(BlockValidationResult::BLOCK_CONSENSUS, "bad-blk-weight", s │ return state.DoS(100, false, REJECT_INVALID, "bad-blk-weight", false, strprintf(
} │ }
│
return true; │ return true;
} │
next prev up dogecoin/src/net_processing.cpp:475 │ bitcoin/src/net_processing.cpp:1085
│
if (count == 0) │ if (count == 0)
return; │ return;
│
vBlocks.reserve(vBlocks.size() + count); │ vBlocks.reserve(vBlocks.size() + count);
CNodeState *state = State(nodeid); │ CNodeState *state = State(nodeid);
assert(state != NULL); │ assert(state != nullptr);
│
// Make sure pindexBestKnownBlock is up to date, we'll need it. │ // Make sure pindexBestKnownBlock is up to date, we'll need it.
ProcessBlockAvailability(nodeid); │ ProcessBlockAvailability(nodeid);
│
if (state->pindexBestKnownBlock == NULL || state->pindexBestKnownBlock->nChainWork < │ if (state->pindexBestKnownBlock == nullptr || state->pindexBestKnownBlock->nChainWor
// This peer has nothing interesting. │ // This peer has nothing interesting.
return; │ return;
} │ }
│
if (state->pindexLastCommonBlock == NULL) { │ if (state->pindexLastCommonBlock == nullptr) {
// Bootstrap quickly by guessing a parent of our best tip is the forking point. │ // Bootstrap quickly by guessing a parent of our best tip is the forking point.
// Guessing wrong in either direction is not a problem. │ // Guessing wrong in either direction is not a problem.
state->pindexLastCommonBlock = chainActive[std::min(state->pindexBestKnownBlock- │ state->pindexLastCommonBlock = m_chainman.ActiveChain()[std::min(state->pindexBe
} │ }
│
// If the peer reorganized, our previous pindexLastCommonBlock may not be an ancesto │ // If the peer reorganized, our previous pindexLastCommonBlock may not be an ancesto
// of its current tip anymore. Go back enough to fix that. │ // of its current tip anymore. Go back enough to fix that.
state->pindexLastCommonBlock = LastCommonAncestor(state->pindexLastCommonBlock, stat │ state->pindexLastCommonBlock = LastCommonAncestor(state->pindexLastCommonBlock, stat
if (state->pindexLastCommonBlock == state->pindexBestKnownBlock) │ if (state->pindexLastCommonBlock == state->pindexBestKnownBlock)
return; │ return;
│
│ const Consensus::Params& consensusParams = m_chainparams.GetConsensus();
std::vector<const CBlockIndex*> vToFetch; │ std::vector<const CBlockIndex*> vToFetch;
const CBlockIndex *pindexWalk = state->pindexLastCommonBlock; │ const CBlockIndex *pindexWalk = state->pindexLastCommonBlock;
// Never fetch further than the best block we know the peer has, or more than BLOCK_ │ // Never fetch further than the best block we know the peer has, or more than BLOCK_
// linked block we have in common with this peer. The +1 is so we can detect stallin │ // linked block we have in common with this peer. The +1 is so we can detect stallin
// download that next block if the window were 1 larger. │ // download that next block if the window were 1 larger.
int nWindowEnd = state->pindexLastCommonBlock->nHeight + BLOCK_DOWNLOAD_WINDOW; │ int nWindowEnd = state->pindexLastCommonBlock->nHeight + BLOCK_DOWNLOAD_WINDOW;
int nMaxHeight = std::min<int>(state->pindexBestKnownBlock->nHeight, nWindowEnd + 1) │ int nMaxHeight = std::min<int>(state->pindexBestKnownBlock->nHeight, nWindowEnd + 1)
NodeId waitingfor = -1; │ NodeId waitingfor = -1;
while (pindexWalk->nHeight < nMaxHeight) { │ while (pindexWalk->nHeight < nMaxHeight) {
// Read up to 128 (or more, if more blocks than that are needed) successors of p │ // Read up to 128 (or more, if more blocks than that are needed) successors of p
// pindexBestKnownBlock) into vToFetch. We fetch 128, because CBlockIndex::GetAn │ // pindexBestKnownBlock) into vToFetch. We fetch 128, because CBlockIndex::GetAn
// as iterating over ~100 CBlockIndex* entries anyway. │ // as iterating over ~100 CBlockIndex* entries anyway.
int nToFetch = std::min(nMaxHeight - pindexWalk->nHeight, std::max<int>(count - │ int nToFetch = std::min(nMaxHeight - pindexWalk->nHeight, std::max<int>(count -
vToFetch.resize(nToFetch); │ vToFetch.resize(nToFetch);
pindexWalk = state->pindexBestKnownBlock->GetAncestor(pindexWalk->nHeight + nToF │ pindexWalk = state->pindexBestKnownBlock->GetAncestor(pindexWalk->nHeight + nToF
vToFetch[nToFetch - 1] = pindexWalk; │ vToFetch[nToFetch - 1] = pindexWalk;
for (unsigned int i = nToFetch - 1; i > 0; i--) { │ for (unsigned int i = nToFetch - 1; i > 0; i--) {
vToFetch[i - 1] = vToFetch[i]->pprev; │ vToFetch[i - 1] = vToFetch[i]->pprev;
} │ }
│
// Iterate over those blocks in vToFetch (in forward direction), adding the ones │ // Iterate over those blocks in vToFetch (in forward direction), adding the ones
// are not yet downloaded and not in flight to vBlocks. In the mean time, update │ // are not yet downloaded and not in flight to vBlocks. In the meantime, update
// pindexLastCommonBlock as long as all ancestors are already downloaded, or if │ // pindexLastCommonBlock as long as all ancestors are already downloaded, or if
// already part of our chain (and therefore don't need it even if pruned). │ // already part of our chain (and therefore don't need it even if pruned).
BOOST_FOREACH(const CBlockIndex* pindex, vToFetch) { │ for (const CBlockIndex* pindex : vToFetch) {
if (!pindex->IsValid(BLOCK_VALID_TREE)) { │ if (!pindex->IsValid(BLOCK_VALID_TREE)) {
// We consider the chain that this peer is on invalid. │ // We consider the chain that this peer is on invalid.
return; │ return;
} │ }
if (!State(nodeid)->fHaveWitness && IsWitnessEnabled(pindex->pprev, consensu │ if (!State(nodeid)->fHaveWitness && DeploymentActiveAt(*pindex, consensusPar
// We wouldn't download this block or its descendants from this peer. │ // We wouldn't download this block or its descendants from this peer.
return; │ return;
} │ }
if (pindex->nStatus & BLOCK_HAVE_DATA || chainActive.Contains(pindex)) { │ if (pindex->nStatus & BLOCK_HAVE_DATA || m_chainman.ActiveChain().Contains(p
if (pindex->nChainTx) │ if (pindex->HaveTxsDownloaded())
state->pindexLastCommonBlock = pindex; │ state->pindexLastCommonBlock = pindex;
} else if (mapBlocksInFlight.count(pindex->GetBlockHash()) == 0) { │ } else if (!IsBlockRequested(pindex->GetBlockHash())) {
// The block is not already downloaded, and not yet in flight. │ // The block is not already downloaded, and not yet in flight.
if (pindex->nHeight > nWindowEnd) { │ if (pindex->nHeight > nWindowEnd) {
// We reached the end of the window. │ // We reached the end of the window.
if (vBlocks.size() == 0 && waitingfor != nodeid) { │ if (vBlocks.size() == 0 && waitingfor != nodeid) {
// We aren't able to fetch anything, but we would be if the down │ // We aren't able to fetch anything, but we would be if the down
nodeStaller = waitingfor; │ nodeStaller = waitingfor;
} │ }
return; │ return;
} │ }
vBlocks.push_back(pindex); │ vBlocks.push_back(pindex);
if (vBlocks.size() == count) { │ if (vBlocks.size() == count) {
return; │ return;
} │ }
} else if (waitingfor == -1) { │ } else if (waitingfor == -1) {
// This is the first already-in-flight block. │ // This is the first already-in-flight block.
waitingfor = mapBlocksInFlight[pindex->GetBlockHash()].first; │ waitingfor = mapBlocksInFlight[pindex->GetBlockHash()].first;
} │ }
} │ }
} │ }
} │
next prev up bitcoin/src/test/cuckoocache_tests.cpp:278 │ dogecoin/src/test/cuckoocache_tests.cpp:301
│
// This test checks that for a simulation of network activity, the fresh hit │ // This test checks that for a simulation of network activity, the fresh hit
// rate is never below 99%, and the number of times that it is worse than │ // rate is never below 99%, and the number of times that it is worse than
// 99.9% are less than 1% of the time. │ // 99.9% are less than 1% of the time.
double min_hit_rate = 0.99; │ double min_hit_rate = 0.99;
double tight_hit_rate = 0.999; │ double tight_hit_rate = 0.999;
double max_rate_less_than_tight_hit_rate = 0.01; │ double max_rate_less_than_tight_hit_rate = 0.01;
// A cache that meets this specification is therefore shown to have a hit │ // A cache that meets this specification is therefore shown to have a hit
// rate of at least tight_hit_rate * (1 - max_rate_less_than_tight_hit_rate) + │ // rate of at least tight_hit_rate * (1 - max_rate_less_than_tight_hit_rate) +
// min_hit_rate*max_rate_less_than_tight_hit_rate = 0.999*99%+0.99*1% == 99.89% │ // min_hit_rate*max_rate_less_than_tight_hit_rate = 0.999*99%+0.99*1% == 99.89%
// hit rate with low variance. │ // hit rate with low variance.
│
// We use deterministic values, but this test has also passed on many │ // We use deterministic values, but this test has also passed on many
// iterations with non-deterministic values, so it isn't "overfit" to the │ // iterations with non-deterministic values, so it isn't "overfit" to the
// specific entropy in FastRandomContext(true) and implementation of the │ // specific entropy in FastRandomContext(true) and implementation of the
// cache. │ // cache.
SeedInsecureRand(SeedRand::ZEROS); │ insecure_rand = FastRandomContext(true);
│
// block_activity models a chunk of network activity. n_insert elements are │ // block_activity models a chunk of network activity. n_insert elements are
// added to the cache. The first and last n/4 are stored for removal later │ // adde to the cache. The first and last n/4 are stored for removal later
// and the middle n/2 are not stored. This models a network which uses half │ // and the middle n/2 are not stored. This models a network which uses half
// the signatures of recently (since the last block) added transactions │ // the signatures of recently (since the last block) added transactions
// immediately and never uses the other half. │ // immediately and never uses the other half.
struct block_activity { │ struct block_activity {
std::vector<uint256> reads; │ std::vector<uint256> reads;
block_activity(uint32_t n_insert, Cache& c) : reads() │ block_activity(uint32_t n_insert, Cache& c) : reads()
{ │ {
std::vector<uint256> inserts; │ std::vector<uint256> inserts;
inserts.resize(n_insert); │ inserts.resize(n_insert);
reads.reserve(n_insert / 2); │ reads.reserve(n_insert / 2);
for (uint32_t i = 0; i < n_insert; ++i) { │ for (uint32_t i = 0; i < n_insert; ++i) {
uint32_t* ptr = (uint32_t*)inserts[i].begin(); │ uint32_t* ptr = (uint32_t*)inserts[i].begin();
for (uint8_t j = 0; j < 8; ++j) │ for (uint8_t j = 0; j < 8; ++j)
*(ptr++) = InsecureRand32(); │ *(ptr++) = insecure_rand.rand32();
} │ }
for (uint32_t i = 0; i < n_insert / 4; ++i) │ for (uint32_t i = 0; i < n_insert / 4; ++i)
reads.push_back(inserts[i]); │ reads.push_back(inserts[i]);
for (uint32_t i = n_insert - (n_insert / 4); i < n_insert; ++i) │ for (uint32_t i = n_insert - (n_insert / 4); i < n_insert; ++i)
reads.push_back(inserts[i]); │ reads.push_back(inserts[i]);
for (const auto& h : inserts) │ for (auto h : inserts)
c.insert(h); │ c.insert(h);
} │ }
}; │ };
│
const uint32_t BLOCK_SIZE = 1000; │ const uint32_t BLOCK_SIZE = 10000;
// We expect window size 60 to perform reasonably given that each epoch │ // We expect window size 60 to perform reasonably given that each epoch
// stores 45% of the cache size (~472k). │ // stores 45% of the cache size (~472k).
const uint32_t WINDOW_SIZE = 60; │ const uint32_t WINDOW_SIZE = 60;
const uint32_t POP_AMOUNT = (BLOCK_SIZE / WINDOW_SIZE) / 2; │ const uint32_t POP_AMOUNT = (BLOCK_SIZE / WINDOW_SIZE) / 2;
const double load = 10; │ const double load = 10;
const size_t megabytes = 4; │ const size_t megabytes = 32;
const size_t bytes = megabytes * (1 << 20); │ const size_t bytes = megabytes * (1 << 20);
const uint32_t n_insert = static_cast<uint32_t>(load * (bytes / sizeof(uint256))); │ const uint32_t n_insert = static_cast<uint32_t>(load * (bytes / sizeof(uint256)));
│
std::vector<block_activity> hashes; │ std::vector<block_activity> hashes;
Cache set{}; │ Cache set{};
set.setup_bytes(bytes); │ set.setup_bytes(bytes);
hashes.reserve(n_insert / BLOCK_SIZE); │ hashes.reserve(n_insert / BLOCK_SIZE);
std::deque<block_activity> last_few; │ std::deque<block_activity> last_few;
uint32_t out_of_tight_tolerance = 0; │ uint32_t out_of_tight_tolerance = 0;
uint32_t total = n_insert / BLOCK_SIZE; │ uint32_t total = n_insert / BLOCK_SIZE;
// we use the deque last_few to model a sliding window of blocks. at each │ // we use the deque last_few to model a sliding window of blocks. at each
// step, each of the last WINDOW_SIZE block_activities checks the cache for │ // step, each of the last WINDOW_SIZE block_activities checks the cache for
// POP_AMOUNT of the hashes that they inserted, and marks these erased. │ // POP_AMOUNT of the hashes that they inserted, and marks these erased.
for (uint32_t i = 0; i < total; ++i) { │ for (uint32_t i = 0; i < total; ++i) {
if (last_few.size() == WINDOW_SIZE) │ if (last_few.size() == WINDOW_SIZE)
last_few.pop_front(); │ last_few.pop_front();
last_few.emplace_back(BLOCK_SIZE, set); │ last_few.emplace_back(BLOCK_SIZE, set);
uint32_t count = 0; │ uint32_t count = 0;
for (auto& act : last_few) │ for (auto& act : last_few)
for (uint32_t k = 0; k < POP_AMOUNT; ++k) { │ for (uint32_t k = 0; k < POP_AMOUNT; ++k) {
count += set.contains(act.reads.back(), true); │ count += set.contains(act.reads.back(), true);
act.reads.pop_back(); │ act.reads.pop_back();
} │ }
// We use last_few.size() rather than WINDOW_SIZE for the correct │ // We use last_few.size() rather than WINDOW_SIZE for the correct
// behavior on the first WINDOW_SIZE iterations where the deque is not │ // behavior on the first WINDOW_SIZE iterations where the deque is not
// full yet. │ // full yet.
double hit = (double(count)) / (last_few.size() * POP_AMOUNT); │ double hit = (double(count)) / (last_few.size() * POP_AMOUNT);
// Loose Check that hit rate is above min_hit_rate │ // Loose Check that hit rate is above min_hit_rate
BOOST_CHECK(hit > min_hit_rate); │ BOOST_CHECK(hit > min_hit_rate);
// Tighter check, count number of times we are less than tight_hit_rate │ // Tighter check, count number of times we are less than tight_hit_rate
// (and implicitly, greater than min_hit_rate) │ // (and implicityly, greater than min_hit_rate)
out_of_tight_tolerance += hit < tight_hit_rate; │ out_of_tight_tolerance += hit < tight_hit_rate;
} │ }
// Check that being out of tolerance happens less than │ // Check that being out of tolerance happens less than
// max_rate_less_than_tight_hit_rate of the time │ // max_rate_less_than_tight_hit_rate of the time
BOOST_CHECK(double(out_of_tight_tolerance) / double(total) < max_rate_less_than_tigh │ BOOST_CHECK(double(out_of_tight_tolerance) / double(total) < max_rate_less_than_tigh
} │
next prev up dogecoin/src/test/multisig_tests.cpp:42 │ bitcoin/src/test/multisig_tests.cpp:39
│
unsigned int flags = SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC; │ unsigned int flags = SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC;
│
ScriptError err; │ ScriptError err;
CKey key[4]; │ CKey key[4];
CAmount amount = 0; │ CAmount amount = 0;
for (int i = 0; i < 4; i++) │ for (int i = 0; i < 4; i++)
key[i].MakeNewKey(true); │ key[i].MakeNewKey(true);
│
CScript a_and_b; │ CScript a_and_b;
a_and_b << OP_2 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetPubKey │ a_and_b << OP_2 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetPubKey
│
CScript a_or_b; │ CScript a_or_b;
a_or_b << OP_1 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetPubKey( │ a_or_b << OP_1 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetPubKey(
│
CScript escrow; │ CScript escrow;
escrow << OP_2 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetPubKey( │ escrow << OP_2 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetPubKey(
│
CMutableTransaction txFrom; // Funding transaction │ CMutableTransaction txFrom; // Funding transaction
txFrom.vout.resize(3); │ txFrom.vout.resize(3);
txFrom.vout[0].scriptPubKey = a_and_b; │ txFrom.vout[0].scriptPubKey = a_and_b;
txFrom.vout[1].scriptPubKey = a_or_b; │ txFrom.vout[1].scriptPubKey = a_or_b;
txFrom.vout[2].scriptPubKey = escrow; │ txFrom.vout[2].scriptPubKey = escrow;
│
CMutableTransaction txTo[3]; // Spending transaction │ CMutableTransaction txTo[3]; // Spending transaction
for (int i = 0; i < 3; i++) │ for (int i = 0; i < 3; i++)
{ │ {
txTo[i].vin.resize(1); │ txTo[i].vin.resize(1);
txTo[i].vout.resize(1); │ txTo[i].vout.resize(1);
txTo[i].vin[0].prevout.n = i; │ txTo[i].vin[0].prevout.n = i;
txTo[i].vin[0].prevout.hash = txFrom.GetHash(); │ txTo[i].vin[0].prevout.hash = txFrom.GetHash();
txTo[i].vout[0].nValue = 1; │ txTo[i].vout[0].nValue = 1;
} │ }
│
std::vector<CKey> keys; │ std::vector<CKey> keys;
CScript s; │ CScript s;
│
// Test a AND b: │ // Test a AND b:
keys.assign(1,key[0]); │ keys.assign(1,key[0]);
keys.push_back(key[1]); │ keys.push_back(key[1]);
s = sign_multisig(a_and_b, keys, txTo[0], 0); │ s = sign_multisig(a_and_b, keys, CTransaction(txTo[0]), 0);
BOOST_CHECK(VerifyScript(s, a_and_b, NULL, flags, MutableTransactionSignatureChecker │ BOOST_CHECK(VerifyScript(s, a_and_b, nullptr, flags, MutableTransactionSignatureChec
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err)); │ BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err));
│
for (int i = 0; i < 4; i++) │ for (int i = 0; i < 4; i++)
{ │ {
keys.assign(1,key[i]); │ keys.assign(1,key[i]);
s = sign_multisig(a_and_b, keys, txTo[0], 0); │ s = sign_multisig(a_and_b, keys, CTransaction(txTo[0]), 0);
BOOST_CHECK_MESSAGE(!VerifyScript(s, a_and_b, NULL, flags, MutableTransactionSig │ BOOST_CHECK_MESSAGE(!VerifyScript(s, a_and_b, nullptr, flags, MutableTransaction
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_INVALID_STACK_OPERATION, ScriptErrorString │ BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_INVALID_STACK_OPERATION, ScriptErrorString
│
keys.assign(1,key[1]); │ keys.assign(1,key[1]);
keys.push_back(key[i]); │ keys.push_back(key[i]);
s = sign_multisig(a_and_b, keys, txTo[0], 0); │ s = sign_multisig(a_and_b, keys, CTransaction(txTo[0]), 0);
BOOST_CHECK_MESSAGE(!VerifyScript(s, a_and_b, NULL, flags, MutableTransactionSig │ BOOST_CHECK_MESSAGE(!VerifyScript(s, a_and_b, nullptr, flags, MutableTransaction
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err)); │ BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err));
} │ }
│
// Test a OR b: │ // Test a OR b:
for (int i = 0; i < 4; i++) │ for (int i = 0; i < 4; i++)
{ │ {
keys.assign(1,key[i]); │ keys.assign(1,key[i]);
s = sign_multisig(a_or_b, keys, txTo[1], 0); │ s = sign_multisig(a_or_b, keys, CTransaction(txTo[1]), 0);
if (i == 0 || i == 1) │ if (i == 0 || i == 1)
{ │ {
BOOST_CHECK_MESSAGE(VerifyScript(s, a_or_b, NULL, flags, MutableTransactionS │ BOOST_CHECK_MESSAGE(VerifyScript(s, a_or_b, nullptr, flags, MutableTransacti
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err)); │ BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err));
} │ }
else │ else
{ │ {
BOOST_CHECK_MESSAGE(!VerifyScript(s, a_or_b, NULL, flags, MutableTransaction │ BOOST_CHECK_MESSAGE(!VerifyScript(s, a_or_b, nullptr, flags, MutableTransact
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err)); │ BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err));
} │ }
} │ }
s.clear(); │ s.clear();
s << OP_0 << OP_1; │ s << OP_0 << OP_1;
BOOST_CHECK(!VerifyScript(s, a_or_b, NULL, flags, MutableTransactionSignatureChecker │ BOOST_CHECK(!VerifyScript(s, a_or_b, nullptr, flags, MutableTransactionSignatureChec
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_SIG_DER, ScriptErrorString(err)); │ BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_SIG_DER, ScriptErrorString(err));
│
│
for (int i = 0; i < 4; i++) │ for (int i = 0; i < 4; i++)
for (int j = 0; j < 4; j++) │ for (int j = 0; j < 4; j++)
{ │ {
keys.assign(1,key[i]); │ keys.assign(1,key[i]);
keys.push_back(key[j]); │ keys.push_back(key[j]);
s = sign_multisig(escrow, keys, txTo[2], 0); │ s = sign_multisig(escrow, keys, CTransaction(txTo[2]), 0);
if (i < j && i < 3 && j < 3) │ if (i < j && i < 3 && j < 3)
{ │ {
BOOST_CHECK_MESSAGE(VerifyScript(s, escrow, NULL, flags, MutableTransact │ BOOST_CHECK_MESSAGE(VerifyScript(s, escrow, nullptr, flags, MutableTrans
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err)); │ BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err));
} │ }
else │ else
{ │ {
BOOST_CHECK_MESSAGE(!VerifyScript(s, escrow, NULL, flags, MutableTransac │ BOOST_CHECK_MESSAGE(!VerifyScript(s, escrow, nullptr, flags, MutableTran
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err) │ BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err)
} │ }
} │ }
} │
next prev up dogecoin/src/qt/splashscreen.cpp:33 │ bitcoin/src/qt/splashscreen.cpp:32
│
// set reference point, paddings │ // set reference point, paddings
int paddingRight = 50; │ int paddingRight = 50;
int paddingTop = 50; │ int paddingTop = 50;
int titleVersionVSpace = 17; │ int titleVersionVSpace = 17;
int titleCopyrightVSpace = 40; │ int titleCopyrightVSpace = 40;
│
float fontFactor = 1.0; │ float fontFactor = 1.0;
float devicePixelRatio = 1.0; │ float devicePixelRatio = 1.0;
#if QT_VERSION > 0x050100 │ devicePixelRatio = static_cast<QGuiApplication*>(QCoreApplication::instance())->devi
devicePixelRatio = ((QGuiApplication*)QCoreApplication::instance())->devicePixelRati │
#endif │
│
// define text to place │ // define text to place
QString titleText = tr(PACKAGE_NAME); │ QString titleText = PACKAGE_NAME;
QString versionText = QString("Version %1").arg(QString::fromStdString(FormatFul │ QString versionText = QString("Version %1").arg(QString::fromStdString(FormatFul
QString copyrightText = QString::fromUtf8(CopyrightHolders(strprintf("\xc2\xA9 %u- │ QString copyrightText = QString::fromUtf8(CopyrightHolders(strprintf("\xc2\xA9 %u-
QString titleAddText = networkStyle->getTitleAddText(); │ QString titleAddText = networkStyle->getTitleAddText();
│
QString font = "Comic Sans MS"; │ QString font = QApplication::font().toString();
│
// create a bitmap according to device pixelratio │ // create a bitmap according to device pixelratio
QSize splashSize(480*devicePixelRatio,320*devicePixelRatio); │ QSize splashSize(480*devicePixelRatio,320*devicePixelRatio);
pixmap = QPixmap(splashSize); │ pixmap = QPixmap(splashSize);
│
#if QT_VERSION > 0x050100 │
// change to HiDPI if it makes sense │ // change to HiDPI if it makes sense
pixmap.setDevicePixelRatio(devicePixelRatio); │ pixmap.setDevicePixelRatio(devicePixelRatio);
#endif │
│
QPainter pixPaint(&pixmap); │ QPainter pixPaint(&pixmap);
pixPaint.setPen(QColor(100,100,100)); │ pixPaint.setPen(QColor(100,100,100));
│
// draw a slightly radial gradient │ // draw a slightly radial gradient
QRadialGradient gradient(QPoint(0,0), splashSize.width()/devicePixelRatio); │ QRadialGradient gradient(QPoint(0,0), splashSize.width()/devicePixelRatio);
gradient.setColorAt(0, Qt::white); │ gradient.setColorAt(0, Qt::white);
gradient.setColorAt(1, QColor(247,247,247)); │ gradient.setColorAt(1, QColor(247,247,247));
QRect rGradient(QPoint(0,0), splashSize); │ QRect rGradient(QPoint(0,0), splashSize);
pixPaint.fillRect(rGradient, gradient); │ pixPaint.fillRect(rGradient, gradient);
│
// draw the bitcoin icon, expected size of PNG: 1024x1024 │ // draw the bitcoin icon, expected size of PNG: 1024x1024
QRect rectIcon(QPoint(-150,-122), QSize(430,430)); │ QRect rectIcon(QPoint(-150,-122), QSize(430,430));
│
const QSize requiredSize(1024,1024); │ const QSize requiredSize(1024,1024);
QPixmap icon(networkStyle->getAppIcon().pixmap(requiredSize)); │ QPixmap icon(networkStyle->getAppIcon().pixmap(requiredSize));
│
pixPaint.drawPixmap(rectIcon, icon); │ pixPaint.drawPixmap(rectIcon, icon);
│
// check font size and drawing with │ // check font size and drawing with
pixPaint.setFont(QFont(font, 33*fontFactor)); │ pixPaint.setFont(QFont(font, 33*fontFactor));
QFontMetrics fm = pixPaint.fontMetrics(); │ QFontMetrics fm = pixPaint.fontMetrics();
int titleTextWidth = fm.width(titleText); │ int titleTextWidth = GUIUtil::TextWidth(fm, titleText);
if (titleTextWidth > 176) { │ if (titleTextWidth > 176) {
fontFactor = fontFactor * 176 / titleTextWidth; │ fontFactor = fontFactor * 176 / titleTextWidth;
} │ }
│
pixPaint.setFont(QFont(font, 33*fontFactor)); │ pixPaint.setFont(QFont(font, 33*fontFactor));
fm = pixPaint.fontMetrics(); │ fm = pixPaint.fontMetrics();
titleTextWidth = fm.width(titleText); │ titleTextWidth = GUIUtil::TextWidth(fm, titleText);
pixPaint.drawText(pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight,paddin │ pixPaint.drawText(pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight,paddin
│
pixPaint.setFont(QFont(font, 15*fontFactor)); │ pixPaint.setFont(QFont(font, 15*fontFactor));
│
// if the version string is to long, reduce size │ // if the version string is too long, reduce size
fm = pixPaint.fontMetrics(); │ fm = pixPaint.fontMetrics();
int versionTextWidth = fm.width(versionText); │ int versionTextWidth = GUIUtil::TextWidth(fm, versionText);
if(versionTextWidth > titleTextWidth+paddingRight-10) { │ if(versionTextWidth > titleTextWidth+paddingRight-10) {
pixPaint.setFont(QFont(font, 10*fontFactor)); │ pixPaint.setFont(QFont(font, 10*fontFactor));
titleVersionVSpace -= 5; │ titleVersionVSpace -= 5;
} │ }
pixPaint.drawText(pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight+2,padd │ pixPaint.drawText(pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight+2,padd
│
// draw copyright stuff │ // draw copyright stuff
{ │ {
pixPaint.setFont(QFont(font, 10*fontFactor)); │ pixPaint.setFont(QFont(font, 10*fontFactor));
const int x = pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight; │ const int x = pixmap.width()/devicePixelRatio-titleTextWidth-paddingRight;
const int y = paddingTop+titleCopyrightVSpace; │ const int y = paddingTop+titleCopyrightVSpace;
QRect copyrightRect(x, y, pixmap.width() - x - paddingRight, pixmap.height() - y │ QRect copyrightRect(x, y, pixmap.width() - x - paddingRight, pixmap.height() - y
pixPaint.drawText(copyrightRect, Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap │ pixPaint.drawText(copyrightRect, Qt::AlignLeft | Qt::AlignTop | Qt::TextWordWrap
} │ }
│
// draw additional text if special network │ // draw additional text if special network
if(!titleAddText.isEmpty()) { │ if(!titleAddText.isEmpty()) {
QFont boldFont = QFont(font, 10*fontFactor); │ QFont boldFont = QFont(font, 10*fontFactor);
boldFont.setWeight(QFont::Bold); │ boldFont.setWeight(QFont::Bold);
pixPaint.setFont(boldFont); │ pixPaint.setFont(boldFont);
fm = pixPaint.fontMetrics(); │ fm = pixPaint.fontMetrics();
int titleAddTextWidth = fm.width(titleAddText); │ int titleAddTextWidth = GUIUtil::TextWidth(fm, titleAddText);
pixPaint.drawText(pixmap.width()/devicePixelRatio-titleAddTextWidth-10,15,titleA │ pixPaint.drawText(pixmap.width()/devicePixelRatio-titleAddTextWidth-10,15,titleA
} │ }
│
pixPaint.end(); │ pixPaint.end();
│
// Set window title │ // Set window title
setWindowTitle(titleText + " " + titleAddText); │ setWindowTitle(titleText + " " + titleAddText);
│
// Resize window and move to center of desktop, disallow resizing │ // Resize window and move to center of desktop, disallow resizing
QRect r(QPoint(), QSize(pixmap.size().width()/devicePixelRatio,pixmap.size().height( │ QRect r(QPoint(), QSize(pixmap.size().width()/devicePixelRatio,pixmap.size().height(
resize(r.size()); │ resize(r.size());
setFixedSize(r.size()); │ setFixedSize(r.size());
move(QApplication::desktop()->screenGeometry().center() - r.center()); │ move(QGuiApplication::primaryScreen()->geometry().center() - r.center());
│
subscribeToCoreSignals(); │ installEventFilter(this);
│
│ GUIUtil::handleCloseWindowShortcut(this);
} │
next prev up dogecoin/src/test/script_tests.cpp:1089 │ bitcoin/src/test/script_tests.cpp:1091
│
ScriptError err; │ ScriptError err;
CKey key1, key2, key3, key4; │ CKey key1, key2, key3, key4;
key1.MakeNewKey(true); │ key1.MakeNewKey(true);
key2.MakeNewKey(false); │ key2.MakeNewKey(false);
key3.MakeNewKey(true); │ key3.MakeNewKey(true);
key4.MakeNewKey(false); │ key4.MakeNewKey(false);
│
CScript scriptPubKey23; │ CScript scriptPubKey23;
scriptPubKey23 << OP_2 << ToByteVector(key1.GetPubKey()) << ToByteVector(key2.GetPub │ scriptPubKey23 << OP_2 << ToByteVector(key1.GetPubKey()) << ToByteVector(key2.GetPub
│
CMutableTransaction txFrom23 = BuildCreditingTransaction(scriptPubKey23); │ const CTransaction txFrom23{BuildCreditingTransaction(scriptPubKey23)};
CMutableTransaction txTo23 = BuildSpendingTransaction(CScript(), CScriptWitness(), t │ CMutableTransaction txTo23 = BuildSpendingTransaction(CScript(), CScriptWitness(), t
│
std::vector<CKey> keys; │ std::vector<CKey> keys;
keys.push_back(key1); keys.push_back(key2); │ keys.push_back(key1); keys.push_back(key2);
CScript goodsig1 = sign_multisig(scriptPubKey23, keys, txTo23); │ CScript goodsig1 = sign_multisig(scriptPubKey23, keys, CTransaction(txTo23));
BOOST_CHECK(VerifyScript(goodsig1, scriptPubKey23, NULL, flags, MutableTransactionSi │ BOOST_CHECK(VerifyScript(goodsig1, scriptPubKey23, nullptr, gFlags, MutableTransacti
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err)); │ BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err));
│
keys.clear(); │ keys.clear();
keys.push_back(key1); keys.push_back(key3); │ keys.push_back(key1); keys.push_back(key3);
CScript goodsig2 = sign_multisig(scriptPubKey23, keys, txTo23); │ CScript goodsig2 = sign_multisig(scriptPubKey23, keys, CTransaction(txTo23));
BOOST_CHECK(VerifyScript(goodsig2, scriptPubKey23, NULL, flags, MutableTransactionSi │ BOOST_CHECK(VerifyScript(goodsig2, scriptPubKey23, nullptr, gFlags, MutableTransacti
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err)); │ BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err));
│
keys.clear(); │ keys.clear();
keys.push_back(key2); keys.push_back(key3); │ keys.push_back(key2); keys.push_back(key3);
CScript goodsig3 = sign_multisig(scriptPubKey23, keys, txTo23); │ CScript goodsig3 = sign_multisig(scriptPubKey23, keys, CTransaction(txTo23));
BOOST_CHECK(VerifyScript(goodsig3, scriptPubKey23, NULL, flags, MutableTransactionSi │ BOOST_CHECK(VerifyScript(goodsig3, scriptPubKey23, nullptr, gFlags, MutableTransacti
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err)); │ BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err));
│
keys.clear(); │ keys.clear();
keys.push_back(key2); keys.push_back(key2); // Can't re-use sig │ keys.push_back(key2); keys.push_back(key2); // Can't re-use sig
CScript badsig1 = sign_multisig(scriptPubKey23, keys, txTo23); │ CScript badsig1 = sign_multisig(scriptPubKey23, keys, CTransaction(txTo23));
BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey23, NULL, flags, MutableTransactionSi │ BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey23, nullptr, gFlags, MutableTransacti
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err)); │ BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err));
│
keys.clear(); │ keys.clear();
keys.push_back(key2); keys.push_back(key1); // sigs must be in correct order │ keys.push_back(key2); keys.push_back(key1); // sigs must be in correct order
CScript badsig2 = sign_multisig(scriptPubKey23, keys, txTo23); │ CScript badsig2 = sign_multisig(scriptPubKey23, keys, CTransaction(txTo23));
BOOST_CHECK(!VerifyScript(badsig2, scriptPubKey23, NULL, flags, MutableTransactionSi │ BOOST_CHECK(!VerifyScript(badsig2, scriptPubKey23, nullptr, gFlags, MutableTransacti
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err)); │ BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err));
│
keys.clear(); │ keys.clear();
keys.push_back(key3); keys.push_back(key2); // sigs must be in correct order │ keys.push_back(key3); keys.push_back(key2); // sigs must be in correct order
CScript badsig3 = sign_multisig(scriptPubKey23, keys, txTo23); │ CScript badsig3 = sign_multisig(scriptPubKey23, keys, CTransaction(txTo23));
BOOST_CHECK(!VerifyScript(badsig3, scriptPubKey23, NULL, flags, MutableTransactionSi │ BOOST_CHECK(!VerifyScript(badsig3, scriptPubKey23, nullptr, gFlags, MutableTransacti
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err)); │ BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err));
│
keys.clear(); │ keys.clear();
keys.push_back(key4); keys.push_back(key2); // sigs must match pubkeys │ keys.push_back(key4); keys.push_back(key2); // sigs must match pubkeys
CScript badsig4 = sign_multisig(scriptPubKey23, keys, txTo23); │ CScript badsig4 = sign_multisig(scriptPubKey23, keys, CTransaction(txTo23));
BOOST_CHECK(!VerifyScript(badsig4, scriptPubKey23, NULL, flags, MutableTransactionSi │ BOOST_CHECK(!VerifyScript(badsig4, scriptPubKey23, nullptr, gFlags, MutableTransacti
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err)); │ BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err));
│
keys.clear(); │ keys.clear();
keys.push_back(key1); keys.push_back(key4); // sigs must match pubkeys │ keys.push_back(key1); keys.push_back(key4); // sigs must match pubkeys
CScript badsig5 = sign_multisig(scriptPubKey23, keys, txTo23); │ CScript badsig5 = sign_multisig(scriptPubKey23, keys, CTransaction(txTo23));
BOOST_CHECK(!VerifyScript(badsig5, scriptPubKey23, NULL, flags, MutableTransactionSi │ BOOST_CHECK(!VerifyScript(badsig5, scriptPubKey23, nullptr, gFlags, MutableTransacti
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err)); │ BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err));
│
keys.clear(); // Must have signatures │ keys.clear(); // Must have signatures
CScript badsig6 = sign_multisig(scriptPubKey23, keys, txTo23); │ CScript badsig6 = sign_multisig(scriptPubKey23, keys, CTransaction(txTo23));
BOOST_CHECK(!VerifyScript(badsig6, scriptPubKey23, NULL, flags, MutableTransactionSi │ BOOST_CHECK(!VerifyScript(badsig6, scriptPubKey23, nullptr, gFlags, MutableTransacti
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_INVALID_STACK_OPERATION, ScriptErrorString(err │ BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_INVALID_STACK_OPERATION, ScriptErrorString(err
} │
next prev up bitcoin/src/test/transaction_tests.cpp:193 │ bitcoin/src/test/transaction_tests.cpp:281
│
UniValue test = tests[idx]; │ UniValue test = tests[idx];
std::string strTest = test.write(); │ std::string strTest = test.write();
if (test[0].isArray()) │ if (test[0].isArray())
{ │ {
if (test.size() != 3 || !test[1].isStr() || !test[2].isStr()) │ if (test.size() != 3 || !test[1].isStr() || !test[2].isStr())
{ │ {
BOOST_ERROR("Bad test: " << strTest); │ BOOST_ERROR("Bad test: " << strTest);
continue; │ continue;
} │ }
│
std::map<COutPoint, CScript> mapprevOutScriptPubKeys; │ std::map<COutPoint, CScript> mapprevOutScriptPubKeys;
std::map<COutPoint, int64_t> mapprevOutValues; │ std::map<COutPoint, int64_t> mapprevOutValues;
UniValue inputs = test[0].get_array(); │ UniValue inputs = test[0].get_array();
bool fValid = true; │ bool fValid = true;
for (unsigned int inpIdx = 0; inpIdx < inputs.size(); inpIdx++) { │ for (unsigned int inpIdx = 0; inpIdx < inputs.size(); inpIdx++) {
const UniValue& input = inputs[inpIdx]; │ const UniValue& input = inputs[inpIdx];
if (!input.isArray()) { │ if (!input.isArray()) {
fValid = false; │ fValid = false;
break; │ break;
} │ }
UniValue vinput = input.get_array(); │ UniValue vinput = input.get_array();
if (vinput.size() < 3 || vinput.size() > 4) │ if (vinput.size() < 3 || vinput.size() > 4)
{ │ {
fValid = false; │ fValid = false;
break; │ break;
} │ }
COutPoint outpoint{uint256S(vinput[0].get_str()), uint32_t(vinput[1].get │ COutPoint outpoint{uint256S(vinput[0].get_str()), uint32_t(vinput[1].get
mapprevOutScriptPubKeys[outpoint] = ParseScript(vinput[2].get_str()); │ mapprevOutScriptPubKeys[outpoint] = ParseScript(vinput[2].get_str());
if (vinput.size() >= 4) │ if (vinput.size() >= 4)
{ │ {
mapprevOutValues[outpoint] = vinput[3].get_int64(); │ mapprevOutValues[outpoint] = vinput[3].get_int64();
} │ }
} │ }
if (!fValid) │ if (!fValid)
{ │ {
BOOST_ERROR("Bad test: " << strTest); │ BOOST_ERROR("Bad test: " << strTest);
continue; │ continue;
} │ }
│
std::string transaction = test[1].get_str(); │ std::string transaction = test[1].get_str();
CDataStream stream(ParseHex(transaction), SER_NETWORK, PROTOCOL_VERSION); │ CDataStream stream(ParseHex(transaction), SER_NETWORK, PROTOCOL_VERSION );
CTransaction tx(deserialize, stream); │ CTransaction tx(deserialize, stream);
│
TxValidationState state; │ TxValidationState state;
BOOST_CHECK_MESSAGE(CheckTransaction(tx, state), strTest); │ if (!CheckTransaction(tx, state) || state.IsInvalid()) {
BOOST_CHECK(state.IsValid()); │ BOOST_CHECK_MESSAGE(test[2].get_str() == "BADTX", strTest);
│ continue;
│ }
│
PrecomputedTransactionData txdata(tx); │ PrecomputedTransactionData txdata(tx);
unsigned int verify_flags = ParseScriptFlags(test[2].get_str()); │ unsigned int verify_flags = ParseScriptFlags(test[2].get_str());
│
// Check that the test gives a valid combination of flags (otherwise VerifyS │ // Check that the test gives a valid combination of flags (otherwise VerifyS
if (~verify_flags != FillFlags(~verify_flags)) { │ if (verify_flags != FillFlags(verify_flags)) {
BOOST_ERROR("Bad test flags: " << strTest); │ BOOST_ERROR("Bad test flags: " << strTest);
} │ }
│
BOOST_CHECK_MESSAGE(CheckTxScripts(tx, mapprevOutScriptPubKeys, mapprevOutVa │ // Not using FillFlags() in the main test, in order to detect invalid verify
"Tx unexpectedly failed: " << strTest); │ BOOST_CHECK_MESSAGE(CheckTxScripts(tx, mapprevOutScriptPubKeys, mapprevOutVa
│ "Tx unexpectedly passed: " << strTest);
│
// Backwards compatibility of script verification flags: Removing any flag(s │ // Backwards compatibility of script verification flags: Adding any flag(s)
for (const auto& [name, flag] : mapFlagNames) { │ for (const auto& [name, flag] : mapFlagNames) {
// Removing individual flags │ unsigned int flags = FillFlags(verify_flags | flag);
unsigned int flags = TrimFlags(~(verify_flags | flag)); │ // Adding individual flags
if (!CheckTxScripts(tx, mapprevOutScriptPubKeys, mapprevOutValues, flags │ if (!CheckTxScripts(tx, mapprevOutScriptPubKeys, mapprevOutValues, flags
BOOST_ERROR("Tx unexpectedly failed with flag " << name << " unset: │ BOOST_ERROR("Tx unexpectedly passed with flag " << name << " set: "
} │ }
// Removing random combinations of flags │ // Adding random combinations of flags
flags = TrimFlags(~(verify_flags | (unsigned int)InsecureRandBits(mapFla │ flags = FillFlags(verify_flags | (unsigned int)InsecureRandBits(mapFlagN
if (!CheckTxScripts(tx, mapprevOutScriptPubKeys, mapprevOutValues, flags │ if (!CheckTxScripts(tx, mapprevOutScriptPubKeys, mapprevOutValues, flags
BOOST_ERROR("Tx unexpectedly failed with random flags " << ToString( │ BOOST_ERROR("Tx unexpectedly passed with random flags " << name << "
} │ }
} │ }
│
// Check that flags are maximal: transaction should fail if any unset flags │ // Check that flags are minimal: transaction should succeed if any set flags
for (auto flags_excluding_one : ExcludeIndividualFlags(verify_flags)) { │ for (auto flags_excluding_one : ExcludeIndividualFlags(verify_flags)) {
if (!CheckTxScripts(tx, mapprevOutScriptPubKeys, mapprevOutValues, ~flag │ if (!CheckTxScripts(tx, mapprevOutScriptPubKeys, mapprevOutValues, flags
BOOST_ERROR("Too many flags unset: " << strTest); │ BOOST_ERROR("Too many flags set: " << strTest);
} │ }
} │ }
} │ }
} │
next prev up dogecoin/src/net_processing.cpp:2177 │ bitcoin/src/net_processing.cpp:3759
│
│ // Ignore blocktxn received while importing
│ if (fImporting || fReindex) {
│ LogPrint(BCLog::NET, "Unexpected blocktxn message received from peer %d\n",
│ return;
│ }
│
BlockTransactions resp; │ BlockTransactions resp;
vRecv >> resp; │ vRecv >> resp;
│
std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>(); │ std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>();
bool fBlockRead = false; │ bool fBlockRead = false;
{ │ {
LOCK(cs_main); │ LOCK(cs_main);
│
std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator> >::ite │ std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator> >::ite
if (it == mapBlocksInFlight.end() || !it->second.second->partialBlock || │ if (it == mapBlocksInFlight.end() || !it->second.second->partialBlock ||
it->second.first != pfrom->GetId()) { │ it->second.first != pfrom.GetId()) {
LogPrint("net", "Peer %d sent us block transactions for block we weren't │ LogPrint(BCLog::NET, "Peer %d sent us block transactions for block we we
return true; │ return;
} │ }
│
PartiallyDownloadedBlock& partialBlock = *it->second.second->partialBlock; │ PartiallyDownloadedBlock& partialBlock = *it->second.second->partialBlock;
ReadStatus status = partialBlock.FillBlock(*pblock, resp.txn); │ ReadStatus status = partialBlock.FillBlock(*pblock, resp.txn);
if (status == READ_STATUS_INVALID) { │ if (status == READ_STATUS_INVALID) {
MarkBlockAsReceived(resp.blockhash); // Reset in-flight state in case of │ RemoveBlockRequest(resp.blockhash); // Reset in-flight state in case Mis
Misbehaving(pfrom->GetId(), 100); │ Misbehaving(pfrom.GetId(), 100, "invalid compact block/non-matching bloc
LogPrintf("Peer %d sent us invalid compact block/non-matching block tran │ return;
return true; │
} else if (status == READ_STATUS_FAILED) { │ } else if (status == READ_STATUS_FAILED) {
// Might have collided, fall back to getdata now :( │ // Might have collided, fall back to getdata now :(
std::vector<CInv> invs; │ std::vector<CInv> invs;
invs.push_back(CInv(MSG_BLOCK | GetFetchFlags(pfrom, chainActive.Tip(), │ invs.push_back(CInv(MSG_BLOCK | GetFetchFlags(pfrom), resp.blockhash));
connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::GETDATA, invs)); │ m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::GETDATA, invs));
} else { │ } else {
// Block is either okay, or possibly we received │ // Block is either okay, or possibly we received
// READ_STATUS_CHECKBLOCK_FAILED. │ // READ_STATUS_CHECKBLOCK_FAILED.
// Note that CheckBlock can only fail for one of a few reasons: │ // Note that CheckBlock can only fail for one of a few reasons:
// 1. bad-proof-of-work (impossible here, because we've already │ // 1. bad-proof-of-work (impossible here, because we've already
// accepted the header) │ // accepted the header)
// 2. merkleroot doesn't match the transactions given (already │ // 2. merkleroot doesn't match the transactions given (already
// caught in FillBlock with READ_STATUS_FAILED, so │ // caught in FillBlock with READ_STATUS_FAILED, so
// impossible here) │ // impossible here)
// 3. the block is otherwise invalid (eg invalid coinbase, │ // 3. the block is otherwise invalid (eg invalid coinbase,
// block is too big, too many legacy sigops, etc). │ // block is too big, too many legacy sigops, etc).
// So if CheckBlock failed, #3 is the only possibility. │ // So if CheckBlock failed, #3 is the only possibility.
// Under BIP 152, we don't DoS-ban unless proof of work is │ // Under BIP 152, we don't discourage the peer unless proof of work is
// invalid (we don't require all the stateless checks to have │ // invalid (we don't require all the stateless checks to have
// been run). This is handled below, so just treat this as │ // been run). This is handled below, so just treat this as
// though the block was successfully read, and rely on the │ // though the block was successfully read, and rely on the
// handling in ProcessNewBlock to ensure the block index is │ // handling in ProcessNewBlock to ensure the block index is
// updated, reject messages go out, etc. │ // updated, etc.
MarkBlockAsReceived(resp.blockhash); // it is now an empty pointer │ RemoveBlockRequest(resp.blockhash); // it is now an empty pointer
fBlockRead = true; │ fBlockRead = true;
// mapBlockSource is only used for sending reject messages and DoS score │ // mapBlockSource is used for potentially punishing peers and
// so the race between here and cs_main in ProcessNewBlock is fine. │ // updating which peers send us compact blocks, so the race
│ // between here and cs_main in ProcessNewBlock is fine.
// BIP 152 permits peers to relay compact blocks after validating │ // BIP 152 permits peers to relay compact blocks after validating
// the header only; we should not punish peers if the block turns │ // the header only; we should not punish peers if the block turns
// out to be invalid. │ // out to be invalid.
mapBlockSource.emplace(resp.blockhash, std::make_pair(pfrom->GetId(), fa │ mapBlockSource.emplace(resp.blockhash, std::make_pair(pfrom.GetId(), fal
} │ }
} // Don't hold cs_main when we call into ProcessNewBlock │ } // Don't hold cs_main when we call into ProcessNewBlock
if (fBlockRead) { │ if (fBlockRead) {
bool fNewBlock = false; │
// Since we requested this block (it was in mapBlocksInFlight), force it to │ // Since we requested this block (it was in mapBlocksInFlight), force it to
// even if it would not be a candidate for new tip (missing previous block, │ // even if it would not be a candidate for new tip (missing previous block,
ProcessNewBlock(chainparams, pblock, true, &fNewBlock); │ // This bypasses some anti-DoS logic in AcceptBlock (eg to prevent
if (fNewBlock) │ // disk-space attacks), but this should be safe due to the
pfrom->nLastBlockTime = GetTime(); │ // protections in the compact block handler -- see related comment
│ // in compact block optimistic reconstruction handling.
│ ProcessBlock(pfrom, pblock, /*force_processing=*/true);
} │ }
│ return;
} │
next prev up dogecoin/src/wallet/db.cpp:356 │ bitcoin/src/wallet/bdb.cpp:456
│
LOCK(bitdb.cs_db); │ {
if (!bitdb.mapFileUseCount.count(strFile) || bitdb.mapFileUseCount[strFile] │ LOCK(cs_db);
│ const std::string strFile = fs::PathToString(m_filename);
│ if (m_refcount <= 0) {
// Flush log data to the dat file │ // Flush log data to the dat file
bitdb.CloseDb(strFile); │ env->CloseDb(m_filename);
bitdb.CheckpointLSN(strFile); │ env->CheckpointLSN(strFile);
bitdb.mapFileUseCount.erase(strFile); │ m_refcount = -1;
│
bool fSuccess = true; │ bool fSuccess = true;
LogPrintf("CDB::Rewrite: Rewriting %s...\n", strFile); │ LogPrintf("BerkeleyBatch::Rewrite: Rewriting %s...\n", strFile);
string strFileRes = strFile + ".rewrite"; │ std::string strFileRes = strFile + ".rewrite";
{ // surround usage of db with extra {} │ { // surround usage of db with extra {}
CDB db(strFile.c_str(), "r"); │ BerkeleyBatch db(*this, true);
Db* pdbCopy = new Db(bitdb.dbenv, 0); │ std::unique_ptr<Db> pdbCopy = std::make_unique<Db>(env->dbenv.get(),
│
int ret = pdbCopy->open(NULL, // Txn pointer │ int ret = pdbCopy->open(nullptr, // Txn pointer
strFileRes.c_str(), // Filename │ strFileRes.c_str(), // Filename
"main", // Logical db name │ "main", // Logical db name
DB_BTREE, // Database type │ DB_BTREE, // Database type
DB_CREATE, // Flags │ DB_CREATE, // Flags
0); │ 0);
if (ret > 0) { │ if (ret > 0) {
LogPrintf("CDB::Rewrite: Can't create database file %s\n", strFi │ LogPrintf("BerkeleyBatch::Rewrite: Can't create database file %s
fSuccess = false; │ fSuccess = false;
} │ }
│
Dbc* pcursor = db.GetCursor(); │ if (db.StartCursor()) {
if (pcursor) │
while (fSuccess) { │ while (fSuccess) {
CDataStream ssKey(SER_DISK, CLIENT_VERSION); │ CDataStream ssKey(SER_DISK, CLIENT_VERSION);
CDataStream ssValue(SER_DISK, CLIENT_VERSION); │ CDataStream ssValue(SER_DISK, CLIENT_VERSION);
int ret1 = db.ReadAtCursor(pcursor, ssKey, ssValue); │ bool complete;
if (ret1 == DB_NOTFOUND) { │ bool ret1 = db.ReadAtCursor(ssKey, ssValue, complete);
pcursor->close(); │ if (complete) {
break; │ break;
} else if (ret1 != 0) { │ } else if (!ret1) {
pcursor->close(); │
fSuccess = false; │ fSuccess = false;
break; │ break;
} │ }
if (pszSkip && │ if (pszSkip &&
strncmp(ssKey.data(), pszSkip, std::min(ssKey.size(), st │ strncmp((const char*)ssKey.data(), pszSkip, std::min(ssK
continue; │ continue;
if (strncmp(ssKey.data(), "\x07version", 8) == 0) { │ if (strncmp((const char*)ssKey.data(), "\x07version", 8) ==
// Update version: │ // Update version:
ssValue.clear(); │ ssValue.clear();
ssValue << CLIENT_VERSION; │ ssValue << CLIENT_VERSION;
} │ }
Dbt datKey(ssKey.data(), ssKey.size()); │ Dbt datKey(ssKey.data(), ssKey.size());
Dbt datValue(ssValue.data(), ssValue.size()); │ Dbt datValue(ssValue.data(), ssValue.size());
int ret2 = pdbCopy->put(NULL, &datKey, &datValue, DB_NOOVERW │ int ret2 = pdbCopy->put(nullptr, &datKey, &datValue, DB_NOOV
if (ret2 > 0) │ if (ret2 > 0)
fSuccess = false; │ fSuccess = false;
} │ }
│ db.CloseCursor();
│ }
if (fSuccess) { │ if (fSuccess) {
db.Close(); │ db.Close();
bitdb.CloseDb(strFile); │ env->CloseDb(m_filename);
if (pdbCopy->close(0)) │ if (pdbCopy->close(0))
fSuccess = false; │ fSuccess = false;
delete pdbCopy; │ } else {
│ pdbCopy->close(0);
} │ }
} │ }
if (fSuccess) { │ if (fSuccess) {
Db dbA(bitdb.dbenv, 0); │ Db dbA(env->dbenv.get(), 0);
if (dbA.remove(strFile.c_str(), NULL, 0)) │ if (dbA.remove(strFile.c_str(), nullptr, 0))
fSuccess = false; │ fSuccess = false;
Db dbB(bitdb.dbenv, 0); │ Db dbB(env->dbenv.get(), 0);
if (dbB.rename(strFileRes.c_str(), NULL, strFile.c_str(), 0)) │ if (dbB.rename(strFileRes.c_str(), nullptr, strFile.c_str(), 0))
fSuccess = false; │ fSuccess = false;
} │ }
if (!fSuccess) │ if (!fSuccess)
LogPrintf("CDB::Rewrite: Failed to rewrite database file %s\n", strF │ LogPrintf("BerkeleyBatch::Rewrite: Failed to rewrite database file %
return fSuccess; │ return fSuccess;
} │ }
│ UninterruptibleSleep(std::chrono::milliseconds{100});
│
next prev up bitcoin/src/qt/addresstablemodel.cpp:70 │ dogecoin/src/qt/addresstablemodel.cpp:70
│
public: │ public:
│ CWallet *wallet;
QList<AddressTableEntry> cachedAddressTable; │ QList<AddressTableEntry> cachedAddressTable;
AddressTableModel *parent; │ AddressTableModel *parent;
│
explicit AddressTablePriv(AddressTableModel *_parent): │ AddressTablePriv(CWallet *_wallet, AddressTableModel *_parent):
parent(_parent) {} │ wallet(_wallet), parent(_parent) {}
│
void refreshAddressTable(interfaces::Wallet& wallet, bool pk_hash_only = false) │ void refreshAddressTable()
{ │ {
cachedAddressTable.clear(); │ cachedAddressTable.clear();
{ │ {
for (const auto& address : wallet.getAddresses()) │ LOCK(wallet->cs_wallet);
│ BOOST_FOREACH(const PAIRTYPE(CTxDestination, CAddressBookData)& item, wallet
{ │ {
if (pk_hash_only && !std::holds_alternative<PKHash>(address.dest)) { │ const CBitcoinAddress& address = item.first;
continue; │ bool fMine = IsMine(*wallet, address.Get());
} │
AddressTableEntry::Type addressType = translateTransactionType( │ AddressTableEntry::Type addressType = translateTransactionType(
QString::fromStdString(address.purpose), address.is_mine); │ QString::fromStdString(item.second.purpose), fMine);
│ const std::string& strName = item.second.name;
cachedAddressTable.append(AddressTableEntry(addressType, │ cachedAddressTable.append(AddressTableEntry(addressType,
QString::fromStdString(address.name), │ QString::fromStdString(strName),
QString::fromStdString(EncodeDestination(address.dest) │ QString::fromStdString(address.ToString())));
} │ }
} │ }
// std::lower_bound() and std::upper_bound() require our cachedAddressTable list │ // qLowerBound() and qUpperBound() require our cachedAddressTable list to be sor
// Even though the map is already sorted this re-sorting step is needed because │ // Even though the map is already sorted this re-sorting step is needed because
// is sorted by binary address, not by base58() address. │ // is sorted by binary address, not by base58() address.
std::sort(cachedAddressTable.begin(), cachedAddressTable.end(), AddressTableEntr │ qSort(cachedAddressTable.begin(), cachedAddressTable.end(), AddressTableEntryLes
} │ }
│
void updateEntry(const QString &address, const QString &label, bool isMine, const QS │ void updateEntry(const QString &address, const QString &label, bool isMine, const QS
{ │ {
// Find address / label in model │ // Find address / label in model
QList<AddressTableEntry>::iterator lower = std::lower_bound( │ QList<AddressTableEntry>::iterator lower = qLowerBound(
cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableE │ cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableE
QList<AddressTableEntry>::iterator upper = std::upper_bound( │ QList<AddressTableEntry>::iterator upper = qUpperBound(
cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableE │ cachedAddressTable.begin(), cachedAddressTable.end(), address, AddressTableE
int lowerIndex = (lower - cachedAddressTable.begin()); │ int lowerIndex = (lower - cachedAddressTable.begin());
int upperIndex = (upper - cachedAddressTable.begin()); │ int upperIndex = (upper - cachedAddressTable.begin());
bool inModel = (lower != upper); │ bool inModel = (lower != upper);
AddressTableEntry::Type newEntryType = translateTransactionType(purpose, isMine) │ AddressTableEntry::Type newEntryType = translateTransactionType(purpose, isMine)
│
switch(status) │ switch(status)
{ │ {
case CT_NEW: │ case CT_NEW:
if(inModel) │ if(inModel)
{ │ {
qWarning() << "AddressTablePriv::updateEntry: Warning: Got CT_NEW, but e │ qWarning() << "AddressTablePriv::updateEntry: Warning: Got CT_NEW, but e
break; │ break;
} │ }
parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex); │ parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex);
cachedAddressTable.insert(lowerIndex, AddressTableEntry(newEntryType, label, │ cachedAddressTable.insert(lowerIndex, AddressTableEntry(newEntryType, label,
parent->endInsertRows(); │ parent->endInsertRows();
break; │ break;
case CT_UPDATED: │ case CT_UPDATED:
if(!inModel) │ if(!inModel)
{ │ {
qWarning() << "AddressTablePriv::updateEntry: Warning: Got CT_UPDATED, b │ qWarning() << "AddressTablePriv::updateEntry: Warning: Got CT_UPDATED, b
break; │ break;
} │ }
lower->type = newEntryType; │ lower->type = newEntryType;
lower->label = label; │ lower->label = label;
parent->emitDataChanged(lowerIndex); │ parent->emitDataChanged(lowerIndex);
break; │ break;
case CT_DELETED: │ case CT_DELETED:
if(!inModel) │ if(!inModel)
{ │ {
qWarning() << "AddressTablePriv::updateEntry: Warning: Got CT_DELETED, b │ qWarning() << "AddressTablePriv::updateEntry: Warning: Got CT_DELETED, b
break; │ break;
} │ }
parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1); │ parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
cachedAddressTable.erase(lower, upper); │ cachedAddressTable.erase(lower, upper);
parent->endRemoveRows(); │ parent->endRemoveRows();
break; │ break;
} │ }
} │ }
│
int size() │ int size()
{ │ {
return cachedAddressTable.size(); │ return cachedAddressTable.size();
} │ }
│
AddressTableEntry *index(int idx) │ AddressTableEntry *index(int idx)
{ │ {
if(idx >= 0 && idx < cachedAddressTable.size()) │ if(idx >= 0 && idx < cachedAddressTable.size())
{ │ {
return &cachedAddressTable[idx]; │ return &cachedAddressTable[idx];
} │ }
else │ else
{ │ {
return nullptr; │ return 0;
} │ }
} │ }
} │
next prev up dogecoin/src/qt/bitcoingui.cpp:793 │ bitcoin/src/qt/bitcoingui.cpp:1007
│
│ // Disabling macOS App Nap on initial sync, disk and reindex operations.
│ #ifdef Q_OS_MAC
│ if (sync_state == SynchronizationState::POST_INIT) {
│ m_app_nap_inhibitor->enableAppNap();
│ } else {
│ m_app_nap_inhibitor->disableAppNap();
│ }
│ #endif
│
if (modalOverlay) │ if (modalOverlay)
{ │ {
if (header) │ if (header)
modalOverlay->setKnownBestHeight(count, blockDate); │ modalOverlay->setKnownBestHeight(count, blockDate);
else │ else
modalOverlay->tipUpdate(count, blockDate, nVerificationProgress); │ modalOverlay->tipUpdate(count, blockDate, nVerificationProgress);
} │ }
if (!clientModel) │ if (!clientModel)
return; │ return;
│
// Prevent orphan statusbar messages (e.g. hover Quit in main menu, wait until chain │ // Prevent orphan statusbar messages (e.g. hover Quit in main menu, wait until chain
statusBar()->clearMessage(); │ statusBar()->clearMessage();
│
// Acquire current block source │ // Acquire current block source
enum BlockSource blockSource = clientModel->getBlockSource(); │ enum BlockSource blockSource = clientModel->getBlockSource();
switch (blockSource) { │ switch (blockSource) {
case BLOCK_SOURCE_NETWORK: │ case BlockSource::NETWORK:
if (header) { │ if (header) {
updateHeadersSyncProgressLabel(); │ updateHeadersSyncProgressLabel();
return; │ return;
} │ }
progressBarLabel->setText(tr("Synchronizing with network...")); │ progressBarLabel->setText(tr("Synchronizing with network…"));
updateHeadersSyncProgressLabel(); │ updateHeadersSyncProgressLabel();
break; │ break;
case BLOCK_SOURCE_DISK: │ case BlockSource::DISK:
if (header) { │ if (header) {
progressBarLabel->setText(tr("Indexing blocks on disk...")); │ progressBarLabel->setText(tr("Indexing blocks on disk…"));
} else { │ } else {
progressBarLabel->setText(tr("Processing blocks on disk...")); │ progressBarLabel->setText(tr("Processing blocks on disk…"));
} │ }
break; │ break;
case BLOCK_SOURCE_REINDEX: │ case BlockSource::REINDEX:
progressBarLabel->setText(tr("Reindexing blocks on disk...")); │ progressBarLabel->setText(tr("Reindexing blocks on disk…"));
break; │ break;
case BLOCK_SOURCE_NONE: │ case BlockSource::NONE:
if (header) { │ if (header) {
return; │ return;
} │ }
progressBarLabel->setText(tr("Connecting to peers...")); │ progressBarLabel->setText(tr("Connecting to peers…"));
break; │ break;
} │ }
│
QString tooltip; │ QString tooltip;
│
QDateTime currentDate = QDateTime::currentDateTime(); │ QDateTime currentDate = QDateTime::currentDateTime();
qint64 secs = blockDate.secsTo(currentDate); │ qint64 secs = blockDate.secsTo(currentDate);
│
tooltip = tr("Processed %n block(s) of transaction history.", "", count); │ tooltip = tr("Processed %n block(s) of transaction history.", "", count);
│
// Set icon state: spinning if catching up, tick otherwise │ // Set icon state: spinning if catching up, tick otherwise
if(secs < 90*60) │ if (secs < MAX_BLOCK_TIME_GAP) {
{ │
tooltip = tr("Up to date") + QString(".<br>") + tooltip; │ tooltip = tr("Up to date") + QString(".<br>") + tooltip;
labelBlocksIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/synced").pixm │ labelBlocksIcon->setThemedPixmap(QStringLiteral(":/icons/synced"), STATUSBAR_ICO
│
#ifdef ENABLE_WALLET │ #ifdef ENABLE_WALLET
if(walletFrame) │ if(walletFrame)
{ │ {
walletFrame->showOutOfSyncWarning(false); │ walletFrame->showOutOfSyncWarning(false);
modalOverlay->showHide(true, true); │ modalOverlay->showHide(true, true);
} │ }
#endif // ENABLE_WALLET │ #endif // ENABLE_WALLET
│
progressBarLabel->setVisible(false); │ progressBarLabel->setVisible(false);
progressBar->setVisible(false); │ progressBar->setVisible(false);
} │ }
else │ else
{ │ {
QString timeBehindText = GUIUtil::formatNiceTimeOffset(secs); │ QString timeBehindText = GUIUtil::formatNiceTimeOffset(secs);
│
progressBarLabel->setVisible(true); │ progressBarLabel->setVisible(true);
progressBar->setFormat(tr("%1 behind").arg(timeBehindText)); │ progressBar->setFormat(tr("%1 behind").arg(timeBehindText));
progressBar->setMaximum(1000000000); │ progressBar->setMaximum(1000000000);
progressBar->setValue(nVerificationProgress * 1000000000.0 + 0.5); │ progressBar->setValue(nVerificationProgress * 1000000000.0 + 0.5);
progressBar->setVisible(true); │ progressBar->setVisible(true);
│
tooltip = tr("Catching up...") + QString("<br>") + tooltip; │ tooltip = tr("Catching up…") + QString("<br>") + tooltip;
if(count != prevBlocks) │ if(count != prevBlocks)
{ │ {
labelBlocksIcon->setPixmap(platformStyle->SingleColorIcon(QString( │ labelBlocksIcon->setThemedPixmap(
":/movies/spinner-%1").arg(spinnerFrame, 3, 10, QChar('0'))) │ QString(":/animation/spinner-%1").arg(spinnerFrame, 3, 10, QChar('0')),
.pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); │ STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);
spinnerFrame = (spinnerFrame + 1) % SPINNER_FRAMES; │ spinnerFrame = (spinnerFrame + 1) % SPINNER_FRAMES;
} │ }
prevBlocks = count; │ prevBlocks = count;
│
#ifdef ENABLE_WALLET │ #ifdef ENABLE_WALLET
if(walletFrame) │ if(walletFrame)
{ │ {
walletFrame->showOutOfSyncWarning(true); │ walletFrame->showOutOfSyncWarning(true);
modalOverlay->showHide(); │ modalOverlay->showHide();
} │ }
#endif // ENABLE_WALLET │ #endif // ENABLE_WALLET
│
tooltip += QString("<br>"); │ tooltip += QString("<br>");
tooltip += tr("Last received block was generated %1 ago.").arg(timeBehindText); │ tooltip += tr("Last received block was generated %1 ago.").arg(timeBehindText);
tooltip += QString("<br>"); │ tooltip += QString("<br>");
tooltip += tr("Transactions after this will not yet be visible."); │ tooltip += tr("Transactions after this will not yet be visible.");
} │ }
│
// Don't word-wrap this (fixed-width) tooltip │ // Don't word-wrap this (fixed-width) tooltip
tooltip = QString("<nobr>") + tooltip + QString("</nobr>"); │ tooltip = QString("<nobr>") + tooltip + QString("</nobr>");
│
labelBlocksIcon->setToolTip(tooltip); │ labelBlocksIcon->setToolTip(tooltip);
progressBarLabel->setToolTip(tooltip); │ progressBarLabel->setToolTip(tooltip);
progressBar->setToolTip(tooltip); │ progressBar->setToolTip(tooltip);
} │
next prev up dogecoin/src/test/merkle_tests.cpp:68 │ bitcoin/src/test/merkle_tests.cpp:183
│
for (int i = 0; i < 32; i++) { │ for (int i = 0; i < 32; i++) {
// Try 32 block sizes: all sizes from 0 to 16 inclusive, and then 15 random size │ // Try 32 block sizes: all sizes from 0 to 16 inclusive, and then 15 random size
int ntx = (i <= 16) ? i : 17 + (insecure_rand() % 4000); │ int ntx = (i <= 16) ? i : 17 + (InsecureRandRange(4000));
// Try up to 3 mutations. │ // Try up to 3 mutations.
for (int mutate = 0; mutate <= 3; mutate++) { │ for (int mutate = 0; mutate <= 3; mutate++) {
int duplicate1 = mutate >= 1 ? 1 << ctz(ntx) : 0; // The last how many trans │ int duplicate1 = mutate >= 1 ? 1 << ctz(ntx) : 0; // The last how many trans
if (duplicate1 >= ntx) break; // Duplication of the entire tree results in a │ if (duplicate1 >= ntx) break; // Duplication of the entire tree results in a
int ntx1 = ntx + duplicate1; // The resulting number of transactions after t │ int ntx1 = ntx + duplicate1; // The resulting number of transactions after t
int duplicate2 = mutate >= 2 ? 1 << ctz(ntx1) : 0; // Likewise for the secon │ int duplicate2 = mutate >= 2 ? 1 << ctz(ntx1) : 0; // Likewise for the secon
if (duplicate2 >= ntx1) break; │ if (duplicate2 >= ntx1) break;
int ntx2 = ntx1 + duplicate2; │ int ntx2 = ntx1 + duplicate2;
int duplicate3 = mutate >= 3 ? 1 << ctz(ntx2) : 0; // And for the third muta │ int duplicate3 = mutate >= 3 ? 1 << ctz(ntx2) : 0; // And for the third muta
if (duplicate3 >= ntx2) break; │ if (duplicate3 >= ntx2) break;
int ntx3 = ntx2 + duplicate3; │ int ntx3 = ntx2 + duplicate3;
// Build a block with ntx different transactions. │ // Build a block with ntx different transactions.
CBlock block; │ CBlock block;
block.vtx.resize(ntx); │ block.vtx.resize(ntx);
for (int j = 0; j < ntx; j++) { │ for (int j = 0; j < ntx; j++) {
CMutableTransaction mtx; │ CMutableTransaction mtx;
mtx.nLockTime = j; │ mtx.nLockTime = j;
block.vtx[j] = MakeTransactionRef(std::move(mtx)); │ block.vtx[j] = MakeTransactionRef(std::move(mtx));
} │ }
// Compute the root of the block before mutating it. │ // Compute the root of the block before mutating it.
bool unmutatedMutated = false; │ bool unmutatedMutated = false;
uint256 unmutatedRoot = BlockMerkleRoot(block, &unmutatedMutated); │ uint256 unmutatedRoot = BlockMerkleRoot(block, &unmutatedMutated);
BOOST_CHECK(unmutatedMutated == false); │ BOOST_CHECK(unmutatedMutated == false);
// Optionally mutate by duplicating the last transactions, resulting in the │ // Optionally mutate by duplicating the last transactions, resulting in the
block.vtx.resize(ntx3); │ block.vtx.resize(ntx3);
for (int j = 0; j < duplicate1; j++) { │ for (int j = 0; j < duplicate1; j++) {
block.vtx[ntx + j] = block.vtx[ntx + j - duplicate1]; │ block.vtx[ntx + j] = block.vtx[ntx + j - duplicate1];
} │ }
for (int j = 0; j < duplicate2; j++) { │ for (int j = 0; j < duplicate2; j++) {
block.vtx[ntx1 + j] = block.vtx[ntx1 + j - duplicate2]; │ block.vtx[ntx1 + j] = block.vtx[ntx1 + j - duplicate2];
} │ }
for (int j = 0; j < duplicate3; j++) { │ for (int j = 0; j < duplicate3; j++) {
block.vtx[ntx2 + j] = block.vtx[ntx2 + j - duplicate3]; │ block.vtx[ntx2 + j] = block.vtx[ntx2 + j - duplicate3];
} │ }
// Compute the merkle root and merkle tree using the old mechanism. │ // Compute the merkle root and merkle tree using the old mechanism.
bool oldMutated = false; │ bool oldMutated = false;
std::vector<uint256> merkleTree; │ std::vector<uint256> merkleTree;
uint256 oldRoot = BlockBuildMerkleTree(block, &oldMutated, merkleTree); │ uint256 oldRoot = BlockBuildMerkleTree(block, &oldMutated, merkleTree);
// Compute the merkle root using the new mechanism. │ // Compute the merkle root using the new mechanism.
bool newMutated = false; │ bool newMutated = false;
uint256 newRoot = BlockMerkleRoot(block, &newMutated); │ uint256 newRoot = BlockMerkleRoot(block, &newMutated);
BOOST_CHECK(oldRoot == newRoot); │ BOOST_CHECK(oldRoot == newRoot);
BOOST_CHECK(newRoot == unmutatedRoot); │ BOOST_CHECK(newRoot == unmutatedRoot);
BOOST_CHECK((newRoot == uint256()) == (ntx == 0)); │ BOOST_CHECK((newRoot == uint256()) == (ntx == 0));
BOOST_CHECK(oldMutated == newMutated); │ BOOST_CHECK(oldMutated == newMutated);
BOOST_CHECK(newMutated == !!mutate); │ BOOST_CHECK(newMutated == !!mutate);
// If no mutation was done (once for every ntx value), try up to 16 branches │ // If no mutation was done (once for every ntx value), try up to 16 branches
if (mutate == 0) { │ if (mutate == 0) {
for (int loop = 0; loop < std::min(ntx, 16); loop++) { │ for (int loop = 0; loop < std::min(ntx, 16); loop++) {
// If ntx <= 16, try all branches. Otherise, try 16 random ones. │ // If ntx <= 16, try all branches. Otherwise, try 16 random ones.
int mtx = loop; │ int mtx = loop;
if (ntx > 16) { │ if (ntx > 16) {
mtx = insecure_rand() % ntx; │ mtx = InsecureRandRange(ntx);
} │ }
std::vector<uint256> newBranch = BlockMerkleBranch(block, mtx); │ std::vector<uint256> newBranch = BlockMerkleBranch(block, mtx);
std::vector<uint256> oldBranch = BlockGetMerkleBranch(block, merkleT │ std::vector<uint256> oldBranch = BlockGetMerkleBranch(block, merkleT
BOOST_CHECK(oldBranch == newBranch); │ BOOST_CHECK(oldBranch == newBranch);
BOOST_CHECK(ComputeMerkleRootFromBranch(block.vtx[mtx]->GetHash(), n │ BOOST_CHECK(ComputeMerkleRootFromBranch(block.vtx[mtx]->GetHash(), n
} │ }
} │ }
} │ }
} │ }
} │
next prev up dogecoin/src/test/script_tests.cpp:1338 │ bitcoin/src/test/script_tests.cpp:1352
│
// Exercise the FindAndDelete functionality │ // Exercise the FindAndDelete functionality
CScript s; │ CScript s;
CScript d; │ CScript d;
CScript expect; │ CScript expect;
│
s = CScript() << OP_1 << OP_2; │ s = CScript() << OP_1 << OP_2;
d = CScript(); // delete nothing should be a no-op │ d = CScript(); // delete nothing should be a no-op
expect = s; │ expect = s;
BOOST_CHECK_EQUAL(s.FindAndDelete(d), 0); │ BOOST_CHECK_EQUAL(FindAndDelete(s, d), 0);
BOOST_CHECK(s == expect); │ BOOST_CHECK(s == expect);
│
s = CScript() << OP_1 << OP_2 << OP_3; │ s = CScript() << OP_1 << OP_2 << OP_3;
d = CScript() << OP_2; │ d = CScript() << OP_2;
expect = CScript() << OP_1 << OP_3; │ expect = CScript() << OP_1 << OP_3;
BOOST_CHECK_EQUAL(s.FindAndDelete(d), 1); │ BOOST_CHECK_EQUAL(FindAndDelete(s, d), 1);
BOOST_CHECK(s == expect); │ BOOST_CHECK(s == expect);
│
s = CScript() << OP_3 << OP_1 << OP_3 << OP_3 << OP_4 << OP_3; │ s = CScript() << OP_3 << OP_1 << OP_3 << OP_3 << OP_4 << OP_3;
d = CScript() << OP_3; │ d = CScript() << OP_3;
expect = CScript() << OP_1 << OP_4; │ expect = CScript() << OP_1 << OP_4;
BOOST_CHECK_EQUAL(s.FindAndDelete(d), 4); │ BOOST_CHECK_EQUAL(FindAndDelete(s, d), 4);
BOOST_CHECK(s == expect); │ BOOST_CHECK(s == expect);
│
s = ScriptFromHex("0302ff03"); // PUSH 0x02ff03 onto stack │ s = ScriptFromHex("0302ff03"); // PUSH 0x02ff03 onto stack
d = ScriptFromHex("0302ff03"); │ d = ScriptFromHex("0302ff03");
expect = CScript(); │ expect = CScript();
BOOST_CHECK_EQUAL(s.FindAndDelete(d), 1); │ BOOST_CHECK_EQUAL(FindAndDelete(s, d), 1);
BOOST_CHECK(s == expect); │ BOOST_CHECK(s == expect);
│
s = ScriptFromHex("0302ff030302ff03"); // PUSH 0x2ff03 PUSH 0x2ff03 │ s = ScriptFromHex("0302ff030302ff03"); // PUSH 0x2ff03 PUSH 0x2ff03
d = ScriptFromHex("0302ff03"); │ d = ScriptFromHex("0302ff03");
expect = CScript(); │ expect = CScript();
BOOST_CHECK_EQUAL(s.FindAndDelete(d), 2); │ BOOST_CHECK_EQUAL(FindAndDelete(s, d), 2);
BOOST_CHECK(s == expect); │ BOOST_CHECK(s == expect);
│
s = ScriptFromHex("0302ff030302ff03"); │ s = ScriptFromHex("0302ff030302ff03");
d = ScriptFromHex("02"); │ d = ScriptFromHex("02");
expect = s; // FindAndDelete matches entire opcodes │ expect = s; // FindAndDelete matches entire opcodes
BOOST_CHECK_EQUAL(s.FindAndDelete(d), 0); │ BOOST_CHECK_EQUAL(FindAndDelete(s, d), 0);
BOOST_CHECK(s == expect); │ BOOST_CHECK(s == expect);
│
s = ScriptFromHex("0302ff030302ff03"); │ s = ScriptFromHex("0302ff030302ff03");
d = ScriptFromHex("ff"); │ d = ScriptFromHex("ff");
expect = s; │ expect = s;
BOOST_CHECK_EQUAL(s.FindAndDelete(d), 0); │ BOOST_CHECK_EQUAL(FindAndDelete(s, d), 0);
BOOST_CHECK(s == expect); │ BOOST_CHECK(s == expect);
│
// This is an odd edge case: strip of the push-three-bytes │ // This is an odd edge case: strip of the push-three-bytes
// prefix, leaving 02ff03 which is push-two-bytes: │ // prefix, leaving 02ff03 which is push-two-bytes:
s = ScriptFromHex("0302ff030302ff03"); │ s = ScriptFromHex("0302ff030302ff03");
d = ScriptFromHex("03"); │ d = ScriptFromHex("03");
expect = CScript() << ParseHex("ff03") << ParseHex("ff03"); │ expect = CScript() << ParseHex("ff03") << ParseHex("ff03");
BOOST_CHECK_EQUAL(s.FindAndDelete(d), 2); │ BOOST_CHECK_EQUAL(FindAndDelete(s, d), 2);
BOOST_CHECK(s == expect); │ BOOST_CHECK(s == expect);
│
// Byte sequence that spans multiple opcodes: │ // Byte sequence that spans multiple opcodes:
s = ScriptFromHex("02feed5169"); // PUSH(0xfeed) OP_1 OP_VERIFY │ s = ScriptFromHex("02feed5169"); // PUSH(0xfeed) OP_1 OP_VERIFY
d = ScriptFromHex("feed51"); │ d = ScriptFromHex("feed51");
expect = s; │ expect = s;
BOOST_CHECK_EQUAL(s.FindAndDelete(d), 0); // doesn't match 'inside' opcodes │ BOOST_CHECK_EQUAL(FindAndDelete(s, d), 0); // doesn't match 'inside' opcodes
BOOST_CHECK(s == expect); │ BOOST_CHECK(s == expect);
│
s = ScriptFromHex("02feed5169"); // PUSH(0xfeed) OP_1 OP_VERIFY │ s = ScriptFromHex("02feed5169"); // PUSH(0xfeed) OP_1 OP_VERIFY
d = ScriptFromHex("02feed51"); │ d = ScriptFromHex("02feed51");
expect = ScriptFromHex("69"); │ expect = ScriptFromHex("69");
BOOST_CHECK_EQUAL(s.FindAndDelete(d), 1); │ BOOST_CHECK_EQUAL(FindAndDelete(s, d), 1);
BOOST_CHECK(s == expect); │ BOOST_CHECK(s == expect);
│
s = ScriptFromHex("516902feed5169"); │ s = ScriptFromHex("516902feed5169");
d = ScriptFromHex("feed51"); │ d = ScriptFromHex("feed51");
expect = s; │ expect = s;
BOOST_CHECK_EQUAL(s.FindAndDelete(d), 0); │ BOOST_CHECK_EQUAL(FindAndDelete(s, d), 0);
BOOST_CHECK(s == expect); │ BOOST_CHECK(s == expect);
│
s = ScriptFromHex("516902feed5169"); │ s = ScriptFromHex("516902feed5169");
d = ScriptFromHex("02feed51"); │ d = ScriptFromHex("02feed51");
expect = ScriptFromHex("516969"); │ expect = ScriptFromHex("516969");
BOOST_CHECK_EQUAL(s.FindAndDelete(d), 1); │ BOOST_CHECK_EQUAL(FindAndDelete(s, d), 1);
BOOST_CHECK(s == expect); │ BOOST_CHECK(s == expect);
│
s = CScript() << OP_0 << OP_0 << OP_1 << OP_1; │ s = CScript() << OP_0 << OP_0 << OP_1 << OP_1;
d = CScript() << OP_0 << OP_1; │ d = CScript() << OP_0 << OP_1;
expect = CScript() << OP_0 << OP_1; // FindAndDelete is single-pass │ expect = CScript() << OP_0 << OP_1; // FindAndDelete is single-pass
BOOST_CHECK_EQUAL(s.FindAndDelete(d), 1); │ BOOST_CHECK_EQUAL(FindAndDelete(s, d), 1);
BOOST_CHECK(s == expect); │ BOOST_CHECK(s == expect);
│
s = CScript() << OP_0 << OP_0 << OP_1 << OP_0 << OP_1 << OP_1; │ s = CScript() << OP_0 << OP_0 << OP_1 << OP_0 << OP_1 << OP_1;
d = CScript() << OP_0 << OP_1; │ d = CScript() << OP_0 << OP_1;
expect = CScript() << OP_0 << OP_1; // FindAndDelete is single-pass │ expect = CScript() << OP_0 << OP_1; // FindAndDelete is single-pass
BOOST_CHECK_EQUAL(s.FindAndDelete(d), 2); │ BOOST_CHECK_EQUAL(FindAndDelete(s, d), 2);
BOOST_CHECK(s == expect); │ BOOST_CHECK(s == expect);
│
// Another weird edge case: │ // Another weird edge case:
// End with invalid push (not enough data)... │ // End with invalid push (not enough data)...
s = ScriptFromHex("0003feed"); │ s = ScriptFromHex("0003feed");
d = ScriptFromHex("03feed"); // ... can remove the invalid push │ d = ScriptFromHex("03feed"); // ... can remove the invalid push
expect = ScriptFromHex("00"); │ expect = ScriptFromHex("00");
BOOST_CHECK_EQUAL(s.FindAndDelete(d), 1); │ BOOST_CHECK_EQUAL(FindAndDelete(s, d), 1);
BOOST_CHECK(s == expect); │ BOOST_CHECK(s == expect);
│
s = ScriptFromHex("0003feed"); │ s = ScriptFromHex("0003feed");
d = ScriptFromHex("00"); │ d = ScriptFromHex("00");
expect = ScriptFromHex("03feed"); │ expect = ScriptFromHex("03feed");
BOOST_CHECK_EQUAL(s.FindAndDelete(d), 1); │ BOOST_CHECK_EQUAL(FindAndDelete(s, d), 1);
BOOST_CHECK(s == expect); │ BOOST_CHECK(s == expect);
} │
next prev up dogecoin/src/script/interpreter.cpp:1054 │ bitcoin/src/script/interpreter.cpp:1250
│
private: │ private:
const CTransaction& txTo; //!< reference to the spending transaction (the one being │ const T& txTo; //!< reference to the spending transaction (the one being
const CScript& scriptCode; //!< output script being consumed │ const CScript& scriptCode; //!< output script being consumed
const unsigned int nIn; //!< input index of txTo being signed │ const unsigned int nIn; //!< input index of txTo being signed
const bool fAnyoneCanPay; //!< whether the hashtype has the SIGHASH_ANYONECANPAY fl │ const bool fAnyoneCanPay; //!< whether the hashtype has the SIGHASH_ANYONECANPAY fl
const bool fHashSingle; //!< whether the hashtype is SIGHASH_SINGLE │ const bool fHashSingle; //!< whether the hashtype is SIGHASH_SINGLE
const bool fHashNone; //!< whether the hashtype is SIGHASH_NONE │ const bool fHashNone; //!< whether the hashtype is SIGHASH_NONE
│
public: │ public:
CTransactionSignatureSerializer(const CTransaction &txToIn, const CScript &scriptCod │ CTransactionSignatureSerializer(const T& txToIn, const CScript& scriptCodeIn, unsign
txTo(txToIn), scriptCode(scriptCodeIn), nIn(nInIn), │ txTo(txToIn), scriptCode(scriptCodeIn), nIn(nInIn),
fAnyoneCanPay(!!(nHashTypeIn & SIGHASH_ANYONECANPAY)), │ fAnyoneCanPay(!!(nHashTypeIn & SIGHASH_ANYONECANPAY)),
fHashSingle((nHashTypeIn & 0x1f) == SIGHASH_SINGLE), │ fHashSingle((nHashTypeIn & 0x1f) == SIGHASH_SINGLE),
fHashNone((nHashTypeIn & 0x1f) == SIGHASH_NONE) {} │ fHashNone((nHashTypeIn & 0x1f) == SIGHASH_NONE) {}
│
/** Serialize the passed scriptCode, skipping OP_CODESEPARATORs */ │ /** Serialize the passed scriptCode, skipping OP_CODESEPARATORs */
template<typename S> │ template<typename S>
void SerializeScriptCode(S &s) const { │ void SerializeScriptCode(S &s) const {
CScript::const_iterator it = scriptCode.begin(); │ CScript::const_iterator it = scriptCode.begin();
CScript::const_iterator itBegin = it; │ CScript::const_iterator itBegin = it;
opcodetype opcode; │ opcodetype opcode;
unsigned int nCodeSeparators = 0; │ unsigned int nCodeSeparators = 0;
while (scriptCode.GetOp(it, opcode)) { │ while (scriptCode.GetOp(it, opcode)) {
if (opcode == OP_CODESEPARATOR) │ if (opcode == OP_CODESEPARATOR)
nCodeSeparators++; │ nCodeSeparators++;
} │ }
::WriteCompactSize(s, scriptCode.size() - nCodeSeparators); │ ::WriteCompactSize(s, scriptCode.size() - nCodeSeparators);
it = itBegin; │ it = itBegin;
while (scriptCode.GetOp(it, opcode)) { │ while (scriptCode.GetOp(it, opcode)) {
if (opcode == OP_CODESEPARATOR) { │ if (opcode == OP_CODESEPARATOR) {
s.write((char*)&itBegin[0], it-itBegin-1); │ s.write(AsBytes(Span{&itBegin[0], size_t(it - itBegin - 1)}));
itBegin = it; │ itBegin = it;
} │ }
} │ }
if (itBegin != scriptCode.end()) │ if (itBegin != scriptCode.end())
s.write((char*)&itBegin[0], it-itBegin); │ s.write(AsBytes(Span{&itBegin[0], size_t(it - itBegin)}));
} │ }
│
/** Serialize an input of txTo */ │ /** Serialize an input of txTo */
template<typename S> │ template<typename S>
void SerializeInput(S &s, unsigned int nInput) const { │ void SerializeInput(S &s, unsigned int nInput) const {
// In case of SIGHASH_ANYONECANPAY, only the input being signed is serialized │ // In case of SIGHASH_ANYONECANPAY, only the input being signed is serialized
if (fAnyoneCanPay) │ if (fAnyoneCanPay)
nInput = nIn; │ nInput = nIn;
// Serialize the prevout │ // Serialize the prevout
::Serialize(s, txTo.vin[nInput].prevout); │ ::Serialize(s, txTo.vin[nInput].prevout);
// Serialize the script │ // Serialize the script
if (nInput != nIn) │ if (nInput != nIn)
// Blank out other inputs' signatures │ // Blank out other inputs' signatures
::Serialize(s, CScriptBase()); │ ::Serialize(s, CScript());
else │ else
SerializeScriptCode(s); │ SerializeScriptCode(s);
// Serialize the nSequence │ // Serialize the nSequence
if (nInput != nIn && (fHashSingle || fHashNone)) │ if (nInput != nIn && (fHashSingle || fHashNone))
// let the others update at will │ // let the others update at will
::Serialize(s, (int)0); │ ::Serialize(s, (int)0);
else │ else
::Serialize(s, txTo.vin[nInput].nSequence); │ ::Serialize(s, txTo.vin[nInput].nSequence);
} │ }
│
/** Serialize an output of txTo */ │ /** Serialize an output of txTo */
template<typename S> │ template<typename S>
void SerializeOutput(S &s, unsigned int nOutput) const { │ void SerializeOutput(S &s, unsigned int nOutput) const {
if (fHashSingle && nOutput != nIn) │ if (fHashSingle && nOutput != nIn)
// Do not lock-in the txout payee at other indices as txin │ // Do not lock-in the txout payee at other indices as txin
::Serialize(s, CTxOut()); │ ::Serialize(s, CTxOut());
else │ else
::Serialize(s, txTo.vout[nOutput]); │ ::Serialize(s, txTo.vout[nOutput]);
} │ }
│
/** Serialize txTo */ │ /** Serialize txTo */
template<typename S> │ template<typename S>
void Serialize(S &s) const { │ void Serialize(S &s) const {
// Serialize nVersion │ // Serialize nVersion
::Serialize(s, txTo.nVersion); │ ::Serialize(s, txTo.nVersion);
// Serialize vin │ // Serialize vin
unsigned int nInputs = fAnyoneCanPay ? 1 : txTo.vin.size(); │ unsigned int nInputs = fAnyoneCanPay ? 1 : txTo.vin.size();
::WriteCompactSize(s, nInputs); │ ::WriteCompactSize(s, nInputs);
for (unsigned int nInput = 0; nInput < nInputs; nInput++) │ for (unsigned int nInput = 0; nInput < nInputs; nInput++)
SerializeInput(s, nInput); │ SerializeInput(s, nInput);
// Serialize vout │ // Serialize vout
unsigned int nOutputs = fHashNone ? 0 : (fHashSingle ? nIn+1 : txTo.vout.size()) │ unsigned int nOutputs = fHashNone ? 0 : (fHashSingle ? nIn+1 : txTo.vout.size())
::WriteCompactSize(s, nOutputs); │ ::WriteCompactSize(s, nOutputs);
for (unsigned int nOutput = 0; nOutput < nOutputs; nOutput++) │ for (unsigned int nOutput = 0; nOutput < nOutputs; nOutput++)
SerializeOutput(s, nOutput); │ SerializeOutput(s, nOutput);
// Serialize nLockTime │ // Serialize nLockTime
::Serialize(s, txTo.nLockTime); │ ::Serialize(s, txTo.nLockTime);
} │ }
} │
next prev up dogecoin/src/univalue/test/object.cpp:247 │ bitcoin/src/univalue/test/object.cpp:247
│
UniValue obj(UniValue::VOBJ); │ UniValue obj(UniValue::VOBJ);
std::string strKey, strVal; │ std::string strKey, strVal;
UniValue v; │ UniValue v;
│
strKey = "age"; │ strKey = "age";
v.setInt(100); │ v.setInt(100);
BOOST_CHECK(obj.pushKV(strKey, v)); │ BOOST_CHECK(obj.pushKV(strKey, v));
│
strKey = "first"; │ strKey = "first";
strVal = "John"; │ strVal = "John";
BOOST_CHECK(obj.pushKV(strKey, strVal)); │ BOOST_CHECK(obj.pushKV(strKey, strVal));
│
strKey = "last"; │ strKey = "last";
const char *cVal = "Smith"; │ const char *cVal = "Smith";
BOOST_CHECK(obj.pushKV(strKey, cVal)); │ BOOST_CHECK(obj.pushKV(strKey, cVal));
│
strKey = "distance"; │ strKey = "distance";
BOOST_CHECK(obj.pushKV(strKey, (int64_t) 25)); │ BOOST_CHECK(obj.pushKV(strKey, (int64_t) 25));
│
strKey = "time"; │ strKey = "time";
BOOST_CHECK(obj.pushKV(strKey, (uint64_t) 3600)); │ BOOST_CHECK(obj.pushKV(strKey, (uint64_t) 3600));
│
strKey = "calories"; │ strKey = "calories";
BOOST_CHECK(obj.pushKV(strKey, (int) 12)); │ BOOST_CHECK(obj.pushKV(strKey, (int) 12));
│
strKey = "temperature"; │ strKey = "temperature";
BOOST_CHECK(obj.pushKV(strKey, (double) 90.012)); │ BOOST_CHECK(obj.pushKV(strKey, (double) 90.012));
│
strKey = "moon"; │ strKey = "moon";
BOOST_CHECK(obj.pushKV(strKey, true)); │ BOOST_CHECK(obj.pushKV(strKey, true));
│
strKey = "spoon"; │ strKey = "spoon";
BOOST_CHECK(obj.pushKV(strKey, false)); │ BOOST_CHECK(obj.pushKV(strKey, false));
│
UniValue obj2(UniValue::VOBJ); │ UniValue obj2(UniValue::VOBJ);
BOOST_CHECK(obj2.pushKV("cat1", 9000)); │ BOOST_CHECK(obj2.pushKV("cat1", 9000));
BOOST_CHECK(obj2.pushKV("cat2", 12345)); │ BOOST_CHECK(obj2.pushKV("cat2", 12345));
│
BOOST_CHECK(obj.pushKVs(obj2)); │ BOOST_CHECK(obj.pushKVs(obj2));
│
BOOST_CHECK_EQUAL(obj.empty(), false); │ BOOST_CHECK_EQUAL(obj.empty(), false);
BOOST_CHECK_EQUAL(obj.size(), 11); │ BOOST_CHECK_EQUAL(obj.size(), 11);
│
BOOST_CHECK_EQUAL(obj["age"].getValStr(), "100"); │ BOOST_CHECK_EQUAL(obj["age"].getValStr(), "100");
BOOST_CHECK_EQUAL(obj["first"].getValStr(), "John"); │ BOOST_CHECK_EQUAL(obj["first"].getValStr(), "John");
BOOST_CHECK_EQUAL(obj["last"].getValStr(), "Smith"); │ BOOST_CHECK_EQUAL(obj["last"].getValStr(), "Smith");
BOOST_CHECK_EQUAL(obj["distance"].getValStr(), "25"); │ BOOST_CHECK_EQUAL(obj["distance"].getValStr(), "25");
BOOST_CHECK_EQUAL(obj["time"].getValStr(), "3600"); │ BOOST_CHECK_EQUAL(obj["time"].getValStr(), "3600");
BOOST_CHECK_EQUAL(obj["calories"].getValStr(), "12"); │ BOOST_CHECK_EQUAL(obj["calories"].getValStr(), "12");
BOOST_CHECK_EQUAL(obj["temperature"].getValStr(), "90.012"); │ BOOST_CHECK_EQUAL(obj["temperature"].getValStr(), "90.012");
BOOST_CHECK_EQUAL(obj["moon"].getValStr(), "1"); │ BOOST_CHECK_EQUAL(obj["moon"].getValStr(), "1");
BOOST_CHECK_EQUAL(obj["spoon"].getValStr(), ""); │ BOOST_CHECK_EQUAL(obj["spoon"].getValStr(), "");
BOOST_CHECK_EQUAL(obj["cat1"].getValStr(), "9000"); │ BOOST_CHECK_EQUAL(obj["cat1"].getValStr(), "9000");
BOOST_CHECK_EQUAL(obj["cat2"].getValStr(), "12345"); │ BOOST_CHECK_EQUAL(obj["cat2"].getValStr(), "12345");
│
BOOST_CHECK_EQUAL(obj["nyuknyuknyuk"].getValStr(), ""); │ BOOST_CHECK_EQUAL(obj["nyuknyuknyuk"].getValStr(), "");
│
BOOST_CHECK(obj.exists("age")); │ BOOST_CHECK(obj.exists("age"));
BOOST_CHECK(obj.exists("first")); │ BOOST_CHECK(obj.exists("first"));
BOOST_CHECK(obj.exists("last")); │ BOOST_CHECK(obj.exists("last"));
BOOST_CHECK(obj.exists("distance")); │ BOOST_CHECK(obj.exists("distance"));
BOOST_CHECK(obj.exists("time")); │ BOOST_CHECK(obj.exists("time"));
BOOST_CHECK(obj.exists("calories")); │ BOOST_CHECK(obj.exists("calories"));
BOOST_CHECK(obj.exists("temperature")); │ BOOST_CHECK(obj.exists("temperature"));
BOOST_CHECK(obj.exists("moon")); │ BOOST_CHECK(obj.exists("moon"));
BOOST_CHECK(obj.exists("spoon")); │ BOOST_CHECK(obj.exists("spoon"));
BOOST_CHECK(obj.exists("cat1")); │ BOOST_CHECK(obj.exists("cat1"));
BOOST_CHECK(obj.exists("cat2")); │ BOOST_CHECK(obj.exists("cat2"));
│
BOOST_CHECK(!obj.exists("nyuknyuknyuk")); │ BOOST_CHECK(!obj.exists("nyuknyuknyuk"));
│
std::map<std::string, UniValue::VType> objTypes; │ std::map<std::string, UniValue::VType> objTypes;
objTypes["age"] = UniValue::VNUM; │ objTypes["age"] = UniValue::VNUM;
objTypes["first"] = UniValue::VSTR; │ objTypes["first"] = UniValue::VSTR;
objTypes["last"] = UniValue::VSTR; │ objTypes["last"] = UniValue::VSTR;
objTypes["distance"] = UniValue::VNUM; │ objTypes["distance"] = UniValue::VNUM;
objTypes["time"] = UniValue::VNUM; │ objTypes["time"] = UniValue::VNUM;
objTypes["calories"] = UniValue::VNUM; │ objTypes["calories"] = UniValue::VNUM;
objTypes["temperature"] = UniValue::VNUM; │ objTypes["temperature"] = UniValue::VNUM;
objTypes["moon"] = UniValue::VBOOL; │ objTypes["moon"] = UniValue::VBOOL;
objTypes["spoon"] = UniValue::VBOOL; │ objTypes["spoon"] = UniValue::VBOOL;
objTypes["cat1"] = UniValue::VNUM; │ objTypes["cat1"] = UniValue::VNUM;
objTypes["cat2"] = UniValue::VNUM; │ objTypes["cat2"] = UniValue::VNUM;
BOOST_CHECK(obj.checkObject(objTypes)); │ BOOST_CHECK(obj.checkObject(objTypes));
│
objTypes["cat2"] = UniValue::VSTR; │ objTypes["cat2"] = UniValue::VSTR;
BOOST_CHECK(!obj.checkObject(objTypes)); │ BOOST_CHECK(!obj.checkObject(objTypes));
│
obj.clear(); │ obj.clear();
BOOST_CHECK(obj.empty()); │ BOOST_CHECK(obj.empty());
BOOST_CHECK_EQUAL(obj.size(), 0); │ BOOST_CHECK_EQUAL(obj.size(), 0);
BOOST_CHECK_EQUAL(obj.getType(), UniValue::VNULL); │ BOOST_CHECK_EQUAL(obj.getType(), UniValue::VNULL);
│
BOOST_CHECK_EQUAL(obj.setObject(), true); │ BOOST_CHECK_EQUAL(obj.setObject(), true);
UniValue uv; │ UniValue uv;
uv.setInt(42); │ uv.setInt(42);
obj.__pushKV("age", uv); │ obj.__pushKV("age", uv);
BOOST_CHECK_EQUAL(obj.size(), 1); │ BOOST_CHECK_EQUAL(obj.size(), 1);
BOOST_CHECK_EQUAL(obj["age"].getValStr(), "42"); │ BOOST_CHECK_EQUAL(obj["age"].getValStr(), "42");
│
uv.setInt(43); │ uv.setInt(43);
obj.pushKV("age", uv); │ obj.pushKV("age", uv);
BOOST_CHECK_EQUAL(obj.size(), 1); │ BOOST_CHECK_EQUAL(obj.size(), 1);
BOOST_CHECK_EQUAL(obj["age"].getValStr(), "43"); │ BOOST_CHECK_EQUAL(obj["age"].getValStr(), "43");
│
obj.pushKV("name", "foo bar"); │ obj.pushKV("name", "foo bar");
│
std::map<std::string,UniValue> kv; │ std::map<std::string,UniValue> kv;
obj.getObjMap(kv); │ obj.getObjMap(kv);
BOOST_CHECK_EQUAL(kv["age"].getValStr(), "43"); │ BOOST_CHECK_EQUAL(kv["age"].getValStr(), "43");
BOOST_CHECK_EQUAL(kv["name"].getValStr(), "foo bar"); │ BOOST_CHECK_EQUAL(kv["name"].getValStr(), "foo bar");
│
} │
next prev up dogecoin/src/test/mempool_tests.cpp:18 │ bitcoin/src/test/mempool_tests.cpp:20
│
// Test CTxMemPool::remove functionality │ // Test CTxMemPool::remove functionality
│
TestMemPoolEntryHelper entry; │ TestMemPoolEntryHelper entry;
// Parent transaction with three children, │ // Parent transaction with three children,
// and three grand-children: │ // and three grand-children:
CMutableTransaction txParent; │ CMutableTransaction txParent;
txParent.vin.resize(1); │ txParent.vin.resize(1);
txParent.vin[0].scriptSig = CScript() << OP_11; │ txParent.vin[0].scriptSig = CScript() << OP_11;
txParent.vout.resize(3); │ txParent.vout.resize(3);
for (int i = 0; i < 3; i++) │ for (int i = 0; i < 3; i++)
{ │ {
txParent.vout[i].scriptPubKey = CScript() << OP_11 << OP_EQUAL; │ txParent.vout[i].scriptPubKey = CScript() << OP_11 << OP_EQUAL;
txParent.vout[i].nValue = 33000LL; │ txParent.vout[i].nValue = 33000LL;
} │ }
CMutableTransaction txChild[3]; │ CMutableTransaction txChild[3];
for (int i = 0; i < 3; i++) │ for (int i = 0; i < 3; i++)
{ │ {
txChild[i].vin.resize(1); │ txChild[i].vin.resize(1);
txChild[i].vin[0].scriptSig = CScript() << OP_11; │ txChild[i].vin[0].scriptSig = CScript() << OP_11;
txChild[i].vin[0].prevout.hash = txParent.GetHash(); │ txChild[i].vin[0].prevout.hash = txParent.GetHash();
txChild[i].vin[0].prevout.n = i; │ txChild[i].vin[0].prevout.n = i;
txChild[i].vout.resize(1); │ txChild[i].vout.resize(1);
txChild[i].vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL; │ txChild[i].vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL;
txChild[i].vout[0].nValue = 11000LL; │ txChild[i].vout[0].nValue = 11000LL;
} │ }
CMutableTransaction txGrandChild[3]; │ CMutableTransaction txGrandChild[3];
for (int i = 0; i < 3; i++) │ for (int i = 0; i < 3; i++)
{ │ {
txGrandChild[i].vin.resize(1); │ txGrandChild[i].vin.resize(1);
txGrandChild[i].vin[0].scriptSig = CScript() << OP_11; │ txGrandChild[i].vin[0].scriptSig = CScript() << OP_11;
txGrandChild[i].vin[0].prevout.hash = txChild[i].GetHash(); │ txGrandChild[i].vin[0].prevout.hash = txChild[i].GetHash();
txGrandChild[i].vin[0].prevout.n = 0; │ txGrandChild[i].vin[0].prevout.n = 0;
txGrandChild[i].vout.resize(1); │ txGrandChild[i].vout.resize(1);
txGrandChild[i].vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL; │ txGrandChild[i].vout[0].scriptPubKey = CScript() << OP_11 << OP_EQUAL;
txGrandChild[i].vout[0].nValue = 11000LL; │ txGrandChild[i].vout[0].nValue = 11000LL;
} │ }
│
│
CTxMemPool testPool(CFeeRate(0)); │ CTxMemPool testPool;
│ LOCK2(cs_main, testPool.cs);
│
// Nothing in pool, remove should do nothing: │ // Nothing in pool, remove should do nothing:
unsigned int poolSize = testPool.size(); │ unsigned int poolSize = testPool.size();
testPool.removeRecursive(txParent); │ testPool.removeRecursive(CTransaction(txParent), REMOVAL_REASON_DUMMY);
BOOST_CHECK_EQUAL(testPool.size(), poolSize); │ BOOST_CHECK_EQUAL(testPool.size(), poolSize);
│
// Just the parent: │ // Just the parent:
testPool.addUnchecked(txParent.GetHash(), entry.FromTx(txParent)); │ testPool.addUnchecked(entry.FromTx(txParent));
poolSize = testPool.size(); │ poolSize = testPool.size();
testPool.removeRecursive(txParent); │ testPool.removeRecursive(CTransaction(txParent), REMOVAL_REASON_DUMMY);
BOOST_CHECK_EQUAL(testPool.size(), poolSize - 1); │ BOOST_CHECK_EQUAL(testPool.size(), poolSize - 1);
│
// Parent, children, grandchildren: │ // Parent, children, grandchildren:
testPool.addUnchecked(txParent.GetHash(), entry.FromTx(txParent)); │ testPool.addUnchecked(entry.FromTx(txParent));
for (int i = 0; i < 3; i++) │ for (int i = 0; i < 3; i++)
{ │ {
testPool.addUnchecked(txChild[i].GetHash(), entry.FromTx(txChild[i])); │ testPool.addUnchecked(entry.FromTx(txChild[i]));
testPool.addUnchecked(txGrandChild[i].GetHash(), entry.FromTx(txGrandChild[i])); │ testPool.addUnchecked(entry.FromTx(txGrandChild[i]));
} │ }
// Remove Child[0], GrandChild[0] should be removed: │ // Remove Child[0], GrandChild[0] should be removed:
poolSize = testPool.size(); │ poolSize = testPool.size();
testPool.removeRecursive(txChild[0]); │ testPool.removeRecursive(CTransaction(txChild[0]), REMOVAL_REASON_DUMMY);
BOOST_CHECK_EQUAL(testPool.size(), poolSize - 2); │ BOOST_CHECK_EQUAL(testPool.size(), poolSize - 2);
// ... make sure grandchild and child are gone: │ // ... make sure grandchild and child are gone:
poolSize = testPool.size(); │ poolSize = testPool.size();
testPool.removeRecursive(txGrandChild[0]); │ testPool.removeRecursive(CTransaction(txGrandChild[0]), REMOVAL_REASON_DUMMY);
BOOST_CHECK_EQUAL(testPool.size(), poolSize); │ BOOST_CHECK_EQUAL(testPool.size(), poolSize);
poolSize = testPool.size(); │ poolSize = testPool.size();
testPool.removeRecursive(txChild[0]); │ testPool.removeRecursive(CTransaction(txChild[0]), REMOVAL_REASON_DUMMY);
BOOST_CHECK_EQUAL(testPool.size(), poolSize); │ BOOST_CHECK_EQUAL(testPool.size(), poolSize);
// Remove parent, all children/grandchildren should go: │ // Remove parent, all children/grandchildren should go:
poolSize = testPool.size(); │ poolSize = testPool.size();
testPool.removeRecursive(txParent); │ testPool.removeRecursive(CTransaction(txParent), REMOVAL_REASON_DUMMY);
BOOST_CHECK_EQUAL(testPool.size(), poolSize - 5); │ BOOST_CHECK_EQUAL(testPool.size(), poolSize - 5);
BOOST_CHECK_EQUAL(testPool.size(), 0); │ BOOST_CHECK_EQUAL(testPool.size(), 0U);
│
// Add children and grandchildren, but NOT the parent (simulate the parent being in │ // Add children and grandchildren, but NOT the parent (simulate the parent being in
for (int i = 0; i < 3; i++) │ for (int i = 0; i < 3; i++)
{ │ {
testPool.addUnchecked(txChild[i].GetHash(), entry.FromTx(txChild[i])); │ testPool.addUnchecked(entry.FromTx(txChild[i]));
testPool.addUnchecked(txGrandChild[i].GetHash(), entry.FromTx(txGrandChild[i])); │ testPool.addUnchecked(entry.FromTx(txGrandChild[i]));
} │ }
// Now remove the parent, as might happen if a block-re-org occurs but the parent ca │ // Now remove the parent, as might happen if a block-re-org occurs but the parent ca
// put into the mempool (maybe because it is non-standard): │ // put into the mempool (maybe because it is non-standard):
poolSize = testPool.size(); │ poolSize = testPool.size();
testPool.removeRecursive(txParent); │ testPool.removeRecursive(CTransaction(txParent), REMOVAL_REASON_DUMMY);
BOOST_CHECK_EQUAL(testPool.size(), poolSize - 6); │ BOOST_CHECK_EQUAL(testPool.size(), poolSize - 6);
BOOST_CHECK_EQUAL(testPool.size(), 0); │ BOOST_CHECK_EQUAL(testPool.size(), 0U);
} │
next prev up bitcoin/src/test/uint256_tests.cpp:160 │ dogecoin/src/test/uint256_tests.cpp:160
│
BOOST_CHECK(R1L.GetHex() == R1L.ToString()); │ BOOST_CHECK(R1L.GetHex() == R1L.ToString());
BOOST_CHECK(R2L.GetHex() == R2L.ToString()); │ BOOST_CHECK(R2L.GetHex() == R2L.ToString());
BOOST_CHECK(OneL.GetHex() == OneL.ToString()); │ BOOST_CHECK(OneL.GetHex() == OneL.ToString());
BOOST_CHECK(MaxL.GetHex() == MaxL.ToString()); │ BOOST_CHECK(MaxL.GetHex() == MaxL.ToString());
uint256 TmpL(R1L); │ uint256 TmpL(R1L);
BOOST_CHECK(TmpL == R1L); │ BOOST_CHECK(TmpL == R1L);
TmpL.SetHex(R2L.ToString()); BOOST_CHECK(TmpL == R2L); │ TmpL.SetHex(R2L.ToString()); BOOST_CHECK(TmpL == R2L);
TmpL.SetHex(ZeroL.ToString()); BOOST_CHECK(TmpL == uint256()); │ TmpL.SetHex(ZeroL.ToString()); BOOST_CHECK(TmpL == uint256());
│
TmpL.SetHex(R1L.ToString()); │ TmpL.SetHex(R1L.ToString());
BOOST_CHECK(memcmp(R1L.begin(), R1Array, 32)==0); │ BOOST_CHECK(memcmp(R1L.begin(), R1Array, 32)==0);
BOOST_CHECK(memcmp(TmpL.begin(), R1Array, 32)==0); │ BOOST_CHECK(memcmp(TmpL.begin(), R1Array, 32)==0);
BOOST_CHECK(memcmp(R2L.begin(), R2Array, 32)==0); │ BOOST_CHECK(memcmp(R2L.begin(), R2Array, 32)==0);
BOOST_CHECK(memcmp(ZeroL.begin(), ZeroArray, 32)==0); │ BOOST_CHECK(memcmp(ZeroL.begin(), ZeroArray, 32)==0);
BOOST_CHECK(memcmp(OneL.begin(), OneArray, 32)==0); │ BOOST_CHECK(memcmp(OneL.begin(), OneArray, 32)==0);
BOOST_CHECK(R1L.size() == sizeof(R1L)); │ BOOST_CHECK(R1L.size() == sizeof(R1L));
BOOST_CHECK(sizeof(R1L) == 32); │ BOOST_CHECK(sizeof(R1L) == 32);
BOOST_CHECK(R1L.size() == 32); │ BOOST_CHECK(R1L.size() == 32);
BOOST_CHECK(R2L.size() == 32); │ BOOST_CHECK(R2L.size() == 32);
BOOST_CHECK(ZeroL.size() == 32); │ BOOST_CHECK(ZeroL.size() == 32);
BOOST_CHECK(MaxL.size() == 32); │ BOOST_CHECK(MaxL.size() == 32);
BOOST_CHECK(R1L.begin() + 32 == R1L.end()); │ BOOST_CHECK(R1L.begin() + 32 == R1L.end());
BOOST_CHECK(R2L.begin() + 32 == R2L.end()); │ BOOST_CHECK(R2L.begin() + 32 == R2L.end());
BOOST_CHECK(OneL.begin() + 32 == OneL.end()); │ BOOST_CHECK(OneL.begin() + 32 == OneL.end());
BOOST_CHECK(MaxL.begin() + 32 == MaxL.end()); │ BOOST_CHECK(MaxL.begin() + 32 == MaxL.end());
BOOST_CHECK(TmpL.begin() + 32 == TmpL.end()); │ BOOST_CHECK(TmpL.begin() + 32 == TmpL.end());
BOOST_CHECK(GetSerializeSize(R1L, 0, PROTOCOL_VERSION) == 32); │ BOOST_CHECK(GetSerializeSize(R1L, 0, PROTOCOL_VERSION) == 32);
BOOST_CHECK(GetSerializeSize(ZeroL, 0, PROTOCOL_VERSION) == 32); │ BOOST_CHECK(GetSerializeSize(ZeroL, 0, PROTOCOL_VERSION) == 32);
│
CDataStream ss(0, PROTOCOL_VERSION); │ CDataStream ss(0, PROTOCOL_VERSION);
ss << R1L; │ ss << R1L;
BOOST_CHECK(ss.str() == std::string(R1Array,R1Array+32)); │ BOOST_CHECK(ss.str() == std::string(R1Array,R1Array+32));
ss >> TmpL; │ ss >> TmpL;
BOOST_CHECK(R1L == TmpL); │ BOOST_CHECK(R1L == TmpL);
ss.clear(); │ ss.clear();
ss << ZeroL; │ ss << ZeroL;
BOOST_CHECK(ss.str() == std::string(ZeroArray,ZeroArray+32)); │ BOOST_CHECK(ss.str() == std::string(ZeroArray,ZeroArray+32));
ss >> TmpL; │ ss >> TmpL;
BOOST_CHECK(ZeroL == TmpL); │ BOOST_CHECK(ZeroL == TmpL);
ss.clear(); │ ss.clear();
ss << MaxL; │ ss << MaxL;
BOOST_CHECK(ss.str() == std::string(MaxArray,MaxArray+32)); │ BOOST_CHECK(ss.str() == std::string(MaxArray,MaxArray+32));
ss >> TmpL; │ ss >> TmpL;
BOOST_CHECK(MaxL == TmpL); │ BOOST_CHECK(MaxL == TmpL);
ss.clear(); │ ss.clear();
│
BOOST_CHECK(R1S.GetHex() == R1S.ToString()); │ BOOST_CHECK(R1S.GetHex() == R1S.ToString());
BOOST_CHECK(R2S.GetHex() == R2S.ToString()); │ BOOST_CHECK(R2S.GetHex() == R2S.ToString());
BOOST_CHECK(OneS.GetHex() == OneS.ToString()); │ BOOST_CHECK(OneS.GetHex() == OneS.ToString());
BOOST_CHECK(MaxS.GetHex() == MaxS.ToString()); │ BOOST_CHECK(MaxS.GetHex() == MaxS.ToString());
uint160 TmpS(R1S); │ uint160 TmpS(R1S);
BOOST_CHECK(TmpS == R1S); │ BOOST_CHECK(TmpS == R1S);
TmpS.SetHex(R2S.ToString()); BOOST_CHECK(TmpS == R2S); │ TmpS.SetHex(R2S.ToString()); BOOST_CHECK(TmpS == R2S);
TmpS.SetHex(ZeroS.ToString()); BOOST_CHECK(TmpS == uint160()); │ TmpS.SetHex(ZeroS.ToString()); BOOST_CHECK(TmpS == uint160());
│
TmpS.SetHex(R1S.ToString()); │ TmpS.SetHex(R1S.ToString());
BOOST_CHECK(memcmp(R1S.begin(), R1Array, 20)==0); │ BOOST_CHECK(memcmp(R1S.begin(), R1Array, 20)==0);
BOOST_CHECK(memcmp(TmpS.begin(), R1Array, 20)==0); │ BOOST_CHECK(memcmp(TmpS.begin(), R1Array, 20)==0);
BOOST_CHECK(memcmp(R2S.begin(), R2Array, 20)==0); │ BOOST_CHECK(memcmp(R2S.begin(), R2Array, 20)==0);
BOOST_CHECK(memcmp(ZeroS.begin(), ZeroArray, 20)==0); │ BOOST_CHECK(memcmp(ZeroS.begin(), ZeroArray, 20)==0);
BOOST_CHECK(memcmp(OneS.begin(), OneArray, 20)==0); │ BOOST_CHECK(memcmp(OneS.begin(), OneArray, 20)==0);
BOOST_CHECK(R1S.size() == sizeof(R1S)); │ BOOST_CHECK(R1S.size() == sizeof(R1S));
BOOST_CHECK(sizeof(R1S) == 20); │ BOOST_CHECK(sizeof(R1S) == 20);
BOOST_CHECK(R1S.size() == 20); │ BOOST_CHECK(R1S.size() == 20);
BOOST_CHECK(R2S.size() == 20); │ BOOST_CHECK(R2S.size() == 20);
BOOST_CHECK(ZeroS.size() == 20); │ BOOST_CHECK(ZeroS.size() == 20);
BOOST_CHECK(MaxS.size() == 20); │ BOOST_CHECK(MaxS.size() == 20);
BOOST_CHECK(R1S.begin() + 20 == R1S.end()); │ BOOST_CHECK(R1S.begin() + 20 == R1S.end());
BOOST_CHECK(R2S.begin() + 20 == R2S.end()); │ BOOST_CHECK(R2S.begin() + 20 == R2S.end());
BOOST_CHECK(OneS.begin() + 20 == OneS.end()); │ BOOST_CHECK(OneS.begin() + 20 == OneS.end());
BOOST_CHECK(MaxS.begin() + 20 == MaxS.end()); │ BOOST_CHECK(MaxS.begin() + 20 == MaxS.end());
BOOST_CHECK(TmpS.begin() + 20 == TmpS.end()); │ BOOST_CHECK(TmpS.begin() + 20 == TmpS.end());
BOOST_CHECK(GetSerializeSize(R1S, 0, PROTOCOL_VERSION) == 20); │ BOOST_CHECK(GetSerializeSize(R1S, 0, PROTOCOL_VERSION) == 20);
BOOST_CHECK(GetSerializeSize(ZeroS, 0, PROTOCOL_VERSION) == 20); │ BOOST_CHECK(GetSerializeSize(ZeroS, 0, PROTOCOL_VERSION) == 20);
│
ss << R1S; │ ss << R1S;
BOOST_CHECK(ss.str() == std::string(R1Array,R1Array+20)); │ BOOST_CHECK(ss.str() == std::string(R1Array,R1Array+20));
ss >> TmpS; │ ss >> TmpS;
BOOST_CHECK(R1S == TmpS); │ BOOST_CHECK(R1S == TmpS);
ss.clear(); │ ss.clear();
ss << ZeroS; │ ss << ZeroS;
BOOST_CHECK(ss.str() == std::string(ZeroArray,ZeroArray+20)); │ BOOST_CHECK(ss.str() == std::string(ZeroArray,ZeroArray+20));
ss >> TmpS; │ ss >> TmpS;
BOOST_CHECK(ZeroS == TmpS); │ BOOST_CHECK(ZeroS == TmpS);
ss.clear(); │ ss.clear();
ss << MaxS; │ ss << MaxS;
BOOST_CHECK(ss.str() == std::string(MaxArray,MaxArray+20)); │ BOOST_CHECK(ss.str() == std::string(MaxArray,MaxArray+20));
ss >> TmpS; │ ss >> TmpS;
BOOST_CHECK(MaxS == TmpS); │ BOOST_CHECK(MaxS == TmpS);
ss.clear(); │ ss.clear();
} │
next prev up dogecoin/src/test/util_tests.cpp:505 │ bitcoin/src/test/util_tests.cpp:1997
│
int64_t amount = 0; │ int64_t amount = 0;
BOOST_CHECK(ParseFixedPoint("0", 8, &amount)); │ BOOST_CHECK(ParseFixedPoint("0", 8, &amount));
BOOST_CHECK_EQUAL(amount, 0LL); │ BOOST_CHECK_EQUAL(amount, 0LL);
BOOST_CHECK(ParseFixedPoint("1", 8, &amount)); │ BOOST_CHECK(ParseFixedPoint("1", 8, &amount));
BOOST_CHECK_EQUAL(amount, 100000000LL); │ BOOST_CHECK_EQUAL(amount, 100000000LL);
BOOST_CHECK(ParseFixedPoint("0.0", 8, &amount)); │ BOOST_CHECK(ParseFixedPoint("0.0", 8, &amount));
BOOST_CHECK_EQUAL(amount, 0LL); │ BOOST_CHECK_EQUAL(amount, 0LL);
BOOST_CHECK(ParseFixedPoint("-0.1", 8, &amount)); │ BOOST_CHECK(ParseFixedPoint("-0.1", 8, &amount));
BOOST_CHECK_EQUAL(amount, -10000000LL); │ BOOST_CHECK_EQUAL(amount, -10000000LL);
BOOST_CHECK(ParseFixedPoint("1.1", 8, &amount)); │ BOOST_CHECK(ParseFixedPoint("1.1", 8, &amount));
BOOST_CHECK_EQUAL(amount, 110000000LL); │ BOOST_CHECK_EQUAL(amount, 110000000LL);
BOOST_CHECK(ParseFixedPoint("1.10000000000000000", 8, &amount)); │ BOOST_CHECK(ParseFixedPoint("1.10000000000000000", 8, &amount));
BOOST_CHECK_EQUAL(amount, 110000000LL); │ BOOST_CHECK_EQUAL(amount, 110000000LL);
BOOST_CHECK(ParseFixedPoint("1.1e1", 8, &amount)); │ BOOST_CHECK(ParseFixedPoint("1.1e1", 8, &amount));
BOOST_CHECK_EQUAL(amount, 1100000000LL); │ BOOST_CHECK_EQUAL(amount, 1100000000LL);
BOOST_CHECK(ParseFixedPoint("1.1e-1", 8, &amount)); │ BOOST_CHECK(ParseFixedPoint("1.1e-1", 8, &amount));
BOOST_CHECK_EQUAL(amount, 11000000LL); │ BOOST_CHECK_EQUAL(amount, 11000000LL);
BOOST_CHECK(ParseFixedPoint("1000", 8, &amount)); │ BOOST_CHECK(ParseFixedPoint("1000", 8, &amount));
BOOST_CHECK_EQUAL(amount, 100000000000LL); │ BOOST_CHECK_EQUAL(amount, 100000000000LL);
BOOST_CHECK(ParseFixedPoint("-1000", 8, &amount)); │ BOOST_CHECK(ParseFixedPoint("-1000", 8, &amount));
BOOST_CHECK_EQUAL(amount, -100000000000LL); │ BOOST_CHECK_EQUAL(amount, -100000000000LL);
BOOST_CHECK(ParseFixedPoint("0.00000001", 8, &amount)); │ BOOST_CHECK(ParseFixedPoint("0.00000001", 8, &amount));
BOOST_CHECK_EQUAL(amount, 1LL); │ BOOST_CHECK_EQUAL(amount, 1LL);
BOOST_CHECK(ParseFixedPoint("0.0000000100000000", 8, &amount)); │ BOOST_CHECK(ParseFixedPoint("0.0000000100000000", 8, &amount));
BOOST_CHECK_EQUAL(amount, 1LL); │ BOOST_CHECK_EQUAL(amount, 1LL);
BOOST_CHECK(ParseFixedPoint("-0.00000001", 8, &amount)); │ BOOST_CHECK(ParseFixedPoint("-0.00000001", 8, &amount));
BOOST_CHECK_EQUAL(amount, -1LL); │ BOOST_CHECK_EQUAL(amount, -1LL);
BOOST_CHECK(ParseFixedPoint("1000000000.00000001", 8, &amount)); │ BOOST_CHECK(ParseFixedPoint("1000000000.00000001", 8, &amount));
BOOST_CHECK_EQUAL(amount, 100000000000000001LL); │ BOOST_CHECK_EQUAL(amount, 100000000000000001LL);
BOOST_CHECK(ParseFixedPoint("9999999999.99999999", 8, &amount)); │ BOOST_CHECK(ParseFixedPoint("9999999999.99999999", 8, &amount));
BOOST_CHECK_EQUAL(amount, 999999999999999999LL); │ BOOST_CHECK_EQUAL(amount, 999999999999999999LL);
BOOST_CHECK(ParseFixedPoint("-9999999999.99999999", 8, &amount)); │ BOOST_CHECK(ParseFixedPoint("-9999999999.99999999", 8, &amount));
BOOST_CHECK_EQUAL(amount, -999999999999999999LL); │ BOOST_CHECK_EQUAL(amount, -999999999999999999LL);
│
BOOST_CHECK(!ParseFixedPoint("", 8, &amount)); │ BOOST_CHECK(!ParseFixedPoint("", 8, &amount));
BOOST_CHECK(!ParseFixedPoint("-", 8, &amount)); │ BOOST_CHECK(!ParseFixedPoint("-", 8, &amount));
BOOST_CHECK(!ParseFixedPoint("a-1000", 8, &amount)); │ BOOST_CHECK(!ParseFixedPoint("a-1000", 8, &amount));
BOOST_CHECK(!ParseFixedPoint("-a1000", 8, &amount)); │ BOOST_CHECK(!ParseFixedPoint("-a1000", 8, &amount));
BOOST_CHECK(!ParseFixedPoint("-1000a", 8, &amount)); │ BOOST_CHECK(!ParseFixedPoint("-1000a", 8, &amount));
BOOST_CHECK(!ParseFixedPoint("-01000", 8, &amount)); │ BOOST_CHECK(!ParseFixedPoint("-01000", 8, &amount));
BOOST_CHECK(!ParseFixedPoint("00.1", 8, &amount)); │ BOOST_CHECK(!ParseFixedPoint("00.1", 8, &amount));
BOOST_CHECK(!ParseFixedPoint(".1", 8, &amount)); │ BOOST_CHECK(!ParseFixedPoint(".1", 8, &amount));
BOOST_CHECK(!ParseFixedPoint("--0.1", 8, &amount)); │ BOOST_CHECK(!ParseFixedPoint("--0.1", 8, &amount));
BOOST_CHECK(!ParseFixedPoint("0.000000001", 8, &amount)); │ BOOST_CHECK(!ParseFixedPoint("0.000000001", 8, &amount));
BOOST_CHECK(!ParseFixedPoint("-0.000000001", 8, &amount)); │ BOOST_CHECK(!ParseFixedPoint("-0.000000001", 8, &amount));
BOOST_CHECK(!ParseFixedPoint("0.00000001000000001", 8, &amount)); │ BOOST_CHECK(!ParseFixedPoint("0.00000001000000001", 8, &amount));
BOOST_CHECK(!ParseFixedPoint("-10000000000.00000000", 8, &amount)); │ BOOST_CHECK(!ParseFixedPoint("-10000000000.00000000", 8, &amount));
BOOST_CHECK(!ParseFixedPoint("10000000000.00000000", 8, &amount)); │ BOOST_CHECK(!ParseFixedPoint("10000000000.00000000", 8, &amount));
BOOST_CHECK(!ParseFixedPoint("-10000000000.00000001", 8, &amount)); │ BOOST_CHECK(!ParseFixedPoint("-10000000000.00000001", 8, &amount));
BOOST_CHECK(!ParseFixedPoint("10000000000.00000001", 8, &amount)); │ BOOST_CHECK(!ParseFixedPoint("10000000000.00000001", 8, &amount));
BOOST_CHECK(!ParseFixedPoint("-10000000000.00000009", 8, &amount)); │ BOOST_CHECK(!ParseFixedPoint("-10000000000.00000009", 8, &amount));
BOOST_CHECK(!ParseFixedPoint("10000000000.00000009", 8, &amount)); │ BOOST_CHECK(!ParseFixedPoint("10000000000.00000009", 8, &amount));
BOOST_CHECK(!ParseFixedPoint("-99999999999.99999999", 8, &amount)); │ BOOST_CHECK(!ParseFixedPoint("-99999999999.99999999", 8, &amount));
BOOST_CHECK(!ParseFixedPoint("99999909999.09999999", 8, &amount)); │ BOOST_CHECK(!ParseFixedPoint("99999909999.09999999", 8, &amount));
BOOST_CHECK(!ParseFixedPoint("92233720368.54775807", 8, &amount)); │ BOOST_CHECK(!ParseFixedPoint("92233720368.54775807", 8, &amount));
BOOST_CHECK(!ParseFixedPoint("92233720368.54775808", 8, &amount)); │ BOOST_CHECK(!ParseFixedPoint("92233720368.54775808", 8, &amount));
BOOST_CHECK(!ParseFixedPoint("-92233720368.54775808", 8, &amount)); │ BOOST_CHECK(!ParseFixedPoint("-92233720368.54775808", 8, &amount));
BOOST_CHECK(!ParseFixedPoint("-92233720368.54775809", 8, &amount)); │ BOOST_CHECK(!ParseFixedPoint("-92233720368.54775809", 8, &amount));
BOOST_CHECK(!ParseFixedPoint("1.1e", 8, &amount)); │ BOOST_CHECK(!ParseFixedPoint("1.1e", 8, &amount));
BOOST_CHECK(!ParseFixedPoint("1.1e-", 8, &amount)); │ BOOST_CHECK(!ParseFixedPoint("1.1e-", 8, &amount));
BOOST_CHECK(!ParseFixedPoint("1.", 8, &amount)); │ BOOST_CHECK(!ParseFixedPoint("1.", 8, &amount));
│
│ // Test with 3 decimal places for fee rates in sat/vB.
│ BOOST_CHECK(ParseFixedPoint("0.001", 3, &amount));
│ BOOST_CHECK_EQUAL(amount, CAmount{1});
│ BOOST_CHECK(!ParseFixedPoint("0.0009", 3, &amount));
│ BOOST_CHECK(!ParseFixedPoint("31.00100001", 3, &amount));
│ BOOST_CHECK(!ParseFixedPoint("31.0011", 3, &amount));
│ BOOST_CHECK(!ParseFixedPoint("31.99999999", 3, &amount));
│ BOOST_CHECK(!ParseFixedPoint("31.999999999999999999999", 3, &amount));
} │
next prev up dogecoin/src/test/allocator_tests.cpp:15 │ bitcoin/src/test/allocator_tests.cpp:19
│
// Fake memory base address for testing │ // Fake memory base address for testing
// without actually using memory. │ // without actually using memory.
void *synth_base = reinterpret_cast<void*>(0x08000000); │ void *synth_base = reinterpret_cast<void*>(0x08000000);
const size_t synth_size = 1024*1024; │ const size_t synth_size = 1024*1024;
Arena b(synth_base, synth_size, 16); │ Arena b(synth_base, synth_size, 16);
void *chunk = b.alloc(1000); │ void *chunk = b.alloc(1000);
#ifdef ARENA_DEBUG │ #ifdef ARENA_DEBUG
b.walk(); │ b.walk();
#endif │ #endif
BOOST_CHECK(chunk != nullptr); │ BOOST_CHECK(chunk != nullptr);
BOOST_CHECK(b.stats().used == 1008); // Aligned to 16 │ BOOST_CHECK(b.stats().used == 1008); // Aligned to 16
BOOST_CHECK(b.stats().total == synth_size); // Nothing has disappeared? │ BOOST_CHECK(b.stats().total == synth_size); // Nothing has disappeared?
b.free(chunk); │ b.free(chunk);
#ifdef ARENA_DEBUG │ #ifdef ARENA_DEBUG
b.walk(); │ b.walk();
#endif │ #endif
BOOST_CHECK(b.stats().used == 0); │ BOOST_CHECK(b.stats().used == 0);
BOOST_CHECK(b.stats().free == synth_size); │ BOOST_CHECK(b.stats().free == synth_size);
try { // Test exception on double-free │ try { // Test exception on double-free
b.free(chunk); │ b.free(chunk);
BOOST_CHECK(0); │ BOOST_CHECK(0);
} catch(std::runtime_error &) │ } catch(std::runtime_error &)
{ │ {
} │ }
│
void *a0 = b.alloc(128); │ void *a0 = b.alloc(128);
void *a1 = b.alloc(256); │ void *a1 = b.alloc(256);
void *a2 = b.alloc(512); │ void *a2 = b.alloc(512);
BOOST_CHECK(b.stats().used == 896); │ BOOST_CHECK(b.stats().used == 896);
BOOST_CHECK(b.stats().total == synth_size); │ BOOST_CHECK(b.stats().total == synth_size);
#ifdef ARENA_DEBUG │ #ifdef ARENA_DEBUG
b.walk(); │ b.walk();
#endif │ #endif
b.free(a0); │ b.free(a0);
#ifdef ARENA_DEBUG │ #ifdef ARENA_DEBUG
b.walk(); │ b.walk();
#endif │ #endif
BOOST_CHECK(b.stats().used == 768); │ BOOST_CHECK(b.stats().used == 768);
b.free(a1); │ b.free(a1);
BOOST_CHECK(b.stats().used == 512); │ BOOST_CHECK(b.stats().used == 512);
void *a3 = b.alloc(128); │ void *a3 = b.alloc(128);
#ifdef ARENA_DEBUG │ #ifdef ARENA_DEBUG
b.walk(); │ b.walk();
#endif │ #endif
BOOST_CHECK(b.stats().used == 640); │ BOOST_CHECK(b.stats().used == 640);
b.free(a2); │ b.free(a2);
BOOST_CHECK(b.stats().used == 128); │ BOOST_CHECK(b.stats().used == 128);
b.free(a3); │ b.free(a3);
BOOST_CHECK(b.stats().used == 0); │ BOOST_CHECK(b.stats().used == 0);
BOOST_CHECK_EQUAL(b.stats().chunks_used, 0); │ BOOST_CHECK_EQUAL(b.stats().chunks_used, 0U);
BOOST_CHECK(b.stats().total == synth_size); │ BOOST_CHECK(b.stats().total == synth_size);
BOOST_CHECK(b.stats().free == synth_size); │ BOOST_CHECK(b.stats().free == synth_size);
BOOST_CHECK_EQUAL(b.stats().chunks_free, 1); │ BOOST_CHECK_EQUAL(b.stats().chunks_free, 1U);
│
std::vector<void*> addr; │ std::vector<void*> addr;
BOOST_CHECK(b.alloc(0) == nullptr); // allocating 0 always returns nullptr │ BOOST_CHECK(b.alloc(0) == nullptr); // allocating 0 always returns nullptr
#ifdef ARENA_DEBUG │ #ifdef ARENA_DEBUG
b.walk(); │ b.walk();
#endif │ #endif
// Sweeping allocate all memory │ // Sweeping allocate all memory
for (int x=0; x<1024; ++x) │ for (int x=0; x<1024; ++x)
addr.push_back(b.alloc(1024)); │ addr.push_back(b.alloc(1024));
BOOST_CHECK(b.stats().free == 0); │ BOOST_CHECK(b.stats().free == 0);
BOOST_CHECK(b.alloc(1024) == nullptr); // memory is full, this must return nullptr │ BOOST_CHECK(b.alloc(1024) == nullptr); // memory is full, this must return nullptr
BOOST_CHECK(b.alloc(0) == nullptr); │ BOOST_CHECK(b.alloc(0) == nullptr);
for (int x=0; x<1024; ++x) │ for (int x=0; x<1024; ++x)
b.free(addr[x]); │ b.free(addr[x]);
addr.clear(); │ addr.clear();
BOOST_CHECK(b.stats().total == synth_size); │ BOOST_CHECK(b.stats().total == synth_size);
BOOST_CHECK(b.stats().free == synth_size); │ BOOST_CHECK(b.stats().free == synth_size);
│
// Now in the other direction... │ // Now in the other direction...
for (int x=0; x<1024; ++x) │ for (int x=0; x<1024; ++x)
addr.push_back(b.alloc(1024)); │ addr.push_back(b.alloc(1024));
for (int x=0; x<1024; ++x) │ for (int x=0; x<1024; ++x)
b.free(addr[1023-x]); │ b.free(addr[1023-x]);
addr.clear(); │ addr.clear();
│
// Now allocate in smaller unequal chunks, then deallocate haphazardly │ // Now allocate in smaller unequal chunks, then deallocate haphazardly
// Not all the chunks will succeed allocating, but freeing nullptr is │ // Not all the chunks will succeed allocating, but freeing nullptr is
// allowed so that is no problem. │ // allowed so that is no problem.
for (int x=0; x<2048; ++x) │ for (int x=0; x<2048; ++x)
addr.push_back(b.alloc(x+1)); │ addr.push_back(b.alloc(x+1));
for (int x=0; x<2048; ++x) │ for (int x=0; x<2048; ++x)
b.free(addr[((x*23)%2048)^242]); │ b.free(addr[((x*23)%2048)^242]);
addr.clear(); │ addr.clear();
│
// Go entirely wild: free and alloc interleaved, │ // Go entirely wild: free and alloc interleaved,
// generate targets and sizes using pseudo-randomness. │ // generate targets and sizes using pseudo-randomness.
for (int x=0; x<2048; ++x) │ for (int x=0; x<2048; ++x)
addr.push_back(0); │ addr.push_back(nullptr);
uint32_t s = 0x12345678; │ uint32_t s = 0x12345678;
for (int x=0; x<5000; ++x) { │ for (int x=0; x<5000; ++x) {
int idx = s & (addr.size()-1); │ int idx = s & (addr.size()-1);
if (s & 0x80000000) { │ if (s & 0x80000000) {
b.free(addr[idx]); │ b.free(addr[idx]);
addr[idx] = 0; │ addr[idx] = nullptr;
} else if(!addr[idx]) { │ } else if(!addr[idx]) {
addr[idx] = b.alloc((s >> 16) & 2047); │ addr[idx] = b.alloc((s >> 16) & 2047);
} │ }
bool lsb = s & 1; │ bool lsb = s & 1;
s >>= 1; │ s >>= 1;
if (lsb) │ if (lsb)
s ^= 0xf00f00f0; // LFSR period 0xf7ffffe0 │ s ^= 0xf00f00f0; // LFSR period 0xf7ffffe0
} │ }
for (void *ptr: addr) │ for (void *ptr: addr)
b.free(ptr); │ b.free(ptr);
addr.clear(); │ addr.clear();
│
BOOST_CHECK(b.stats().total == synth_size); │ BOOST_CHECK(b.stats().total == synth_size);
BOOST_CHECK(b.stats().free == synth_size); │ BOOST_CHECK(b.stats().free == synth_size);
} │
next prev up dogecoin/src/qt/transactiontablemodel.cpp:100 │ bitcoin/src/qt/transactiontablemodel.cpp:133
│
qDebug() << "TransactionTablePriv::updateWallet: " + QString::fromStdString(hash │ qDebug() << "TransactionTablePriv::updateWallet: " + QString::fromStdString(hash
│
// Find bounds of this transaction in model │ // Find bounds of this transaction in model
QList<TransactionRecord>::iterator lower = qLowerBound( │ QList<TransactionRecord>::iterator lower = std::lower_bound(
cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan()); │ cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan());
QList<TransactionRecord>::iterator upper = qUpperBound( │ QList<TransactionRecord>::iterator upper = std::upper_bound(
cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan()); │ cachedWallet.begin(), cachedWallet.end(), hash, TxLessThan());
int lowerIndex = (lower - cachedWallet.begin()); │ int lowerIndex = (lower - cachedWallet.begin());
int upperIndex = (upper - cachedWallet.begin()); │ int upperIndex = (upper - cachedWallet.begin());
bool inModel = (lower != upper); │ bool inModel = (lower != upper);
│
if(status == CT_UPDATED) │ if(status == CT_UPDATED)
{ │ {
if(showTransaction && !inModel) │ if(showTransaction && !inModel)
status = CT_NEW; /* Not in model, but want to show, treat as new */ │ status = CT_NEW; /* Not in model, but want to show, treat as new */
if(!showTransaction && inModel) │ if(!showTransaction && inModel)
status = CT_DELETED; /* In model, but want to hide, treat as deleted */ │ status = CT_DELETED; /* In model, but want to hide, treat as deleted */
} │ }
│
qDebug() << " inModel=" + QString::number(inModel) + │ qDebug() << " inModel=" + QString::number(inModel) +
" Index=" + QString::number(lowerIndex) + "-" + QString::number(uppe │ " Index=" + QString::number(lowerIndex) + "-" + QString::number(uppe
" showTransaction=" + QString::number(showTransaction) + " derivedSt │ " showTransaction=" + QString::number(showTransaction) + " derivedSt
│
switch(status) │ switch(status)
{ │ {
case CT_NEW: │ case CT_NEW:
if(inModel) │ if(inModel)
{ │ {
qWarning() << "TransactionTablePriv::updateWallet: Warning: Got CT_NEW, │ qWarning() << "TransactionTablePriv::updateWallet: Warning: Got CT_NEW,
break; │ break;
} │ }
if(showTransaction) │ if(showTransaction)
{ │ {
LOCK2(cs_main, wallet->cs_wallet); │
// Find transaction in wallet │ // Find transaction in wallet
std::map<uint256, CWalletTx>::iterator mi = wallet->mapWallet.find(hash) │ interfaces::WalletTx wtx = wallet.getWalletTx(hash);
if(mi == wallet->mapWallet.end()) │ if(!wtx.tx)
{ │ {
qWarning() << "TransactionTablePriv::updateWallet: Warning: Got CT_N │ qWarning() << "TransactionTablePriv::updateWallet: Warning: Got CT_N
break; │ break;
} │ }
// Added -- insert at the right position │ // Added -- insert at the right position
QList<TransactionRecord> toInsert = │ QList<TransactionRecord> toInsert =
TransactionRecord::decomposeTransaction(wallet, mi->second); │ TransactionRecord::decomposeTransaction(wtx);
if(!toInsert.isEmpty()) /* only if something to insert */ │ if(!toInsert.isEmpty()) /* only if something to insert */
{ │ {
parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex+toInse │ parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex+toInse
int insert_idx = lowerIndex; │ int insert_idx = lowerIndex;
Q_FOREACH(const TransactionRecord &rec, toInsert) │ for (const TransactionRecord &rec : toInsert)
{ │ {
cachedWallet.insert(insert_idx, rec); │ cachedWallet.insert(insert_idx, rec);
insert_idx += 1; │ insert_idx += 1;
} │ }
parent->endInsertRows(); │ parent->endInsertRows();
} │ }
} │ }
break; │ break;
case CT_DELETED: │ case CT_DELETED:
if(!inModel) │ if(!inModel)
{ │ {
qWarning() << "TransactionTablePriv::updateWallet: Warning: Got CT_DELET │ qWarning() << "TransactionTablePriv::updateWallet: Warning: Got CT_DELET
break; │ break;
} │ }
// Removed -- remove entire transaction from table │ // Removed -- remove entire transaction from table
parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1); │ parent->beginRemoveRows(QModelIndex(), lowerIndex, upperIndex-1);
cachedWallet.erase(lower, upper); │ cachedWallet.erase(lower, upper);
parent->endRemoveRows(); │ parent->endRemoveRows();
break; │ break;
case CT_UPDATED: │ case CT_UPDATED:
// Miscellaneous updates -- nothing to do, status update will take care of t │ // Miscellaneous updates -- nothing to do, status update will take care of t
// visible transactions. │ // visible transactions.
│ for (int i = lowerIndex; i < upperIndex; i++) {
│ TransactionRecord *rec = &cachedWallet[i];
│ rec->status.needsUpdate = true;
│ }
break; │ break;
} │ }
} │
next prev up bitcoin/src/test/merkle_tests.cpp:26 │ dogecoin/src/consensus/merkle.cpp:46
│
if (pbranch) pbranch->clear(); │ if (pbranch) pbranch->clear();
if (leaves.size() == 0) { │ if (leaves.size() == 0) {
if (pmutated) *pmutated = false; │ if (pmutated) *pmutated = false;
if (proot) *proot = uint256(); │ if (proot) *proot = uint256();
return; │ return;
} │ }
bool mutated = false; │ bool mutated = false;
// count is the number of leaves processed so far. │ // count is the number of leaves processed so far.
uint32_t count = 0; │ uint32_t count = 0;
// inner is an array of eagerly computed subtree hashes, indexed by tree │ // inner is an array of eagerly computed subtree hashes, indexed by tree
// level (0 being the leaves). │ // level (0 being the leaves).
// For example, when count is 25 (11001 in binary), inner[4] is the hash of │ // For example, when count is 25 (11001 in binary), inner[4] is the hash of
// the first 16 leaves, inner[3] of the next 8 leaves, and inner[0] equal to │ // the first 16 leaves, inner[3] of the next 8 leaves, and inner[0] equal to
// the last leaf. The other inner entries are undefined. │ // the last leaf. The other inner entries are undefined.
uint256 inner[32]; │ uint256 inner[32];
// Which position in inner is a hash that depends on the matching leaf. │ // Which position in inner is a hash that depends on the matching leaf.
int matchlevel = -1; │ int matchlevel = -1;
// First process all leaves into 'inner' values. │ // First process all leaves into 'inner' values.
while (count < leaves.size()) { │ while (count < leaves.size()) {
uint256 h = leaves[count]; │ uint256 h = leaves[count];
bool matchh = count == branchpos; │ bool matchh = count == branchpos;
count++; │ count++;
int level; │ int level;
// For each of the lower bits in count that are 0, do 1 step. Each │ // For each of the lower bits in count that are 0, do 1 step. Each
// corresponds to an inner value that existed before processing the │ // corresponds to an inner value that existed before processing the
// current leaf, and each needs a hash to combine it. │ // current leaf, and each needs a hash to combine it.
for (level = 0; !(count & (((uint32_t)1) << level)); level++) { │ for (level = 0; !(count & (((uint32_t)1) << level)); level++) {
if (pbranch) { │ if (pbranch) {
if (matchh) { │ if (matchh) {
pbranch->push_back(inner[level]); │ pbranch->push_back(inner[level]);
} else if (matchlevel == level) { │ } else if (matchlevel == level) {
pbranch->push_back(h); │ pbranch->push_back(h);
matchh = true; │ matchh = true;
} │ }
} │ }
mutated |= (inner[level] == h); │ mutated |= (inner[level] == h);
CHash256().Write(inner[level]).Write(h).Finalize(h); │ CHash256().Write(inner[level].begin(), 32).Write(h.begin(), 32).Finalize(h.b
} │ }
// Store the resulting hash at inner position level. │ // Store the resulting hash at inner position level.
inner[level] = h; │ inner[level] = h;
if (matchh) { │ if (matchh) {
matchlevel = level; │ matchlevel = level;
} │ }
} │ }
// Do a final 'sweep' over the rightmost branch of the tree to process │ // Do a final 'sweep' over the rightmost branch of the tree to process
// odd levels, and reduce everything to a single top value. │ // odd levels, and reduce everything to a single top value.
// Level is the level (counted from the bottom) up to which we've sweeped. │ // Level is the level (counted from the bottom) up to which we've sweeped.
int level = 0; │ int level = 0;
// As long as bit number level in count is zero, skip it. It means there │ // As long as bit number level in count is zero, skip it. It means there
// is nothing left at this level. │ // is nothing left at this level.
while (!(count & (((uint32_t)1) << level))) { │ while (!(count & (((uint32_t)1) << level))) {
level++; │ level++;
} │ }
uint256 h = inner[level]; │ uint256 h = inner[level];
bool matchh = matchlevel == level; │ bool matchh = matchlevel == level;
while (count != (((uint32_t)1) << level)) { │ while (count != (((uint32_t)1) << level)) {
// If we reach this point, h is an inner value that is not the top. │ // If we reach this point, h is an inner value that is not the top.
// We combine it with itself (Bitcoin's special rule for odd levels in │ // We combine it with itself (Bitcoin's special rule for odd levels in
// the tree) to produce a higher level one. │ // the tree) to produce a higher level one.
if (pbranch && matchh) { │ if (pbranch && matchh) {
pbranch->push_back(h); │ pbranch->push_back(h);
} │ }
CHash256().Write(h).Write(h).Finalize(h); │ CHash256().Write(h.begin(), 32).Write(h.begin(), 32).Finalize(h.begin());
// Increment count to the value it would have if two entries at this │ // Increment count to the value it would have if two entries at this
// level had existed. │ // level had existed.
count += (((uint32_t)1) << level); │ count += (((uint32_t)1) << level);
level++; │ level++;
// And propagate the result upwards accordingly. │ // And propagate the result upwards accordingly.
while (!(count & (((uint32_t)1) << level))) { │ while (!(count & (((uint32_t)1) << level))) {
if (pbranch) { │ if (pbranch) {
if (matchh) { │ if (matchh) {
pbranch->push_back(inner[level]); │ pbranch->push_back(inner[level]);
} else if (matchlevel == level) { │ } else if (matchlevel == level) {
pbranch->push_back(h); │ pbranch->push_back(h);
matchh = true; │ matchh = true;
} │ }
} │ }
CHash256().Write(inner[level]).Write(h).Finalize(h); │ CHash256().Write(inner[level].begin(), 32).Write(h.begin(), 32).Finalize(h.b
level++; │ level++;
} │ }
} │ }
// Return result. │ // Return result.
if (pmutated) *pmutated = mutated; │ if (pmutated) *pmutated = mutated;
if (proot) *proot = h; │ if (proot) *proot = h;
} │
next prev up dogecoin/src/test/scheduler_tests.cpp:44 │ bitcoin/src/test/scheduler_tests.cpp:32
│
// Stress test: hundreds of microsecond-scheduled tasks, │ // Stress test: hundreds of microsecond-scheduled tasks,
// serviced by 10 threads. │ // serviced by 10 threads.
// │ //
// So... ten shared counters, which if all the tasks execute │ // So... ten shared counters, which if all the tasks execute
// properly will sum to the number of tasks done. │ // properly will sum to the number of tasks done.
// Each task adds or subtracts a random amount from one of the │ // Each task adds or subtracts a random amount from one of the
// counters, and then schedules another task 0-1000 │ // counters, and then schedules another task 0-1000
// microseconds in the future to subtract or add from │ // microseconds in the future to subtract or add from
// the counter -random_amount+1, so in the end the shared │ // the counter -random_amount+1, so in the end the shared
// counters should sum to the number of initial tasks performed. │ // counters should sum to the number of initial tasks performed.
CScheduler microTasks; │ CScheduler microTasks;
│
boost::mutex counterMutex[10]; │ std::mutex counterMutex[10];
int counter[10] = { 0 }; │ int counter[10] = { 0 };
boost::random::mt19937 rng(42); │ FastRandomContext rng{/*fDeterministic=*/true};
boost::random::uniform_int_distribution<> zeroToNine(0, 9); │ auto zeroToNine = [](FastRandomContext& rc) -> int { return rc.randrange(10); }; //
boost::random::uniform_int_distribution<> randomMsec(-11, 1000); │ auto randomMsec = [](FastRandomContext& rc) -> int { return -11 + (int)rc.randrange(
boost::random::uniform_int_distribution<> randomDelta(-1000, 1000); │ auto randomDelta = [](FastRandomContext& rc) -> int { return -1000 + (int)rc.randran
│
boost::chrono::system_clock::time_point start = boost::chrono::system_clock::now(); │ std::chrono::system_clock::time_point start = std::chrono::system_clock::now();
boost::chrono::system_clock::time_point now = start; │ std::chrono::system_clock::time_point now = start;
boost::chrono::system_clock::time_point first, last; │ std::chrono::system_clock::time_point first, last;
size_t nTasks = microTasks.getQueueInfo(first, last); │ size_t nTasks = microTasks.getQueueInfo(first, last);
BOOST_CHECK(nTasks == 0); │ BOOST_CHECK(nTasks == 0);
│
for (int i = 0; i < 100; i++) { │ for (int i = 0; i < 100; ++i) {
boost::chrono::system_clock::time_point t = now + boost::chrono::microseconds(ra │ std::chrono::system_clock::time_point t = now + std::chrono::microseconds(random
boost::chrono::system_clock::time_point tReschedule = now + boost::chrono::micro │ std::chrono::system_clock::time_point tReschedule = now + std::chrono::microseco
int whichCounter = zeroToNine(rng); │ int whichCounter = zeroToNine(rng);
CScheduler::Function f = boost::bind(µTask, boost::ref(microTasks), │ CScheduler::Function f = std::bind(µTask, std::ref(microTasks),
boost::ref(counterMutex[whichCounter]), boo │ std::ref(counterMutex[whichCounter]), std::
randomDelta(rng), tReschedule); │ randomDelta(rng), tReschedule);
microTasks.schedule(f, t); │ microTasks.schedule(f, t);
} │ }
nTasks = microTasks.getQueueInfo(first, last); │ nTasks = microTasks.getQueueInfo(first, last);
BOOST_CHECK(nTasks == 100); │ BOOST_CHECK(nTasks == 100);
BOOST_CHECK(first < last); │ BOOST_CHECK(first < last);
BOOST_CHECK(last > now); │ BOOST_CHECK(last > now);
│
// As soon as these are created they will start running and servicing the queue │ // As soon as these are created they will start running and servicing the queue
boost::thread_group microThreads; │ std::vector<std::thread> microThreads;
for (int i = 0; i < 5; i++) │ for (int i = 0; i < 5; i++)
microThreads.create_thread(boost::bind(&CScheduler::serviceQueue, µTasks)); │ microThreads.emplace_back(std::bind(&CScheduler::serviceQueue, µTasks));
│
MicroSleep(600); │ UninterruptibleSleep(std::chrono::microseconds{600});
now = boost::chrono::system_clock::now(); │ now = std::chrono::system_clock::now();
│
// More threads and more tasks: │ // More threads and more tasks:
for (int i = 0; i < 5; i++) │ for (int i = 0; i < 5; i++)
microThreads.create_thread(boost::bind(&CScheduler::serviceQueue, µTasks)); │ microThreads.emplace_back(std::bind(&CScheduler::serviceQueue, µTasks));
for (int i = 0; i < 100; i++) { │ for (int i = 0; i < 100; i++) {
boost::chrono::system_clock::time_point t = now + boost::chrono::microseconds(ra │ std::chrono::system_clock::time_point t = now + std::chrono::microseconds(random
boost::chrono::system_clock::time_point tReschedule = now + boost::chrono::micro │ std::chrono::system_clock::time_point tReschedule = now + std::chrono::microseco
int whichCounter = zeroToNine(rng); │ int whichCounter = zeroToNine(rng);
CScheduler::Function f = boost::bind(µTask, boost::ref(microTasks), │ CScheduler::Function f = std::bind(µTask, std::ref(microTasks),
boost::ref(counterMutex[whichCounter]), boo │ std::ref(counterMutex[whichCounter]), std::
randomDelta(rng), tReschedule); │ randomDelta(rng), tReschedule);
microTasks.schedule(f, t); │ microTasks.schedule(f, t);
} │ }
│
// Drain the task queue then exit threads │ // Drain the task queue then exit threads
microTasks.stop(true); │ microTasks.StopWhenDrained();
microThreads.join_all(); // ... wait until all the threads are done │ // wait until all the threads are done
│ for (auto& thread: microThreads) {
│ if (thread.joinable()) thread.join();
│ }
│
int counterSum = 0; │ int counterSum = 0;
for (int i = 0; i < 10; i++) { │ for (int i = 0; i < 10; i++) {
BOOST_CHECK(counter[i] != 0); │ BOOST_CHECK(counter[i] != 0);
counterSum += counter[i]; │ counterSum += counter[i];
} │ }
BOOST_CHECK_EQUAL(counterSum, 200); │ BOOST_CHECK_EQUAL(counterSum, 200);
} │
next prev up dogecoin/src/key.cpp:63 │ bitcoin/src/key.cpp:94
│
│ assert(*seckeylen >= CKey::SIZE);
secp256k1_pubkey pubkey; │ secp256k1_pubkey pubkey;
size_t pubkeylen = 0; │ size_t pubkeylen = 0;
if (!secp256k1_ec_pubkey_create(ctx, &pubkey, key32)) { │ if (!secp256k1_ec_pubkey_create(ctx, &pubkey, key32)) {
*privkeylen = 0; │ *seckeylen = 0;
return 0; │ return 0;
} │ }
if (compressed) { │ if (compressed) {
static const unsigned char begin[] = { │ static const unsigned char begin[] = {
0x30,0x81,0xD3,0x02,0x01,0x01,0x04,0x20 │ 0x30,0x81,0xD3,0x02,0x01,0x01,0x04,0x20
}; │ };
static const unsigned char middle[] = { │ static const unsigned char middle[] = {
0xA0,0x81,0x85,0x30,0x81,0x82,0x02,0x01,0x01,0x30,0x2C,0x06,0x07,0x2A,0x86,0 │ 0xA0,0x81,0x85,0x30,0x81,0x82,0x02,0x01,0x01,0x30,0x2C,0x06,0x07,0x2A,0x86,0
0xCE,0x3D,0x01,0x01,0x02,0x21,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0 │ 0xCE,0x3D,0x01,0x01,0x02,0x21,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0 │ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0
0xFF,0xFF,0xFE,0xFF,0xFF,0xFC,0x2F,0x30,0x06,0x04,0x01,0x00,0x04,0x01,0x07,0 │ 0xFF,0xFF,0xFE,0xFF,0xFF,0xFC,0x2F,0x30,0x06,0x04,0x01,0x00,0x04,0x01,0x07,0
0x21,0x02,0x79,0xBE,0x66,0x7E,0xF9,0xDC,0xBB,0xAC,0x55,0xA0,0x62,0x95,0xCE,0 │ 0x21,0x02,0x79,0xBE,0x66,0x7E,0xF9,0xDC,0xBB,0xAC,0x55,0xA0,0x62,0x95,0xCE,0
0x0B,0x07,0x02,0x9B,0xFC,0xDB,0x2D,0xCE,0x28,0xD9,0x59,0xF2,0x81,0x5B,0x16,0 │ 0x0B,0x07,0x02,0x9B,0xFC,0xDB,0x2D,0xCE,0x28,0xD9,0x59,0xF2,0x81,0x5B,0x16,0
0x17,0x98,0x02,0x21,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0 │ 0x17,0x98,0x02,0x21,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0
0xFF,0xFF,0xFF,0xFF,0xFE,0xBA,0xAE,0xDC,0xE6,0xAF,0x48,0xA0,0x3B,0xBF,0xD2,0 │ 0xFF,0xFF,0xFF,0xFF,0xFE,0xBA,0xAE,0xDC,0xE6,0xAF,0x48,0xA0,0x3B,0xBF,0xD2,0
0x8C,0xD0,0x36,0x41,0x41,0x02,0x01,0x01,0xA1,0x24,0x03,0x22,0x00 │ 0x8C,0xD0,0x36,0x41,0x41,0x02,0x01,0x01,0xA1,0x24,0x03,0x22,0x00
}; │ };
unsigned char *ptr = privkey; │ unsigned char *ptr = seckey;
memcpy(ptr, begin, sizeof(begin)); ptr += sizeof(begin); │ memcpy(ptr, begin, sizeof(begin)); ptr += sizeof(begin);
memcpy(ptr, key32, 32); ptr += 32; │ memcpy(ptr, key32, 32); ptr += 32;
memcpy(ptr, middle, sizeof(middle)); ptr += sizeof(middle); │ memcpy(ptr, middle, sizeof(middle)); ptr += sizeof(middle);
pubkeylen = CPubKey::COMPRESSED_SIZE; │ pubkeylen = CPubKey::COMPRESSED_SIZE;
secp256k1_ec_pubkey_serialize(ctx, ptr, &pubkeylen, &pubkey, SECP256K1_EC_COMPRE │ secp256k1_ec_pubkey_serialize(ctx, ptr, &pubkeylen, &pubkey, SECP256K1_EC_COMPRE
ptr += pubkeylen; │ ptr += pubkeylen;
*privkeylen = ptr - privkey; │ *seckeylen = ptr - seckey;
│ assert(*seckeylen == CKey::COMPRESSED_SIZE);
} else { │ } else {
static const unsigned char begin[] = { │ static const unsigned char begin[] = {
0x30,0x82,0x01,0x13,0x02,0x01,0x01,0x04,0x20 │ 0x30,0x82,0x01,0x13,0x02,0x01,0x01,0x04,0x20
}; │ };
static const unsigned char middle[] = { │ static const unsigned char middle[] = {
0xA0,0x81,0xA5,0x30,0x81,0xA2,0x02,0x01,0x01,0x30,0x2C,0x06,0x07,0x2A,0x86,0 │ 0xA0,0x81,0xA5,0x30,0x81,0xA2,0x02,0x01,0x01,0x30,0x2C,0x06,0x07,0x2A,0x86,0
0xCE,0x3D,0x01,0x01,0x02,0x21,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0 │ 0xCE,0x3D,0x01,0x01,0x02,0x21,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0 │ 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0
0xFF,0xFF,0xFE,0xFF,0xFF,0xFC,0x2F,0x30,0x06,0x04,0x01,0x00,0x04,0x01,0x07,0 │ 0xFF,0xFF,0xFE,0xFF,0xFF,0xFC,0x2F,0x30,0x06,0x04,0x01,0x00,0x04,0x01,0x07,0
0x41,0x04,0x79,0xBE,0x66,0x7E,0xF9,0xDC,0xBB,0xAC,0x55,0xA0,0x62,0x95,0xCE,0 │ 0x41,0x04,0x79,0xBE,0x66,0x7E,0xF9,0xDC,0xBB,0xAC,0x55,0xA0,0x62,0x95,0xCE,0
0x0B,0x07,0x02,0x9B,0xFC,0xDB,0x2D,0xCE,0x28,0xD9,0x59,0xF2,0x81,0x5B,0x16,0 │ 0x0B,0x07,0x02,0x9B,0xFC,0xDB,0x2D,0xCE,0x28,0xD9,0x59,0xF2,0x81,0x5B,0x16,0
0x17,0x98,0x48,0x3A,0xDA,0x77,0x26,0xA3,0xC4,0x65,0x5D,0xA4,0xFB,0xFC,0x0E,0 │ 0x17,0x98,0x48,0x3A,0xDA,0x77,0x26,0xA3,0xC4,0x65,0x5D,0xA4,0xFB,0xFC,0x0E,0
0x08,0xA8,0xFD,0x17,0xB4,0x48,0xA6,0x85,0x54,0x19,0x9C,0x47,0xD0,0x8F,0xFB,0 │ 0x08,0xA8,0xFD,0x17,0xB4,0x48,0xA6,0x85,0x54,0x19,0x9C,0x47,0xD0,0x8F,0xFB,0
0xD4,0xB8,0x02,0x21,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0 │ 0xD4,0xB8,0x02,0x21,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0
0xFF,0xFF,0xFF,0xFF,0xFE,0xBA,0xAE,0xDC,0xE6,0xAF,0x48,0xA0,0x3B,0xBF,0xD2,0 │ 0xFF,0xFF,0xFF,0xFF,0xFE,0xBA,0xAE,0xDC,0xE6,0xAF,0x48,0xA0,0x3B,0xBF,0xD2,0
0x8C,0xD0,0x36,0x41,0x41,0x02,0x01,0x01,0xA1,0x44,0x03,0x42,0x00 │ 0x8C,0xD0,0x36,0x41,0x41,0x02,0x01,0x01,0xA1,0x44,0x03,0x42,0x00
}; │ };
unsigned char *ptr = privkey; │ unsigned char *ptr = seckey;
memcpy(ptr, begin, sizeof(begin)); ptr += sizeof(begin); │ memcpy(ptr, begin, sizeof(begin)); ptr += sizeof(begin);
memcpy(ptr, key32, 32); ptr += 32; │ memcpy(ptr, key32, 32); ptr += 32;
memcpy(ptr, middle, sizeof(middle)); ptr += sizeof(middle); │ memcpy(ptr, middle, sizeof(middle)); ptr += sizeof(middle);
pubkeylen = CPubKey::SIZE; │ pubkeylen = CPubKey::SIZE;
secp256k1_ec_pubkey_serialize(ctx, ptr, &pubkeylen, &pubkey, SECP256K1_EC_UNCOMP │ secp256k1_ec_pubkey_serialize(ctx, ptr, &pubkeylen, &pubkey, SECP256K1_EC_UNCOMP
ptr += pubkeylen; │ ptr += pubkeylen;
*privkeylen = ptr - privkey; │ *seckeylen = ptr - seckey;
│ assert(*seckeylen == CKey::SIZE);
} │ }
return 1; │ return 1;
} │
next prev up dogecoin/src/pubkey.cpp:26 │ bitcoin/src/pubkey.cpp:35
│
size_t rpos, rlen, spos, slen; │ size_t rpos, rlen, spos, slen;
size_t pos = 0; │ size_t pos = 0;
size_t lenbyte; │ size_t lenbyte;
unsigned char tmpsig[64] = {0}; │ unsigned char tmpsig[64] = {0};
int overflow = 0; │ int overflow = 0;
│
/* Hack to initialize sig with a correctly-parsed but invalid signature. */ │ /* Hack to initialize sig with a correctly-parsed but invalid signature. */
secp256k1_ecdsa_signature_parse_compact(ctx, sig, tmpsig); │ secp256k1_ecdsa_signature_parse_compact(ctx, sig, tmpsig);
│
/* Sequence tag byte */ │ /* Sequence tag byte */
if (pos == inputlen || input[pos] != 0x30) { │ if (pos == inputlen || input[pos] != 0x30) {
return 0; │ return 0;
} │ }
pos++; │ pos++;
│
/* Sequence length bytes */ │ /* Sequence length bytes */
if (pos == inputlen) { │ if (pos == inputlen) {
return 0; │ return 0;
} │ }
lenbyte = input[pos++]; │ lenbyte = input[pos++];
if (lenbyte & 0x80) { │ if (lenbyte & 0x80) {
lenbyte -= 0x80; │ lenbyte -= 0x80;
if (pos + lenbyte > inputlen) { │ if (lenbyte > inputlen - pos) {
return 0; │ return 0;
} │ }
pos += lenbyte; │ pos += lenbyte;
} │ }
│
/* Integer tag byte for R */ │ /* Integer tag byte for R */
if (pos == inputlen || input[pos] != 0x02) { │ if (pos == inputlen || input[pos] != 0x02) {
return 0; │ return 0;
} │ }
pos++; │ pos++;
│
/* Integer length for R */ │ /* Integer length for R */
if (pos == inputlen) { │ if (pos == inputlen) {
return 0; │ return 0;
} │ }
lenbyte = input[pos++]; │ lenbyte = input[pos++];
if (lenbyte & 0x80) { │ if (lenbyte & 0x80) {
lenbyte -= 0x80; │ lenbyte -= 0x80;
if (pos + lenbyte > inputlen) { │ if (lenbyte > inputlen - pos) {
return 0; │ return 0;
} │ }
while (lenbyte > 0 && input[pos] == 0) { │ while (lenbyte > 0 && input[pos] == 0) {
pos++; │ pos++;
lenbyte--; │ lenbyte--;
} │ }
if (lenbyte >= sizeof(size_t)) { │ static_assert(sizeof(size_t) >= 4, "size_t too small");
│ if (lenbyte >= 4) {
return 0; │ return 0;
} │ }
rlen = 0; │ rlen = 0;
while (lenbyte > 0) { │ while (lenbyte > 0) {
rlen = (rlen << 8) + input[pos]; │ rlen = (rlen << 8) + input[pos];
pos++; │ pos++;
lenbyte--; │ lenbyte--;
} │ }
} else { │ } else {
rlen = lenbyte; │ rlen = lenbyte;
} │ }
if (rlen > inputlen - pos) { │ if (rlen > inputlen - pos) {
return 0; │ return 0;
} │ }
rpos = pos; │ rpos = pos;
pos += rlen; │ pos += rlen;
│
/* Integer tag byte for S */ │ /* Integer tag byte for S */
if (pos == inputlen || input[pos] != 0x02) { │ if (pos == inputlen || input[pos] != 0x02) {
return 0; │ return 0;
} │ }
pos++; │ pos++;
│
/* Integer length for S */ │ /* Integer length for S */
if (pos == inputlen) { │ if (pos == inputlen) {
return 0; │ return 0;
} │ }
lenbyte = input[pos++]; │ lenbyte = input[pos++];
if (lenbyte & 0x80) { │ if (lenbyte & 0x80) {
lenbyte -= 0x80; │ lenbyte -= 0x80;
if (pos + lenbyte > inputlen) { │ if (lenbyte > inputlen - pos) {
return 0; │ return 0;
} │ }
while (lenbyte > 0 && input[pos] == 0) { │ while (lenbyte > 0 && input[pos] == 0) {
pos++; │ pos++;
lenbyte--; │ lenbyte--;
} │ }
if (lenbyte >= sizeof(size_t)) { │ static_assert(sizeof(size_t) >= 4, "size_t too small");
│ if (lenbyte >= 4) {
return 0; │ return 0;
} │ }
slen = 0; │ slen = 0;
while (lenbyte > 0) { │ while (lenbyte > 0) {
slen = (slen << 8) + input[pos]; │ slen = (slen << 8) + input[pos];
pos++; │ pos++;
lenbyte--; │ lenbyte--;
} │ }
} else { │ } else {
slen = lenbyte; │ slen = lenbyte;
} │ }
if (slen > inputlen - pos) { │ if (slen > inputlen - pos) {
return 0; │ return 0;
} │ }
spos = pos; │ spos = pos;
pos += slen; │
│
/* Ignore leading zeroes in R */ │ /* Ignore leading zeroes in R */
while (rlen > 0 && input[rpos] == 0) { │ while (rlen > 0 && input[rpos] == 0) {
rlen--; │ rlen--;
rpos++; │ rpos++;
} │ }
/* Copy R value */ │ /* Copy R value */
if (rlen > 32) { │ if (rlen > 32) {
overflow = 1; │ overflow = 1;
} else { │ } else {
memcpy(tmpsig + 32 - rlen, input + rpos, rlen); │ memcpy(tmpsig + 32 - rlen, input + rpos, rlen);
} │ }
│
/* Ignore leading zeroes in S */ │ /* Ignore leading zeroes in S */
while (slen > 0 && input[spos] == 0) { │ while (slen > 0 && input[spos] == 0) {
slen--; │ slen--;
spos++; │ spos++;
} │ }
/* Copy S value */ │ /* Copy S value */
if (slen > 32) { │ if (slen > 32) {
overflow = 1; │ overflow = 1;
} else { │ } else {
memcpy(tmpsig + 64 - slen, input + spos, slen); │ memcpy(tmpsig + 64 - slen, input + spos, slen);
} │ }
│
if (!overflow) { │ if (!overflow) {
overflow = !secp256k1_ecdsa_signature_parse_compact(ctx, sig, tmpsig); │ overflow = !secp256k1_ecdsa_signature_parse_compact(ctx, sig, tmpsig);
} │ }
if (overflow) { │ if (overflow) {
/* Overwrite the result again with a correctly-parsed but invalid │ /* Overwrite the result again with a correctly-parsed but invalid
signature if parsing failed. */ │ signature if parsing failed. */
memset(tmpsig, 0, 64); │ memset(tmpsig, 0, 64);
secp256k1_ecdsa_signature_parse_compact(ctx, sig, tmpsig); │ secp256k1_ecdsa_signature_parse_compact(ctx, sig, tmpsig);
} │ }
return 1; │ return 1;
} │
next prev up dogecoin/src/validation.cpp:406 │ bitcoin/src/validation.cpp:194
│
AssertLockHeld(cs_main); │ assert(tip != nullptr);
AssertLockHeld(mempool.cs); │
│
CBlockIndex* tip = chainActive.Tip(); │
CBlockIndex index; │ CBlockIndex index;
index.pprev = tip; │ index.pprev = tip;
// CheckSequenceLocks() uses chainActive.Height()+1 to evaluate │ // CheckSequenceLocksAtTip() uses active_chainstate.m_chain.Height()+1 to evaluate
// height based locks because when SequenceLocks() is called within │ // height based locks because when SequenceLocks() is called within
// ConnectBlock(), the height of the block *being* │ // ConnectBlock(), the height of the block *being*
// evaluated is what is used. │ // evaluated is what is used.
// Thus if we want to know if a transaction can be part of the │ // Thus if we want to know if a transaction can be part of the
// *next* block, we need to use one more than chainActive.Height() │ // *next* block, we need to use one more than active_chainstate.m_chain.Height()
index.nHeight = tip->nHeight + 1; │ index.nHeight = tip->nHeight + 1;
│
std::pair<int, int64_t> lockPair; │ std::pair<int, int64_t> lockPair;
if (useExistingLockPoints) { │ if (useExistingLockPoints) {
assert(lp); │ assert(lp);
lockPair.first = lp->height; │ lockPair.first = lp->height;
lockPair.second = lp->time; │ lockPair.second = lp->time;
} │ }
else { │ else {
// pcoinsTip contains the UTXO set for chainActive.Tip() │
CCoinsViewMemPool viewMemPool(pcoinsTip, mempool); │
std::vector<int> prevheights; │ std::vector<int> prevheights;
prevheights.resize(tx.vin.size()); │ prevheights.resize(tx.vin.size());
for (size_t txinIndex = 0; txinIndex < tx.vin.size(); txinIndex++) { │ for (size_t txinIndex = 0; txinIndex < tx.vin.size(); txinIndex++) {
const CTxIn& txin = tx.vin[txinIndex]; │ const CTxIn& txin = tx.vin[txinIndex];
CCoins coins; │ Coin coin;
if (!viewMemPool.GetCoins(txin.prevout.hash, coins)) { │ if (!coins_view.GetCoin(txin.prevout, coin)) {
return error("%s: Missing input", __func__); │ return error("%s: Missing input", __func__);
} │ }
if (coins.nHeight == MEMPOOL_HEIGHT) { │ if (coin.nHeight == MEMPOOL_HEIGHT) {
// Assume all mempool transaction confirm in the next block │ // Assume all mempool transaction confirm in the next block
prevheights[txinIndex] = tip->nHeight + 1; │ prevheights[txinIndex] = tip->nHeight + 1;
} else { │ } else {
prevheights[txinIndex] = coins.nHeight; │ prevheights[txinIndex] = coin.nHeight;
} │ }
} │ }
lockPair = CalculateSequenceLocks(tx, flags, &prevheights, index); │ lockPair = CalculateSequenceLocks(tx, STANDARD_LOCKTIME_VERIFY_FLAGS, prevheight
if (lp) { │ if (lp) {
lp->height = lockPair.first; │ lp->height = lockPair.first;
lp->time = lockPair.second; │ lp->time = lockPair.second;
// Also store the hash of the block with the highest height of │ // Also store the hash of the block with the highest height of
// all the blocks which have sequence locked prevouts. │ // all the blocks which have sequence locked prevouts.
// This hash needs to still be on the chain │ // This hash needs to still be on the chain
// for these LockPoint calculations to be valid │ // for these LockPoint calculations to be valid
// Note: It is impossible to correctly calculate a maxInputBlock │ // Note: It is impossible to correctly calculate a maxInputBlock
// if any of the sequence locked inputs depend on unconfirmed txs, │ // if any of the sequence locked inputs depend on unconfirmed txs,
// except in the special case where the relative lock time/height │ // except in the special case where the relative lock time/height
// is 0, which is equivalent to no sequence lock. Since we assume │ // is 0, which is equivalent to no sequence lock. Since we assume
// input height of tip+1 for mempool txs and test the resulting │ // input height of tip+1 for mempool txs and test the resulting
// lockPair from CalculateSequenceLocks against tip+1. We know │ // lockPair from CalculateSequenceLocks against tip+1. We know
// EvaluateSequenceLocks will fail if there was a non-zero sequence │ // EvaluateSequenceLocks will fail if there was a non-zero sequence
// lock on a mempool input, so we can use the return value of │ // lock on a mempool input, so we can use the return value of
// CheckSequenceLocks to indicate the LockPoints validity │ // CheckSequenceLocksAtTip to indicate the LockPoints validity
int maxInputHeight = 0; │ int maxInputHeight = 0;
BOOST_FOREACH(int height, prevheights) { │ for (const int height : prevheights) {
// Can ignore mempool inputs since we'll fail if they had non-zero locks │ // Can ignore mempool inputs since we'll fail if they had non-zero locks
if (height != tip->nHeight+1) { │ if (height != tip->nHeight+1) {
maxInputHeight = std::max(maxInputHeight, height); │ maxInputHeight = std::max(maxInputHeight, height);
} │ }
} │ }
lp->maxInputBlock = tip->GetAncestor(maxInputHeight); │ // tip->GetAncestor(maxInputHeight) should never return a nullptr
│ // because maxInputHeight is always less than the tip height.
│ // It would, however, be a bad bug to continue execution, since a
│ // LockPoints object with the maxInputBlock member set to nullptr
│ // signifies no relative lock time.
│ lp->maxInputBlock = Assert(tip->GetAncestor(maxInputHeight));
} │ }
} │ }
return EvaluateSequenceLocks(index, lockPair); │ return EvaluateSequenceLocks(index, lockPair);
} │
next prev up dogecoin/src/test/cuckoocache_tests.cpp:213 │ bitcoin/src/test/cuckoocache_tests.cpp:188
│
double load = 1; │ double load = 1;
insecure_rand = FastRandomContext(true); │ SeedInsecureRand(SeedRand::ZEROS);
std::vector<uint256> hashes; │ std::vector<uint256> hashes;
Cache set{}; │ Cache set{};
size_t bytes = megabytes * (1 << 20); │ size_t bytes = megabytes * (1 << 20);
set.setup_bytes(bytes); │ set.setup_bytes(bytes);
uint32_t n_insert = static_cast<uint32_t>(load * (bytes / sizeof(uint256))); │ uint32_t n_insert = static_cast<uint32_t>(load * (bytes / sizeof(uint256)));
hashes.resize(n_insert); │ hashes.resize(n_insert);
for (uint32_t i = 0; i < n_insert; ++i) { │ for (uint32_t i = 0; i < n_insert; ++i) {
uint32_t* ptr = (uint32_t*)hashes[i].begin(); │ uint32_t* ptr = (uint32_t*)hashes[i].begin();
for (uint8_t j = 0; j < 8; ++j) │ for (uint8_t j = 0; j < 8; ++j)
*(ptr++) = insecure_rand.rand32(); │ *(ptr++) = InsecureRand32();
} │ }
/** We make a copy of the hashes because future optimizations of the │ /** We make a copy of the hashes because future optimizations of the
* cuckoocache may overwrite the inserted element, so the test is │ * cuckoocache may overwrite the inserted element, so the test is
* "future proofed". │ * "future proofed".
*/ │ */
std::vector<uint256> hashes_insert_copy = hashes; │ std::vector<uint256> hashes_insert_copy = hashes;
boost::shared_mutex mtx; │ std::shared_mutex mtx;
│
{ │ {
/** Grab lock to make sure we release inserts */ │ /** Grab lock to make sure we release inserts */
boost::unique_lock<boost::shared_mutex> l(mtx); │ std::unique_lock<std::shared_mutex> l(mtx);
/** Insert the first half */ │ /** Insert the first half */
for (uint32_t i = 0; i < (n_insert / 2); ++i) │ for (uint32_t i = 0; i < (n_insert / 2); ++i)
set.insert(hashes_insert_copy[i]); │ set.insert(hashes_insert_copy[i]);
} │ }
│
/** Spin up 3 threads to run contains with erase. │ /** Spin up 3 threads to run contains with erase.
*/ │ */
std::vector<std::thread> threads; │ std::vector<std::thread> threads;
/** Erase the first quarter */ │ /** Erase the first quarter */
for (uint32_t x = 0; x < 3; ++x) │ for (uint32_t x = 0; x < 3; ++x)
/** Each thread is emplaced with x copy-by-value │ /** Each thread is emplaced with x copy-by-value
*/ │ */
threads.emplace_back([&, x] { │ threads.emplace_back([&, x] {
boost::shared_lock<boost::shared_mutex> l(mtx); │ std::shared_lock<std::shared_mutex> l(mtx);
size_t ntodo = (n_insert/4)/3; │ size_t ntodo = (n_insert/4)/3;
size_t start = ntodo*x; │ size_t start = ntodo*x;
size_t end = ntodo*(x+1); │ size_t end = ntodo*(x+1);
for (uint32_t i = start; i < end; ++i) │ for (uint32_t i = start; i < end; ++i) {
set.contains(hashes[i], true); │ bool contains = set.contains(hashes[i], true);
│ assert(contains);
│ }
}); │ });
│
/** Wait for all threads to finish │ /** Wait for all threads to finish
*/ │ */
for (std::thread& t : threads) │ for (std::thread& t : threads)
t.join(); │ t.join();
/** Grab lock to make sure we observe erases */ │ /** Grab lock to make sure we observe erases */
boost::unique_lock<boost::shared_mutex> l(mtx); │ std::unique_lock<std::shared_mutex> l(mtx);
/** Insert the second half */ │ /** Insert the second half */
for (uint32_t i = (n_insert / 2); i < n_insert; ++i) │ for (uint32_t i = (n_insert / 2); i < n_insert; ++i)
set.insert(hashes_insert_copy[i]); │ set.insert(hashes_insert_copy[i]);
│
/** elements that we marked erased but that are still there */ │ /** elements that we marked erased but that are still there */
size_t count_erased_but_contained = 0; │ size_t count_erased_but_contained = 0;
/** elements that we did not erase but are older */ │ /** elements that we did not erase but are older */
size_t count_stale = 0; │ size_t count_stale = 0;
/** elements that were most recently inserted */ │ /** elements that were most recently inserted */
size_t count_fresh = 0; │ size_t count_fresh = 0;
│
for (uint32_t i = 0; i < (n_insert / 4); ++i) │ for (uint32_t i = 0; i < (n_insert / 4); ++i)
count_erased_but_contained += set.contains(hashes[i], false); │ count_erased_but_contained += set.contains(hashes[i], false);
for (uint32_t i = (n_insert / 4); i < (n_insert / 2); ++i) │ for (uint32_t i = (n_insert / 4); i < (n_insert / 2); ++i)
count_stale += set.contains(hashes[i], false); │ count_stale += set.contains(hashes[i], false);
for (uint32_t i = (n_insert / 2); i < n_insert; ++i) │ for (uint32_t i = (n_insert / 2); i < n_insert; ++i)
count_fresh += set.contains(hashes[i], false); │ count_fresh += set.contains(hashes[i], false);
│
double hit_rate_erased_but_contained = double(count_erased_but_contained) / (double( │ double hit_rate_erased_but_contained = double(count_erased_but_contained) / (double(
double hit_rate_stale = double(count_stale) / (double(n_insert) / 4.0); │ double hit_rate_stale = double(count_stale) / (double(n_insert) / 4.0);
double hit_rate_fresh = double(count_fresh) / (double(n_insert) / 2.0); │ double hit_rate_fresh = double(count_fresh) / (double(n_insert) / 2.0);
│
// Check that our hit_rate_fresh is perfect │ // Check that our hit_rate_fresh is perfect
BOOST_CHECK_EQUAL(hit_rate_fresh, 1.0); │ BOOST_CHECK_EQUAL(hit_rate_fresh, 1.0);
// Check that we have a more than 2x better hit rate on stale elements than │ // Check that we have a more than 2x better hit rate on stale elements than
// erased elements. │ // erased elements.
BOOST_CHECK(hit_rate_stale > 2 * hit_rate_erased_but_contained); │ BOOST_CHECK(hit_rate_stale > 2 * hit_rate_erased_but_contained);
} │
next prev up dogecoin/src/test/util_tests.cpp:466 │ bitcoin/src/test/util_tests.cpp:1958
│
BOOST_CHECK_EQUAL(FormatParagraph("", 79, 0), ""); │ BOOST_CHECK_EQUAL(FormatParagraph("", 79, 0), "");
BOOST_CHECK_EQUAL(FormatParagraph("test", 79, 0), "test"); │ BOOST_CHECK_EQUAL(FormatParagraph("test", 79, 0), "test");
BOOST_CHECK_EQUAL(FormatParagraph(" test", 79, 0), " test"); │ BOOST_CHECK_EQUAL(FormatParagraph(" test", 79, 0), " test");
BOOST_CHECK_EQUAL(FormatParagraph("test test", 79, 0), "test test"); │ BOOST_CHECK_EQUAL(FormatParagraph("test test", 79, 0), "test test");
BOOST_CHECK_EQUAL(FormatParagraph("test test", 4, 0), "test\ntest"); │ BOOST_CHECK_EQUAL(FormatParagraph("test test", 4, 0), "test\ntest");
BOOST_CHECK_EQUAL(FormatParagraph("testerde test", 4, 0), "testerde\ntest"); │ BOOST_CHECK_EQUAL(FormatParagraph("testerde test", 4, 0), "testerde\ntest");
BOOST_CHECK_EQUAL(FormatParagraph("test test", 4, 4), "test\n test"); │ BOOST_CHECK_EQUAL(FormatParagraph("test test", 4, 4), "test\n test");
│
// Make sure we don't indent a fully-new line following a too-long line ending │ // Make sure we don't indent a fully-new line following a too-long line ending
BOOST_CHECK_EQUAL(FormatParagraph("test test\nabc", 4, 4), "test\n test\nabc"); │ BOOST_CHECK_EQUAL(FormatParagraph("test test\nabc", 4, 4), "test\n test\nabc");
│
BOOST_CHECK_EQUAL(FormatParagraph("This_is_a_very_long_test_string_without_any_space │ BOOST_CHECK_EQUAL(FormatParagraph("This_is_a_very_long_test_string_without_any_space
│
// Test wrap length is exact │ // Test wrap length is exact
BOOST_CHECK_EQUAL(FormatParagraph("a b c d e f g h i j k l m n o p q r s t u v w x y │ BOOST_CHECK_EQUAL(FormatParagraph("a b c d e f g h i j k l m n o p q r s t u v w x y
BOOST_CHECK_EQUAL(FormatParagraph("x\na b c d e f g h i j k l m n o p q r s t u v w │ BOOST_CHECK_EQUAL(FormatParagraph("x\na b c d e f g h i j k l m n o p q r s t u v w
// Indent should be included in length of lines │ // Indent should be included in length of lines
BOOST_CHECK_EQUAL(FormatParagraph("x\na b c d e f g h i j k l m n o p q r s t u v w │ BOOST_CHECK_EQUAL(FormatParagraph("x\na b c d e f g h i j k l m n o p q r s t u v w
│
BOOST_CHECK_EQUAL(FormatParagraph("This is a very long test string. This is a second │ BOOST_CHECK_EQUAL(FormatParagraph("This is a very long test string. This is a second
BOOST_CHECK_EQUAL(FormatParagraph("This is a very long test string.\nThis is a secon │ BOOST_CHECK_EQUAL(FormatParagraph("This is a very long test string.\nThis is a secon
BOOST_CHECK_EQUAL(FormatParagraph("This is a very long test string.\n\nThis is a sec │ BOOST_CHECK_EQUAL(FormatParagraph("This is a very long test string.\n\nThis is a sec
BOOST_CHECK_EQUAL(FormatParagraph("Testing that normal newlines do not get indented. │ BOOST_CHECK_EQUAL(FormatParagraph("Testing that normal newlines do not get indented.
} │
next prev up bitcoin/src/test/pmt_tests.cpp:31 │ dogecoin/src/test/pmt_tests.cpp:34
│
│ seed_insecure_rand(false);
static const unsigned int nTxCounts[] = {1, 4, 7, 17, 56, 100, 127, 256, 312, 513, 1 │ static const unsigned int nTxCounts[] = {1, 4, 7, 17, 56, 100, 127, 256, 312, 513, 1
│
for (int i = 0; i < 12; i++) { │ for (int i = 0; i < 12; i++) {
unsigned int nTx = nTxCounts[i]; │ unsigned int nTx = nTxCounts[i];
│
// build a block with some dummy transactions │ // build a block with some dummy transactions
CBlock block; │ CBlock block;
for (unsigned int j=0; j<nTx; j++) { │ for (unsigned int j=0; j<nTx; j++) {
CMutableTransaction tx; │ CMutableTransaction tx;
tx.nLockTime = j; // actual transaction data doesn't matter; just make the n │ tx.nLockTime = j; // actual transaction data doesn't matter; just make the n
block.vtx.push_back(MakeTransactionRef(std::move(tx))); │ block.vtx.push_back(MakeTransactionRef(std::move(tx)));
} │ }
│
// calculate actual merkle root and height │ // calculate actual merkle root and height
uint256 merkleRoot1 = BlockMerkleRoot(block); │ uint256 merkleRoot1 = BlockMerkleRoot(block);
std::vector<uint256> vTxid(nTx, uint256()); │ std::vector<uint256> vTxid(nTx, uint256());
for (unsigned int j=0; j<nTx; j++) │ for (unsigned int j=0; j<nTx; j++)
vTxid[j] = block.vtx[j]->GetHash(); │ vTxid[j] = block.vtx[j]->GetHash();
int nHeight = 1, nTx_ = nTx; │ int nHeight = 1, nTx_ = nTx;
while (nTx_ > 1) { │ while (nTx_ > 1) {
nTx_ = (nTx_+1)/2; │ nTx_ = (nTx_+1)/2;
nHeight++; │ nHeight++;
} │ }
│
// check with random subsets with inclusion chances 1, 1/2, 1/4, ..., 1/128 │ // check with random subsets with inclusion chances 1, 1/2, 1/4, ..., 1/128
for (int att = 1; att < 15; att++) { │ for (int att = 1; att < 15; att++) {
// build random subset of txid's │ // build random subset of txid's
std::vector<bool> vMatch(nTx, false); │ std::vector<bool> vMatch(nTx, false);
std::vector<uint256> vMatchTxid1; │ std::vector<uint256> vMatchTxid1;
for (unsigned int j=0; j<nTx; j++) { │ for (unsigned int j=0; j<nTx; j++) {
bool fInclude = InsecureRandBits(att / 2) == 0; │ bool fInclude = (insecure_rand() & ((1 << (att/2)) - 1)) == 0;
vMatch[j] = fInclude; │ vMatch[j] = fInclude;
if (fInclude) │ if (fInclude)
vMatchTxid1.push_back(vTxid[j]); │ vMatchTxid1.push_back(vTxid[j]);
} │ }
│
// build the partial merkle tree │ // build the partial merkle tree
CPartialMerkleTree pmt1(vTxid, vMatch); │ CPartialMerkleTree pmt1(vTxid, vMatch);
│
// serialize │ // serialize
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); │ CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
ss << pmt1; │ ss << pmt1;
│
// verify CPartialMerkleTree's size guarantees │ // verify CPartialMerkleTree's size guarantees
unsigned int n = std::min<unsigned int>(nTx, 1 + vMatchTxid1.size()*nHeight) │ unsigned int n = std::min<unsigned int>(nTx, 1 + vMatchTxid1.size()*nHeight)
BOOST_CHECK(ss.size() <= 10 + (258*n+7)/8); │ BOOST_CHECK(ss.size() <= 10 + (258*n+7)/8);
│
// deserialize into a tester copy │ // deserialize into a tester copy
CPartialMerkleTreeTester pmt2; │ CPartialMerkleTreeTester pmt2;
ss >> pmt2; │ ss >> pmt2;
│
// extract merkle root and matched txids from copy │ // extract merkle root and matched txids from copy
std::vector<uint256> vMatchTxid2; │ std::vector<uint256> vMatchTxid2;
std::vector<unsigned int> vIndex; │ std::vector<unsigned int> vIndex;
uint256 merkleRoot2 = pmt2.ExtractMatches(vMatchTxid2, vIndex); │ uint256 merkleRoot2 = pmt2.ExtractMatches(vMatchTxid2, vIndex);
│
// check that it has the same merkle root as the original, and a valid one │ // check that it has the same merkle root as the original, and a valid one
BOOST_CHECK(merkleRoot1 == merkleRoot2); │ BOOST_CHECK(merkleRoot1 == merkleRoot2);
BOOST_CHECK(!merkleRoot2.IsNull()); │ BOOST_CHECK(!merkleRoot2.IsNull());
│
// check that it contains the matched transactions (in the same order!) │ // check that it contains the matched transactions (in the same order!)
BOOST_CHECK(vMatchTxid1 == vMatchTxid2); │ BOOST_CHECK(vMatchTxid1 == vMatchTxid2);
│
// check that random bit flips break the authentication │ // check that random bit flips break the authentication
for (int j=0; j<4; j++) { │ for (int j=0; j<4; j++) {
CPartialMerkleTreeTester pmt3(pmt2); │ CPartialMerkleTreeTester pmt3(pmt2);
pmt3.Damage(); │ pmt3.Damage();
std::vector<uint256> vMatchTxid3; │ std::vector<uint256> vMatchTxid3;
uint256 merkleRoot3 = pmt3.ExtractMatches(vMatchTxid3, vIndex); │ uint256 merkleRoot3 = pmt3.ExtractMatches(vMatchTxid3, vIndex);
BOOST_CHECK(merkleRoot3 != merkleRoot1); │ BOOST_CHECK(merkleRoot3 != merkleRoot1);
} │ }
} │ }
} │ }
} │
next prev up dogecoin/src/test/script_tests.cpp:1300 │ bitcoin/src/test/script_tests.cpp:1316
│
BOOST_CHECK_EQUAL("OP_CHECKLOCKTIMEVERIFY", ScriptToAsmStr(CScript() << OP_NOP2, tru │ BOOST_CHECK_EQUAL("OP_CHECKLOCKTIMEVERIFY", ScriptToAsmStr(CScript() << OP_NOP2, tru
BOOST_CHECK_EQUAL("OP_CHECKLOCKTIMEVERIFY", ScriptToAsmStr(CScript() << OP_CHECKLOCK │ BOOST_CHECK_EQUAL("OP_CHECKLOCKTIMEVERIFY", ScriptToAsmStr(CScript() << OP_CHECKLOCK
BOOST_CHECK_EQUAL("OP_CHECKLOCKTIMEVERIFY", ScriptToAsmStr(CScript() << OP_NOP2)); │ BOOST_CHECK_EQUAL("OP_CHECKLOCKTIMEVERIFY", ScriptToAsmStr(CScript() << OP_NOP2));
BOOST_CHECK_EQUAL("OP_CHECKLOCKTIMEVERIFY", ScriptToAsmStr(CScript() << OP_CHECKLOCK │ BOOST_CHECK_EQUAL("OP_CHECKLOCKTIMEVERIFY", ScriptToAsmStr(CScript() << OP_CHECKLOCK
│
std::string derSig("304502207fa7a6d1e0ee81132a269ad84e68d695483745cde8b541e3bf630749 │ std::string derSig("304502207fa7a6d1e0ee81132a269ad84e68d695483745cde8b541e3bf630749
std::string pubKey("03b0da749730dc9b4b1f4a14d6902877a92541f5368778853d9c4a0cb7802dcf │ std::string pubKey("03b0da749730dc9b4b1f4a14d6902877a92541f5368778853d9c4a0cb7802dcf
std::vector<unsigned char> vchPubKey = ToByteVector(ParseHex(pubKey)); │ std::vector<unsigned char> vchPubKey = ToByteVector(ParseHex(pubKey));
│
BOOST_CHECK_EQUAL(derSig + "00 " + pubKey, ScriptToAsmStr(CScript() << ToByteVector( │ BOOST_CHECK_EQUAL(derSig + "00 " + pubKey, ScriptToAsmStr(CScript() << ToByteVector(
BOOST_CHECK_EQUAL(derSig + "80 " + pubKey, ScriptToAsmStr(CScript() << ToByteVector( │ BOOST_CHECK_EQUAL(derSig + "80 " + pubKey, ScriptToAsmStr(CScript() << ToByteVector(
BOOST_CHECK_EQUAL(derSig + "[ALL] " + pubKey, ScriptToAsmStr(CScript() << ToByteVect │ BOOST_CHECK_EQUAL(derSig + "[ALL] " + pubKey, ScriptToAsmStr(CScript() << ToByteVect
BOOST_CHECK_EQUAL(derSig + "[NONE] " + pubKey, ScriptToAsmStr(CScript() << ToByteVec │ BOOST_CHECK_EQUAL(derSig + "[NONE] " + pubKey, ScriptToAsmStr(CScript() << ToByteVec
BOOST_CHECK_EQUAL(derSig + "[SINGLE] " + pubKey, ScriptToAsmStr(CScript() << ToByteV │ BOOST_CHECK_EQUAL(derSig + "[SINGLE] " + pubKey, ScriptToAsmStr(CScript() << ToByteV
BOOST_CHECK_EQUAL(derSig + "[ALL|ANYONECANPAY] " + pubKey, ScriptToAsmStr(CScript() │ BOOST_CHECK_EQUAL(derSig + "[ALL|ANYONECANPAY] " + pubKey, ScriptToAsmStr(CScript()
BOOST_CHECK_EQUAL(derSig + "[NONE|ANYONECANPAY] " + pubKey, ScriptToAsmStr(CScript() │ BOOST_CHECK_EQUAL(derSig + "[NONE|ANYONECANPAY] " + pubKey, ScriptToAsmStr(CScript()
BOOST_CHECK_EQUAL(derSig + "[SINGLE|ANYONECANPAY] " + pubKey, ScriptToAsmStr(CScript │ BOOST_CHECK_EQUAL(derSig + "[SINGLE|ANYONECANPAY] " + pubKey, ScriptToAsmStr(CScript
│
BOOST_CHECK_EQUAL(derSig + "00 " + pubKey, ScriptToAsmStr(CScript() << ToByteVector( │ BOOST_CHECK_EQUAL(derSig + "00 " + pubKey, ScriptToAsmStr(CScript() << ToByteVector(
BOOST_CHECK_EQUAL(derSig + "80 " + pubKey, ScriptToAsmStr(CScript() << ToByteVector( │ BOOST_CHECK_EQUAL(derSig + "80 " + pubKey, ScriptToAsmStr(CScript() << ToByteVector(
BOOST_CHECK_EQUAL(derSig + "01 " + pubKey, ScriptToAsmStr(CScript() << ToByteVector( │ BOOST_CHECK_EQUAL(derSig + "01 " + pubKey, ScriptToAsmStr(CScript() << ToByteVector(
BOOST_CHECK_EQUAL(derSig + "02 " + pubKey, ScriptToAsmStr(CScript() << ToByteVector( │ BOOST_CHECK_EQUAL(derSig + "02 " + pubKey, ScriptToAsmStr(CScript() << ToByteVector(
BOOST_CHECK_EQUAL(derSig + "03 " + pubKey, ScriptToAsmStr(CScript() << ToByteVector( │ BOOST_CHECK_EQUAL(derSig + "03 " + pubKey, ScriptToAsmStr(CScript() << ToByteVector(
BOOST_CHECK_EQUAL(derSig + "81 " + pubKey, ScriptToAsmStr(CScript() << ToByteVector( │ BOOST_CHECK_EQUAL(derSig + "81 " + pubKey, ScriptToAsmStr(CScript() << ToByteVector(
BOOST_CHECK_EQUAL(derSig + "82 " + pubKey, ScriptToAsmStr(CScript() << ToByteVector( │ BOOST_CHECK_EQUAL(derSig + "82 " + pubKey, ScriptToAsmStr(CScript() << ToByteVector(
BOOST_CHECK_EQUAL(derSig + "83 " + pubKey, ScriptToAsmStr(CScript() << ToByteVector( │ BOOST_CHECK_EQUAL(derSig + "83 " + pubKey, ScriptToAsmStr(CScript() << ToByteVector(
} │
next prev up bitcoin/src/test/script_p2sh_tests.cpp:51 │ dogecoin/src/test/script_P2SH_tests.cpp:51
│
LOCK(cs_main); │ LOCK(cs_main);
// Pay-to-script-hash looks like this: │ // Pay-to-script-hash looks like this:
// scriptSig: <sig> <sig...> <serialized_script> │ // scriptSig: <sig> <sig...> <serialized_script>
// scriptPubKey: HASH160 <hash> EQUAL │ // scriptPubKey: HASH160 <hash> EQUAL
│
// Test SignSignature() (and therefore the version of Solver() that signs transactio │ // Test SignSignature() (and therefore the version of Solver() that signs transactio
FillableSigningProvider keystore; │ CBasicKeyStore keystore;
CKey key[4]; │ CKey key[4];
for (int i = 0; i < 4; i++) │ for (int i = 0; i < 4; i++)
{ │ {
key[i].MakeNewKey(true); │ key[i].MakeNewKey(true);
BOOST_CHECK(keystore.AddKey(key[i])); │ keystore.AddKey(key[i]);
} │ }
│
// 8 Scripts: checking all combinations of │ // 8 Scripts: checking all combinations of
// different keys, straight/P2SH, pubkey/pubkeyhash │ // different keys, straight/P2SH, pubkey/pubkeyhash
CScript standardScripts[4]; │ CScript standardScripts[4];
standardScripts[0] << ToByteVector(key[0].GetPubKey()) << OP_CHECKSIG; │ standardScripts[0] << ToByteVector(key[0].GetPubKey()) << OP_CHECKSIG;
standardScripts[1] = GetScriptForDestination(PKHash(key[1].GetPubKey())); │ standardScripts[1] = GetScriptForDestination(key[1].GetPubKey().GetID());
standardScripts[2] << ToByteVector(key[1].GetPubKey()) << OP_CHECKSIG; │ standardScripts[2] << ToByteVector(key[1].GetPubKey()) << OP_CHECKSIG;
standardScripts[3] = GetScriptForDestination(PKHash(key[2].GetPubKey())); │ standardScripts[3] = GetScriptForDestination(key[2].GetPubKey().GetID());
CScript evalScripts[4]; │ CScript evalScripts[4];
for (int i = 0; i < 4; i++) │ for (int i = 0; i < 4; i++)
{ │ {
BOOST_CHECK(keystore.AddCScript(standardScripts[i])); │ keystore.AddCScript(standardScripts[i]);
evalScripts[i] = GetScriptForDestination(ScriptHash(standardScripts[i])); │ evalScripts[i] = GetScriptForDestination(CScriptID(standardScripts[i]));
} │ }
│
CMutableTransaction txFrom; // Funding transaction: │ CMutableTransaction txFrom; // Funding transaction:
std::string reason; │ std::string reason;
txFrom.vout.resize(8); │ txFrom.vout.resize(8);
for (int i = 0; i < 4; i++) │ for (int i = 0; i < 4; i++)
{ │ {
txFrom.vout[i].scriptPubKey = evalScripts[i]; │ txFrom.vout[i].scriptPubKey = evalScripts[i];
txFrom.vout[i].nValue = COIN; │ txFrom.vout[i].nValue = COIN;
txFrom.vout[i+4].scriptPubKey = standardScripts[i]; │ txFrom.vout[i+4].scriptPubKey = standardScripts[i];
txFrom.vout[i+4].nValue = COIN; │ txFrom.vout[i+4].nValue = COIN;
} │ }
BOOST_CHECK(IsStandardTx(CTransaction(txFrom), reason)); │ BOOST_CHECK(IsStandardTx(txFrom, reason));
│
CMutableTransaction txTo[8]; // Spending transactions │ CMutableTransaction txTo[8]; // Spending transactions
for (int i = 0; i < 8; i++) │ for (int i = 0; i < 8; i++)
{ │ {
txTo[i].vin.resize(1); │ txTo[i].vin.resize(1);
txTo[i].vout.resize(1); │ txTo[i].vout.resize(1);
txTo[i].vin[0].prevout.n = i; │ txTo[i].vin[0].prevout.n = i;
txTo[i].vin[0].prevout.hash = txFrom.GetHash(); │ txTo[i].vin[0].prevout.hash = txFrom.GetHash();
txTo[i].vout[0].nValue = 1; │ txTo[i].vout[0].nValue = 1;
│ BOOST_CHECK_MESSAGE(IsMine(keystore, txFrom.vout[i].scriptPubKey), strprintf("Is
} │ }
for (int i = 0; i < 8; i++) │ for (int i = 0; i < 8; i++)
{ │ {
BOOST_CHECK_MESSAGE(SignSignature(keystore, CTransaction(txFrom), txTo[i], 0, SI │ BOOST_CHECK_MESSAGE(SignSignature(keystore, txFrom, txTo[i], 0, SIGHASH_ALL), st
} │ }
// All of the above should be OK, and the txTos have valid signatures │ // All of the above should be OK, and the txTos have valid signatures
// Check to make sure signature verification fails if we use the wrong ScriptSig: │ // Check to make sure signature verification fails if we use the wrong ScriptSig:
for (int i = 0; i < 8; i++) { │ for (int i = 0; i < 8; i++) {
PrecomputedTransactionData txdata(txTo[i]); │ PrecomputedTransactionData txdata(txTo[i]);
for (int j = 0; j < 8; j++) │ for (int j = 0; j < 8; j++)
{ │ {
CScript sigSave = txTo[i].vin[0].scriptSig; │ CScript sigSave = txTo[i].vin[0].scriptSig;
txTo[i].vin[0].scriptSig = txTo[j].vin[0].scriptSig; │ txTo[i].vin[0].scriptSig = txTo[j].vin[0].scriptSig;
bool sigOK = CScriptCheck(txFrom.vout[txTo[i].vin[0].prevout.n], CTransactio │ bool sigOK = CScriptCheck(CCoins(txFrom, 0), txTo[i], 0, SCRIPT_VERIFY_P2SH
if (i == j) │ if (i == j)
BOOST_CHECK_MESSAGE(sigOK, strprintf("VerifySignature %d %d", i, j)); │ BOOST_CHECK_MESSAGE(sigOK, strprintf("VerifySignature %d %d", i, j));
else │ else
BOOST_CHECK_MESSAGE(!sigOK, strprintf("VerifySignature %d %d", i, j)); │ BOOST_CHECK_MESSAGE(!sigOK, strprintf("VerifySignature %d %d", i, j));
txTo[i].vin[0].scriptSig = sigSave; │ txTo[i].vin[0].scriptSig = sigSave;
} │ }
} │ }
} │
next prev up dogecoin/src/validation.cpp:311 │ bitcoin/src/consensus/tx_verify.cpp:40
│
assert(prevHeights->size() == tx.vin.size()); │ assert(prevHeights.size() == tx.vin.size());
│
// Will be set to the equivalent height- and time-based nLockTime │ // Will be set to the equivalent height- and time-based nLockTime
// values that would be necessary to satisfy all relative lock- │ // values that would be necessary to satisfy all relative lock-
// time constraints given our view of block chain history. │ // time constraints given our view of block chain history.
// The semantics of nLockTime are the last invalid height/time, so │ // The semantics of nLockTime are the last invalid height/time, so
// use -1 to have the effect of any height or time being valid. │ // use -1 to have the effect of any height or time being valid.
int nMinHeight = -1; │ int nMinHeight = -1;
int64_t nMinTime = -1; │ int64_t nMinTime = -1;
│
// tx.nVersion is signed integer so requires cast to unsigned otherwise │ // tx.nVersion is signed integer so requires cast to unsigned otherwise
// we would be doing a signed comparison and half the range of nVersion │ // we would be doing a signed comparison and half the range of nVersion
// wouldn't support BIP 68. │ // wouldn't support BIP 68.
bool fEnforceBIP68 = static_cast<uint32_t>(tx.nVersion) >= 2 │ bool fEnforceBIP68 = static_cast<uint32_t>(tx.nVersion) >= 2
&& flags & LOCKTIME_VERIFY_SEQUENCE; │ && flags & LOCKTIME_VERIFY_SEQUENCE;
│
// Do not enforce sequence numbers as a relative lock time │ // Do not enforce sequence numbers as a relative lock time
// unless we have been instructed to │ // unless we have been instructed to
if (!fEnforceBIP68) { │ if (!fEnforceBIP68) {
return std::make_pair(nMinHeight, nMinTime); │ return std::make_pair(nMinHeight, nMinTime);
} │ }
│
for (size_t txinIndex = 0; txinIndex < tx.vin.size(); txinIndex++) { │ for (size_t txinIndex = 0; txinIndex < tx.vin.size(); txinIndex++) {
const CTxIn& txin = tx.vin[txinIndex]; │ const CTxIn& txin = tx.vin[txinIndex];
│
// Sequence numbers with the most significant bit set are not │ // Sequence numbers with the most significant bit set are not
// treated as relative lock-times, nor are they given any │ // treated as relative lock-times, nor are they given any
// consensus-enforced meaning at this point. │ // consensus-enforced meaning at this point.
if (txin.nSequence & CTxIn::SEQUENCE_LOCKTIME_DISABLE_FLAG) { │ if (txin.nSequence & CTxIn::SEQUENCE_LOCKTIME_DISABLE_FLAG) {
// The height of this input is not relevant for sequence locks │ // The height of this input is not relevant for sequence locks
(*prevHeights)[txinIndex] = 0; │ prevHeights[txinIndex] = 0;
continue; │ continue;
} │ }
│
int nCoinHeight = (*prevHeights)[txinIndex]; │ int nCoinHeight = prevHeights[txinIndex];
│
if (txin.nSequence & CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG) { │ if (txin.nSequence & CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG) {
int64_t nCoinTime = block.GetAncestor(std::max(nCoinHeight-1, 0))->GetMedian │ const int64_t nCoinTime{Assert(block.GetAncestor(std::max(nCoinHeight - 1, 0
// NOTE: Subtract 1 to maintain nLockTime semantics │ // NOTE: Subtract 1 to maintain nLockTime semantics
// BIP 68 relative lock times have the semantics of calculating │ // BIP 68 relative lock times have the semantics of calculating
// the first block or time at which the transaction would be │ // the first block or time at which the transaction would be
// valid. When calculating the effective block time or height │ // valid. When calculating the effective block time or height
// for the entire transaction, we switch to using the │ // for the entire transaction, we switch to using the
// semantics of nLockTime which is the last invalid block │ // semantics of nLockTime which is the last invalid block
// time or height. Thus we subtract 1 from the calculated │ // time or height. Thus we subtract 1 from the calculated
// time or height. │ // time or height.
│
// Time-based relative lock-times are measured from the │ // Time-based relative lock-times are measured from the
// smallest allowed timestamp of the block containing the │ // smallest allowed timestamp of the block containing the
// txout being spent, which is the median time past of the │ // txout being spent, which is the median time past of the
// block prior. │ // block prior.
nMinTime = std::max(nMinTime, nCoinTime + (int64_t)((txin.nSequence & CTxIn: │ nMinTime = std::max(nMinTime, nCoinTime + (int64_t)((txin.nSequence & CTxIn:
} else { │ } else {
nMinHeight = std::max(nMinHeight, nCoinHeight + (int)(txin.nSequence & CTxIn │ nMinHeight = std::max(nMinHeight, nCoinHeight + (int)(txin.nSequence & CTxIn
} │ }
} │ }
│
return std::make_pair(nMinHeight, nMinTime); │ return std::make_pair(nMinHeight, nMinTime);
} │
next prev up bitcoin/src/qt/modaloverlay.cpp:91 │ dogecoin/src/qt/modaloverlay.cpp:78
│
QDateTime currentDate = QDateTime::currentDateTime(); │ QDateTime currentDate = QDateTime::currentDateTime();
│
// keep a vector of samples of verification progress at height │ // keep a vector of samples of verification progress at height
blockProcessTime.push_front(qMakePair(currentDate.toMSecsSinceEpoch(), nVerification │ blockProcessTime.push_front(qMakePair(currentDate.toMSecsSinceEpoch(), nVerification
│
// show progress speed if we have more than one sample │ // show progress speed if we have more then one sample
if (blockProcessTime.size() >= 2) { │ if (blockProcessTime.size() >= 2)
│ {
│ double progressStart = blockProcessTime[0].second;
double progressDelta = 0; │ double progressDelta = 0;
double progressPerHour = 0; │ double progressPerHour = 0;
qint64 timeDelta = 0; │ qint64 timeDelta = 0;
qint64 remainingMSecs = 0; │ qint64 remainingMSecs = 0;
double remainingProgress = 1.0 - nVerificationProgress; │ double remainingProgress = 1.0 - nVerificationProgress;
for (int i = 1; i < blockProcessTime.size(); i++) { │ for (int i = 1; i < blockProcessTime.size(); i++)
│ {
QPair<qint64, double> sample = blockProcessTime[i]; │ QPair<qint64, double> sample = blockProcessTime[i];
│
// take first sample after 500 seconds or last available one │ // take first sample after 500 seconds or last available one
if (sample.first < (currentDate.toMSecsSinceEpoch() - 500 * 1000) || i == bl │ if (sample.first < (currentDate.toMSecsSinceEpoch() - 500 * 1000) || i == bl
progressDelta = blockProcessTime[0].second - sample.second; │ progressDelta = progressStart-sample.second;
timeDelta = blockProcessTime[0].first - sample.first; │ timeDelta = blockProcessTime[0].first - sample.first;
progressPerHour = (progressDelta > 0) ? progressDelta / (double)timeDelt │ progressPerHour = progressDelta/(double)timeDelta*1000*3600;
remainingMSecs = (progressDelta > 0) ? remainingProgress / progressDelta │ remainingMSecs = remainingProgress / progressDelta * timeDelta;
break; │ break;
} │ }
} │ }
// show progress increase per hour │ // show progress increase per hour
ui->progressIncreasePerH->setText(QString::number(progressPerHour * 100, 'f', 2) │ ui->progressIncreasePerH->setText(QString::number(progressPerHour > 0 ? progress
│
// show expected remaining time │ // show expected remaining time, if we have a sample
if(remainingMSecs >= 0) { │ if (remainingMSecs > 0)
ui->expectedTimeLeft->setText(GUIUtil::formatNiceTimeOffset(remainingMSecs / │ ui->expectedTimeLeft->setText(GUIUtil::formatNiceTimeOffset(remainingMSecs/1
} else { │
ui->expectedTimeLeft->setText(QObject::tr("unknown")); │
} │
│
static const int MAX_SAMPLES = 5000; │ static const int MAX_SAMPLES = 5000;
if (blockProcessTime.count() > MAX_SAMPLES) { │ if (blockProcessTime.count() > MAX_SAMPLES)
blockProcessTime.remove(MAX_SAMPLES, blockProcessTime.count() - MAX_SAMPLES) │ blockProcessTime.remove(MAX_SAMPLES, blockProcessTime.count()-MAX_SAMPLES);
} │
} │ }
│
// show the last block date │ // show the last block date
ui->newestBlockDate->setText(blockDate.toString()); │ ui->newestBlockDate->setText(blockDate.toString());
│
// show the percentage done according to nVerificationProgress │ // show the percentage done according to nVerificationProgress
ui->percentageProgress->setText(QString::number(nVerificationProgress*100, 'f', 2)+" │ ui->percentageProgress->setText(QString::number(nVerificationProgress*100, 'f', 2)+"
│ ui->progressBar->setValue(nVerificationProgress*100);
│
if (!bestHeaderDate.isValid()) │ if (!bestHeaderDate.isValid())
// not syncing │ // not syncing
return; │ return;
│
// estimate the number of headers left based on nPowTargetSpacing │ // estimate the number of headers left based on nPowTargetSpacing
// and check if the gui is not aware of the best header (happens rarely) │ // and check if the GUI is not aware of the best header (happens rarely)
int estimateNumHeadersLeft = bestHeaderDate.secsTo(currentDate) / Params().GetConsen │ int estimateNumHeadersLeft = bestHeaderDate.secsTo(currentDate) / Params().GetConsen
bool hasBestHeader = bestHeaderHeight >= count; │ bool hasBestHeader = bestHeaderHeight >= count;
│
// show remaining number of blocks │ // show remaining number of blocks
if (estimateNumHeadersLeft < HEADER_HEIGHT_DELTA_SYNC && hasBestHeader) { │ if (estimateNumHeadersLeft < HEADER_HEIGHT_DELTA_SYNC && hasBestHeader) {
ui->numberOfBlocksLeft->setText(QString::number(bestHeaderHeight - count)); │ ui->numberOfBlocksLeft->setText(QString::number(bestHeaderHeight - count));
} else { │ } else {
UpdateHeaderSyncLabel(); │ ui->numberOfBlocksLeft->setText(tr("Unknown. Syncing Headers (%1)...").arg(bestH
ui->expectedTimeLeft->setText(tr("Unknown…")); │ ui->expectedTimeLeft->setText(tr("Unknown..."));
} │ }
} │
next prev up bitcoin/src/util/strencodings.cpp:344 │ dogecoin/src/utilstrencodings.cpp:614
│
int64_t mantissa = 0; │ int64_t mantissa = 0;
int64_t exponent = 0; │ int64_t exponent = 0;
int mantissa_tzeros = 0; │ int mantissa_tzeros = 0;
bool mantissa_sign = false; │ bool mantissa_sign = false;
bool exponent_sign = false; │ bool exponent_sign = false;
int ptr = 0; │ int ptr = 0;
int end = val.size(); │ int end = val.size();
int point_ofs = 0; │ int point_ofs = 0;
│
if (ptr < end && val[ptr] == '-') { │ if (ptr < end && val[ptr] == '-') {
mantissa_sign = true; │ mantissa_sign = true;
++ptr; │ ++ptr;
} │ }
if (ptr < end) │ if (ptr < end)
{ │ {
if (val[ptr] == '0') { │ if (val[ptr] == '0') {
/* pass single 0 */ │ /* pass single 0 */
++ptr; │ ++ptr;
} else if (val[ptr] >= '1' && val[ptr] <= '9') { │ } else if (val[ptr] >= '1' && val[ptr] <= '9') {
while (ptr < end && IsDigit(val[ptr])) { │ while (ptr < end && val[ptr] >= '0' && val[ptr] <= '9') {
if (!ProcessMantissaDigit(val[ptr], mantissa, mantissa_tzeros)) │ if (!ProcessMantissaDigit(val[ptr], mantissa, mantissa_tzeros))
return false; /* overflow */ │ return false; /* overflow */
++ptr; │ ++ptr;
} │ }
} else return false; /* missing expected digit */ │ } else return false; /* missing expected digit */
} else return false; /* empty string or loose '-' */ │ } else return false; /* empty string or loose '-' */
if (ptr < end && val[ptr] == '.') │ if (ptr < end && val[ptr] == '.')
{ │ {
++ptr; │ ++ptr;
if (ptr < end && IsDigit(val[ptr])) │ if (ptr < end && val[ptr] >= '0' && val[ptr] <= '9')
{ │ {
while (ptr < end && IsDigit(val[ptr])) { │ while (ptr < end && val[ptr] >= '0' && val[ptr] <= '9') {
if (!ProcessMantissaDigit(val[ptr], mantissa, mantissa_tzeros)) │ if (!ProcessMantissaDigit(val[ptr], mantissa, mantissa_tzeros))
return false; /* overflow */ │ return false; /* overflow */
++ptr; │ ++ptr;
++point_ofs; │ ++point_ofs;
} │ }
} else return false; /* missing expected digit */ │ } else return false; /* missing expected digit */
} │ }
if (ptr < end && (val[ptr] == 'e' || val[ptr] == 'E')) │ if (ptr < end && (val[ptr] == 'e' || val[ptr] == 'E'))
{ │ {
++ptr; │ ++ptr;
if (ptr < end && val[ptr] == '+') │ if (ptr < end && val[ptr] == '+')
++ptr; │ ++ptr;
else if (ptr < end && val[ptr] == '-') { │ else if (ptr < end && val[ptr] == '-') {
exponent_sign = true; │ exponent_sign = true;
++ptr; │ ++ptr;
} │ }
if (ptr < end && IsDigit(val[ptr])) { │ if (ptr < end && val[ptr] >= '0' && val[ptr] <= '9') {
while (ptr < end && IsDigit(val[ptr])) { │ while (ptr < end && val[ptr] >= '0' && val[ptr] <= '9') {
if (exponent > (UPPER_BOUND / 10LL)) │ if (exponent > (UPPER_BOUND / 10LL))
return false; /* overflow */ │ return false; /* overflow */
exponent = exponent * 10 + val[ptr] - '0'; │ exponent = exponent * 10 + val[ptr] - '0';
++ptr; │ ++ptr;
} │ }
} else return false; /* missing expected digit */ │ } else return false; /* missing expected digit */
} │ }
if (ptr != end) │ if (ptr != end)
return false; /* trailing garbage */ │ return false; /* trailing garbage */
│
/* finalize exponent */ │ /* finalize exponent */
if (exponent_sign) │ if (exponent_sign)
exponent = -exponent; │ exponent = -exponent;
exponent = exponent - point_ofs + mantissa_tzeros; │ exponent = exponent - point_ofs + mantissa_tzeros;
│
/* finalize mantissa */ │ /* finalize mantissa */
if (mantissa_sign) │ if (mantissa_sign)
mantissa = -mantissa; │ mantissa = -mantissa;
│
/* convert to one 64-bit fixed-point value */ │ /* convert to one 64-bit fixed-point value */
exponent += decimals; │ exponent += decimals;
if (exponent < 0) │ if (exponent < 0)
return false; /* cannot represent values smaller than 10^-decimals */ │ return false; /* cannot represent values smaller than 10^-decimals */
if (exponent >= 18) │ if (exponent >= 18)
return false; /* cannot represent values larger than or equal to 10^(18-decimals │ return false; /* cannot represent values larger than or equal to 10^(18-decimals
│
for (int i=0; i < exponent; ++i) { │ for (int i=0; i < exponent; ++i) {
if (mantissa > (UPPER_BOUND / 10LL) || mantissa < -(UPPER_BOUND / 10LL)) │ if (mantissa > (UPPER_BOUND / 10LL) || mantissa < -(UPPER_BOUND / 10LL))
return false; /* overflow */ │ return false; /* overflow */
mantissa *= 10; │ mantissa *= 10;
} │ }
if (mantissa > UPPER_BOUND || mantissa < -UPPER_BOUND) │ if (mantissa > UPPER_BOUND || mantissa < -UPPER_BOUND)
return false; /* overflow */ │ return false; /* overflow */
│
if (amount_out) │ if (amount_out)
*amount_out = mantissa; │ *amount_out = mantissa;
│
return true; │ return true;
} │
next prev up dogecoin/src/test/skiplist_tests.cpp:48 │ bitcoin/src/test/skiplist_tests.cpp:46
│
// Build a main chain 100000 blocks long. │ // Build a main chain 100000 blocks long.
std::vector<uint256> vHashMain(100000); │ std::vector<uint256> vHashMain(100000);
std::vector<CBlockIndex> vBlocksMain(100000); │ std::vector<CBlockIndex> vBlocksMain(100000);
for (unsigned int i=0; i<vBlocksMain.size(); i++) { │ for (unsigned int i=0; i<vBlocksMain.size(); i++) {
vHashMain[i] = ArithToUint256(i); // Set the hash equal to the height, so we can │ vHashMain[i] = ArithToUint256(i); // Set the hash equal to the height, so we can
vBlocksMain[i].nHeight = i; │ vBlocksMain[i].nHeight = i;
vBlocksMain[i].pprev = i ? &vBlocksMain[i - 1] : NULL; │ vBlocksMain[i].pprev = i ? &vBlocksMain[i - 1] : nullptr;
vBlocksMain[i].phashBlock = &vHashMain[i]; │ vBlocksMain[i].phashBlock = &vHashMain[i];
vBlocksMain[i].BuildSkip(); │ vBlocksMain[i].BuildSkip();
BOOST_CHECK_EQUAL((int)UintToArith256(vBlocksMain[i].GetBlockHash()).GetLow64(), │ BOOST_CHECK_EQUAL((int)UintToArith256(vBlocksMain[i].GetBlockHash()).GetLow64(),
BOOST_CHECK(vBlocksMain[i].pprev == NULL || vBlocksMain[i].nHeight == vBlocksMai │ BOOST_CHECK(vBlocksMain[i].pprev == nullptr || vBlocksMain[i].nHeight == vBlocks
} │ }
│
// Build a branch that splits off at block 49999, 50000 blocks long. │ // Build a branch that splits off at block 49999, 50000 blocks long.
std::vector<uint256> vHashSide(50000); │ std::vector<uint256> vHashSide(50000);
std::vector<CBlockIndex> vBlocksSide(50000); │ std::vector<CBlockIndex> vBlocksSide(50000);
for (unsigned int i=0; i<vBlocksSide.size(); i++) { │ for (unsigned int i=0; i<vBlocksSide.size(); i++) {
vHashSide[i] = ArithToUint256(i + 50000 + (arith_uint256(1) << 128)); // Add 1<< │ vHashSide[i] = ArithToUint256(i + 50000 + (arith_uint256(1) << 128)); // Add 1<<
vBlocksSide[i].nHeight = i + 50000; │ vBlocksSide[i].nHeight = i + 50000;
vBlocksSide[i].pprev = i ? &vBlocksSide[i - 1] : &vBlocksMain[49999]; │ vBlocksSide[i].pprev = i ? &vBlocksSide[i - 1] : (vBlocksMain.data()+49999);
vBlocksSide[i].phashBlock = &vHashSide[i]; │ vBlocksSide[i].phashBlock = &vHashSide[i];
vBlocksSide[i].BuildSkip(); │ vBlocksSide[i].BuildSkip();
BOOST_CHECK_EQUAL((int)UintToArith256(vBlocksSide[i].GetBlockHash()).GetLow64(), │ BOOST_CHECK_EQUAL((int)UintToArith256(vBlocksSide[i].GetBlockHash()).GetLow64(),
BOOST_CHECK(vBlocksSide[i].pprev == NULL || vBlocksSide[i].nHeight == vBlocksSid │ BOOST_CHECK(vBlocksSide[i].pprev == nullptr || vBlocksSide[i].nHeight == vBlocks
} │ }
│
// Build a CChain for the main branch. │ // Build a CChain for the main branch.
CChain chain; │ CChain chain;
chain.SetTip(&vBlocksMain.back()); │ chain.SetTip(&vBlocksMain.back());
│
// Test 100 random starting points for locators. │ // Test 100 random starting points for locators.
for (int n=0; n<100; n++) { │ for (int n=0; n<100; n++) {
int r = insecure_rand() % 150000; │ int r = InsecureRandRange(150000);
CBlockIndex* tip = (r < 100000) ? &vBlocksMain[r] : &vBlocksSide[r - 100000]; │ CBlockIndex* tip = (r < 100000) ? &vBlocksMain[r] : &vBlocksSide[r - 100000];
CBlockLocator locator = chain.GetLocator(tip); │ CBlockLocator locator = chain.GetLocator(tip);
│
// The first result must be the block itself, the last one must be genesis. │ // The first result must be the block itself, the last one must be genesis.
BOOST_CHECK(locator.vHave.front() == tip->GetBlockHash()); │ BOOST_CHECK(locator.vHave.front() == tip->GetBlockHash());
BOOST_CHECK(locator.vHave.back() == vBlocksMain[0].GetBlockHash()); │ BOOST_CHECK(locator.vHave.back() == vBlocksMain[0].GetBlockHash());
│
// Entries 1 through 11 (inclusive) go back one step each. │ // Entries 1 through 11 (inclusive) go back one step each.
for (unsigned int i = 1; i < 12 && i < locator.vHave.size() - 1; i++) { │ for (unsigned int i = 1; i < 12 && i < locator.vHave.size() - 1; i++) {
BOOST_CHECK_EQUAL(UintToArith256(locator.vHave[i]).GetLow64(), tip->nHeight │ BOOST_CHECK_EQUAL(UintToArith256(locator.vHave[i]).GetLow64(), tip->nHeight
} │ }
│
// The further ones (excluding the last one) go back with exponential steps. │ // The further ones (excluding the last one) go back with exponential steps.
unsigned int dist = 2; │ unsigned int dist = 2;
for (unsigned int i = 12; i < locator.vHave.size() - 1; i++) { │ for (unsigned int i = 12; i < locator.vHave.size() - 1; i++) {
BOOST_CHECK_EQUAL(UintToArith256(locator.vHave[i - 1]).GetLow64() - UintToAr │ BOOST_CHECK_EQUAL(UintToArith256(locator.vHave[i - 1]).GetLow64() - UintToAr
dist *= 2; │ dist *= 2;
} │ }
} │ }
} │
next prev up dogecoin/src/validation.cpp:2356 │ bitcoin/src/validation.cpp:2768
│
│ AssertLockHeld(::cs_main);
do { │ do {
CBlockIndex *pindexNew = NULL; │ CBlockIndex *pindexNew = nullptr;
│
// Find the best candidate header. │ // Find the best candidate header.
{ │ {
std::set<CBlockIndex*, CBlockIndexWorkComparator>::reverse_iterator it = set │ std::set<CBlockIndex*, CBlockIndexWorkComparator>::reverse_iterator it = set
if (it == setBlockIndexCandidates.rend()) │ if (it == setBlockIndexCandidates.rend())
return NULL; │ return nullptr;
pindexNew = *it; │ pindexNew = *it;
} │ }
│
// Check whether all blocks on the path between the currently active chain and t │ // Check whether all blocks on the path between the currently active chain and t
// Just going until the active chain is an optimization, as we know all blocks i │ // Just going until the active chain is an optimization, as we know all blocks i
CBlockIndex *pindexTest = pindexNew; │ CBlockIndex *pindexTest = pindexNew;
bool fInvalidAncestor = false; │ bool fInvalidAncestor = false;
while (pindexTest && !chainActive.Contains(pindexTest)) { │ while (pindexTest && !m_chain.Contains(pindexTest)) {
assert(pindexTest->nChainTx || pindexTest->nHeight == 0); │ assert(pindexTest->HaveTxsDownloaded() || pindexTest->nHeight == 0);
│
// Pruned nodes may have entries in setBlockIndexCandidates for │ // Pruned nodes may have entries in setBlockIndexCandidates for
// which block files have been deleted. Remove those as candidates │ // which block files have been deleted. Remove those as candidates
// for the most work chain if we come across them; we can't switch │ // for the most work chain if we come across them; we can't switch
// to a chain unless we have all the non-active-chain parent blocks. │ // to a chain unless we have all the non-active-chain parent blocks.
bool fFailedChain = pindexTest->nStatus & BLOCK_FAILED_MASK; │ bool fFailedChain = pindexTest->nStatus & BLOCK_FAILED_MASK;
bool fMissingData = !(pindexTest->nStatus & BLOCK_HAVE_DATA); │ bool fMissingData = !(pindexTest->nStatus & BLOCK_HAVE_DATA);
if (fFailedChain || fMissingData) { │ if (fFailedChain || fMissingData) {
// Candidate chain is not usable (either invalid or missing data) │ // Candidate chain is not usable (either invalid or missing data)
if (fFailedChain && (pindexBestInvalid == NULL || pindexNew->nChainWork │ if (fFailedChain && (m_chainman.m_best_invalid == nullptr || pindexNew->
pindexBestInvalid = pindexNew; │ m_chainman.m_best_invalid = pindexNew;
│ }
CBlockIndex *pindexFailed = pindexNew; │ CBlockIndex *pindexFailed = pindexNew;
// Remove the entire chain from the set. │ // Remove the entire chain from the set.
while (pindexTest != pindexFailed) { │ while (pindexTest != pindexFailed) {
if (fFailedChain) { │ if (fFailedChain) {
pindexFailed->nStatus |= BLOCK_FAILED_CHILD; │ pindexFailed->nStatus |= BLOCK_FAILED_CHILD;
} else if (fMissingData) { │ } else if (fMissingData) {
// If we're missing data, then add back to mapBlocksUnlinked, │ // If we're missing data, then add back to m_blocks_unlinked,
// so that if the block arrives in the future we can try adding │ // so that if the block arrives in the future we can try adding
// to setBlockIndexCandidates again. │ // to setBlockIndexCandidates again.
mapBlocksUnlinked.insert(std::make_pair(pindexFailed->pprev, pin │ m_blockman.m_blocks_unlinked.insert(
│ std::make_pair(pindexFailed->pprev, pindexFailed));
} │ }
setBlockIndexCandidates.erase(pindexFailed); │ setBlockIndexCandidates.erase(pindexFailed);
pindexFailed = pindexFailed->pprev; │ pindexFailed = pindexFailed->pprev;
} │ }
setBlockIndexCandidates.erase(pindexTest); │ setBlockIndexCandidates.erase(pindexTest);
fInvalidAncestor = true; │ fInvalidAncestor = true;
break; │ break;
} │ }
pindexTest = pindexTest->pprev; │ pindexTest = pindexTest->pprev;
} │ }
if (!fInvalidAncestor) │ if (!fInvalidAncestor)
return pindexNew; │ return pindexNew;
} while(true); │ } while(true);
} │
next prev up bitcoin/src/qt/test/uritests.cpp:13 │ dogecoin/src/qt/test/uritests.cpp:13
│
SendCoinsRecipient rv; │ SendCoinsRecipient rv;
QUrl uri; │ QUrl uri;
uri.setUrl(QString("dogecoin:D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-dontexist=")); │ uri.setUrl(QString("dogecoin:D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-dontexist="));
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); │ QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
│
uri.setUrl(QString("dogecoin:D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?dontexist=")); │ uri.setUrl(QString("dogecoin:D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?dontexist="));
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); │ QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
QVERIFY(rv.address == QString("D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); │ QVERIFY(rv.address == QString("D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
QVERIFY(rv.label == QString()); │ QVERIFY(rv.label == QString());
QVERIFY(rv.amount == 0); │ QVERIFY(rv.amount == 0);
│
uri.setUrl(QString("dogecoin:D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?label=Wikipedia Exam │ uri.setUrl(QString("dogecoin:D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?label=Wikipedia Exam
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); │ QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
QVERIFY(rv.address == QString("D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); │ QVERIFY(rv.address == QString("D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
QVERIFY(rv.label == QString("Wikipedia Example Address")); │ QVERIFY(rv.label == QString("Wikipedia Example Address"));
QVERIFY(rv.amount == 0); │ QVERIFY(rv.amount == 0);
│
uri.setUrl(QString("dogecoin:D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=0.001")); │ uri.setUrl(QString("dogecoin:D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=0.001"));
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); │ QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
QVERIFY(rv.address == QString("D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); │ QVERIFY(rv.address == QString("D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
QVERIFY(rv.label == QString()); │ QVERIFY(rv.label == QString());
QVERIFY(rv.amount == 100000); │ QVERIFY(rv.amount == 100000);
│
uri.setUrl(QString("dogecoin:D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1.001")); │ uri.setUrl(QString("dogecoin:D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1.001"));
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); │ QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
QVERIFY(rv.address == QString("D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); │ QVERIFY(rv.address == QString("D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
QVERIFY(rv.label == QString()); │ QVERIFY(rv.label == QString());
QVERIFY(rv.amount == 100100000); │ QVERIFY(rv.amount == 100100000);
│
uri.setUrl(QString("dogecoin:D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=100&label=Wik │ uri.setUrl(QString("dogecoin:D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=100&label=Wik
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); │ QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
QVERIFY(rv.address == QString("D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); │ QVERIFY(rv.address == QString("D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
QVERIFY(rv.amount == 10000000000LL); │ QVERIFY(rv.amount == 10000000000LL);
QVERIFY(rv.label == QString("Wikipedia Example")); │ QVERIFY(rv.label == QString("Wikipedia Example"));
│
uri.setUrl(QString("dogecoin:D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Ex │ uri.setUrl(QString("dogecoin:D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Ex
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); │ QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
QVERIFY(rv.address == QString("D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); │ QVERIFY(rv.address == QString("D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
QVERIFY(rv.label == QString()); │ QVERIFY(rv.label == QString());
│
QVERIFY(GUIUtil::parseBitcoinURI("dogecoin://D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?mess │ QVERIFY(GUIUtil::parseBitcoinURI("dogecoin://D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?mess
QVERIFY(rv.address == QString("D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); │ QVERIFY(rv.address == QString("D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
QVERIFY(rv.label == QString()); │ QVERIFY(rv.label == QString());
│
uri.setUrl(QString("dogecoin:D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-message=Wikipedi │ uri.setUrl(QString("dogecoin:D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-message=Wikipedi
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); │ QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
│
uri.setUrl(QString("dogecoin:D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000&label=W │ uri.setUrl(QString("dogecoin:D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000&label=W
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); │ QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
│
uri.setUrl(QString("dogecoin:D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000.0&label │ uri.setUrl(QString("dogecoin:D75tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000.0&label
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); │ QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
} │
next prev up bitcoin/src/test/addrman_tests.cpp:399 │ bitcoin/src/test/addrman_tests.cpp:527
│
│ std::vector<bool> asmap = FromBytes(asmap_raw, sizeof(asmap_raw) * 8);
│ NetGroupManager ngm_asmap{asmap};
│
CAddress addr1 = CAddress(ResolveService("250.1.2.1", 8333), NODE_NONE); │ CAddress addr1 = CAddress(ResolveService("250.1.2.1", 8333), NODE_NONE);
CAddress addr2 = CAddress(ResolveService("250.1.2.1", 9999), NODE_NONE); │ CAddress addr2 = CAddress(ResolveService("250.1.2.1", 9999), NODE_NONE);
│
CNetAddr source1 = ResolveIP("250.1.2.1"); │ CNetAddr source1 = ResolveIP("250.1.2.1");
│
AddrInfo info1 = AddrInfo(addr1, source1); │ AddrInfo info1 = AddrInfo(addr1, source1);
│
uint256 nKey1 = (uint256)(CHashWriter(SER_GETHASH, 0) << 1).GetHash(); │ uint256 nKey1 = (uint256)(CHashWriter(SER_GETHASH, 0) << 1).GetHash();
uint256 nKey2 = (uint256)(CHashWriter(SER_GETHASH, 0) << 2).GetHash(); │ uint256 nKey2 = (uint256)(CHashWriter(SER_GETHASH, 0) << 2).GetHash();
│
// Test: Make sure the buckets are what we expect │ // Test: Make sure the buckets are what we expect
BOOST_CHECK_EQUAL(info1.GetNewBucket(nKey1, EMPTY_NETGROUPMAN), 786); │ BOOST_CHECK_EQUAL(info1.GetNewBucket(nKey1, ngm_asmap), 795);
BOOST_CHECK_EQUAL(info1.GetNewBucket(nKey1, source1, EMPTY_NETGROUPMAN), 786); │ BOOST_CHECK_EQUAL(info1.GetNewBucket(nKey1, source1, ngm_asmap), 795);
│
// Test: Make sure key actually randomizes bucket placement. A fail on │ // Test: Make sure key actually randomizes bucket placement. A fail on
// this test could be a security issue. │ // this test could be a security issue.
BOOST_CHECK(info1.GetNewBucket(nKey1, EMPTY_NETGROUPMAN) != info1.GetNewBucket(nKey2 │ BOOST_CHECK(info1.GetNewBucket(nKey1, ngm_asmap) != info1.GetNewBucket(nKey2, ngm_as
│
// Test: Ports should not affect bucket placement in the addr │ // Test: Ports should not affect bucket placement in the addr
AddrInfo info2 = AddrInfo(addr2, source1); │ AddrInfo info2 = AddrInfo(addr2, source1);
BOOST_CHECK(info1.GetKey() != info2.GetKey()); │ BOOST_CHECK(info1.GetKey() != info2.GetKey());
BOOST_CHECK_EQUAL(info1.GetNewBucket(nKey1, EMPTY_NETGROUPMAN), info2.GetNewBucket(n │ BOOST_CHECK_EQUAL(info1.GetNewBucket(nKey1, ngm_asmap), info2.GetNewBucket(nKey1, ng
│
std::set<int> buckets; │ std::set<int> buckets;
for (int i = 0; i < 255; i++) { │ for (int i = 0; i < 255; i++) {
AddrInfo infoi = AddrInfo( │ AddrInfo infoi = AddrInfo(
CAddress(ResolveService("250.1.1." + ToString(i)), NODE_NONE), │ CAddress(ResolveService("250.1.1." + ToString(i)), NODE_NONE),
ResolveIP("250.1.1." + ToString(i))); │ ResolveIP("250.1.1." + ToString(i)));
int bucket = infoi.GetNewBucket(nKey1, EMPTY_NETGROUPMAN); │ int bucket = infoi.GetNewBucket(nKey1, ngm_asmap);
buckets.insert(bucket); │ buckets.insert(bucket);
} │ }
// Test: IP addresses in the same group (\16 prefix for IPv4) should │ // Test: IP addresses in the same /16 prefix
// always map to the same bucket. │ // usually map to the same bucket.
BOOST_CHECK_EQUAL(buckets.size(), 1U); │ BOOST_CHECK_EQUAL(buckets.size(), 1U);
│
buckets.clear(); │ buckets.clear();
for (int j = 0; j < 4 * 255; j++) { │ for (int j = 0; j < 4 * 255; j++) {
AddrInfo infoj = AddrInfo(CAddress( │ AddrInfo infoj = AddrInfo(CAddress(
ResolveService( │ ResolveService(
ToString(250 + (j / 255)) + "." + ToString(j │ ToString(250 + (j / 255)) + "." + ToString(j
ResolveIP("251.4.1.1")); │ ResolveIP("251.4.1.1"));
int bucket = infoj.GetNewBucket(nKey1, EMPTY_NETGROUPMAN); │ int bucket = infoj.GetNewBucket(nKey1, ngm_asmap);
buckets.insert(bucket); │ buckets.insert(bucket);
} │ }
// Test: IP addresses in the same source groups should map to NO MORE │ // Test: IP addresses in the same source /16 prefix should not map to more
// than 64 buckets. │ // than 64 buckets.
BOOST_CHECK(buckets.size() <= 64); │ BOOST_CHECK(buckets.size() <= 64);
│
buckets.clear(); │ buckets.clear();
for (int p = 0; p < 255; p++) { │ for (int p = 0; p < 255; p++) {
AddrInfo infoj = AddrInfo( │ AddrInfo infoj = AddrInfo(
CAddress(ResolveService("250.1.1.1"), NODE_NONE), │ CAddress(ResolveService("250.1.1.1"), NODE_NONE),
│ ResolveIP("101." + ToString(p) + ".1.1"));
│ int bucket = infoj.GetNewBucket(nKey1, ngm_asmap);
│ buckets.insert(bucket);
│ }
│ // Test: IP addresses in the different source /16 prefixes usually map to MORE
│ // than 1 bucket.
│ BOOST_CHECK(buckets.size() > 1);
│
│ buckets.clear();
│ for (int p = 0; p < 255; p++) {
│ AddrInfo infoj = AddrInfo(
│ CAddress(ResolveService("250.1.1.1"), NODE_NONE),
ResolveIP("250." + ToString(p) + ".1.1")); │ ResolveIP("250." + ToString(p) + ".1.1"));
int bucket = infoj.GetNewBucket(nKey1, EMPTY_NETGROUPMAN); │ int bucket = infoj.GetNewBucket(nKey1, ngm_asmap);
buckets.insert(bucket); │ buckets.insert(bucket);
} │ }
// Test: IP addresses in the different source groups should map to MORE │ // Test: IP addresses in the different source /16 prefixes sometimes map to NO MORE
// than 64 buckets. │ // than 1 bucket.
BOOST_CHECK(buckets.size() > 64); │ BOOST_CHECK(buckets.size() == 1);
} │
next prev up dogecoin/src/test/rpc_tests.cpp:187 │ bitcoin/src/test/rpc_tests.cpp:192
│
BOOST_CHECK_THROW(AmountFromValue(ValueFromString("-0.00000001")), UniValue); │ BOOST_CHECK_THROW(AmountFromValue(ValueFromString("-0.00000001")), UniValue);
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0")), 0LL); │ BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0")), 0LL);
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.00000000")), 0LL); │ BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.00000000")), 0LL);
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.00000001")), 1LL); │ BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.00000001")), 1LL);
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.17622195")), 17622195LL); │ BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.17622195")), 17622195LL);
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.5")), 50000000LL); │ BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.5")), 50000000LL);
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.50000000")), 50000000LL); │ BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.50000000")), 50000000LL);
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.89898989")), 89898989LL); │ BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.89898989")), 89898989LL);
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("1.00000000")), 100000000LL); │ BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("1.00000000")), 100000000LL);
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("20999999.9999999")), 209999999999 │ BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("20999999.9999999")), 209999999999
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("20999999.99999999")), 20999999999 │ BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("20999999.99999999")), 20999999999
│
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("1e-8")), COIN/100000000); │ BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("1e-8")), COIN/100000000);
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.1e-7")), COIN/100000000); │ BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.1e-7")), COIN/100000000);
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.01e-6")), COIN/100000000); │ BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.01e-6")), COIN/100000000);
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.0000000000000000000000000000000 │ BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.0000000000000000000000000000000
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("100000000000000000000000000000000 │ BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("100000000000000000000000000000000
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.0000000000000000000000000000000 │ BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.0000000000000000000000000000000
│
BOOST_CHECK_THROW(AmountFromValue(ValueFromString("1e-9")), UniValue); //should fail │ BOOST_CHECK_THROW(AmountFromValue(ValueFromString("1e-9")), UniValue); //should fail
BOOST_CHECK_THROW(AmountFromValue(ValueFromString("0.000000019")), UniValue); //shou │ BOOST_CHECK_THROW(AmountFromValue(ValueFromString("0.000000019")), UniValue); //shou
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.00000001000000")), 1LL); //shou │ BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.00000001000000")), 1LL); //shou
BOOST_CHECK_THROW(AmountFromValue(ValueFromString("19e-9")), UniValue); //should fai │ BOOST_CHECK_THROW(AmountFromValue(ValueFromString("19e-9")), UniValue); //should fai
BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.19e-6")), 19); //should pass, l │ BOOST_CHECK_EQUAL(AmountFromValue(ValueFromString("0.19e-6")), 19); //should pass, l
│
BOOST_CHECK_THROW(AmountFromValue(ValueFromString("92233720368.54775808")), UniValue │ BOOST_CHECK_THROW(AmountFromValue(ValueFromString("92233720368.54775808")), UniValue
BOOST_CHECK_THROW(AmountFromValue(ValueFromString("1e+11")), UniValue); //overflow e │ BOOST_CHECK_THROW(AmountFromValue(ValueFromString("1e+11")), UniValue); //overflow e
BOOST_CHECK_THROW(AmountFromValue(ValueFromString("1e11")), UniValue); //overflow er │ BOOST_CHECK_THROW(AmountFromValue(ValueFromString("1e11")), UniValue); //overflow er
BOOST_CHECK_THROW(AmountFromValue(ValueFromString("93e+9")), UniValue); //overflow e │ BOOST_CHECK_THROW(AmountFromValue(ValueFromString("93e+9")), UniValue); //overflow e
} │
next prev up bitcoin/src/script/interpreter.cpp:107 │ dogecoin/src/script/interpreter.cpp:110
│
// Format: 0x30 [total-length] 0x02 [R-length] [R] 0x02 [S-length] [S] [sighash] │ // Format: 0x30 [total-length] 0x02 [R-length] [R] 0x02 [S-length] [S] [sighash]
// * total-length: 1-byte length descriptor of everything that follows, │ // * total-length: 1-byte length descriptor of everything that follows,
// excluding the sighash byte. │ // excluding the sighash byte.
// * R-length: 1-byte length descriptor of the R value that follows. │ // * R-length: 1-byte length descriptor of the R value that follows.
// * R: arbitrary-length big-endian encoded R value. It must use the shortest │ // * R: arbitrary-length big-endian encoded R value. It must use the shortest
// possible encoding for a positive integer (which means no null bytes at │ // possible encoding for a positive integers (which means no null bytes at
// the start, except a single one when the next byte has its highest bit set). │ // the start, except a single one when the next byte has its highest bit set).
// * S-length: 1-byte length descriptor of the S value that follows. │ // * S-length: 1-byte length descriptor of the S value that follows.
// * S: arbitrary-length big-endian encoded S value. The same rules apply. │ // * S: arbitrary-length big-endian encoded S value. The same rules apply.
// * sighash: 1-byte value indicating what data is hashed (not part of the DER │ // * sighash: 1-byte value indicating what data is hashed (not part of the DER
// signature) │ // signature)
│
// Minimum and maximum size constraints. │ // Minimum and maximum size constraints.
if (sig.size() < 9) return false; │ if (sig.size() < 9) return false;
if (sig.size() > 73) return false; │ if (sig.size() > 73) return false;
│
// A signature is of type 0x30 (compound). │ // A signature is of type 0x30 (compound).
if (sig[0] != 0x30) return false; │ if (sig[0] != 0x30) return false;
│
// Make sure the length covers the entire signature. │ // Make sure the length covers the entire signature.
if (sig[1] != sig.size() - 3) return false; │ if (sig[1] != sig.size() - 3) return false;
│
// Extract the length of the R element. │ // Extract the length of the R element.
unsigned int lenR = sig[3]; │ unsigned int lenR = sig[3];
│
// Make sure the length of the S element is still inside the signature. │ // Make sure the length of the S element is still inside the signature.
if (5 + lenR >= sig.size()) return false; │ if (5 + lenR >= sig.size()) return false;
│
// Extract the length of the S element. │ // Extract the length of the S element.
unsigned int lenS = sig[5 + lenR]; │ unsigned int lenS = sig[5 + lenR];
│
// Verify that the length of the signature matches the sum of the length │ // Verify that the length of the signature matches the sum of the length
// of the elements. │ // of the elements.
if ((size_t)(lenR + lenS + 7) != sig.size()) return false; │ if ((size_t)(lenR + lenS + 7) != sig.size()) return false;
│
// Check whether the R element is an integer. │ // Check whether the R element is an integer.
if (sig[2] != 0x02) return false; │ if (sig[2] != 0x02) return false;
│
// Zero-length integers are not allowed for R. │ // Zero-length integers are not allowed for R.
if (lenR == 0) return false; │ if (lenR == 0) return false;
│
// Negative numbers are not allowed for R. │ // Negative numbers are not allowed for R.
if (sig[4] & 0x80) return false; │ if (sig[4] & 0x80) return false;
│
// Null bytes at the start of R are not allowed, unless R would │ // Null bytes at the start of R are not allowed, unless R would
// otherwise be interpreted as a negative number. │ // otherwise be interpreted as a negative number.
if (lenR > 1 && (sig[4] == 0x00) && !(sig[5] & 0x80)) return false; │ if (lenR > 1 && (sig[4] == 0x00) && !(sig[5] & 0x80)) return false;
│
// Check whether the S element is an integer. │ // Check whether the S element is an integer.
if (sig[lenR + 4] != 0x02) return false; │ if (sig[lenR + 4] != 0x02) return false;
│
// Zero-length integers are not allowed for S. │ // Zero-length integers are not allowed for S.
if (lenS == 0) return false; │ if (lenS == 0) return false;
│
// Negative numbers are not allowed for S. │ // Negative numbers are not allowed for S.
if (sig[lenR + 6] & 0x80) return false; │ if (sig[lenR + 6] & 0x80) return false;
│
// Null bytes at the start of S are not allowed, unless S would otherwise be │ // Null bytes at the start of S are not allowed, unless S would otherwise be
// interpreted as a negative number. │ // interpreted as a negative number.
if (lenS > 1 && (sig[lenR + 6] == 0x00) && !(sig[lenR + 7] & 0x80)) return false; │ if (lenS > 1 && (sig[lenR + 6] == 0x00) && !(sig[lenR + 7] & 0x80)) return false;
│
return true; │ return true;
} │
next prev up dogecoin/src/addrman.cpp:243 │ bitcoin/src/addrman.cpp:542
│
│ AssertLockHeld(cs);
│
if (!addr.IsRoutable()) │ if (!addr.IsRoutable())
return false; │ return false;
│
bool fNew = false; │
int nId; │ int nId;
CAddrInfo* pinfo = Find(addr, &nId); │ AddrInfo* pinfo = Find(addr, &nId);
│
// Do not set a penalty for a source's self-announcement │ // Do not set a penalty for a source's self-announcement
if (addr == source) { │ if (addr == source) {
nTimePenalty = 0; │ nTimePenalty = 0;
} │ }
│
if (pinfo) { │ if (pinfo) {
// periodically update nTime │ // periodically update nTime
bool fCurrentlyOnline = (GetAdjustedTime() - addr.nTime < 24 * 60 * 60); │ bool fCurrentlyOnline = (GetAdjustedTime() - addr.nTime < 24 * 60 * 60);
int64_t nUpdateInterval = (fCurrentlyOnline ? 60 * 60 : 24 * 60 * 60); │ int64_t nUpdateInterval = (fCurrentlyOnline ? 60 * 60 : 24 * 60 * 60);
if (addr.nTime && (!pinfo->nTime || pinfo->nTime < addr.nTime - nUpdateInterval │ if (addr.nTime && (!pinfo->nTime || pinfo->nTime < addr.nTime - nUpdateInterval
pinfo->nTime = std::max((int64_t)0, addr.nTime - nTimePenalty); │ pinfo->nTime = std::max((int64_t)0, addr.nTime - nTimePenalty);
│
// add services │ // add services
pinfo->nServices = ServiceFlags(pinfo->nServices | addr.nServices); │ pinfo->nServices = ServiceFlags(pinfo->nServices | addr.nServices);
│
// do not update if no new information is present │ // do not update if no new information is present
if (!addr.nTime || (pinfo->nTime && addr.nTime <= pinfo->nTime)) │ if (!addr.nTime || (pinfo->nTime && addr.nTime <= pinfo->nTime))
return false; │ return false;
│
// do not update if the entry was already in the "tried" table │ // do not update if the entry was already in the "tried" table
if (pinfo->fInTried) │ if (pinfo->fInTried)
return false; │ return false;
│
// do not update if the max reference count is reached │ // do not update if the max reference count is reached
if (pinfo->nRefCount == ADDRMAN_NEW_BUCKETS_PER_ADDRESS) │ if (pinfo->nRefCount == ADDRMAN_NEW_BUCKETS_PER_ADDRESS)
return false; │ return false;
│
// stochastic test: previous nRefCount == N: 2^N times harder to increase it │ // stochastic test: previous nRefCount == N: 2^N times harder to increase it
int nFactor = 1; │ int nFactor = 1;
for (int n = 0; n < pinfo->nRefCount; n++) │ for (int n = 0; n < pinfo->nRefCount; n++)
nFactor *= 2; │ nFactor *= 2;
if (nFactor > 1 && (RandomInt(nFactor) != 0)) │ if (nFactor > 1 && (insecure_rand.randrange(nFactor) != 0))
return false; │ return false;
} else { │ } else {
pinfo = Create(addr, source, &nId); │ pinfo = Create(addr, source, &nId);
pinfo->nTime = std::max((int64_t)0, (int64_t)pinfo->nTime - nTimePenalty); │ pinfo->nTime = std::max((int64_t)0, (int64_t)pinfo->nTime - nTimePenalty);
nNew++; │ nNew++;
fNew = true; │
} │ }
│
int nUBucket = pinfo->GetNewBucket(nKey, source); │ int nUBucket = pinfo->GetNewBucket(nKey, source, m_netgroupman);
int nUBucketPos = pinfo->GetBucketPosition(nKey, true, nUBucket); │ int nUBucketPos = pinfo->GetBucketPosition(nKey, true, nUBucket);
│ bool fInsert = vvNew[nUBucket][nUBucketPos] == -1;
if (vvNew[nUBucket][nUBucketPos] != nId) { │ if (vvNew[nUBucket][nUBucketPos] != nId) {
bool fInsert = vvNew[nUBucket][nUBucketPos] == -1; │
if (!fInsert) { │ if (!fInsert) {
CAddrInfo& infoExisting = mapInfo[vvNew[nUBucket][nUBucketPos]]; │ AddrInfo& infoExisting = mapInfo[vvNew[nUBucket][nUBucketPos]];
if (infoExisting.IsTerrible() || (infoExisting.nRefCount > 1 && pinfo->nRefC │ if (infoExisting.IsTerrible() || (infoExisting.nRefCount > 1 && pinfo->nRefC
// Overwrite the existing new table entry. │ // Overwrite the existing new table entry.
fInsert = true; │ fInsert = true;
} │ }
} │ }
if (fInsert) { │ if (fInsert) {
ClearNew(nUBucket, nUBucketPos); │ ClearNew(nUBucket, nUBucketPos);
pinfo->nRefCount++; │ pinfo->nRefCount++;
vvNew[nUBucket][nUBucketPos] = nId; │ vvNew[nUBucket][nUBucketPos] = nId;
│ LogPrint(BCLog::ADDRMAN, "Added %s mapped to AS%i to new[%i][%i]\n",
│ addr.ToString(), m_netgroupman.GetMappedAS(addr), nUBucket, nUBucke
} else { │ } else {
if (pinfo->nRefCount == 0) { │ if (pinfo->nRefCount == 0) {
Delete(nId); │ Delete(nId);
} │ }
} │ }
} │ }
return fNew; │ return fInsert;
} │
next prev up dogecoin/src/test/crypto_tests.cpp:258 │ bitcoin/src/test/crypto_tests.cpp:261
│
TestSHA512("", │ TestSHA512("",
"cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce" │ "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce"
"47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e"); │ "47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e");
TestSHA512("abc", │ TestSHA512("abc",
"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a" │ "ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a"
"2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f"); │ "2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f");
TestSHA512("message digest", │ TestSHA512("message digest",
"107dbf389d9e9f71a3a95f6c055b9251bc5268c2be16d6c13492ea45b0199f33" │ "107dbf389d9e9f71a3a95f6c055b9251bc5268c2be16d6c13492ea45b0199f33"
"09e16455ab1e96118e8a905d5597b72038ddb372a89826046de66687bb420e7c"); │ "09e16455ab1e96118e8a905d5597b72038ddb372a89826046de66687bb420e7c");
TestSHA512("secure hash algorithm", │ TestSHA512("secure hash algorithm",
"7746d91f3de30c68cec0dd693120a7e8b04d8073cb699bdce1a3f64127bca7a3" │ "7746d91f3de30c68cec0dd693120a7e8b04d8073cb699bdce1a3f64127bca7a3"
"d5db502e814bb63c063a7a5043b2df87c61133395f4ad1edca7fcf4b30c3236e"); │ "d5db502e814bb63c063a7a5043b2df87c61133395f4ad1edca7fcf4b30c3236e");
TestSHA512("SHA512 is considered to be safe", │ TestSHA512("SHA512 is considered to be safe",
"099e6468d889e1c79092a89ae925a9499b5408e01b66cb5b0a3bd0dfa51a9964" │ "099e6468d889e1c79092a89ae925a9499b5408e01b66cb5b0a3bd0dfa51a9964"
"6b4a3901caab1318189f74cd8cf2e941829012f2449df52067d3dd5b978456c2"); │ "6b4a3901caab1318189f74cd8cf2e941829012f2449df52067d3dd5b978456c2");
TestSHA512("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", │ TestSHA512("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
"204a8fc6dda82f0a0ced7beb8e08a41657c16ef468b228a8279be331a703c335" │ "204a8fc6dda82f0a0ced7beb8e08a41657c16ef468b228a8279be331a703c335"
"96fd15c13b1b07f9aa1d3bea57789ca031ad85c7a71dd70354ec631238ca3445"); │ "96fd15c13b1b07f9aa1d3bea57789ca031ad85c7a71dd70354ec631238ca3445");
TestSHA512("For this sample, this 63-byte string will be used as input data", │ TestSHA512("For this sample, this 63-byte string will be used as input data",
"b3de4afbc516d2478fe9b518d063bda6c8dd65fc38402dd81d1eb7364e72fb6e" │ "b3de4afbc516d2478fe9b518d063bda6c8dd65fc38402dd81d1eb7364e72fb6e"
"6663cf6d2771c8f5a6da09601712fb3d2a36c6ffea3e28b0818b05b0a8660766"); │ "6663cf6d2771c8f5a6da09601712fb3d2a36c6ffea3e28b0818b05b0a8660766");
TestSHA512("This is exactly 64 bytes long, not counting the terminating byte", │ TestSHA512("This is exactly 64 bytes long, not counting the terminating byte",
"70aefeaa0e7ac4f8fe17532d7185a289bee3b428d950c14fa8b713ca09814a38" │ "70aefeaa0e7ac4f8fe17532d7185a289bee3b428d950c14fa8b713ca09814a38"
"7d245870e007a80ad97c369d193e41701aa07f3221d15f0e65a1ff970cedf030"); │ "7d245870e007a80ad97c369d193e41701aa07f3221d15f0e65a1ff970cedf030");
TestSHA512("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmno" │ TestSHA512("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmno"
"ijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu", │ "ijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
"8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018" │ "8e959b75dae313da8cf4f72814fc143f8f7779c6eb9f7fa17299aeadb6889018"
"501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909"); │ "501d289e4900f7e4331b99dec4b5433ac7d329eeb6dd26545e96e55b874be909");
TestSHA512(std::string(1000000, 'a'), │ TestSHA512(std::string(1000000, 'a'),
"e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973eb" │ "e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973eb"
"de0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b"); │ "de0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b");
TestSHA512(test1, │ TestSHA512(test1,
"40cac46c147e6131c5193dd5f34e9d8bb4951395f27b08c558c65ff4ba2de594" │ "40cac46c147e6131c5193dd5f34e9d8bb4951395f27b08c558c65ff4ba2de594"
"37de8c3ef5459d76a52cedc02dc499a3c9ed9dedbfb3281afd9653b8a112fafc"); │ "37de8c3ef5459d76a52cedc02dc499a3c9ed9dedbfb3281afd9653b8a112fafc");
} │
next prev up bitcoin/src/test/streams_tests.cpp:16 │ dogecoin/src/test/streams_tests.cpp:18
│
unsigned char a(1); │ unsigned char a(1);
unsigned char b(2); │ unsigned char b(2);
unsigned char bytes[] = { 3, 4, 5, 6 }; │ unsigned char bytes[] = { 3, 4, 5, 6 };
std::vector<unsigned char> vch; │ std::vector<unsigned char> vch;
│
// Each test runs twice. Serializing a second time at the same starting │ // Each test runs twice. Serializing a second time at the same starting
// point should yield the same results, even if the first test grew the │ // point should yield the same results, even if the first test grew the
// vector. │ // vector.
│
CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 0, a, b); │ CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 0, a, b);
BOOST_CHECK((vch == std::vector<unsigned char>{{1, 2}})); │ BOOST_CHECK((vch == std::vector<unsigned char>{{1, 2}}));
CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 0, a, b); │ CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 0, a, b);
BOOST_CHECK((vch == std::vector<unsigned char>{{1, 2}})); │ BOOST_CHECK((vch == std::vector<unsigned char>{{1, 2}}));
vch.clear(); │ vch.clear();
│
CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 2, a, b); │ CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 2, a, b);
BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 1, 2}})); │ BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 1, 2}}));
CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 2, a, b); │ CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 2, a, b);
BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 1, 2}})); │ BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 1, 2}}));
vch.clear(); │ vch.clear();
│
vch.resize(5, 0); │ vch.resize(5, 0);
CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 2, a, b); │ CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 2, a, b);
BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 1, 2, 0}})); │ BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 1, 2, 0}}));
CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 2, a, b); │ CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 2, a, b);
BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 1, 2, 0}})); │ BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 1, 2, 0}}));
vch.clear(); │ vch.clear();
│
vch.resize(4, 0); │ vch.resize(4, 0);
CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 3, a, b); │ CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 3, a, b);
BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 0, 1, 2}})); │ BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 0, 1, 2}}));
CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 3, a, b); │ CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 3, a, b);
BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 0, 1, 2}})); │ BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 0, 1, 2}}));
vch.clear(); │ vch.clear();
│
vch.resize(4, 0); │ vch.resize(4, 0);
CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 4, a, b); │ CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 4, a, b);
BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 0, 0, 1, 2}})); │ BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 0, 0, 1, 2}}));
CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 4, a, b); │ CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 4, a, b);
BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 0, 0, 1, 2}})); │ BOOST_CHECK((vch == std::vector<unsigned char>{{0, 0, 0, 0, 1, 2}}));
vch.clear(); │ vch.clear();
│
CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 0, bytes); │ CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 0, FLATDATA(bytes));
BOOST_CHECK((vch == std::vector<unsigned char>{{3, 4, 5, 6}})); │ BOOST_CHECK((vch == std::vector<unsigned char>{{3, 4, 5, 6}}));
CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 0, bytes); │ CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 0, FLATDATA(bytes));
BOOST_CHECK((vch == std::vector<unsigned char>{{3, 4, 5, 6}})); │ BOOST_CHECK((vch == std::vector<unsigned char>{{3, 4, 5, 6}}));
vch.clear(); │ vch.clear();
│
vch.resize(4, 8); │ vch.resize(4, 8);
CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 2, a, bytes, b); │ CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 2, a, FLATDATA(bytes), b);
BOOST_CHECK((vch == std::vector<unsigned char>{{8, 8, 1, 3, 4, 5, 6, 2}})); │ BOOST_CHECK((vch == std::vector<unsigned char>{{8, 8, 1, 3, 4, 5, 6, 2}}));
CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 2, a, bytes, b); │ CVectorWriter(SER_NETWORK, INIT_PROTO_VERSION, vch, 2, a, FLATDATA(bytes), b);
BOOST_CHECK((vch == std::vector<unsigned char>{{8, 8, 1, 3, 4, 5, 6, 2}})); │ BOOST_CHECK((vch == std::vector<unsigned char>{{8, 8, 1, 3, 4, 5, 6, 2}}));
vch.clear(); │ vch.clear();
} │
next prev up bitcoin/src/common/bloom.cpp:95 │ dogecoin/src/bloom.cpp:135
│
bool fFound = false; │ bool fFound = false;
// Match if the filter contains the hash of tx │ // Match if the filter contains the hash of tx
// for finding tx when they appear in a block │ // for finding tx when they appear in a block
if (vData.empty()) // zero-size = "match-all" filter │ if (isFull)
return true; │ return true;
│ if (isEmpty)
│ return false;
const uint256& hash = tx.GetHash(); │ const uint256& hash = tx.GetHash();
if (contains(hash)) │ if (contains(hash))
fFound = true; │ fFound = true;
│
for (unsigned int i = 0; i < tx.vout.size(); i++) │ for (unsigned int i = 0; i < tx.vout.size(); i++)
{ │ {
const CTxOut& txout = tx.vout[i]; │ const CTxOut& txout = tx.vout[i];
// Match if the filter contains any arbitrary script data element in any scriptP │ // Match if the filter contains any arbitrary script data element in any scriptP
// If this matches, also add the specific output that was matched. │ // If this matches, also add the specific output that was matched.
// This means clients don't have to update the filter themselves when a new rele │ // This means clients don't have to update the filter themselves when a new rele
// is discovered in order to find spending transactions, which avoids round-trip │ // is discovered in order to find spending transactions, which avoids round-trip
CScript::const_iterator pc = txout.scriptPubKey.begin(); │ CScript::const_iterator pc = txout.scriptPubKey.begin();
std::vector<unsigned char> data; │ std::vector<unsigned char> data;
while (pc < txout.scriptPubKey.end()) │ while (pc < txout.scriptPubKey.end())
{ │ {
opcodetype opcode; │ opcodetype opcode;
if (!txout.scriptPubKey.GetOp(pc, opcode, data)) │ if (!txout.scriptPubKey.GetOp(pc, opcode, data))
break; │ break;
if (data.size() != 0 && contains(data)) │ if (data.size() != 0 && contains(data))
{ │ {
fFound = true; │ fFound = true;
if ((nFlags & BLOOM_UPDATE_MASK) == BLOOM_UPDATE_ALL) │ if ((nFlags & BLOOM_UPDATE_MASK) == BLOOM_UPDATE_ALL)
insert(COutPoint(hash, i)); │ insert(COutPoint(hash, i));
else if ((nFlags & BLOOM_UPDATE_MASK) == BLOOM_UPDATE_P2PUBKEY_ONLY) │ else if ((nFlags & BLOOM_UPDATE_MASK) == BLOOM_UPDATE_P2PUBKEY_ONLY)
{ │ {
│ txnouttype type;
std::vector<std::vector<unsigned char> > vSolutions; │ std::vector<std::vector<unsigned char> > vSolutions;
TxoutType type = Solver(txout.scriptPubKey, vSolutions); │ if (Solver(txout.scriptPubKey, type, vSolutions) &&
if (type == TxoutType::PUBKEY || type == TxoutType::MULTISIG) { │ (type == TX_PUBKEY || type == TX_MULTISIG))
insert(COutPoint(hash, i)); │ insert(COutPoint(hash, i));
} │
} │ }
break; │ break;
} │ }
} │ }
} │ }
│
if (fFound) │ if (fFound)
return true; │ return true;
│
for (const CTxIn& txin : tx.vin) │ BOOST_FOREACH(const CTxIn& txin, tx.vin)
{ │ {
// Match if the filter contains an outpoint tx spends │ // Match if the filter contains an outpoint tx spends
if (contains(txin.prevout)) │ if (contains(txin.prevout))
return true; │ return true;
│
// Match if the filter contains any arbitrary script data element in any scriptS │ // Match if the filter contains any arbitrary script data element in any scriptS
CScript::const_iterator pc = txin.scriptSig.begin(); │ CScript::const_iterator pc = txin.scriptSig.begin();
std::vector<unsigned char> data; │ std::vector<unsigned char> data;
while (pc < txin.scriptSig.end()) │ while (pc < txin.scriptSig.end())
{ │ {
opcodetype opcode; │ opcodetype opcode;
if (!txin.scriptSig.GetOp(pc, opcode, data)) │ if (!txin.scriptSig.GetOp(pc, opcode, data))
break; │ break;
if (data.size() != 0 && contains(data)) │ if (data.size() != 0 && contains(data))
return true; │ return true;
} │ }
} │ }
│
return false; │ return false;
} │
next prev up dogecoin/src/rpc/blockchain.cpp:551 │ dogecoin/src/rpc/blockchain.cpp:487
│
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2) { │ if (request.fHelp || request.params.size() < 1 || request.params.size() > 2) {
throw runtime_error( │ throw runtime_error(
"getmempooldescendants txid (verbose)\n" │ "getmempoolancestors txid (verbose)\n"
"\nIf txid is in the mempool, returns all in-mempool descendants.\n" │ "\nIf txid is in the mempool, returns all in-mempool ancestors.\n"
"\nArguments:\n" │ "\nArguments:\n"
"1. \"txid\" (string, required) The transaction id (must be │ "1. \"txid\" (string, required) The transaction id (must be
"2. verbose (boolean, optional, default=false) True for a j │ "2. verbose (boolean, optional, default=false) True for a j
"\nResult (for verbose=false):\n" │ "\nResult (for verbose=false):\n"
"[ (json array of strings)\n" │ "[ (json array of strings)\n"
" \"transactionid\" (string) The transaction id of an in-mempool │ " \"transactionid\" (string) The transaction id of an in-mempool
" ,...\n" │ " ,...\n"
"]\n" │ "]\n"
"\nResult (for verbose=true):\n" │ "\nResult (for verbose=true):\n"
"{ (json object)\n" │ "{ (json object)\n"
" \"transactionid\" : { (json object)\n" │ " \"transactionid\" : { (json object)\n"
+ EntryDescriptionString() │ + EntryDescriptionString()
+ " }, ...\n" │ + " }, ...\n"
"}\n" │ "}\n"
"\nExamples:\n" │ "\nExamples:\n"
+ HelpExampleCli("getmempooldescendants", "\"mytxid\"") │ + HelpExampleCli("getmempoolancestors", "\"mytxid\"")
+ HelpExampleRpc("getmempooldescendants", "\"mytxid\"") │ + HelpExampleRpc("getmempoolancestors", "\"mytxid\"")
); │ );
} │ }
│
bool fVerbose = false; │ bool fVerbose = false;
if (request.params.size() > 1) │ if (request.params.size() > 1)
fVerbose = request.params[1].get_bool(); │ fVerbose = request.params[1].get_bool();
│
uint256 hash = ParseHashV(request.params[0], "parameter 1"); │ uint256 hash = ParseHashV(request.params[0], "parameter 1");
│
LOCK(mempool.cs); │ LOCK(mempool.cs);
│
CTxMemPool::txiter it = mempool.mapTx.find(hash); │ CTxMemPool::txiter it = mempool.mapTx.find(hash);
if (it == mempool.mapTx.end()) { │ if (it == mempool.mapTx.end()) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not in mempool"); │ throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not in mempool");
} │ }
│
CTxMemPool::setEntries setDescendants; │ CTxMemPool::setEntries setAncestors;
mempool.CalculateDescendants(it, setDescendants); │ uint64_t noLimit = std::numeric_limits<uint64_t>::max();
// CTxMemPool::CalculateDescendants will include the given tx │ std::string dummy;
setDescendants.erase(it); │ mempool.CalculateMemPoolAncestors(*it, setAncestors, noLimit, noLimit, noLimit, noLi
│
if (!fVerbose) { │ if (!fVerbose) {
UniValue o(UniValue::VARR); │ UniValue o(UniValue::VARR);
BOOST_FOREACH(CTxMemPool::txiter descendantIt, setDescendants) { │ BOOST_FOREACH(CTxMemPool::txiter ancestorIt, setAncestors) {
o.push_back(descendantIt->GetTx().GetHash().ToString()); │ o.push_back(ancestorIt->GetTx().GetHash().ToString());
} │ }
│
return o; │ return o;
} else { │ } else {
UniValue o(UniValue::VOBJ); │ UniValue o(UniValue::VOBJ);
BOOST_FOREACH(CTxMemPool::txiter descendantIt, setDescendants) { │ BOOST_FOREACH(CTxMemPool::txiter ancestorIt, setAncestors) {
const CTxMemPoolEntry &e = *descendantIt; │ const CTxMemPoolEntry &e = *ancestorIt;
const uint256& _hash = e.GetTx().GetHash(); │ const uint256& _hash = e.GetTx().GetHash();
UniValue info(UniValue::VOBJ); │ UniValue info(UniValue::VOBJ);
entryToJSON(info, e); │ entryToJSON(info, e);
o.pushKV(_hash.ToString(), info); │ o.pushKV(_hash.ToString(), info);
} │ }
return o; │ return o;
} │ }
} │
next prev up bitcoin/src/wallet/rpc/backup.cpp:1387 │ bitcoin/src/wallet/rpc/backup.cpp:1681
│
int64_t scannedTime = pwallet->RescanFromTime(nLowestTimestamp, reserver, true / │ int64_t scanned_time = pwallet->RescanFromTime(lowest_timestamp, reserver, true
{ │ {
LOCK(pwallet->cs_wallet); │ LOCK(pwallet->cs_wallet);
pwallet->ReacceptWalletTransactions(); │ pwallet->ReacceptWalletTransactions();
} │ }
│
if (pwallet->IsAbortingRescan()) { │ if (pwallet->IsAbortingRescan()) {
throw JSONRPCError(RPC_MISC_ERROR, "Rescan aborted by user."); │ throw JSONRPCError(RPC_MISC_ERROR, "Rescan aborted by user.");
} │ }
if (scannedTime > nLowestTimestamp) { │
│ if (scanned_time > lowest_timestamp) {
std::vector<UniValue> results = response.getValues(); │ std::vector<UniValue> results = response.getValues();
response.clear(); │ response.clear();
response.setArray(); │ response.setArray();
size_t i = 0; │
for (const UniValue& request : requests.getValues()) { │ // Compose the response
// If key creation date is within the successfully scanned │ for (unsigned int i = 0; i < requests.size(); ++i) {
│ const UniValue& request = requests.getValues().at(i);
│
│ // If the descriptor timestamp is within the successfully scanned
// range, or if the import result already has an error set, let │ // range, or if the import result already has an error set, let
// the result stand unmodified. Otherwise replace the result │ // the result stand unmodified. Otherwise replace the result
// with an error message. │ // with an error message.
if (scannedTime <= GetImportTimestamp(request, now) || results.at(i).exi │ if (scanned_time <= GetImportTimestamp(request, now) || results.at(i).ex
response.push_back(results.at(i)); │ response.push_back(results.at(i));
} else { │ } else {
UniValue result = UniValue(UniValue::VOBJ); │ UniValue result = UniValue(UniValue::VOBJ);
result.pushKV("success", UniValue(false)); │ result.pushKV("success", UniValue(false));
result.pushKV( │ result.pushKV(
"error", │ "error",
JSONRPCError( │ JSONRPCError(
RPC_MISC_ERROR, │ RPC_MISC_ERROR,
strprintf("Rescan failed for key with creation timestamp %d. │ strprintf("Rescan failed for descriptor with timestamp %d. T
"block from time %d, which is after or within %d s │ "block from time %d, which is after or within %d s
"could contain transactions pertaining to the key. │ "could contain transactions pertaining to the desc
"and coins using this key may not appear in the wa │ "and coins using this desc may not appear in the w
"caused by pruning or data corruption (see bitcoin │ "caused by pruning or data corruption (see bitcoin
"be dealt with by downloading and rescanning the r │ "be dealt with by downloading and rescanning the r
"option and rescanblockchain RPC).", │ "option and rescanblockchain RPC).",
GetImportTimestamp(request, now), scannedTime - TIMESTAM │ GetImportTimestamp(request, now), scanned_time - TIMESTA
response.push_back(std::move(result)); │ response.push_back(std::move(result));
} │ }
++i; │
} │ }
} │ }
} │
next prev up dogecoin/src/test/arith_uint256_tests.cpp:68 │ bitcoin/src/test/arith_uint256_tests.cpp:69
│
BOOST_CHECK(1 == 0+1); │ BOOST_CHECK(1 == 0+1);
// constructor arith_uint256(vector<char>): │ // constructor arith_uint256(vector<char>):
BOOST_CHECK(R1L.ToString() == ArrayToString(R1Array,32)); │ BOOST_CHECK(R1L.ToString() == ArrayToString(R1Array,32));
BOOST_CHECK(R2L.ToString() == ArrayToString(R2Array,32)); │ BOOST_CHECK(R2L.ToString() == ArrayToString(R2Array,32));
BOOST_CHECK(ZeroL.ToString() == ArrayToString(ZeroArray,32)); │ BOOST_CHECK(ZeroL.ToString() == ArrayToString(ZeroArray,32));
BOOST_CHECK(OneL.ToString() == ArrayToString(OneArray,32)); │ BOOST_CHECK(OneL.ToString() == ArrayToString(OneArray,32));
BOOST_CHECK(MaxL.ToString() == ArrayToString(MaxArray,32)); │ BOOST_CHECK(MaxL.ToString() == ArrayToString(MaxArray,32));
BOOST_CHECK(OneL.ToString() != ArrayToString(ZeroArray,32)); │ BOOST_CHECK(OneL.ToString() != ArrayToString(ZeroArray,32));
│
// == and != │ // == and !=
BOOST_CHECK(R1L != R2L); │ BOOST_CHECK(R1L != R2L);
BOOST_CHECK(ZeroL != OneL); │ BOOST_CHECK(ZeroL != OneL);
BOOST_CHECK(OneL != ZeroL); │ BOOST_CHECK(OneL != ZeroL);
BOOST_CHECK(MaxL != ZeroL); │ BOOST_CHECK(MaxL != ZeroL);
BOOST_CHECK(~MaxL == ZeroL); │ BOOST_CHECK(~MaxL == ZeroL);
BOOST_CHECK( ((R1L ^ R2L) ^ R1L) == R2L); │ BOOST_CHECK( ((R1L ^ R2L) ^ R1L) == R2L);
│
uint64_t Tmp64 = 0xc4dab720d9c7acaaULL; │ uint64_t Tmp64 = 0xc4dab720d9c7acaaULL;
for (unsigned int i = 0; i < 256; ++i) │ for (unsigned int i = 0; i < 256; ++i)
{ │ {
BOOST_CHECK(ZeroL != (OneL << i)); │ BOOST_CHECK(ZeroL != (OneL << i));
BOOST_CHECK((OneL << i) != ZeroL); │ BOOST_CHECK((OneL << i) != ZeroL);
BOOST_CHECK(R1L != (R1L ^ (OneL << i))); │ BOOST_CHECK(R1L != (R1L ^ (OneL << i)));
BOOST_CHECK(((arith_uint256(Tmp64) ^ (OneL << i) ) != Tmp64 )); │ BOOST_CHECK(((arith_uint256(Tmp64) ^ (OneL << i) ) != Tmp64 ));
} │ }
BOOST_CHECK(ZeroL == (OneL << 256)); │ BOOST_CHECK(ZeroL == (OneL << 256));
│
// String Constructor and Copy Constructor │ // String Constructor and Copy Constructor
BOOST_CHECK(arith_uint256("0x"+R1L.ToString()) == R1L); │ BOOST_CHECK(arith_uint256("0x"+R1L.ToString()) == R1L);
BOOST_CHECK(arith_uint256("0x"+R2L.ToString()) == R2L); │ BOOST_CHECK(arith_uint256("0x"+R2L.ToString()) == R2L);
BOOST_CHECK(arith_uint256("0x"+ZeroL.ToString()) == ZeroL); │ BOOST_CHECK(arith_uint256("0x"+ZeroL.ToString()) == ZeroL);
BOOST_CHECK(arith_uint256("0x"+OneL.ToString()) == OneL); │ BOOST_CHECK(arith_uint256("0x"+OneL.ToString()) == OneL);
BOOST_CHECK(arith_uint256("0x"+MaxL.ToString()) == MaxL); │ BOOST_CHECK(arith_uint256("0x"+MaxL.ToString()) == MaxL);
BOOST_CHECK(arith_uint256(R1L.ToString()) == R1L); │ BOOST_CHECK(arith_uint256(R1L.ToString()) == R1L);
BOOST_CHECK(arith_uint256(" 0x"+R1L.ToString()+" ") == R1L); │ BOOST_CHECK(arith_uint256(" 0x"+R1L.ToString()+" ") == R1L);
BOOST_CHECK(arith_uint256("") == ZeroL); │ BOOST_CHECK(arith_uint256("") == ZeroL);
BOOST_CHECK(R1L == arith_uint256(R1ArrayHex)); │ BOOST_CHECK(R1L == arith_uint256(R1ArrayHex));
BOOST_CHECK(arith_uint256(R1L) == R1L); │ BOOST_CHECK(arith_uint256(R1L) == R1L);
BOOST_CHECK((arith_uint256(R1L^R2L)^R2L) == R1L); │ BOOST_CHECK((arith_uint256(R1L^R2L)^R2L) == R1L);
BOOST_CHECK(arith_uint256(ZeroL) == ZeroL); │ BOOST_CHECK(arith_uint256(ZeroL) == ZeroL);
BOOST_CHECK(arith_uint256(OneL) == OneL); │ BOOST_CHECK(arith_uint256(OneL) == OneL);
│
// uint64_t constructor │ // uint64_t constructor
BOOST_CHECK( (R1L & arith_uint256("0xffffffffffffffff")) == arith_uint256(R1LLow64)) │ BOOST_CHECK( (R1L & arith_uint256("0xffffffffffffffff")) == arith_uint256(R1LLow64))
BOOST_CHECK(ZeroL == arith_uint256(0)); │ BOOST_CHECK(ZeroL == arith_uint256(0));
BOOST_CHECK(OneL == arith_uint256(1)); │ BOOST_CHECK(OneL == arith_uint256(1));
BOOST_CHECK(arith_uint256("0xffffffffffffffff") == arith_uint256(0xffffffffffffffffU │ BOOST_CHECK(arith_uint256("0xffffffffffffffff") == arith_uint256(0xffffffffffffffffU
│
// Assignment (from base_uint) │ // Assignment (from base_uint)
arith_uint256 tmpL = ~ZeroL; BOOST_CHECK(tmpL == ~ZeroL); │ arith_uint256 tmpL = ~ZeroL; BOOST_CHECK(tmpL == ~ZeroL);
tmpL = ~OneL; BOOST_CHECK(tmpL == ~OneL); │ tmpL = ~OneL; BOOST_CHECK(tmpL == ~OneL);
tmpL = ~R1L; BOOST_CHECK(tmpL == ~R1L); │ tmpL = ~R1L; BOOST_CHECK(tmpL == ~R1L);
tmpL = ~R2L; BOOST_CHECK(tmpL == ~R2L); │ tmpL = ~R2L; BOOST_CHECK(tmpL == ~R2L);
tmpL = ~MaxL; BOOST_CHECK(tmpL == ~MaxL); │ tmpL = ~MaxL; BOOST_CHECK(tmpL == ~MaxL);
} │
next prev up bitcoin/src/rpc/mempool.cpp:493 │ bitcoin/src/rpc/mempool.cpp:429
│
return RPCHelpMan{"getmempooldescendants", │ return RPCHelpMan{"getmempoolancestors",
"\nIf txid is in the mempool, returns all in-mempool descendants.\n", │ "\nIf txid is in the mempool, returns all in-mempool ancestors.\n",
{ │ {
{"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id (m │ {"txid", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The transaction id (m
{"verbose", RPCArg::Type::BOOL, RPCArg::Default{false}, "True for a json obj │ {"verbose", RPCArg::Type::BOOL, RPCArg::Default{false}, "True for a json obj
}, │ },
{ │ {
RPCResult{"for verbose = false", │ RPCResult{"for verbose = false",
RPCResult::Type::ARR, "", "", │ RPCResult::Type::ARR, "", "",
{{RPCResult::Type::STR_HEX, "", "The transaction id of an in-mempool des │ {{RPCResult::Type::STR_HEX, "", "The transaction id of an in-mempool anc
RPCResult{"for verbose = true", │ RPCResult{"for verbose = true",
RPCResult::Type::OBJ_DYN, "", "", │ RPCResult::Type::OBJ_DYN, "", "",
{ │ {
{RPCResult::Type::OBJ, "transactionid", "", MempoolEntryDescription( │ {RPCResult::Type::OBJ, "transactionid", "", MempoolEntryDescription(
}}, │ }},
}, │ },
RPCExamples{ │ RPCExamples{
HelpExampleCli("getmempooldescendants", "\"mytxid\"") │ HelpExampleCli("getmempoolancestors", "\"mytxid\"")
+ HelpExampleRpc("getmempooldescendants", "\"mytxid\"") │ + HelpExampleRpc("getmempoolancestors", "\"mytxid\"")
}, │ },
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue │ [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{ │ {
bool fVerbose = false; │ bool fVerbose = false;
if (!request.params[1].isNull()) │ if (!request.params[1].isNull())
fVerbose = request.params[1].get_bool(); │ fVerbose = request.params[1].get_bool();
│
uint256 hash = ParseHashV(request.params[0], "parameter 1"); │ uint256 hash = ParseHashV(request.params[0], "parameter 1");
│
const CTxMemPool& mempool = EnsureAnyMemPool(request.context); │ const CTxMemPool& mempool = EnsureAnyMemPool(request.context);
LOCK(mempool.cs); │ LOCK(mempool.cs);
│
CTxMemPool::txiter it = mempool.mapTx.find(hash); │ CTxMemPool::txiter it = mempool.mapTx.find(hash);
if (it == mempool.mapTx.end()) { │ if (it == mempool.mapTx.end()) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not in mempool"); │ throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Transaction not in mempool");
} │ }
│
CTxMemPool::setEntries setDescendants; │ CTxMemPool::setEntries setAncestors;
mempool.CalculateDescendants(it, setDescendants); │ uint64_t noLimit = std::numeric_limits<uint64_t>::max();
// CTxMemPool::CalculateDescendants will include the given tx │ std::string dummy;
setDescendants.erase(it); │ mempool.CalculateMemPoolAncestors(*it, setAncestors, noLimit, noLimit, noLimit, noLi
│
if (!fVerbose) { │ if (!fVerbose) {
UniValue o(UniValue::VARR); │ UniValue o(UniValue::VARR);
for (CTxMemPool::txiter descendantIt : setDescendants) { │ for (CTxMemPool::txiter ancestorIt : setAncestors) {
o.push_back(descendantIt->GetTx().GetHash().ToString()); │ o.push_back(ancestorIt->GetTx().GetHash().ToString());
} │ }
│
return o; │ return o;
} else { │ } else {
UniValue o(UniValue::VOBJ); │ UniValue o(UniValue::VOBJ);
for (CTxMemPool::txiter descendantIt : setDescendants) { │ for (CTxMemPool::txiter ancestorIt : setAncestors) {
const CTxMemPoolEntry &e = *descendantIt; │ const CTxMemPoolEntry &e = *ancestorIt;
const uint256& _hash = e.GetTx().GetHash(); │ const uint256& _hash = e.GetTx().GetHash();
UniValue info(UniValue::VOBJ); │ UniValue info(UniValue::VOBJ);
entryToJSON(mempool, info, e); │ entryToJSON(mempool, info, e);
o.pushKV(_hash.ToString(), info); │ o.pushKV(_hash.ToString(), info);
} │ }
return o; │ return o;
} │ }
}, │ },
}; │ };
} │
next prev up bitcoin/src/script/interpreter.cpp:1569 │ dogecoin/src/script/interpreter.cpp:1179
│
assert(nIn < txTo.vin.size()); │ if (sigversion == SIGVERSION_WITNESS_V0) {
│
if (sigversion == SigVersion::WITNESS_V0) { │
uint256 hashPrevouts; │ uint256 hashPrevouts;
uint256 hashSequence; │ uint256 hashSequence;
uint256 hashOutputs; │ uint256 hashOutputs;
const bool cacheready = cache && cache->m_bip143_segwit_ready; │
│
if (!(nHashType & SIGHASH_ANYONECANPAY)) { │ if (!(nHashType & SIGHASH_ANYONECANPAY)) {
hashPrevouts = cacheready ? cache->hashPrevouts : SHA256Uint256(GetPrevoutsS │ hashPrevouts = cache ? cache->hashPrevouts : GetPrevoutHash(txTo);
} │ }
│
if (!(nHashType & SIGHASH_ANYONECANPAY) && (nHashType & 0x1f) != SIGHASH_SINGLE │ if (!(nHashType & SIGHASH_ANYONECANPAY) && (nHashType & 0x1f) != SIGHASH_SINGLE
hashSequence = cacheready ? cache->hashSequence : SHA256Uint256(GetSequences │ hashSequence = cache ? cache->hashSequence : GetSequenceHash(txTo);
} │ }
│
│
if ((nHashType & 0x1f) != SIGHASH_SINGLE && (nHashType & 0x1f) != SIGHASH_NONE) │ if ((nHashType & 0x1f) != SIGHASH_SINGLE && (nHashType & 0x1f) != SIGHASH_NONE)
hashOutputs = cacheready ? cache->hashOutputs : SHA256Uint256(GetOutputsSHA2 │ hashOutputs = cache ? cache->hashOutputs : GetOutputsHash(txTo);
} else if ((nHashType & 0x1f) == SIGHASH_SINGLE && nIn < txTo.vout.size()) { │ } else if ((nHashType & 0x1f) == SIGHASH_SINGLE && nIn < txTo.vout.size()) {
CHashWriter ss(SER_GETHASH, 0); │ CHashWriter ss(SER_GETHASH, 0);
ss << txTo.vout[nIn]; │ ss << txTo.vout[nIn];
hashOutputs = ss.GetHash(); │ hashOutputs = ss.GetHash();
} │ }
│
CHashWriter ss(SER_GETHASH, 0); │ CHashWriter ss(SER_GETHASH, 0);
// Version │ // Version
ss << txTo.nVersion; │ ss << txTo.nVersion;
// Input prevouts/nSequence (none/all, depending on flags) │ // Input prevouts/nSequence (none/all, depending on flags)
ss << hashPrevouts; │ ss << hashPrevouts;
ss << hashSequence; │ ss << hashSequence;
// The input being signed (replacing the scriptSig with scriptCode + amount) │ // The input being signed (replacing the scriptSig with scriptCode + amount)
// The prevout may already be contained in hashPrevout, and the nSequence │ // The prevout may already be contained in hashPrevout, and the nSequence
// may already be contain in hashSequence. │ // may already be contain in hashSequence.
ss << txTo.vin[nIn].prevout; │ ss << txTo.vin[nIn].prevout;
ss << scriptCode; │ ss << static_cast<const CScriptBase&>(scriptCode);
ss << amount; │ ss << amount;
ss << txTo.vin[nIn].nSequence; │ ss << txTo.vin[nIn].nSequence;
// Outputs (none/one/all, depending on flags) │ // Outputs (none/one/all, depending on flags)
ss << hashOutputs; │ ss << hashOutputs;
// Locktime │ // Locktime
ss << txTo.nLockTime; │ ss << txTo.nLockTime;
// Sighash type │ // Sighash type
ss << nHashType; │ ss << nHashType;
│
return ss.GetHash(); │ return ss.GetHash();
} │ }
│
│ static const uint256 one(uint256S("0000000000000000000000000000000000000000000000000
│ if (nIn >= txTo.vin.size()) {
│ // nIn out of range
│ return one;
│ }
│
// Check for invalid use of SIGHASH_SINGLE │ // Check for invalid use of SIGHASH_SINGLE
if ((nHashType & 0x1f) == SIGHASH_SINGLE) { │ if ((nHashType & 0x1f) == SIGHASH_SINGLE) {
if (nIn >= txTo.vout.size()) { │ if (nIn >= txTo.vout.size()) {
// nOut out of range │ // nOut out of range
return uint256::ONE; │ return one;
} │ }
} │ }
│
// Wrapper to serialize only the necessary parts of the transaction being signed │ // Wrapper to serialize only the necessary parts of the transaction being signed
CTransactionSignatureSerializer<T> txTmp(txTo, scriptCode, nIn, nHashType); │ CTransactionSignatureSerializer txTmp(txTo, scriptCode, nIn, nHashType);
│
// Serialize and hash │ // Serialize and hash
CHashWriter ss(SER_GETHASH, 0); │ CHashWriter ss(SER_GETHASH, 0);
ss << txTmp << nHashType; │ ss << txTmp << nHashType;
return ss.GetHash(); │ return ss.GetHash();
} │
next prev up dogecoin/src/test/uint256_tests.cpp:76 │ bitcoin/src/test/uint256_tests.cpp:76
│
BOOST_CHECK(1 == 0+1); │ BOOST_CHECK(1 == 0+1);
// constructor uint256(vector<char>): │ // constructor uint256(vector<char>):
BOOST_CHECK(R1L.ToString() == ArrayToString(R1Array,32)); │ BOOST_CHECK(R1L.ToString() == ArrayToString(R1Array,32));
BOOST_CHECK(R1S.ToString() == ArrayToString(R1Array,20)); │ BOOST_CHECK(R1S.ToString() == ArrayToString(R1Array,20));
BOOST_CHECK(R2L.ToString() == ArrayToString(R2Array,32)); │ BOOST_CHECK(R2L.ToString() == ArrayToString(R2Array,32));
BOOST_CHECK(R2S.ToString() == ArrayToString(R2Array,20)); │ BOOST_CHECK(R2S.ToString() == ArrayToString(R2Array,20));
BOOST_CHECK(ZeroL.ToString() == ArrayToString(ZeroArray,32)); │ BOOST_CHECK(ZeroL.ToString() == ArrayToString(ZeroArray,32));
BOOST_CHECK(ZeroS.ToString() == ArrayToString(ZeroArray,20)); │ BOOST_CHECK(ZeroS.ToString() == ArrayToString(ZeroArray,20));
BOOST_CHECK(OneL.ToString() == ArrayToString(OneArray,32)); │ BOOST_CHECK(OneL.ToString() == ArrayToString(OneArray,32));
BOOST_CHECK(OneS.ToString() == ArrayToString(OneArray,20)); │ BOOST_CHECK(OneS.ToString() == ArrayToString(OneArray,20));
BOOST_CHECK(MaxL.ToString() == ArrayToString(MaxArray,32)); │ BOOST_CHECK(MaxL.ToString() == ArrayToString(MaxArray,32));
BOOST_CHECK(MaxS.ToString() == ArrayToString(MaxArray,20)); │ BOOST_CHECK(MaxS.ToString() == ArrayToString(MaxArray,20));
BOOST_CHECK(OneL.ToString() != ArrayToString(ZeroArray,32)); │ BOOST_CHECK(OneL.ToString() != ArrayToString(ZeroArray,32));
BOOST_CHECK(OneS.ToString() != ArrayToString(ZeroArray,20)); │ BOOST_CHECK(OneS.ToString() != ArrayToString(ZeroArray,20));
│
// == and != │ // == and !=
BOOST_CHECK(R1L != R2L && R1S != R2S); │ BOOST_CHECK(R1L != R2L && R1S != R2S);
BOOST_CHECK(ZeroL != OneL && ZeroS != OneS); │ BOOST_CHECK(ZeroL != OneL && ZeroS != OneS);
BOOST_CHECK(OneL != ZeroL && OneS != ZeroS); │ BOOST_CHECK(OneL != ZeroL && OneS != ZeroS);
BOOST_CHECK(MaxL != ZeroL && MaxS != ZeroS); │ BOOST_CHECK(MaxL != ZeroL && MaxS != ZeroS);
│
// String Constructor and Copy Constructor │ // String Constructor and Copy Constructor
BOOST_CHECK(uint256S("0x"+R1L.ToString()) == R1L); │ BOOST_CHECK(uint256S("0x"+R1L.ToString()) == R1L);
BOOST_CHECK(uint256S("0x"+R2L.ToString()) == R2L); │ BOOST_CHECK(uint256S("0x"+R2L.ToString()) == R2L);
BOOST_CHECK(uint256S("0x"+ZeroL.ToString()) == ZeroL); │ BOOST_CHECK(uint256S("0x"+ZeroL.ToString()) == ZeroL);
BOOST_CHECK(uint256S("0x"+OneL.ToString()) == OneL); │ BOOST_CHECK(uint256S("0x"+OneL.ToString()) == OneL);
BOOST_CHECK(uint256S("0x"+MaxL.ToString()) == MaxL); │ BOOST_CHECK(uint256S("0x"+MaxL.ToString()) == MaxL);
BOOST_CHECK(uint256S(R1L.ToString()) == R1L); │ BOOST_CHECK(uint256S(R1L.ToString()) == R1L);
BOOST_CHECK(uint256S(" 0x"+R1L.ToString()+" ") == R1L); │ BOOST_CHECK(uint256S(" 0x"+R1L.ToString()+" ") == R1L);
BOOST_CHECK(uint256S("") == ZeroL); │ BOOST_CHECK(uint256S("") == ZeroL);
BOOST_CHECK(R1L == uint256S(R1ArrayHex)); │ BOOST_CHECK(R1L == uint256S(R1ArrayHex));
BOOST_CHECK(uint256(R1L) == R1L); │ BOOST_CHECK(uint256(R1L) == R1L);
BOOST_CHECK(uint256(ZeroL) == ZeroL); │ BOOST_CHECK(uint256(ZeroL) == ZeroL);
BOOST_CHECK(uint256(OneL) == OneL); │ BOOST_CHECK(uint256(OneL) == OneL);
│
BOOST_CHECK(uint160S("0x"+R1S.ToString()) == R1S); │ BOOST_CHECK(uint160S("0x"+R1S.ToString()) == R1S);
BOOST_CHECK(uint160S("0x"+R2S.ToString()) == R2S); │ BOOST_CHECK(uint160S("0x"+R2S.ToString()) == R2S);
BOOST_CHECK(uint160S("0x"+ZeroS.ToString()) == ZeroS); │ BOOST_CHECK(uint160S("0x"+ZeroS.ToString()) == ZeroS);
BOOST_CHECK(uint160S("0x"+OneS.ToString()) == OneS); │ BOOST_CHECK(uint160S("0x"+OneS.ToString()) == OneS);
BOOST_CHECK(uint160S("0x"+MaxS.ToString()) == MaxS); │ BOOST_CHECK(uint160S("0x"+MaxS.ToString()) == MaxS);
BOOST_CHECK(uint160S(R1S.ToString()) == R1S); │ BOOST_CHECK(uint160S(R1S.ToString()) == R1S);
BOOST_CHECK(uint160S(" 0x"+R1S.ToString()+" ") == R1S); │ BOOST_CHECK(uint160S(" 0x"+R1S.ToString()+" ") == R1S);
BOOST_CHECK(uint160S("") == ZeroS); │ BOOST_CHECK(uint160S("") == ZeroS);
BOOST_CHECK(R1S == uint160S(R1ArrayHex)); │ BOOST_CHECK(R1S == uint160S(R1ArrayHex));
│
BOOST_CHECK(uint160(R1S) == R1S); │ BOOST_CHECK(uint160(R1S) == R1S);
BOOST_CHECK(uint160(ZeroS) == ZeroS); │ BOOST_CHECK(uint160(ZeroS) == ZeroS);
BOOST_CHECK(uint160(OneS) == OneS); │ BOOST_CHECK(uint160(OneS) == OneS);
} │
next prev up dogecoin/src/test/transaction_tests.cpp:266 │ bitcoin/src/test/transaction_tests.cpp:368
│
// Random real transaction (e2769b09e784f32f62ef849763d4f45b98e07ba658647343b915ff83 │ // Random real transaction (e2769b09e784f32f62ef849763d4f45b98e07ba658647343b915ff83
unsigned char ch[] = {0x01, 0x00, 0x00, 0x00, 0x01, 0x6b, 0xff, 0x7f, 0xcd, 0x4f, 0x │ unsigned char ch[] = {0x01, 0x00, 0x00, 0x00, 0x01, 0x6b, 0xff, 0x7f, 0xcd, 0x4f, 0x
std::vector<unsigned char> vch(ch, ch + sizeof(ch) -1); │ std::vector<unsigned char> vch(ch, ch + sizeof(ch) -1);
CDataStream stream(vch, SER_DISK, CLIENT_VERSION); │ CDataStream stream(vch, SER_DISK, CLIENT_VERSION);
CMutableTransaction tx; │ CMutableTransaction tx;
stream >> tx; │ stream >> tx;
CValidationState state; │ TxValidationState state;
BOOST_CHECK_MESSAGE(CheckTransaction(tx, state) && state.IsValid(), "Simple deserial │ BOOST_CHECK_MESSAGE(CheckTransaction(CTransaction(tx), state) && state.IsValid(), "S
│
// Check that duplicate txins fail │ // Check that duplicate txins fail
tx.vin.push_back(tx.vin[0]); │ tx.vin.push_back(tx.vin[0]);
BOOST_CHECK_MESSAGE(!CheckTransaction(tx, state) || !state.IsValid(), "Transaction w │ BOOST_CHECK_MESSAGE(!CheckTransaction(CTransaction(tx), state) || !state.IsValid(),
} │
next prev up bitcoin/src/qt/sendcoinsdialog.cpp:971 │ dogecoin/src/qt/sendcoinsdialog.cpp:760
│
if (model && model->getAddressTableModel()) │ if (model && model->getAddressTableModel())
{ │ {
// Default to no change address until verified │ // Default to no change address until verified
m_coin_control->destChange = CNoDestination(); │ CoinControlDialog::coinControl->destChange = CNoDestination();
ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}"); │ ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}");
│
const CTxDestination dest = DecodeDestination(text.toStdString()); │ CBitcoinAddress addr = CBitcoinAddress(text.toStdString());
│
if (text.isEmpty()) // Nothing entered │ if (text.isEmpty()) // Nothing entered
{ │ {
ui->labelCoinControlChangeLabel->setText(""); │ ui->labelCoinControlChangeLabel->setText("");
} │ }
else if (!IsValidDestination(dest)) // Invalid address │ else if (!addr.IsValid()) // Invalid address
{ │ {
ui->labelCoinControlChangeLabel->setText(tr("Warning: Invalid Bitcoin addres │ ui->labelCoinControlChangeLabel->setText(tr("Warning: Invalid Dogecoin addre
} │ }
else // Valid address │ else // Valid address
{ │ {
if (!model->wallet().isSpendable(dest)) { │ CKeyID keyid;
│ addr.GetKeyID(keyid);
│ if (!model->havePrivKey(keyid)) // Unknown change address
│ {
ui->labelCoinControlChangeLabel->setText(tr("Warning: Unknown change add │ ui->labelCoinControlChangeLabel->setText(tr("Warning: Unknown change add
│
// confirmation dialog │ // confirmation dialog
QMessageBox::StandardButton btnRetVal = QMessageBox::question(this, tr(" │ QMessageBox::StandardButton btnRetVal = QMessageBox::question(this, tr("
QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel); │ QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Cancel);
│
if(btnRetVal == QMessageBox::Yes) │ if(btnRetVal == QMessageBox::Yes)
m_coin_control->destChange = dest; │ CoinControlDialog::coinControl->destChange = addr.Get();
else │ else
{ │ {
ui->lineEditCoinControlChange->setText(""); │ ui->lineEditCoinControlChange->setText("");
ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:black;} │ ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:black;}
ui->labelCoinControlChangeLabel->setText(""); │ ui->labelCoinControlChangeLabel->setText("");
} │ }
} │ }
else // Known change address │ else // Known change address
{ │ {
ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:black;}"); │ ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:black;}");
│
// Query label │ // Query label
QString associatedLabel = model->getAddressTableModel()->labelForAddress │ QString associatedLabel = model->getAddressTableModel()->labelForAddress
if (!associatedLabel.isEmpty()) │ if (!associatedLabel.isEmpty())
ui->labelCoinControlChangeLabel->setText(associatedLabel); │ ui->labelCoinControlChangeLabel->setText(associatedLabel);
else │ else
ui->labelCoinControlChangeLabel->setText(tr("(no label)")); │ ui->labelCoinControlChangeLabel->setText(tr("(no label)"));
│
m_coin_control->destChange = dest; │ CoinControlDialog::coinControl->destChange = addr.Get();
} │ }
} │ }
} │ }
} │
next prev up dogecoin/src/qt/addresstablemodel.cpp:240 │ bitcoin/src/qt/addresstablemodel.cpp:238
│
if(!index.isValid()) │ if(!index.isValid())
return false; │ return false;
AddressTableEntry *rec = static_cast<AddressTableEntry*>(index.internalPointer()); │ AddressTableEntry *rec = static_cast<AddressTableEntry*>(index.internalPointer());
std::string strPurpose = (rec->type == AddressTableEntry::Sending ? "send" : "receiv │ std::string strPurpose = (rec->type == AddressTableEntry::Sending ? "send" : "receiv
editStatus = OK; │ editStatus = OK;
│
if(role == Qt::EditRole) │ if(role == Qt::EditRole)
{ │ {
LOCK(wallet->cs_wallet); /* For SetAddressBook / DelAddressBook */ │ CTxDestination curAddress = DecodeDestination(rec->address.toStdString());
CTxDestination curAddress = CBitcoinAddress(rec->address.toStdString()).Get(); │
if(index.column() == Label) │ if(index.column() == Label)
{ │ {
// Do nothing, if old label == new label │ // Do nothing, if old label == new label
if(rec->label == value.toString()) │ if(rec->label == value.toString())
{ │ {
editStatus = NO_CHANGES; │ editStatus = NO_CHANGES;
return false; │ return false;
} │ }
wallet->SetAddressBook(curAddress, value.toString().toStdString(), strPurpos │ walletModel->wallet().setAddressBook(curAddress, value.toString().toStdStrin
} else if(index.column() == Address) { │ } else if(index.column() == Address) {
CTxDestination newAddress = CBitcoinAddress(value.toString().toStdString()). │ CTxDestination newAddress = DecodeDestination(value.toString().toStdString()
// Refuse to set invalid address, set error status and return false │ // Refuse to set invalid address, set error status and return false
if(boost::get<CNoDestination>(&newAddress)) │ if(std::get_if<CNoDestination>(&newAddress))
{ │ {
editStatus = INVALID_ADDRESS; │ editStatus = INVALID_ADDRESS;
return false; │ return false;
} │ }
// Do nothing, if old address == new address │ // Do nothing, if old address == new address
else if(newAddress == curAddress) │ else if(newAddress == curAddress)
{ │ {
editStatus = NO_CHANGES; │ editStatus = NO_CHANGES;
return false; │ return false;
} │ }
// Check for duplicate addresses to prevent accidental deletion of addresses │ // Check for duplicate addresses to prevent accidental deletion of addresses
// to paste an existing address over another address (with a different label │ // to paste an existing address over another address (with a different label
else if(wallet->mapAddressBook.count(newAddress)) │ if (walletModel->wallet().getAddress(
│ newAddress, /* name= */ nullptr, /* is_mine= */ nullptr, /* purpose=
{ │ {
editStatus = DUPLICATE_ADDRESS; │ editStatus = DUPLICATE_ADDRESS;
return false; │ return false;
} │ }
// Double-check that we're not overwriting a receiving address │ // Double-check that we're not overwriting a receiving address
else if(rec->type == AddressTableEntry::Sending) │ else if(rec->type == AddressTableEntry::Sending)
{ │ {
// Remove old entry │ // Remove old entry
wallet->DelAddressBook(curAddress); │ walletModel->wallet().delAddressBook(curAddress);
// Add new entry with new address │ // Add new entry with new address
wallet->SetAddressBook(newAddress, rec->label.toStdString(), strPurpose) │ walletModel->wallet().setAddressBook(newAddress, value.toString().toStdS
} │ }
} │ }
return true; │ return true;
} │ }
return false; │ return false;
} │
next prev up dogecoin/src/test/script_tests.cpp:59 │ bitcoin/src/test/script_tests.cpp:62
│
{SCRIPT_ERR_OK, "OK"}, │ {SCRIPT_ERR_OK, "OK"},
{SCRIPT_ERR_UNKNOWN_ERROR, "UNKNOWN_ERROR"}, │ {SCRIPT_ERR_UNKNOWN_ERROR, "UNKNOWN_ERROR"},
{SCRIPT_ERR_EVAL_FALSE, "EVAL_FALSE"}, │ {SCRIPT_ERR_EVAL_FALSE, "EVAL_FALSE"},
{SCRIPT_ERR_OP_RETURN, "OP_RETURN"}, │ {SCRIPT_ERR_OP_RETURN, "OP_RETURN"},
{SCRIPT_ERR_SCRIPT_SIZE, "SCRIPT_SIZE"}, │ {SCRIPT_ERR_SCRIPT_SIZE, "SCRIPT_SIZE"},
{SCRIPT_ERR_PUSH_SIZE, "PUSH_SIZE"}, │ {SCRIPT_ERR_PUSH_SIZE, "PUSH_SIZE"},
{SCRIPT_ERR_OP_COUNT, "OP_COUNT"}, │ {SCRIPT_ERR_OP_COUNT, "OP_COUNT"},
{SCRIPT_ERR_STACK_SIZE, "STACK_SIZE"}, │ {SCRIPT_ERR_STACK_SIZE, "STACK_SIZE"},
{SCRIPT_ERR_SIG_COUNT, "SIG_COUNT"}, │ {SCRIPT_ERR_SIG_COUNT, "SIG_COUNT"},
{SCRIPT_ERR_PUBKEY_COUNT, "PUBKEY_COUNT"}, │ {SCRIPT_ERR_PUBKEY_COUNT, "PUBKEY_COUNT"},
{SCRIPT_ERR_VERIFY, "VERIFY"}, │ {SCRIPT_ERR_VERIFY, "VERIFY"},
{SCRIPT_ERR_EQUALVERIFY, "EQUALVERIFY"}, │ {SCRIPT_ERR_EQUALVERIFY, "EQUALVERIFY"},
{SCRIPT_ERR_CHECKMULTISIGVERIFY, "CHECKMULTISIGVERIFY"}, │ {SCRIPT_ERR_CHECKMULTISIGVERIFY, "CHECKMULTISIGVERIFY"},
{SCRIPT_ERR_CHECKSIGVERIFY, "CHECKSIGVERIFY"}, │ {SCRIPT_ERR_CHECKSIGVERIFY, "CHECKSIGVERIFY"},
{SCRIPT_ERR_NUMEQUALVERIFY, "NUMEQUALVERIFY"}, │ {SCRIPT_ERR_NUMEQUALVERIFY, "NUMEQUALVERIFY"},
{SCRIPT_ERR_BAD_OPCODE, "BAD_OPCODE"}, │ {SCRIPT_ERR_BAD_OPCODE, "BAD_OPCODE"},
{SCRIPT_ERR_DISABLED_OPCODE, "DISABLED_OPCODE"}, │ {SCRIPT_ERR_DISABLED_OPCODE, "DISABLED_OPCODE"},
{SCRIPT_ERR_INVALID_STACK_OPERATION, "INVALID_STACK_OPERATION"}, │ {SCRIPT_ERR_INVALID_STACK_OPERATION, "INVALID_STACK_OPERATION"},
{SCRIPT_ERR_INVALID_ALTSTACK_OPERATION, "INVALID_ALTSTACK_OPERATION"}, │ {SCRIPT_ERR_INVALID_ALTSTACK_OPERATION, "INVALID_ALTSTACK_OPERATION"},
{SCRIPT_ERR_UNBALANCED_CONDITIONAL, "UNBALANCED_CONDITIONAL"}, │ {SCRIPT_ERR_UNBALANCED_CONDITIONAL, "UNBALANCED_CONDITIONAL"},
{SCRIPT_ERR_NEGATIVE_LOCKTIME, "NEGATIVE_LOCKTIME"}, │ {SCRIPT_ERR_NEGATIVE_LOCKTIME, "NEGATIVE_LOCKTIME"},
{SCRIPT_ERR_UNSATISFIED_LOCKTIME, "UNSATISFIED_LOCKTIME"}, │ {SCRIPT_ERR_UNSATISFIED_LOCKTIME, "UNSATISFIED_LOCKTIME"},
{SCRIPT_ERR_SIG_HASHTYPE, "SIG_HASHTYPE"}, │ {SCRIPT_ERR_SIG_HASHTYPE, "SIG_HASHTYPE"},
{SCRIPT_ERR_SIG_DER, "SIG_DER"}, │ {SCRIPT_ERR_SIG_DER, "SIG_DER"},
{SCRIPT_ERR_MINIMALDATA, "MINIMALDATA"}, │ {SCRIPT_ERR_MINIMALDATA, "MINIMALDATA"},
{SCRIPT_ERR_SIG_PUSHONLY, "SIG_PUSHONLY"}, │ {SCRIPT_ERR_SIG_PUSHONLY, "SIG_PUSHONLY"},
{SCRIPT_ERR_SIG_HIGH_S, "SIG_HIGH_S"}, │ {SCRIPT_ERR_SIG_HIGH_S, "SIG_HIGH_S"},
{SCRIPT_ERR_SIG_NULLDUMMY, "SIG_NULLDUMMY"}, │ {SCRIPT_ERR_SIG_NULLDUMMY, "SIG_NULLDUMMY"},
{SCRIPT_ERR_PUBKEYTYPE, "PUBKEYTYPE"}, │ {SCRIPT_ERR_PUBKEYTYPE, "PUBKEYTYPE"},
{SCRIPT_ERR_CLEANSTACK, "CLEANSTACK"}, │ {SCRIPT_ERR_CLEANSTACK, "CLEANSTACK"},
{SCRIPT_ERR_MINIMALIF, "MINIMALIF"}, │ {SCRIPT_ERR_MINIMALIF, "MINIMALIF"},
{SCRIPT_ERR_SIG_NULLFAIL, "NULLFAIL"}, │ {SCRIPT_ERR_SIG_NULLFAIL, "NULLFAIL"},
{SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS, "DISCOURAGE_UPGRADABLE_NOPS"}, │ {SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS, "DISCOURAGE_UPGRADABLE_NOPS"},
{SCRIPT_ERR_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM, "DISCOURAGE_UPGRADABLE_WITNESS_PR │ {SCRIPT_ERR_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM, "DISCOURAGE_UPGRADABLE_WITNESS_PR
{SCRIPT_ERR_WITNESS_PROGRAM_WRONG_LENGTH, "WITNESS_PROGRAM_WRONG_LENGTH"}, │ {SCRIPT_ERR_WITNESS_PROGRAM_WRONG_LENGTH, "WITNESS_PROGRAM_WRONG_LENGTH"},
{SCRIPT_ERR_WITNESS_PROGRAM_WITNESS_EMPTY, "WITNESS_PROGRAM_WITNESS_EMPTY"}, │ {SCRIPT_ERR_WITNESS_PROGRAM_WITNESS_EMPTY, "WITNESS_PROGRAM_WITNESS_EMPTY"},
{SCRIPT_ERR_WITNESS_PROGRAM_MISMATCH, "WITNESS_PROGRAM_MISMATCH"}, │ {SCRIPT_ERR_WITNESS_PROGRAM_MISMATCH, "WITNESS_PROGRAM_MISMATCH"},
{SCRIPT_ERR_WITNESS_MALLEATED, "WITNESS_MALLEATED"}, │ {SCRIPT_ERR_WITNESS_MALLEATED, "WITNESS_MALLEATED"},
{SCRIPT_ERR_WITNESS_MALLEATED_P2SH, "WITNESS_MALLEATED_P2SH"}, │ {SCRIPT_ERR_WITNESS_MALLEATED_P2SH, "WITNESS_MALLEATED_P2SH"},
{SCRIPT_ERR_WITNESS_UNEXPECTED, "WITNESS_UNEXPECTED"}, │ {SCRIPT_ERR_WITNESS_UNEXPECTED, "WITNESS_UNEXPECTED"},
{SCRIPT_ERR_WITNESS_PUBKEYTYPE, "WITNESS_PUBKEYTYPE"}, │ {SCRIPT_ERR_WITNESS_PUBKEYTYPE, "WITNESS_PUBKEYTYPE"},
│ {SCRIPT_ERR_OP_CODESEPARATOR, "OP_CODESEPARATOR"},
│ {SCRIPT_ERR_SIG_FINDANDDELETE, "SIG_FINDANDDELETE"},
} │
next prev up bitcoin/src/test/bloom_tests.cpp:450 │ dogecoin/src/test/bloom_tests.cpp:471
│
SeedInsecureRand(SeedRand::ZEROS); │
g_mock_deterministic_tests = true; │
│
// last-100-entry, 1% false positive: │ // last-100-entry, 1% false positive:
CRollingBloomFilter rb1(100, 0.01); │ CRollingBloomFilter rb1(100, 0.01);
│
// Overfill: │ // Overfill:
static const int DATASIZE=399; │ static const int DATASIZE=399;
std::vector<unsigned char> data[DATASIZE]; │ std::vector<unsigned char> data[DATASIZE];
for (int i = 0; i < DATASIZE; i++) { │ for (int i = 0; i < DATASIZE; i++) {
data[i] = RandomData(); │ data[i] = RandomData();
rb1.insert(data[i]); │ rb1.insert(data[i]);
} │ }
// Last 100 guaranteed to be remembered: │ // Last 100 guaranteed to be remembered:
for (int i = 299; i < DATASIZE; i++) { │ for (int i = 299; i < DATASIZE; i++) {
BOOST_CHECK(rb1.contains(data[i])); │ BOOST_CHECK(rb1.contains(data[i]));
} │ }
│
// false positive rate is 1%, so we should get about 100 hits if │ // false positive rate is 1%, so we should get about 100 hits if
// testing 10,000 random keys. We get worst-case false positive │ // testing 10,000 random keys. We get worst-case false positive
// behavior when the filter is as full as possible, which is │ // behavior when the filter is as full as possible, which is
// when we've inserted one minus an integer multiple of nElement*2. │ // when we've inserted one minus an integer multiple of nElement*2.
unsigned int nHits = 0; │ unsigned int nHits = 0;
for (int i = 0; i < 10000; i++) { │ for (int i = 0; i < 10000; i++) {
if (rb1.contains(RandomData())) │ if (rb1.contains(RandomData()))
++nHits; │ ++nHits;
} │ }
// Expect about 100 hits │ // Run test_bitcoin with --log_level=message to see BOOST_TEST_MESSAGEs:
BOOST_CHECK_EQUAL(nHits, 75U); │ BOOST_TEST_MESSAGE("RollingBloomFilter got " << nHits << " false positives (~100 exp
│
│ // Insanely unlikely to get a fp count outside this range:
│ BOOST_CHECK(nHits > 25);
│ BOOST_CHECK(nHits < 175);
│
BOOST_CHECK(rb1.contains(data[DATASIZE-1])); │ BOOST_CHECK(rb1.contains(data[DATASIZE-1]));
rb1.reset(); │ rb1.reset();
BOOST_CHECK(!rb1.contains(data[DATASIZE-1])); │ BOOST_CHECK(!rb1.contains(data[DATASIZE-1]));
│
// Now roll through data, make sure last 100 entries │ // Now roll through data, make sure last 100 entries
// are always remembered: │ // are always remembered:
for (int i = 0; i < DATASIZE; i++) { │ for (int i = 0; i < DATASIZE; i++) {
if (i >= 100) │ if (i >= 100)
BOOST_CHECK(rb1.contains(data[i-100])); │ BOOST_CHECK(rb1.contains(data[i-100]));
rb1.insert(data[i]); │ rb1.insert(data[i]);
BOOST_CHECK(rb1.contains(data[i])); │ BOOST_CHECK(rb1.contains(data[i]));
} │ }
│
// Insert 999 more random entries: │ // Insert 999 more random entries:
for (int i = 0; i < 999; i++) { │ for (int i = 0; i < 999; i++) {
std::vector<unsigned char> d = RandomData(); │ std::vector<unsigned char> d = RandomData();
rb1.insert(d); │ rb1.insert(d);
BOOST_CHECK(rb1.contains(d)); │ BOOST_CHECK(rb1.contains(d));
} │ }
// Sanity check to make sure the filter isn't just filling up: │ // Sanity check to make sure the filter isn't just filling up:
nHits = 0; │ nHits = 0;
for (int i = 0; i < DATASIZE; i++) { │ for (int i = 0; i < DATASIZE; i++) {
if (rb1.contains(data[i])) │ if (rb1.contains(data[i]))
++nHits; │ ++nHits;
} │ }
// Expect about 5 false positives │ // Expect about 5 false positives, more than 100 means
BOOST_CHECK_EQUAL(nHits, 6U); │ // something is definitely broken.
│ BOOST_TEST_MESSAGE("RollingBloomFilter got " << nHits << " false positives (~5 expec
│ BOOST_CHECK(nHits < 100);
│
// last-1000-entry, 0.01% false positive: │ // last-1000-entry, 0.01% false positive:
CRollingBloomFilter rb2(1000, 0.001); │ CRollingBloomFilter rb2(1000, 0.001);
for (int i = 0; i < DATASIZE; i++) { │ for (int i = 0; i < DATASIZE; i++) {
rb2.insert(data[i]); │ rb2.insert(data[i]);
} │ }
// ... room for all of them: │ // ... room for all of them:
for (int i = 0; i < DATASIZE; i++) { │ for (int i = 0; i < DATASIZE; i++) {
BOOST_CHECK(rb2.contains(data[i])); │ BOOST_CHECK(rb2.contains(data[i]));
} │ }
g_mock_deterministic_tests = false; │
} │
next prev up dogecoin/src/wallet/wallet.cpp:326 │ bitcoin/src/wallet/wallet.cpp:477
│
│ bool fWasLocked = IsLocked();
│
│ {
LOCK(cs_wallet); │ LOCK(cs_wallet);
Lock(); │ Lock();
│
CCrypter crypter; │ CCrypter crypter;
CKeyingMaterial vMasterKey; │ CKeyingMaterial _vMasterKey;
BOOST_FOREACH(MasterKeyMap::value_type& pMasterKey, mapMasterKeys) │ for (MasterKeyMap::value_type& pMasterKey : mapMasterKeys)
{ │ {
if(!crypter.SetKeyFromPassphrase(strOldWalletPassphrase, pMasterKey.second.v │ if(!crypter.SetKeyFromPassphrase(strOldWalletPassphrase, pMasterKey.second.v
return false; │ return false;
if (!crypter.Decrypt(pMasterKey.second.vchCryptedKey, vMasterKey)) │ if (!crypter.Decrypt(pMasterKey.second.vchCryptedKey, _vMasterKey))
return false; │ return false;
if (CCryptoKeyStore::Unlock(vMasterKey)) │ if (Unlock(_vMasterKey))
{ │ {
int64_t nStartTime = GetTimeMillis(); │ int64_t nStartTime = GetTimeMillis();
crypter.SetKeyFromPassphrase(strNewWalletPassphrase, pMasterKey.second.v │ crypter.SetKeyFromPassphrase(strNewWalletPassphrase, pMasterKey.second.v
pMasterKey.second.nDeriveIterations = pMasterKey.second.nDeriveIteration │ pMasterKey.second.nDeriveIterations = static_cast<unsigned int>(pMasterK
│
nStartTime = GetTimeMillis(); │ nStartTime = GetTimeMillis();
crypter.SetKeyFromPassphrase(strNewWalletPassphrase, pMasterKey.second.v │ crypter.SetKeyFromPassphrase(strNewWalletPassphrase, pMasterKey.second.v
pMasterKey.second.nDeriveIterations = (pMasterKey.second.nDeriveIteratio │ pMasterKey.second.nDeriveIterations = (pMasterKey.second.nDeriveIteratio
│
if (pMasterKey.second.nDeriveIterations < 25000) │ if (pMasterKey.second.nDeriveIterations < 25000)
pMasterKey.second.nDeriveIterations = 25000; │ pMasterKey.second.nDeriveIterations = 25000;
│
LogPrintf("Wallet passphrase changed to an nDeriveIterations of %i\n", p │ WalletLogPrintf("Wallet passphrase changed to an nDeriveIterations of %i
│
if (!crypter.SetKeyFromPassphrase(strNewWalletPassphrase, pMasterKey.sec │ if (!crypter.SetKeyFromPassphrase(strNewWalletPassphrase, pMasterKey.sec
return false; │ return false;
if (!crypter.Encrypt(vMasterKey, pMasterKey.second.vchCryptedKey)) │ if (!crypter.Encrypt(_vMasterKey, pMasterKey.second.vchCryptedKey))
return false; │ return false;
CWalletDB(strWalletFile).WriteMasterKey(pMasterKey.first, pMasterKey.sec │ WalletBatch(GetDatabase()).WriteMasterKey(pMasterKey.first, pMasterKey.s
if (fWasLocked) │ if (fWasLocked)
Lock(); │ Lock();
return true; │ return true;
} │ }
} │ }
│
│ return false;
│
next prev up bitcoin/src/net_processing.cpp:3973 │ dogecoin/src/net_processing.cpp:2502
│
const auto ping_end = time_received; │ int64_t pingUsecEnd = nTimeReceived;
uint64_t nonce = 0; │ uint64_t nonce = 0;
size_t nAvail = vRecv.in_avail(); │ size_t nAvail = vRecv.in_avail();
bool bPingFinished = false; │ bool bPingFinished = false;
std::string sProblem; │ std::string sProblem;
│
if (nAvail >= sizeof(nonce)) { │ if (nAvail >= sizeof(nonce)) {
vRecv >> nonce; │ vRecv >> nonce;
│
// Only process pong message if there is an outstanding ping (old ping witho │ // Only process pong message if there is an outstanding ping (old ping witho
if (peer->m_ping_nonce_sent != 0) { │ if (pfrom->nPingNonceSent != 0) {
if (nonce == peer->m_ping_nonce_sent) { │ if (nonce == pfrom->nPingNonceSent) {
// Matching pong received, this ping is no longer outstanding │ // Matching pong received, this ping is no longer outstanding
bPingFinished = true; │ bPingFinished = true;
const auto ping_time = ping_end - peer->m_ping_start.load(); │ int64_t pingUsecTime = pingUsecEnd - pfrom->nPingUsecStart;
if (ping_time.count() >= 0) { │ if (pingUsecTime > 0) {
// Let connman know about this successful ping-pong │ // Successful ping time measurement, replace previous
pfrom.PongReceived(ping_time); │ pfrom->nPingUsecTime = pingUsecTime;
│ pfrom->nMinPingUsecTime = std::min(pfrom->nMinPingUsecTime.load(
} else { │ } else {
// This should never happen │ // This should never happen
sProblem = "Timing mishap"; │ sProblem = "Timing mishap";
} │ }
} else { │ } else {
// Nonce mismatches are normal when pings are overlapping │ // Nonce mismatches are normal when pings are overlapping
sProblem = "Nonce mismatch"; │ sProblem = "Nonce mismatch";
if (nonce == 0) { │ if (nonce == 0) {
// This is most likely a bug in another implementation somewhere │ // This is most likely a bug in another implementation somewhere
bPingFinished = true; │ bPingFinished = true;
sProblem = "Nonce zero"; │ sProblem = "Nonce zero";
} │ }
} │ }
} else { │ } else {
sProblem = "Unsolicited pong without ping"; │ sProblem = "Unsolicited pong without ping";
} │ }
} else { │ } else {
// This is most likely a bug in another implementation somewhere; cancel thi │ // This is most likely a bug in another implementation somewhere; cancel thi
bPingFinished = true; │ bPingFinished = true;
sProblem = "Short payload"; │ sProblem = "Short payload";
} │ }
│
if (!(sProblem.empty())) { │ if (!(sProblem.empty())) {
LogPrint(BCLog::NET, "pong peer=%d: %s, %x expected, %x received, %u bytes\n │ LogPrint("net", "pong peer=%d: %s, %x expected, %x received, %u bytes\n",
pfrom.GetId(), │ pfrom->id,
sProblem, │ sProblem,
peer->m_ping_nonce_sent, │ pfrom->nPingNonceSent,
nonce, │ nonce,
nAvail); │ nAvail);
} │ }
if (bPingFinished) { │ if (bPingFinished) {
peer->m_ping_nonce_sent = 0; │ pfrom->nPingNonceSent = 0;
} │ }
return; │
} │
next prev up bitcoin/src/wallet/rpc/coins.cpp:122 │ bitcoin/src/wallet/rpc/coins.cpp:81
│
return RPCHelpMan{"getreceivedbylabel", │ return RPCHelpMan{"getreceivedbyaddress",
"\nReturns the total amount received by addresses with <label> in transa │ "\nReturns the total amount received by the given address in transaction
{ │ {
{"label", RPCArg::Type::STR, RPCArg::Optional::NO, "The selected lab │ {"address", RPCArg::Type::STR, RPCArg::Optional::NO, "The bitcoin ad
{"minconf", RPCArg::Type::NUM, RPCArg::Default{1}, "Only include tra │ {"minconf", RPCArg::Type::NUM, RPCArg::Default{1}, "Only include tra
{"include_immature_coinbase", RPCArg::Type::BOOL, RPCArg::Default{fa │ {"include_immature_coinbase", RPCArg::Type::BOOL, RPCArg::Default{fa
}, │ },
RPCResult{ │ RPCResult{
RPCResult::Type::STR_AMOUNT, "amount", "The total amount in " + CURR │ RPCResult::Type::STR_AMOUNT, "amount", "The total amount in " + CURR
}, │ },
RPCExamples{ │ RPCExamples{
"\nAmount received by the default label with at least 1 confirmation\n" │ "\nThe amount from transactions with at least 1 confirmation\n"
+ HelpExampleCli("getreceivedbylabel", "\"\"") + │ + HelpExampleCli("getreceivedbyaddress", "\"" + EXAMPLE_ADDRESS[0] + "\"") +
"\nAmount received at the tabby label including unconfirmed amounts with zer │ "\nThe amount including unconfirmed transactions, zero confirmations\n"
+ HelpExampleCli("getreceivedbylabel", "\"tabby\" 0") + │ + HelpExampleCli("getreceivedbyaddress", "\"" + EXAMPLE_ADDRESS[0] + "\" 0")
"\nThe amount with at least 6 confirmations\n" │ "\nThe amount with at least 6 confirmations\n"
+ HelpExampleCli("getreceivedbylabel", "\"tabby\" 6") + │ + HelpExampleCli("getreceivedbyaddress", "\"" + EXAMPLE_ADDRESS[0] + "\" 6")
"\nThe amount with at least 6 confirmations including immature coinbase outp │ "\nThe amount with at least 6 confirmations including immature coinbase outp
+ HelpExampleCli("getreceivedbylabel", "\"tabby\" 6 true") + │ + HelpExampleCli("getreceivedbyaddress", "\"" + EXAMPLE_ADDRESS[0] + "\" 6 t
"\nAs a JSON-RPC call\n" │ "\nAs a JSON-RPC call\n"
+ HelpExampleRpc("getreceivedbylabel", "\"tabby\", 6, true") │ + HelpExampleRpc("getreceivedbyaddress", "\"" + EXAMPLE_ADDRESS[0] + "\", 6"
}, │ },
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue │ [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{ │ {
const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request); │ const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
if (!pwallet) return NullUniValue; │ if (!pwallet) return NullUniValue;
│
// Make sure the results are valid at least up to the most recent block │ // Make sure the results are valid at least up to the most recent block
// the user could have gotten from another RPC command prior to now │ // the user could have gotten from another RPC command prior to now
pwallet->BlockUntilSyncedToCurrentChain(); │ pwallet->BlockUntilSyncedToCurrentChain();
│
LOCK(pwallet->cs_wallet); │ LOCK(pwallet->cs_wallet);
│
return ValueFromAmount(GetReceived(*pwallet, request.params, /*by_label=*/true)); │ return ValueFromAmount(GetReceived(*pwallet, request.params, /*by_label=*/false));
}, │ },
}; │ };
} │
next prev up bitcoin/src/test/key_tests.cpp:78 │ dogecoin/src/test/key_tests.cpp:110
│
std::string strMsg = strprintf("Very secret message %i: 11", n); │ std::string strMsg = strprintf("Very secret message %i: 11", n);
uint256 hashMsg = Hash(strMsg); │ uint256 hashMsg = Hash(strMsg.begin(), strMsg.end());
│
// normal signatures │ // normal signatures
│
std::vector<unsigned char> sign1, sign2, sign1C, sign2C; │ std::vector<unsigned char> sign1, sign2, sign1C, sign2C;
│
BOOST_CHECK(key1.Sign (hashMsg, sign1)); │ BOOST_CHECK(key1.Sign (hashMsg, sign1));
BOOST_CHECK(key2.Sign (hashMsg, sign2)); │ BOOST_CHECK(key2.Sign (hashMsg, sign2));
BOOST_CHECK(key1C.Sign(hashMsg, sign1C)); │ BOOST_CHECK(key1C.Sign(hashMsg, sign1C));
BOOST_CHECK(key2C.Sign(hashMsg, sign2C)); │ BOOST_CHECK(key2C.Sign(hashMsg, sign2C));
│
BOOST_CHECK( pubkey1.Verify(hashMsg, sign1)); │ BOOST_CHECK( pubkey1.Verify(hashMsg, sign1));
BOOST_CHECK(!pubkey1.Verify(hashMsg, sign2)); │ BOOST_CHECK(!pubkey1.Verify(hashMsg, sign2));
BOOST_CHECK( pubkey1.Verify(hashMsg, sign1C)); │ BOOST_CHECK( pubkey1.Verify(hashMsg, sign1C));
BOOST_CHECK(!pubkey1.Verify(hashMsg, sign2C)); │ BOOST_CHECK(!pubkey1.Verify(hashMsg, sign2C));
│
BOOST_CHECK(!pubkey2.Verify(hashMsg, sign1)); │ BOOST_CHECK(!pubkey2.Verify(hashMsg, sign1));
BOOST_CHECK( pubkey2.Verify(hashMsg, sign2)); │ BOOST_CHECK( pubkey2.Verify(hashMsg, sign2));
BOOST_CHECK(!pubkey2.Verify(hashMsg, sign1C)); │ BOOST_CHECK(!pubkey2.Verify(hashMsg, sign1C));
BOOST_CHECK( pubkey2.Verify(hashMsg, sign2C)); │ BOOST_CHECK( pubkey2.Verify(hashMsg, sign2C));
│
BOOST_CHECK( pubkey1C.Verify(hashMsg, sign1)); │ BOOST_CHECK( pubkey1C.Verify(hashMsg, sign1));
BOOST_CHECK(!pubkey1C.Verify(hashMsg, sign2)); │ BOOST_CHECK(!pubkey1C.Verify(hashMsg, sign2));
BOOST_CHECK( pubkey1C.Verify(hashMsg, sign1C)); │ BOOST_CHECK( pubkey1C.Verify(hashMsg, sign1C));
BOOST_CHECK(!pubkey1C.Verify(hashMsg, sign2C)); │ BOOST_CHECK(!pubkey1C.Verify(hashMsg, sign2C));
│
BOOST_CHECK(!pubkey2C.Verify(hashMsg, sign1)); │ BOOST_CHECK(!pubkey2C.Verify(hashMsg, sign1));
BOOST_CHECK( pubkey2C.Verify(hashMsg, sign2)); │ BOOST_CHECK( pubkey2C.Verify(hashMsg, sign2));
BOOST_CHECK(!pubkey2C.Verify(hashMsg, sign1C)); │ BOOST_CHECK(!pubkey2C.Verify(hashMsg, sign1C));
BOOST_CHECK( pubkey2C.Verify(hashMsg, sign2C)); │ BOOST_CHECK( pubkey2C.Verify(hashMsg, sign2C));
│
// compact signatures (with key recovery) │ // compact signatures (with key recovery)
│
std::vector<unsigned char> csign1, csign2, csign1C, csign2C; │ std::vector<unsigned char> csign1, csign2, csign1C, csign2C;
│
BOOST_CHECK(key1.SignCompact (hashMsg, csign1)); │ BOOST_CHECK(key1.SignCompact (hashMsg, csign1));
BOOST_CHECK(key2.SignCompact (hashMsg, csign2)); │ BOOST_CHECK(key2.SignCompact (hashMsg, csign2));
BOOST_CHECK(key1C.SignCompact(hashMsg, csign1C)); │ BOOST_CHECK(key1C.SignCompact(hashMsg, csign1C));
BOOST_CHECK(key2C.SignCompact(hashMsg, csign2C)); │ BOOST_CHECK(key2C.SignCompact(hashMsg, csign2C));
│
CPubKey rkey1, rkey2, rkey1C, rkey2C; │ CPubKey rkey1, rkey2, rkey1C, rkey2C;
│
BOOST_CHECK(rkey1.RecoverCompact (hashMsg, csign1)); │ BOOST_CHECK(rkey1.RecoverCompact (hashMsg, csign1));
BOOST_CHECK(rkey2.RecoverCompact (hashMsg, csign2)); │ BOOST_CHECK(rkey2.RecoverCompact (hashMsg, csign2));
BOOST_CHECK(rkey1C.RecoverCompact(hashMsg, csign1C)); │ BOOST_CHECK(rkey1C.RecoverCompact(hashMsg, csign1C));
BOOST_CHECK(rkey2C.RecoverCompact(hashMsg, csign2C)); │ BOOST_CHECK(rkey2C.RecoverCompact(hashMsg, csign2C));
│
BOOST_CHECK(rkey1 == pubkey1); │ BOOST_CHECK(rkey1 == pubkey1);
BOOST_CHECK(rkey2 == pubkey2); │ BOOST_CHECK(rkey2 == pubkey2);
BOOST_CHECK(rkey1C == pubkey1C); │ BOOST_CHECK(rkey1C == pubkey1C);
BOOST_CHECK(rkey2C == pubkey2C); │ BOOST_CHECK(rkey2C == pubkey2C);
} │
next prev up dogecoin/src/policy/policy.cpp:60 │ bitcoin/src/policy/policy.cpp:82
│
if (tx.nVersion > CTransaction::MAX_STANDARD_VERSION || tx.nVersion < 1) { │ if (tx.nVersion > TX_MAX_STANDARD_VERSION || tx.nVersion < 1) {
reason = "version"; │ reason = "version";
return false; │ return false;
} │ }
│
// Extremely large transactions with lots of inputs can cost the network │ // Extremely large transactions with lots of inputs can cost the network
// almost as much to process as they cost the sender in fees, because │ // almost as much to process as they cost the sender in fees, because
// computing signature hashes is O(ninputs*txsize). Limiting transactions │ // computing signature hashes is O(ninputs*txsize). Limiting transactions
// to MAX_STANDARD_TX_WEIGHT mitigates CPU exhaustion attacks. │ // to MAX_STANDARD_TX_WEIGHT mitigates CPU exhaustion attacks.
unsigned int sz = GetTransactionWeight(tx); │ unsigned int sz = GetTransactionWeight(tx);
if (sz >= MAX_STANDARD_TX_WEIGHT) { │ if (sz > MAX_STANDARD_TX_WEIGHT) {
reason = "tx-size"; │ reason = "tx-size";
return false; │ return false;
} │ }
│
BOOST_FOREACH(const CTxIn& txin, tx.vin) │ for (const CTxIn& txin : tx.vin)
{ │ {
// Biggest 'standard' txin is a 15-of-15 P2SH multisig with compressed │ // Biggest 'standard' txin involving only keys is a 15-of-15 P2SH
// keys (remember the 520 byte limit on redeemScript size). That works │ // multisig with compressed keys (remember the 520 byte limit on
// out to a (15*(33+1))+3=513 byte redeemScript, 513+1+15*(73+1)+3=1627 │ // redeemScript size). That works out to a (15*(33+1))+3=513 byte
// bytes of scriptSig, which we round off to 1650 bytes for some minor │ // redeemScript, 513+1+15*(73+1)+3=1627 bytes of scriptSig, which
// future-proofing. That's also enough to spend a 20-of-20 │ // we round off to 1650(MAX_STANDARD_SCRIPTSIG_SIZE) bytes for
// CHECKMULTISIG scriptPubKey, though such a scriptPubKey is not │ // some minor future-proofing. That's also enough to spend a
// considered standard. │ // 20-of-20 CHECKMULTISIG scriptPubKey, though such a scriptPubKey
if (txin.scriptSig.size() > 1650) { │ // is not considered standard.
│ if (txin.scriptSig.size() > MAX_STANDARD_SCRIPTSIG_SIZE) {
reason = "scriptsig-size"; │ reason = "scriptsig-size";
return false; │ return false;
} │ }
if (!txin.scriptSig.IsPushOnly()) { │ if (!txin.scriptSig.IsPushOnly()) {
reason = "scriptsig-not-pushonly"; │ reason = "scriptsig-not-pushonly";
return false; │ return false;
} │ }
} │ }
│
unsigned int nDataOut = 0; │ unsigned int nDataOut = 0;
txnouttype whichType; │ TxoutType whichType;
BOOST_FOREACH(const CTxOut& txout, tx.vout) { │ for (const CTxOut& txout : tx.vout) {
if (!::IsStandard(txout.scriptPubKey, whichType, witnessEnabled)) { │ if (!::IsStandard(txout.scriptPubKey, whichType)) {
reason = "scriptpubkey"; │ reason = "scriptpubkey";
return false; │ return false;
} │ }
│
if (whichType == TX_NULL_DATA) │ if (whichType == TxoutType::NULL_DATA)
nDataOut++; │ nDataOut++;
else if ((whichType == TX_MULTISIG) && (!fIsBareMultisigStd)) { │ else if ((whichType == TxoutType::MULTISIG) && (!permit_bare_multisig)) {
reason = "bare-multisig"; │ reason = "bare-multisig";
return false; │ return false;
} else if (txout.IsDust(nHardDustLimit)) { │ } else if (IsDust(txout, dust_relay_fee)) {
reason = "dust"; │ reason = "dust";
return false; │ return false;
} │ }
} │ }
│
// only one OP_RETURN txout is permitted │ // only one OP_RETURN txout is permitted
if (nDataOut > 1) { │ if (nDataOut > 1) {
reason = "multi-op-return"; │ reason = "multi-op-return";
return false; │ return false;
} │ }
│
return true; │ return true;
} │
next prev up dogecoin/src/bench/verify_script.cpp:52 │ bitcoin/src/bench/verify_script.cpp:20
│
const int flags = SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2SH; │ const ECCVerifyHandle verify_handle;
│ ECC_Start();
│
│ const uint32_t flags{SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_P2SH};
const int witnessversion = 0; │ const int witnessversion = 0;
│
// Keypair. │ // Key pair.
CKey key; │ CKey key;
const unsigned char vchKey[32] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, │ static const std::array<unsigned char, 32> vchKey = {
key.Set(vchKey, vchKey + 32, false); │ {
│ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
│ }
│ };
│ key.Set(vchKey.begin(), vchKey.end(), false);
CPubKey pubkey = key.GetPubKey(); │ CPubKey pubkey = key.GetPubKey();
uint160 pubkeyHash; │ uint160 pubkeyHash;
CHash160().Write(pubkey.begin(), pubkey.size()).Finalize(pubkeyHash.begin()); │ CHash160().Write(pubkey).Finalize(pubkeyHash);
│
// Script. │ // Script.
CScript scriptPubKey = CScript() << witnessversion << ToByteVector(pubkeyHash); │ CScript scriptPubKey = CScript() << witnessversion << ToByteVector(pubkeyHash);
CScript scriptSig; │ CScript scriptSig;
CScript witScriptPubkey = CScript() << OP_DUP << OP_HASH160 << ToByteVector(pubkeyHa │ CScript witScriptPubkey = CScript() << OP_DUP << OP_HASH160 << ToByteVector(pubkeyHa
CTransaction txCredit = BuildCreditingTransaction(scriptPubKey); │ const CMutableTransaction& txCredit = BuildCreditingTransaction(scriptPubKey, 1);
CMutableTransaction txSpend = BuildSpendingTransaction(scriptSig, txCredit); │ CMutableTransaction txSpend = BuildSpendingTransaction(scriptSig, CScriptWitness(),
CScriptWitness& witness = txSpend.vin[0].scriptWitness; │ CScriptWitness& witness = txSpend.vin[0].scriptWitness;
witness.stack.emplace_back(); │ witness.stack.emplace_back();
key.Sign(SignatureHash(witScriptPubkey, txSpend, 0, SIGHASH_ALL, txCredit.vout[0].nV │ key.Sign(SignatureHash(witScriptPubkey, txSpend, 0, SIGHASH_ALL, txCredit.vout[0].nV
witness.stack.back().push_back(static_cast<unsigned char>(SIGHASH_ALL)); │ witness.stack.back().push_back(static_cast<unsigned char>(SIGHASH_ALL));
witness.stack.push_back(ToByteVector(pubkey)); │ witness.stack.push_back(ToByteVector(pubkey));
│
// Benchmark. │ // Benchmark.
while (state.KeepRunning()) { │ bench.run([&] {
ScriptError err; │ ScriptError err;
bool success = VerifyScript( │ bool success = VerifyScript(
txSpend.vin[0].scriptSig, │ txSpend.vin[0].scriptSig,
txCredit.vout[0].scriptPubKey, │ txCredit.vout[0].scriptPubKey,
&txSpend.vin[0].scriptWitness, │ &txSpend.vin[0].scriptWitness,
flags, │ flags,
MutableTransactionSignatureChecker(&txSpend, 0, txCredit.vout[0].nValue), │ MutableTransactionSignatureChecker(&txSpend, 0, txCredit.vout[0].nValue, Mis
&err); │ &err);
assert(err == SCRIPT_ERR_OK); │ assert(err == SCRIPT_ERR_OK);
assert(success); │ assert(success);
│
#if defined(HAVE_CONSENSUS_LIB) │ #if defined(HAVE_CONSENSUS_LIB)
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); │ CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
stream << txSpend; │ stream << txSpend;
int csuccess = bitcoinconsensus_verify_script_with_amount( │ int csuccess = bitcoinconsensus_verify_script_with_amount(
txCredit.vout[0].scriptPubKey.data(), │ txCredit.vout[0].scriptPubKey.data(),
txCredit.vout[0].scriptPubKey.size(), │ txCredit.vout[0].scriptPubKey.size(),
txCredit.vout[0].nValue, │ txCredit.vout[0].nValue,
(const unsigned char*)stream.data(), stream.size(), 0, flags, nullptr); │ (const unsigned char*)stream.data(), stream.size(), 0, flags, nullptr);
assert(csuccess == 1); │ assert(csuccess == 1);
#endif │ #endif
} │ });
│ ECC_Stop();
} │
next prev up bitcoin/src/test/bloom_tests.cpp:317 │ dogecoin/src/test/bloom_tests.cpp:335
│
// Random real block (000000000000dab0130bbcc991d3d7ae6b81aa6f50a798888dfe62337458dc │ // Random real block (000000000000dab0130bbcc991d3d7ae6b81aa6f50a798888dfe62337458dc
// With one tx │ // With one tx
CBlock block; │ CBlock block;
CDataStream stream(ParseHex("0100000079cda856b143d9db2c1caff01d1aecc8630d30625d10e8b │ CDataStream stream(ParseHex("0100000079cda856b143d9db2c1caff01d1aecc8630d30625d10e8b
stream >> block; │ stream >> block;
│
CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_ALL); │ CBloomFilter filter(10, 0.000001, 0, BLOOM_UPDATE_ALL);
// Match the only transaction │ // Match the only transaction
filter.insert(uint256S("0x63194f18be0af63f2c6bc9dc0f777cbefed3d9415c4af83f3ee3a3d669 │ filter.insert(uint256S("0x63194f18be0af63f2c6bc9dc0f777cbefed3d9415c4af83f3ee3a3d669
│
CMerkleBlock merkleBlock(block, filter); │ CMerkleBlock merkleBlock(block, filter);
BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash()); │ BOOST_CHECK(merkleBlock.header.GetHash() == block.GetHash());
│
BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 1); │ BOOST_CHECK(merkleBlock.vMatchedTxn.size() == 1);
│
BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0x63194f18be0af63f2c6bc9d │ BOOST_CHECK(merkleBlock.vMatchedTxn[0].second == uint256S("0x63194f18be0af63f2c6bc9d
BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 0); │ BOOST_CHECK(merkleBlock.vMatchedTxn[0].first == 0);
│
std::vector<uint256> vMatched; │ std::vector<uint256> vMatched;
std::vector<unsigned int> vIndex; │ std::vector<unsigned int> vIndex;
BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot │ BOOST_CHECK(merkleBlock.txn.ExtractMatches(vMatched, vIndex) == block.hashMerkleRoot
BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size()); │ BOOST_CHECK(vMatched.size() == merkleBlock.vMatchedTxn.size());
for (unsigned int i = 0; i < vMatched.size(); i++) │ for (unsigned int i = 0; i < vMatched.size(); i++)
BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second); │ BOOST_CHECK(vMatched[i] == merkleBlock.vMatchedTxn[i].second);
│
CDataStream merkleStream(SER_NETWORK, PROTOCOL_VERSION); │ CDataStream merkleStream(SER_NETWORK, PROTOCOL_VERSION);
merkleStream << merkleBlock; │ merkleStream << merkleBlock;
│
std::vector<uint8_t> expected = ParseHex("0100000079cda856b143d9db2c1caff01d1aecc863 │ std::vector<unsigned char> vch = ParseHex("0100000079cda856b143d9db2c1caff01d1aecc86
auto result{MakeUCharSpan(merkleStream)}; │ std::vector<char> expected(vch.size());
│
BOOST_CHECK_EQUAL_COLLECTIONS(expected.begin(), expected.end(), result.begin(), resu │ for (unsigned int i = 0; i < vch.size(); i++)
│ expected[i] = (char)vch[i];
│
│ BOOST_CHECK_EQUAL_COLLECTIONS(expected.begin(), expected.end(), merkleStream.begin()
} │
next prev up dogecoin/src/univalue/lib/univalue_get.cpp:19 │ bitcoin/src/univalue/lib/univalue_get.cpp:19
│
static bool ParsePrechecks(const std::string& str) │ static bool ParsePrechecks(const std::string& str)
{ │ {
if (str.empty()) // No empty string allowed │ if (str.empty()) // No empty string allowed
return false; │ return false;
if (str.size() >= 1 && (json_isspace(str[0]) || json_isspace(str[str.size()-1]))) // │ if (str.size() >= 1 && (json_isspace(str[0]) || json_isspace(str[str.size()-1]))) //
return false; │ return false;
if (str.size() != strlen(str.c_str())) // No embedded NUL characters allowed │ if (str.size() != strlen(str.c_str())) // No embedded NUL characters allowed
return false; │ return false;
return true; │ return true;
} │ }
│
bool ParseInt32(const std::string& str, int32_t *out) │ bool ParseInt32(const std::string& str, int32_t *out)
{ │ {
if (!ParsePrechecks(str)) │ if (!ParsePrechecks(str))
return false; │ return false;
char *endp = nullptr; │ char *endp = nullptr;
errno = 0; // strtol will not set errno if valid │ errno = 0; // strtol will not set errno if valid
long int n = strtol(str.c_str(), &endp, 10); │ long int n = strtol(str.c_str(), &endp, 10);
if(out) *out = (int32_t)n; │ if(out) *out = (int32_t)n;
// Note that strtol returns a *long int*, so even if strtol doesn't report an over/u │ // Note that strtol returns a *long int*, so even if strtol doesn't report an over/u
// we still have to check that the returned value is within the range of an *int32_t │ // we still have to check that the returned value is within the range of an *int32_t
// platforms the size of these types may be different. │ // platforms the size of these types may be different.
return endp && *endp == 0 && !errno && │ return endp && *endp == 0 && !errno &&
n >= std::numeric_limits<int32_t>::min() && │ n >= std::numeric_limits<int32_t>::min() &&
n <= std::numeric_limits<int32_t>::max(); │ n <= std::numeric_limits<int32_t>::max();
} │ }
│
bool ParseInt64(const std::string& str, int64_t *out) │ bool ParseInt64(const std::string& str, int64_t *out)
{ │ {
if (!ParsePrechecks(str)) │ if (!ParsePrechecks(str))
return false; │ return false;
char *endp = nullptr; │ char *endp = nullptr;
errno = 0; // strtoll will not set errno if valid │ errno = 0; // strtoll will not set errno if valid
long long int n = strtoll(str.c_str(), &endp, 10); │ long long int n = strtoll(str.c_str(), &endp, 10);
if(out) *out = (int64_t)n; │ if(out) *out = (int64_t)n;
// Note that strtoll returns a *long long int*, so even if strtol doesn't report a o │ // Note that strtoll returns a *long long int*, so even if strtol doesn't report a o
// we still have to check that the returned value is within the range of an *int64_t │ // we still have to check that the returned value is within the range of an *int64_t
return endp && *endp == 0 && !errno && │ return endp && *endp == 0 && !errno &&
n >= std::numeric_limits<int64_t>::min() && │ n >= std::numeric_limits<int64_t>::min() &&
n <= std::numeric_limits<int64_t>::max(); │ n <= std::numeric_limits<int64_t>::max();
} │ }
│
bool ParseDouble(const std::string& str, double *out) │ bool ParseDouble(const std::string& str, double *out)
{ │ {
if (!ParsePrechecks(str)) │ if (!ParsePrechecks(str))
return false; │ return false;
if (str.size() >= 2 && str[0] == '0' && str[1] == 'x') // No hexadecimal floats allo │ if (str.size() >= 2 && str[0] == '0' && str[1] == 'x') // No hexadecimal floats allo
return false; │ return false;
std::istringstream text(str); │ std::istringstream text(str);
text.imbue(std::locale::classic()); │ text.imbue(std::locale::classic());
double result; │ double result;
text >> result; │ text >> result;
if(out) *out = result; │ if(out) *out = result;
return text.eof() && !text.fail(); │ return text.eof() && !text.fail();
} │ }
} │
next prev up bitcoin/src/wallet/rpc/transactions.cpp:466 │ bitcoin/src/wallet/rpc/transactions.cpp:578
RPCResult::Type::OBJ, "", "", Cat(Cat<std::vector<RPCResult>>( │ RPCResult::Type::ARR, "transactions", "", { │ { {RPCResult::Type::BOOL, "involvesWatchonly", /*optional=*/tr │ {RPCResult::Type::OBJ, "", "", Cat(Cat<std::vector<RPCResult {RPCResult::Type::STR, "address", "The bitcoin address of th │ { {RPCResult::Type::STR, "category", "The transaction category │ {RPCResult::Type::BOOL, "involvesWatchonly", /*optional= "\"send\" Transactions sent.\n" │ {RPCResult::Type::STR, "address", "The bitcoin address o "\"receive\" Non-coinbase transactions rec │ {RPCResult::Type::STR, "category", "The transaction cate "\"generate\" Coinbase transactions receive │ "\"send\" Transactions sent.\n" "\"immature\" Coinbase transactions receive │ "\"receive\" Non-coinbase transactions "\"orphan\" Orphaned coinbase transaction │ "\"generate\" Coinbase transactions rec {RPCResult::Type::STR_AMOUNT, "amount", "The amount in " + C │ "\"immature\" Coinbase transactions rec "for all other categories"}, │ "\"orphan\" Orphaned coinbase transac {RPCResult::Type::STR, "label", /*optional=*/true, "A commen │ {RPCResult::Type::STR_AMOUNT, "amount", "The amount in " {RPCResult::Type::NUM, "vout", "the vout value"}, │ "for all other categories"}, {RPCResult::Type::STR_AMOUNT, "fee", /*optional=*/true, "The │ {RPCResult::Type::NUM, "vout", "the vout value"}, "'send' category of transactions."}, │ {RPCResult::Type::STR_AMOUNT, "fee", /*optional=*/true, }, │ "'send' category of transactions."}, TransactionDescriptionString()), │ }, { │ TransactionDescriptionString()), {RPCResult::Type::BOOL, "abandoned", /*optional=*/true, "'tr │ { "'send' category of transactions."}, │ {RPCResult::Type::BOOL, "abandoned", /*optional=*/true, │ {RPCResult::Type::STR, "label", /*optional=*/true, "A co │ })}, │ }
next prev up dogecoin/src/script/interpreter.cpp:783 │ bitcoin/src/script/interpreter.cpp:957
│
// (x1 x2 -- out) │ // (x1 x2 -- out)
if (stack.size() < 2) │ if (stack.size() < 2)
return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); │ return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION);
CScriptNum bn1(stacktop(-2), fRequireMinimal); │ CScriptNum bn1(stacktop(-2), fRequireMinimal);
CScriptNum bn2(stacktop(-1), fRequireMinimal); │ CScriptNum bn2(stacktop(-1), fRequireMinimal);
CScriptNum bn(0); │ CScriptNum bn(0);
switch (opcode) │ switch (opcode)
{ │ {
case OP_ADD: │ case OP_ADD:
bn = bn1 + bn2; │ bn = bn1 + bn2;
break; │ break;
│
case OP_SUB: │ case OP_SUB:
bn = bn1 - bn2; │ bn = bn1 - bn2;
break; │ break;
│
case OP_BOOLAND: bn = (bn1 != bnZero && bn2 != bnZero); │ case OP_BOOLAND: bn = (bn1 != bnZero && bn2 != bnZero);
case OP_BOOLOR: bn = (bn1 != bnZero || bn2 != bnZero); │ case OP_BOOLOR: bn = (bn1 != bnZero || bn2 != bnZero);
case OP_NUMEQUAL: bn = (bn1 == bn2); break; │ case OP_NUMEQUAL: bn = (bn1 == bn2); break;
case OP_NUMEQUALVERIFY: bn = (bn1 == bn2); break; │ case OP_NUMEQUALVERIFY: bn = (bn1 == bn2); break;
case OP_NUMNOTEQUAL: bn = (bn1 != bn2); break; │ case OP_NUMNOTEQUAL: bn = (bn1 != bn2); break;
case OP_LESSTHAN: bn = (bn1 < bn2); break; │ case OP_LESSTHAN: bn = (bn1 < bn2); break;
case OP_GREATERTHAN: bn = (bn1 > bn2); break; │ case OP_GREATERTHAN: bn = (bn1 > bn2); break;
case OP_LESSTHANOREQUAL: bn = (bn1 <= bn2); break; │ case OP_LESSTHANOREQUAL: bn = (bn1 <= bn2); break;
case OP_GREATERTHANOREQUAL: bn = (bn1 >= bn2); break; │ case OP_GREATERTHANOREQUAL: bn = (bn1 >= bn2); break;
case OP_MIN: bn = (bn1 < bn2 ? bn1 : bn2); break; │ case OP_MIN: bn = (bn1 < bn2 ? bn1 : bn2); break;
case OP_MAX: bn = (bn1 > bn2 ? bn1 : bn2); break; │ case OP_MAX: bn = (bn1 > bn2 ? bn1 : bn2); break;
default: assert(!"invalid opcode"); break; │ default: assert(!"invalid opcode"); break;
} │ }
popstack(stack); │ popstack(stack);
popstack(stack); │ popstack(stack);
stack.push_back(bn.getvch()); │ stack.push_back(bn.getvch());
│
if (opcode == OP_NUMEQUALVERIFY) │ if (opcode == OP_NUMEQUALVERIFY)
{ │ {
if (CastToBool(stacktop(-1))) │ if (CastToBool(stacktop(-1)))
popstack(stack); │ popstack(stack);
else │ else
return set_error(serror, SCRIPT_ERR_NUMEQUALVERIFY); │ return set_error(serror, SCRIPT_ERR_NUMEQUALVERIFY);
} │ }
} │
next prev up dogecoin/src/test/addrman_tests.cpp:422 │ bitcoin/src/test/addrman_tests.cpp:473
│
CAddrManTest addrman; │ std::vector<bool> asmap = FromBytes(asmap_raw, sizeof(asmap_raw) * 8);
│ NetGroupManager ngm_asmap{asmap};
// Set addrman addr placement to be deterministic. │
addrman.MakeDeterministic(); │
│
CAddress addr1 = CAddress(ResolveService("250.1.1.1", 8333), NODE_NONE); │ CAddress addr1 = CAddress(ResolveService("250.1.1.1", 8333), NODE_NONE);
CAddress addr2 = CAddress(ResolveService("250.1.1.1", 9999), NODE_NONE); │ CAddress addr2 = CAddress(ResolveService("250.1.1.1", 9999), NODE_NONE);
│
CNetAddr source1 = ResolveIP("250.1.1.1"); │ CNetAddr source1 = ResolveIP("250.1.1.1");
│
│
CAddrInfo info1 = CAddrInfo(addr1, source1); │ AddrInfo info1 = AddrInfo(addr1, source1);
│
uint256 nKey1 = (uint256)(CHashWriter(SER_GETHASH, 0) << 1).GetHash(); │ uint256 nKey1 = (uint256)(CHashWriter(SER_GETHASH, 0) << 1).GetHash();
uint256 nKey2 = (uint256)(CHashWriter(SER_GETHASH, 0) << 2).GetHash(); │ uint256 nKey2 = (uint256)(CHashWriter(SER_GETHASH, 0) << 2).GetHash();
│
│ BOOST_CHECK_EQUAL(info1.GetTriedBucket(nKey1, ngm_asmap), 236);
│
BOOST_CHECK(info1.GetTriedBucket(nKey1) == 40); │ // Test: Make sure key actually randomizes bucket placement. A fail on
│
// Test 26: Make sure key actually randomizes bucket placement. A fail on │
// this test could be a security issue. │ // this test could be a security issue.
BOOST_CHECK(info1.GetTriedBucket(nKey1) != info1.GetTriedBucket(nKey2)); │ BOOST_CHECK(info1.GetTriedBucket(nKey1, ngm_asmap) != info1.GetTriedBucket(nKey2, ng
│
// Test 27: Two addresses with same IP but different ports can map to │ // Test: Two addresses with same IP but different ports can map to
// different buckets because they have different keys. │ // different buckets because they have different keys.
CAddrInfo info2 = CAddrInfo(addr2, source1); │ AddrInfo info2 = AddrInfo(addr2, source1);
│
BOOST_CHECK(info1.GetKey() != info2.GetKey()); │ BOOST_CHECK(info1.GetKey() != info2.GetKey());
BOOST_CHECK(info1.GetTriedBucket(nKey1) != info2.GetTriedBucket(nKey1)); │ BOOST_CHECK(info1.GetTriedBucket(nKey1, ngm_asmap) != info2.GetTriedBucket(nKey1, ng
│
std::set<int> buckets; │ std::set<int> buckets;
for (int i = 0; i < 255; i++) { │ for (int j = 0; j < 255; j++) {
CAddrInfo infoi = CAddrInfo( │ AddrInfo infoj = AddrInfo(
CAddress(ResolveService("250.1.1." + boost::to_string(i)), NODE_NONE), │ CAddress(ResolveService("101." + ToString(j) + ".1.1"), NODE_NONE),
ResolveIP("250.1.1." + boost::to_string(i))); │ ResolveIP("101." + ToString(j) + ".1.1"));
int bucket = infoi.GetTriedBucket(nKey1); │ int bucket = infoj.GetTriedBucket(nKey1, ngm_asmap);
buckets.insert(bucket); │ buckets.insert(bucket);
} │ }
// Test 28: IP addresses in the same group (\16 prefix for IPv4) should │ // Test: IP addresses in the different /16 prefix MAY map to more than
// never get more than 8 buckets │ // 8 buckets.
BOOST_CHECK(buckets.size() == 8); │ BOOST_CHECK(buckets.size() > 8);
│
buckets.clear(); │ buckets.clear();
for (int j = 0; j < 255; j++) { │ for (int j = 0; j < 255; j++) {
CAddrInfo infoj = CAddrInfo( │ AddrInfo infoj = AddrInfo(
CAddress(ResolveService("250." + boost::to_string(j) + ".1.1"), NODE_NONE), │ CAddress(ResolveService("250." + ToString(j) + ".1.1"), NODE_NONE),
ResolveIP("250." + boost::to_string(j) + ".1.1")); │ ResolveIP("250." + ToString(j) + ".1.1"));
int bucket = infoj.GetTriedBucket(nKey1); │ int bucket = infoj.GetTriedBucket(nKey1, ngm_asmap);
buckets.insert(bucket); │ buckets.insert(bucket);
} │ }
// Test 29: IP addresses in the different groups should map to more than │ // Test: IP addresses in the different /16 prefix MAY NOT map to more than
// 8 buckets. │ // 8 buckets.
BOOST_CHECK(buckets.size() == 160); │ BOOST_CHECK(buckets.size() == 8);
} │
next prev up dogecoin/src/test/addrman_tests.cpp:422 │ bitcoin/src/test/addrman_tests.cpp:348
│
CAddrManTest addrman; │
│
// Set addrman addr placement to be deterministic. │
addrman.MakeDeterministic(); │
│
CAddress addr1 = CAddress(ResolveService("250.1.1.1", 8333), NODE_NONE); │ CAddress addr1 = CAddress(ResolveService("250.1.1.1", 8333), NODE_NONE);
CAddress addr2 = CAddress(ResolveService("250.1.1.1", 9999), NODE_NONE); │ CAddress addr2 = CAddress(ResolveService("250.1.1.1", 9999), NODE_NONE);
│
CNetAddr source1 = ResolveIP("250.1.1.1"); │ CNetAddr source1 = ResolveIP("250.1.1.1");
│
│
CAddrInfo info1 = CAddrInfo(addr1, source1); │ AddrInfo info1 = AddrInfo(addr1, source1);
│
uint256 nKey1 = (uint256)(CHashWriter(SER_GETHASH, 0) << 1).GetHash(); │ uint256 nKey1 = (uint256)(CHashWriter(SER_GETHASH, 0) << 1).GetHash();
uint256 nKey2 = (uint256)(CHashWriter(SER_GETHASH, 0) << 2).GetHash(); │ uint256 nKey2 = (uint256)(CHashWriter(SER_GETHASH, 0) << 2).GetHash();
│
│ BOOST_CHECK_EQUAL(info1.GetTriedBucket(nKey1, EMPTY_NETGROUPMAN), 40);
│
BOOST_CHECK(info1.GetTriedBucket(nKey1) == 40); │ // Test: Make sure key actually randomizes bucket placement. A fail on
│
// Test 26: Make sure key actually randomizes bucket placement. A fail on │
// this test could be a security issue. │ // this test could be a security issue.
BOOST_CHECK(info1.GetTriedBucket(nKey1) != info1.GetTriedBucket(nKey2)); │ BOOST_CHECK(info1.GetTriedBucket(nKey1, EMPTY_NETGROUPMAN) != info1.GetTriedBucket(n
│
// Test 27: Two addresses with same IP but different ports can map to │ // Test: Two addresses with same IP but different ports can map to
// different buckets because they have different keys. │ // different buckets because they have different keys.
CAddrInfo info2 = CAddrInfo(addr2, source1); │ AddrInfo info2 = AddrInfo(addr2, source1);
│
BOOST_CHECK(info1.GetKey() != info2.GetKey()); │ BOOST_CHECK(info1.GetKey() != info2.GetKey());
BOOST_CHECK(info1.GetTriedBucket(nKey1) != info2.GetTriedBucket(nKey1)); │ BOOST_CHECK(info1.GetTriedBucket(nKey1, EMPTY_NETGROUPMAN) != info2.GetTriedBucket(n
│
std::set<int> buckets; │ std::set<int> buckets;
for (int i = 0; i < 255; i++) { │ for (int i = 0; i < 255; i++) {
CAddrInfo infoi = CAddrInfo( │ AddrInfo infoi = AddrInfo(
CAddress(ResolveService("250.1.1." + boost::to_string(i)), NODE_NONE), │ CAddress(ResolveService("250.1.1." + ToString(i)), NODE_NONE),
ResolveIP("250.1.1." + boost::to_string(i))); │ ResolveIP("250.1.1." + ToString(i)));
int bucket = infoi.GetTriedBucket(nKey1); │ int bucket = infoi.GetTriedBucket(nKey1, EMPTY_NETGROUPMAN);
buckets.insert(bucket); │ buckets.insert(bucket);
} │ }
// Test 28: IP addresses in the same group (\16 prefix for IPv4) should │ // Test: IP addresses in the same /16 prefix should
// never get more than 8 buckets │ // never get more than 8 buckets with legacy grouping
BOOST_CHECK(buckets.size() == 8); │ BOOST_CHECK_EQUAL(buckets.size(), 8U);
│
buckets.clear(); │ buckets.clear();
for (int j = 0; j < 255; j++) { │ for (int j = 0; j < 255; j++) {
CAddrInfo infoj = CAddrInfo( │ AddrInfo infoj = AddrInfo(
CAddress(ResolveService("250." + boost::to_string(j) + ".1.1"), NODE_NONE), │ CAddress(ResolveService("250." + ToString(j) + ".1.1"), NODE_NONE),
ResolveIP("250." + boost::to_string(j) + ".1.1")); │ ResolveIP("250." + ToString(j) + ".1.1"));
int bucket = infoj.GetTriedBucket(nKey1); │ int bucket = infoj.GetTriedBucket(nKey1, EMPTY_NETGROUPMAN);
buckets.insert(bucket); │ buckets.insert(bucket);
} │ }
// Test 29: IP addresses in the different groups should map to more than │ // Test: IP addresses in the different /16 prefix should map to more than
// 8 buckets. │ // 8 buckets with legacy grouping
BOOST_CHECK(buckets.size() == 160); │ BOOST_CHECK_EQUAL(buckets.size(), 160U);
} │
next prev up bitcoin/src/test/coins_tests.cpp:349 │ dogecoin/src/test/coins_tests.cpp:289
│
│
COutPoint prevout; │ uint256 prevouthash;
// 1/20 times reconnect a previously disconnected tx │ // 1/20 times reconnect a previously disconnected tx
if (randiter % 20 == 2 && disconnected_coins.size()) { │ if (randiter % 20 == 2 && disconnectedids.size()) {
auto utxod = FindRandomFrom(disconnected_coins); │ TxData &txd = FindRandomFrom(disconnectedids);
tx = CMutableTransaction{std::get<0>(utxod->second)}; │ tx = std::get<0>(txd);
prevout = tx.vin[0].prevout; │ prevouthash = tx.vin[0].prevout.hash;
if (!CTransaction(tx).IsCoinBase() && !utxoset.count(prevout)) { │ if (!CTransaction(tx).IsCoinBase() && !utxoset.count(prevouthash)) {
disconnected_coins.erase(utxod->first); │ disconnectedids.erase(tx.GetHash());
continue; │ continue;
} │ }
│
// If this tx is already IN the UTXO, then it must be a coinbase, an │ // If this tx is already IN the UTXO, then it must be a coinbase, an
if (utxoset.count(utxod->first)) { │ if (utxoset.count(tx.GetHash())) {
assert(CTransaction(tx).IsCoinBase()); │ assert(CTransaction(tx).IsCoinBase());
assert(duplicate_coins.count(utxod->first)); │ assert(duplicateids.count(tx.GetHash()));
} │ }
disconnected_coins.erase(utxod->first); │ disconnectedids.erase(tx.GetHash());
} │ }
│
// 16/20 times create a regular tx │ // 16/20 times create a regular tx
else { │ else {
auto utxod = FindRandomFrom(utxoset); │ TxData &txd = FindRandomFrom(utxoset);
prevout = utxod->first; │ prevouthash = std::get<0>(txd).GetHash();
│
// Construct the tx to spend the coins of prevouthash │ // Construct the tx to spend the coins of prevouthash
tx.vin[0].prevout = prevout; │ tx.vin[0].prevout.hash = prevouthash;
│ tx.vin[0].prevout.n = 0;
assert(!CTransaction(tx).IsCoinBase()); │ assert(!CTransaction(tx).IsCoinBase());
} │ }
// In this simple test coins only have two states, spent or unspent, sav │ // In this simple test coins only have two states, spent or unspent, sav
old_coin = result[prevout]; │ oldcoins = result[prevouthash];
// Update the expected result of prevouthash to know these coins are spe │ // Update the expected result of prevouthash to know these coins are spe
result[prevout].Clear(); │ result[prevouthash].Clear();
│
utxoset.erase(prevout); │ utxoset.erase(prevouthash);
│
// The test is designed to ensure spending a duplicate coinbase will wor │ // The test is designed to ensure spending a duplicate coinbase will wor
// if that ever happens and not resurrect the previously overwritten coi │ // if that ever happens and not resurrect the previously overwritten coi
if (duplicate_coins.count(prevout)) { │ if (duplicateids.count(prevouthash))
spent_a_duplicate_coinbase = true; │ spent_a_duplicate_coinbase = true;
} │
│
} │
next prev up bitcoin/src/net_processing.cpp:2388 │ bitcoin/src/net_processing.cpp:3482
│
// We can add the wtxid of this transaction to our reject filter. │ // We can add the wtxid of this transaction to our reject filter.
// Do not add txids of witness transactions or witness-stripped │ // Do not add txids of witness transactions or witness-stripped
// transactions to the filter, as they can have been malleated; │ // transactions to the filter, as they can have been malleated;
// adding such txids to the reject filter would potentially │ // adding such txids to the reject filter would potentially
// interfere with relay of valid transactions from peers that │ // interfere with relay of valid transactions from peers that
// do not support wtxid-based relay. See │ // do not support wtxid-based relay. See
// https://github.com/bitcoin/bitcoin/issues/8279 for details. │ // https://github.com/bitcoin/bitcoin/issues/8279 for details.
// We can remove this restriction (and always add wtxids to │ // We can remove this restriction (and always add wtxids to
// the filter even for witness stripped transactions) once │ // the filter even for witness stripped transactions) once
// wtxid-based relay is broadly deployed. │ // wtxid-based relay is broadly deployed.
// See also comments in https://github.com/bitcoin/bitcoin/pull/18044#di │ // See also comments in https://github.com/bitcoin/bitcoin/pull/18044#di
// for concerns around weakening security of unupgraded nodes │ // for concerns around weakening security of unupgraded nodes
// if we start doing this too early. │ // if we start doing this too early.
m_recent_rejects.insert(porphanTx->GetWitnessHash()); │ m_recent_rejects.insert(tx.GetWitnessHash());
│ m_txrequest.ForgetTxHash(tx.GetWitnessHash());
// If the transaction failed for TX_INPUTS_NOT_STANDARD, │ // If the transaction failed for TX_INPUTS_NOT_STANDARD,
// then we know that the witness was irrelevant to the policy │ // then we know that the witness was irrelevant to the policy
// failure, since this check depends only on the txid │ // failure, since this check depends only on the txid
// (the scriptPubKey being spent is covered by the txid). │ // (the scriptPubKey being spent is covered by the txid).
// Add the txid to the reject filter to prevent repeated │ // Add the txid to the reject filter to prevent repeated
// processing of this transaction in the event that child │ // processing of this transaction in the event that child
// transactions are later received (resulting in │ // transactions are later received (resulting in
// parent-fetching by txid via the orphan-handling logic). │ // parent-fetching by txid via the orphan-handling logic).
if (state.GetResult() == TxValidationResult::TX_INPUTS_NOT_STANDARD && p │ if (state.GetResult() == TxValidationResult::TX_INPUTS_NOT_STANDARD && t
// We only add the txid if it differs from the wtxid, to │ m_recent_rejects.insert(tx.GetHash());
// avoid wasting entries in the rolling bloom filter. │ m_txrequest.ForgetTxHash(tx.GetHash());
m_recent_rejects.insert(porphanTx->GetHash()); │ }
│ if (RecursiveDynamicUsage(*ptx) < 100000) {
│ AddToCompactExtraTransactions(ptx);
} │ }
} │
next prev up dogecoin/src/test/checkqueue_tests.cpp:383 │ bitcoin/src/test/checkqueue_tests.cpp:384
│
auto queue = std::unique_ptr<Standard_Queue>(new Standard_Queue{QUEUE_BATCH_SIZE}); │ auto queue = std::make_unique<Standard_Queue>(QUEUE_BATCH_SIZE);
{ │ {
boost::thread_group tg; │ std::vector<std::thread> tg;
std::atomic<int> nThreads {0}; │ std::atomic<int> nThreads {0};
std::atomic<int> fails {0}; │ std::atomic<int> fails {0};
for (size_t i = 0; i < 3; ++i) { │ for (size_t i = 0; i < 3; ++i) {
tg.create_thread( │ tg.emplace_back(
[&]{ │ [&]{
CCheckQueueControl<FakeCheck> control(queue.get()); │ CCheckQueueControl<FakeCheck> control(queue.get());
// While sleeping, no other thread should execute to this point │ // While sleeping, no other thread should execute to this point
auto observed = ++nThreads; │ auto observed = ++nThreads;
MilliSleep(10); │ UninterruptibleSleep(std::chrono::milliseconds{10});
fails += observed != nThreads; │ fails += observed != nThreads;
}); │ });
} │ }
tg.join_all(); │ for (auto& thread: tg) {
│ if (thread.joinable()) thread.join();
│ }
BOOST_REQUIRE_EQUAL(fails, 0); │ BOOST_REQUIRE_EQUAL(fails, 0);
} │ }
{ │ {
boost::thread_group tg; │ std::vector<std::thread> tg;
std::mutex m; │ std::mutex m;
bool has_lock {false}; │
bool has_tried {false}; │
bool done {false}; │
bool done_ack {false}; │
std::condition_variable cv; │ std::condition_variable cv;
│ bool has_lock{false};
│ bool has_tried{false};
│ bool done{false};
│ bool done_ack{false};
{ │ {
std::unique_lock<std::mutex> l(m); │ std::unique_lock<std::mutex> l(m);
tg.create_thread([&]{ │ tg.emplace_back([&]{
CCheckQueueControl<FakeCheck> control(queue.get()); │ CCheckQueueControl<FakeCheck> control(queue.get());
std::unique_lock<std::mutex> l(m); │ std::unique_lock<std::mutex> ll(m);
has_lock = true; │ has_lock = true;
cv.notify_one(); │ cv.notify_one();
cv.wait(l, [&]{return has_tried;}); │ cv.wait(ll, [&]{return has_tried;});
done = true; │ done = true;
cv.notify_one(); │ cv.notify_one();
// Wait until the done is acknowledged │ // Wait until the done is acknowledged
// │ //
cv.wait(l, [&]{return done_ack;}); │ cv.wait(ll, [&]{return done_ack;});
}); │ });
// Wait for thread to get the lock │ // Wait for thread to get the lock
cv.wait(l, [&](){return has_lock;}); │ cv.wait(l, [&](){return has_lock;});
bool fails = false; │ bool fails = false;
for (auto x = 0; x < 100 && !fails; ++x) { │ for (auto x = 0; x < 100 && !fails; ++x) {
fails = queue->ControlMutex.try_lock(); │ fails = queue->m_control_mutex.try_lock();
} │ }
has_tried = true; │ has_tried = true;
cv.notify_one(); │ cv.notify_one();
cv.wait(l, [&](){return done;}); │ cv.wait(l, [&](){return done;});
// Acknowledge the done │ // Acknowledge the done
done_ack = true; │ done_ack = true;
cv.notify_one(); │ cv.notify_one();
BOOST_REQUIRE(!fails); │ BOOST_REQUIRE(!fails);
} │ }
tg.join_all(); │ for (auto& thread: tg) {
│ if (thread.joinable()) thread.join();
│ }
} │ }
} │
next prev up bitcoin/src/wallet/rpc/transactions.cpp:721 │ bitcoin/src/wallet/rpc/transactions.cpp:578
RPCResult::Type::ARR, "details", "", │ RPCResult::Type::ARR, "transactions", "", { │ { {RPCResult::Type::OBJ, "", "", │ {RPCResult::Type::OBJ, "", "", Cat(Cat<std::vector<RPCResult { │ { {RPCResult::Type::BOOL, "involvesWatchonly", /*optional= │ {RPCResult::Type::BOOL, "involvesWatchonly", /*optional= {RPCResult::Type::STR, "address", /*optional=*/true, "Th │ {RPCResult::Type::STR, "address", "The bitcoin address o {RPCResult::Type::STR, "category", "The transaction cate │ {RPCResult::Type::STR, "category", "The transaction cate "\"send\" Transactions sent.\n" │ "\"send\" Transactions sent.\n" "\"receive\" Non-coinbase transactions │ "\"receive\" Non-coinbase transactions "\"generate\" Coinbase transactions rec │ "\"generate\" Coinbase transactions rec "\"immature\" Coinbase transactions rec │ "\"immature\" Coinbase transactions rec "\"orphan\" Orphaned coinbase transac │ "\"orphan\" Orphaned coinbase transac {RPCResult::Type::STR_AMOUNT, "amount", "The amount in " │ {RPCResult::Type::STR_AMOUNT, "amount", "The amount in " {RPCResult::Type::STR, "label", /*optional=*/true, "A co │ "for all other categories"}, {RPCResult::Type::NUM, "vout", "the vout value"}, │ {RPCResult::Type::NUM, "vout", "the vout value"}, {RPCResult::Type::STR_AMOUNT, "fee", /*optional=*/true, │ {RPCResult::Type::STR_AMOUNT, "fee", /*optional=*/true, "'send' category of transactions."}, │ "'send' category of transactions."}, │ }, │ TransactionDescriptionString()), │ { {RPCResult::Type::BOOL, "abandoned", /*optional=*/true, │ {RPCResult::Type::BOOL, "abandoned", /*optional=*/true, "'send' category of transactions."}, │ "'send' category of transactions."}, }}, │ {RPCResult::Type::STR, "label", /*optional=*/true, "A co │ })}, }} │ }
next prev up bitcoin/src/wallet/rpc/transactions.cpp:721 │ bitcoin/src/wallet/rpc/transactions.cpp:466
RPCResult::Type::ARR, "details", "", │ RPCResult::Type::OBJ, "", "", Cat(Cat<std::vector<RPCResult>>( { │ { {RPCResult::Type::OBJ, "", "", │ {RPCResult::Type::BOOL, "involvesWatchonly", /*optional=*/tr { │ {RPCResult::Type::STR, "address", "The bitcoin address of th {RPCResult::Type::BOOL, "involvesWatchonly", /*optional= │ {RPCResult::Type::STR, "category", "The transaction category {RPCResult::Type::STR, "address", /*optional=*/true, "Th │ "\"send\" Transactions sent.\n" {RPCResult::Type::STR, "category", "The transaction cate │ "\"receive\" Non-coinbase transactions rec "\"send\" Transactions sent.\n" │ "\"generate\" Coinbase transactions receive "\"receive\" Non-coinbase transactions │ "\"immature\" Coinbase transactions receive "\"generate\" Coinbase transactions rec │ "\"orphan\" Orphaned coinbase transaction "\"immature\" Coinbase transactions rec │ {RPCResult::Type::STR_AMOUNT, "amount", "The amount in " + C "\"orphan\" Orphaned coinbase transac │ "for all other categories"}, {RPCResult::Type::STR_AMOUNT, "amount", "The amount in " │ {RPCResult::Type::STR, "label", /*optional=*/true, "A commen {RPCResult::Type::STR, "label", /*optional=*/true, "A co │ {RPCResult::Type::NUM, "vout", "the vout value"}, {RPCResult::Type::NUM, "vout", "the vout value"}, │ {RPCResult::Type::STR_AMOUNT, "fee", /*optional=*/true, "The {RPCResult::Type::STR_AMOUNT, "fee", /*optional=*/true, │ "'send' category of transactions."}, "'send' category of transactions."}, │ }, {RPCResult::Type::BOOL, "abandoned", /*optional=*/true, │ TransactionDescriptionString()), "'send' category of transactions."}, │ { }}, │ {RPCResult::Type::BOOL, "abandoned", /*optional=*/true, "'tr │ })
next prev up dogecoin/src/core_write.cpp:74 │ bitcoin/src/core_write.cpp:99
│
std::string str; │ std::string str;
opcodetype opcode; │ opcodetype opcode;
std::vector<unsigned char> vch; │ std::vector<unsigned char> vch;
CScript::const_iterator pc = script.begin(); │ CScript::const_iterator pc = script.begin();
while (pc < script.end()) { │ while (pc < script.end()) {
if (!str.empty()) { │ if (!str.empty()) {
str += " "; │ str += " ";
} │ }
if (!script.GetOp(pc, opcode, vch)) { │ if (!script.GetOp(pc, opcode, vch)) {
str += "[error]"; │ str += "[error]";
return str; │ return str;
} │ }
if (0 <= opcode && opcode <= OP_PUSHDATA4) { │ if (0 <= opcode && opcode <= OP_PUSHDATA4) {
if (vch.size() <= static_cast<std::vector<unsigned char>::size_type>(4)) { │ if (vch.size() <= static_cast<std::vector<unsigned char>::size_type>(4)) {
str += strprintf("%d", CScriptNum(vch, false).getint()); │ str += strprintf("%d", CScriptNum(vch, false).getint());
} else { │ } else {
// the IsUnspendable check makes sure not to try to decode OP_RETURN dat │ // the IsUnspendable check makes sure not to try to decode OP_RETURN dat
if (fAttemptSighashDecode && !script.IsUnspendable()) { │ if (fAttemptSighashDecode && !script.IsUnspendable()) {
std::string strSigHashDecode; │ std::string strSigHashDecode;
// goal: only attempt to decode a defined sighash type from data tha │ // goal: only attempt to decode a defined sighash type from data tha
// this won't decode correctly formatted public keys in Pubkey or Mu │ // this won't decode correctly formatted public keys in Pubkey or Mu
// the restrictions on the pubkey formats (see IsCompressedOrUncompr │ // the restrictions on the pubkey formats (see IsCompressedOrUncompr
// checks in CheckSignatureEncoding. │ // checks in CheckSignatureEncoding.
if (CheckSignatureEncoding(vch, SCRIPT_VERIFY_STRICTENC, NULL)) { │ if (CheckSignatureEncoding(vch, SCRIPT_VERIFY_STRICTENC, nullptr)) {
const unsigned char chSigHashType = vch.back(); │ const unsigned char chSigHashType = vch.back();
if (mapSigHashTypes.count(chSigHashType)) { │ const auto it = mapSigHashTypes.find(chSigHashType);
strSigHashDecode = "[" + mapSigHashTypes.find(chSigHashType) │ if (it != mapSigHashTypes.end()) {
│ strSigHashDecode = "[" + it->second + "]";
vch.pop_back(); // remove the sighash type byte. it will be │ vch.pop_back(); // remove the sighash type byte. it will be
} │ }
} │ }
str += HexStr(vch) + strSigHashDecode; │ str += HexStr(vch) + strSigHashDecode;
} else { │ } else {
str += HexStr(vch); │ str += HexStr(vch);
} │ }
} │ }
} else { │ } else {
str += GetOpName(opcode); │ str += GetOpName(opcode);
} │ }
} │ }
return str; │ return str;
} │
next prev up dogecoin/src/validation.cpp:1817 │ bitcoin/src/validation.cpp:2034
│
// We've been configured with the hash of a block which has been externally veri │ // We've been configured with the hash of a block which has been externally veri
// A suitable default value is included with the software and updated from time │ // A suitable default value is included with the software and updated from time
// relative to a piece of software is an objective fact these defaults can be e │ // relative to a piece of software is an objective fact these defaults can be e
// This setting doesn't force the selection of any particular chain but makes va │ // This setting doesn't force the selection of any particular chain but makes va
// effectively caching the result of part of the verification. │ // effectively caching the result of part of the verification.
BlockMap::const_iterator it = mapBlockIndex.find(hashAssumeValid); │ BlockMap::const_iterator it = m_blockman.m_block_index.find(hashAssumeValid);
if (it != mapBlockIndex.end()) { │ if (it != m_blockman.m_block_index.end()) {
if (it->second->GetAncestor(pindex->nHeight) == pindex && │ if (it->second.GetAncestor(pindex->nHeight) == pindex &&
pindexBestHeader->GetAncestor(pindex->nHeight) == pindex && │ m_chainman.m_best_header->GetAncestor(pindex->nHeight) == pindex &&
pindexBestHeader->nChainWork >= UintToArith256(consensus.nMinimumChainWo │ m_chainman.m_best_header->nChainWork >= nMinimumChainWork) {
// This block is a member of the assumed verified chain and an ancestor │ // This block is a member of the assumed verified chain and an ancestor
// The equivalent time check discourages hashpower from extorting the ne │ // Script verification is skipped when connecting blocks under the
│ // assumevalid block. Assuming the assumevalid block is valid this
│ // is safe because block merkle hashes are still computed and checked,
│ // Of course, if an assumed valid block is invalid due to false scriptSi
│ // this optimization would allow an invalid chain to be accepted.
│ // The equivalent time check discourages hash power from extorting the n
// into accepting an invalid block through telling users they must manu │ // into accepting an invalid block through telling users they must manu
// Requiring a software change or burying the invalid block, regardless │ // Requiring a software change or burying the invalid block, regardless
// it hard to hide the implication of the demand. This also avoids hav │ // it hard to hide the implication of the demand. This also avoids hav
// that are hardly doing any signature verification at all in testing w │ // that are hardly doing any signature verification at all in testing w
// artificially set the default assumed verified block further back. │ // artificially set the default assumed verified block further back.
// The test against nMinimumChainWork prevents the skipping when denied │ // The test against nMinimumChainWork prevents the skipping when denied
// least as good as the expected chain. │ // least as good as the expected chain.
fScriptChecks = (GetBlockProofEquivalentTime(*pindexBestHeader, *pindex, │ fScriptChecks = (GetBlockProofEquivalentTime(*m_chainman.m_best_header,
} │ }
} │ }
} │
next prev up bitcoin/src/validation.cpp:3275 │ dogecoin/src/validation.cpp:2781
│
AssertLockHeld(cs_main); │
pindexNew->nTx = block.vtx.size(); │ pindexNew->nTx = block.vtx.size();
pindexNew->nChainTx = 0; │ pindexNew->nChainTx = 0;
pindexNew->nFile = pos.nFile; │ pindexNew->nFile = pos.nFile;
pindexNew->nDataPos = pos.nPos; │ pindexNew->nDataPos = pos.nPos;
pindexNew->nUndoPos = 0; │ pindexNew->nUndoPos = 0;
pindexNew->nStatus |= BLOCK_HAVE_DATA; │ pindexNew->nStatus |= BLOCK_HAVE_DATA;
if (DeploymentActiveAt(*pindexNew, m_params.GetConsensus(), Consensus::DEPLOYMENT_SE │ if (IsWitnessEnabled(pindexNew->pprev, Params().GetConsensus(pindexNew->nHeight))) {
pindexNew->nStatus |= BLOCK_OPT_WITNESS; │ pindexNew->nStatus |= BLOCK_OPT_WITNESS;
} │ }
pindexNew->RaiseValidity(BLOCK_VALID_TRANSACTIONS); │ pindexNew->RaiseValidity(BLOCK_VALID_TRANSACTIONS);
m_blockman.m_dirty_blockindex.insert(pindexNew); │ setDirtyBlockIndex.insert(pindexNew);
│
if (pindexNew->pprev == nullptr || pindexNew->pprev->HaveTxsDownloaded()) { │ if (pindexNew->pprev == NULL || pindexNew->pprev->nChainTx) {
// If pindexNew is the genesis block or all parents are BLOCK_VALID_TRANSACTIONS │ // If pindexNew is the genesis block or all parents are BLOCK_VALID_TRANSACTIONS
std::deque<CBlockIndex*> queue; │ std::deque<CBlockIndex*> queue;
queue.push_back(pindexNew); │ queue.push_back(pindexNew);
│
// Recursively process any descendant blocks that now may be eligible to be conn │ // Recursively process any descendant blocks that now may be eligible to be conn
while (!queue.empty()) { │ while (!queue.empty()) {
CBlockIndex *pindex = queue.front(); │ CBlockIndex *pindex = queue.front();
queue.pop_front(); │ queue.pop_front();
pindex->nChainTx = (pindex->pprev ? pindex->pprev->nChainTx : 0) + pindex->n │ pindex->nChainTx = (pindex->pprev ? pindex->pprev->nChainTx : 0) + pindex->n
pindex->nSequenceId = nBlockSequenceId++; │ {
if (m_chain.Tip() == nullptr || !setBlockIndexCandidates.value_comp()(pindex │ LOCK(cs_nBlockSequenceId);
│ pindex->nSequenceId = nBlockSequenceId++;
│ }
│ if (chainActive.Tip() == NULL || !setBlockIndexCandidates.value_comp()(pinde
setBlockIndexCandidates.insert(pindex); │ setBlockIndexCandidates.insert(pindex);
} │ }
std::pair<std::multimap<CBlockIndex*, CBlockIndex*>::iterator, std::multimap │ std::pair<std::multimap<CBlockIndex*, CBlockIndex*>::iterator, std::multimap
while (range.first != range.second) { │ while (range.first != range.second) {
std::multimap<CBlockIndex*, CBlockIndex*>::iterator it = range.first; │ std::multimap<CBlockIndex*, CBlockIndex*>::iterator it = range.first;
queue.push_back(it->second); │ queue.push_back(it->second);
range.first++; │ range.first++;
m_blockman.m_blocks_unlinked.erase(it); │ mapBlocksUnlinked.erase(it);
} │ }
} │ }
} else { │ } else {
if (pindexNew->pprev && pindexNew->pprev->IsValid(BLOCK_VALID_TREE)) { │ if (pindexNew->pprev && pindexNew->pprev->IsValid(BLOCK_VALID_TREE)) {
m_blockman.m_blocks_unlinked.insert(std::make_pair(pindexNew->pprev, pindexN │ mapBlocksUnlinked.insert(std::make_pair(pindexNew->pprev, pindexNew));
} │ }
} │ }
│
│ return true;
} │
next prev up dogecoin/src/univalue/test/object.cpp:188 │ bitcoin/src/univalue/test/object.cpp:188
│
UniValue arr(UniValue::VARR); │ UniValue arr(UniValue::VARR);
│
UniValue v((int64_t)1023LL); │ UniValue v((int64_t)1023LL);
BOOST_CHECK(arr.push_back(v)); │ BOOST_CHECK(arr.push_back(v));
│
std::string vStr("zippy"); │ std::string vStr("zippy");
BOOST_CHECK(arr.push_back(vStr)); │ BOOST_CHECK(arr.push_back(vStr));
│
const char *s = "pippy"; │ const char *s = "pippy";
BOOST_CHECK(arr.push_back(s)); │ BOOST_CHECK(arr.push_back(s));
│
std::vector<UniValue> vec; │ std::vector<UniValue> vec;
v.setStr("boing"); │ v.setStr("boing");
vec.push_back(v); │ vec.push_back(v);
│
v.setStr("going"); │ v.setStr("going");
vec.push_back(v); │ vec.push_back(v);
│
BOOST_CHECK(arr.push_backV(vec)); │ BOOST_CHECK(arr.push_backV(vec));
│
BOOST_CHECK(arr.push_back((uint64_t) 400ULL)); │ BOOST_CHECK(arr.push_back((uint64_t) 400ULL));
BOOST_CHECK(arr.push_back((int64_t) -400LL)); │ BOOST_CHECK(arr.push_back((int64_t) -400LL));
BOOST_CHECK(arr.push_back((int) -401)); │ BOOST_CHECK(arr.push_back((int) -401));
BOOST_CHECK(arr.push_back(-40.1)); │ BOOST_CHECK(arr.push_back(-40.1));
BOOST_CHECK(arr.push_back(true)); │ BOOST_CHECK(arr.push_back(true));
│
BOOST_CHECK_EQUAL(arr.empty(), false); │ BOOST_CHECK_EQUAL(arr.empty(), false);
BOOST_CHECK_EQUAL(arr.size(), 10); │ BOOST_CHECK_EQUAL(arr.size(), 10);
│
BOOST_CHECK_EQUAL(arr[0].getValStr(), "1023"); │ BOOST_CHECK_EQUAL(arr[0].getValStr(), "1023");
BOOST_CHECK_EQUAL(arr[0].getType(), UniValue::VNUM); │ BOOST_CHECK_EQUAL(arr[0].getType(), UniValue::VNUM);
BOOST_CHECK_EQUAL(arr[1].getValStr(), "zippy"); │ BOOST_CHECK_EQUAL(arr[1].getValStr(), "zippy");
BOOST_CHECK_EQUAL(arr[1].getType(), UniValue::VSTR); │ BOOST_CHECK_EQUAL(arr[1].getType(), UniValue::VSTR);
BOOST_CHECK_EQUAL(arr[2].getValStr(), "pippy"); │ BOOST_CHECK_EQUAL(arr[2].getValStr(), "pippy");
BOOST_CHECK_EQUAL(arr[2].getType(), UniValue::VSTR); │ BOOST_CHECK_EQUAL(arr[2].getType(), UniValue::VSTR);
BOOST_CHECK_EQUAL(arr[3].getValStr(), "boing"); │ BOOST_CHECK_EQUAL(arr[3].getValStr(), "boing");
BOOST_CHECK_EQUAL(arr[3].getType(), UniValue::VSTR); │ BOOST_CHECK_EQUAL(arr[3].getType(), UniValue::VSTR);
BOOST_CHECK_EQUAL(arr[4].getValStr(), "going"); │ BOOST_CHECK_EQUAL(arr[4].getValStr(), "going");
BOOST_CHECK_EQUAL(arr[4].getType(), UniValue::VSTR); │ BOOST_CHECK_EQUAL(arr[4].getType(), UniValue::VSTR);
BOOST_CHECK_EQUAL(arr[5].getValStr(), "400"); │ BOOST_CHECK_EQUAL(arr[5].getValStr(), "400");
BOOST_CHECK_EQUAL(arr[5].getType(), UniValue::VNUM); │ BOOST_CHECK_EQUAL(arr[5].getType(), UniValue::VNUM);
BOOST_CHECK_EQUAL(arr[6].getValStr(), "-400"); │ BOOST_CHECK_EQUAL(arr[6].getValStr(), "-400");
BOOST_CHECK_EQUAL(arr[6].getType(), UniValue::VNUM); │ BOOST_CHECK_EQUAL(arr[6].getType(), UniValue::VNUM);
BOOST_CHECK_EQUAL(arr[7].getValStr(), "-401"); │ BOOST_CHECK_EQUAL(arr[7].getValStr(), "-401");
BOOST_CHECK_EQUAL(arr[7].getType(), UniValue::VNUM); │ BOOST_CHECK_EQUAL(arr[7].getType(), UniValue::VNUM);
BOOST_CHECK_EQUAL(arr[8].getValStr(), "-40.1"); │ BOOST_CHECK_EQUAL(arr[8].getValStr(), "-40.1");
BOOST_CHECK_EQUAL(arr[8].getType(), UniValue::VNUM); │ BOOST_CHECK_EQUAL(arr[8].getType(), UniValue::VNUM);
BOOST_CHECK_EQUAL(arr[9].getValStr(), "1"); │ BOOST_CHECK_EQUAL(arr[9].getValStr(), "1");
BOOST_CHECK_EQUAL(arr[9].getType(), UniValue::VBOOL); │ BOOST_CHECK_EQUAL(arr[9].getType(), UniValue::VBOOL);
│
BOOST_CHECK_EQUAL(arr[999].getValStr(), ""); │ BOOST_CHECK_EQUAL(arr[999].getValStr(), "");
│
arr.clear(); │ arr.clear();
BOOST_CHECK(arr.empty()); │ BOOST_CHECK(arr.empty());
BOOST_CHECK_EQUAL(arr.size(), 0); │ BOOST_CHECK_EQUAL(arr.size(), 0);
} │
next prev up dogecoin/src/script/interpreter.cpp:1311 │ bitcoin/src/script/interpreter.cpp:1739
│
// Relative lock times are supported by comparing the passed │ // Relative lock times are supported by comparing the passed
// in operand to the sequence number of the input. │ // in operand to the sequence number of the input.
const int64_t txToSequence = (int64_t)txTo->vin[nIn].nSequence; │ const int64_t txToSequence = (int64_t)txTo->vin[nIn].nSequence;
│
// Fail if the transaction's version number is not set high │ // Fail if the transaction's version number is not set high
// enough to trigger BIP 68 rules. │ // enough to trigger BIP 68 rules.
if (static_cast<uint32_t>(txTo->nVersion) < 2) │ if (static_cast<uint32_t>(txTo->nVersion) < 2)
return false; │ return false;
│
// Sequence numbers with their most significant bit set are not │ // Sequence numbers with their most significant bit set are not
// consensus constrained. Testing that the transaction's sequence │ // consensus constrained. Testing that the transaction's sequence
// number do not have this bit set prevents using this property │ // number do not have this bit set prevents using this property
// to get around a CHECKSEQUENCEVERIFY check. │ // to get around a CHECKSEQUENCEVERIFY check.
if (txToSequence & CTxIn::SEQUENCE_LOCKTIME_DISABLE_FLAG) │ if (txToSequence & CTxIn::SEQUENCE_LOCKTIME_DISABLE_FLAG)
return false; │ return false;
│
// Mask off any bits that do not have consensus-enforced meaning │ // Mask off any bits that do not have consensus-enforced meaning
// before doing the integer comparisons │ // before doing the integer comparisons
const uint32_t nLockTimeMask = CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG | CTxIn::SEQUENCE_ │ const uint32_t nLockTimeMask = CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG | CTxIn::SEQUENCE_
const int64_t txToSequenceMasked = txToSequence & nLockTimeMask; │ const int64_t txToSequenceMasked = txToSequence & nLockTimeMask;
const CScriptNum nSequenceMasked = nSequence & nLockTimeMask; │ const CScriptNum nSequenceMasked = nSequence & nLockTimeMask;
│
// There are two kinds of nSequence: lock-by-blockheight │ // There are two kinds of nSequence: lock-by-blockheight
// and lock-by-blocktime, distinguished by whether │ // and lock-by-blocktime, distinguished by whether
// nSequenceMasked < CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG. │ // nSequenceMasked < CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG.
// │ //
// We want to compare apples to apples, so fail the script │ // We want to compare apples to apples, so fail the script
// unless the type of nSequenceMasked being tested is the same as │ // unless the type of nSequenceMasked being tested is the same as
// the nSequenceMasked in the transaction. │ // the nSequenceMasked in the transaction.
if (!( │ if (!(
(txToSequenceMasked < CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG && nSequenceMasked < │ (txToSequenceMasked < CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG && nSequenceMasked <
(txToSequenceMasked >= CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG && nSequenceMasked >= │ (txToSequenceMasked >= CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG && nSequenceMasked >=
)) { │ )) {
return false; │ return false;
} │ }
│
// Now that we know we're comparing apples-to-apples, the │ // Now that we know we're comparing apples-to-apples, the
// comparison is a simple numeric one. │ // comparison is a simple numeric one.
if (nSequenceMasked > txToSequenceMasked) │ if (nSequenceMasked > txToSequenceMasked)
return false; │ return false;
│
return true; │ return true;
} │
next prev up dogecoin/src/univalue/test/unitester.cpp:80 │ bitcoin/src/univalue/test/unitester.cpp:80
│
"fail10.json", │ "fail10.json",
"fail11.json", │ "fail11.json",
"fail12.json", │ "fail12.json",
"fail13.json", │ "fail13.json",
"fail14.json", │ "fail14.json",
"fail15.json", │ "fail15.json",
"fail16.json", │ "fail16.json",
"fail17.json", │ "fail17.json",
//"fail18.json", // investigate │ //"fail18.json", // investigate
"fail19.json", │ "fail19.json",
"fail1.json", │ "fail1.json",
"fail20.json", │ "fail20.json",
"fail21.json", │ "fail21.json",
"fail22.json", │ "fail22.json",
"fail23.json", │ "fail23.json",
"fail24.json", │ "fail24.json",
"fail25.json", │ "fail25.json",
"fail26.json", │ "fail26.json",
"fail27.json", │ "fail27.json",
"fail28.json", │ "fail28.json",
"fail29.json", │ "fail29.json",
"fail2.json", │ "fail2.json",
"fail30.json", │ "fail30.json",
"fail31.json", │ "fail31.json",
"fail32.json", │ "fail32.json",
"fail33.json", │ "fail33.json",
"fail34.json", │ "fail34.json",
"fail35.json", │ "fail35.json",
"fail36.json", │ "fail36.json",
"fail37.json", │ "fail37.json",
"fail38.json", // invalid unicode: only first half of surrogate pa │ "fail38.json", // invalid unicode: only first half of surrogate pa
"fail39.json", // invalid unicode: only second half of surrogate p │ "fail39.json", // invalid unicode: only second half of surrogate p
"fail40.json", // invalid unicode: broken UTF-8 │ "fail40.json", // invalid unicode: broken UTF-8
"fail41.json", // invalid unicode: unfinished UTF-8 │ "fail41.json", // invalid unicode: unfinished UTF-8
"fail42.json", // valid json with garbage following a nul byte │ "fail42.json", // valid json with garbage following a nul byte
"fail44.json", // unterminated string │ "fail44.json", // unterminated string
"fail45.json", // nested beyond max depth │ "fail45.json", // nested beyond max depth
"fail3.json", │ "fail3.json",
"fail4.json", // extra comma │ "fail4.json", // extra comma
"fail5.json", │ "fail5.json",
"fail6.json", │ "fail6.json",
"fail7.json", │ "fail7.json",
"fail8.json", │ "fail8.json",
"fail9.json", // extra comma │ "fail9.json", // extra comma
"pass1.json", │ "pass1.json",
"pass2.json", │ "pass2.json",
"pass3.json", │ "pass3.json",
"pass4.json", │ "pass4.json",
"round1.json", // round-trip test │ "round1.json", // round-trip test
"round2.json", // unicode │ "round2.json", // unicode
"round3.json", // bare string │ "round3.json", // bare string
"round4.json", // bare number │ "round4.json", // bare number
"round5.json", // bare true │ "round5.json", // bare true
"round6.json", // bare false │ "round6.json", // bare false
"round7.json", // bare null │ "round7.json", // bare null
} │
next prev up bitcoin/src/script/interpreter.cpp:522 │ dogecoin/src/script/interpreter.cpp:351
│
if (!(flags & SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)) { │ if (!(flags & SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY)) {
// not enabled; treat as a NOP2 │ // not enabled; treat as a NOP2
│ if (flags & SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS) {
│ return set_error(serror, SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NO
│ }
break; │ break;
} │ }
│
if (stack.size() < 1) │ if (stack.size() < 1)
return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); │ return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION);
│
// Note that elsewhere numeric opcodes are limited to │ // Note that elsewhere numeric opcodes are limited to
// operands in the range -2**31+1 to 2**31-1, however it is │ // operands in the range -2**31+1 to 2**31-1, however it is
// legal for opcodes to produce results exceeding that │ // legal for opcodes to produce results exceeding that
// range. This limitation is implemented by CScriptNum's │ // range. This limitation is implemented by CScriptNum's
// default 4-byte limit. │ // default 4-byte limit.
// │ //
// If we kept to that limit we'd have a year 2038 problem, │ // If we kept to that limit we'd have a year 2038 problem,
// even though the nLockTime field in transactions │ // even though the nLockTime field in transactions
// themselves is uint32 which only becomes meaningless │ // themselves is uint32 which only becomes meaningless
// after the year 2106. │ // after the year 2106.
// │ //
// Thus as a special case we tell CScriptNum to accept up │ // Thus as a special case we tell CScriptNum to accept up
// to 5-byte bignums, which are good until 2**39-1, well │ // to 5-byte bignums, which are good until 2**39-1, well
// beyond the 2**32-1 limit of the nLockTime field itself. │ // beyond the 2**32-1 limit of the nLockTime field itself.
const CScriptNum nLockTime(stacktop(-1), fRequireMinimal, 5); │ const CScriptNum nLockTime(stacktop(-1), fRequireMinimal, 5);
│
// In the rare event that the argument may be < 0 due to │ // In the rare event that the argument may be < 0 due to
// some arithmetic being done first, you can always use │ // some arithmetic being done first, you can always use
// 0 MAX CHECKLOCKTIMEVERIFY. │ // 0 MAX CHECKLOCKTIMEVERIFY.
if (nLockTime < 0) │ if (nLockTime < 0)
return set_error(serror, SCRIPT_ERR_NEGATIVE_LOCKTIME); │ return set_error(serror, SCRIPT_ERR_NEGATIVE_LOCKTIME);
│
// Actually compare the specified lock time with the transaction. │ // Actually compare the specified lock time with the transaction.
if (!checker.CheckLockTime(nLockTime)) │ if (!checker.CheckLockTime(nLockTime))
return set_error(serror, SCRIPT_ERR_UNSATISFIED_LOCKTIME); │ return set_error(serror, SCRIPT_ERR_UNSATISFIED_LOCKTIME);
│
break; │ break;
} │
next prev up dogecoin/src/test/crypto_tests.cpp:109 │ bitcoin/src/test/crypto_tests.cpp:93
│
std::vector<unsigned char> key = ParseHex(hexkey); │ std::vector<unsigned char> key = ParseHex(hexkey);
std::vector<unsigned char> iv = ParseHex(hexiv); │ std::vector<unsigned char> iv = ParseHex(hexiv);
std::vector<unsigned char> in = ParseHex(hexin); │ std::vector<unsigned char> in = ParseHex(hexin);
std::vector<unsigned char> correctout = ParseHex(hexout); │ std::vector<unsigned char> correctout = ParseHex(hexout);
std::vector<unsigned char> realout(in.size() + AES_BLOCKSIZE); │ std::vector<unsigned char> realout(in.size() + AES_BLOCKSIZE);
│
// Encrypt the plaintext and verify that it equals the cipher │ // Encrypt the plaintext and verify that it equals the cipher
AES128CBCEncrypt enc(&key[0], &iv[0], pad); │ AES256CBCEncrypt enc(key.data(), iv.data(), pad);
int size = enc.Encrypt(&in[0], in.size(), &realout[0]); │ int size = enc.Encrypt(in.data(), in.size(), realout.data());
realout.resize(size); │ realout.resize(size);
BOOST_CHECK(realout.size() == correctout.size()); │ BOOST_CHECK(realout.size() == correctout.size());
BOOST_CHECK_MESSAGE(realout == correctout, HexStr(realout) + std::string(" != ") + h │ BOOST_CHECK_MESSAGE(realout == correctout, HexStr(realout) + std::string(" != ") + h
│
// Decrypt the cipher and verify that it equals the plaintext │ // Decrypt the cipher and verify that it equals the plaintext
std::vector<unsigned char> decrypted(correctout.size()); │ std::vector<unsigned char> decrypted(correctout.size());
AES128CBCDecrypt dec(&key[0], &iv[0], pad); │ AES256CBCDecrypt dec(key.data(), iv.data(), pad);
size = dec.Decrypt(&correctout[0], correctout.size(), &decrypted[0]); │ size = dec.Decrypt(correctout.data(), correctout.size(), decrypted.data());
decrypted.resize(size); │ decrypted.resize(size);
BOOST_CHECK(decrypted.size() == in.size()); │ BOOST_CHECK(decrypted.size() == in.size());
BOOST_CHECK_MESSAGE(decrypted == in, HexStr(decrypted) + std::string(" != ") + hexin │ BOOST_CHECK_MESSAGE(decrypted == in, HexStr(decrypted) + std::string(" != ") + hexin
│
// Encrypt and re-decrypt substrings of the plaintext and verify that they equal eac │ // Encrypt and re-decrypt substrings of the plaintext and verify that they equal eac
for(std::vector<unsigned char>::iterator i(in.begin()); i != in.end(); ++i) │ for(std::vector<unsigned char>::iterator i(in.begin()); i != in.end(); ++i)
{ │ {
std::vector<unsigned char> sub(i, in.end()); │ std::vector<unsigned char> sub(i, in.end());
std::vector<unsigned char> subout(sub.size() + AES_BLOCKSIZE); │ std::vector<unsigned char> subout(sub.size() + AES_BLOCKSIZE);
int _size = enc.Encrypt(&sub[0], sub.size(), &subout[0]); │ int _size = enc.Encrypt(sub.data(), sub.size(), subout.data());
if (_size != 0) │ if (_size != 0)
{ │ {
subout.resize(_size); │ subout.resize(_size);
std::vector<unsigned char> subdecrypted(subout.size()); │ std::vector<unsigned char> subdecrypted(subout.size());
_size = dec.Decrypt(&subout[0], subout.size(), &subdecrypted[0]); │ _size = dec.Decrypt(subout.data(), subout.size(), subdecrypted.data());
subdecrypted.resize(_size); │ subdecrypted.resize(_size);
BOOST_CHECK(decrypted.size() == in.size()); │ BOOST_CHECK(decrypted.size() == in.size());
BOOST_CHECK_MESSAGE(subdecrypted == sub, HexStr(subdecrypted) + std::string( │ BOOST_CHECK_MESSAGE(subdecrypted == sub, HexStr(subdecrypted) + std::string(
} │ }
} │ }
} │
next prev up dogecoin/src/test/crypto_tests.cpp:150 │ bitcoin/src/test/crypto_tests.cpp:93
│
std::vector<unsigned char> key = ParseHex(hexkey); │ std::vector<unsigned char> key = ParseHex(hexkey);
std::vector<unsigned char> iv = ParseHex(hexiv); │ std::vector<unsigned char> iv = ParseHex(hexiv);
std::vector<unsigned char> in = ParseHex(hexin); │ std::vector<unsigned char> in = ParseHex(hexin);
std::vector<unsigned char> correctout = ParseHex(hexout); │ std::vector<unsigned char> correctout = ParseHex(hexout);
std::vector<unsigned char> realout(in.size() + AES_BLOCKSIZE); │ std::vector<unsigned char> realout(in.size() + AES_BLOCKSIZE);
│
// Encrypt the plaintext and verify that it equals the cipher │ // Encrypt the plaintext and verify that it equals the cipher
AES256CBCEncrypt enc(&key[0], &iv[0], pad); │ AES256CBCEncrypt enc(key.data(), iv.data(), pad);
int size = enc.Encrypt(&in[0], in.size(), &realout[0]); │ int size = enc.Encrypt(in.data(), in.size(), realout.data());
realout.resize(size); │ realout.resize(size);
BOOST_CHECK(realout.size() == correctout.size()); │ BOOST_CHECK(realout.size() == correctout.size());
BOOST_CHECK_MESSAGE(realout == correctout, HexStr(realout) + std::string(" != ") + h │ BOOST_CHECK_MESSAGE(realout == correctout, HexStr(realout) + std::string(" != ") + h
│
// Decrypt the cipher and verify that it equals the plaintext │ // Decrypt the cipher and verify that it equals the plaintext
std::vector<unsigned char> decrypted(correctout.size()); │ std::vector<unsigned char> decrypted(correctout.size());
AES256CBCDecrypt dec(&key[0], &iv[0], pad); │ AES256CBCDecrypt dec(key.data(), iv.data(), pad);
size = dec.Decrypt(&correctout[0], correctout.size(), &decrypted[0]); │ size = dec.Decrypt(correctout.data(), correctout.size(), decrypted.data());
decrypted.resize(size); │ decrypted.resize(size);
BOOST_CHECK(decrypted.size() == in.size()); │ BOOST_CHECK(decrypted.size() == in.size());
BOOST_CHECK_MESSAGE(decrypted == in, HexStr(decrypted) + std::string(" != ") + hexin │ BOOST_CHECK_MESSAGE(decrypted == in, HexStr(decrypted) + std::string(" != ") + hexin
│
// Encrypt and re-decrypt substrings of the plaintext and verify that they equal eac │ // Encrypt and re-decrypt substrings of the plaintext and verify that they equal eac
for(std::vector<unsigned char>::iterator i(in.begin()); i != in.end(); ++i) │ for(std::vector<unsigned char>::iterator i(in.begin()); i != in.end(); ++i)
{ │ {
std::vector<unsigned char> sub(i, in.end()); │ std::vector<unsigned char> sub(i, in.end());
std::vector<unsigned char> subout(sub.size() + AES_BLOCKSIZE); │ std::vector<unsigned char> subout(sub.size() + AES_BLOCKSIZE);
int _size = enc.Encrypt(&sub[0], sub.size(), &subout[0]); │ int _size = enc.Encrypt(sub.data(), sub.size(), subout.data());
if (_size != 0) │ if (_size != 0)
{ │ {
subout.resize(_size); │ subout.resize(_size);
std::vector<unsigned char> subdecrypted(subout.size()); │ std::vector<unsigned char> subdecrypted(subout.size());
_size = dec.Decrypt(&subout[0], subout.size(), &subdecrypted[0]); │ _size = dec.Decrypt(subout.data(), subout.size(), subdecrypted.data());
subdecrypted.resize(_size); │ subdecrypted.resize(_size);
BOOST_CHECK(decrypted.size() == in.size()); │ BOOST_CHECK(decrypted.size() == in.size());
BOOST_CHECK_MESSAGE(subdecrypted == sub, HexStr(subdecrypted) + std::string( │ BOOST_CHECK_MESSAGE(subdecrypted == sub, HexStr(subdecrypted) + std::string(
} │ }
} │ }
} │
next prev up dogecoin/src/test/crypto_tests.cpp:150 │ dogecoin/src/test/crypto_tests.cpp:109
│
std::vector<unsigned char> key = ParseHex(hexkey); │ std::vector<unsigned char> key = ParseHex(hexkey);
std::vector<unsigned char> iv = ParseHex(hexiv); │ std::vector<unsigned char> iv = ParseHex(hexiv);
std::vector<unsigned char> in = ParseHex(hexin); │ std::vector<unsigned char> in = ParseHex(hexin);
std::vector<unsigned char> correctout = ParseHex(hexout); │ std::vector<unsigned char> correctout = ParseHex(hexout);
std::vector<unsigned char> realout(in.size() + AES_BLOCKSIZE); │ std::vector<unsigned char> realout(in.size() + AES_BLOCKSIZE);
│
// Encrypt the plaintext and verify that it equals the cipher │ // Encrypt the plaintext and verify that it equals the cipher
AES256CBCEncrypt enc(&key[0], &iv[0], pad); │ AES128CBCEncrypt enc(&key[0], &iv[0], pad);
int size = enc.Encrypt(&in[0], in.size(), &realout[0]); │ int size = enc.Encrypt(&in[0], in.size(), &realout[0]);
realout.resize(size); │ realout.resize(size);
BOOST_CHECK(realout.size() == correctout.size()); │ BOOST_CHECK(realout.size() == correctout.size());
BOOST_CHECK_MESSAGE(realout == correctout, HexStr(realout) + std::string(" != ") + h │ BOOST_CHECK_MESSAGE(realout == correctout, HexStr(realout) + std::string(" != ") + h
│
// Decrypt the cipher and verify that it equals the plaintext │ // Decrypt the cipher and verify that it equals the plaintext
std::vector<unsigned char> decrypted(correctout.size()); │ std::vector<unsigned char> decrypted(correctout.size());
AES256CBCDecrypt dec(&key[0], &iv[0], pad); │ AES128CBCDecrypt dec(&key[0], &iv[0], pad);
size = dec.Decrypt(&correctout[0], correctout.size(), &decrypted[0]); │ size = dec.Decrypt(&correctout[0], correctout.size(), &decrypted[0]);
decrypted.resize(size); │ decrypted.resize(size);
BOOST_CHECK(decrypted.size() == in.size()); │ BOOST_CHECK(decrypted.size() == in.size());
BOOST_CHECK_MESSAGE(decrypted == in, HexStr(decrypted) + std::string(" != ") + hexin │ BOOST_CHECK_MESSAGE(decrypted == in, HexStr(decrypted) + std::string(" != ") + hexin
│
// Encrypt and re-decrypt substrings of the plaintext and verify that they equal eac │ // Encrypt and re-decrypt substrings of the plaintext and verify that they equal eac
for(std::vector<unsigned char>::iterator i(in.begin()); i != in.end(); ++i) │ for(std::vector<unsigned char>::iterator i(in.begin()); i != in.end(); ++i)
{ │ {
std::vector<unsigned char> sub(i, in.end()); │ std::vector<unsigned char> sub(i, in.end());
std::vector<unsigned char> subout(sub.size() + AES_BLOCKSIZE); │ std::vector<unsigned char> subout(sub.size() + AES_BLOCKSIZE);
int _size = enc.Encrypt(&sub[0], sub.size(), &subout[0]); │ int _size = enc.Encrypt(&sub[0], sub.size(), &subout[0]);
if (_size != 0) │ if (_size != 0)
{ │ {
subout.resize(_size); │ subout.resize(_size);
std::vector<unsigned char> subdecrypted(subout.size()); │ std::vector<unsigned char> subdecrypted(subout.size());
_size = dec.Decrypt(&subout[0], subout.size(), &subdecrypted[0]); │ _size = dec.Decrypt(&subout[0], subout.size(), &subdecrypted[0]);
subdecrypted.resize(_size); │ subdecrypted.resize(_size);
BOOST_CHECK(decrypted.size() == in.size()); │ BOOST_CHECK(decrypted.size() == in.size());
BOOST_CHECK_MESSAGE(subdecrypted == sub, HexStr(subdecrypted) + std::string( │ BOOST_CHECK_MESSAGE(subdecrypted == sub, HexStr(subdecrypted) + std::string(
} │ }
} │ }
} │
next prev up dogecoin/src/qt/trafficgraphwidget.cpp:65 │ bitcoin/src/qt/trafficgraphwidget.cpp:64
│
QPainter painter(this); │ QPainter painter(this);
painter.fillRect(rect(), Qt::black); │ painter.fillRect(rect(), Qt::black);
│
if(fMax <= 0.0f) return; │ if(fMax <= 0.0f) return;
│
QColor axisCol(Qt::gray); │ QColor axisCol(Qt::gray);
int h = height() - YMARGIN * 2; │ int h = height() - YMARGIN * 2;
painter.setPen(axisCol); │ painter.setPen(axisCol);
painter.drawLine(XMARGIN, YMARGIN + h, width() - XMARGIN, YMARGIN + h); │ painter.drawLine(XMARGIN, YMARGIN + h, width() - XMARGIN, YMARGIN + h);
│
// decide what order of magnitude we are │ // decide what order of magnitude we are
int base = floor(log10(fMax)); │ int base = floor(log10(fMax));
float val = pow(10.0f, base); │ float val = pow(10.0f, base);
│
const QString units = tr("KB/s"); │ const QString units = tr("kB/s");
const float yMarginText = 2.0; │ const float yMarginText = 2.0;
│
// draw lines │ // draw lines
painter.setPen(axisCol); │ painter.setPen(axisCol);
painter.drawText(XMARGIN, YMARGIN + h - h * val / fMax-yMarginText, QString("%1 %2") │ painter.drawText(XMARGIN, YMARGIN + h - h * val / fMax-yMarginText, QString("%1 %2")
for(float y = val; y < fMax; y += val) { │ for(float y = val; y < fMax; y += val) {
int yy = YMARGIN + h - h * y / fMax; │ int yy = YMARGIN + h - h * y / fMax;
painter.drawLine(XMARGIN, yy, width() - XMARGIN, yy); │ painter.drawLine(XMARGIN, yy, width() - XMARGIN, yy);
} │ }
// if we drew 3 or fewer lines, break them up at the next lower order of magnitude │ // if we drew 3 or fewer lines, break them up at the next lower order of magnitude
if(fMax / val <= 3.0f) { │ if(fMax / val <= 3.0f) {
axisCol = axisCol.darker(); │ axisCol = axisCol.darker();
val = pow(10.0f, base - 1); │ val = pow(10.0f, base - 1);
painter.setPen(axisCol); │ painter.setPen(axisCol);
painter.drawText(XMARGIN, YMARGIN + h - h * val / fMax-yMarginText, QString("%1 │ painter.drawText(XMARGIN, YMARGIN + h - h * val / fMax-yMarginText, QString("%1
int count = 1; │ int count = 1;
for(float y = val; y < fMax; y += val, count++) { │ for(float y = val; y < fMax; y += val, count++) {
// don't overwrite lines drawn above │ // don't overwrite lines drawn above
if(count % 10 == 0) │ if(count % 10 == 0)
continue; │ continue;
int yy = YMARGIN + h - h * y / fMax; │ int yy = YMARGIN + h - h * y / fMax;
painter.drawLine(XMARGIN, yy, width() - XMARGIN, yy); │ painter.drawLine(XMARGIN, yy, width() - XMARGIN, yy);
} │ }
} │ }
│
│ painter.setRenderHint(QPainter::Antialiasing);
if(!vSamplesIn.empty()) { │ if(!vSamplesIn.empty()) {
QPainterPath p; │ QPainterPath p;
paintPath(p, vSamplesIn); │ paintPath(p, vSamplesIn);
painter.fillPath(p, QColor(0, 255, 0, 128)); │ painter.fillPath(p, QColor(0, 255, 0, 128));
painter.setPen(Qt::green); │ painter.setPen(Qt::green);
painter.drawPath(p); │ painter.drawPath(p);
} │ }
if(!vSamplesOut.empty()) { │ if(!vSamplesOut.empty()) {
QPainterPath p; │ QPainterPath p;
paintPath(p, vSamplesOut); │ paintPath(p, vSamplesOut);
painter.fillPath(p, QColor(255, 0, 0, 128)); │ painter.fillPath(p, QColor(255, 0, 0, 128));
painter.setPen(Qt::red); │ painter.setPen(Qt::red);
painter.drawPath(p); │ painter.drawPath(p);
} │ }
} │
next prev up dogecoin/src/torcontrol.cpp:137 │ bitcoin/src/torcontrol.cpp:68
│
TorControlConnection *self = (TorControlConnection*)ctx; │ TorControlConnection *self = static_cast<TorControlConnection*>(ctx);
struct evbuffer *input = bufferevent_get_input(bev); │ struct evbuffer *input = bufferevent_get_input(bev);
size_t n_read_out = 0; │ size_t n_read_out = 0;
char *line; │ char *line;
assert(input); │ assert(input);
// If there is not a whole line to read, evbuffer_readln returns NULL │ // If there is not a whole line to read, evbuffer_readln returns nullptr
while((line = evbuffer_readln(input, &n_read_out, EVBUFFER_EOL_CRLF)) != NULL) │ while((line = evbuffer_readln(input, &n_read_out, EVBUFFER_EOL_CRLF)) != nullptr)
{ │ {
std::string s(line, n_read_out); │ std::string s(line, n_read_out);
free(line); │ free(line);
if (s.size() < 4) // Short line │ if (s.size() < 4) // Short line
continue; │ continue;
// <status>(-|+| )<data><CRLF> │ // <status>(-|+| )<data><CRLF>
self->message.code = atoi(s.substr(0,3)); │ self->message.code = LocaleIndependentAtoi<int>(s.substr(0,3));
self->message.lines.push_back(s.substr(4)); │ self->message.lines.push_back(s.substr(4));
char ch = s[3]; // '-','+' or ' ' │ char ch = s[3]; // '-','+' or ' '
if (ch == ' ') { │ if (ch == ' ') {
// Final line, dispatch reply and clean up │ // Final line, dispatch reply and clean up
if (self->message.code >= 600) { │ if (self->message.code >= 600) {
// Dispatch async notifications to async handler │ // Dispatch async notifications to async handler
// Synchronous and asynchronous messages are never interleaved │ // Synchronous and asynchronous messages are never interleaved
self->async_handler(*self, self->message); │ self->async_handler(*self, self->message);
} else { │ } else {
if (!self->reply_handlers.empty()) { │ if (!self->reply_handlers.empty()) {
// Invoke reply handler with message │ // Invoke reply handler with message
self->reply_handlers.front()(*self, self->message); │ self->reply_handlers.front()(*self, self->message);
self->reply_handlers.pop_front(); │ self->reply_handlers.pop_front();
} else { │ } else {
LogPrint("tor", "tor: Received unexpected sync reply %i\n", self->me │ LogPrint(BCLog::TOR, "tor: Received unexpected sync reply %i\n", sel
} │ }
} │ }
self->message.Clear(); │ self->message.Clear();
} │ }
} │ }
// Check for size of buffer - protect against memory exhaustion with very long line │ // Check for size of buffer - protect against memory exhaustion with very long line
// Do this after evbuffer_readln to make sure all full lines have been │ // Do this after evbuffer_readln to make sure all full lines have been
// removed from the buffer. Everything left is an incomplete line. │ // removed from the buffer. Everything left is an incomplete line.
if (evbuffer_get_length(input) > MAX_LINE_LENGTH) { │ if (evbuffer_get_length(input) > MAX_LINE_LENGTH) {
LogPrintf("tor: Disconnecting because MAX_LINE_LENGTH exceeded\n"); │ LogPrintf("tor: Disconnecting because MAX_LINE_LENGTH exceeded\n");
self->Disconnect(); │ self->Disconnect();
} │ }
} │
next prev up bitcoin/src/test/multisig_tests.cpp:139 │ dogecoin/src/test/multisig_tests.cpp:142
│
CKey key[4]; │ CKey key[4];
for (int i = 0; i < 4; i++) │ for (int i = 0; i < 4; i++)
key[i].MakeNewKey(true); │ key[i].MakeNewKey(true);
│
TxoutType whichType; │ txnouttype whichType;
│
CScript a_and_b; │ CScript a_and_b;
a_and_b << OP_2 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetPubKey │ a_and_b << OP_2 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetPubKey
BOOST_CHECK(::IsStandard(a_and_b, whichType)); │ BOOST_CHECK(::IsStandard(a_and_b, whichType));
│
CScript a_or_b; │ CScript a_or_b;
a_or_b << OP_1 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetPubKey │ a_or_b << OP_1 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetPubKey
BOOST_CHECK(::IsStandard(a_or_b, whichType)); │ BOOST_CHECK(::IsStandard(a_or_b, whichType));
│
CScript escrow; │ CScript escrow;
escrow << OP_2 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetPubKey( │ escrow << OP_2 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetPubKey(
BOOST_CHECK(::IsStandard(escrow, whichType)); │ BOOST_CHECK(::IsStandard(escrow, whichType));
│
CScript one_of_four; │ CScript one_of_four;
one_of_four << OP_1 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetPu │ one_of_four << OP_1 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetPu
BOOST_CHECK(!::IsStandard(one_of_four, whichType)); │ BOOST_CHECK(!::IsStandard(one_of_four, whichType));
│
CScript malformed[6]; │ CScript malformed[6];
malformed[0] << OP_3 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetP │ malformed[0] << OP_3 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetP
malformed[1] << OP_2 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetP │ malformed[1] << OP_2 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetP
malformed[2] << OP_0 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetP │ malformed[2] << OP_0 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetP
malformed[3] << OP_1 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetP │ malformed[3] << OP_1 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetP
malformed[4] << OP_1 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetP │ malformed[4] << OP_1 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetP
malformed[5] << OP_1 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetP │ malformed[5] << OP_1 << ToByteVector(key[0].GetPubKey()) << ToByteVector(key[1].GetP
│
for (int i = 0; i < 6; i++) │ for (int i = 0; i < 6; i++)
BOOST_CHECK(!::IsStandard(malformed[i], whichType)); │ BOOST_CHECK(!::IsStandard(malformed[i], whichType));
} │
next prev up dogecoin/src/net_processing.cpp:3265 │ bitcoin/src/net_processing.cpp:5027
│
// Detect whether this is a stalling initial-headers-sync peer │ // Detect whether this is a stalling initial-headers-sync peer
if (pindexBestHeader->GetBlockTime() <= GetAdjustedTime() - 24*60*60) { │ if (m_chainman.m_best_header->GetBlockTime() <= GetAdjustedTime() - 24 * 60
if (nNow > state.nHeadersSyncTimeout && nSyncStarted == 1 && (nPreferred │ if (current_time > state.m_headers_sync_timeout && nSyncStarted == 1 &&
// Disconnect a (non-whitelisted) peer if it is our only sync peer, │ // Disconnect a peer (without NetPermissionFlags::NoBan permission)
// and we have others we could be using instead. │ // and we have others we could be using instead.
// Note: If all our peers are inbound, then we won't │ // Note: If all our peers are inbound, then we won't
// disconnect our sync peer for stalling; we have bigger │ // disconnect our sync peer for stalling; we have bigger
// problems if we can't get any outbound peers. │ // problems if we can't get any outbound peers.
if (!pto->fWhitelisted) { │ if (!pto->HasPermission(NetPermissionFlags::NoBan)) {
LogPrintf("Timeout downloading headers from peer=%d, disconnecti │ LogPrintf("Timeout downloading headers from peer=%d, disconnecti
pto->fDisconnect = true; │ pto->fDisconnect = true;
return true; │ return true;
} else { │ } else {
LogPrintf("Timeout downloading headers from whitelisted peer=%d, │ LogPrintf("Timeout downloading headers from noban peer=%d, not d
// Reset the headers sync state so that we have a │ // Reset the headers sync state so that we have a
// chance to try downloading from a different peer. │ // chance to try downloading from a different peer.
// Note: this will also result in at least one more │ // Note: this will also result in at least one more
// getheaders message to be sent to │ // getheaders message to be sent to
// this peer (eventually). │ // this peer (eventually).
state.fSyncStarted = false; │ state.fSyncStarted = false;
nSyncStarted--; │ nSyncStarted--;
state.nHeadersSyncTimeout = 0; │ state.m_headers_sync_timeout = 0us;
} │ }
} │ }
} else { │ } else {
// After we've caught up once, reset the timeout so we can't trigger │ // After we've caught up once, reset the timeout so we can't trigger
// disconnect later. │ // disconnect later.
state.nHeadersSyncTimeout = std::numeric_limits<int64_t>::max(); │ state.m_headers_sync_timeout = std::chrono::microseconds::max();
} │ }
} │
next prev up dogecoin/src/test/script_tests.cpp:954 │ bitcoin/src/test/script_tests.cpp:934
│
// Read tests from test/data/script_tests.json │ // Read tests from test/data/script_tests.json
// Format is an array of arrays │ // Format is an array of arrays
// Inner arrays are [ ["wit"..., nValue]?, "scriptSig", "scriptPubKey", "flags", "ex │ // Inner arrays are [ ["wit"..., nValue]?, "scriptSig", "scriptPubKey", "flags", "ex
// ... where scriptSig and scriptPubKey are stringified │ // ... where scriptSig and scriptPubKey are stringified
// scripts. │ // scripts.
// If a witness is given, then the last value in the array should be the │ // If a witness is given, then the last value in the array should be the
// amount (nValue) to use in the crediting tx │ // amount (nValue) to use in the crediting tx
UniValue tests = read_json(std::string(json_tests::script_tests, json_tests::script_ │ UniValue tests = read_json(std::string(json_tests::script_tests, json_tests::script_
│
for (unsigned int idx = 0; idx < tests.size(); idx++) { │ for (unsigned int idx = 0; idx < tests.size(); idx++) {
UniValue test = tests[idx]; │ UniValue test = tests[idx];
std::string strTest = test.write(); │ std::string strTest = test.write();
CScriptWitness witness; │ CScriptWitness witness;
CAmount nValue = 0; │ CAmount nValue = 0;
unsigned int pos = 0; │ unsigned int pos = 0;
if (test.size() > 0 && test[pos].isArray()) { │ if (test.size() > 0 && test[pos].isArray()) {
unsigned int i=0; │ unsigned int i=0;
for (i = 0; i < test[pos].size()-1; i++) { │ for (i = 0; i < test[pos].size()-1; i++) {
witness.stack.push_back(ParseHex(test[pos][i].get_str())); │ witness.stack.push_back(ParseHex(test[pos][i].get_str()));
} │ }
nValue = AmountFromValue(test[pos][i]); │ nValue = AmountFromValue(test[pos][i]);
pos++; │ pos++;
} │ }
if (test.size() < 4 + pos) // Allow size > 3; extra stuff ignored (useful for co │ if (test.size() < 4 + pos) // Allow size > 3; extra stuff ignored (useful for co
{ │ {
if (test.size() != 1) { │ if (test.size() != 1) {
BOOST_ERROR("Bad test: " << strTest); │ BOOST_ERROR("Bad test: " << strTest);
} │ }
continue; │ continue;
} │ }
std::string scriptSigString = test[pos++].get_str(); │ std::string scriptSigString = test[pos++].get_str();
CScript scriptSig = ParseScript(scriptSigString); │ CScript scriptSig = ParseScript(scriptSigString);
std::string scriptPubKeyString = test[pos++].get_str(); │ std::string scriptPubKeyString = test[pos++].get_str();
CScript scriptPubKey = ParseScript(scriptPubKeyString); │ CScript scriptPubKey = ParseScript(scriptPubKeyString);
unsigned int scriptflags = ParseScriptFlags(test[pos++].get_str()); │ unsigned int scriptflags = ParseScriptFlags(test[pos++].get_str());
int scriptError = ParseScriptError(test[pos++].get_str()); │ int scriptError = ParseScriptError(test[pos++].get_str());
│
DoTest(scriptPubKey, scriptSig, witness, scriptflags, strTest, scriptError, nVal │ DoTest(scriptPubKey, scriptSig, witness, scriptflags, strTest, scriptError, nVal
} │ }
} │
next prev up dogecoin/src/test/skiplist_tests.cpp:104 │ bitcoin/src/test/skiplist_tests.cpp:102
│
std::vector<uint256> vHashMain(100000); │ std::vector<uint256> vHashMain(100000);
std::vector<CBlockIndex> vBlocksMain(100000); │ std::vector<CBlockIndex> vBlocksMain(100000);
for (unsigned int i=0; i<vBlocksMain.size(); i++) { │ for (unsigned int i=0; i<vBlocksMain.size(); i++) {
vHashMain[i] = ArithToUint256(i); // Set the hash equal to the height │ vHashMain[i] = ArithToUint256(i); // Set the hash equal to the height
vBlocksMain[i].nHeight = i; │ vBlocksMain[i].nHeight = i;
vBlocksMain[i].pprev = i ? &vBlocksMain[i - 1] : NULL; │ vBlocksMain[i].pprev = i ? &vBlocksMain[i - 1] : nullptr;
vBlocksMain[i].phashBlock = &vHashMain[i]; │ vBlocksMain[i].phashBlock = &vHashMain[i];
vBlocksMain[i].BuildSkip(); │ vBlocksMain[i].BuildSkip();
if (i < 10) { │ if (i < 10) {
vBlocksMain[i].nTime = i; │ vBlocksMain[i].nTime = i;
vBlocksMain[i].nTimeMax = i; │ vBlocksMain[i].nTimeMax = i;
} else { │ } else {
// randomly choose something in the range [MTP, MTP*2] │ // randomly choose something in the range [MTP, MTP*2]
int64_t medianTimePast = vBlocksMain[i].GetMedianTimePast(); │ int64_t medianTimePast = vBlocksMain[i].GetMedianTimePast();
int r = insecure_rand() % medianTimePast; │ int r{int(InsecureRandRange(medianTimePast))};
vBlocksMain[i].nTime = r + medianTimePast; │ vBlocksMain[i].nTime = uint32_t(r + medianTimePast);
vBlocksMain[i].nTimeMax = std::max(vBlocksMain[i].nTime, vBlocksMain[i-1].nT │ vBlocksMain[i].nTimeMax = std::max(vBlocksMain[i].nTime, vBlocksMain[i-1].nT
} │ }
} │ }
// Check that we set nTimeMax up correctly. │ // Check that we set nTimeMax up correctly.
unsigned int curTimeMax = 0; │ unsigned int curTimeMax = 0;
for (unsigned int i=0; i<vBlocksMain.size(); ++i) { │ for (unsigned int i=0; i<vBlocksMain.size(); ++i) {
curTimeMax = std::max(curTimeMax, vBlocksMain[i].nTime); │ curTimeMax = std::max(curTimeMax, vBlocksMain[i].nTime);
BOOST_CHECK(curTimeMax == vBlocksMain[i].nTimeMax); │ BOOST_CHECK(curTimeMax == vBlocksMain[i].nTimeMax);
} │ }
│
// Build a CChain for the main branch. │ // Build a CChain for the main branch.
CChain chain; │ CChain chain;
chain.SetTip(&vBlocksMain.back()); │ chain.SetTip(&vBlocksMain.back());
│
// Verify that FindEarliestAtLeast is correct. │ // Verify that FindEarliestAtLeast is correct.
for (unsigned int i=0; i<10000; ++i) { │ for (unsigned int i=0; i<10000; ++i) {
// Pick a random element in vBlocksMain. │ // Pick a random element in vBlocksMain.
int r = insecure_rand() % vBlocksMain.size(); │ int r = InsecureRandRange(vBlocksMain.size());
int64_t test_time = vBlocksMain[r].nTime; │ int64_t test_time = vBlocksMain[r].nTime;
CBlockIndex *ret = chain.FindEarliestAtLeast(test_time); │ CBlockIndex* ret = chain.FindEarliestAtLeast(test_time, 0);
BOOST_CHECK(ret->nTimeMax >= test_time); │ BOOST_CHECK(ret->nTimeMax >= test_time);
BOOST_CHECK((ret->pprev==NULL) || ret->pprev->nTimeMax < test_time); │ BOOST_CHECK((ret->pprev==nullptr) || ret->pprev->nTimeMax < test_time);
BOOST_CHECK(vBlocksMain[r].GetAncestor(ret->nHeight) == ret); │ BOOST_CHECK(vBlocksMain[r].GetAncestor(ret->nHeight) == ret);
} │ }
} │
next prev up bitcoin/src/rpc/blockchain.cpp:508 │ bitcoin/src/rpc/blockchain.cpp:615
"for verbose = true", │ "for verbosity = 1", RPCResult::Type::OBJ, "", "", │ RPCResult::Type::OBJ, "", "", { │ { {RPCResult::Type::STR_HEX, "hash", "the block hash (same as │ {RPCResult::Type::STR_HEX, "hash", "the block hash (same as provided {RPCResult::Type::NUM, "confirmations", "The number of confi │ {RPCResult::Type::NUM, "confirmations", "The number of confirmations {RPCResult::Type::NUM, "height", "The block height or index" │ {RPCResult::Type::NUM, "size", "The block size"}, {RPCResult::Type::NUM, "version", "The block version"}, │ {RPCResult::Type::NUM, "strippedsize", "The block size excluding wit {RPCResult::Type::STR_HEX, "versionHex", "The block version │ {RPCResult::Type::NUM, "weight", "The block weight as defined in BIP {RPCResult::Type::STR_HEX, "merkleroot", "The merkle root"}, │ {RPCResult::Type::NUM, "height", "The block height or index"}, {RPCResult::Type::NUM_TIME, "time", "The block time expresse │ {RPCResult::Type::NUM, "version", "The block version"}, {RPCResult::Type::NUM_TIME, "mediantime", "The median block │ {RPCResult::Type::STR_HEX, "versionHex", "The block version formatte {RPCResult::Type::NUM, "nonce", "The nonce"}, │ {RPCResult::Type::STR_HEX, "merkleroot", "The merkle root"}, {RPCResult::Type::STR_HEX, "bits", "The bits"}, │ {RPCResult::Type::ARR, "tx", "The transaction ids", {RPCResult::Type::NUM, "difficulty", "The difficulty"}, │ {{RPCResult::Type::STR_HEX, "", "The transaction id"}}}, {RPCResult::Type::STR_HEX, "chainwork", "Expected number of │ {RPCResult::Type::NUM_TIME, "time", "The block time expressed {RPCResult::Type::NUM, "nTx", "The number of transactions in │ {RPCResult::Type::NUM_TIME, "mediantime", "The median block time exp {RPCResult::Type::STR_HEX, "previousblockhash", /*optional=* │ {RPCResult::Type::NUM, "nonce", "The nonce"}, {RPCResult::Type::STR_HEX, "nextblockhash", /*optional=*/tru │ {RPCResult::Type::STR_HEX, "bits", "The bits"}, │ {RPCResult::Type::STR_HEX, "chainwork", "Expected number of hashes r │ {RPCResult::Type::NUM, "nTx", "The number of transactions in the blo │ {RPCResult::Type::STR_HEX, "previousblockhash", /*optional=*/true, " │ {RPCResult::Type::STR_HEX, "nextblockhash", /*optional=*/true, "The │ }
next prev up dogecoin/src/test/scriptnum_tests.cpp:114 │ bitcoin/src/test/scriptnum_tests.cpp:110
│
const CScriptNum10 bignum1(num1); │ const CScriptNum10 bignum1(num1);
const CScriptNum10 bignum2(num2); │ const CScriptNum10 bignum2(num2);
const CScriptNum scriptnum1(num1); │ const CScriptNum scriptnum1(num1);
const CScriptNum scriptnum2(num2); │ const CScriptNum scriptnum2(num2);
│
BOOST_CHECK((bignum1 == bignum1) == (scriptnum1 == scriptnum1)); │ BOOST_CHECK((bignum1 == bignum1) == (scriptnum1 == scriptnum1));
BOOST_CHECK((bignum1 != bignum1) == (scriptnum1 != scriptnum1)); │ BOOST_CHECK((bignum1 != bignum1) == (scriptnum1 != scriptnum1));
BOOST_CHECK((bignum1 < bignum1) == (scriptnum1 < scriptnum1)); │ BOOST_CHECK((bignum1 < bignum1) == (scriptnum1 < scriptnum1));
BOOST_CHECK((bignum1 > bignum1) == (scriptnum1 > scriptnum1)); │ BOOST_CHECK((bignum1 > bignum1) == (scriptnum1 > scriptnum1));
BOOST_CHECK((bignum1 >= bignum1) == (scriptnum1 >= scriptnum1)); │ BOOST_CHECK((bignum1 >= bignum1) == (scriptnum1 >= scriptnum1));
BOOST_CHECK((bignum1 <= bignum1) == (scriptnum1 <= scriptnum1)); │ BOOST_CHECK((bignum1 <= bignum1) == (scriptnum1 <= scriptnum1));
│
BOOST_CHECK((bignum1 == bignum1) == (scriptnum1 == num1)); │ BOOST_CHECK((bignum1 == bignum1) == (scriptnum1 == num1));
BOOST_CHECK((bignum1 != bignum1) == (scriptnum1 != num1)); │ BOOST_CHECK((bignum1 != bignum1) == (scriptnum1 != num1));
BOOST_CHECK((bignum1 < bignum1) == (scriptnum1 < num1)); │ BOOST_CHECK((bignum1 < bignum1) == (scriptnum1 < num1));
BOOST_CHECK((bignum1 > bignum1) == (scriptnum1 > num1)); │ BOOST_CHECK((bignum1 > bignum1) == (scriptnum1 > num1));
BOOST_CHECK((bignum1 >= bignum1) == (scriptnum1 >= num1)); │ BOOST_CHECK((bignum1 >= bignum1) == (scriptnum1 >= num1));
BOOST_CHECK((bignum1 <= bignum1) == (scriptnum1 <= num1)); │ BOOST_CHECK((bignum1 <= bignum1) == (scriptnum1 <= num1));
│
BOOST_CHECK((bignum1 == bignum2) == (scriptnum1 == scriptnum2)); │ BOOST_CHECK((bignum1 == bignum2) == (scriptnum1 == scriptnum2));
BOOST_CHECK((bignum1 != bignum2) == (scriptnum1 != scriptnum2)); │ BOOST_CHECK((bignum1 != bignum2) == (scriptnum1 != scriptnum2));
BOOST_CHECK((bignum1 < bignum2) == (scriptnum1 < scriptnum2)); │ BOOST_CHECK((bignum1 < bignum2) == (scriptnum1 < scriptnum2));
BOOST_CHECK((bignum1 > bignum2) == (scriptnum1 > scriptnum2)); │ BOOST_CHECK((bignum1 > bignum2) == (scriptnum1 > scriptnum2));
BOOST_CHECK((bignum1 >= bignum2) == (scriptnum1 >= scriptnum2)); │ BOOST_CHECK((bignum1 >= bignum2) == (scriptnum1 >= scriptnum2));
BOOST_CHECK((bignum1 <= bignum2) == (scriptnum1 <= scriptnum2)); │ BOOST_CHECK((bignum1 <= bignum2) == (scriptnum1 <= scriptnum2));
│
BOOST_CHECK((bignum1 == bignum2) == (scriptnum1 == num2)); │ BOOST_CHECK((bignum1 == bignum2) == (scriptnum1 == num2));
BOOST_CHECK((bignum1 != bignum2) == (scriptnum1 != num2)); │ BOOST_CHECK((bignum1 != bignum2) == (scriptnum1 != num2));
BOOST_CHECK((bignum1 < bignum2) == (scriptnum1 < num2)); │ BOOST_CHECK((bignum1 < bignum2) == (scriptnum1 < num2));
BOOST_CHECK((bignum1 > bignum2) == (scriptnum1 > num2)); │ BOOST_CHECK((bignum1 > bignum2) == (scriptnum1 > num2));
BOOST_CHECK((bignum1 >= bignum2) == (scriptnum1 >= num2)); │ BOOST_CHECK((bignum1 >= bignum2) == (scriptnum1 >= num2));
BOOST_CHECK((bignum1 <= bignum2) == (scriptnum1 <= num2)); │ BOOST_CHECK((bignum1 <= bignum2) == (scriptnum1 <= num2));
} │
next prev up bitcoin/src/rpc/blockchain.cpp:253 │ bitcoin/src/rpc/blockchain.cpp:341
│
return RPCHelpMan{"waitfornewblock", │ return RPCHelpMan{"waitforblockheight",
"\nWaits for a specific new block and returns useful info about it.\n" │ "\nWaits for (at least) block height and returns the height and hash\n"
│ "of the current tip.\n"
"\nReturns the current block on timeout or exit.\n", │ "\nReturns the current block on timeout or exit.\n",
{ │ {
│ {"height", RPCArg::Type::NUM, RPCArg::Optional::NO, "Block height to
{"timeout", RPCArg::Type::NUM, RPCArg::Default{0}, "Time in millisec │ {"timeout", RPCArg::Type::NUM, RPCArg::Default{0}, "Time in millisec
}, │ },
RPCResult{ │ RPCResult{
RPCResult::Type::OBJ, "", "", │ RPCResult::Type::OBJ, "", "",
{ │ {
{RPCResult::Type::STR_HEX, "hash", "The blockhash"}, │ {RPCResult::Type::STR_HEX, "hash", "The blockhash"},
{RPCResult::Type::NUM, "height", "Block height"}, │ {RPCResult::Type::NUM, "height", "Block height"},
}}, │ }},
RPCExamples{ │ RPCExamples{
HelpExampleCli("waitfornewblock", "1000") │ HelpExampleCli("waitforblockheight", "100 1000")
+ HelpExampleRpc("waitfornewblock", "1000") │ + HelpExampleRpc("waitforblockheight", "100, 1000")
}, │ },
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue │ [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{ │ {
int timeout = 0; │ int timeout = 0;
if (!request.params[0].isNull()) │
timeout = request.params[0].get_int(); │ int height = request.params[0].get_int();
│
│ if (!request.params[1].isNull())
│ timeout = request.params[1].get_int();
│
CUpdatedBlock block; │ CUpdatedBlock block;
{ │ {
WAIT_LOCK(cs_blockchange, lock); │ WAIT_LOCK(cs_blockchange, lock);
block = latestblock; │
if(timeout) │ if(timeout)
cond_blockchange.wait_for(lock, std::chrono::milliseconds(timeout), [&block] │ cond_blockchange.wait_for(lock, std::chrono::milliseconds(timeout), [&height
else │ else
cond_blockchange.wait(lock, [&block]() EXCLUSIVE_LOCKS_REQUIRED(cs_blockchan │ cond_blockchange.wait(lock, [&height]() EXCLUSIVE_LOCKS_REQUIRED(cs_blockcha
block = latestblock; │ block = latestblock;
} │ }
UniValue ret(UniValue::VOBJ); │ UniValue ret(UniValue::VOBJ);
ret.pushKV("hash", block.hash.GetHex()); │ ret.pushKV("hash", block.hash.GetHex());
ret.pushKV("height", block.height); │ ret.pushKV("height", block.height);
return ret; │ return ret;
}, │ },
}; │ };
} │
next prev up dogecoin/src/blockencodings.cpp:178 │ bitcoin/src/blockencodings.cpp:176
│
assert(!header.IsNull()); │ assert(!header.IsNull());
uint256 hash = header.GetHash(); │ uint256 hash = header.GetHash();
block = header; │ block = header;
block.vtx.resize(txn_available.size()); │ block.vtx.resize(txn_available.size());
│
size_t tx_missing_offset = 0; │ size_t tx_missing_offset = 0;
for (size_t i = 0; i < txn_available.size(); i++) { │ for (size_t i = 0; i < txn_available.size(); i++) {
if (!txn_available[i]) { │ if (!txn_available[i]) {
if (vtx_missing.size() <= tx_missing_offset) │ if (vtx_missing.size() <= tx_missing_offset)
return READ_STATUS_INVALID; │ return READ_STATUS_INVALID;
block.vtx[i] = vtx_missing[tx_missing_offset++]; │ block.vtx[i] = vtx_missing[tx_missing_offset++];
} else │ } else
block.vtx[i] = std::move(txn_available[i]); │ block.vtx[i] = std::move(txn_available[i]);
} │ }
│
// Make sure we can't call FillBlock again. │ // Make sure we can't call FillBlock again.
header.SetNull(); │ header.SetNull();
txn_available.clear(); │ txn_available.clear();
│
if (vtx_missing.size() != tx_missing_offset) │ if (vtx_missing.size() != tx_missing_offset)
return READ_STATUS_INVALID; │ return READ_STATUS_INVALID;
│
CValidationState state; │ BlockValidationState state;
// TODO: Make sure lack of block height doesn't cause verification problems │ if (!CheckBlock(block, state, Params().GetConsensus())) {
if (!CheckBlock(block, state)) { │
// TODO: We really want to just check merkle tree manually here, │ // TODO: We really want to just check merkle tree manually here,
// but that is expensive, and CheckBlock caches a block's │ // but that is expensive, and CheckBlock caches a block's
// "checked-status" (in the CBlock?). CBlock should be able to │ // "checked-status" (in the CBlock?). CBlock should be able to
// check its own merkle root and cache that check. │ // check its own merkle root and cache that check.
if (state.CorruptionPossible()) │ if (state.GetResult() == BlockValidationResult::BLOCK_MUTATED)
return READ_STATUS_FAILED; // Possible Short ID collision │ return READ_STATUS_FAILED; // Possible Short ID collision
return READ_STATUS_CHECKBLOCK_FAILED; │ return READ_STATUS_CHECKBLOCK_FAILED;
} │ }
│
LogPrint("cmpctblock", "Successfully reconstructed block %s with %lu txn prefilled, │ LogPrint(BCLog::CMPCTBLOCK, "Successfully reconstructed block %s with %lu txn prefil
if (vtx_missing.size() < 5) { │ if (vtx_missing.size() < 5) {
for (const auto& tx : vtx_missing) │ for (const auto& tx : vtx_missing) {
LogPrint("cmpctblock", "Reconstructed block %s required tx %s\n", hash.ToStr │ LogPrint(BCLog::CMPCTBLOCK, "Reconstructed block %s required tx %s\n", hash.
│ }
} │ }
│
return READ_STATUS_OK; │ return READ_STATUS_OK;
} │
next prev up bitcoin/src/test/sighash_tests.cpp:28 │ dogecoin/src/test/sighash_tests.cpp:29
│
│ static const uint256 one(uint256S("0000000000000000000000000000000000000000000000000
if (nIn >= txTo.vin.size()) │ if (nIn >= txTo.vin.size())
{ │ {
return uint256::ONE; │ printf("ERROR: SignatureHash(): nIn=%d out of range\n", nIn);
│ return one;
} │ }
CMutableTransaction txTmp(txTo); │ CMutableTransaction txTmp(txTo);
│
// In case concatenating two scripts ends up with two codeseparators, │ // In case concatenating two scripts ends up with two codeseparators,
// or an extra one at the end, this prevents all those possible incompatibilities. │ // or an extra one at the end, this prevents all those possible incompatibilities.
FindAndDelete(scriptCode, CScript(OP_CODESEPARATOR)); │ scriptCode.FindAndDelete(CScript(OP_CODESEPARATOR));
│
// Blank out other inputs' signatures │ // Blank out other inputs' signatures
for (unsigned int i = 0; i < txTmp.vin.size(); i++) │ for (unsigned int i = 0; i < txTmp.vin.size(); i++)
txTmp.vin[i].scriptSig = CScript(); │ txTmp.vin[i].scriptSig = CScript();
txTmp.vin[nIn].scriptSig = scriptCode; │ txTmp.vin[nIn].scriptSig = scriptCode;
│
// Blank out some of the outputs │ // Blank out some of the outputs
if ((nHashType & 0x1f) == SIGHASH_NONE) │ if ((nHashType & 0x1f) == SIGHASH_NONE)
{ │ {
// Wildcard payee │ // Wildcard payee
txTmp.vout.clear(); │ txTmp.vout.clear();
│
// Let the others update at will │ // Let the others update at will
for (unsigned int i = 0; i < txTmp.vin.size(); i++) │ for (unsigned int i = 0; i < txTmp.vin.size(); i++)
if (i != nIn) │ if (i != nIn)
txTmp.vin[i].nSequence = 0; │ txTmp.vin[i].nSequence = 0;
} │ }
else if ((nHashType & 0x1f) == SIGHASH_SINGLE) │ else if ((nHashType & 0x1f) == SIGHASH_SINGLE)
{ │ {
// Only lock-in the txout payee at same index as txin │ // Only lock-in the txout payee at same index as txin
unsigned int nOut = nIn; │ unsigned int nOut = nIn;
if (nOut >= txTmp.vout.size()) │ if (nOut >= txTmp.vout.size())
{ │ {
return uint256::ONE; │ printf("ERROR: SignatureHash(): nOut=%d out of range\n", nOut);
│ return one;
} │ }
txTmp.vout.resize(nOut+1); │ txTmp.vout.resize(nOut+1);
for (unsigned int i = 0; i < nOut; i++) │ for (unsigned int i = 0; i < nOut; i++)
txTmp.vout[i].SetNull(); │ txTmp.vout[i].SetNull();
│
// Let the others update at will │ // Let the others update at will
for (unsigned int i = 0; i < txTmp.vin.size(); i++) │ for (unsigned int i = 0; i < txTmp.vin.size(); i++)
if (i != nIn) │ if (i != nIn)
txTmp.vin[i].nSequence = 0; │ txTmp.vin[i].nSequence = 0;
} │ }
│
// Blank out other inputs completely, not recommended for open transactions │ // Blank out other inputs completely, not recommended for open transactions
if (nHashType & SIGHASH_ANYONECANPAY) │ if (nHashType & SIGHASH_ANYONECANPAY)
{ │ {
txTmp.vin[0] = txTmp.vin[nIn]; │ txTmp.vin[0] = txTmp.vin[nIn];
txTmp.vin.resize(1); │ txTmp.vin.resize(1);
} │ }
│
// Serialize and hash │ // Serialize and hash
CHashWriter ss(SER_GETHASH, SERIALIZE_TRANSACTION_NO_WITNESS); │ CHashWriter ss(SER_GETHASH, SERIALIZE_TRANSACTION_NO_WITNESS);
ss << txTmp << nHashType; │ ss << txTmp << nHashType;
return ss.GetHash(); │ return ss.GetHash();
} │
next prev up bitcoin/src/qt/rpcconsole.cpp:609 │ dogecoin/src/qt/rpcconsole.cpp:492
│
if(event->type() == QEvent::KeyPress) // Special key handling │ if(event->type() == QEvent::KeyPress) // Special key handling
{ │ {
QKeyEvent *keyevt = static_cast<QKeyEvent*>(event); │ QKeyEvent *keyevt = static_cast<QKeyEvent*>(event);
int key = keyevt->key(); │ int key = keyevt->key();
Qt::KeyboardModifiers mod = keyevt->modifiers(); │ Qt::KeyboardModifiers mod = keyevt->modifiers();
switch(key) │ switch(key)
{ │ {
case Qt::Key_Up: if(obj == ui->lineEdit) { browseHistory(-1); return true; } bre │ case Qt::Key_Up: if(obj == ui->lineEdit) { browseHistory(-1); return true; } bre
case Qt::Key_Down: if(obj == ui->lineEdit) { browseHistory(1); return true; } br │ case Qt::Key_Down: if(obj == ui->lineEdit) { browseHistory(1); return true; } br
case Qt::Key_PageUp: /* pass paging keys to messages widget */ │ case Qt::Key_PageUp: /* pass paging keys to messages widget */
case Qt::Key_PageDown: │ case Qt::Key_PageDown:
if (obj == ui->lineEdit) { │ if(obj == ui->lineEdit)
QApplication::sendEvent(ui->messagesWidget, keyevt); │ {
│ QApplication::postEvent(ui->messagesWidget, new QKeyEvent(*keyevt));
return true; │ return true;
} │ }
break; │ break;
case Qt::Key_Return: │ case Qt::Key_Return:
case Qt::Key_Enter: │ case Qt::Key_Enter:
// forward these events to lineEdit │ // forward these events to lineEdit
if (obj == autoCompleter->popup()) { │ if(obj == autoCompleter->popup()) {
QApplication::sendEvent(ui->lineEdit, keyevt); │ QApplication::postEvent(ui->lineEdit, new QKeyEvent(*keyevt));
autoCompleter->popup()->hide(); │
return true; │ return true;
} │ }
break; │ break;
default: │ default:
// Typing in messages widget brings focus to line edit, and redirects key th │ // Typing in messages widget brings focus to line edit, and redirects key th
// Exclude most combinations and keys that emit no text, except paste shortc │ // Exclude most combinations and keys that emit no text, except paste shortc
if(obj == ui->messagesWidget && ( │ if(obj == ui->messagesWidget && (
(!mod && !keyevt->text().isEmpty() && key != Qt::Key_Tab) || │ (!mod && !keyevt->text().isEmpty() && key != Qt::Key_Tab) ||
((mod & Qt::ControlModifier) && key == Qt::Key_V) || │ ((mod & Qt::ControlModifier) && key == Qt::Key_V) ||
((mod & Qt::ShiftModifier) && key == Qt::Key_Insert))) │ ((mod & Qt::ShiftModifier) && key == Qt::Key_Insert)))
{ │ {
ui->lineEdit->setFocus(); │ ui->lineEdit->setFocus();
QApplication::sendEvent(ui->lineEdit, keyevt); │ QApplication::postEvent(ui->lineEdit, new QKeyEvent(*keyevt));
return true; │ return true;
} │ }
} │ }
} │ }
return QWidget::eventFilter(obj, event); │ return QWidget::eventFilter(obj, event);
} │
next prev up dogecoin/src/test/arith_uint256_tests.cpp:156 │ bitcoin/src/test/arith_uint256_tests.cpp:157
// "<<" ">>" "<<=" ">>=" │ // "<<" ">>" "<<=" ">>=" unsigned char TmpArray[32]; │ unsigned char TmpArray[32]; arith_uint256 TmpL; │ arith_uint256 TmpL; for (unsigned int i = 0; i < 256; ++i) │ for (unsigned int i = 0; i < 256; ++i) { │ { shiftArrayLeft(TmpArray, OneArray, 32, i); │ shiftArrayLeft(TmpArray, OneArray, 32, i); BOOST_CHECK(arith_uint256V(std::vector<unsigned char>(TmpArray,TmpArray+32)) == │ BOOST_CHECK(arith_uint256V(std::vector<unsigned char>(TmpArray,TmpArray+32)) == TmpL = OneL; TmpL <<= i; │ TmpL = OneL; TmpL <<= i; BOOST_CHECK(TmpL == (OneL << i)); │ BOOST_CHECK(TmpL == (OneL << i)); BOOST_CHECK((HalfL >> (255-i)) == (OneL << i)); │ BOOST_CHECK((HalfL >> (255-i)) == (OneL << i)); TmpL = HalfL; TmpL >>= (255-i); │ TmpL = HalfL; TmpL >>= (255-i); BOOST_CHECK(TmpL == (OneL << i)); │ BOOST_CHECK(TmpL == (OneL << i)); │ shiftArrayLeft(TmpArray, R1Array, 32, i); │ shiftArrayLeft(TmpArray, R1Array, 32, i); BOOST_CHECK(arith_uint256V(std::vector<unsigned char>(TmpArray,TmpArray+32)) == │ BOOST_CHECK(arith_uint256V(std::vector<unsigned char>(TmpArray,TmpArray+32)) == TmpL = R1L; TmpL <<= i; │ TmpL = R1L; TmpL <<= i; BOOST_CHECK(TmpL == (R1L << i)); │ BOOST_CHECK(TmpL == (R1L << i)); │ shiftArrayRight(TmpArray, R1Array, 32, i); │ shiftArrayRight(TmpArray, R1Array, 32, i); BOOST_CHECK(arith_uint256V(std::vector<unsigned char>(TmpArray,TmpArray+32)) == │ BOOST_CHECK(arith_uint256V(std::vector<unsigned char>(TmpArray,TmpArray+32)) == TmpL = R1L; TmpL >>= i; │ TmpL = R1L; TmpL >>= i; BOOST_CHECK(TmpL == (R1L >> i)); │ BOOST_CHECK(TmpL == (R1L >> i)); │ shiftArrayLeft(TmpArray, MaxArray, 32, i); │ shiftArrayLeft(TmpArray, MaxArray, 32, i); BOOST_CHECK(arith_uint256V(std::vector<unsigned char>(TmpArray,TmpArray+32)) == │ BOOST_CHECK(arith_uint256V(std::vector<unsigned char>(TmpArray,TmpArray+32)) == TmpL = MaxL; TmpL <<= i; │ TmpL = MaxL; TmpL <<= i; BOOST_CHECK(TmpL == (MaxL << i)); │ BOOST_CHECK(TmpL == (MaxL << i)); │ shiftArrayRight(TmpArray, MaxArray, 32, i); │ shiftArrayRight(TmpArray, MaxArray, 32, i); BOOST_CHECK(arith_uint256V(std::vector<unsigned char>(TmpArray,TmpArray+32)) == │ BOOST_CHECK(arith_uint256V(std::vector<unsigned char>(TmpArray,TmpArray+32)) == TmpL = MaxL; TmpL >>= i; │ TmpL = MaxL; TmpL >>= i; BOOST_CHECK(TmpL == (MaxL >> i)); │ BOOST_CHECK(TmpL == (MaxL >> i)); } │ } arith_uint256 c1L = arith_uint256(0x0123456789abcdefULL); │ arith_uint256 c1L = arith_uint256(0x0123456789abcdefULL); arith_uint256 c2L = c1L << 128; │ arith_uint256 c2L = c1L << 128; for (unsigned int i = 0; i < 128; ++i) { │ for (unsigned int i = 0; i < 128; ++i) { BOOST_CHECK((c1L << i) == (c2L >> (128-i))); │ BOOST_CHECK((c1L << i) == (c2L >> (128-i))); } │ } for (unsigned int i = 128; i < 256; ++i) { │ for (unsigned int i = 128; i < 256; ++i) { BOOST_CHECK((c1L << i) == (c2L << (i-128))); │ BOOST_CHECK((c1L << i) == (c2L << (i-128))); } │ } } │
next prev up dogecoin/src/test/blockencodings_tests.cpp:68 │ bitcoin/src/test/blockencodings_tests.cpp:66
│
CBlockHeaderAndShortTxIDs shortIDs(block, true); │ CBlockHeaderAndShortTxIDs shortIDs(block, true);
│
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); │ CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
stream << shortIDs; │ stream << shortIDs;
│
CBlockHeaderAndShortTxIDs shortIDs2; │ CBlockHeaderAndShortTxIDs shortIDs2;
stream >> shortIDs2; │ stream >> shortIDs2;
│
PartiallyDownloadedBlock partialBlock(&pool); │ PartiallyDownloadedBlock partialBlock(&pool);
BOOST_CHECK(partialBlock.InitData(shortIDs2, extra_txn) == READ_STATUS_OK); │ BOOST_CHECK(partialBlock.InitData(shortIDs2, extra_txn) == READ_STATUS_OK);
BOOST_CHECK( partialBlock.IsTxAvailable(0)); │ BOOST_CHECK( partialBlock.IsTxAvailable(0));
BOOST_CHECK(!partialBlock.IsTxAvailable(1)); │ BOOST_CHECK(!partialBlock.IsTxAvailable(1));
BOOST_CHECK( partialBlock.IsTxAvailable(2)); │ BOOST_CHECK( partialBlock.IsTxAvailable(2));
│
BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_co │ BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[2]->GetHash())->GetSharedTx().use_co
│
size_t poolSize = pool.size(); │ size_t poolSize = pool.size();
pool.removeRecursive(*block.vtx[2]); │ pool.removeRecursive(*block.vtx[2], MemPoolRemovalReason::REPLACED);
BOOST_CHECK_EQUAL(pool.size(), poolSize - 1); │ BOOST_CHECK_EQUAL(pool.size(), poolSize - 1);
│
CBlock block2; │ CBlock block2;
{ │ {
PartiallyDownloadedBlock tmp = partialBlock; │ PartiallyDownloadedBlock tmp = partialBlock;
BOOST_CHECK(partialBlock.FillBlock(block2, {}) == READ_STATUS_INVALID); // N │ BOOST_CHECK(partialBlock.FillBlock(block2, {}) == READ_STATUS_INVALID); // N
partialBlock = tmp; │ partialBlock = tmp;
} │ }
│
// Wrong transaction │ // Wrong transaction
{ │ {
PartiallyDownloadedBlock tmp = partialBlock; │ PartiallyDownloadedBlock tmp = partialBlock;
partialBlock.FillBlock(block2, {block.vtx[2]}); // Current implementation do │ partialBlock.FillBlock(block2, {block.vtx[2]}); // Current implementation do
partialBlock = tmp; │ partialBlock = tmp;
} │ }
bool mutated; │ bool mutated;
BOOST_CHECK(block.hashMerkleRoot != BlockMerkleRoot(block2, &mutated)); │ BOOST_CHECK(block.hashMerkleRoot != BlockMerkleRoot(block2, &mutated));
│
CBlock block3; │ CBlock block3;
BOOST_CHECK(partialBlock.FillBlock(block3, {block.vtx[1]}) == READ_STATUS_OK); │ BOOST_CHECK(partialBlock.FillBlock(block3, {block.vtx[1]}) == READ_STATUS_OK);
BOOST_CHECK_EQUAL(block.GetHash().ToString(), block3.GetHash().ToString()); │ BOOST_CHECK_EQUAL(block.GetHash().ToString(), block3.GetHash().ToString());
BOOST_CHECK_EQUAL(block.hashMerkleRoot.ToString(), BlockMerkleRoot(block3, &muta │ BOOST_CHECK_EQUAL(block.hashMerkleRoot.ToString(), BlockMerkleRoot(block3, &muta
BOOST_CHECK(!mutated); │ BOOST_CHECK(!mutated);
} │
next prev up dogecoin/src/validation.cpp:4280 │ bitcoin/src/validation.cpp:4575
│
// We are going to either move to a parent or a sibling of pindex. │ // We are going to either move to a parent or a sibling of pindex.
// If pindex was the first with a certain property, unset the corresponding │ // If pindex was the first with a certain property, unset the corresponding
if (pindex == pindexFirstInvalid) pindexFirstInvalid = NULL; │ if (pindex == pindexFirstInvalid) pindexFirstInvalid = nullptr;
if (pindex == pindexFirstMissing) pindexFirstMissing = NULL; │ if (pindex == pindexFirstMissing) pindexFirstMissing = nullptr;
if (pindex == pindexFirstNeverProcessed) pindexFirstNeverProcessed = NULL; │ if (pindex == pindexFirstNeverProcessed) pindexFirstNeverProcessed = nullptr
if (pindex == pindexFirstNotTreeValid) pindexFirstNotTreeValid = NULL; │ if (pindex == pindexFirstNotTreeValid) pindexFirstNotTreeValid = nullptr;
if (pindex == pindexFirstNotTransactionsValid) pindexFirstNotTransactionsVal │ if (pindex == pindexFirstNotTransactionsValid) pindexFirstNotTransactionsVal
if (pindex == pindexFirstNotChainValid) pindexFirstNotChainValid = NULL; │ if (pindex == pindexFirstNotChainValid) pindexFirstNotChainValid = nullptr;
if (pindex == pindexFirstNotScriptsValid) pindexFirstNotScriptsValid = NULL; │ if (pindex == pindexFirstNotScriptsValid) pindexFirstNotScriptsValid = nullp
// Find our parent. │ // Find our parent.
CBlockIndex* pindexPar = pindex->pprev; │ CBlockIndex* pindexPar = pindex->pprev;
// Find which child we just visited. │ // Find which child we just visited.
std::pair<std::multimap<CBlockIndex*,CBlockIndex*>::iterator,std::multimap<C │ std::pair<std::multimap<CBlockIndex*,CBlockIndex*>::iterator,std::multimap<C
while (rangePar.first->second != pindex) { │ while (rangePar.first->second != pindex) {
assert(rangePar.first != rangePar.second); // Our parent must have at le │ assert(rangePar.first != rangePar.second); // Our parent must have at le
rangePar.first++; │ rangePar.first++;
} │ }
// Proceed to the next one. │ // Proceed to the next one.
rangePar.first++; │ rangePar.first++;
if (rangePar.first != rangePar.second) { │ if (rangePar.first != rangePar.second) {
// Move to the sibling. │ // Move to the sibling.
pindex = rangePar.first->second; │ pindex = rangePar.first->second;
break; │ break;
} else { │ } else {
// Move up further. │ // Move up further.
pindex = pindexPar; │ pindex = pindexPar;
nHeight--; │ nHeight--;
continue; │ continue;
} │ }
} │
next prev up dogecoin/src/test/arith_uint256_tests.cpp:289 │ bitcoin/src/test/arith_uint256_tests.cpp:283
│
arith_uint256 TmpL = 0; │ arith_uint256 TmpL = 0;
BOOST_CHECK(R1L+R2L == arith_uint256(R1LplusR2L)); │ BOOST_CHECK(R1L+R2L == arith_uint256(R1LplusR2L));
TmpL += R1L; │ TmpL += R1L;
BOOST_CHECK(TmpL == R1L); │ BOOST_CHECK(TmpL == R1L);
TmpL += R2L; │ TmpL += R2L;
BOOST_CHECK(TmpL == R1L + R2L); │ BOOST_CHECK(TmpL == R1L + R2L);
BOOST_CHECK(OneL+MaxL == ZeroL); │ BOOST_CHECK(OneL+MaxL == ZeroL);
BOOST_CHECK(MaxL+OneL == ZeroL); │ BOOST_CHECK(MaxL+OneL == ZeroL);
for (unsigned int i = 1; i < 256; ++i) { │ for (unsigned int i = 1; i < 256; ++i) {
BOOST_CHECK( (MaxL >> i) + OneL == (HalfL >> (i-1)) ); │ BOOST_CHECK( (MaxL >> i) + OneL == (HalfL >> (i-1)) );
BOOST_CHECK( OneL + (MaxL >> i) == (HalfL >> (i-1)) ); │ BOOST_CHECK( OneL + (MaxL >> i) == (HalfL >> (i-1)) );
TmpL = (MaxL>>i); TmpL += OneL; │ TmpL = (MaxL>>i); TmpL += OneL;
BOOST_CHECK( TmpL == (HalfL >> (i-1)) ); │ BOOST_CHECK( TmpL == (HalfL >> (i-1)) );
TmpL = (MaxL>>i); TmpL += 1; │ TmpL = (MaxL>>i); TmpL += 1;
BOOST_CHECK( TmpL == (HalfL >> (i-1)) ); │ BOOST_CHECK( TmpL == (HalfL >> (i-1)) );
TmpL = (MaxL>>i); │ TmpL = (MaxL>>i);
BOOST_CHECK( TmpL++ == (MaxL>>i) ); │ BOOST_CHECK( TmpL++ == (MaxL>>i) );
BOOST_CHECK( TmpL == (HalfL >> (i-1))); │ BOOST_CHECK( TmpL == (HalfL >> (i-1)));
} │ }
BOOST_CHECK(arith_uint256(0xbedc77e27940a7ULL) + 0xee8d836fce66fbULL == arith_uint25 │ BOOST_CHECK(arith_uint256(0xbedc77e27940a7ULL) + 0xee8d836fce66fbULL == arith_uint25
TmpL = arith_uint256(0xbedc77e27940a7ULL); TmpL += 0xee8d836fce66fbULL; │ TmpL = arith_uint256(0xbedc77e27940a7ULL); TmpL += 0xee8d836fce66fbULL;
BOOST_CHECK(TmpL == arith_uint256(0xbedc77e27940a7ULL+0xee8d836fce66fbULL)); │ BOOST_CHECK(TmpL == arith_uint256(0xbedc77e27940a7ULL+0xee8d836fce66fbULL));
TmpL -= 0xee8d836fce66fbULL; BOOST_CHECK(TmpL == 0xbedc77e27940a7ULL); │ TmpL -= 0xee8d836fce66fbULL; BOOST_CHECK(TmpL == 0xbedc77e27940a7ULL);
TmpL = R1L; │ TmpL = R1L;
BOOST_CHECK(++TmpL == R1L+1); │ BOOST_CHECK(++TmpL == R1L+1);
│
BOOST_CHECK(R1L -(-R2L) == R1L+R2L); │ BOOST_CHECK(R1L -(-R2L) == R1L+R2L);
BOOST_CHECK(R1L -(-OneL) == R1L+OneL); │ BOOST_CHECK(R1L -(-OneL) == R1L+OneL);
BOOST_CHECK(R1L - OneL == R1L+(-OneL)); │ BOOST_CHECK(R1L - OneL == R1L+(-OneL));
for (unsigned int i = 1; i < 256; ++i) { │ for (unsigned int i = 1; i < 256; ++i) {
BOOST_CHECK((MaxL>>i) - (-OneL) == (HalfL >> (i-1))); │ BOOST_CHECK((MaxL>>i) - (-OneL) == (HalfL >> (i-1)));
BOOST_CHECK((HalfL >> (i-1)) - OneL == (MaxL>>i)); │ BOOST_CHECK((HalfL >> (i-1)) - OneL == (MaxL>>i));
TmpL = (HalfL >> (i-1)); │ TmpL = (HalfL >> (i-1));
BOOST_CHECK(TmpL-- == (HalfL >> (i-1))); │ BOOST_CHECK(TmpL-- == (HalfL >> (i-1)));
BOOST_CHECK(TmpL == (MaxL >> i)); │ BOOST_CHECK(TmpL == (MaxL >> i));
TmpL = (HalfL >> (i-1)); │ TmpL = (HalfL >> (i-1));
BOOST_CHECK(--TmpL == (MaxL >> i)); │ BOOST_CHECK(--TmpL == (MaxL >> i));
} │ }
TmpL = R1L; │ TmpL = R1L;
BOOST_CHECK(--TmpL == R1L-1); │ BOOST_CHECK(--TmpL == R1L-1);
} │
next prev up bitcoin/src/bitcoin-tx.cpp:795 │ dogecoin/src/bitcoin-tx.cpp:754
│
std::string strPrint; │ std::string strPrint;
int nRet = 0; │ int nRet = 0;
try { │ try {
// Skip switches; Permit common stdin convention "-" │ // Skip switches; Permit common stdin convention "-"
while (argc > 1 && IsSwitchChar(argv[1][0]) && │ while (argc > 1 && IsSwitchChar(argv[1][0]) &&
(argv[1][1] != 0)) { │ (argv[1][1] != 0)) {
argc--; │ argc--;
argv++; │ argv++;
} │ }
│
CMutableTransaction tx; │ CMutableTransaction tx;
int startArg; │ int startArg;
│
if (!fCreateBlank) { │ if (!fCreateBlank) {
// require at least one param │ // require at least one param
if (argc < 2) │ if (argc < 2)
throw std::runtime_error("too few parameters"); │ throw std::runtime_error("too few parameters");
│
// param: hex-encoded bitcoin transaction │ // param: hex-encoded bitcoin transaction
std::string strHexTx(argv[1]); │ std::string strHexTx(argv[1]);
if (strHexTx == "-") // "-" implies standard input │ if (strHexTx == "-") // "-" implies standard input
strHexTx = readStdin(); │ strHexTx = readStdin();
│
if (!DecodeHexTx(tx, strHexTx, true)) │ if (!DecodeHexTx(tx, strHexTx, true))
throw std::runtime_error("invalid transaction encoding"); │ throw std::runtime_error("invalid transaction encoding");
│
startArg = 2; │ startArg = 2;
} else │ } else
startArg = 1; │ startArg = 1;
│
for (int i = startArg; i < argc; i++) { │ for (int i = startArg; i < argc; i++) {
std::string arg = argv[i]; │ std::string arg = argv[i];
std::string key, value; │ std::string key, value;
size_t eqpos = arg.find('='); │ size_t eqpos = arg.find('=');
if (eqpos == std::string::npos) │ if (eqpos == std::string::npos)
key = arg; │ key = arg;
else { │ else {
key = arg.substr(0, eqpos); │ key = arg.substr(0, eqpos);
value = arg.substr(eqpos + 1); │ value = arg.substr(eqpos + 1);
} │ }
│
MutateTx(tx, key, value); │ MutateTx(tx, key, value);
} │ }
│
OutputTx(CTransaction(tx)); │ OutputTx(tx);
│ }
│
│ catch (const boost::thread_interrupted&) {
│ throw;
} │ }
catch (const std::exception& e) { │ catch (const std::exception& e) {
strPrint = std::string("error: ") + e.what(); │ strPrint = std::string("error: ") + e.what();
nRet = EXIT_FAILURE; │ nRet = EXIT_FAILURE;
} │ }
catch (...) { │ catch (...) {
PrintExceptionContinue(nullptr, "CommandLineRawTx()"); │ PrintExceptionContinue(NULL, "CommandLineRawTx()");
throw; │ throw;
} │ }
│
if (strPrint != "") { │ if (strPrint != "") {
tfm::format(nRet == 0 ? std::cout : std::cerr, "%s\n", strPrint); │ fprintf((nRet == 0 ? stdout : stderr), "%s\n", strPrint.c_str());
} │ }
return nRet; │ return nRet;
} │
next prev up dogecoin/src/net.cpp:2124 │ bitcoin/src/net.cpp:2456
│
if (!fDiscover) │ if (!fDiscover)
return; │ return;
│
#ifdef WIN32 │ #ifdef WIN32
// Get local host IP │ // Get local host IP
char pszHostName[256] = ""; │ char pszHostName[256] = "";
if (gethostname(pszHostName, sizeof(pszHostName)) != SOCKET_ERROR) │ if (gethostname(pszHostName, sizeof(pszHostName)) != SOCKET_ERROR)
{ │ {
std::vector<CNetAddr> vaddr; │ std::vector<CNetAddr> vaddr;
if (LookupHost(pszHostName, vaddr, 0, true)) │ if (LookupHost(pszHostName, vaddr, 0, true))
{ │ {
BOOST_FOREACH (const CNetAddr &addr, vaddr) │ for (const CNetAddr &addr : vaddr)
{ │ {
if (AddLocal(addr, LOCAL_IF)) │ if (AddLocal(addr, LOCAL_IF))
LogPrintf("%s: %s - %s\n", __func__, pszHostName, addr.ToString()); │ LogPrintf("%s: %s - %s\n", __func__, pszHostName, addr.ToString());
} │ }
} │ }
} │ }
#else │ #elif (HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS)
// Get local host ip │ // Get local host ip
struct ifaddrs* myaddrs; │ struct ifaddrs* myaddrs;
if (getifaddrs(&myaddrs) == 0) │ if (getifaddrs(&myaddrs) == 0)
{ │ {
for (struct ifaddrs* ifa = myaddrs; ifa != NULL; ifa = ifa->ifa_next) │ for (struct ifaddrs* ifa = myaddrs; ifa != nullptr; ifa = ifa->ifa_next)
{ │ {
if (ifa->ifa_addr == NULL) continue; │ if (ifa->ifa_addr == nullptr) continue;
if ((ifa->ifa_flags & IFF_UP) == 0) continue; │ if ((ifa->ifa_flags & IFF_UP) == 0) continue;
if (strcmp(ifa->ifa_name, "lo") == 0) continue; │ if (strcmp(ifa->ifa_name, "lo") == 0) continue;
if (strcmp(ifa->ifa_name, "lo0") == 0) continue; │ if (strcmp(ifa->ifa_name, "lo0") == 0) continue;
if (ifa->ifa_addr->sa_family == AF_INET) │ if (ifa->ifa_addr->sa_family == AF_INET)
{ │ {
struct sockaddr_in* s4 = (struct sockaddr_in*)(ifa->ifa_addr); │ struct sockaddr_in* s4 = (struct sockaddr_in*)(ifa->ifa_addr);
CNetAddr addr(s4->sin_addr); │ CNetAddr addr(s4->sin_addr);
if (AddLocal(addr, LOCAL_IF)) │ if (AddLocal(addr, LOCAL_IF))
LogPrintf("%s: IPv4 %s: %s\n", __func__, ifa->ifa_name, addr.ToStrin │ LogPrintf("%s: IPv4 %s: %s\n", __func__, ifa->ifa_name, addr.ToStrin
} │ }
else if (ifa->ifa_addr->sa_family == AF_INET6) │ else if (ifa->ifa_addr->sa_family == AF_INET6)
{ │ {
struct sockaddr_in6* s6 = (struct sockaddr_in6*)(ifa->ifa_addr); │ struct sockaddr_in6* s6 = (struct sockaddr_in6*)(ifa->ifa_addr);
CNetAddr addr(s6->sin6_addr); │ CNetAddr addr(s6->sin6_addr);
if (AddLocal(addr, LOCAL_IF)) │ if (AddLocal(addr, LOCAL_IF))
LogPrintf("%s: IPv6 %s: %s\n", __func__, ifa->ifa_name, addr.ToStrin │ LogPrintf("%s: IPv6 %s: %s\n", __func__, ifa->ifa_name, addr.ToStrin
} │ }
} │ }
freeifaddrs(myaddrs); │ freeifaddrs(myaddrs);
} │ }
#endif │ #endif
} │
next prev up dogecoin/src/rpc/blockchain.cpp:314 │ dogecoin/src/rpc/blockchain.cpp:272
│
if (request.fHelp || request.params.size() < 1 || request.params.size() > 2) │ if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
throw runtime_error( │ throw runtime_error(
"waitforblockheight <height> (timeout)\n" │ "waitforblock <blockhash> (timeout)\n"
"\nWaits for (at least) block height and returns the height and hash\n" │ "\nWaits for a specific new block and returns useful info about it.\n"
"of the current tip.\n" │
"\nReturns the current block on timeout or exit.\n" │ "\nReturns the current block on timeout or exit.\n"
"\nArguments:\n" │ "\nArguments:\n"
"1. height (required, int) Block height to wait for (int)\n" │ "1. \"blockhash\" (required, string) Block hash to wait for.\n"
"2. timeout (int, optional, default=0) Time in milliseconds to wait for a re │ "2. timeout (int, optional, default=0) Time in milliseconds to wait fo
"\nResult:\n" │ "\nResult:\n"
"{ (json object)\n" │ "{ (json object)\n"
" \"hash\" : { (string) The blockhash\n" │ " \"hash\" : { (string) The blockhash\n"
" \"height\" : { (int) Block height\n" │ " \"height\" : { (int) Block height\n"
"}\n" │ "}\n"
"\nExamples:\n" │ "\nExamples:\n"
+ HelpExampleCli("waitforblockheight", "\"100\", 1000") │ + HelpExampleCli("waitforblock", "\"0000000000079f8ef3d2c688c244eb7a4570b24c
+ HelpExampleRpc("waitforblockheight", "\"100\", 1000") │ + HelpExampleRpc("waitforblock", "\"0000000000079f8ef3d2c688c244eb7a4570b24c
); │ );
int timeout = 0; │ int timeout = 0;
│
int height = request.params[0].get_int(); │ uint256 hash = uint256S(request.params[0].get_str());
│
if (request.params.size() > 1) │ if (request.params.size() > 1)
timeout = request.params[1].get_int(); │ timeout = request.params[1].get_int();
│
CUpdatedBlock block; │ CUpdatedBlock block;
{ │ {
std::unique_lock<std::mutex> lock(cs_blockchange); │ std::unique_lock<std::mutex> lock(cs_blockchange);
if(timeout) │ if(timeout)
cond_blockchange.wait_for(lock, std::chrono::milliseconds(timeout), [&height │ cond_blockchange.wait_for(lock, std::chrono::milliseconds(timeout), [&hash]{
else │ else
cond_blockchange.wait(lock, [&height]{return latestblock.height >= height || │ cond_blockchange.wait(lock, [&hash]{return latestblock.hash == hash || !IsRP
block = latestblock; │ block = latestblock;
} │ }
│
UniValue ret(UniValue::VOBJ); │ UniValue ret(UniValue::VOBJ);
ret.pushKV("hash", block.hash.GetHex()); │ ret.pushKV("hash", block.hash.GetHex());
ret.pushKV("height", block.height); │ ret.pushKV("height", block.height);
return ret; │ return ret;
} │
next prev up dogecoin/src/test/allocator_tests.cpp:162 │ bitcoin/src/test/allocator_tests.cpp:166
│
// Test over three virtual arenas, of which one will succeed being locked │ // Test over three virtual arenas, of which one will succeed being locked
std::unique_ptr<LockedPageAllocator> x(new TestLockedPageAllocator(3, 1)); │ std::unique_ptr<LockedPageAllocator> x = std::make_unique<TestLockedPageAllocator>(3
LockedPool pool(std::move(x)); │ LockedPool pool(std::move(x));
BOOST_CHECK(pool.stats().total == 0); │ BOOST_CHECK(pool.stats().total == 0);
BOOST_CHECK(pool.stats().locked == 0); │ BOOST_CHECK(pool.stats().locked == 0);
│
// Ensure unreasonable requests are refused without allocating anything │ // Ensure unreasonable requests are refused without allocating anything
void *invalid_toosmall = pool.alloc(0); │ void *invalid_toosmall = pool.alloc(0);
BOOST_CHECK(invalid_toosmall == nullptr); │ BOOST_CHECK(invalid_toosmall == nullptr);
BOOST_CHECK(pool.stats().used == 0); │ BOOST_CHECK(pool.stats().used == 0);
BOOST_CHECK(pool.stats().free == 0); │ BOOST_CHECK(pool.stats().free == 0);
void *invalid_toobig = pool.alloc(LockedPool::ARENA_SIZE+1); │ void *invalid_toobig = pool.alloc(LockedPool::ARENA_SIZE+1);
BOOST_CHECK(invalid_toobig == nullptr); │ BOOST_CHECK(invalid_toobig == nullptr);
BOOST_CHECK(pool.stats().used == 0); │ BOOST_CHECK(pool.stats().used == 0);
BOOST_CHECK(pool.stats().free == 0); │ BOOST_CHECK(pool.stats().free == 0);
│
void *a0 = pool.alloc(LockedPool::ARENA_SIZE / 2); │ void *a0 = pool.alloc(LockedPool::ARENA_SIZE / 2);
BOOST_CHECK(a0); │ BOOST_CHECK(a0);
BOOST_CHECK(pool.stats().locked == LockedPool::ARENA_SIZE); │ BOOST_CHECK(pool.stats().locked == LockedPool::ARENA_SIZE);
void *a1 = pool.alloc(LockedPool::ARENA_SIZE / 2); │ void *a1 = pool.alloc(LockedPool::ARENA_SIZE / 2);
BOOST_CHECK(a1); │ BOOST_CHECK(a1);
void *a2 = pool.alloc(LockedPool::ARENA_SIZE / 2); │ void *a2 = pool.alloc(LockedPool::ARENA_SIZE / 2);
BOOST_CHECK(a2); │ BOOST_CHECK(a2);
void *a3 = pool.alloc(LockedPool::ARENA_SIZE / 2); │ void *a3 = pool.alloc(LockedPool::ARENA_SIZE / 2);
BOOST_CHECK(a3); │ BOOST_CHECK(a3);
void *a4 = pool.alloc(LockedPool::ARENA_SIZE / 2); │ void *a4 = pool.alloc(LockedPool::ARENA_SIZE / 2);
BOOST_CHECK(a4); │ BOOST_CHECK(a4);
void *a5 = pool.alloc(LockedPool::ARENA_SIZE / 2); │ void *a5 = pool.alloc(LockedPool::ARENA_SIZE / 2);
BOOST_CHECK(a5); │ BOOST_CHECK(a5);
// We've passed a count of three arenas, so this allocation should fail │ // We've passed a count of three arenas, so this allocation should fail
void *a6 = pool.alloc(16); │ void *a6 = pool.alloc(16);
BOOST_CHECK(!a6); │ BOOST_CHECK(!a6);
│
pool.free(a0); │ pool.free(a0);
pool.free(a2); │ pool.free(a2);
pool.free(a4); │ pool.free(a4);
pool.free(a1); │ pool.free(a1);
pool.free(a3); │ pool.free(a3);
pool.free(a5); │ pool.free(a5);
BOOST_CHECK(pool.stats().total == 3*LockedPool::ARENA_SIZE); │ BOOST_CHECK(pool.stats().total == 3*LockedPool::ARENA_SIZE);
BOOST_CHECK(pool.stats().locked == LockedPool::ARENA_SIZE); │ BOOST_CHECK(pool.stats().locked == LockedPool::ARENA_SIZE);
BOOST_CHECK(pool.stats().used == 0); │ BOOST_CHECK(pool.stats().used == 0);
} │
next prev up dogecoin/src/bloom.cpp:218 │ bitcoin/src/common/bloom.cpp:163
│
double logFpRate = log(fpRate); │ double logFpRate = log(fpRate);
/* The optimal number of hash functions is log(fpRate) / log(0.5), but │ /* The optimal number of hash functions is log(fpRate) / log(0.5), but
* restrict it to the range 1-50. */ │ * restrict it to the range 1-50. */
nHashFuncs = std::max(1, std::min((int)round(logFpRate / log(0.5)), 50)); │ nHashFuncs = std::max(1, std::min((int)round(logFpRate / log(0.5)), 50));
/* In this rolling bloom filter, we'll store between 2 and 3 generations of nElement │ /* In this rolling bloom filter, we'll store between 2 and 3 generations of nElement
nEntriesPerGeneration = (nElements + 1) / 2; │ nEntriesPerGeneration = (nElements + 1) / 2;
uint32_t nMaxElements = nEntriesPerGeneration * 3; │ uint32_t nMaxElements = nEntriesPerGeneration * 3;
/* The maximum fpRate = pow(1.0 - exp(-nHashFuncs * nMaxElements / nFilterBits), nHa │ /* The maximum fpRate = pow(1.0 - exp(-nHashFuncs * nMaxElements / nFilterBits), nHa
* => pow(fpRate, 1.0 / nHashFuncs) = 1.0 - exp(-nHashFuncs * nMaxElements │ * => pow(fpRate, 1.0 / nHashFuncs) = 1.0 - exp(-nHashFuncs * nMaxElements
* => 1.0 - pow(fpRate, 1.0 / nHashFuncs) = exp(-nHashFuncs * nMaxElements │ * => 1.0 - pow(fpRate, 1.0 / nHashFuncs) = exp(-nHashFuncs * nMaxElements
* => log(1.0 - pow(fpRate, 1.0 / nHashFuncs)) = -nHashFuncs * nMaxElements │ * => log(1.0 - pow(fpRate, 1.0 / nHashFuncs)) = -nHashFuncs * nMaxElements
* => nFilterBits = -nHashFuncs * nMaxElements / log(1.0 - pow(fpRate, 1.0 │ * => nFilterBits = -nHashFuncs * nMaxElements / log(1.0 - pow(fpRate, 1.0
* => nFilterBits = -nHashFuncs * nMaxElements / log(1.0 - exp(logFpRate / │ * => nFilterBits = -nHashFuncs * nMaxElements / log(1.0 - exp(logFpRate /
*/ │ */
uint32_t nFilterBits = (uint32_t)ceil(-1.0 * nHashFuncs * nMaxElements / log(1.0 - e │ uint32_t nFilterBits = (uint32_t)ceil(-1.0 * nHashFuncs * nMaxElements / log(1.0 - e
data.clear(); │ data.clear();
/* For each data element we need to store 2 bits. If both bits are 0, the │ /* For each data element we need to store 2 bits. If both bits are 0, the
* bit is treated as unset. If the bits are (01), (10), or (11), the bit is │ * bit is treated as unset. If the bits are (01), (10), or (11), the bit is
* treated as set in generation 1, 2, or 3 respectively. │ * treated as set in generation 1, 2, or 3 respectively.
* These bits are stored in separate integers: position P corresponds to bit │ * These bits are stored in separate integers: position P corresponds to bit
* (P & 63) of the integers data[(P >> 6) * 2] and data[(P >> 6) * 2 + 1]. */ │ * (P & 63) of the integers data[(P >> 6) * 2] and data[(P >> 6) * 2 + 1]. */
data.resize(((nFilterBits + 63) / 64) << 1); │ data.resize(((nFilterBits + 63) / 64) << 1);
reset(); │ reset();
} │
next prev up dogecoin/src/qt/transactionview.cpp:432 │ bitcoin/src/qt/transactionview.cpp:483
│
if(!transactionView->selectionModel() ||!model) │ if(!transactionView->selectionModel() ||!model)
return; │ return;
QModelIndexList selection = transactionView->selectionModel()->selectedRows(); │ QModelIndexList selection = transactionView->selectionModel()->selectedRows();
if(!selection.isEmpty()) │ if(!selection.isEmpty())
{ │ {
AddressTableModel *addressBook = model->getAddressTableModel(); │ AddressTableModel *addressBook = model->getAddressTableModel();
if(!addressBook) │ if(!addressBook)
return; │ return;
QString address = selection.at(0).data(TransactionTableModel::AddressRole).toStr │ QString address = selection.at(0).data(TransactionTableModel::AddressRole).toStr
if(address.isEmpty()) │ if(address.isEmpty())
{ │ {
// If this transaction has no associated address, exit │ // If this transaction has no associated address, exit
return; │ return;
} │ }
// Is address in address book? Address book can miss address when a transaction │ // Is address in address book? Address book can miss address when a transaction
// sent from outside the UI. │ // sent from outside the UI.
int idx = addressBook->lookupAddress(address); │ int idx = addressBook->lookupAddress(address);
if(idx != -1) │ if(idx != -1)
{ │ {
// Edit sending / receiving address │ // Edit sending / receiving address
QModelIndex modelIdx = addressBook->index(idx, 0, QModelIndex()); │ QModelIndex modelIdx = addressBook->index(idx, 0, QModelIndex());
// Determine type of address, launch appropriate editor dialog type │ // Determine type of address, launch appropriate editor dialog type
QString type = modelIdx.data(AddressTableModel::TypeRole).toString(); │ QString type = modelIdx.data(AddressTableModel::TypeRole).toString();
│
EditAddressDialog dlg( │ auto dlg = new EditAddressDialog(
type == AddressTableModel::Receive │ type == AddressTableModel::Receive
? EditAddressDialog::EditReceivingAddress │ ? EditAddressDialog::EditReceivingAddress
: EditAddressDialog::EditSendingAddress, this); │ : EditAddressDialog::EditSendingAddress, this);
dlg.setModel(addressBook); │ dlg->setModel(addressBook);
dlg.loadRow(idx); │ dlg->loadRow(idx);
dlg.exec(); │ GUIUtil::ShowModalDialogAsynchronously(dlg);
} │ }
else │ else
{ │ {
// Add sending address │ // Add sending address
EditAddressDialog dlg(EditAddressDialog::NewSendingAddress, │ auto dlg = new EditAddressDialog(EditAddressDialog::NewSendingAddress,
this); │ this);
dlg.setModel(addressBook); │ dlg->setModel(addressBook);
dlg.setAddress(address); │ dlg->setAddress(address);
dlg.exec(); │ GUIUtil::ShowModalDialogAsynchronously(dlg);
} │ }
} │ }
} │
next prev up dogecoin/src/univalue/test/object.cpp:129 │ bitcoin/src/univalue/test/object.cpp:129
│
UniValue v(UniValue::VSTR, "foo"); │ UniValue v(UniValue::VSTR, "foo");
v.clear(); │ v.clear();
BOOST_CHECK(v.isNull()); │ BOOST_CHECK(v.isNull());
BOOST_CHECK_EQUAL(v.getValStr(), ""); │ BOOST_CHECK_EQUAL(v.getValStr(), "");
│
BOOST_CHECK(v.setObject()); │ BOOST_CHECK(v.setObject());
BOOST_CHECK(v.isObject()); │ BOOST_CHECK(v.isObject());
BOOST_CHECK_EQUAL(v.size(), 0); │ BOOST_CHECK_EQUAL(v.size(), 0);
BOOST_CHECK_EQUAL(v.getType(), UniValue::VOBJ); │ BOOST_CHECK_EQUAL(v.getType(), UniValue::VOBJ);
BOOST_CHECK(v.empty()); │ BOOST_CHECK(v.empty());
│
BOOST_CHECK(v.setArray()); │ BOOST_CHECK(v.setArray());
BOOST_CHECK(v.isArray()); │ BOOST_CHECK(v.isArray());
BOOST_CHECK_EQUAL(v.size(), 0); │ BOOST_CHECK_EQUAL(v.size(), 0);
│
BOOST_CHECK(v.setStr("zum")); │ BOOST_CHECK(v.setStr("zum"));
BOOST_CHECK(v.isStr()); │ BOOST_CHECK(v.isStr());
BOOST_CHECK_EQUAL(v.getValStr(), "zum"); │ BOOST_CHECK_EQUAL(v.getValStr(), "zum");
│
BOOST_CHECK(v.setFloat(-1.01)); │ BOOST_CHECK(v.setFloat(-1.01));
BOOST_CHECK(v.isNum()); │ BOOST_CHECK(v.isNum());
BOOST_CHECK_EQUAL(v.getValStr(), "-1.01"); │ BOOST_CHECK_EQUAL(v.getValStr(), "-1.01");
│
BOOST_CHECK(v.setInt((int)1023)); │ BOOST_CHECK(v.setInt((int)1023));
BOOST_CHECK(v.isNum()); │ BOOST_CHECK(v.isNum());
BOOST_CHECK_EQUAL(v.getValStr(), "1023"); │ BOOST_CHECK_EQUAL(v.getValStr(), "1023");
│
BOOST_CHECK(v.setInt((int64_t)-1023LL)); │ BOOST_CHECK(v.setInt((int64_t)-1023LL));
BOOST_CHECK(v.isNum()); │ BOOST_CHECK(v.isNum());
BOOST_CHECK_EQUAL(v.getValStr(), "-1023"); │ BOOST_CHECK_EQUAL(v.getValStr(), "-1023");
│
BOOST_CHECK(v.setInt((uint64_t)1023ULL)); │ BOOST_CHECK(v.setInt((uint64_t)1023ULL));
BOOST_CHECK(v.isNum()); │ BOOST_CHECK(v.isNum());
BOOST_CHECK_EQUAL(v.getValStr(), "1023"); │ BOOST_CHECK_EQUAL(v.getValStr(), "1023");
│
BOOST_CHECK(v.setNumStr("-688")); │ BOOST_CHECK(v.setNumStr("-688"));
BOOST_CHECK(v.isNum()); │ BOOST_CHECK(v.isNum());
BOOST_CHECK_EQUAL(v.getValStr(), "-688"); │ BOOST_CHECK_EQUAL(v.getValStr(), "-688");
│
BOOST_CHECK(v.setBool(false)); │ BOOST_CHECK(v.setBool(false));
BOOST_CHECK_EQUAL(v.isBool(), true); │ BOOST_CHECK_EQUAL(v.isBool(), true);
BOOST_CHECK_EQUAL(v.isTrue(), false); │ BOOST_CHECK_EQUAL(v.isTrue(), false);
BOOST_CHECK_EQUAL(v.isFalse(), true); │ BOOST_CHECK_EQUAL(v.isFalse(), true);
BOOST_CHECK_EQUAL(v.getBool(), false); │ BOOST_CHECK_EQUAL(v.getBool(), false);
│
BOOST_CHECK(v.setBool(true)); │ BOOST_CHECK(v.setBool(true));
BOOST_CHECK_EQUAL(v.isBool(), true); │ BOOST_CHECK_EQUAL(v.isBool(), true);
BOOST_CHECK_EQUAL(v.isTrue(), true); │ BOOST_CHECK_EQUAL(v.isTrue(), true);
BOOST_CHECK_EQUAL(v.isFalse(), false); │ BOOST_CHECK_EQUAL(v.isFalse(), false);
BOOST_CHECK_EQUAL(v.getBool(), true); │ BOOST_CHECK_EQUAL(v.getBool(), true);
│
BOOST_CHECK(!v.setNumStr("zombocom")); │ BOOST_CHECK(!v.setNumStr("zombocom"));
│
BOOST_CHECK(v.setNull()); │ BOOST_CHECK(v.setNull());
BOOST_CHECK(v.isNull()); │ BOOST_CHECK(v.isNull());
} │
next prev up dogecoin/src/test/univalue_tests.cpp:108 │ bitcoin/src/univalue/test/object.cpp:129
│
UniValue v(UniValue::VSTR, "foo"); │ UniValue v(UniValue::VSTR, "foo");
v.clear(); │ v.clear();
BOOST_CHECK(v.isNull()); │ BOOST_CHECK(v.isNull());
BOOST_CHECK_EQUAL(v.getValStr(), ""); │ BOOST_CHECK_EQUAL(v.getValStr(), "");
│
BOOST_CHECK(v.setObject()); │ BOOST_CHECK(v.setObject());
BOOST_CHECK(v.isObject()); │ BOOST_CHECK(v.isObject());
BOOST_CHECK_EQUAL(v.size(), 0); │ BOOST_CHECK_EQUAL(v.size(), 0);
BOOST_CHECK_EQUAL(v.getType(), UniValue::VOBJ); │ BOOST_CHECK_EQUAL(v.getType(), UniValue::VOBJ);
BOOST_CHECK(v.empty()); │ BOOST_CHECK(v.empty());
│
BOOST_CHECK(v.setArray()); │ BOOST_CHECK(v.setArray());
BOOST_CHECK(v.isArray()); │ BOOST_CHECK(v.isArray());
BOOST_CHECK_EQUAL(v.size(), 0); │ BOOST_CHECK_EQUAL(v.size(), 0);
│
BOOST_CHECK(v.setStr("zum")); │ BOOST_CHECK(v.setStr("zum"));
BOOST_CHECK(v.isStr()); │ BOOST_CHECK(v.isStr());
BOOST_CHECK_EQUAL(v.getValStr(), "zum"); │ BOOST_CHECK_EQUAL(v.getValStr(), "zum");
│
BOOST_CHECK(v.setFloat(-1.01)); │ BOOST_CHECK(v.setFloat(-1.01));
BOOST_CHECK(v.isNum()); │ BOOST_CHECK(v.isNum());
BOOST_CHECK_EQUAL(v.getValStr(), "-1.01"); │ BOOST_CHECK_EQUAL(v.getValStr(), "-1.01");
│
BOOST_CHECK(v.setInt((int)1023)); │ BOOST_CHECK(v.setInt((int)1023));
BOOST_CHECK(v.isNum()); │ BOOST_CHECK(v.isNum());
BOOST_CHECK_EQUAL(v.getValStr(), "1023"); │ BOOST_CHECK_EQUAL(v.getValStr(), "1023");
│
BOOST_CHECK(v.setInt((int64_t)-1023LL)); │ BOOST_CHECK(v.setInt((int64_t)-1023LL));
BOOST_CHECK(v.isNum()); │ BOOST_CHECK(v.isNum());
BOOST_CHECK_EQUAL(v.getValStr(), "-1023"); │ BOOST_CHECK_EQUAL(v.getValStr(), "-1023");
│
BOOST_CHECK(v.setInt((uint64_t)1023ULL)); │ BOOST_CHECK(v.setInt((uint64_t)1023ULL));
BOOST_CHECK(v.isNum()); │ BOOST_CHECK(v.isNum());
BOOST_CHECK_EQUAL(v.getValStr(), "1023"); │ BOOST_CHECK_EQUAL(v.getValStr(), "1023");
│
BOOST_CHECK(v.setNumStr("-688")); │ BOOST_CHECK(v.setNumStr("-688"));
BOOST_CHECK(v.isNum()); │ BOOST_CHECK(v.isNum());
BOOST_CHECK_EQUAL(v.getValStr(), "-688"); │ BOOST_CHECK_EQUAL(v.getValStr(), "-688");
│
BOOST_CHECK(v.setBool(false)); │ BOOST_CHECK(v.setBool(false));
BOOST_CHECK_EQUAL(v.isBool(), true); │ BOOST_CHECK_EQUAL(v.isBool(), true);
BOOST_CHECK_EQUAL(v.isTrue(), false); │ BOOST_CHECK_EQUAL(v.isTrue(), false);
BOOST_CHECK_EQUAL(v.isFalse(), true); │ BOOST_CHECK_EQUAL(v.isFalse(), true);
BOOST_CHECK_EQUAL(v.getBool(), false); │ BOOST_CHECK_EQUAL(v.getBool(), false);
│
BOOST_CHECK(v.setBool(true)); │ BOOST_CHECK(v.setBool(true));
BOOST_CHECK_EQUAL(v.isBool(), true); │ BOOST_CHECK_EQUAL(v.isBool(), true);
BOOST_CHECK_EQUAL(v.isTrue(), true); │ BOOST_CHECK_EQUAL(v.isTrue(), true);
BOOST_CHECK_EQUAL(v.isFalse(), false); │ BOOST_CHECK_EQUAL(v.isFalse(), false);
BOOST_CHECK_EQUAL(v.getBool(), true); │ BOOST_CHECK_EQUAL(v.getBool(), true);
│
BOOST_CHECK(!v.setNumStr("zombocom")); │ BOOST_CHECK(!v.setNumStr("zombocom"));
│
BOOST_CHECK(v.setNull()); │ BOOST_CHECK(v.setNull());
BOOST_CHECK(v.isNull()); │ BOOST_CHECK(v.isNull());
} │
next prev up dogecoin/src/test/univalue_tests.cpp:108 │ dogecoin/src/univalue/test/object.cpp:129
│
UniValue v(UniValue::VSTR, "foo"); │ UniValue v(UniValue::VSTR, "foo");
v.clear(); │ v.clear();
BOOST_CHECK(v.isNull()); │ BOOST_CHECK(v.isNull());
BOOST_CHECK_EQUAL(v.getValStr(), ""); │ BOOST_CHECK_EQUAL(v.getValStr(), "");
│
BOOST_CHECK(v.setObject()); │ BOOST_CHECK(v.setObject());
BOOST_CHECK(v.isObject()); │ BOOST_CHECK(v.isObject());
BOOST_CHECK_EQUAL(v.size(), 0); │ BOOST_CHECK_EQUAL(v.size(), 0);
BOOST_CHECK_EQUAL(v.getType(), UniValue::VOBJ); │ BOOST_CHECK_EQUAL(v.getType(), UniValue::VOBJ);
BOOST_CHECK(v.empty()); │ BOOST_CHECK(v.empty());
│
BOOST_CHECK(v.setArray()); │ BOOST_CHECK(v.setArray());
BOOST_CHECK(v.isArray()); │ BOOST_CHECK(v.isArray());
BOOST_CHECK_EQUAL(v.size(), 0); │ BOOST_CHECK_EQUAL(v.size(), 0);
│
BOOST_CHECK(v.setStr("zum")); │ BOOST_CHECK(v.setStr("zum"));
BOOST_CHECK(v.isStr()); │ BOOST_CHECK(v.isStr());
BOOST_CHECK_EQUAL(v.getValStr(), "zum"); │ BOOST_CHECK_EQUAL(v.getValStr(), "zum");
│
BOOST_CHECK(v.setFloat(-1.01)); │ BOOST_CHECK(v.setFloat(-1.01));
BOOST_CHECK(v.isNum()); │ BOOST_CHECK(v.isNum());
BOOST_CHECK_EQUAL(v.getValStr(), "-1.01"); │ BOOST_CHECK_EQUAL(v.getValStr(), "-1.01");
│
BOOST_CHECK(v.setInt((int)1023)); │ BOOST_CHECK(v.setInt((int)1023));
BOOST_CHECK(v.isNum()); │ BOOST_CHECK(v.isNum());
BOOST_CHECK_EQUAL(v.getValStr(), "1023"); │ BOOST_CHECK_EQUAL(v.getValStr(), "1023");
│
BOOST_CHECK(v.setInt((int64_t)-1023LL)); │ BOOST_CHECK(v.setInt((int64_t)-1023LL));
BOOST_CHECK(v.isNum()); │ BOOST_CHECK(v.isNum());
BOOST_CHECK_EQUAL(v.getValStr(), "-1023"); │ BOOST_CHECK_EQUAL(v.getValStr(), "-1023");
│
BOOST_CHECK(v.setInt((uint64_t)1023ULL)); │ BOOST_CHECK(v.setInt((uint64_t)1023ULL));
BOOST_CHECK(v.isNum()); │ BOOST_CHECK(v.isNum());
BOOST_CHECK_EQUAL(v.getValStr(), "1023"); │ BOOST_CHECK_EQUAL(v.getValStr(), "1023");
│
BOOST_CHECK(v.setNumStr("-688")); │ BOOST_CHECK(v.setNumStr("-688"));
BOOST_CHECK(v.isNum()); │ BOOST_CHECK(v.isNum());
BOOST_CHECK_EQUAL(v.getValStr(), "-688"); │ BOOST_CHECK_EQUAL(v.getValStr(), "-688");
│
BOOST_CHECK(v.setBool(false)); │ BOOST_CHECK(v.setBool(false));
BOOST_CHECK_EQUAL(v.isBool(), true); │ BOOST_CHECK_EQUAL(v.isBool(), true);
BOOST_CHECK_EQUAL(v.isTrue(), false); │ BOOST_CHECK_EQUAL(v.isTrue(), false);
BOOST_CHECK_EQUAL(v.isFalse(), true); │ BOOST_CHECK_EQUAL(v.isFalse(), true);
BOOST_CHECK_EQUAL(v.getBool(), false); │ BOOST_CHECK_EQUAL(v.getBool(), false);
│
BOOST_CHECK(v.setBool(true)); │ BOOST_CHECK(v.setBool(true));
BOOST_CHECK_EQUAL(v.isBool(), true); │ BOOST_CHECK_EQUAL(v.isBool(), true);
BOOST_CHECK_EQUAL(v.isTrue(), true); │ BOOST_CHECK_EQUAL(v.isTrue(), true);
BOOST_CHECK_EQUAL(v.isFalse(), false); │ BOOST_CHECK_EQUAL(v.isFalse(), false);
BOOST_CHECK_EQUAL(v.getBool(), true); │ BOOST_CHECK_EQUAL(v.getBool(), true);
│
BOOST_CHECK(!v.setNumStr("zombocom")); │ BOOST_CHECK(!v.setNumStr("zombocom"));
│
BOOST_CHECK(v.setNull()); │ BOOST_CHECK(v.setNull());
BOOST_CHECK(v.isNull()); │ BOOST_CHECK(v.isNull());
} │
next prev up bitcoin/src/qt/intro.cpp:68 │ dogecoin/src/qt/intro.cpp:72
│
│ namespace fs = boost::filesystem;
QString dataDirStr = intro->getPathToCheck(); │ QString dataDirStr = intro->getPathToCheck();
fs::path dataDir = GUIUtil::QStringToPath(dataDirStr); │ fs::path dataDir = GUIUtil::qstringToBoostPath(dataDirStr);
uint64_t freeBytesAvailable = 0; │ uint64_t freeBytesAvailable = 0;
int replyStatus = ST_OK; │ int replyStatus = ST_OK;
QString replyMessage = tr("A new data directory will be created."); │ QString replyMessage = tr("A new data directory will be created.");
│
/* Find first parent that exists, so that fs::space does not fail */ │ /* Find first parent that exists, so that fs::space does not fail */
fs::path parentDir = dataDir; │ fs::path parentDir = dataDir;
fs::path parentDirOld = fs::path(); │ fs::path parentDirOld = fs::path();
while(parentDir.has_parent_path() && !fs::exists(parentDir)) │ while(parentDir.has_parent_path() && !fs::exists(parentDir))
{ │ {
parentDir = parentDir.parent_path(); │ parentDir = parentDir.parent_path();
│
/* Check if we make any progress, break if not to prevent an infinite loop here │ /* Check if we make any progress, break if not to prevent an infinite loop here
if (parentDirOld == parentDir) │ if (parentDirOld == parentDir)
break; │ break;
│
parentDirOld = parentDir; │ parentDirOld = parentDir;
} │ }
│
try { │ try {
freeBytesAvailable = fs::space(parentDir).available; │ freeBytesAvailable = fs::space(parentDir).available;
if(fs::exists(dataDir)) │ if(fs::exists(dataDir))
{ │ {
if(fs::is_directory(dataDir)) │ if(fs::is_directory(dataDir))
{ │ {
QString separator = "<code>" + QDir::toNativeSeparators("/") + tr("name" │ QString separator = "<code>" + QDir::toNativeSeparators("/") + tr("name"
replyStatus = ST_OK; │ replyStatus = ST_OK;
replyMessage = tr("Directory already exists. Add %1 if you intend to cre │ replyMessage = tr("Directory already exists. Add %1 if you intend to cre
} else { │ } else {
replyStatus = ST_ERROR; │ replyStatus = ST_ERROR;
replyMessage = tr("Path already exists, and is not a directory."); │ replyMessage = tr("Path already exists, and is not a directory.");
} │ }
} │ }
} catch (const fs::filesystem_error&) │ } catch (const fs::filesystem_error&)
{ │ {
/* Parent directory does not exist or is not accessible */ │ /* Parent directory does not exist or is not accessible */
replyStatus = ST_ERROR; │ replyStatus = ST_ERROR;
replyMessage = tr("Cannot create data directory here."); │ replyMessage = tr("Cannot create data directory here.");
} │ }
Q_EMIT reply(replyStatus, replyMessage, freeBytesAvailable); │ Q_EMIT reply(replyStatus, replyMessage, freeBytesAvailable);
} │
next prev up dogecoin/src/test/script_tests.cpp:1059 │ bitcoin/src/test/script_tests.cpp:1061
│
ScriptError err; │ ScriptError err;
CKey key1, key2, key3; │ CKey key1, key2, key3;
key1.MakeNewKey(true); │ key1.MakeNewKey(true);
key2.MakeNewKey(false); │ key2.MakeNewKey(false);
key3.MakeNewKey(true); │ key3.MakeNewKey(true);
│
CScript scriptPubKey12; │ CScript scriptPubKey12;
scriptPubKey12 << OP_1 << ToByteVector(key1.GetPubKey()) << ToByteVector(key2.GetPub │ scriptPubKey12 << OP_1 << ToByteVector(key1.GetPubKey()) << ToByteVector(key2.GetPub
│
CMutableTransaction txFrom12 = BuildCreditingTransaction(scriptPubKey12); │ const CTransaction txFrom12{BuildCreditingTransaction(scriptPubKey12)};
CMutableTransaction txTo12 = BuildSpendingTransaction(CScript(), CScriptWitness(), t │ CMutableTransaction txTo12 = BuildSpendingTransaction(CScript(), CScriptWitness(), t
│
CScript goodsig1 = sign_multisig(scriptPubKey12, key1, txTo12); │ CScript goodsig1 = sign_multisig(scriptPubKey12, key1, CTransaction(txTo12));
BOOST_CHECK(VerifyScript(goodsig1, scriptPubKey12, NULL, flags, MutableTransactionSi │ BOOST_CHECK(VerifyScript(goodsig1, scriptPubKey12, nullptr, gFlags, MutableTransacti
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err)); │ BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err));
txTo12.vout[0].nValue = 2; │ txTo12.vout[0].nValue = 2;
BOOST_CHECK(!VerifyScript(goodsig1, scriptPubKey12, NULL, flags, MutableTransactionS │ BOOST_CHECK(!VerifyScript(goodsig1, scriptPubKey12, nullptr, gFlags, MutableTransact
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err)); │ BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err));
│
CScript goodsig2 = sign_multisig(scriptPubKey12, key2, txTo12); │ CScript goodsig2 = sign_multisig(scriptPubKey12, key2, CTransaction(txTo12));
BOOST_CHECK(VerifyScript(goodsig2, scriptPubKey12, NULL, flags, MutableTransactionSi │ BOOST_CHECK(VerifyScript(goodsig2, scriptPubKey12, nullptr, gFlags, MutableTransacti
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err)); │ BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_OK, ScriptErrorString(err));
│
CScript badsig1 = sign_multisig(scriptPubKey12, key3, txTo12); │ CScript badsig1 = sign_multisig(scriptPubKey12, key3, CTransaction(txTo12));
BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey12, NULL, flags, MutableTransactionSi │ BOOST_CHECK(!VerifyScript(badsig1, scriptPubKey12, nullptr, gFlags, MutableTransacti
BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err)); │ BOOST_CHECK_MESSAGE(err == SCRIPT_ERR_EVAL_FALSE, ScriptErrorString(err));
} │
next prev up dogecoin/src/test/blockencodings_tests.cpp:235 │ bitcoin/src/test/blockencodings_tests.cpp:221
│
TestHeaderAndShortIDs shortIDs(block); │ TestHeaderAndShortIDs shortIDs(block);
shortIDs.prefilledtxn.resize(2); │ shortIDs.prefilledtxn.resize(2);
shortIDs.prefilledtxn[0] = {0, block.vtx[0]}; │ shortIDs.prefilledtxn[0] = {0, block.vtx[0]};
shortIDs.prefilledtxn[1] = {1, block.vtx[2]}; // id == 1 as it is 1 after index │ shortIDs.prefilledtxn[1] = {1, block.vtx[2]}; // id == 1 as it is 1 after index
shortIDs.shorttxids.resize(1); │ shortIDs.shorttxids.resize(1);
shortIDs.shorttxids[0] = shortIDs.GetShortID(block.vtx[1]->GetHash()); │ shortIDs.shorttxids[0] = shortIDs.GetShortID(block.vtx[1]->GetHash());
│
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); │ CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
stream << shortIDs; │ stream << shortIDs;
│
CBlockHeaderAndShortTxIDs shortIDs2; │ CBlockHeaderAndShortTxIDs shortIDs2;
stream >> shortIDs2; │ stream >> shortIDs2;
│
PartiallyDownloadedBlock partialBlock(&pool); │ PartiallyDownloadedBlock partialBlock(&pool);
BOOST_CHECK(partialBlock.InitData(shortIDs2, extra_txn) == READ_STATUS_OK); │ BOOST_CHECK(partialBlock.InitData(shortIDs2, extra_txn) == READ_STATUS_OK);
BOOST_CHECK( partialBlock.IsTxAvailable(0)); │ BOOST_CHECK( partialBlock.IsTxAvailable(0));
BOOST_CHECK( partialBlock.IsTxAvailable(1)); │ BOOST_CHECK( partialBlock.IsTxAvailable(1));
BOOST_CHECK( partialBlock.IsTxAvailable(2)); │ BOOST_CHECK( partialBlock.IsTxAvailable(2));
│
BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[1]->GetHash())->GetSharedTx().use_co │ BOOST_CHECK_EQUAL(pool.mapTx.find(block.vtx[1]->GetHash())->GetSharedTx().use_co
│
CBlock block2; │ CBlock block2;
PartiallyDownloadedBlock partialBlockCopy = partialBlock; │ PartiallyDownloadedBlock partialBlockCopy = partialBlock;
BOOST_CHECK(partialBlock.FillBlock(block2, {}) == READ_STATUS_OK); │ BOOST_CHECK(partialBlock.FillBlock(block2, {}) == READ_STATUS_OK);
BOOST_CHECK_EQUAL(block.GetHash().ToString(), block2.GetHash().ToString()); │ BOOST_CHECK_EQUAL(block.GetHash().ToString(), block2.GetHash().ToString());
bool mutated; │ bool mutated;
BOOST_CHECK_EQUAL(block.hashMerkleRoot.ToString(), BlockMerkleRoot(block2, &muta │ BOOST_CHECK_EQUAL(block.hashMerkleRoot.ToString(), BlockMerkleRoot(block2, &muta
BOOST_CHECK(!mutated); │ BOOST_CHECK(!mutated);
│
txhash = block.vtx[1]->GetHash(); │ txhash = block.vtx[1]->GetHash();
block.vtx.clear(); │ block.vtx.clear();
block2.vtx.clear(); │ block2.vtx.clear();
BOOST_CHECK_EQUAL(pool.mapTx.find(txhash)->GetSharedTx().use_count(), SHARED_TX_ │ BOOST_CHECK_EQUAL(pool.mapTx.find(txhash)->GetSharedTx().use_count(), SHARED_TX_
} │
next prev up bitcoin/src/test/dbwrapper_tests.cpp:358 │ dogecoin/src/test/dbwrapper_tests.cpp:273
│
char buf[10]; │ char buf[10];
│
fs::path ph = m_args.GetDataDirBase() / "iterator_string_ordering"; │ boost::filesystem::path ph = boost::filesystem::temp_directory_path() / boost::files
CDBWrapper dbw(ph, (1 << 20), true, false, false); │ CDBWrapper dbw(ph, (1 << 20), true, false, false);
for (int x=0x00; x<10; ++x) { │ for (int x=0x00; x<10; ++x) {
for (int y = 0; y < 10; y++) { │ for (int y = 0; y < 10; y++) {
snprintf(buf, sizeof(buf), "%d", x); │ sprintf(buf, "%d", x);
StringContentsSerializer key(buf); │ StringContentsSerializer key(buf);
for (int z = 0; z < y; z++) │ for (int z = 0; z < y; z++)
key += key; │ key += key;
uint32_t value = x*x; │ uint32_t value = x*x;
BOOST_CHECK(dbw.Write(key, value)); │ BOOST_CHECK(dbw.Write(key, value));
} │ }
} │ }
│
std::unique_ptr<CDBIterator> it(const_cast<CDBWrapper&>(dbw).NewIterator()); │ std::unique_ptr<CDBIterator> it(const_cast<CDBWrapper*>(&dbw)->NewIterator());
for (const int seek_start : {0, 5}) { │ for (int c=0; c<2; ++c) {
snprintf(buf, sizeof(buf), "%d", seek_start); │ int seek_start;
│ if (c == 0)
│ seek_start = 0;
│ else
│ seek_start = 5;
│ sprintf(buf, "%d", seek_start);
StringContentsSerializer seek_key(buf); │ StringContentsSerializer seek_key(buf);
it->Seek(seek_key); │ it->Seek(seek_key);
for (unsigned int x=seek_start; x<10; ++x) { │ for (int x=seek_start; x<10; ++x) {
for (int y = 0; y < 10; y++) { │ for (int y = 0; y < 10; y++) {
snprintf(buf, sizeof(buf), "%d", x); │ sprintf(buf, "%d", x);
std::string exp_key(buf); │ std::string exp_key(buf);
for (int z = 0; z < y; z++) │ for (int z = 0; z < y; z++)
exp_key += exp_key; │ exp_key += exp_key;
StringContentsSerializer key; │ StringContentsSerializer key;
uint32_t value; │ uint32_t value;
BOOST_CHECK(it->Valid()); │ BOOST_CHECK(it->Valid());
if (!it->Valid()) // Avoid spurious errors about invalid iterator's key │ if (!it->Valid()) // Avoid spurious errors about invalid iterator's key
break; │ break;
BOOST_CHECK(it->GetKey(key)); │ BOOST_CHECK(it->GetKey(key));
BOOST_CHECK(it->GetValue(value)); │ BOOST_CHECK(it->GetValue(value));
BOOST_CHECK_EQUAL(key.str, exp_key); │ BOOST_CHECK_EQUAL(key.str, exp_key);
BOOST_CHECK_EQUAL(value, x*x); │ BOOST_CHECK_EQUAL(value, x*x);
it->Next(); │ it->Next();
} │ }
} │ }
BOOST_CHECK(!it->Valid()); │ BOOST_CHECK(!it->Valid());
} │ }
} │
next prev up dogecoin/src/test/sighash_tests.cpp:171 │ bitcoin/src/test/sighash_tests.cpp:164
│
UniValue tests = read_json(std::string(json_tests::sighash, json_tests::sighash + si │ UniValue tests = read_json(std::string(json_tests::sighash, json_tests::sighash + si
│
for (unsigned int idx = 0; idx < tests.size(); idx++) { │ for (unsigned int idx = 0; idx < tests.size(); idx++) {
UniValue test = tests[idx]; │ UniValue test = tests[idx];
std::string strTest = test.write(); │ std::string strTest = test.write();
if (test.size() < 1) // Allow for extra stuff (useful for comments) │ if (test.size() < 1) // Allow for extra stuff (useful for comments)
{ │ {
BOOST_ERROR("Bad test: " << strTest); │ BOOST_ERROR("Bad test: " << strTest);
continue; │ continue;
} │ }
if (test.size() == 1) continue; // comment │ if (test.size() == 1) continue; // comment
│
std::string raw_tx, raw_script, sigHashHex; │ std::string raw_tx, raw_script, sigHashHex;
int nIn, nHashType; │ int nIn, nHashType;
uint256 sh; │ uint256 sh;
CTransactionRef tx; │ CTransactionRef tx;
CScript scriptCode = CScript(); │ CScript scriptCode = CScript();
│
try { │ try {
// deserialize test data │ // deserialize test data
raw_tx = test[0].get_str(); │ raw_tx = test[0].get_str();
raw_script = test[1].get_str(); │ raw_script = test[1].get_str();
nIn = test[2].get_int(); │ nIn = test[2].get_int();
nHashType = test[3].get_int(); │ nHashType = test[3].get_int();
sigHashHex = test[4].get_str(); │ sigHashHex = test[4].get_str();
│
CDataStream stream(ParseHex(raw_tx), SER_NETWORK, PROTOCOL_VERSION); │ CDataStream stream(ParseHex(raw_tx), SER_NETWORK, PROTOCOL_VERSION);
stream >> tx; │ stream >> tx;
│
CValidationState state; │ TxValidationState state;
BOOST_CHECK_MESSAGE(CheckTransaction(*tx, state), strTest); │ BOOST_CHECK_MESSAGE(CheckTransaction(*tx, state), strTest);
BOOST_CHECK(state.IsValid()); │ BOOST_CHECK(state.IsValid());
│
std::vector<unsigned char> raw = ParseHex(raw_script); │ std::vector<unsigned char> raw = ParseHex(raw_script);
scriptCode.insert(scriptCode.end(), raw.begin(), raw.end()); │ scriptCode.insert(scriptCode.end(), raw.begin(), raw.end());
} catch (...) { │ } catch (...) {
BOOST_ERROR("Bad test, couldn't deserialize data: " << strTest); │ BOOST_ERROR("Bad test, couldn't deserialize data: " << strTest);
continue; │ continue;
} │ }
│
sh = SignatureHash(scriptCode, *tx, nIn, nHashType, 0, SIGVERSION_BASE); │ sh = SignatureHash(scriptCode, *tx, nIn, nHashType, 0, SigVersion::BASE);
BOOST_CHECK_MESSAGE(sh.GetHex() == sigHashHex, strTest); │ BOOST_CHECK_MESSAGE(sh.GetHex() == sigHashHex, strTest);
} │ }
} │
next prev up dogecoin/src/addrman.cpp:143 │ bitcoin/src/addrman.cpp:487
│
│ AssertLockHeld(cs);
│
// remove the entry from all new buckets │ // remove the entry from all new buckets
for (int bucket = 0; bucket < ADDRMAN_NEW_BUCKET_COUNT; bucket++) { │ const int start_bucket{info.GetNewBucket(nKey, m_netgroupman)};
int pos = info.GetBucketPosition(nKey, true, bucket); │ for (int n = 0; n < ADDRMAN_NEW_BUCKET_COUNT; ++n) {
│ const int bucket{(start_bucket + n) % ADDRMAN_NEW_BUCKET_COUNT};
│ const int pos{info.GetBucketPosition(nKey, true, bucket)};
if (vvNew[bucket][pos] == nId) { │ if (vvNew[bucket][pos] == nId) {
vvNew[bucket][pos] = -1; │ vvNew[bucket][pos] = -1;
info.nRefCount--; │ info.nRefCount--;
│ if (info.nRefCount == 0) break;
} │ }
} │ }
nNew--; │ nNew--;
│
assert(info.nRefCount == 0); │ assert(info.nRefCount == 0);
│
// which tried bucket to move the entry to │ // which tried bucket to move the entry to
int nKBucket = info.GetTriedBucket(nKey); │ int nKBucket = info.GetTriedBucket(nKey, m_netgroupman);
int nKBucketPos = info.GetBucketPosition(nKey, false, nKBucket); │ int nKBucketPos = info.GetBucketPosition(nKey, false, nKBucket);
│
// first make space to add it (the existing tried entry there is moved to new, delet │ // first make space to add it (the existing tried entry there is moved to new, delet
if (vvTried[nKBucket][nKBucketPos] != -1) { │ if (vvTried[nKBucket][nKBucketPos] != -1) {
// find an item to evict │ // find an item to evict
int nIdEvict = vvTried[nKBucket][nKBucketPos]; │ int nIdEvict = vvTried[nKBucket][nKBucketPos];
assert(mapInfo.count(nIdEvict) == 1); │ assert(mapInfo.count(nIdEvict) == 1);
CAddrInfo& infoOld = mapInfo[nIdEvict]; │ AddrInfo& infoOld = mapInfo[nIdEvict];
│
// Remove the to-be-evicted item from the tried set. │ // Remove the to-be-evicted item from the tried set.
infoOld.fInTried = false; │ infoOld.fInTried = false;
vvTried[nKBucket][nKBucketPos] = -1; │ vvTried[nKBucket][nKBucketPos] = -1;
nTried--; │ nTried--;
│
// find which new bucket it belongs to │ // find which new bucket it belongs to
int nUBucket = infoOld.GetNewBucket(nKey); │ int nUBucket = infoOld.GetNewBucket(nKey, m_netgroupman);
int nUBucketPos = infoOld.GetBucketPosition(nKey, true, nUBucket); │ int nUBucketPos = infoOld.GetBucketPosition(nKey, true, nUBucket);
ClearNew(nUBucket, nUBucketPos); │ ClearNew(nUBucket, nUBucketPos);
assert(vvNew[nUBucket][nUBucketPos] == -1); │ assert(vvNew[nUBucket][nUBucketPos] == -1);
│
// Enter it into the new set again. │ // Enter it into the new set again.
infoOld.nRefCount = 1; │ infoOld.nRefCount = 1;
vvNew[nUBucket][nUBucketPos] = nIdEvict; │ vvNew[nUBucket][nUBucketPos] = nIdEvict;
nNew++; │ nNew++;
│ LogPrint(BCLog::ADDRMAN, "Moved %s from tried[%i][%i] to new[%i][%i] to make spa
│ infoOld.ToString(), nKBucket, nKBucketPos, nUBucket, nUBucketPos);
} │ }
assert(vvTried[nKBucket][nKBucketPos] == -1); │ assert(vvTried[nKBucket][nKBucketPos] == -1);
│
vvTried[nKBucket][nKBucketPos] = nId; │ vvTried[nKBucket][nKBucketPos] = nId;
nTried++; │ nTried++;
info.fInTried = true; │ info.fInTried = true;
} │
next prev up bitcoin/src/test/prevector_tests.cpp:43 │ dogecoin/src/test/prevector_tests.cpp:42
│
const pretype& const_pre_vector = pre_vector; │ const pretype& const_pre_vector = pre_vector;
local_check_equal(real_vector.size(), pre_vector.size()); │ local_check_equal(real_vector.size(), pre_vector.size());
local_check_equal(real_vector.empty(), pre_vector.empty()); │ local_check_equal(real_vector.empty(), pre_vector.empty());
for (Size s = 0; s < real_vector.size(); s++) { │ for (Size s = 0; s < real_vector.size(); s++) {
local_check(real_vector[s] == pre_vector[s]); │ local_check(real_vector[s] == pre_vector[s]);
local_check(&(pre_vector[s]) == &(pre_vector.begin()[s])); │ local_check(&(pre_vector[s]) == &(pre_vector.begin()[s]));
local_check(&(pre_vector[s]) == &*(pre_vector.begin() + s)); │ local_check(&(pre_vector[s]) == &*(pre_vector.begin() + s));
local_check(&(pre_vector[s]) == &*((pre_vector.end() + s) - real_vector.siz │ local_check(&(pre_vector[s]) == &*((pre_vector.end() + s) - real_vector.siz
} │ }
// local_check(realtype(pre_vector) == real_vector); │ // local_check(realtype(pre_vector) == real_vector);
local_check(pretype(real_vector.begin(), real_vector.end()) == pre_vector); │ local_check(pretype(real_vector.begin(), real_vector.end()) == pre_vector);
local_check(pretype(pre_vector.begin(), pre_vector.end()) == pre_vector); │ local_check(pretype(pre_vector.begin(), pre_vector.end()) == pre_vector);
size_t pos = 0; │ size_t pos = 0;
for (const T& v : pre_vector) { │ BOOST_FOREACH(const T& v, pre_vector) {
local_check(v == real_vector[pos++]); │ local_check(v == real_vector[pos++]);
} │ }
for (const T& v : reverse_iterate(pre_vector)) { │ BOOST_REVERSE_FOREACH(const T& v, pre_vector) {
local_check(v == real_vector[--pos]); │ local_check(v == real_vector[--pos]);
} │ }
for (const T& v : const_pre_vector) { │ BOOST_FOREACH(const T& v, const_pre_vector) {
local_check(v == real_vector[pos++]); │ local_check(v == real_vector[pos++]);
} │ }
for (const T& v : reverse_iterate(const_pre_vector)) { │ BOOST_REVERSE_FOREACH(const T& v, const_pre_vector) {
local_check(v == real_vector[--pos]); │ local_check(v == real_vector[--pos]);
} │ }
CDataStream ss1(SER_DISK, 0); │ CDataStream ss1(SER_DISK, 0);
CDataStream ss2(SER_DISK, 0); │ CDataStream ss2(SER_DISK, 0);
ss1 << real_vector; │ ss1 << real_vector;
ss2 << pre_vector; │ ss2 << pre_vector;
local_check_equal(ss1.size(), ss2.size()); │ local_check_equal(ss1.size(), ss2.size());
for (Size s = 0; s < ss1.size(); s++) { │ for (Size s = 0; s < ss1.size(); s++) {
local_check_equal(ss1[s], ss2[s]); │ local_check_equal(ss1[s], ss2[s]);
} │ }
} │
next prev up dogecoin/src/versionbits.cpp:109 │ bitcoin/src/versionbits.cpp:141
│
│ int64_t start_time = BeginTime(params);
│ if (start_time == Consensus::BIP9Deployment::ALWAYS_ACTIVE || start_time == Consensu
│ return 0;
│ }
│
const ThresholdState initialState = GetStateFor(pindexPrev, params, cache); │ const ThresholdState initialState = GetStateFor(pindexPrev, params, cache);
│
// BIP 9 about state DEFINED: "The genesis block is by definition in this state for │ // BIP 9 about state DEFINED: "The genesis block is by definition in this state for
if (initialState == THRESHOLD_DEFINED) { │ if (initialState == ThresholdState::DEFINED) {
return 0; │ return 0;
} │ }
│
const int nPeriod = Period(params); │ const int nPeriod = Period(params);
│
// A block's state is always the same as that of the first of its period, so it is c │ // A block's state is always the same as that of the first of its period, so it is c
// To ease understanding of the following height calculation, it helps to remember t │ // To ease understanding of the following height calculation, it helps to remember t
// right now pindexPrev points to the block prior to the block that we are computing │ // right now pindexPrev points to the block prior to the block that we are computing
// if we are computing for the last block of a period, then pindexPrev points to the │ // if we are computing for the last block of a period, then pindexPrev points to the
// if we are computing for the first block of a period, then pindexPrev points to th │ // if we are computing for the first block of a period, then pindexPrev points to th
// The parent of the genesis block is represented by NULL. │ // The parent of the genesis block is represented by nullptr.
pindexPrev = pindexPrev->GetAncestor(pindexPrev->nHeight - ((pindexPrev->nHeight + 1 │ pindexPrev = Assert(pindexPrev->GetAncestor(pindexPrev->nHeight - ((pindexPrev->nHei
│
const CBlockIndex* previousPeriodParent = pindexPrev->GetAncestor(pindexPrev->nHeigh │ const CBlockIndex* previousPeriodParent = pindexPrev->GetAncestor(pindexPrev->nHeigh
│
while (previousPeriodParent != NULL && GetStateFor(previousPeriodParent, params, cac │ while (previousPeriodParent != nullptr && GetStateFor(previousPeriodParent, params,
pindexPrev = previousPeriodParent; │ pindexPrev = previousPeriodParent;
previousPeriodParent = pindexPrev->GetAncestor(pindexPrev->nHeight - nPeriod); │ previousPeriodParent = pindexPrev->GetAncestor(pindexPrev->nHeight - nPeriod);
} │ }
│
// Adjust the result because right now we point to the parent block. │ // Adjust the result because right now we point to the parent block.
return pindexPrev->nHeight + 1; │ return pindexPrev->nHeight + 1;
} │
next prev up dogecoin/src/qt/bitcoinaddressvalidator.cpp:24 │ bitcoin/src/qt/bitcoinaddressvalidator.cpp:24
│
Q_UNUSED(pos); │ Q_UNUSED(pos);
│
// Empty address is "intermediate" input │ // Empty address is "intermediate" input
if (input.isEmpty()) │ if (input.isEmpty())
return QValidator::Intermediate; │ return QValidator::Intermediate;
│
// Correction │ // Correction
for (int idx = 0; idx < input.size();) │ for (int idx = 0; idx < input.size();)
{ │ {
bool removeChar = false; │ bool removeChar = false;
QChar ch = input.at(idx); │ QChar ch = input.at(idx);
// Corrections made are very conservative on purpose, to avoid │ // Corrections made are very conservative on purpose, to avoid
// users unexpectedly getting away with typos that would normally │ // users unexpectedly getting away with typos that would normally
// be detected, and thus sending to the wrong address. │ // be detected, and thus sending to the wrong address.
switch(ch.unicode()) │ switch(ch.unicode())
{ │ {
// Qt categorizes these as "Other_Format" not "Separator_Space" │ // Qt categorizes these as "Other_Format" not "Separator_Space"
case 0x200B: // ZERO WIDTH SPACE │ case 0x200B: // ZERO WIDTH SPACE
case 0xFEFF: // ZERO WIDTH NO-BREAK SPACE │ case 0xFEFF: // ZERO WIDTH NO-BREAK SPACE
removeChar = true; │ removeChar = true;
break; │ break;
default: │ default:
break; │ break;
} │ }
│
// Remove whitespace │ // Remove whitespace
if (ch.isSpace()) │ if (ch.isSpace())
removeChar = true; │ removeChar = true;
│
// To next character │ // To next character
if (removeChar) │ if (removeChar)
input.remove(idx, 1); │ input.remove(idx, 1);
else │ else
++idx; │ ++idx;
} │ }
│
// Validation │ // Validation
QValidator::State state = QValidator::Acceptable; │ QValidator::State state = QValidator::Acceptable;
for (int idx = 0; idx < input.size(); ++idx) │ for (int idx = 0; idx < input.size(); ++idx)
{ │ {
int ch = input.at(idx).unicode(); │ int ch = input.at(idx).unicode();
│
if (((ch >= '0' && ch<='9') || │ if (((ch >= '0' && ch<='9') ||
(ch >= 'a' && ch<='z') || │ (ch >= 'a' && ch<='z') ||
(ch >= 'A' && ch<='Z')) && │ (ch >= 'A' && ch<='Z')) &&
ch != 'I' && ch != 'O') // Characters invalid in both Base58 and Bech32 │ ch != 'I' && ch != 'O') // Characters invalid in both Base58 and Bech32
{ │ {
// Alphanumeric and not a 'forbidden' character │ // Alphanumeric and not a 'forbidden' character
} │ }
else │ else
{ │ {
state = QValidator::Invalid; │ state = QValidator::Invalid;
} │ }
} │ }
│
return state; │ return state;
} │
next prev up bitcoin/src/script/interpreter.cpp:561 │ dogecoin/src/script/interpreter.cpp:393
│
if (!(flags & SCRIPT_VERIFY_CHECKSEQUENCEVERIFY)) { │ if (!(flags & SCRIPT_VERIFY_CHECKSEQUENCEVERIFY)) {
// not enabled; treat as a NOP3 │ // not enabled; treat as a NOP3
│ if (flags & SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS) {
│ return set_error(serror, SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NO
│ }
break; │ break;
} │ }
│
if (stack.size() < 1) │ if (stack.size() < 1)
return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); │ return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION);
│
// nSequence, like nLockTime, is a 32-bit unsigned integer │ // nSequence, like nLockTime, is a 32-bit unsigned integer
// field. See the comment in CHECKLOCKTIMEVERIFY regarding │ // field. See the comment in CHECKLOCKTIMEVERIFY regarding
// 5-byte numeric operands. │ // 5-byte numeric operands.
const CScriptNum nSequence(stacktop(-1), fRequireMinimal, 5); │ const CScriptNum nSequence(stacktop(-1), fRequireMinimal, 5);
│
// In the rare event that the argument may be < 0 due to │ // In the rare event that the argument may be < 0 due to
// some arithmetic being done first, you can always use │ // some arithmetic being done first, you can always use
// 0 MAX CHECKSEQUENCEVERIFY. │ // 0 MAX CHECKSEQUENCEVERIFY.
if (nSequence < 0) │ if (nSequence < 0)
return set_error(serror, SCRIPT_ERR_NEGATIVE_LOCKTIME); │ return set_error(serror, SCRIPT_ERR_NEGATIVE_LOCKTIME);
│
// To provide for future soft-fork extensibility, if the │ // To provide for future soft-fork extensibility, if the
// operand has the disabled lock-time flag set, │ // operand has the disabled lock-time flag set,
// CHECKSEQUENCEVERIFY behaves as a NOP. │ // CHECKSEQUENCEVERIFY behaves as a NOP.
if ((nSequence & CTxIn::SEQUENCE_LOCKTIME_DISABLE_FLAG) != 0) │ if ((nSequence & CTxIn::SEQUENCE_LOCKTIME_DISABLE_FLAG) != 0)
break; │ break;
│
// Compare the specified sequence number with the input. │ // Compare the specified sequence number with the input.
if (!checker.CheckSequence(nSequence)) │ if (!checker.CheckSequence(nSequence))
return set_error(serror, SCRIPT_ERR_UNSATISFIED_LOCKTIME); │ return set_error(serror, SCRIPT_ERR_UNSATISFIED_LOCKTIME);
│
break; │ break;
} │
next prev up bitcoin/src/test/bloom_tests.cpp:27 │ dogecoin/src/test/bloom_tests.cpp:27
│
CBloomFilter filter(3, 0.01, 0, BLOOM_UPDATE_ALL); │ CBloomFilter filter(3, 0.01, 0, BLOOM_UPDATE_ALL);
│
BOOST_CHECK_MESSAGE( !filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f09 │
filter.insert(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")); │ filter.insert(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8"));
BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f095 │ BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f095
// One bit different in first byte │ // One bit different in first byte
BOOST_CHECK_MESSAGE(!filter.contains(ParseHex("19108ad8ed9bb6274d3980bab5a85c048f095 │ BOOST_CHECK_MESSAGE(!filter.contains(ParseHex("19108ad8ed9bb6274d3980bab5a85c048f095
│
filter.insert(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32eee")); │ filter.insert(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32eee"));
BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32e │ BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32e
│
filter.insert(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729c5")); │ filter.insert(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729c5"));
BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729 │ BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729
│
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); │ CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
stream << filter; │ stream << filter;
│
std::vector<uint8_t> expected = ParseHex("03614e9b050000000000000001"); │ std::vector<unsigned char> vch = ParseHex("03614e9b050000000000000001");
auto result{MakeUCharSpan(stream)}; │ std::vector<char> expected(vch.size());
│
│ for (unsigned int i = 0; i < vch.size(); i++)
│ expected[i] = (char)vch[i];
│
BOOST_CHECK_EQUAL_COLLECTIONS(result.begin(), result.end(), expected.begin(), expect │ BOOST_CHECK_EQUAL_COLLECTIONS(stream.begin(), stream.end(), expected.begin(), expect
│
BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f095 │ BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f095
│ filter.clear();
│ BOOST_CHECK_MESSAGE( !filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f09
} │
next prev up dogecoin/src/qt/recentrequeststablemodel.cpp:54 │ bitcoin/src/qt/recentrequeststablemodel.cpp:59
│
if(!index.isValid() || index.row() >= list.length()) │ if(!index.isValid() || index.row() >= list.length())
return QVariant(); │ return QVariant();
│
const RecentRequestEntry *rec = &list[index.row()]; │
│
if(role == Qt::DisplayRole || role == Qt::EditRole) │ if(role == Qt::DisplayRole || role == Qt::EditRole)
{ │ {
│ const RecentRequestEntry *rec = &list[index.row()];
switch(index.column()) │ switch(index.column())
{ │ {
case Date: │ case Date:
return GUIUtil::dateTimeStr(rec->date); │ return GUIUtil::dateTimeStr(rec->date);
case Label: │ case Label:
if(rec->recipient.label.isEmpty() && role == Qt::DisplayRole) │ if(rec->recipient.label.isEmpty() && role == Qt::DisplayRole)
{ │ {
return tr("(no label)"); │ return tr("(no label)");
} │ }
else │ else
{ │ {
return rec->recipient.label; │ return rec->recipient.label;
} │ }
case Message: │ case Message:
if(rec->recipient.message.isEmpty() && role == Qt::DisplayRole) │ if(rec->recipient.message.isEmpty() && role == Qt::DisplayRole)
{ │ {
return tr("(no message)"); │ return tr("(no message)");
} │ }
else │ else
{ │ {
return rec->recipient.message; │ return rec->recipient.message;
} │ }
case Amount: │ case Amount:
if (rec->recipient.amount == 0 && role == Qt::DisplayRole) │ if (rec->recipient.amount == 0 && role == Qt::DisplayRole)
return tr("(no amount requested)"); │ return tr("(no amount requested)");
else if (role == Qt::EditRole) │ else if (role == Qt::EditRole)
return BitcoinUnits::format(walletModel->getOptionsModel()->getDisplayUn │ return BitcoinUnits::format(walletModel->getOptionsModel()->getDisplayUn
else │ else
return BitcoinUnits::format(walletModel->getOptionsModel()->getDisplayUn │ return BitcoinUnits::format(walletModel->getOptionsModel()->getDisplayUn
} │ }
} │ }
else if (role == Qt::TextAlignmentRole) │ else if (role == Qt::TextAlignmentRole)
{ │ {
if (index.column() == Amount) │ if (index.column() == Amount)
return (int)(Qt::AlignRight|Qt::AlignVCenter); │ return (int)(Qt::AlignRight|Qt::AlignVCenter);
} │ }
return QVariant(); │ return QVariant();
} │
next prev up dogecoin/src/base58.cpp:22 │ bitcoin/src/base58.cpp:39
│
// Skip leading spaces. │ // Skip leading spaces.
while (*psz && isspace(*psz)) │ while (*psz && IsSpace(*psz))
psz++; │ psz++;
// Skip and count leading '1's. │ // Skip and count leading '1's.
int zeroes = 0; │ int zeroes = 0;
int length = 0; │ int length = 0;
while (*psz == '1') { │ while (*psz == '1') {
zeroes++; │ zeroes++;
│ if (zeroes > max_ret_len) return false;
psz++; │ psz++;
} │ }
// Allocate enough space in big-endian base256 representation. │ // Allocate enough space in big-endian base256 representation.
int size = strlen(psz) * 733 /1000 + 1; // log(58) / log(256), rounded up. │ int size = strlen(psz) * 733 /1000 + 1; // log(58) / log(256), rounded up.
std::vector<unsigned char> b256(size); │ std::vector<unsigned char> b256(size);
// Process the characters. │ // Process the characters.
while (*psz && !isspace(*psz)) { │ static_assert(std::size(mapBase58) == 256, "mapBase58.size() should be 256"); // gua
│ while (*psz && !IsSpace(*psz)) {
// Decode base58 character │ // Decode base58 character
const char* ch = strchr(pszBase58, *psz); │ int carry = mapBase58[(uint8_t)*psz];
if (ch == NULL) │ if (carry == -1) // Invalid b58 character
return false; │ return false;
// Apply "b256 = b256 * 58 + ch". │
int carry = ch - pszBase58; │
int i = 0; │ int i = 0;
for (std::vector<unsigned char>::reverse_iterator it = b256.rbegin(); (carry != │ for (std::vector<unsigned char>::reverse_iterator it = b256.rbegin(); (carry !=
carry += 58 * (*it); │ carry += 58 * (*it);
*it = carry % 256; │ *it = carry % 256;
carry /= 256; │ carry /= 256;
} │ }
assert(carry == 0); │ assert(carry == 0);
length = i; │ length = i;
│ if (length + zeroes > max_ret_len) return false;
psz++; │ psz++;
} │ }
// Skip trailing spaces. │ // Skip trailing spaces.
while (isspace(*psz)) │ while (IsSpace(*psz))
psz++; │ psz++;
if (*psz != 0) │ if (*psz != 0)
return false; │ return false;
// Skip leading zeroes in b256. │ // Skip leading zeroes in b256.
std::vector<unsigned char>::iterator it = b256.begin() + (size - length); │ std::vector<unsigned char>::iterator it = b256.begin() + (size - length);
while (it != b256.end() && *it == 0) │
it++; │
// Copy result into output vector. │ // Copy result into output vector.
vch.reserve(zeroes + (b256.end() - it)); │ vch.reserve(zeroes + (b256.end() - it));
vch.assign(zeroes, 0x00); │ vch.assign(zeroes, 0x00);
while (it != b256.end()) │ while (it != b256.end())
vch.push_back(*(it++)); │ vch.push_back(*(it++));
return true; │ return true;
} │
next prev up bitcoin/src/addrman.cpp:740 │ bitcoin/src/addrman.cpp:712
│
// use a new node │ // use a tried node
double fChanceFactor = 1.0; │ double fChanceFactor = 1.0;
while (1) { │ while (1) {
// Pick a new bucket, and an initial position in that bucket. │ // Pick a tried bucket, and an initial position in that bucket.
int nUBucket = insecure_rand.randrange(ADDRMAN_NEW_BUCKET_COUNT); │ int nKBucket = insecure_rand.randrange(ADDRMAN_TRIED_BUCKET_COUNT);
int nUBucketPos = insecure_rand.randrange(ADDRMAN_BUCKET_SIZE); │ int nKBucketPos = insecure_rand.randrange(ADDRMAN_BUCKET_SIZE);
// Iterate over the positions of that bucket, starting at the initial one, │ // Iterate over the positions of that bucket, starting at the initial one,
// and looping around. │ // and looping around.
int i; │ int i;
for (i = 0; i < ADDRMAN_BUCKET_SIZE; ++i) { │ for (i = 0; i < ADDRMAN_BUCKET_SIZE; ++i) {
if (vvNew[nUBucket][(nUBucketPos + i) % ADDRMAN_BUCKET_SIZE] != -1) brea │ if (vvTried[nKBucket][(nKBucketPos + i) % ADDRMAN_BUCKET_SIZE] != -1) br
} │ }
// If the bucket is entirely empty, start over with a (likely) different one │ // If the bucket is entirely empty, start over with a (likely) different one
if (i == ADDRMAN_BUCKET_SIZE) continue; │ if (i == ADDRMAN_BUCKET_SIZE) continue;
// Find the entry to return. │ // Find the entry to return.
int nId = vvNew[nUBucket][(nUBucketPos + i) % ADDRMAN_BUCKET_SIZE]; │ int nId = vvTried[nKBucket][(nKBucketPos + i) % ADDRMAN_BUCKET_SIZE];
const auto it_found{mapInfo.find(nId)}; │ const auto it_found{mapInfo.find(nId)};
assert(it_found != mapInfo.end()); │ assert(it_found != mapInfo.end());
const AddrInfo& info{it_found->second}; │ const AddrInfo& info{it_found->second};
// With probability GetChance() * fChanceFactor, return the entry. │ // With probability GetChance() * fChanceFactor, return the entry.
if (insecure_rand.randbits(30) < fChanceFactor * info.GetChance() * (1 << 30 │ if (insecure_rand.randbits(30) < fChanceFactor * info.GetChance() * (1 << 30
LogPrint(BCLog::ADDRMAN, "Selected %s from new\n", info.ToString()); │ LogPrint(BCLog::ADDRMAN, "Selected %s from tried\n", info.ToString());
return {info, info.nLastTry}; │ return {info, info.nLastTry};
} │ }
// Otherwise start over with a (likely) different bucket, and increased chan │ // Otherwise start over with a (likely) different bucket, and increased chan
fChanceFactor *= 1.2; │ fChanceFactor *= 1.2;
} │ }
} │
next prev up dogecoin/src/qt/transactionview.cpp:332 │ bitcoin/src/qt/transactionview.cpp:352
│
│ if (!model || !model->getOptionsModel()) {
│ return;
│ }
│
// CSV is currently the only supported format │ // CSV is currently the only supported format
QString filename = GUIUtil::getSaveFileName(this, │ QString filename = GUIUtil::getSaveFileName(this,
tr("Export Transaction History"), QString(), │ tr("Export Transaction History"), QString(),
tr("Comma separated file (*.csv)"), NULL); │ /*: Expanded name of the CSV file format.
│ See: https://en.wikipedia.org/wiki/Comma-separated_values. */
│ tr("Comma separated file") + QLatin1String(" (*.csv)"), nullptr);
│
if (filename.isNull()) │ if (filename.isNull())
return; │ return;
│
CSVModelWriter writer(filename); │ CSVModelWriter writer(filename);
│
// name, column, role │ // name, column, role
writer.setModel(transactionProxyModel); │ writer.setModel(transactionProxyModel);
writer.addColumn(tr("Confirmed"), 0, TransactionTableModel::ConfirmedRole); │ writer.addColumn(tr("Confirmed"), 0, TransactionTableModel::ConfirmedRole);
if (model && model->haveWatchOnly()) │ if (model->wallet().haveWatchOnly())
writer.addColumn(tr("Watch-only"), TransactionTableModel::Watchonly); │ writer.addColumn(tr("Watch-only"), TransactionTableModel::Watchonly);
writer.addColumn(tr("Date"), 0, TransactionTableModel::DateRole); │ writer.addColumn(tr("Date"), 0, TransactionTableModel::DateRole);
writer.addColumn(tr("Type"), TransactionTableModel::Type, Qt::EditRole); │ writer.addColumn(tr("Type"), TransactionTableModel::Type, Qt::EditRole);
writer.addColumn(tr("Label"), 0, TransactionTableModel::LabelRole); │ writer.addColumn(tr("Label"), 0, TransactionTableModel::LabelRole);
writer.addColumn(tr("Address"), 0, TransactionTableModel::AddressRole); │ writer.addColumn(tr("Address"), 0, TransactionTableModel::AddressRole);
writer.addColumn(BitcoinUnits::getAmountColumnTitle(model->getOptionsModel()->getDis │ writer.addColumn(BitcoinUnits::getAmountColumnTitle(model->getOptionsModel()->getDis
writer.addColumn(tr("ID"), 0, TransactionTableModel::TxIDRole); │ writer.addColumn(tr("ID"), 0, TransactionTableModel::TxHashRole);
│
if(!writer.write()) { │ if(!writer.write()) {
Q_EMIT message(tr("Exporting Failed"), tr("There was an error trying to save the │ Q_EMIT message(tr("Exporting Failed"), tr("There was an error trying to save the
CClientUIInterface::MSG_ERROR); │ CClientUIInterface::MSG_ERROR);
} │ }
else { │ else {
Q_EMIT message(tr("Exporting Successful"), tr("The transaction history was succe │ Q_EMIT message(tr("Exporting Successful"), tr("The transaction history was succe
CClientUIInterface::MSG_INFORMATION); │ CClientUIInterface::MSG_INFORMATION);
} │ }
} │
next prev up dogecoin/src/univalue/test/object.cpp:87 │ bitcoin/src/univalue/test/object.cpp:87
│
UniValue v1; │ UniValue v1;
BOOST_CHECK(v1.setNumStr("1")); │ BOOST_CHECK(v1.setNumStr("1"));
BOOST_CHECK(v1.isNum()); │ BOOST_CHECK(v1.isNum());
BOOST_CHECK_THROW(v1.get_bool(), std::runtime_error); │ BOOST_CHECK_THROW(v1.get_bool(), std::runtime_error);
│
UniValue v2; │ UniValue v2;
BOOST_CHECK(v2.setBool(true)); │ BOOST_CHECK(v2.setBool(true));
BOOST_CHECK_EQUAL(v2.get_bool(), true); │ BOOST_CHECK_EQUAL(v2.get_bool(), true);
BOOST_CHECK_THROW(v2.get_int(), std::runtime_error); │ BOOST_CHECK_THROW(v2.get_int(), std::runtime_error);
│
UniValue v3; │ UniValue v3;
BOOST_CHECK(v3.setNumStr("32482348723847471234")); │ BOOST_CHECK(v3.setNumStr("32482348723847471234"));
BOOST_CHECK_THROW(v3.get_int64(), std::runtime_error); │ BOOST_CHECK_THROW(v3.get_int64(), std::runtime_error);
BOOST_CHECK(v3.setNumStr("1000")); │ BOOST_CHECK(v3.setNumStr("1000"));
BOOST_CHECK_EQUAL(v3.get_int64(), 1000); │ BOOST_CHECK_EQUAL(v3.get_int64(), 1000);
│
UniValue v4; │ UniValue v4;
BOOST_CHECK(v4.setNumStr("2147483648")); │ BOOST_CHECK(v4.setNumStr("2147483648"));
BOOST_CHECK_EQUAL(v4.get_int64(), 2147483648); │ BOOST_CHECK_EQUAL(v4.get_int64(), 2147483648);
BOOST_CHECK_THROW(v4.get_int(), std::runtime_error); │ BOOST_CHECK_THROW(v4.get_int(), std::runtime_error);
BOOST_CHECK(v4.setNumStr("1000")); │ BOOST_CHECK(v4.setNumStr("1000"));
BOOST_CHECK_EQUAL(v4.get_int(), 1000); │ BOOST_CHECK_EQUAL(v4.get_int(), 1000);
BOOST_CHECK_THROW(v4.get_str(), std::runtime_error); │ BOOST_CHECK_THROW(v4.get_str(), std::runtime_error);
BOOST_CHECK_EQUAL(v4.get_real(), 1000); │ BOOST_CHECK_EQUAL(v4.get_real(), 1000);
BOOST_CHECK_THROW(v4.get_array(), std::runtime_error); │ BOOST_CHECK_THROW(v4.get_array(), std::runtime_error);
BOOST_CHECK_THROW(v4.getKeys(), std::runtime_error); │ BOOST_CHECK_THROW(v4.getKeys(), std::runtime_error);
BOOST_CHECK_THROW(v4.getValues(), std::runtime_error); │ BOOST_CHECK_THROW(v4.getValues(), std::runtime_error);
BOOST_CHECK_THROW(v4.get_obj(), std::runtime_error); │ BOOST_CHECK_THROW(v4.get_obj(), std::runtime_error);
│
UniValue v5; │ UniValue v5;
BOOST_CHECK(v5.read("[true, 10]")); │ BOOST_CHECK(v5.read("[true, 10]"));
BOOST_CHECK_NO_THROW(v5.get_array()); │ BOOST_CHECK_NO_THROW(v5.get_array());
std::vector<UniValue> vals = v5.getValues(); │ std::vector<UniValue> vals = v5.getValues();
BOOST_CHECK_THROW(vals[0].get_int(), std::runtime_error); │ BOOST_CHECK_THROW(vals[0].get_int(), std::runtime_error);
BOOST_CHECK_EQUAL(vals[0].get_bool(), true); │ BOOST_CHECK_EQUAL(vals[0].get_bool(), true);
│
BOOST_CHECK_EQUAL(vals[1].get_int(), 10); │ BOOST_CHECK_EQUAL(vals[1].get_int(), 10);
BOOST_CHECK_THROW(vals[1].get_bool(), std::runtime_error); │ BOOST_CHECK_THROW(vals[1].get_bool(), std::runtime_error);
} │
next prev up dogecoin/src/test/univalue_tests.cpp:66 │ bitcoin/src/univalue/test/object.cpp:87
│
UniValue v1; │ UniValue v1;
BOOST_CHECK(v1.setNumStr("1")); │ BOOST_CHECK(v1.setNumStr("1"));
BOOST_CHECK(v1.isNum()); │ BOOST_CHECK(v1.isNum());
BOOST_CHECK_THROW(v1.get_bool(), std::runtime_error); │ BOOST_CHECK_THROW(v1.get_bool(), std::runtime_error);
│
UniValue v2; │ UniValue v2;
BOOST_CHECK(v2.setBool(true)); │ BOOST_CHECK(v2.setBool(true));
BOOST_CHECK_EQUAL(v2.get_bool(), true); │ BOOST_CHECK_EQUAL(v2.get_bool(), true);
BOOST_CHECK_THROW(v2.get_int(), std::runtime_error); │ BOOST_CHECK_THROW(v2.get_int(), std::runtime_error);
│
UniValue v3; │ UniValue v3;
BOOST_CHECK(v3.setNumStr("32482348723847471234")); │ BOOST_CHECK(v3.setNumStr("32482348723847471234"));
BOOST_CHECK_THROW(v3.get_int64(), std::runtime_error); │ BOOST_CHECK_THROW(v3.get_int64(), std::runtime_error);
BOOST_CHECK(v3.setNumStr("1000")); │ BOOST_CHECK(v3.setNumStr("1000"));
BOOST_CHECK_EQUAL(v3.get_int64(), 1000); │ BOOST_CHECK_EQUAL(v3.get_int64(), 1000);
│
UniValue v4; │ UniValue v4;
BOOST_CHECK(v4.setNumStr("2147483648")); │ BOOST_CHECK(v4.setNumStr("2147483648"));
BOOST_CHECK_EQUAL(v4.get_int64(), 2147483648); │ BOOST_CHECK_EQUAL(v4.get_int64(), 2147483648);
BOOST_CHECK_THROW(v4.get_int(), std::runtime_error); │ BOOST_CHECK_THROW(v4.get_int(), std::runtime_error);
BOOST_CHECK(v4.setNumStr("1000")); │ BOOST_CHECK(v4.setNumStr("1000"));
BOOST_CHECK_EQUAL(v4.get_int(), 1000); │ BOOST_CHECK_EQUAL(v4.get_int(), 1000);
BOOST_CHECK_THROW(v4.get_str(), std::runtime_error); │ BOOST_CHECK_THROW(v4.get_str(), std::runtime_error);
BOOST_CHECK_EQUAL(v4.get_real(), 1000); │ BOOST_CHECK_EQUAL(v4.get_real(), 1000);
BOOST_CHECK_THROW(v4.get_array(), std::runtime_error); │ BOOST_CHECK_THROW(v4.get_array(), std::runtime_error);
BOOST_CHECK_THROW(v4.getKeys(), std::runtime_error); │ BOOST_CHECK_THROW(v4.getKeys(), std::runtime_error);
BOOST_CHECK_THROW(v4.getValues(), std::runtime_error); │ BOOST_CHECK_THROW(v4.getValues(), std::runtime_error);
BOOST_CHECK_THROW(v4.get_obj(), std::runtime_error); │ BOOST_CHECK_THROW(v4.get_obj(), std::runtime_error);
│
UniValue v5; │ UniValue v5;
BOOST_CHECK(v5.read("[true, 10]")); │ BOOST_CHECK(v5.read("[true, 10]"));
BOOST_CHECK_NO_THROW(v5.get_array()); │ BOOST_CHECK_NO_THROW(v5.get_array());
std::vector<UniValue> vals = v5.getValues(); │ std::vector<UniValue> vals = v5.getValues();
BOOST_CHECK_THROW(vals[0].get_int(), std::runtime_error); │ BOOST_CHECK_THROW(vals[0].get_int(), std::runtime_error);
BOOST_CHECK_EQUAL(vals[0].get_bool(), true); │ BOOST_CHECK_EQUAL(vals[0].get_bool(), true);
│
BOOST_CHECK_EQUAL(vals[1].get_int(), 10); │ BOOST_CHECK_EQUAL(vals[1].get_int(), 10);
BOOST_CHECK_THROW(vals[1].get_bool(), std::runtime_error); │ BOOST_CHECK_THROW(vals[1].get_bool(), std::runtime_error);
} │
next prev up dogecoin/src/test/univalue_tests.cpp:66 │ dogecoin/src/univalue/test/object.cpp:87
│
UniValue v1; │ UniValue v1;
BOOST_CHECK(v1.setNumStr("1")); │ BOOST_CHECK(v1.setNumStr("1"));
BOOST_CHECK(v1.isNum()); │ BOOST_CHECK(v1.isNum());
BOOST_CHECK_THROW(v1.get_bool(), std::runtime_error); │ BOOST_CHECK_THROW(v1.get_bool(), std::runtime_error);
│
UniValue v2; │ UniValue v2;
BOOST_CHECK(v2.setBool(true)); │ BOOST_CHECK(v2.setBool(true));
BOOST_CHECK_EQUAL(v2.get_bool(), true); │ BOOST_CHECK_EQUAL(v2.get_bool(), true);
BOOST_CHECK_THROW(v2.get_int(), std::runtime_error); │ BOOST_CHECK_THROW(v2.get_int(), std::runtime_error);
│
UniValue v3; │ UniValue v3;
BOOST_CHECK(v3.setNumStr("32482348723847471234")); │ BOOST_CHECK(v3.setNumStr("32482348723847471234"));
BOOST_CHECK_THROW(v3.get_int64(), std::runtime_error); │ BOOST_CHECK_THROW(v3.get_int64(), std::runtime_error);
BOOST_CHECK(v3.setNumStr("1000")); │ BOOST_CHECK(v3.setNumStr("1000"));
BOOST_CHECK_EQUAL(v3.get_int64(), 1000); │ BOOST_CHECK_EQUAL(v3.get_int64(), 1000);
│
UniValue v4; │ UniValue v4;
BOOST_CHECK(v4.setNumStr("2147483648")); │ BOOST_CHECK(v4.setNumStr("2147483648"));
BOOST_CHECK_EQUAL(v4.get_int64(), 2147483648); │ BOOST_CHECK_EQUAL(v4.get_int64(), 2147483648);
BOOST_CHECK_THROW(v4.get_int(), std::runtime_error); │ BOOST_CHECK_THROW(v4.get_int(), std::runtime_error);
BOOST_CHECK(v4.setNumStr("1000")); │ BOOST_CHECK(v4.setNumStr("1000"));
BOOST_CHECK_EQUAL(v4.get_int(), 1000); │ BOOST_CHECK_EQUAL(v4.get_int(), 1000);
BOOST_CHECK_THROW(v4.get_str(), std::runtime_error); │ BOOST_CHECK_THROW(v4.get_str(), std::runtime_error);
BOOST_CHECK_EQUAL(v4.get_real(), 1000); │ BOOST_CHECK_EQUAL(v4.get_real(), 1000);
BOOST_CHECK_THROW(v4.get_array(), std::runtime_error); │ BOOST_CHECK_THROW(v4.get_array(), std::runtime_error);
BOOST_CHECK_THROW(v4.getKeys(), std::runtime_error); │ BOOST_CHECK_THROW(v4.getKeys(), std::runtime_error);
BOOST_CHECK_THROW(v4.getValues(), std::runtime_error); │ BOOST_CHECK_THROW(v4.getValues(), std::runtime_error);
BOOST_CHECK_THROW(v4.get_obj(), std::runtime_error); │ BOOST_CHECK_THROW(v4.get_obj(), std::runtime_error);
│
UniValue v5; │ UniValue v5;
BOOST_CHECK(v5.read("[true, 10]")); │ BOOST_CHECK(v5.read("[true, 10]"));
BOOST_CHECK_NO_THROW(v5.get_array()); │ BOOST_CHECK_NO_THROW(v5.get_array());
std::vector<UniValue> vals = v5.getValues(); │ std::vector<UniValue> vals = v5.getValues();
BOOST_CHECK_THROW(vals[0].get_int(), std::runtime_error); │ BOOST_CHECK_THROW(vals[0].get_int(), std::runtime_error);
BOOST_CHECK_EQUAL(vals[0].get_bool(), true); │ BOOST_CHECK_EQUAL(vals[0].get_bool(), true);
│
BOOST_CHECK_EQUAL(vals[1].get_int(), 10); │ BOOST_CHECK_EQUAL(vals[1].get_int(), 10);
BOOST_CHECK_THROW(vals[1].get_bool(), std::runtime_error); │ BOOST_CHECK_THROW(vals[1].get_bool(), std::runtime_error);
} │
next prev up dogecoin/src/rpc/server.cpp:442 │ bitcoin/src/rpc/server.cpp:391
│
JSONRPCRequest out = in; │ JSONRPCRequest out = in;
out.params = UniValue(UniValue::VARR); │ out.params = UniValue(UniValue::VARR);
// Build a map of parameters, and remove ones that have been processed, so that we c │ // Build a map of parameters, and remove ones that have been processed, so that we c
// there is an unknown one. │ // there is an unknown one.
const std::vector<std::string>& keys = in.params.getKeys(); │ const std::vector<std::string>& keys = in.params.getKeys();
const std::vector<UniValue>& values = in.params.getValues(); │ const std::vector<UniValue>& values = in.params.getValues();
std::unordered_map<std::string, const UniValue*> argsIn; │ std::unordered_map<std::string, const UniValue*> argsIn;
for (size_t i=0; i<keys.size(); ++i) { │ for (size_t i=0; i<keys.size(); ++i) {
argsIn[keys[i]] = &values[i]; │ argsIn[keys[i]] = &values[i];
} │ }
// Process expected parameters. │ // Process expected parameters.
int hole = 0; │ int hole = 0;
for (const std::string &argName: argNames) { │ for (const std::string &argNamePattern: argNames) {
auto fr = argsIn.find(argName); │ std::vector<std::string> vargNames = SplitString(argNamePattern, '|');
│ auto fr = argsIn.end();
│ for (const std::string & argName : vargNames) {
│ fr = argsIn.find(argName);
│ if (fr != argsIn.end()) {
│ break;
│ }
│ }
if (fr != argsIn.end()) { │ if (fr != argsIn.end()) {
for (int i = 0; i < hole; ++i) { │ for (int i = 0; i < hole; ++i) {
// Fill hole between specified parameters with JSON nulls, │ // Fill hole between specified parameters with JSON nulls,
// but not at the end (for backwards compatibility with calls │ // but not at the end (for backwards compatibility with calls
// that act based on number of specified parameters). │ // that act based on number of specified parameters).
out.params.push_back(UniValue()); │ out.params.push_back(UniValue());
} │ }
hole = 0; │ hole = 0;
out.params.push_back(*fr->second); │ out.params.push_back(*fr->second);
argsIn.erase(fr); │ argsIn.erase(fr);
} else { │ } else {
hole += 1; │ hole += 1;
} │ }
} │ }
// If there are still arguments in the argsIn map, this is an error. │ // If there are still arguments in the argsIn map, this is an error.
if (!argsIn.empty()) { │ if (!argsIn.empty()) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Unknown named parameter " + argsIn.be │ throw JSONRPCError(RPC_INVALID_PARAMETER, "Unknown named parameter " + argsIn.be
} │ }
// Return request with named arguments transformed to positional arguments │ // Return request with named arguments transformed to positional arguments
return out; │ return out;
} │
next prev up dogecoin/src/qt/bitcoin.cpp:117 │ bitcoin/src/qt/bitcoin.cpp:119
│
// Remove old translators │ // Remove old translators
QApplication::removeTranslator(&qtTranslatorBase); │ QApplication::removeTranslator(&qtTranslatorBase);
QApplication::removeTranslator(&qtTranslator); │ QApplication::removeTranslator(&qtTranslator);
QApplication::removeTranslator(&translatorBase); │ QApplication::removeTranslator(&translatorBase);
QApplication::removeTranslator(&translator); │ QApplication::removeTranslator(&translator);
│
// Get desired locale (e.g. "de_DE") │ // Get desired locale (e.g. "de_DE")
// 1) System default language │ // 1) System default language
QString lang_territory = GetLangTerritory(); │ QString lang_territory = GetLangTerritory();
│
// Convert to "de" only by truncating "_DE" │ // Convert to "de" only by truncating "_DE"
QString lang = lang_territory; │ QString lang = lang_territory;
lang.truncate(lang_territory.lastIndexOf('_')); │ lang.truncate(lang_territory.lastIndexOf('_'));
│
// Load language files for configured locale: │ // Load language files for configured locale:
// - First load the translator for the base language, without territory │ // - First load the translator for the base language, without territory
// - Then load the more specific locale translator │ // - Then load the more specific locale translator
│
// Load e.g. qt_de.qm │ // Load e.g. qt_de.qm
if (qtTranslatorBase.load("qt_" + lang, QLibraryInfo::location(QLibraryInfo::Transla │ if (qtTranslatorBase.load("qt_" + lang, QLibraryInfo::location(QLibraryInfo::Transla
QApplication::installTranslator(&qtTranslatorBase); │ QApplication::installTranslator(&qtTranslatorBase);
│
// Load e.g. qt_de_DE.qm │ // Load e.g. qt_de_DE.qm
if (qtTranslator.load("qt_" + lang_territory, QLibraryInfo::location(QLibraryInfo::T │ if (qtTranslator.load("qt_" + lang_territory, QLibraryInfo::location(QLibraryInfo::T
QApplication::installTranslator(&qtTranslator); │ QApplication::installTranslator(&qtTranslator);
│
// Load e.g. bitcoin_de.qm (shortcut "de" needs to be defined in bitcoin.qrc) │ // Load e.g. bitcoin_de.qm (shortcut "de" needs to be defined in bitcoin.qrc)
if (translatorBase.load(lang, ":/translations/")) │ if (translatorBase.load(lang, ":/translations/"))
QApplication::installTranslator(&translatorBase); │ QApplication::installTranslator(&translatorBase);
│
// Load e.g. bitcoin_de_DE.qm (shortcut "de_DE" needs to be defined in bitcoin.qrc) │ // Load e.g. bitcoin_de_DE.qm (shortcut "de_DE" needs to be defined in bitcoin.qrc)
if (translator.load(lang_territory, ":/translations/")) │ if (translator.load(lang_territory, ":/translations/"))
QApplication::installTranslator(&translator); │ QApplication::installTranslator(&translator);
} │
next prev up bitcoin/src/qt/transactionview.cpp:268 │ dogecoin/src/qt/transactionview.cpp:246
│
if (!transactionProxyModel) return; │ if(!transactionProxyModel)
│ return;
QDate current = QDate::currentDate(); │ QDate current = QDate::currentDate();
dateRangeWidget->setVisible(false); │ dateRangeWidget->setVisible(false);
switch(dateWidget->itemData(idx).toInt()) │ switch(dateWidget->itemData(idx).toInt())
{ │ {
case All: │ case All:
transactionProxyModel->setDateRange( │ transactionProxyModel->setDateRange(
std::nullopt, │ TransactionFilterProxy::MIN_DATE,
std::nullopt); │ TransactionFilterProxy::MAX_DATE);
break; │ break;
case Today: │ case Today:
transactionProxyModel->setDateRange( │ transactionProxyModel->setDateRange(
GUIUtil::StartOfDay(current), │ QDateTime(current),
std::nullopt); │ TransactionFilterProxy::MAX_DATE);
break; │ break;
case ThisWeek: { │ case ThisWeek: {
// Find last Monday │ // Find last Monday
QDate startOfWeek = current.addDays(-(current.dayOfWeek()-1)); │ QDate startOfWeek = current.addDays(-(current.dayOfWeek()-1));
transactionProxyModel->setDateRange( │ transactionProxyModel->setDateRange(
GUIUtil::StartOfDay(startOfWeek), │ QDateTime(startOfWeek),
std::nullopt); │ TransactionFilterProxy::MAX_DATE);
│
} break; │ } break;
case ThisMonth: │ case ThisMonth:
transactionProxyModel->setDateRange( │ transactionProxyModel->setDateRange(
GUIUtil::StartOfDay(QDate(current.year(), current.month(), 1)), │ QDateTime(QDate(current.year(), current.month(), 1)),
std::nullopt); │ TransactionFilterProxy::MAX_DATE);
break; │ break;
case LastMonth: │ case LastMonth:
transactionProxyModel->setDateRange( │ transactionProxyModel->setDateRange(
GUIUtil::StartOfDay(QDate(current.year(), current.month(), 1).addMonths( │ QDateTime(QDate(current.year(), current.month(), 1).addMonths(-1)),
GUIUtil::StartOfDay(QDate(current.year(), current.month(), 1))); │ QDateTime(QDate(current.year(), current.month(), 1)));
break; │ break;
case ThisYear: │ case ThisYear:
transactionProxyModel->setDateRange( │ transactionProxyModel->setDateRange(
GUIUtil::StartOfDay(QDate(current.year(), 1, 1)), │ QDateTime(QDate(current.year(), 1, 1)),
std::nullopt); │ TransactionFilterProxy::MAX_DATE);
break; │ break;
case Range: │ case Range:
dateRangeWidget->setVisible(true); │ dateRangeWidget->setVisible(true);
dateRangeChanged(); │ dateRangeChanged();
break; │ break;
} │ }
} │
next prev up bitcoin/src/test/blockencodings_tests.cpp:260 │ dogecoin/src/test/blockencodings_tests.cpp:274
│
CTxMemPool pool; │ CTxMemPool pool(CFeeRate(0));
CMutableTransaction coinbase; │ CMutableTransaction coinbase;
coinbase.vin.resize(1); │ coinbase.vin.resize(1);
coinbase.vin[0].scriptSig.resize(10); │ coinbase.vin[0].scriptSig.resize(10);
coinbase.vout.resize(1); │ coinbase.vout.resize(1);
coinbase.vout[0].nValue = 42; │ coinbase.vout[0].nValue = 42;
│
CBlock block; │ CBlock block;
block.vtx.resize(1); │ block.vtx.resize(1);
block.vtx[0] = MakeTransactionRef(std::move(coinbase)); │ block.vtx[0] = MakeTransactionRef(std::move(coinbase));
block.nVersion = 42; │ block.nVersion = 1;
block.hashPrevBlock = InsecureRand256(); │ block.hashPrevBlock = GetRandHash();
block.nBits = 0x207fffff; │ block.nBits = 0x207fffff;
│
bool mutated; │ bool mutated;
block.hashMerkleRoot = BlockMerkleRoot(block, &mutated); │ block.hashMerkleRoot = BlockMerkleRoot(block, &mutated);
assert(!mutated); │ assert(!mutated);
while (!CheckProofOfWork(block.GetHash(), block.nBits, Params().GetConsensus())) ++b │ while (!CheckProofOfWork(block.GetPoWHash(), block.nBits, Params().GetConsensus(0)))
│
// Test simple header round-trip with only coinbase │ // Test simple header round-trip with only coinbase
{ │ {
CBlockHeaderAndShortTxIDs shortIDs(block, false); │ CBlockHeaderAndShortTxIDs shortIDs(block, false);
│
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); │ CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
stream << shortIDs; │ stream << shortIDs;
│
CBlockHeaderAndShortTxIDs shortIDs2; │ CBlockHeaderAndShortTxIDs shortIDs2;
stream >> shortIDs2; │ stream >> shortIDs2;
│
PartiallyDownloadedBlock partialBlock(&pool); │ PartiallyDownloadedBlock partialBlock(&pool);
BOOST_CHECK(partialBlock.InitData(shortIDs2, extra_txn) == READ_STATUS_OK); │ BOOST_CHECK(partialBlock.InitData(shortIDs2, extra_txn) == READ_STATUS_OK);
BOOST_CHECK(partialBlock.IsTxAvailable(0)); │ BOOST_CHECK(partialBlock.IsTxAvailable(0));
│
CBlock block2; │ CBlock block2;
std::vector<CTransactionRef> vtx_missing; │ std::vector<CTransactionRef> vtx_missing;
BOOST_CHECK(partialBlock.FillBlock(block2, vtx_missing) == READ_STATUS_OK); │ BOOST_CHECK(partialBlock.FillBlock(block2, vtx_missing) == READ_STATUS_OK);
BOOST_CHECK_EQUAL(block.GetHash().ToString(), block2.GetHash().ToString()); │ BOOST_CHECK_EQUAL(block.GetHash().ToString(), block2.GetHash().ToString());
BOOST_CHECK_EQUAL(block.hashMerkleRoot.ToString(), BlockMerkleRoot(block2, &muta │ BOOST_CHECK_EQUAL(block.hashMerkleRoot.ToString(), BlockMerkleRoot(block2, &muta
BOOST_CHECK(!mutated); │ BOOST_CHECK(!mutated);
} │ }
} │
next prev up dogecoin/src/test/arith_uint256_tests.cpp:231 │ bitcoin/src/test/arith_uint256_tests.cpp:225
│
unsigned char TmpArray[32]; │ unsigned char TmpArray[32];
│
CHECKBITWISEOPERATOR(R1,R2,|) │ CHECKBITWISEOPERATOR(R1,R2,|)
CHECKBITWISEOPERATOR(R1,R2,^) │ CHECKBITWISEOPERATOR(R1,R2,^)
CHECKBITWISEOPERATOR(R1,R2,&) │ CHECKBITWISEOPERATOR(R1,R2,&)
CHECKBITWISEOPERATOR(R1,Zero,|) │ CHECKBITWISEOPERATOR(R1,Zero,|)
CHECKBITWISEOPERATOR(R1,Zero,^) │ CHECKBITWISEOPERATOR(R1,Zero,^)
CHECKBITWISEOPERATOR(R1,Zero,&) │ CHECKBITWISEOPERATOR(R1,Zero,&)
CHECKBITWISEOPERATOR(R1,Max,|) │ CHECKBITWISEOPERATOR(R1,Max,|)
CHECKBITWISEOPERATOR(R1,Max,^) │ CHECKBITWISEOPERATOR(R1,Max,^)
CHECKBITWISEOPERATOR(R1,Max,&) │ CHECKBITWISEOPERATOR(R1,Max,&)
CHECKBITWISEOPERATOR(Zero,R1,|) │ CHECKBITWISEOPERATOR(Zero,R1,|)
CHECKBITWISEOPERATOR(Zero,R1,^) │ CHECKBITWISEOPERATOR(Zero,R1,^)
CHECKBITWISEOPERATOR(Zero,R1,&) │ CHECKBITWISEOPERATOR(Zero,R1,&)
CHECKBITWISEOPERATOR(Max,R1,|) │ CHECKBITWISEOPERATOR(Max,R1,|)
CHECKBITWISEOPERATOR(Max,R1,^) │ CHECKBITWISEOPERATOR(Max,R1,^)
CHECKBITWISEOPERATOR(Max,R1,&) │ CHECKBITWISEOPERATOR(Max,R1,&)
│
arith_uint256 TmpL; │ arith_uint256 TmpL;
CHECKASSIGNMENTOPERATOR(R1,R2,|) │ CHECKASSIGNMENTOPERATOR(R1,R2,|)
CHECKASSIGNMENTOPERATOR(R1,R2,^) │ CHECKASSIGNMENTOPERATOR(R1,R2,^)
CHECKASSIGNMENTOPERATOR(R1,R2,&) │ CHECKASSIGNMENTOPERATOR(R1,R2,&)
CHECKASSIGNMENTOPERATOR(R1,Zero,|) │ CHECKASSIGNMENTOPERATOR(R1,Zero,|)
CHECKASSIGNMENTOPERATOR(R1,Zero,^) │ CHECKASSIGNMENTOPERATOR(R1,Zero,^)
CHECKASSIGNMENTOPERATOR(R1,Zero,&) │ CHECKASSIGNMENTOPERATOR(R1,Zero,&)
CHECKASSIGNMENTOPERATOR(R1,Max,|) │ CHECKASSIGNMENTOPERATOR(R1,Max,|)
CHECKASSIGNMENTOPERATOR(R1,Max,^) │ CHECKASSIGNMENTOPERATOR(R1,Max,^)
CHECKASSIGNMENTOPERATOR(R1,Max,&) │ CHECKASSIGNMENTOPERATOR(R1,Max,&)
CHECKASSIGNMENTOPERATOR(Zero,R1,|) │ CHECKASSIGNMENTOPERATOR(Zero,R1,|)
CHECKASSIGNMENTOPERATOR(Zero,R1,^) │ CHECKASSIGNMENTOPERATOR(Zero,R1,^)
CHECKASSIGNMENTOPERATOR(Zero,R1,&) │ CHECKASSIGNMENTOPERATOR(Zero,R1,&)
CHECKASSIGNMENTOPERATOR(Max,R1,|) │ CHECKASSIGNMENTOPERATOR(Max,R1,|)
CHECKASSIGNMENTOPERATOR(Max,R1,^) │ CHECKASSIGNMENTOPERATOR(Max,R1,^)
CHECKASSIGNMENTOPERATOR(Max,R1,&) │ CHECKASSIGNMENTOPERATOR(Max,R1,&)
│
uint64_t Tmp64 = 0xe1db685c9a0b47a2ULL; │ uint64_t Tmp64 = 0xe1db685c9a0b47a2ULL;
TmpL = R1L; TmpL |= Tmp64; BOOST_CHECK(TmpL == (R1L | arith_uint256(Tmp64))); │ TmpL = R1L; TmpL |= Tmp64; BOOST_CHECK(TmpL == (R1L | arith_uint256(Tmp64)));
TmpL = R1L; TmpL |= 0; BOOST_CHECK(TmpL == R1L); │ TmpL = R1L; TmpL |= 0; BOOST_CHECK(TmpL == R1L);
TmpL ^= 0; BOOST_CHECK(TmpL == R1L); │ TmpL ^= 0; BOOST_CHECK(TmpL == R1L);
TmpL ^= Tmp64; BOOST_CHECK(TmpL == (R1L ^ arith_uint256(Tmp64))); │ TmpL ^= Tmp64; BOOST_CHECK(TmpL == (R1L ^ arith_uint256(Tmp64)));
} │
next prev up dogecoin/src/qt/walletmodel.cpp:504 │ dogecoin/src/qt/walletmodel.cpp:526
│
// Connect signals to wallet │ // Disconnect signals from wallet
wallet->NotifyStatusChanged.connect(boost::bind(&NotifyKeyStoreStatusChanged, this, │ wallet->NotifyStatusChanged.disconnect(boost::bind(&NotifyKeyStoreStatusChanged, thi
boost::placeholders::_1)); │
wallet->NotifyAddressBookChanged.connect(boost::bind(NotifyAddressBookChanged, this, │
boost::placeholders::_1, │
boost::placeholders::_2, │
boost::placeholders::_3, │
boost::placeholders::_4, │
boost::placeholders::_5, │
boost::placeholders::_6)); │
wallet->NotifyTransactionChanged.connect(boost::bind(NotifyTransactionChanged, this, │
boost::placeholders::_1, │
boost::placeholders::_2, │
boost::placeholders::_3)); │
wallet->ShowProgress.connect(boost::bind(ShowProgress, this, boost::placeholders::_1 │
boost::placeholders::_2)); │
wallet->NotifyWatchonlyChanged.connect(boost::bind(NotifyWatchonlyChanged, this, │
boost::placeholders::_1)); │ boost::placeholders::_1));
│ wallet->NotifyAddressBookChanged.disconnect(boost::bind(NotifyAddressBookChanged, th
│ boost::placeholders::_1,
│ boost::placeholders::_2,
│ boost::placeholders::_3,
│ boost::placeholders::_4,
│ boost::placeholders::_5,
│ boost::placeholders::_6));
│ wallet->NotifyTransactionChanged.disconnect(boost::bind(NotifyTransactionChanged, th
│ boost::placeholders::_1,
│ boost::placeholders::_2,
│ boost::placeholders::_3));
│ wallet->ShowProgress.disconnect(boost::bind(ShowProgress, this,
│ boost::placeholders::_1,
│ boost::placeholders::_2));
│ wallet->NotifyWatchonlyChanged.disconnect(boost::bind(NotifyWatchonlyChanged, this,
│ boost::placeholders::_1));
} │
next prev up dogecoin/src/test/crypto_tests.cpp:236 │ bitcoin/src/test/crypto_tests.cpp:239
│
TestSHA256("", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"); │ TestSHA256("", "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855");
TestSHA256("abc", "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" │ TestSHA256("abc", "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"
TestSHA256("message digest", │ TestSHA256("message digest",
"f7846f55cf23e14eebeab5b4e1550cad5b509e3348fbc4efa3a1413d393cb650"); │ "f7846f55cf23e14eebeab5b4e1550cad5b509e3348fbc4efa3a1413d393cb650");
TestSHA256("secure hash algorithm", │ TestSHA256("secure hash algorithm",
"f30ceb2bb2829e79e4ca9753d35a8ecc00262d164cc077080295381cbd643f0d"); │ "f30ceb2bb2829e79e4ca9753d35a8ecc00262d164cc077080295381cbd643f0d");
TestSHA256("SHA256 is considered to be safe", │ TestSHA256("SHA256 is considered to be safe",
"6819d915c73f4d1e77e4e1b52d1fa0f9cf9beaead3939f15874bd988e2a23630"); │ "6819d915c73f4d1e77e4e1b52d1fa0f9cf9beaead3939f15874bd988e2a23630");
TestSHA256("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", │ TestSHA256("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"); │ "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1");
TestSHA256("For this sample, this 63-byte string will be used as input data", │ TestSHA256("For this sample, this 63-byte string will be used as input data",
"f08a78cbbaee082b052ae0708f32fa1e50c5c421aa772ba5dbb406a2ea6be342"); │ "f08a78cbbaee082b052ae0708f32fa1e50c5c421aa772ba5dbb406a2ea6be342");
TestSHA256("This is exactly 64 bytes long, not counting the terminating byte", │ TestSHA256("This is exactly 64 bytes long, not counting the terminating byte",
"ab64eff7e88e2e46165e29f2bce41826bd4c7b3552f6b382a9e7d3af47c245f8"); │ "ab64eff7e88e2e46165e29f2bce41826bd4c7b3552f6b382a9e7d3af47c245f8");
TestSHA256("As Bitcoin relies on 80 byte header hashes, we want to have an example f │ TestSHA256("As Bitcoin relies on 80 byte header hashes, we want to have an example f
"7406e8de7d6e4fffc573daef05aefb8806e7790f55eab5576f31349743cca743"); │ "7406e8de7d6e4fffc573daef05aefb8806e7790f55eab5576f31349743cca743");
TestSHA256(std::string(1000000, 'a'), │ TestSHA256(std::string(1000000, 'a'),
"cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0"); │ "cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0");
TestSHA256(test1, "a316d55510b49662420f49d145d42fb83f31ef8dc016aa4e32df049991a91e26" │ TestSHA256(test1, "a316d55510b49662420f49d145d42fb83f31ef8dc016aa4e32df049991a91e26"
} │
next prev up bitcoin/src/test/serialize_tests.cpp:63 │ dogecoin/src/test/serialize_tests.cpp:61
│
BOOST_CHECK_EQUAL(sizeof(unsigned char), GetSerializeSize((unsigned char)0, 0)); │ BOOST_CHECK_EQUAL(sizeof(char), GetSerializeSize(char(0), 0));
BOOST_CHECK_EQUAL(sizeof(int8_t), GetSerializeSize(int8_t(0), 0)); │ BOOST_CHECK_EQUAL(sizeof(int8_t), GetSerializeSize(int8_t(0), 0));
BOOST_CHECK_EQUAL(sizeof(uint8_t), GetSerializeSize(uint8_t(0), 0)); │ BOOST_CHECK_EQUAL(sizeof(uint8_t), GetSerializeSize(uint8_t(0), 0));
BOOST_CHECK_EQUAL(sizeof(int16_t), GetSerializeSize(int16_t(0), 0)); │ BOOST_CHECK_EQUAL(sizeof(int16_t), GetSerializeSize(int16_t(0), 0));
BOOST_CHECK_EQUAL(sizeof(uint16_t), GetSerializeSize(uint16_t(0), 0)); │ BOOST_CHECK_EQUAL(sizeof(uint16_t), GetSerializeSize(uint16_t(0), 0));
BOOST_CHECK_EQUAL(sizeof(int32_t), GetSerializeSize(int32_t(0), 0)); │ BOOST_CHECK_EQUAL(sizeof(int32_t), GetSerializeSize(int32_t(0), 0));
BOOST_CHECK_EQUAL(sizeof(uint32_t), GetSerializeSize(uint32_t(0), 0)); │ BOOST_CHECK_EQUAL(sizeof(uint32_t), GetSerializeSize(uint32_t(0), 0));
BOOST_CHECK_EQUAL(sizeof(int64_t), GetSerializeSize(int64_t(0), 0)); │ BOOST_CHECK_EQUAL(sizeof(int64_t), GetSerializeSize(int64_t(0), 0));
BOOST_CHECK_EQUAL(sizeof(uint64_t), GetSerializeSize(uint64_t(0), 0)); │ BOOST_CHECK_EQUAL(sizeof(uint64_t), GetSerializeSize(uint64_t(0), 0));
// Bool is serialized as uint8_t │ BOOST_CHECK_EQUAL(sizeof(float), GetSerializeSize(float(0), 0));
BOOST_CHECK_EQUAL(sizeof(uint8_t), GetSerializeSize(bool(0), 0)); │ BOOST_CHECK_EQUAL(sizeof(double), GetSerializeSize(double(0), 0));
│ // Bool is serialized as char
│ BOOST_CHECK_EQUAL(sizeof(char), GetSerializeSize(bool(0), 0));
│
// Sanity-check GetSerializeSize and c++ type matching │ // Sanity-check GetSerializeSize and c++ type matching
BOOST_CHECK_EQUAL(GetSerializeSize((unsigned char)0, 0), 1U); │ BOOST_CHECK_EQUAL(GetSerializeSize(char(0), 0), 1);
BOOST_CHECK_EQUAL(GetSerializeSize(int8_t(0), 0), 1U); │ BOOST_CHECK_EQUAL(GetSerializeSize(int8_t(0), 0), 1);
BOOST_CHECK_EQUAL(GetSerializeSize(uint8_t(0), 0), 1U); │ BOOST_CHECK_EQUAL(GetSerializeSize(uint8_t(0), 0), 1);
BOOST_CHECK_EQUAL(GetSerializeSize(int16_t(0), 0), 2U); │ BOOST_CHECK_EQUAL(GetSerializeSize(int16_t(0), 0), 2);
BOOST_CHECK_EQUAL(GetSerializeSize(uint16_t(0), 0), 2U); │ BOOST_CHECK_EQUAL(GetSerializeSize(uint16_t(0), 0), 2);
BOOST_CHECK_EQUAL(GetSerializeSize(int32_t(0), 0), 4U); │ BOOST_CHECK_EQUAL(GetSerializeSize(int32_t(0), 0), 4);
BOOST_CHECK_EQUAL(GetSerializeSize(uint32_t(0), 0), 4U); │ BOOST_CHECK_EQUAL(GetSerializeSize(uint32_t(0), 0), 4);
BOOST_CHECK_EQUAL(GetSerializeSize(int64_t(0), 0), 8U); │ BOOST_CHECK_EQUAL(GetSerializeSize(int64_t(0), 0), 8);
BOOST_CHECK_EQUAL(GetSerializeSize(uint64_t(0), 0), 8U); │ BOOST_CHECK_EQUAL(GetSerializeSize(uint64_t(0), 0), 8);
BOOST_CHECK_EQUAL(GetSerializeSize(bool(0), 0), 1U); │ BOOST_CHECK_EQUAL(GetSerializeSize(float(0), 0), 4);
│ BOOST_CHECK_EQUAL(GetSerializeSize(double(0), 0), 8);
│ BOOST_CHECK_EQUAL(GetSerializeSize(bool(0), 0), 1);
} │
next prev up bitcoin/src/qt/guiutil.cpp:143 │ dogecoin/src/qt/guiutil.cpp:153
│
// return if URI is not valid or is no bitcoin: URI │ // return if URI is not valid or is no dogecoin: URI
if(!uri.isValid() || uri.scheme() != QString("bitcoin")) │ if(!uri.isValid() || uri.scheme() != QString("dogecoin"))
return false; │ return false;
│
SendCoinsRecipient rv; │ SendCoinsRecipient rv;
rv.address = uri.path(); │ rv.address = uri.path();
// Trim any following forward slash which may have been added by the OS │ // Trim any following forward slash which may have been added by the OS
if (rv.address.endsWith("/")) { │ if (rv.address.endsWith("/")) {
rv.address.truncate(rv.address.length() - 1); │ rv.address.truncate(rv.address.length() - 1);
} │ }
rv.amount = 0; │ rv.amount = 0;
│
│ #if QT_VERSION < 0x050000
│ QList<QPair<QString, QString> > items = uri.queryItems();
│ #else
QUrlQuery uriQuery(uri); │ QUrlQuery uriQuery(uri);
QList<QPair<QString, QString> > items = uriQuery.queryItems(); │ QList<QPair<QString, QString> > items = uriQuery.queryItems();
│ #endif
for (QList<QPair<QString, QString> >::iterator i = items.begin(); i != items.end(); │ for (QList<QPair<QString, QString> >::iterator i = items.begin(); i != items.end();
{ │ {
bool fShouldReturnFalse = false; │ bool fShouldReturnFalse = false;
if (i->first.startsWith("req-")) │ if (i->first.startsWith("req-"))
{ │ {
i->first.remove(0, 4); │ i->first.remove(0, 4);
fShouldReturnFalse = true; │ fShouldReturnFalse = true;
} │ }
│
if (i->first == "label") │ if (i->first == "label")
{ │ {
rv.label = i->second; │ rv.label = i->second;
fShouldReturnFalse = false; │ fShouldReturnFalse = false;
} │ }
if (i->first == "message") │ if (i->first == "message")
{ │ {
rv.message = i->second; │ rv.message = i->second;
fShouldReturnFalse = false; │ fShouldReturnFalse = false;
} │ }
else if (i->first == "amount") │ else if (i->first == "amount")
{ │ {
if(!i->second.isEmpty()) │ if(!i->second.isEmpty())
{ │ {
if (!BitcoinUnits::parse(BitcoinUnit::BTC, i->second, &rv.amount)) { │ if(!BitcoinUnits::parse(BitcoinUnits::BTC, i->second, &rv.amount))
│ {
return false; │ return false;
} │ }
} │ }
fShouldReturnFalse = false; │ fShouldReturnFalse = false;
} │ }
│
if (fShouldReturnFalse) │ if (fShouldReturnFalse)
return false; │ return false;
} │ }
if(out) │ if(out)
{ │ {
*out = rv; │ *out = rv;
} │ }
return true; │ return true;
} │
next prev up bitcoin/src/merkleblock.cpp:95 │ dogecoin/src/merkleblock.cpp:96
│
if (nBitsUsed >= vBits.size()) { │ if (nBitsUsed >= vBits.size()) {
// overflowed the bits array - failure │ // overflowed the bits array - failure
fBad = true; │ fBad = true;
return uint256(); │ return uint256();
} │ }
bool fParentOfMatch = vBits[nBitsUsed++]; │ bool fParentOfMatch = vBits[nBitsUsed++];
if (height==0 || !fParentOfMatch) { │ if (height==0 || !fParentOfMatch) {
// if at height 0, or nothing interesting below, use stored hash and do not desc │ // if at height 0, or nothing interesting below, use stored hash and do not desc
if (nHashUsed >= vHash.size()) { │ if (nHashUsed >= vHash.size()) {
// overflowed the hash array - failure │ // overflowed the hash array - failure
fBad = true; │ fBad = true;
return uint256(); │ return uint256();
} │ }
const uint256 &hash = vHash[nHashUsed++]; │ const uint256 &hash = vHash[nHashUsed++];
if (height==0 && fParentOfMatch) { // in case of height 0, we have a matched txi │ if (height==0 && fParentOfMatch) { // in case of height 0, we have a matched txi
vMatch.push_back(hash); │ vMatch.push_back(hash);
vnIndex.push_back(pos); │ vnIndex.push_back(pos);
} │ }
return hash; │ return hash;
} else { │ } else {
// otherwise, descend into the subtrees to extract matched txids and hashes │ // otherwise, descend into the subtrees to extract matched txids and hashes
uint256 left = TraverseAndExtract(height-1, pos*2, nBitsUsed, nHashUsed, vMatch, │ uint256 left = TraverseAndExtract(height-1, pos*2, nBitsUsed, nHashUsed, vMatch,
if (pos*2+1 < CalcTreeWidth(height-1)) { │ if (pos*2+1 < CalcTreeWidth(height-1)) {
right = TraverseAndExtract(height-1, pos*2+1, nBitsUsed, nHashUsed, vMatch, │ right = TraverseAndExtract(height-1, pos*2+1, nBitsUsed, nHashUsed, vMatch,
if (right == left) { │ if (right == left) {
// The left and right branches should never be identical, as the transac │ // The left and right branches should never be identical, as the transac
// hashes covered by them must each be unique. │ // hashes covered by them must each be unique.
fBad = true; │ fBad = true;
} │ }
} else { │ } else {
right = left; │ right = left;
} │ }
// and combine them before returning │ // and combine them before returning
return Hash(left, right); │ return Hash(BEGIN(left), END(left), BEGIN(right), END(right));
} │ }
} │
next prev up dogecoin/src/qt/clientmodel.cpp:333 │ dogecoin/src/qt/clientmodel.cpp:355
│
// Connect signals to client │ // Disconnect signals from client
uiInterface.ShowProgress.connect(boost::bind(ShowProgress, this, │ uiInterface.ShowProgress.disconnect(boost::bind(ShowProgress, this,
boost::placeholders::_1, │
boost::placeholders::_2)); │
uiInterface.NotifyNumConnectionsChanged.connect(boost::bind(NotifyNumConnectionsChan │
boost::placeholders::_1) │
uiInterface.NotifyNetworkActiveChanged.connect(boost::bind(NotifyNetworkActiveChange │
boost::placeholders::_1)) │
uiInterface.NotifyAlertChanged.connect(boost::bind(NotifyAlertChanged, this, │
boost::placeholders::_1, │
boost::placeholders::_2)); │
uiInterface.BannedListChanged.connect(boost::bind(BannedListChanged, this)); │
uiInterface.NotifyBlockTip.connect(boost::bind(BlockTipChanged, this, │
boost::placeholders::_1, │
boost::placeholders::_2, false)); │
uiInterface.NotifyHeaderTip.connect(boost::bind(BlockTipChanged, this, │
boost::placeholders::_1, │ boost::placeholders::_1,
boost::placeholders::_2, true)); │ boost::placeholders::_2));
│ uiInterface.NotifyNumConnectionsChanged.disconnect(boost::bind(NotifyNumConnectionsC
│ boost::placeholders::
│ uiInterface.NotifyNetworkActiveChanged.disconnect(boost::bind(NotifyNetworkActiveCha
│ boost::placeholders::_
│ uiInterface.NotifyAlertChanged.disconnect(boost::bind(NotifyAlertChanged, this,
│ boost::placeholders::_1,
│ boost::placeholders::_2));
│ uiInterface.BannedListChanged.disconnect(boost::bind(BannedListChanged, this));
│ uiInterface.NotifyBlockTip.disconnect(boost::bind(BlockTipChanged, this,
│ boost::placeholders::_1,
│ boost::placeholders::_2, false));
│ uiInterface.NotifyHeaderTip.disconnect(boost::bind(BlockTipChanged, this,
│ boost::placeholders::_1,
│ boost::placeholders::_2, true));
} │
next prev up bitcoin/src/txmempool.cpp:1132 │ dogecoin/src/txmempool.cpp:1108
│
indexed_transaction_set::index<descendant_score>::type::iterator it = mapTx.get< │ indexed_transaction_set::index<descendant_score>::type::iterator it = mapTx.get<
│
// We set the new mempool min fee to the feerate of the removed set, plus the │ // We set the new mempool min fee to the feerate of the removed set, plus the
// "minimum reasonable fee rate" (ie some value under which we consider txn │ // "minimum reasonable fee rate" (ie some value under which we consider txn
// to have 0 fee). This way, we don't allow txn to enter mempool with feerate │ // to have 0 fee). This way, we don't allow txn to enter mempool with feerate
// equal to txn which were removed with no block in between. │ // equal to txn which were removed with no block in between.
CFeeRate removed(it->GetModFeesWithDescendants(), it->GetSizeWithDescendants()); │ CFeeRate removed(it->GetModFeesWithDescendants(), it->GetSizeWithDescendants());
removed += incrementalRelayFee; │ removed += incrementalRelayFee;
trackPackageRemoved(removed); │ trackPackageRemoved(removed);
maxFeeRateRemoved = std::max(maxFeeRateRemoved, removed); │ maxFeeRateRemoved = std::max(maxFeeRateRemoved, removed);
│
setEntries stage; │ setEntries stage;
CalculateDescendants(mapTx.project<0>(it), stage); │ CalculateDescendants(mapTx.project<0>(it), stage);
nTxnRemoved += stage.size(); │ nTxnRemoved += stage.size();
│
std::vector<CTransaction> txn; │ std::vector<CTransaction> txn;
if (pvNoSpendsRemaining) { │ if (pvNoSpendsRemaining) {
txn.reserve(stage.size()); │ txn.reserve(stage.size());
for (txiter iter : stage) │ BOOST_FOREACH(txiter iter, stage)
txn.push_back(iter->GetTx()); │ txn.push_back(iter->GetTx());
} │ }
RemoveStaged(stage, false, MemPoolRemovalReason::SIZELIMIT); │ RemoveStaged(stage, false, MemPoolRemovalReason::SIZELIMIT);
if (pvNoSpendsRemaining) { │ if (pvNoSpendsRemaining) {
for (const CTransaction& tx : txn) { │ BOOST_FOREACH(const CTransaction& tx, txn) {
for (const CTxIn& txin : tx.vin) { │ BOOST_FOREACH(const CTxIn& txin, tx.vin) {
if (exists(GenTxid::Txid(txin.prevout.hash))) continue; │ if (exists(txin.prevout.hash))
pvNoSpendsRemaining->push_back(txin.prevout); │ continue;
│ auto iter = mapNextTx.lower_bound(COutPoint(txin.prevout.hash, 0));
│ if (iter == mapNextTx.end() || iter->first->hash != txin.prevout.has
│ pvNoSpendsRemaining->push_back(txin.prevout.hash);
} │ }
} │ }
} │ }
} │
next prev up dogecoin/src/test/script_tests.cpp:185 │ bitcoin/src/test/script_tests.cpp:168
│
// Parse the signature. │ // Parse the signature.
std::vector<unsigned char> r, s; │ std::vector<unsigned char> r, s;
r = std::vector<unsigned char>(vchSig.begin() + 4, vchSig.begin() + 4 + vchSig[3]); │ r = std::vector<unsigned char>(vchSig.begin() + 4, vchSig.begin() + 4 + vchSig[3]);
s = std::vector<unsigned char>(vchSig.begin() + 6 + vchSig[3], vchSig.begin() + 6 + │ s = std::vector<unsigned char>(vchSig.begin() + 6 + vchSig[3], vchSig.begin() + 6 +
│
// Really ugly to implement mod-n negation here, but it would be feature creep to ex │ // Really ugly to implement mod-n negation here, but it would be feature creep to ex
static const unsigned char order[33] = { │ static const unsigned char order[33] = {
0x00, │ 0x00,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, │ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, │ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE,
0xBA, 0xAE, 0xDC, 0xE6, 0xAF, 0x48, 0xA0, 0x3B, │ 0xBA, 0xAE, 0xDC, 0xE6, 0xAF, 0x48, 0xA0, 0x3B,
0xBF, 0xD2, 0x5E, 0x8C, 0xD0, 0x36, 0x41, 0x41 │ 0xBF, 0xD2, 0x5E, 0x8C, 0xD0, 0x36, 0x41, 0x41
}; │ };
while (s.size() < 33) { │ while (s.size() < 33) {
s.insert(s.begin(), 0x00); │ s.insert(s.begin(), 0x00);
} │ }
int carry = 0; │ int carry = 0;
for (int p = 32; p >= 1; p--) { │ for (int p = 32; p >= 1; p--) {
int n = (int)order[p] - s[p] - carry; │ int n = (int)order[p] - s[p] - carry;
s[p] = (n + 256) & 0xFF; │ s[p] = (n + 256) & 0xFF;
carry = (n < 0); │ carry = (n < 0);
} │ }
assert(carry == 0); │ assert(carry == 0);
if (s.size() > 1 && s[0] == 0 && s[1] < 0x80) { │ if (s.size() > 1 && s[0] == 0 && s[1] < 0x80) {
s.erase(s.begin()); │ s.erase(s.begin());
} │ }
│
// Reconstruct the signature. │ // Reconstruct the signature.
vchSig.clear(); │ vchSig.clear();
vchSig.push_back(0x30); │ vchSig.push_back(0x30);
vchSig.push_back(4 + r.size() + s.size()); │ vchSig.push_back(4 + r.size() + s.size());
vchSig.push_back(0x02); │ vchSig.push_back(0x02);
vchSig.push_back(r.size()); │ vchSig.push_back(r.size());
vchSig.insert(vchSig.end(), r.begin(), r.end()); │ vchSig.insert(vchSig.end(), r.begin(), r.end());
vchSig.push_back(0x02); │ vchSig.push_back(0x02);
vchSig.push_back(s.size()); │ vchSig.push_back(s.size());
vchSig.insert(vchSig.end(), s.begin(), s.end()); │ vchSig.insert(vchSig.end(), s.begin(), s.end());
} │
next prev up dogecoin/src/test/bloom_tests.cpp:58 │ dogecoin/src/test/bloom_tests.cpp:27
│
// Same test as bloom_create_insert_serialize, but we add a nTweak of 100 │ CBloomFilter filter(3, 0.01, 0, BLOOM_UPDATE_ALL);
CBloomFilter filter(3, 0.01, 2147483649UL, BLOOM_UPDATE_ALL); │
│
filter.insert(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")); │ filter.insert(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8"));
BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f095 │ BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f095
// One bit different in first byte │ // One bit different in first byte
BOOST_CHECK_MESSAGE(!filter.contains(ParseHex("19108ad8ed9bb6274d3980bab5a85c048f095 │ BOOST_CHECK_MESSAGE(!filter.contains(ParseHex("19108ad8ed9bb6274d3980bab5a85c048f095
│
filter.insert(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32eee")); │ filter.insert(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32eee"));
BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32e │ BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32e
│
filter.insert(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729c5")); │ filter.insert(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729c5"));
BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729 │ BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729
│
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); │ CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
stream << filter; │ stream << filter;
│
std::vector<unsigned char> vch = ParseHex("03ce4299050000000100008001"); │ std::vector<unsigned char> vch = ParseHex("03614e9b050000000000000001");
std::vector<char> expected(vch.size()); │ std::vector<char> expected(vch.size());
│
for (unsigned int i = 0; i < vch.size(); i++) │ for (unsigned int i = 0; i < vch.size(); i++)
expected[i] = (char)vch[i]; │ expected[i] = (char)vch[i];
│
BOOST_CHECK_EQUAL_COLLECTIONS(stream.begin(), stream.end(), expected.begin(), expect │ BOOST_CHECK_EQUAL_COLLECTIONS(stream.begin(), stream.end(), expected.begin(), expect
│
│ BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f095
│ filter.clear();
│ BOOST_CHECK_MESSAGE( !filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f09
} │
next prev up dogecoin/src/test/serialize_tests.cpp:258 │ bitcoin/src/test/serialize_tests.cpp:182
│
// Write some non-canonical CompactSize encodings, and │ // Write some non-canonical CompactSize encodings, and
// make sure an exception is thrown when read back. │ // make sure an exception is thrown when read back.
CDataStream ss(SER_DISK, 0); │ CDataStream ss(SER_DISK, 0);
std::vector<char>::size_type n; │ std::vector<char>::size_type n;
│
// zero encoded with three bytes: │ // zero encoded with three bytes:
ss.write("\xfd\x00\x00", 3); │ ss.write(MakeByteSpan("\xfd\x00\x00").first(3));
BOOST_CHECK_EXCEPTION(ReadCompactSize(ss), std::ios_base::failure, isCanonicalExcept │ BOOST_CHECK_EXCEPTION(ReadCompactSize(ss), std::ios_base::failure, isCanonicalExcept
│
// 0xfc encoded with three bytes: │ // 0xfc encoded with three bytes:
ss.write("\xfd\xfc\x00", 3); │ ss.write(MakeByteSpan("\xfd\xfc\x00").first(3));
BOOST_CHECK_EXCEPTION(ReadCompactSize(ss), std::ios_base::failure, isCanonicalExcept │ BOOST_CHECK_EXCEPTION(ReadCompactSize(ss), std::ios_base::failure, isCanonicalExcept
│
// 0xfd encoded with three bytes is OK: │ // 0xfd encoded with three bytes is OK:
ss.write("\xfd\xfd\x00", 3); │ ss.write(MakeByteSpan("\xfd\xfd\x00").first(3));
n = ReadCompactSize(ss); │ n = ReadCompactSize(ss);
BOOST_CHECK(n == 0xfd); │ BOOST_CHECK(n == 0xfd);
│
// zero encoded with five bytes: │ // zero encoded with five bytes:
ss.write("\xfe\x00\x00\x00\x00", 5); │ ss.write(MakeByteSpan("\xfe\x00\x00\x00\x00").first(5));
BOOST_CHECK_EXCEPTION(ReadCompactSize(ss), std::ios_base::failure, isCanonicalExcept │ BOOST_CHECK_EXCEPTION(ReadCompactSize(ss), std::ios_base::failure, isCanonicalExcept
│
// 0xffff encoded with five bytes: │ // 0xffff encoded with five bytes:
ss.write("\xfe\xff\xff\x00\x00", 5); │ ss.write(MakeByteSpan("\xfe\xff\xff\x00\x00").first(5));
BOOST_CHECK_EXCEPTION(ReadCompactSize(ss), std::ios_base::failure, isCanonicalExcept │ BOOST_CHECK_EXCEPTION(ReadCompactSize(ss), std::ios_base::failure, isCanonicalExcept
│
// zero encoded with nine bytes: │ // zero encoded with nine bytes:
ss.write("\xff\x00\x00\x00\x00\x00\x00\x00\x00", 9); │ ss.write(MakeByteSpan("\xff\x00\x00\x00\x00\x00\x00\x00\x00").first(9));
BOOST_CHECK_EXCEPTION(ReadCompactSize(ss), std::ios_base::failure, isCanonicalExcept │ BOOST_CHECK_EXCEPTION(ReadCompactSize(ss), std::ios_base::failure, isCanonicalExcept
│
// 0x01ffffff encoded with nine bytes: │ // 0x01ffffff encoded with nine bytes:
ss.write("\xff\xff\xff\xff\x01\x00\x00\x00\x00", 9); │ ss.write(MakeByteSpan("\xff\xff\xff\xff\x01\x00\x00\x00\x00").first(9));
BOOST_CHECK_EXCEPTION(ReadCompactSize(ss), std::ios_base::failure, isCanonicalExcept │ BOOST_CHECK_EXCEPTION(ReadCompactSize(ss), std::ios_base::failure, isCanonicalExcept
} │
next prev up bitcoin/src/test/util_tests.cpp:1928 │ dogecoin/src/test/util_tests.cpp:406
│
uint64_t n; │ uint64_t n;
// Valid values │ // Valid values
BOOST_CHECK(ParseUInt64("1234", nullptr)); │ BOOST_CHECK(ParseUInt64("1234", NULL));
BOOST_CHECK(ParseUInt64("0", &n) && n == 0LL); │ BOOST_CHECK(ParseUInt64("0", &n) && n == 0LL);
BOOST_CHECK(ParseUInt64("1234", &n) && n == 1234LL); │ BOOST_CHECK(ParseUInt64("1234", &n) && n == 1234LL);
BOOST_CHECK(ParseUInt64("01234", &n) && n == 1234LL); // no octal │ BOOST_CHECK(ParseUInt64("01234", &n) && n == 1234LL); // no octal
BOOST_CHECK(ParseUInt64("2147483647", &n) && n == 2147483647LL); │ BOOST_CHECK(ParseUInt64("2147483647", &n) && n == 2147483647LL);
BOOST_CHECK(ParseUInt64("9223372036854775807", &n) && n == 9223372036854775807ULL); │ BOOST_CHECK(ParseUInt64("9223372036854775807", &n) && n == 9223372036854775807ULL);
BOOST_CHECK(ParseUInt64("9223372036854775808", &n) && n == 9223372036854775808ULL); │ BOOST_CHECK(ParseUInt64("9223372036854775808", &n) && n == 9223372036854775808ULL);
BOOST_CHECK(ParseUInt64("18446744073709551615", &n) && n == 18446744073709551615ULL) │ BOOST_CHECK(ParseUInt64("18446744073709551615", &n) && n == 18446744073709551615ULL)
// Invalid values │ // Invalid values
BOOST_CHECK(!ParseUInt64("", &n)); │ BOOST_CHECK(!ParseUInt64("", &n));
BOOST_CHECK(!ParseUInt64(" 1", &n)); // no padding inside │ BOOST_CHECK(!ParseUInt64(" 1", &n)); // no padding inside
BOOST_CHECK(!ParseUInt64(" -1", &n)); │ BOOST_CHECK(!ParseUInt64(" -1", &n));
BOOST_CHECK(!ParseUInt64("1 ", &n)); │ BOOST_CHECK(!ParseUInt64("1 ", &n));
BOOST_CHECK(!ParseUInt64("1a", &n)); │ BOOST_CHECK(!ParseUInt64("1a", &n));
BOOST_CHECK(!ParseUInt64("aap", &n)); │ BOOST_CHECK(!ParseUInt64("aap", &n));
BOOST_CHECK(!ParseUInt64("0x1", &n)); // no hex │ BOOST_CHECK(!ParseUInt64("0x1", &n)); // no hex
BOOST_CHECK(!ParseUInt64(STRING_WITH_EMBEDDED_NULL_CHAR, &n)); │ const char test_bytes[] = {'1', 0, '1'};
│ std::string teststr(test_bytes, sizeof(test_bytes));
│ BOOST_CHECK(!ParseUInt64(teststr, &n)); // no embedded NULs
// Overflow and underflow │ // Overflow and underflow
BOOST_CHECK(!ParseUInt64("-9223372036854775809", nullptr)); │ BOOST_CHECK(!ParseUInt64("-9223372036854775809", NULL));
BOOST_CHECK(!ParseUInt64("18446744073709551616", nullptr)); │ BOOST_CHECK(!ParseUInt64("18446744073709551616", NULL));
BOOST_CHECK(!ParseUInt64("-32482348723847471234", nullptr)); │ BOOST_CHECK(!ParseUInt64("-32482348723847471234", NULL));
BOOST_CHECK(!ParseUInt64("-2147483648", &n)); │ BOOST_CHECK(!ParseUInt64("-2147483648", &n));
BOOST_CHECK(!ParseUInt64("-9223372036854775808", &n)); │ BOOST_CHECK(!ParseUInt64("-9223372036854775808", &n));
BOOST_CHECK(!ParseUInt64("-1234", &n)); │ BOOST_CHECK(!ParseUInt64("-1234", &n));
} │
next prev up bitcoin/src/qt/networkstyle.cpp:30 │ dogecoin/src/qt/networkstyle.cpp:28
│
// load pixmap │ // load pixmap
QPixmap pixmap(":/icons/bitcoin"); │ QPixmap pixmap(":/icons/bitcoin");
│
if(iconColorHueShift != 0 && iconColorSaturationReduction != 0) │ if(iconColorHueShift != 0 && iconColorSaturationReduction != 0)
{ │ {
// generate QImage from QPixmap │ // generate QImage from QPixmap
QImage img = pixmap.toImage(); │ QImage img = pixmap.toImage();
│
int h,s,l,a; │ int h,s,l,a;
│
// traverse though lines │ // traverse though lines
for(int y=0;y<img.height();y++) │ for(int y=0;y<img.height();y++)
{ │ {
QRgb *scL = reinterpret_cast< QRgb *>( img.scanLine( y ) ); │ QRgb *scL = reinterpret_cast< QRgb *>( img.scanLine( y ) );
│
// loop through pixels │ // loop through pixels
for(int x=0;x<img.width();x++) │ for(int x=0;x<img.width();x++)
{ │ {
// preserve alpha because QColor::getHsl doesn't return the alpha value │ // preserve alpha because QColor::getHsl doesen't return the alpha value
a = qAlpha(scL[x]); │ a = qAlpha(scL[x]);
QColor col(scL[x]); │ QColor col(scL[x]);
│
// get hue value │ // get hue value
col.getHsl(&h,&s,&l); │ col.getHsl(&h,&s,&l);
│
// rotate color on RGB color circle │ // rotate color on RGB color circle
// 70° should end up with the typical "testnet" green │ // 70° should end up with the typical "testnet" green
h+=iconColorHueShift; │ h+=iconColorHueShift;
│
// change saturation value │ // change saturation value
if(s>iconColorSaturationReduction) │ if(s>iconColorSaturationReduction)
{ │ {
s -= iconColorSaturationReduction; │ s -= iconColorSaturationReduction;
} │ }
col.setHsl(h,s,l,a); │ col.setHsl(h,s,l,a);
│
// set the pixel │ // set the pixel
scL[x] = col.rgba(); │ scL[x] = col.rgba();
} │ }
} │ }
│
//convert back to QPixmap │ //convert back to QPixmap
│ #if QT_VERSION >= 0x040700
pixmap.convertFromImage(img); │ pixmap.convertFromImage(img);
│ #else
│ pixmap = QPixmap::fromImage(img);
│ #endif
} │ }
│
appIcon = QIcon(pixmap); │ appIcon = QIcon(pixmap);
trayAndWindowIcon = QIcon(pixmap.scaled(QSize(256,256))); │ trayAndWindowIcon = QIcon(pixmap.scaled(QSize(256,256)));
} │
next prev up bitcoin/src/qt/editaddressdialog.cpp:97 │ dogecoin/src/qt/editaddressdialog.cpp:94
│
if(!model) │ if(!model)
return; │ return;
│
if(!saveCurrentRow()) │ if(!saveCurrentRow())
{ │ {
switch(model->getEditStatus()) │ switch(model->getEditStatus())
{ │ {
case AddressTableModel::OK: │ case AddressTableModel::OK:
// Failed with unknown reason. Just reject. │ // Failed with unknown reason. Just reject.
break; │ break;
case AddressTableModel::NO_CHANGES: │ case AddressTableModel::NO_CHANGES:
// No changes were made during edit operation. Just reject. │ // No changes were made during edit operation. Just reject.
break; │ break;
case AddressTableModel::INVALID_ADDRESS: │ case AddressTableModel::INVALID_ADDRESS:
QMessageBox::warning(this, windowTitle(), │ QMessageBox::warning(this, windowTitle(),
tr("The entered address \"%1\" is not a valid Bitcoin address.").arg(ui- │ tr("The entered address \"%1\" is not a valid Dogecoin address.").arg(ui
QMessageBox::Ok, QMessageBox::Ok); │ QMessageBox::Ok, QMessageBox::Ok);
break; │ break;
case AddressTableModel::DUPLICATE_ADDRESS: │ case AddressTableModel::DUPLICATE_ADDRESS:
QMessageBox::warning(this, windowTitle(), │ QMessageBox::warning(this, windowTitle(),
getDuplicateAddressWarning(), │ tr("The entered address \"%1\" is already in the address book.").arg(ui-
QMessageBox::Ok, QMessageBox::Ok); │ QMessageBox::Ok, QMessageBox::Ok);
break; │ break;
case AddressTableModel::WALLET_UNLOCK_FAILURE: │ case AddressTableModel::WALLET_UNLOCK_FAILURE:
QMessageBox::critical(this, windowTitle(), │ QMessageBox::critical(this, windowTitle(),
tr("Could not unlock wallet."), │ tr("Could not unlock wallet."),
QMessageBox::Ok, QMessageBox::Ok); │ QMessageBox::Ok, QMessageBox::Ok);
break; │ break;
case AddressTableModel::KEY_GENERATION_FAILURE: │ case AddressTableModel::KEY_GENERATION_FAILURE:
QMessageBox::critical(this, windowTitle(), │ QMessageBox::critical(this, windowTitle(),
tr("New key generation failed."), │ tr("New key generation failed."),
QMessageBox::Ok, QMessageBox::Ok); │ QMessageBox::Ok, QMessageBox::Ok);
break; │ break;
│
} │ }
return; │ return;
} │ }
QDialog::accept(); │ QDialog::accept();
} │
next prev up bitcoin/src/validation.cpp:4358 │ dogecoin/src/validation.cpp:4096
│
uint256 head = queue.front(); │ uint256 head = queue.front();
queue.pop_front(); │ queue.pop_front();
std::pair<std::multimap<uint256, FlatFilePos>::iterator, std::multim │ std::pair<std::multimap<uint256, CDiskBlockPos>::iterator, std::mult
while (range.first != range.second) { │ while (range.first != range.second) {
std::multimap<uint256, FlatFilePos>::iterator it = range.first; │ std::multimap<uint256, CDiskBlockPos>::iterator it = range.first
std::shared_ptr<CBlock> pblockrecursive = std::make_shared<CBloc │ std::shared_ptr<CBlock> pblockrecursive = std::make_shared<CBloc
if (ReadBlockFromDisk(*pblockrecursive, it->second, m_params.Get │ // TODO: Need a valid consensus height
LogPrint(BCLog::REINDEX, "%s: Processing out of order child │ if (ReadBlockFromDisk(*pblockrecursive, it->second, chainparams.
│ {
│ LogPrint("reindex", "%s: Processing out of order child %s of
head.ToString()); │ head.ToString());
LOCK(cs_main); │ LOCK(cs_main);
BlockValidationState dummy; │ CValidationState dummy;
if (AcceptBlock(pblockrecursive, dummy, nullptr, true, &it-> │ if (AcceptBlock(pblockrecursive, dummy, chainparams, NULL, t
│ {
nLoaded++; │ nLoaded++;
queue.push_back(pblockrecursive->GetHash()); │ queue.push_back(pblockrecursive->GetHash());
} │ }
} │ }
range.first++; │ range.first++;
mapBlocksUnknownParent.erase(it); │ mapBlocksUnknownParent.erase(it);
NotifyHeaderTip(*this); │ NotifyHeaderTip();
} │ }
} │
next prev up dogecoin/src/test/checkqueue_tests.cpp:343 │ bitcoin/src/test/checkqueue_tests.cpp:344
│
auto queue = std::unique_ptr<FrozenCleanup_Queue>(new FrozenCleanup_Queue {QUEUE_BAT │ auto queue = std::make_unique<FrozenCleanup_Queue>(QUEUE_BATCH_SIZE);
boost::thread_group tg; │
bool fails = false; │ bool fails = false;
for (auto x = 0; x < nScriptCheckThreads; ++x) { │ queue->StartWorkerThreads(SCRIPT_CHECK_THREADS);
tg.create_thread([&]{queue->Thread();}); │
} │
std::thread t0([&]() { │ std::thread t0([&]() {
CCheckQueueControl<FrozenCleanupCheck> control(queue.get()); │ CCheckQueueControl<FrozenCleanupCheck> control(queue.get());
std::vector<FrozenCleanupCheck> vChecks(1); │ std::vector<FrozenCleanupCheck> vChecks(1);
// Freezing can't be the default initialized behavior given how the queue │ // Freezing can't be the default initialized behavior given how the queue
// swaps in default initialized Checks (otherwise freezing destructor │ // swaps in default initialized Checks (otherwise freezing destructor
// would get called twice). │ // would get called twice).
vChecks[0].should_freeze = true; │ vChecks[0].should_freeze = true;
control.Add(vChecks); │ control.Add(vChecks);
control.Wait(); // Hangs here │ bool waitResult = control.Wait(); // Hangs here
│ assert(waitResult);
}); │ });
{ │ {
std::unique_lock<std::mutex> l(FrozenCleanupCheck::m); │ std::unique_lock<std::mutex> l(FrozenCleanupCheck::m);
// Wait until the queue has finished all jobs and frozen │ // Wait until the queue has finished all jobs and frozen
FrozenCleanupCheck::cv.wait(l, [](){return FrozenCleanupCheck::nFrozen == 1;}); │ FrozenCleanupCheck::cv.wait(l, [](){return FrozenCleanupCheck::nFrozen == 1;});
// Try to get control of the queue a bunch of times │ }
for (auto x = 0; x < 100 && !fails; ++x) { │ // Try to get control of the queue a bunch of times
fails = queue->ControlMutex.try_lock(); │ for (auto x = 0; x < 100 && !fails; ++x) {
} │ fails = queue->m_control_mutex.try_lock();
// Unfreeze │ }
│ {
│ // Unfreeze (we need lock n case of spurious wakeup)
│ std::unique_lock<std::mutex> l(FrozenCleanupCheck::m);
FrozenCleanupCheck::nFrozen = 0; │ FrozenCleanupCheck::nFrozen = 0;
} │ }
// Awaken frozen destructor │ // Awaken frozen destructor
FrozenCleanupCheck::cv.notify_one(); │ FrozenCleanupCheck::cv.notify_one();
// Wait for control to finish │ // Wait for control to finish
t0.join(); │ t0.join();
tg.interrupt_all(); │
tg.join_all(); │
BOOST_REQUIRE(!fails); │ BOOST_REQUIRE(!fails);
│ queue->StopWorkerThreads();
} │
next prev up dogecoin/src/test/hash_tests.cpp:61 │ bitcoin/src/test/hash_tests.cpp:61
│
0x726fdb47dd0e0e31, 0x74f839c593dc67fd, 0x0d6c8009d9a94f5a, 0x85676696d7fb7e2d, │ 0x726fdb47dd0e0e31, 0x74f839c593dc67fd, 0x0d6c8009d9a94f5a, 0x85676696d7fb7e2d,
0xcf2794e0277187b7, 0x18765564cd99a68d, 0xcbc9466e58fee3ce, 0xab0200f58b01d137, │ 0xcf2794e0277187b7, 0x18765564cd99a68d, 0xcbc9466e58fee3ce, 0xab0200f58b01d137,
0x93f5f5799a932462, 0x9e0082df0ba9e4b0, 0x7a5dbbc594ddb9f3, 0xf4b32f46226bada7, │ 0x93f5f5799a932462, 0x9e0082df0ba9e4b0, 0x7a5dbbc594ddb9f3, 0xf4b32f46226bada7,
0x751e8fbc860ee5fb, 0x14ea5627c0843d90, 0xf723ca908e7af2ee, 0xa129ca6149be45e5, │ 0x751e8fbc860ee5fb, 0x14ea5627c0843d90, 0xf723ca908e7af2ee, 0xa129ca6149be45e5,
0x3f2acc7f57c29bdb, 0x699ae9f52cbe4794, 0x4bc1b3f0968dd39c, 0xbb6dc91da77961bd, │ 0x3f2acc7f57c29bdb, 0x699ae9f52cbe4794, 0x4bc1b3f0968dd39c, 0xbb6dc91da77961bd,
0xbed65cf21aa2ee98, 0xd0f2cbb02e3b67c7, 0x93536795e3a33e88, 0xa80c038ccd5ccec8, │ 0xbed65cf21aa2ee98, 0xd0f2cbb02e3b67c7, 0x93536795e3a33e88, 0xa80c038ccd5ccec8,
0xb8ad50c6f649af94, 0xbce192de8a85b8ea, 0x17d835b85bbb15f3, 0x2f2e6163076bcfad, │ 0xb8ad50c6f649af94, 0xbce192de8a85b8ea, 0x17d835b85bbb15f3, 0x2f2e6163076bcfad,
0xde4daaaca71dc9a5, 0xa6a2506687956571, 0xad87a3535c49ef28, 0x32d892fad841c342, │ 0xde4daaaca71dc9a5, 0xa6a2506687956571, 0xad87a3535c49ef28, 0x32d892fad841c342,
0x7127512f72f27cce, 0xa7f32346f95978e3, 0x12e0b01abb051238, 0x15e034d40fa197ae, │ 0x7127512f72f27cce, 0xa7f32346f95978e3, 0x12e0b01abb051238, 0x15e034d40fa197ae,
0x314dffbe0815a3b4, 0x027990f029623981, 0xcadcd4e59ef40c4d, 0x9abfd8766a33735c, │ 0x314dffbe0815a3b4, 0x027990f029623981, 0xcadcd4e59ef40c4d, 0x9abfd8766a33735c,
0x0e3ea96b5304a7d0, 0xad0c42d6fc585992, 0x187306c89bc215a9, 0xd4a60abcf3792b95, │ 0x0e3ea96b5304a7d0, 0xad0c42d6fc585992, 0x187306c89bc215a9, 0xd4a60abcf3792b95,
0xf935451de4f21df2, 0xa9538f0419755787, 0xdb9acddff56ca510, 0xd06c98cd5c0975eb, │ 0xf935451de4f21df2, 0xa9538f0419755787, 0xdb9acddff56ca510, 0xd06c98cd5c0975eb,
0xe612a3cb9ecba951, 0xc766e62cfcadaf96, 0xee64435a9752fe72, 0xa192d576b245165a, │ 0xe612a3cb9ecba951, 0xc766e62cfcadaf96, 0xee64435a9752fe72, 0xa192d576b245165a,
0x0a8787bf8ecb74b2, 0x81b3e73d20b49b6f, 0x7fa8220ba3b2ecea, 0x245731c13ca42499, │ 0x0a8787bf8ecb74b2, 0x81b3e73d20b49b6f, 0x7fa8220ba3b2ecea, 0x245731c13ca42499,
0xb78dbfaf3a8d83bd, 0xea1ad565322a1a0b, 0x60e61c23a3795013, 0x6606d7e446282b93, │ 0xb78dbfaf3a8d83bd, 0xea1ad565322a1a0b, 0x60e61c23a3795013, 0x6606d7e446282b93,
0x6ca4ecb15c5f91e1, 0x9f626da15c9625f3, 0xe51b38608ef25f57, 0x958a324ceb064572 │ 0x6ca4ecb15c5f91e1, 0x9f626da15c9625f3, 0xe51b38608ef25f57, 0x958a324ceb064572
} │
next prev up dogecoin/src/utilstrencodings.cpp:513 │ bitcoin/src/util/strencodings.cpp:275
│
│ assert(width >= indent);
std::stringstream out; │ std::stringstream out;
size_t ptr = 0; │ size_t ptr = 0;
size_t indented = 0; │ size_t indented = 0;
while (ptr < in.size()) │ while (ptr < in.size())
{ │ {
size_t lineend = in.find_first_of('\n', ptr); │ size_t lineend = in.find_first_of('\n', ptr);
if (lineend == std::string::npos) { │ if (lineend == std::string::npos) {
lineend = in.size(); │ lineend = in.size();
} │ }
const size_t linelen = lineend - ptr; │ const size_t linelen = lineend - ptr;
const size_t rem_width = width - indented; │ const size_t rem_width = width - indented;
if (linelen <= rem_width) { │ if (linelen <= rem_width) {
out << in.substr(ptr, linelen + 1); │ out << in.substr(ptr, linelen + 1);
ptr = lineend + 1; │ ptr = lineend + 1;
indented = 0; │ indented = 0;
} else { │ } else {
size_t finalspace = in.find_last_of(" \n", ptr + rem_width); │ size_t finalspace = in.find_last_of(" \n", ptr + rem_width);
if (finalspace == std::string::npos || finalspace < ptr) { │ if (finalspace == std::string::npos || finalspace < ptr) {
// No place to break; just include the entire word and move on │ // No place to break; just include the entire word and move on
finalspace = in.find_first_of("\n ", ptr); │ finalspace = in.find_first_of("\n ", ptr);
if (finalspace == std::string::npos) { │ if (finalspace == std::string::npos) {
// End of the string, just add it and break │ // End of the string, just add it and break
out << in.substr(ptr); │ out << in.substr(ptr);
break; │ break;
} │ }
} │ }
out << in.substr(ptr, finalspace - ptr) << "\n"; │ out << in.substr(ptr, finalspace - ptr) << "\n";
if (in[finalspace] == '\n') { │ if (in[finalspace] == '\n') {
indented = 0; │ indented = 0;
} else if (indent) { │ } else if (indent) {
out << std::string(indent, ' '); │ out << std::string(indent, ' ');
indented = indent; │ indented = indent;
} │ }
ptr = finalspace + 1; │ ptr = finalspace + 1;
} │ }
} │ }
return out.str(); │ return out.str();
} │
next prev up bitcoin/src/script/bitcoinconsensus.cpp:13 │ dogecoin/src/script/bitcoinconsensus.cpp:13
│
│
/** A class that deserializes a single CTransaction one time. */ │ /** A class that deserializes a single CTransaction one time. */
class TxInputStream │ class TxInputStream
{ │ {
public: │ public:
TxInputStream(int nTypeIn, int nVersionIn, const unsigned char *txTo, size_t txToLen │ TxInputStream(int nTypeIn, int nVersionIn, const unsigned char *txTo, size_t txToLen
m_type(nTypeIn), │ m_type(nTypeIn),
m_version(nVersionIn), │ m_version(nVersionIn),
m_data(txTo), │ m_data(txTo),
m_remaining(txToLen) │ m_remaining(txToLen)
{} │ {}
│
void read(char* pch, size_t nSize) │ void read(char* pch, size_t nSize)
{ │ {
if (nSize > m_remaining) │ if (nSize > m_remaining)
throw std::ios_base::failure(std::string(__func__) + ": end of data"); │ throw std::ios_base::failure(std::string(__func__) + ": end of data");
│
if (pch == NULL) │ if (pch == NULL)
throw std::ios_base::failure(std::string(__func__) + ": bad destination buff │ throw std::ios_base::failure(std::string(__func__) + ": bad destination buff
│
if (m_data == NULL) │ if (m_data == NULL)
throw std::ios_base::failure(std::string(__func__) + ": bad source buffer"); │ throw std::ios_base::failure(std::string(__func__) + ": bad source buffer");
│
memcpy(pch, m_data, nSize); │ memcpy(pch, m_data, nSize);
m_remaining -= nSize; │ m_remaining -= nSize;
m_data += nSize; │ m_data += nSize;
} │ }
│
template<typename T> │ template<typename T>
TxInputStream& operator>>(T& obj) │ TxInputStream& operator>>(T& obj)
{ │ {
::Unserialize(*this, obj); │ ::Unserialize(*this, obj);
return *this; │ return *this;
} │ }
│
int GetVersion() const { return m_version; } │ int GetVersion() const { return m_version; }
int GetType() const { return m_type; } │ int GetType() const { return m_type; }
private: │ private:
const int m_type; │ const int m_type;
const int m_version; │ const int m_version;
const unsigned char* m_data; │ const unsigned char* m_data;
size_t m_remaining; │ size_t m_remaining;
}; │ };
│
inline int set_error(bitcoinconsensus_error* ret, bitcoinconsensus_error serror) │ inline int set_error(bitcoinconsensus_error* ret, bitcoinconsensus_error serror)
{ │ {
if (ret) │ if (ret)
*ret = serror; │ *ret = serror;
return 0; │ return 0;
} │ }
│
struct ECCryptoClosure │ struct ECCryptoClosure
{ │ {
ECCVerifyHandle handle; │ ECCVerifyHandle handle;
}; │ };
│
ECCryptoClosure instance_of_eccryptoclosure; │ ECCryptoClosure instance_of_eccryptoclosure;
} │
next prev up dogecoin/src/script/interpreter.cpp:1275 │ bitcoin/src/script/interpreter.cpp:1702
│
// There are two kinds of nLockTime: lock-by-blockheight │ // There are two kinds of nLockTime: lock-by-blockheight
// and lock-by-blocktime, distinguished by whether │ // and lock-by-blocktime, distinguished by whether
// nLockTime < LOCKTIME_THRESHOLD. │ // nLockTime < LOCKTIME_THRESHOLD.
// │ //
// We want to compare apples to apples, so fail the script │ // We want to compare apples to apples, so fail the script
// unless the type of nLockTime being tested is the same as │ // unless the type of nLockTime being tested is the same as
// the nLockTime in the transaction. │ // the nLockTime in the transaction.
if (!( │ if (!(
(txTo->nLockTime < LOCKTIME_THRESHOLD && nLockTime < LOCKTIME_THRESHOLD) || │ (txTo->nLockTime < LOCKTIME_THRESHOLD && nLockTime < LOCKTIME_THRESHOLD) ||
(txTo->nLockTime >= LOCKTIME_THRESHOLD && nLockTime >= LOCKTIME_THRESHOLD) │ (txTo->nLockTime >= LOCKTIME_THRESHOLD && nLockTime >= LOCKTIME_THRESHOLD)
)) │ ))
return false; │ return false;
│
// Now that we know we're comparing apples-to-apples, the │ // Now that we know we're comparing apples-to-apples, the
// comparison is a simple numeric one. │ // comparison is a simple numeric one.
if (nLockTime > (int64_t)txTo->nLockTime) │ if (nLockTime > (int64_t)txTo->nLockTime)
return false; │ return false;
│
// Finally the nLockTime feature can be disabled and thus │ // Finally the nLockTime feature can be disabled in IsFinalTx()
// CHECKLOCKTIMEVERIFY bypassed if every txin has been │ // and thus CHECKLOCKTIMEVERIFY bypassed if every txin has
// finalized by setting nSequence to maxint. The │ // been finalized by setting nSequence to maxint. The
// transaction would be allowed into the blockchain, making │ // transaction would be allowed into the blockchain, making
// the opcode ineffective. │ // the opcode ineffective.
// │ //
// Testing if this vin is not final is sufficient to │ // Testing if this vin is not final is sufficient to
// prevent this condition. Alternatively we could test all │ // prevent this condition. Alternatively we could test all
// inputs, but testing just this input minimizes the data │ // inputs, but testing just this input minimizes the data
// required to prove correct CHECKLOCKTIMEVERIFY execution. │ // required to prove correct CHECKLOCKTIMEVERIFY execution.
if (CTxIn::SEQUENCE_FINAL == txTo->vin[nIn].nSequence) │ if (CTxIn::SEQUENCE_FINAL == txTo->vin[nIn].nSequence)
return false; │ return false;
│
return true; │ return true;
} │
next prev up dogecoin/src/util.cpp:687 │ bitcoin/src/util/system.cpp:1189
│
#if defined(WIN32) │ #if defined(WIN32)
// Windows-specific version │ // Windows-specific version
HANDLE hFile = (HANDLE)_get_osfhandle(_fileno(file)); │ HANDLE hFile = (HANDLE)_get_osfhandle(_fileno(file));
LARGE_INTEGER nFileSize; │ LARGE_INTEGER nFileSize;
int64_t nEndPos = (int64_t)offset + length; │ int64_t nEndPos = (int64_t)offset + length;
nFileSize.u.LowPart = nEndPos & 0xFFFFFFFF; │ nFileSize.u.LowPart = nEndPos & 0xFFFFFFFF;
nFileSize.u.HighPart = nEndPos >> 32; │ nFileSize.u.HighPart = nEndPos >> 32;
SetFilePointerEx(hFile, nFileSize, 0, FILE_BEGIN); │ SetFilePointerEx(hFile, nFileSize, 0, FILE_BEGIN);
SetEndOfFile(hFile); │ SetEndOfFile(hFile);
#elif defined(MAC_OSX) │ #elif defined(MAC_OSX)
// OSX specific version │ // OSX specific version
│ // NOTE: Contrary to other OS versions, the OSX version assumes that
│ // NOTE: offset is the size of the file.
fstore_t fst; │ fstore_t fst;
fst.fst_flags = F_ALLOCATECONTIG; │ fst.fst_flags = F_ALLOCATECONTIG;
fst.fst_posmode = F_PEOFPOSMODE; │ fst.fst_posmode = F_PEOFPOSMODE;
fst.fst_offset = 0; │ fst.fst_offset = 0;
fst.fst_length = (off_t)offset + length; │ fst.fst_length = length; // mac os fst_length takes the # of free bytes to allocate,
fst.fst_bytesalloc = 0; │ fst.fst_bytesalloc = 0;
if (fcntl(fileno(file), F_PREALLOCATE, &fst) == -1) { │ if (fcntl(fileno(file), F_PREALLOCATE, &fst) == -1) {
fst.fst_flags = F_ALLOCATEALL; │ fst.fst_flags = F_ALLOCATEALL;
fcntl(fileno(file), F_PREALLOCATE, &fst); │ fcntl(fileno(file), F_PREALLOCATE, &fst);
} │ }
ftruncate(fileno(file), fst.fst_length); │ ftruncate(fileno(file), static_cast<off_t>(offset) + length);
#elif defined(__linux__) │ #else
│ #if defined(HAVE_POSIX_FALLOCATE)
// Version using posix_fallocate │ // Version using posix_fallocate
off_t nEndPos = (off_t)offset + length; │ off_t nEndPos = (off_t)offset + length;
posix_fallocate(fileno(file), 0, nEndPos); │ if (0 == posix_fallocate(fileno(file), 0, nEndPos)) return;
#else │ #endif
// Fallback version │ // Fallback version
// TODO: just write one byte per block │ // TODO: just write one byte per block
static const char buf[65536] = {}; │ static const char buf[65536] = {};
fseek(file, offset, SEEK_SET); │ if (fseek(file, offset, SEEK_SET)) {
│ return;
│ }
while (length > 0) { │ while (length > 0) {
unsigned int now = 65536; │ unsigned int now = 65536;
if (length < now) │ if (length < now)
now = length; │ now = length;
fwrite(buf, 1, now, file); // allowed to fail; this function is advisory anyway │ fwrite(buf, 1, now, file); // allowed to fail; this function is advisory anyway
length -= now; │ length -= now;
} │ }
#endif │ #endif
} │
next prev up bitcoin/src/test/sighash_tests.cpp:121 │ dogecoin/src/test/sighash_tests.cpp:124
│
│ seed_insecure_rand(false);
│
#if defined(PRINT_SIGHASH_JSON) │ #if defined(PRINT_SIGHASH_JSON)
std::cout << "[\n"; │ std::cout << "[\n";
std::cout << "\t[\"raw_transaction, script, input_index, hashType, signature_hash (r │ std::cout << "\t[\"raw_transaction, script, input_index, hashType, signature_hash (r
int nRandomTests = 500; │ #endif
#else │
int nRandomTests = 50000; │ int nRandomTests = 50000;
│
│ #if defined(PRINT_SIGHASH_JSON)
│ nRandomTests = 500;
#endif │ #endif
for (int i=0; i<nRandomTests; i++) { │ for (int i=0; i<nRandomTests; i++) {
int nHashType{int(InsecureRand32())}; │ int nHashType = insecure_rand();
CMutableTransaction txTo; │ CMutableTransaction txTo;
RandomTransaction(txTo, (nHashType & 0x1f) == SIGHASH_SINGLE); │ RandomTransaction(txTo, (nHashType & 0x1f) == SIGHASH_SINGLE);
CScript scriptCode; │ CScript scriptCode;
RandomScript(scriptCode); │ RandomScript(scriptCode);
int nIn = InsecureRandRange(txTo.vin.size()); │ int nIn = insecure_rand() % txTo.vin.size();
│
uint256 sh, sho; │ uint256 sh, sho;
sho = SignatureHashOld(scriptCode, CTransaction(txTo), nIn, nHashType); │ sho = SignatureHashOld(scriptCode, txTo, nIn, nHashType);
sh = SignatureHash(scriptCode, txTo, nIn, nHashType, 0, SigVersion::BASE); │ sh = SignatureHash(scriptCode, txTo, nIn, nHashType, 0, SIGVERSION_BASE);
#if defined(PRINT_SIGHASH_JSON) │ #if defined(PRINT_SIGHASH_JSON)
CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); │ CDataStream ss(SER_NETWORK, PROTOCOL_VERSION);
ss << txTo; │ ss << txTo;
│
std::cout << "\t[\"" ; │ std::cout << "\t[\"" ;
std::cout << HexStr(ss) << "\", \""; │ std::cout << HexStr(ss.begin(), ss.end()) << "\", \"";
std::cout << HexStr(scriptCode) << "\", "; │ std::cout << HexStr(scriptCode) << "\", ";
std::cout << nIn << ", "; │ std::cout << nIn << ", ";
std::cout << nHashType << ", \""; │ std::cout << nHashType << ", \"";
std::cout << sho.GetHex() << "\"]"; │ std::cout << sho.GetHex() << "\"]";
if (i+1 != nRandomTests) { │ if (i+1 != nRandomTests) {
std::cout << ","; │ std::cout << ",";
} │ }
std::cout << "\n"; │ std::cout << "\n";
#endif │ #endif
BOOST_CHECK(sh == sho); │ BOOST_CHECK(sh == sho);
} │ }
#if defined(PRINT_SIGHASH_JSON) │ #if defined(PRINT_SIGHASH_JSON)
std::cout << "]\n"; │ std::cout << "]\n";
#endif │ #endif
} │
next prev up dogecoin/src/qt/notificator.cpp:173 │ bitcoin/src/qt/notificator.cpp:145
│
Q_UNUSED(cls); │ // https://developer.gnome.org/notification-spec/
// Arguments for DBus call: │ // Arguments for DBus "Notify" call:
QList<QVariant> args; │ QList<QVariant> args;
│
// Program Name: │ // Program Name:
args.append(programName); │ args.append(programName);
│
// Unique ID of this notification type: │ // Replaces ID; A value of 0 means that this notification won't replace any existing
args.append(0U); │ args.append(0U);
│
// Application Icon, empty string │ // Application Icon, empty string
args.append(QString()); │ args.append(QString());
│
// Summary │ // Summary
args.append(title); │ args.append(title);
│
// Body │ // Body
args.append(text); │ args.append(text);
│
// Actions (none, actions are deprecated) │ // Actions (none, actions are deprecated)
QStringList actions; │ QStringList actions;
args.append(actions); │ args.append(actions);
│
// Hints │ // Hints
QVariantMap hints; │ QVariantMap hints;
│
// If no icon specified, set icon based on class │ // If no icon specified, set icon based on class
QIcon tmpicon; │ QIcon tmpicon;
if(icon.isNull()) │ if(icon.isNull())
{ │ {
QStyle::StandardPixmap sicon = QStyle::SP_MessageBoxQuestion; │ QStyle::StandardPixmap sicon = QStyle::SP_MessageBoxQuestion;
switch(cls) │ switch(cls)
{ │ {
case Information: sicon = QStyle::SP_MessageBoxInformation; break; │ case Information: sicon = QStyle::SP_MessageBoxInformation; break;
case Warning: sicon = QStyle::SP_MessageBoxWarning; break; │ case Warning: sicon = QStyle::SP_MessageBoxWarning; break;
case Critical: sicon = QStyle::SP_MessageBoxCritical; break; │ case Critical: sicon = QStyle::SP_MessageBoxCritical; break;
default: break; │ default: break;
} │ }
tmpicon = QApplication::style()->standardIcon(sicon); │ tmpicon = QApplication::style()->standardIcon(sicon);
} │ }
else │ else
{ │ {
tmpicon = icon; │ tmpicon = icon;
} │ }
hints["icon_data"] = FreedesktopImage::toVariant(tmpicon.pixmap(FREEDESKTOP_NOTIFICA │ hints["icon_data"] = FreedesktopImage::toVariant(tmpicon.pixmap(FREEDESKTOP_NOTIFICA
args.append(hints); │ args.append(hints);
│
// Timeout (in msec) │ // Timeout (in msec)
args.append(millisTimeout); │ args.append(millisTimeout);
│
// "Fire and forget" │ // "Fire and forget"
interface->callWithArgumentList(QDBus::NoBlock, "Notify", args); │ interface->callWithArgumentList(QDBus::NoBlock, "Notify", args);
} │
next prev up bitcoin/src/qt/signverifymessagedialog.cpp:26 │ dogecoin/src/qt/signverifymessagedialog.cpp:28
│
ui->setupUi(this); │ ui->setupUi(this);
│
ui->addressBookButton_SM->setIcon(platformStyle->SingleColorIcon(":/icons/address-bo │ ui->addressBookButton_SM->setIcon(platformStyle->SingleColorIcon(":/icons/address-bo
ui->pasteButton_SM->setIcon(platformStyle->SingleColorIcon(":/icons/editpaste")); │ ui->pasteButton_SM->setIcon(platformStyle->SingleColorIcon(":/icons/editpaste"));
ui->copySignatureButton_SM->setIcon(platformStyle->SingleColorIcon(":/icons/editcopy │ ui->copySignatureButton_SM->setIcon(platformStyle->SingleColorIcon(":/icons/editcopy
ui->signMessageButton_SM->setIcon(platformStyle->SingleColorIcon(":/icons/edit")); │ ui->signMessageButton_SM->setIcon(platformStyle->SingleColorIcon(":/icons/edit"));
ui->clearButton_SM->setIcon(platformStyle->SingleColorIcon(":/icons/remove")); │ ui->clearButton_SM->setIcon(platformStyle->SingleColorIcon(":/icons/remove"));
ui->addressBookButton_VM->setIcon(platformStyle->SingleColorIcon(":/icons/address-bo │ ui->addressBookButton_VM->setIcon(platformStyle->SingleColorIcon(":/icons/address-bo
ui->verifyMessageButton_VM->setIcon(platformStyle->SingleColorIcon(":/icons/transact │ ui->verifyMessageButton_VM->setIcon(platformStyle->SingleColorIcon(":/icons/transact
ui->clearButton_VM->setIcon(platformStyle->SingleColorIcon(":/icons/remove")); │ ui->clearButton_VM->setIcon(platformStyle->SingleColorIcon(":/icons/remove"));
│
│ #if QT_VERSION >= 0x040700
│ ui->signatureOut_SM->setPlaceholderText(tr("Click \"Sign Message\" to generate signa
│ #endif
│
GUIUtil::setupAddressWidget(ui->addressIn_SM, this); │ GUIUtil::setupAddressWidget(ui->addressIn_SM, this);
GUIUtil::setupAddressWidget(ui->addressIn_VM, this); │ GUIUtil::setupAddressWidget(ui->addressIn_VM, this);
│
ui->addressIn_SM->installEventFilter(this); │ ui->addressIn_SM->installEventFilter(this);
ui->messageIn_SM->installEventFilter(this); │ ui->messageIn_SM->installEventFilter(this);
ui->signatureOut_SM->installEventFilter(this); │ ui->signatureOut_SM->installEventFilter(this);
ui->addressIn_VM->installEventFilter(this); │ ui->addressIn_VM->installEventFilter(this);
ui->messageIn_VM->installEventFilter(this); │ ui->messageIn_VM->installEventFilter(this);
ui->signatureIn_VM->installEventFilter(this); │ ui->signatureIn_VM->installEventFilter(this);
│
ui->signatureOut_SM->setFont(GUIUtil::fixedPitchFont()); │ ui->signatureOut_SM->setFont(GUIUtil::fixedPitchFont());
ui->signatureIn_VM->setFont(GUIUtil::fixedPitchFont()); │ ui->signatureIn_VM->setFont(GUIUtil::fixedPitchFont());
│
GUIUtil::handleCloseWindowShortcut(this); │
} │
next prev up bitcoin/src/rest.cpp:434 │ bitcoin/src/rest.cpp:237
│
case RESTResponseFormat::BINARY: { │ case RESTResponseFormat::BINARY: {
CDataStream ssHeader{SER_NETWORK, PROTOCOL_VERSION}; │ CDataStream ssHeader(SER_NETWORK, PROTOCOL_VERSION);
for (const uint256& header : filter_headers) { │ for (const CBlockIndex *pindex : headers) {
ssHeader << header; │ ssHeader << pindex->GetBlockHeader();
} │ }
│
std::string binaryHeader = ssHeader.str(); │ std::string binaryHeader = ssHeader.str();
req->WriteHeader("Content-Type", "application/octet-stream"); │ req->WriteHeader("Content-Type", "application/octet-stream");
req->WriteReply(HTTP_OK, binaryHeader); │ req->WriteReply(HTTP_OK, binaryHeader);
return true; │ return true;
} │ }
│
case RESTResponseFormat::HEX: { │ case RESTResponseFormat::HEX: {
CDataStream ssHeader{SER_NETWORK, PROTOCOL_VERSION}; │ CDataStream ssHeader(SER_NETWORK, PROTOCOL_VERSION);
for (const uint256& header : filter_headers) { │ for (const CBlockIndex *pindex : headers) {
ssHeader << header; │ ssHeader << pindex->GetBlockHeader();
} │ }
│
std::string strHex = HexStr(ssHeader) + "\n"; │ std::string strHex = HexStr(ssHeader) + "\n";
req->WriteHeader("Content-Type", "text/plain"); │ req->WriteHeader("Content-Type", "text/plain");
req->WriteReply(HTTP_OK, strHex); │ req->WriteReply(HTTP_OK, strHex);
return true; │ return true;
} │ }
case RESTResponseFormat::JSON: { │ case RESTResponseFormat::JSON: {
UniValue jsonHeaders(UniValue::VARR); │ UniValue jsonHeaders(UniValue::VARR);
for (const uint256& header : filter_headers) { │ for (const CBlockIndex *pindex : headers) {
jsonHeaders.push_back(header.GetHex()); │ jsonHeaders.push_back(blockheaderToJSON(tip, pindex));
} │ }
│
std::string strJSON = jsonHeaders.write() + "\n"; │ std::string strJSON = jsonHeaders.write() + "\n";
req->WriteHeader("Content-Type", "application/json"); │ req->WriteHeader("Content-Type", "application/json");
req->WriteReply(HTTP_OK, strJSON); │ req->WriteReply(HTTP_OK, strJSON);
return true; │ return true;
} │ }
default: { │ default: {
return RESTERR(req, HTTP_NOT_FOUND, "output format not found (available: " + Ava │ return RESTERR(req, HTTP_NOT_FOUND, "output format not found (available: " + Ava
} │ }
} │
next prev up bitcoin/src/test/bloom_tests.cpp:54 │ bitcoin/src/test/bloom_tests.cpp:27
│
// Same test as bloom_create_insert_serialize, but we add a nTweak of 100 │ CBloomFilter filter(3, 0.01, 0, BLOOM_UPDATE_ALL);
CBloomFilter filter(3, 0.01, 2147483649UL, BLOOM_UPDATE_ALL); │
│
│ BOOST_CHECK_MESSAGE( !filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f09
filter.insert(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")); │ filter.insert(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8"));
BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f095 │ BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f095
// One bit different in first byte │ // One bit different in first byte
BOOST_CHECK_MESSAGE(!filter.contains(ParseHex("19108ad8ed9bb6274d3980bab5a85c048f095 │ BOOST_CHECK_MESSAGE(!filter.contains(ParseHex("19108ad8ed9bb6274d3980bab5a85c048f095
│
filter.insert(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32eee")); │ filter.insert(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32eee"));
BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32e │ BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32e
│
filter.insert(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729c5")); │ filter.insert(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729c5"));
BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729 │ BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729
│
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); │ CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
stream << filter; │ stream << filter;
│
std::vector<uint8_t> expected = ParseHex("03ce4299050000000100008001"); │ std::vector<uint8_t> expected = ParseHex("03614e9b050000000000000001");
auto result{MakeUCharSpan(stream)}; │ auto result{MakeUCharSpan(stream)};
│
BOOST_CHECK_EQUAL_COLLECTIONS(result.begin(), result.end(), expected.begin(), expect │ BOOST_CHECK_EQUAL_COLLECTIONS(result.begin(), result.end(), expected.begin(), expect
│
│ BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f095
} │
next prev up bitcoin/src/test/bloom_tests.cpp:54 │ dogecoin/src/test/bloom_tests.cpp:58
│
// Same test as bloom_create_insert_serialize, but we add a nTweak of 100 │ // Same test as bloom_create_insert_serialize, but we add a nTweak of 100
CBloomFilter filter(3, 0.01, 2147483649UL, BLOOM_UPDATE_ALL); │ CBloomFilter filter(3, 0.01, 2147483649UL, BLOOM_UPDATE_ALL);
│
filter.insert(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8")); │ filter.insert(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f0950c8"));
BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f095 │ BOOST_CHECK_MESSAGE( filter.contains(ParseHex("99108ad8ed9bb6274d3980bab5a85c048f095
// One bit different in first byte │ // One bit different in first byte
BOOST_CHECK_MESSAGE(!filter.contains(ParseHex("19108ad8ed9bb6274d3980bab5a85c048f095 │ BOOST_CHECK_MESSAGE(!filter.contains(ParseHex("19108ad8ed9bb6274d3980bab5a85c048f095
│
filter.insert(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32eee")); │ filter.insert(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32eee"));
BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32e │ BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b5a2c786d9ef4658287ced5914b37a1b4aa32e
│
filter.insert(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729c5")); │ filter.insert(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729c5"));
BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729 │ BOOST_CHECK_MESSAGE(filter.contains(ParseHex("b9300670b4c5366e95b2699e8b18bc75e5f729
│
CDataStream stream(SER_NETWORK, PROTOCOL_VERSION); │ CDataStream stream(SER_NETWORK, PROTOCOL_VERSION);
stream << filter; │ stream << filter;
│
std::vector<uint8_t> expected = ParseHex("03ce4299050000000100008001"); │ std::vector<unsigned char> vch = ParseHex("03ce4299050000000100008001");
auto result{MakeUCharSpan(stream)}; │ std::vector<char> expected(vch.size());
│
BOOST_CHECK_EQUAL_COLLECTIONS(result.begin(), result.end(), expected.begin(), expect │ for (unsigned int i = 0; i < vch.size(); i++)
│ expected[i] = (char)vch[i];
│
│ BOOST_CHECK_EQUAL_COLLECTIONS(stream.begin(), stream.end(), expected.begin(), expect
} │
next prev up bitcoin/src/crypto/muhash.cpp:182 │ bitcoin/src/crypto/muhash.cpp:219
│
limb_t c0 = 0, c1 = 0, c2 = 0; │ limb_t c0 = 0, c1 = 0, c2 = 0;
Num3072 tmp; │ Num3072 tmp;
│
/* Compute limbs 0..N-2 of this*a into tmp, including one reduction. */ │ /* Compute limbs 0..N-2 of this*this into tmp, including one reduction. */
for (int j = 0; j < LIMBS - 1; ++j) { │ for (int j = 0; j < LIMBS - 1; ++j) {
limb_t d0 = 0, d1 = 0, d2 = 0; │ limb_t d0 = 0, d1 = 0, d2 = 0;
mul(d0, d1, this->limbs[1 + j], a.limbs[LIMBS + j - (1 + j)]); │ for (int i = 0; i < (LIMBS - 1 - j) / 2; ++i) muldbladd3(d0, d1, d2, this->limbs
for (int i = 2 + j; i < LIMBS; ++i) muladd3(d0, d1, d2, this->limbs[i], a.limbs[ │ if ((j + 1) & 1) muladd3(d0, d1, d2, this->limbs[(LIMBS - 1 - j) / 2 + j + 1], t
mulnadd3(c0, c1, c2, d0, d1, d2, MAX_PRIME_DIFF); │ mulnadd3(c0, c1, c2, d0, d1, d2, MAX_PRIME_DIFF);
for (int i = 0; i < j + 1; ++i) muladd3(c0, c1, c2, this->limbs[i], a.limbs[j - │ for (int i = 0; i < (j + 1) / 2; ++i) muldbladd3(c0, c1, c2, this->limbs[i], thi
│ if ((j + 1) & 1) muladd3(c0, c1, c2, this->limbs[(j + 1) / 2], this->limbs[j - (
extract3(c0, c1, c2, tmp.limbs[j]); │ extract3(c0, c1, c2, tmp.limbs[j]);
} │ }
│
/* Compute limb N-1 of a*b into tmp. */ │
assert(c2 == 0); │ assert(c2 == 0);
for (int i = 0; i < LIMBS; ++i) muladd3(c0, c1, c2, this->limbs[i], a.limbs[LIMBS - │ for (int i = 0; i < LIMBS / 2; ++i) muldbladd3(c0, c1, c2, this->limbs[i], this->lim
extract3(c0, c1, c2, tmp.limbs[LIMBS - 1]); │ extract3(c0, c1, c2, tmp.limbs[LIMBS - 1]);
│
/* Perform a second reduction. */ │ /* Perform a second reduction. */
muln2(c0, c1, MAX_PRIME_DIFF); │ muln2(c0, c1, MAX_PRIME_DIFF);
for (int j = 0; j < LIMBS; ++j) { │ for (int j = 0; j < LIMBS; ++j) {
addnextract2(c0, c1, tmp.limbs[j], this->limbs[j]); │ addnextract2(c0, c1, tmp.limbs[j], this->limbs[j]);
} │ }
│
assert(c1 == 0); │ assert(c1 == 0);
assert(c0 == 0 || c0 == 1); │ assert(c0 == 0 || c0 == 1);
│
/* Perform up to two more reductions if the internal state has already │ /* Perform up to two more reductions if the internal state has already
* overflown the MAX of Num3072 or if it is larger than the modulus or │ * overflown the MAX of Num3072 or if it is larger than the modulus or
* if both are the case. │ * if both are the case.
* */ │ * */
if (this->IsOverflow()) this->FullReduce(); │ if (this->IsOverflow()) this->FullReduce();
if (c0) this->FullReduce(); │ if (c0) this->FullReduce();
} │
next prev up dogecoin/src/test/arith_uint256_tests.cpp:378 │ bitcoin/src/test/arith_uint256_tests.cpp:372
│
BOOST_CHECK(R1L.GetHex() == R1L.ToString()); │ BOOST_CHECK(R1L.GetHex() == R1L.ToString());
BOOST_CHECK(R2L.GetHex() == R2L.ToString()); │ BOOST_CHECK(R2L.GetHex() == R2L.ToString());
BOOST_CHECK(OneL.GetHex() == OneL.ToString()); │ BOOST_CHECK(OneL.GetHex() == OneL.ToString());
BOOST_CHECK(MaxL.GetHex() == MaxL.ToString()); │ BOOST_CHECK(MaxL.GetHex() == MaxL.ToString());
arith_uint256 TmpL(R1L); │ arith_uint256 TmpL(R1L);
BOOST_CHECK(TmpL == R1L); │ BOOST_CHECK(TmpL == R1L);
TmpL.SetHex(R2L.ToString()); BOOST_CHECK(TmpL == R2L); │ TmpL.SetHex(R2L.ToString()); BOOST_CHECK(TmpL == R2L);
TmpL.SetHex(ZeroL.ToString()); BOOST_CHECK(TmpL == 0); │ TmpL.SetHex(ZeroL.ToString()); BOOST_CHECK(TmpL == 0);
TmpL.SetHex(HalfL.ToString()); BOOST_CHECK(TmpL == HalfL); │ TmpL.SetHex(HalfL.ToString()); BOOST_CHECK(TmpL == HalfL);
│
TmpL.SetHex(R1L.ToString()); │ TmpL.SetHex(R1L.ToString());
BOOST_CHECK(R1L.size() == 32); │ BOOST_CHECK(R1L.size() == 32);
BOOST_CHECK(R2L.size() == 32); │ BOOST_CHECK(R2L.size() == 32);
BOOST_CHECK(ZeroL.size() == 32); │ BOOST_CHECK(ZeroL.size() == 32);
BOOST_CHECK(MaxL.size() == 32); │ BOOST_CHECK(MaxL.size() == 32);
BOOST_CHECK(R1L.GetLow64() == R1LLow64); │ BOOST_CHECK(R1L.GetLow64() == R1LLow64);
BOOST_CHECK(HalfL.GetLow64() ==0x0000000000000000ULL); │ BOOST_CHECK(HalfL.GetLow64() ==0x0000000000000000ULL);
BOOST_CHECK(OneL.GetLow64() ==0x0000000000000001ULL); │ BOOST_CHECK(OneL.GetLow64() ==0x0000000000000001ULL);
│
for (unsigned int i = 0; i < 255; ++i) │ for (unsigned int i = 0; i < 255; ++i)
{ │ {
BOOST_CHECK((OneL << i).getdouble() == ldexp(1.0,i)); │ BOOST_CHECK((OneL << i).getdouble() == ldexp(1.0,i));
} │ }
BOOST_CHECK(ZeroL.getdouble() == 0.0); │ BOOST_CHECK(ZeroL.getdouble() == 0.0);
for (int i = 256; i > 53; --i) │ for (int i = 256; i > 53; --i)
BOOST_CHECK(almostEqual((R1L>>(256-i)).getdouble(), ldexp(R1Ldouble,i))); │ BOOST_CHECK(almostEqual((R1L>>(256-i)).getdouble(), ldexp(R1Ldouble,i)));
uint64_t R1L64part = (R1L>>192).GetLow64(); │ uint64_t R1L64part = (R1L>>192).GetLow64();
for (int i = 53; i > 0; --i) // doubles can store all integers in {0,...,2^54-1} exa │ for (int i = 53; i > 0; --i) // doubles can store all integers in {0,...,2^54-1} exa
{ │ {
BOOST_CHECK((R1L>>(256-i)).getdouble() == (double)(R1L64part >> (64-i))); │ BOOST_CHECK((R1L>>(256-i)).getdouble() == (double)(R1L64part >> (64-i)));
} │ }
} │
next prev up dogecoin/src/test/sigopcount_tests.cpp:29 │ bitcoin/src/test/sigopcount_tests.cpp:29
│
// Test CScript::GetSigOpCount() │ // Test CScript::GetSigOpCount()
CScript s1; │ CScript s1;
BOOST_CHECK_EQUAL(s1.GetSigOpCount(false), 0U); │ BOOST_CHECK_EQUAL(s1.GetSigOpCount(false), 0U);
BOOST_CHECK_EQUAL(s1.GetSigOpCount(true), 0U); │ BOOST_CHECK_EQUAL(s1.GetSigOpCount(true), 0U);
│
uint160 dummy; │ uint160 dummy;
s1 << OP_1 << ToByteVector(dummy) << ToByteVector(dummy) << OP_2 << OP_CHECKMULTISIG │ s1 << OP_1 << ToByteVector(dummy) << ToByteVector(dummy) << OP_2 << OP_CHECKMULTISIG
BOOST_CHECK_EQUAL(s1.GetSigOpCount(true), 2U); │ BOOST_CHECK_EQUAL(s1.GetSigOpCount(true), 2U);
s1 << OP_IF << OP_CHECKSIG << OP_ENDIF; │ s1 << OP_IF << OP_CHECKSIG << OP_ENDIF;
BOOST_CHECK_EQUAL(s1.GetSigOpCount(true), 3U); │ BOOST_CHECK_EQUAL(s1.GetSigOpCount(true), 3U);
BOOST_CHECK_EQUAL(s1.GetSigOpCount(false), 21U); │ BOOST_CHECK_EQUAL(s1.GetSigOpCount(false), 21U);
│
CScript p2sh = GetScriptForDestination(ScriptHash(s1)); │ CScript p2sh = GetScriptForDestination(ScriptHash(s1));
CScript scriptSig; │ CScript scriptSig;
scriptSig << OP_0 << Serialize(s1); │ scriptSig << OP_0 << Serialize(s1);
BOOST_CHECK_EQUAL(p2sh.GetSigOpCount(scriptSig), 3U); │ BOOST_CHECK_EQUAL(p2sh.GetSigOpCount(scriptSig), 3U);
│
std::vector<CPubKey> keys; │ std::vector<CPubKey> keys;
for (int i = 0; i < 3; i++) │ for (int i = 0; i < 3; i++)
{ │ {
CKey k; │ CKey k;
k.MakeNewKey(true); │ k.MakeNewKey(true);
keys.push_back(k.GetPubKey()); │ keys.push_back(k.GetPubKey());
} │ }
CScript s2 = GetScriptForMultisig(1, keys); │ CScript s2 = GetScriptForMultisig(1, keys);
BOOST_CHECK_EQUAL(s2.GetSigOpCount(true), 3U); │ BOOST_CHECK_EQUAL(s2.GetSigOpCount(true), 3U);
BOOST_CHECK_EQUAL(s2.GetSigOpCount(false), 20U); │ BOOST_CHECK_EQUAL(s2.GetSigOpCount(false), 20U);
│
p2sh = GetScriptForDestination(ScriptHash(s2)); │ p2sh = GetScriptForDestination(ScriptHash(s2));
BOOST_CHECK_EQUAL(p2sh.GetSigOpCount(true), 0U); │ BOOST_CHECK_EQUAL(p2sh.GetSigOpCount(true), 0U);
BOOST_CHECK_EQUAL(p2sh.GetSigOpCount(false), 0U); │ BOOST_CHECK_EQUAL(p2sh.GetSigOpCount(false), 0U);
CScript scriptSig2; │ CScript scriptSig2;
scriptSig2 << OP_1 << ToByteVector(dummy) << ToByteVector(dummy) << Serialize(s2); │ scriptSig2 << OP_1 << ToByteVector(dummy) << ToByteVector(dummy) << Serialize(s2);
BOOST_CHECK_EQUAL(p2sh.GetSigOpCount(scriptSig2), 3U); │ BOOST_CHECK_EQUAL(p2sh.GetSigOpCount(scriptSig2), 3U);
} │
next prev up bitcoin/src/test/util_tests.cpp:1793 │ dogecoin/src/test/util_tests.cpp:345
│
int64_t n; │ int64_t n;
// Valid values │ // Valid values
BOOST_CHECK(ParseInt64("1234", nullptr)); │ BOOST_CHECK(ParseInt64("1234", NULL));
BOOST_CHECK(ParseInt64("0", &n) && n == 0LL); │ BOOST_CHECK(ParseInt64("0", &n) && n == 0LL);
BOOST_CHECK(ParseInt64("1234", &n) && n == 1234LL); │ BOOST_CHECK(ParseInt64("1234", &n) && n == 1234LL);
BOOST_CHECK(ParseInt64("01234", &n) && n == 1234LL); // no octal │ BOOST_CHECK(ParseInt64("01234", &n) && n == 1234LL); // no octal
BOOST_CHECK(ParseInt64("2147483647", &n) && n == 2147483647LL); │ BOOST_CHECK(ParseInt64("2147483647", &n) && n == 2147483647LL);
BOOST_CHECK(ParseInt64("-2147483648", &n) && n == -2147483648LL); │ BOOST_CHECK(ParseInt64("-2147483648", &n) && n == -2147483648LL);
BOOST_CHECK(ParseInt64("9223372036854775807", &n) && n == (int64_t)92233720368547758 │ BOOST_CHECK(ParseInt64("9223372036854775807", &n) && n == (int64_t)92233720368547758
BOOST_CHECK(ParseInt64("-9223372036854775808", &n) && n == (int64_t)-922337203685477 │ BOOST_CHECK(ParseInt64("-9223372036854775808", &n) && n == (int64_t)-922337203685477
BOOST_CHECK(ParseInt64("-1234", &n) && n == -1234LL); │ BOOST_CHECK(ParseInt64("-1234", &n) && n == -1234LL);
// Invalid values │ // Invalid values
BOOST_CHECK(!ParseInt64("", &n)); │ BOOST_CHECK(!ParseInt64("", &n));
BOOST_CHECK(!ParseInt64(" 1", &n)); // no padding inside │ BOOST_CHECK(!ParseInt64(" 1", &n)); // no padding inside
BOOST_CHECK(!ParseInt64("1 ", &n)); │ BOOST_CHECK(!ParseInt64("1 ", &n));
BOOST_CHECK(!ParseInt64("1a", &n)); │ BOOST_CHECK(!ParseInt64("1a", &n));
BOOST_CHECK(!ParseInt64("aap", &n)); │ BOOST_CHECK(!ParseInt64("aap", &n));
BOOST_CHECK(!ParseInt64("0x1", &n)); // no hex │ BOOST_CHECK(!ParseInt64("0x1", &n)); // no hex
BOOST_CHECK(!ParseInt64(STRING_WITH_EMBEDDED_NULL_CHAR, &n)); │ const char test_bytes[] = {'1', 0, '1'};
│ std::string teststr(test_bytes, sizeof(test_bytes));
│ BOOST_CHECK(!ParseInt64(teststr, &n)); // no embedded NULs
// Overflow and underflow │ // Overflow and underflow
BOOST_CHECK(!ParseInt64("-9223372036854775809", nullptr)); │ BOOST_CHECK(!ParseInt64("-9223372036854775809", NULL));
BOOST_CHECK(!ParseInt64("9223372036854775808", nullptr)); │ BOOST_CHECK(!ParseInt64("9223372036854775808", NULL));
BOOST_CHECK(!ParseInt64("-32482348723847471234", nullptr)); │ BOOST_CHECK(!ParseInt64("-32482348723847471234", NULL));
BOOST_CHECK(!ParseInt64("32482348723847471234", nullptr)); │ BOOST_CHECK(!ParseInt64("32482348723847471234", NULL));
} │
next prev up bitcoin/src/qt/bitcoinamountfield.cpp:121 │ dogecoin/src/qt/bitcoinamountfield.cpp:95
│
if(cachedMinimumSizeHint.isEmpty()) │ if(cachedMinimumSizeHint.isEmpty())
{ │ {
ensurePolished(); │ ensurePolished();
│
const QFontMetrics fm(fontMetrics()); │ const QFontMetrics fm(fontMetrics());
int h = lineEdit()->minimumSizeHint().height(); │ int h = lineEdit()->minimumSizeHint().height();
int w = GUIUtil::TextWidth(fm, BitcoinUnits::format(BitcoinUnit::BTC, Bitcoi │ int w = fm.width(BitcoinUnits::format(BitcoinUnits::BTC, BitcoinUnits::maxMo
w += 2; // cursor blinking space │ w += 2; // cursor blinking space
│
QStyleOptionSpinBox opt; │ QStyleOptionSpinBox opt;
initStyleOption(&opt); │ initStyleOption(&opt);
QSize hint(w, h); │ QSize hint(w, h);
QSize extra(35, 6); │ QSize extra(35, 6);
opt.rect.setSize(hint + extra); │ opt.rect.setSize(hint + extra);
extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &opt, │ extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &opt,
QStyle::SC_SpinBoxEditField, this).s │ QStyle::SC_SpinBoxEditField, this).s
// get closer to final result by repeating the calculation │ // get closer to final result by repeating the calculation
opt.rect.setSize(hint + extra); │ opt.rect.setSize(hint + extra);
extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &opt, │ extra += hint - style()->subControlRect(QStyle::CC_SpinBox, &opt,
QStyle::SC_SpinBoxEditField, this).s │ QStyle::SC_SpinBoxEditField, this).s
hint += extra; │ hint += extra;
hint.setHeight(h); │ hint.setHeight(h);
│
opt.rect = rect(); │ opt.rect = rect();
│
cachedMinimumSizeHint = style()->sizeFromContents(QStyle::CT_SpinBox, &opt, │ cachedMinimumSizeHint = style()->sizeFromContents(QStyle::CT_SpinBox, &opt,
│ .expandedTo(QApplication::globalStrut());
} │ }
return cachedMinimumSizeHint; │ return cachedMinimumSizeHint;
} │
next prev up bitcoin/src/merkleblock.cpp:149 │ dogecoin/src/merkleblock.cpp:150
│
vMatch.clear(); │ vMatch.clear();
// An empty set will not work │ // An empty set will not work
if (nTransactions == 0) │ if (nTransactions == 0)
return uint256(); │ return uint256();
// check for excessively high numbers of transactions │ // check for excessively high numbers of transactions
if (nTransactions > MAX_BLOCK_WEIGHT / MIN_TRANSACTION_WEIGHT) │ if (nTransactions > MAX_BLOCK_BASE_SIZE / 60) // 60 is the lower bound for the size
return uint256(); │ return uint256();
// there can never be more hashes provided than one for every txid │ // there can never be more hashes provided than one for every txid
if (vHash.size() > nTransactions) │ if (vHash.size() > nTransactions)
return uint256(); │ return uint256();
// there must be at least one bit per node in the partial tree, and at least one nod │ // there must be at least one bit per node in the partial tree, and at least one nod
if (vBits.size() < vHash.size()) │ if (vBits.size() < vHash.size())
return uint256(); │ return uint256();
// calculate height of tree │ // calculate height of tree
int nHeight = 0; │ int nHeight = 0;
while (CalcTreeWidth(nHeight) > 1) │ while (CalcTreeWidth(nHeight) > 1)
nHeight++; │ nHeight++;
// traverse the partial tree │ // traverse the partial tree
unsigned int nBitsUsed = 0, nHashUsed = 0; │ unsigned int nBitsUsed = 0, nHashUsed = 0;
uint256 hashMerkleRoot = TraverseAndExtract(nHeight, 0, nBitsUsed, nHashUsed, vMatch │ uint256 hashMerkleRoot = TraverseAndExtract(nHeight, 0, nBitsUsed, nHashUsed, vMatch
// verify that no problems occurred during the tree traversal │ // verify that no problems occurred during the tree traversal
if (fBad) │ if (fBad)
return uint256(); │ return uint256();
// verify that all bits were consumed (except for the padding caused by serializing │ // verify that all bits were consumed (except for the padding caused by serializing
if ((nBitsUsed+7)/8 != (vBits.size()+7)/8) │ if ((nBitsUsed+7)/8 != (vBits.size()+7)/8)
return uint256(); │ return uint256();
// verify that all hashes were consumed │ // verify that all hashes were consumed
if (nHashUsed != vHash.size()) │ if (nHashUsed != vHash.size())
return uint256(); │ return uint256();
return hashMerkleRoot; │ return hashMerkleRoot;
} │
next prev up bitcoin/src/wallet/test/ismine_tests.cpp:285 │ bitcoin/src/wallet/test/ismine_tests.cpp:311
│
CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase()); │ CWallet keystore(chain.get(), "", m_args, CreateDummyWalletDatabase());
keystore.SetupLegacyScriptPubKeyMan(); │ keystore.SetupLegacyScriptPubKeyMan();
LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore); │ LOCK(keystore.GetLegacyScriptPubKeyMan()->cs_KeyStore);
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[0])); │ BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(uncompressedKey));
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[1])); │ BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddKey(keys[1]));
│
CScript witnessScript = GetScriptForMultisig(2, {pubkeys[0], pubkeys[1]}); │ CScript witnessScript = GetScriptForMultisig(2, {uncompressedPubkey, pubkeys[1]}
scriptPubKey = GetScriptForDestination(WitnessV0ScriptHash(witnessScript)); │ scriptPubKey = GetScriptForDestination(WitnessV0ScriptHash(witnessScript));
│
// Keystore has keys, but no witnessScript or P2SH redeemScript │ // Keystore has keys, but no witnessScript or P2SH redeemScript
result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey); │ result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
BOOST_CHECK_EQUAL(result, ISMINE_NO); │ BOOST_CHECK_EQUAL(result, ISMINE_NO);
│
// Keystore has keys and witnessScript, but no P2SH redeemScript │ // Keystore has keys and witnessScript, but no P2SH redeemScript
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(witnessScript)); │ BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(witnessScript));
result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey); │ result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
BOOST_CHECK_EQUAL(result, ISMINE_NO); │ BOOST_CHECK_EQUAL(result, ISMINE_NO);
│
// Keystore has keys, witnessScript, P2SH redeemScript │ // Keystore has keys, witnessScript, P2SH redeemScript
BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(scriptPubKey)); │ BOOST_CHECK(keystore.GetLegacyScriptPubKeyMan()->AddCScript(scriptPubKey));
result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey); │ result = keystore.GetLegacyScriptPubKeyMan()->IsMine(scriptPubKey);
BOOST_CHECK_EQUAL(result, ISMINE_SPENDABLE); │ BOOST_CHECK_EQUAL(result, ISMINE_NO);
} │
next prev up dogecoin/src/addrdb.cpp:122 │ dogecoin/src/addrdb.cpp:25
│
// Generate random temporary filename │ // Generate random temporary filename
unsigned short randv = 0; │ unsigned short randv = 0;
GetRandBytes((unsigned char*)&randv, sizeof(randv)); │ GetRandBytes((unsigned char*)&randv, sizeof(randv));
std::string tmpfn = strprintf("peers.dat.%04x", randv); │ std::string tmpfn = strprintf("banlist.dat.%04x", randv);
│
// serialize addresses, checksum data up to that point, then append csum │ // serialize banlist, checksum data up to that point, then append csum
CDataStream ssPeers(SER_DISK, CLIENT_VERSION); │ CDataStream ssBanlist(SER_DISK, CLIENT_VERSION);
ssPeers << FLATDATA(Params().MessageStart()); │ ssBanlist << FLATDATA(Params().MessageStart());
ssPeers << addr; │ ssBanlist << banSet;
uint256 hash = Hash(ssPeers.begin(), ssPeers.end()); │ uint256 hash = Hash(ssBanlist.begin(), ssBanlist.end());
ssPeers << hash; │ ssBanlist << hash;
│
// open temp output file, and associate with CAutoFile │ // open temp output file, and associate with CAutoFile
boost::filesystem::path pathTmp = GetDataDir() / tmpfn; │ boost::filesystem::path pathTmp = GetDataDir() / tmpfn;
FILE *file = fopen(pathTmp.string().c_str(), "wb"); │ FILE *file = fopen(pathTmp.string().c_str(), "wb");
CAutoFile fileout(file, SER_DISK, CLIENT_VERSION); │ CAutoFile fileout(file, SER_DISK, CLIENT_VERSION);
if (fileout.IsNull()) │ if (fileout.IsNull())
return error("%s: Failed to open file %s", __func__, pathTmp.string()); │ return error("%s: Failed to open file %s", __func__, pathTmp.string());
│
// Write and commit header, data │ // Write and commit header, data
try { │ try {
fileout << ssPeers; │ fileout << ssBanlist;
} │ }
catch (const std::exception& e) { │ catch (const std::exception& e) {
return error("%s: Serialize or I/O error - %s", __func__, e.what()); │ return error("%s: Serialize or I/O error - %s", __func__, e.what());
} │ }
FileCommit(fileout.Get()); │ FileCommit(fileout.Get());
fileout.fclose(); │ fileout.fclose();
│
// replace existing peers.dat, if any, with new peers.dat.XXXX │ // replace existing banlist.dat, if any, with new banlist.dat.XXXX
if (!RenameOver(pathTmp, pathAddr)) │ if (!RenameOver(pathTmp, pathBanlist))
return error("%s: Rename-into-place failed", __func__); │ return error("%s: Rename-into-place failed", __func__);
│
return true; │ return true;
} │
next prev up bitcoin/src/netbase.cpp:397 │ dogecoin/src/netbase.cpp:315
│
// Perform username/password authentication (as described in RFC1929) │ // Perform username/password authentication (as described in RFC1929)
std::vector<uint8_t> vAuth; │ std::vector<uint8_t> vAuth;
vAuth.push_back(0x01); // Current (and only) version of user/pass subnegotiation │ vAuth.push_back(0x01);
if (auth->username.size() > 255 || auth->password.size() > 255) │ if (auth->username.size() > 255 || auth->password.size() > 255)
return error("Proxy username or password too long"); │ return error("Proxy username or password too long");
vAuth.push_back(auth->username.size()); │ vAuth.push_back(auth->username.size());
vAuth.insert(vAuth.end(), auth->username.begin(), auth->username.end()); │ vAuth.insert(vAuth.end(), auth->username.begin(), auth->username.end());
vAuth.push_back(auth->password.size()); │ vAuth.push_back(auth->password.size());
vAuth.insert(vAuth.end(), auth->password.begin(), auth->password.end()); │ vAuth.insert(vAuth.end(), auth->password.begin(), auth->password.end());
ret = sock.Send(vAuth.data(), vAuth.size(), MSG_NOSIGNAL); │ ret = send(hSocket, (const char*)vAuth.data(), vAuth.size(), MSG_NOSIGNAL);
if (ret != (ssize_t)vAuth.size()) { │ if (ret != (ssize_t)vAuth.size()) {
│ CloseSocket(hSocket);
return error("Error sending authentication to proxy"); │ return error("Error sending authentication to proxy");
} │ }
LogPrint(BCLog::PROXY, "SOCKS5 sending proxy authentication %s:%s\n", auth->user │ LogPrint("proxy", "SOCKS5 sending proxy authentication %s:%s\n", auth->username,
uint8_t pchRetA[2]; │ char pchRetA[2];
if ((recvr = InterruptibleRecv(pchRetA, 2, g_socks5_recv_timeout, sock)) != Intr │ if (( recvr = InterruptibleRecv(pchRetA, 2, SOCKS5_RECV_TIMEOUT, hSocket)) != In
│ CloseSocket(hSocket);
return error("Error reading proxy authentication response"); │ return error("Error reading proxy authentication response");
} │ }
if (pchRetA[0] != 0x01 || pchRetA[1] != 0x00) { │ if (pchRetA[0] != 0x01 || pchRetA[1] != 0x00) {
│ CloseSocket(hSocket);
return error("Proxy authentication unsuccessful"); │ return error("Proxy authentication unsuccessful");
} │ }
} │
next prev up bitcoin/src/net_processing.cpp:934 │ dogecoin/src/net_processing.cpp:339
│
const uint256& hash{block.GetBlockHash()}; │
│
CNodeState *state = State(nodeid); │ CNodeState *state = State(nodeid);
assert(state != nullptr); │ assert(state != NULL);
│
// Short-circuit most stuff in case it is from the same node │ // Short-circuit most stuff in case its from the same node
std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator> >::iterator it │ std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator> >::iterator it
if (itInFlight != mapBlocksInFlight.end() && itInFlight->second.first == nodeid) { │ if (itInFlight != mapBlocksInFlight.end() && itInFlight->second.first == nodeid) {
if (pit) { │ *pit = &itInFlight->second.second;
*pit = &itInFlight->second.second; │
} │
return false; │ return false;
} │ }
│
// Make sure it's not listed somewhere already. │ // Make sure it's not listed somewhere already.
RemoveBlockRequest(hash); │ MarkBlockAsReceived(hash);
│
std::list<QueuedBlock>::iterator it = state->vBlocksInFlight.insert(state->vBlocksIn │ std::list<QueuedBlock>::iterator it = state->vBlocksInFlight.insert(state->vBlocksIn
{&block, std::unique_ptr<PartiallyDownloadedBlock>(pit ? new PartiallyDownlo │ {hash, pindex, pindex != NULL, std::unique_ptr<PartiallyDownloadedBlock>(pit
state->nBlocksInFlight++; │ state->nBlocksInFlight++;
│ state->nBlocksInFlightValidHeaders += it->fValidatedHeaders;
if (state->nBlocksInFlight == 1) { │ if (state->nBlocksInFlight == 1) {
// We're starting a block download (batch) from this peer. │ // We're starting a block download (batch) from this peer.
state->m_downloading_since = GetTime<std::chrono::microseconds>(); │ state->nDownloadingSince = GetTimeMicros();
m_peers_downloading_from++; │ }
│ if (state->nBlocksInFlightValidHeaders == 1 && pindex != NULL) {
│ nPeersWithValidatedDownloads++;
} │ }
itInFlight = mapBlocksInFlight.insert(std::make_pair(hash, std::make_pair(nodeid, it │ itInFlight = mapBlocksInFlight.insert(std::make_pair(hash, std::make_pair(nodeid, it
if (pit) { │ if (pit)
*pit = &itInFlight->second.second; │ *pit = &itInFlight->second.second;
} │
return true; │ return true;
} │
next prev up dogecoin/src/test/transaction_tests.cpp:346 │ bitcoin/src/test/transaction_tests.cpp:410
│
CMutableTransaction outputm; │ CMutableTransaction outputm;
outputm.nVersion = 1; │ outputm.nVersion = 1;
outputm.vin.resize(1); │ outputm.vin.resize(1);
outputm.vin[0].prevout.SetNull(); │ outputm.vin[0].prevout.SetNull();
outputm.vin[0].scriptSig = CScript(); │ outputm.vin[0].scriptSig = CScript();
outputm.vout.resize(1); │ outputm.vout.resize(1);
outputm.vout[0].nValue = 1; │ outputm.vout[0].nValue = 1;
outputm.vout[0].scriptPubKey = outscript; │ outputm.vout[0].scriptPubKey = outscript;
CDataStream ssout(SER_NETWORK, PROTOCOL_VERSION); │ CDataStream ssout(SER_NETWORK, PROTOCOL_VERSION);
ssout << outputm; │ ssout << outputm;
ssout >> output; │ ssout >> output;
assert(output->vin.size() == 1); │ assert(output->vin.size() == 1);
assert(output->vin[0] == outputm.vin[0]); │ assert(output->vin[0] == outputm.vin[0]);
assert(output->vout.size() == 1); │ assert(output->vout.size() == 1);
assert(output->vout[0] == outputm.vout[0]); │ assert(output->vout[0] == outputm.vout[0]);
│
CMutableTransaction inputm; │ CMutableTransaction inputm;
inputm.nVersion = 1; │ inputm.nVersion = 1;
inputm.vin.resize(1); │ inputm.vin.resize(1);
inputm.vin[0].prevout.hash = output->GetHash(); │ inputm.vin[0].prevout.hash = output->GetHash();
inputm.vin[0].prevout.n = 0; │ inputm.vin[0].prevout.n = 0;
inputm.vout.resize(1); │ inputm.vout.resize(1);
inputm.vout[0].nValue = 1; │ inputm.vout[0].nValue = 1;
inputm.vout[0].scriptPubKey = CScript(); │ inputm.vout[0].scriptPubKey = CScript();
bool ret = SignSignature(keystore, *output, inputm, 0, SIGHASH_ALL); │ bool ret = SignSignature(keystore, *output, inputm, 0, SIGHASH_ALL);
assert(ret == success); │ assert(ret == success);
CDataStream ssin(SER_NETWORK, PROTOCOL_VERSION); │ CDataStream ssin(SER_NETWORK, PROTOCOL_VERSION);
ssin << inputm; │ ssin << inputm;
ssin >> input; │ ssin >> input;
assert(input.vin.size() == 1); │ assert(input.vin.size() == 1);
assert(input.vin[0] == inputm.vin[0]); │ assert(input.vin[0] == inputm.vin[0]);
assert(input.vout.size() == 1); │ assert(input.vout.size() == 1);
assert(input.vout[0] == inputm.vout[0]); │ assert(input.vout[0] == inputm.vout[0]);
assert(input.vin[0].scriptWitness.stack == inputm.vin[0].scriptWitness.stack); │ assert(input.vin[0].scriptWitness.stack == inputm.vin[0].scriptWitness.stack);
} │
next prev up dogecoin/src/rpc/mining.cpp:1042 │ dogecoin/src/rpc/mining.cpp:1192
│
if (pindexPrev != chainActive.Tip()) │ LOCK(cs_main);
│ if (pindexPrev != chainActive.Tip()
│ || (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast
│ && GetTime() - nStart > 60))
{ │ {
// Clear old blocks since they're obsolete now. │ if (pindexPrev != chainActive.Tip())
mapNewBlock.clear(); │ {
vNewBlockTemplate.clear(); │ // Clear old blocks since they're obsolete now.
curBlocks.clear(); │ mapNewBlock.clear();
pblock = nullptr; │ vNewBlockTemplate.clear();
} │ pblock = nullptr;
│ }
│
// Create new block with nonce = 0 and extraNonce = 1 │ // Create new block with nonce = 0 and extraNonce = 1
std::unique_ptr<CBlockTemplate> newBlock │ std::unique_ptr<CBlockTemplate> newBlock(BlockAssembler(Params()).Create
= BlockAssembler(Params()).CreateNewBlock(scriptPubKey, fMineWitnessTx); │ if (!newBlock)
if (!newBlock) │ throw JSONRPCError(RPC_OUT_OF_MEMORY, "out of memory");
throw JSONRPCError(RPC_OUT_OF_MEMORY, "out of memory"); │
│
// Update state only when CreateNewBlock succeeded │ // Update state only when CreateNewBlock succeeded
nTransactionsUpdatedLast = mempool.GetTransactionsUpdated(); │ nTransactionsUpdatedLast = mempool.GetTransactionsUpdated();
pindexPrev = chainActive.Tip(); │ pindexPrev = chainActive.Tip();
nStart = GetTime(); │ nStart = GetTime();
│
// Finalise it by setting the version and building the merkle root │ // Finalise it by setting the version and building the merkle root
IncrementExtraNonce(&newBlock->block, pindexPrev, nExtraNonce); │ IncrementExtraNonce(&newBlock->block, pindexPrev, nExtraNonce);
newBlock->block.SetAuxpowFlag(true); │ newBlock->block.SetAuxpowFlag(true);
│
// Save │ // Save
pblock = &newBlock->block; │ pblock = &newBlock->block;
curBlocks[scriptID] = pblock; │ mapNewBlock[pblock->GetHash()] = pblock;
mapNewBlock[pblock->GetHash()] = pblock; │ vNewBlockTemplate.push_back(std::move(newBlock));
vNewBlockTemplate.push_back(std::move(newBlock)); │ }
} │
next prev up bitcoin/src/minisketch/src/fields/clmul_8bytes.cpp:127 │ bitcoin/src/minisketch/src/fields/generic_8bytes.cpp:90
0x19c9369f278adc02, 0x84b2b22ab2383ee4, 0x84b2b22ab2383ee6, 0x9d7b84b495b3e3f6, 0x84b2b2 │ 0x19c9369f278adc02, 0x84b2b22ab2383ee4, 0x84b2b22ab2383ee6, 0x9d7b84b495b3e3f6, 0x84b2b
next prev up bitcoin/src/txmempool.cpp:916 │ dogecoin/src/txmempool.cpp:922
│
{ │ {
LOCK(cs); │ LOCK(cs);
CAmount &delta = mapDeltas[hash]; │ std::pair<double, CAmount> &deltas = mapDeltas[hash];
delta += nFeeDelta; │ deltas.first += dPriorityDelta;
│ deltas.second += nFeeDelta;
txiter it = mapTx.find(hash); │ txiter it = mapTx.find(hash);
if (it != mapTx.end()) { │ if (it != mapTx.end()) {
mapTx.modify(it, [&delta](CTxMemPoolEntry& e) { e.UpdateFeeDelta(delta); }); │ mapTx.modify(it, update_fee_delta(deltas.second));
// Now update all ancestors' modified fees with descendants │ // Now update all ancestors' modified fees with descendants
setEntries setAncestors; │ setEntries setAncestors;
uint64_t nNoLimit = std::numeric_limits<uint64_t>::max(); │ uint64_t nNoLimit = std::numeric_limits<uint64_t>::max();
std::string dummy; │ std::string dummy;
CalculateMemPoolAncestors(*it, setAncestors, nNoLimit, nNoLimit, nNoLimit, n │ CalculateMemPoolAncestors(*it, setAncestors, nNoLimit, nNoLimit, nNoLimit, n
for (txiter ancestorIt : setAncestors) { │ BOOST_FOREACH(txiter ancestorIt, setAncestors) {
mapTx.modify(ancestorIt, update_descendant_state(0, nFeeDelta, 0)); │ mapTx.modify(ancestorIt, update_descendant_state(0, nFeeDelta, 0));
} │ }
// Now update all descendants' modified fees with ancestors │ // Now update all descendants' modified fees with ancestors
setEntries setDescendants; │ setEntries setDescendants;
CalculateDescendants(it, setDescendants); │ CalculateDescendants(it, setDescendants);
setDescendants.erase(it); │ setDescendants.erase(it);
for (txiter descendantIt : setDescendants) { │ BOOST_FOREACH(txiter descendantIt, setDescendants) {
mapTx.modify(descendantIt, update_ancestor_state(0, nFeeDelta, 0, 0)); │ mapTx.modify(descendantIt, update_ancestor_state(0, nFeeDelta, 0, 0));
} │ }
++nTransactionsUpdated; │ ++nTransactionsUpdated;
} │ }
} │ }
LogPrintf("PrioritiseTransaction: %s fee += %s\n", hash.ToString(), FormatMoney(nFee │ LogPrintf("PrioritiseTransaction: %s priority += %f, fee += %d\n", strHash, dPriorit
} │
next prev up bitcoin/src/hash.cpp:18 │ dogecoin/src/hash.cpp:17
│
// The following is MurmurHash3 (x86_32), see https://code.google.com/p/smhasher/sou │ // The following is MurmurHash3 (x86_32), see http://code.google.com/p/smhasher/sour
uint32_t h1 = nHashSeed; │ uint32_t h1 = nHashSeed;
const uint32_t c1 = 0xcc9e2d51; │ if (vDataToHash.size() > 0)
const uint32_t c2 = 0x1b873593; │ {
│ const uint32_t c1 = 0xcc9e2d51;
│ const uint32_t c2 = 0x1b873593;
│
│ const int nblocks = vDataToHash.size() / 4;
│
│ //----------
│ // body
│ const uint8_t* blocks = &vDataToHash[0] + nblocks * 4;
│
const int nblocks = vDataToHash.size() / 4; │ for (int i = -nblocks; i; i++) {
│ uint32_t k1 = ReadLE32(blocks + i*4);
│
//---------- │ k1 *= c1;
// body │ k1 = ROTL32(k1, 15);
const uint8_t* blocks = vDataToHash.data(); │ k1 *= c2;
│
for (int i = 0; i < nblocks; ++i) { │
uint32_t k1 = ReadLE32(blocks + i*4); │
│
k1 *= c1; │
k1 = ROTL32(k1, 15); │
k1 *= c2; │
│
h1 ^= k1; │ h1 ^= k1;
h1 = ROTL32(h1, 13); │ h1 = ROTL32(h1, 13);
h1 = h1 * 5 + 0xe6546b64; │ h1 = h1 * 5 + 0xe6546b64;
} │ }
│
//---------- │ //----------
// tail │ // tail
const uint8_t* tail = vDataToHash.data() + nblocks * 4; │ const uint8_t* tail = (const uint8_t*)(&vDataToHash[0] + nblocks * 4);
│
uint32_t k1 = 0; │ uint32_t k1 = 0;
│
switch (vDataToHash.size() & 3) { │ switch (vDataToHash.size() & 3) {
case 3: │ case 3:
k1 ^= tail[2] << 16; │ k1 ^= tail[2] << 16;
[[fallthrough]]; │ // Falls through
case 2: │ case 2:
k1 ^= tail[1] << 8; │ k1 ^= tail[1] << 8;
[[fallthrough]]; │ // Falls through
case 1: │ case 1:
k1 ^= tail[0]; │ k1 ^= tail[0];
k1 *= c1; │ k1 *= c1;
k1 = ROTL32(k1, 15); │ k1 = ROTL32(k1, 15);
k1 *= c2; │ k1 *= c2;
h1 ^= k1; │ h1 ^= k1;
│ }
} │ }
│
//---------- │ //----------
// finalization │ // finalization
h1 ^= vDataToHash.size(); │ h1 ^= vDataToHash.size();
h1 ^= h1 >> 16; │ h1 ^= h1 >> 16;
h1 *= 0x85ebca6b; │ h1 *= 0x85ebca6b;
h1 ^= h1 >> 13; │ h1 ^= h1 >> 13;
h1 *= 0xc2b2ae35; │ h1 *= 0xc2b2ae35;
h1 ^= h1 >> 16; │ h1 ^= h1 >> 16;
│
return h1; │ return h1;
} │
next prev up bitcoin/src/qt/guiutil.cpp:298 │ dogecoin/src/qt/guiutil.cpp:307
│
QString selectedFilter; │ QString selectedFilter;
QString myDir; │ QString myDir;
if(dir.isEmpty()) // Default to user documents location │ if(dir.isEmpty()) // Default to user documents location
{ │ {
│ #if QT_VERSION < 0x050000
│ myDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
│ #else
myDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); │ myDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation);
│ #endif
} │ }
else │ else
{ │ {
myDir = dir; │ myDir = dir;
} │ }
/* Directly convert path to native OS path separators */ │ /* Directly convert path to native OS path separators */
QString result = QDir::toNativeSeparators(QFileDialog::getSaveFileName(parent, capti │ QString result = QDir::toNativeSeparators(QFileDialog::getSaveFileName(parent, capti
│
/* Extract first suffix from filter pattern "Description (*.foo)" or "Description (* │ /* Extract first suffix from filter pattern "Description (*.foo)" or "Description (*
QRegExp filter_re(".* \\(\\*\\.(.*)[ \\)]"); │ QRegExp filter_re(".* \\(\\*\\.(.*)[ \\)]");
QString selectedSuffix; │ QString selectedSuffix;
if(filter_re.exactMatch(selectedFilter)) │ if(filter_re.exactMatch(selectedFilter))
{ │ {
selectedSuffix = filter_re.cap(1); │ selectedSuffix = filter_re.cap(1);
} │ }
│
/* Add suffix if needed */ │ /* Add suffix if needed */
QFileInfo info(result); │ QFileInfo info(result);
if(!result.isEmpty()) │ if(!result.isEmpty())
{ │ {
if(info.suffix().isEmpty() && !selectedSuffix.isEmpty()) │ if(info.suffix().isEmpty() && !selectedSuffix.isEmpty())
{ │ {
/* No suffix specified, add selected suffix */ │ /* No suffix specified, add selected suffix */
if(!result.endsWith(".")) │ if(!result.endsWith("."))
result.append("."); │ result.append(".");
result.append(selectedSuffix); │ result.append(selectedSuffix);
} │ }
} │ }
│
/* Return selected suffix if asked to */ │ /* Return selected suffix if asked to */
if(selectedSuffixOut) │ if(selectedSuffixOut)
{ │ {
*selectedSuffixOut = selectedSuffix; │ *selectedSuffixOut = selectedSuffix;
} │ }
return result; │ return result;
} │
next prev up bitcoin/src/qt/bitcoingui.cpp:1318 │ dogecoin/src/qt/bitcoingui.cpp:1081
│
switch(status) │ switch(status)
{ │ {
case WalletModel::Unencrypted: │ case WalletModel::Unencrypted:
labelWalletEncryptionIcon->hide(); │ labelWalletEncryptionIcon->hide();
encryptWalletAction->setChecked(false); │ encryptWalletAction->setChecked(false);
changePassphraseAction->setEnabled(false); │ changePassphraseAction->setEnabled(false);
encryptWalletAction->setEnabled(true); │ encryptWalletAction->setEnabled(true);
break; │ break;
case WalletModel::Unlocked: │ case WalletModel::Unlocked:
labelWalletEncryptionIcon->show(); │ labelWalletEncryptionIcon->show();
labelWalletEncryptionIcon->setThemedPixmap(QStringLiteral(":/icons/lock_open"), │ labelWalletEncryptionIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/loc
labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and current │ labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and current
encryptWalletAction->setChecked(true); │ encryptWalletAction->setChecked(true);
changePassphraseAction->setEnabled(true); │ changePassphraseAction->setEnabled(true);
encryptWalletAction->setEnabled(false); │ encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
break; │ break;
case WalletModel::Locked: │ case WalletModel::Locked:
labelWalletEncryptionIcon->show(); │ labelWalletEncryptionIcon->show();
labelWalletEncryptionIcon->setThemedPixmap(QStringLiteral(":/icons/lock_closed") │ labelWalletEncryptionIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/loc
labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and current │ labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and current
encryptWalletAction->setChecked(true); │ encryptWalletAction->setChecked(true);
changePassphraseAction->setEnabled(true); │ changePassphraseAction->setEnabled(true);
encryptWalletAction->setEnabled(false); │ encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
break; │ break;
} │ }
} │
next prev up bitcoin/src/test/rpc_tests.cpp:125 │ dogecoin/src/test/rpc_tests.cpp:127
│
BOOST_CHECK_NO_THROW(CallRPC("createrawtransaction [{\"txid\":\"a3b807410df0b60fcb97 │ BOOST_CHECK_NO_THROW(CallRPC("createrawtransaction [{\"txid\":\"a3b807410df0b60fcb97
│
│ // Allow more than one data transaction output
│ BOOST_CHECK_NO_THROW(CallRPC("createrawtransaction [{\"txid\":\"a3b807410df0b60fcb97
│
// Key not "data" (bad address) │ // Key not "data" (bad address)
BOOST_CHECK_THROW(CallRPC("createrawtransaction [{\"txid\":\"a3b807410df0b60fcb97367 │ BOOST_CHECK_THROW(CallRPC("createrawtransaction [{\"txid\":\"a3b807410df0b60fcb97367
│
// Bad hex encoding of data output │ // Bad hex encoding of data output
BOOST_CHECK_THROW(CallRPC("createrawtransaction [{\"txid\":\"a3b807410df0b60fcb97367 │ BOOST_CHECK_THROW(CallRPC("createrawtransaction [{\"txid\":\"a3b807410df0b60fcb97367
BOOST_CHECK_THROW(CallRPC("createrawtransaction [{\"txid\":\"a3b807410df0b60fcb97367 │ BOOST_CHECK_THROW(CallRPC("createrawtransaction [{\"txid\":\"a3b807410df0b60fcb97367
│
// Data 81 bytes long │ // Data 81 bytes long
BOOST_CHECK_NO_THROW(CallRPC("createrawtransaction [{\"txid\":\"a3b807410df0b60fcb97 │ BOOST_CHECK_NO_THROW(CallRPC("createrawtransaction [{\"txid\":\"a3b807410df0b60fcb97
} │
next prev up dogecoin/src/rpc/rawtransaction.cpp:407 │ bitcoin/src/rpc/rawtransaction_util.cpp:49
│
const UniValue& input = inputs[idx]; │ const UniValue& input = inputs[idx];
const UniValue& o = input.get_obj(); │ const UniValue& o = input.get_obj();
│
uint256 txid = ParseHashO(o, "txid"); │ uint256 txid = ParseHashO(o, "txid");
│
const UniValue& vout_v = find_value(o, "vout"); │ const UniValue& vout_v = find_value(o, "vout");
if (!vout_v.isNum()) │ if (!vout_v.isNum())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing vout k │ throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, missing vout k
int nOutput = vout_v.get_int(); │ int nOutput = vout_v.get_int();
if (nOutput < 0) │ if (nOutput < 0)
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, vout must be p │ throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, vout cannot be
│
uint32_t nSequence = (rawTx.nLockTime ? std::numeric_limits<uint32_t>::max() - 1 │ uint32_t nSequence;
│ if (rbf) {
│ nSequence = MAX_BIP125_RBF_SEQUENCE; /* CTxIn::SEQUENCE_FINAL - 2 */
│ } else if (rawTx.nLockTime) {
│ nSequence = CTxIn::MAX_SEQUENCE_NONFINAL; /* CTxIn::SEQUENCE_FINAL - 1 */
│ } else {
│ nSequence = CTxIn::SEQUENCE_FINAL;
│ }
│
// set the sequence number if passed in the parameters object │ // set the sequence number if passed in the parameters object
const UniValue& sequenceObj = find_value(o, "sequence"); │ const UniValue& sequenceObj = find_value(o, "sequence");
if (sequenceObj.isNum()) { │ if (sequenceObj.isNum()) {
int64_t seqNr64 = sequenceObj.get_int64(); │ int64_t seqNr64 = sequenceObj.get_int64();
if (seqNr64 < 0 || seqNr64 > std::numeric_limits<uint32_t>::max()) │ if (seqNr64 < 0 || seqNr64 > CTxIn::SEQUENCE_FINAL) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, sequence n │ throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, sequence n
else │ } else {
nSequence = (uint32_t)seqNr64; │ nSequence = (uint32_t)seqNr64;
│ }
} │ }
│
CTxIn in(COutPoint(txid, nOutput), CScript(), nSequence); │ CTxIn in(COutPoint(txid, nOutput), CScript(), nSequence);
│
rawTx.vin.push_back(in); │ rawTx.vin.push_back(in);
} │
next prev up dogecoin/src/base58.cpp:72 │ bitcoin/src/base58.cpp:88
│
// Skip & count leading zeroes. │ // Skip & count leading zeroes.
int zeroes = 0; │ int zeroes = 0;
int length = 0; │ int length = 0;
while (pbegin != pend && *pbegin == 0) { │ while (input.size() > 0 && input[0] == 0) {
pbegin++; │ input = input.subspan(1);
zeroes++; │ zeroes++;
} │ }
// Allocate enough space in big-endian base58 representation. │ // Allocate enough space in big-endian base58 representation.
int size = (pend - pbegin) * 138 / 100 + 1; // log(256) / log(58), rounded up. │ int size = input.size() * 138 / 100 + 1; // log(256) / log(58), rounded up.
std::vector<unsigned char> b58(size); │ std::vector<unsigned char> b58(size);
// Process the bytes. │ // Process the bytes.
while (pbegin != pend) { │ while (input.size() > 0) {
int carry = *pbegin; │ int carry = input[0];
int i = 0; │ int i = 0;
// Apply "b58 = b58 * 256 + ch". │ // Apply "b58 = b58 * 256 + ch".
for (std::vector<unsigned char>::reverse_iterator it = b58.rbegin(); (carry != 0 │ for (std::vector<unsigned char>::reverse_iterator it = b58.rbegin(); (carry != 0
carry += 256 * (*it); │ carry += 256 * (*it);
*it = carry % 58; │ *it = carry % 58;
carry /= 58; │ carry /= 58;
} │ }
│
assert(carry == 0); │ assert(carry == 0);
length = i; │ length = i;
pbegin++; │ input = input.subspan(1);
} │ }
// Skip leading zeroes in base58 result. │ // Skip leading zeroes in base58 result.
std::vector<unsigned char>::iterator it = b58.begin() + (size - length); │ std::vector<unsigned char>::iterator it = b58.begin() + (size - length);
while (it != b58.end() && *it == 0) │ while (it != b58.end() && *it == 0)
it++; │ it++;
// Translate the result into a string. │ // Translate the result into a string.
std::string str; │ std::string str;
str.reserve(zeroes + (b58.end() - it)); │ str.reserve(zeroes + (b58.end() - it));
str.assign(zeroes, '1'); │ str.assign(zeroes, '1');
while (it != b58.end()) │ while (it != b58.end())
str += pszBase58[*(it++)]; │ str += pszBase58[*(it++)];
return str; │ return str;
} │
next prev up dogecoin/src/test/transaction_tests.cpp:289 │ dogecoin/src/bench/ccoins_caching.cpp:21
│
std::vector<CMutableTransaction> dummyTransactions; │ std::vector<CMutableTransaction> dummyTransactions;
dummyTransactions.resize(2); │ dummyTransactions.resize(2);
│
// Add some keys to the keystore: │ // Add some keys to the keystore:
CKey key[4]; │ CKey key[4];
for (int i = 0; i < 4; i++) │ for (int i = 0; i < 4; i++) {
{ │
key[i].MakeNewKey(i % 2); │ key[i].MakeNewKey(i % 2);
keystoreRet.AddKey(key[i]); │ keystoreRet.AddKey(key[i]);
} │ }
│
// Create some dummy input transactions │ // Create some dummy input transactions
dummyTransactions[0].vout.resize(2); │ dummyTransactions[0].vout.resize(2);
dummyTransactions[0].vout[0].nValue = 11*CENT; │ dummyTransactions[0].vout[0].nValue = 11 * CENT;
dummyTransactions[0].vout[0].scriptPubKey << ToByteVector(key[0].GetPubKey()) << OP_ │ dummyTransactions[0].vout[0].scriptPubKey << ToByteVector(key[0].GetPubKey()) << OP_
dummyTransactions[0].vout[1].nValue = 50*CENT; │ dummyTransactions[0].vout[1].nValue = 50 * CENT;
dummyTransactions[0].vout[1].scriptPubKey << ToByteVector(key[1].GetPubKey()) << OP_ │ dummyTransactions[0].vout[1].scriptPubKey << ToByteVector(key[1].GetPubKey()) << OP_
coinsRet.ModifyCoins(dummyTransactions[0].GetHash())->FromTx(dummyTransactions[0], 0 │ coinsRet.ModifyCoins(dummyTransactions[0].GetHash())->FromTx(dummyTransactions[0], 0
│
dummyTransactions[1].vout.resize(2); │ dummyTransactions[1].vout.resize(2);
dummyTransactions[1].vout[0].nValue = 21*CENT; │ dummyTransactions[1].vout[0].nValue = 21 * CENT;
dummyTransactions[1].vout[0].scriptPubKey = GetScriptForDestination(key[2].GetPubKey │ dummyTransactions[1].vout[0].scriptPubKey = GetScriptForDestination(key[2].GetPubKey
dummyTransactions[1].vout[1].nValue = 22*CENT; │ dummyTransactions[1].vout[1].nValue = 22 * CENT;
dummyTransactions[1].vout[1].scriptPubKey = GetScriptForDestination(key[3].GetPubKey │ dummyTransactions[1].vout[1].scriptPubKey = GetScriptForDestination(key[3].GetPubKey
coinsRet.ModifyCoins(dummyTransactions[1].GetHash())->FromTx(dummyTransactions[1], 0 │ coinsRet.ModifyCoins(dummyTransactions[1].GetHash())->FromTx(dummyTransactions[1], 0
│
return dummyTransactions; │ return dummyTransactions;
} │
next prev up dogecoin/src/bloom.cpp:250 │ bitcoin/src/common/bloom.cpp:196
│
if (nEntriesThisGeneration == nEntriesPerGeneration) { │ if (nEntriesThisGeneration == nEntriesPerGeneration) {
nEntriesThisGeneration = 0; │ nEntriesThisGeneration = 0;
nGeneration++; │ nGeneration++;
if (nGeneration == 4) { │ if (nGeneration == 4) {
nGeneration = 1; │ nGeneration = 1;
} │ }
uint64_t nGenerationMask1 = -(uint64_t)(nGeneration & 1); │ uint64_t nGenerationMask1 = 0 - (uint64_t)(nGeneration & 1);
uint64_t nGenerationMask2 = -(uint64_t)(nGeneration >> 1); │ uint64_t nGenerationMask2 = 0 - (uint64_t)(nGeneration >> 1);
/* Wipe old entries that used this generation number. */ │ /* Wipe old entries that used this generation number. */
for (uint32_t p = 0; p < data.size(); p += 2) { │ for (uint32_t p = 0; p < data.size(); p += 2) {
uint64_t p1 = data[p], p2 = data[p + 1]; │ uint64_t p1 = data[p], p2 = data[p + 1];
uint64_t mask = (p1 ^ nGenerationMask1) | (p2 ^ nGenerationMask2); │ uint64_t mask = (p1 ^ nGenerationMask1) | (p2 ^ nGenerationMask2);
data[p] = p1 & mask; │ data[p] = p1 & mask;
data[p + 1] = p2 & mask; │ data[p + 1] = p2 & mask;
} │ }
} │ }
nEntriesThisGeneration++; │ nEntriesThisGeneration++;
│
for (int n = 0; n < nHashFuncs; n++) { │ for (int n = 0; n < nHashFuncs; n++) {
uint32_t h = RollingBloomHash(n, nTweak, vKey); │ uint32_t h = RollingBloomHash(n, nTweak, vKey);
int bit = h & 0x3F; │ int bit = h & 0x3F;
uint32_t pos = (h >> 6) % data.size(); │ /* FastMod works with the upper bits of h, so it is safe to ignore that the lowe
│ uint32_t pos = FastRange32(h, data.size());
/* The lowest bit of pos is ignored, and set to zero for the first bit, and to o │ /* The lowest bit of pos is ignored, and set to zero for the first bit, and to o
data[pos & ~1] = (data[pos & ~1] & ~(((uint64_t)1) << bit)) | ((uint64_t)(nGener │ data[pos & ~1U] = (data[pos & ~1U] & ~(uint64_t{1} << bit)) | (uint64_t(nGenerat
data[pos | 1] = (data[pos | 1] & ~(((uint64_t)1) << bit)) | ((uint64_t)(nGenerat │ data[pos | 1] = (data[pos | 1] & ~(uint64_t{1} << bit)) | (uint64_t(nGeneration
} │ }
} │
next prev up dogecoin/src/qt/guiutil.cpp:1009 │ bitcoin/src/qt/guiutil.cpp:770
│
// Represent time from last generated block in human readable text │ // Represent time from last generated block in human readable text
QString timeBehindText; │ QString timeBehindText;
const int HOUR_IN_SECONDS = 60*60; │ const int HOUR_IN_SECONDS = 60*60;
const int DAY_IN_SECONDS = 24*60*60; │ const int DAY_IN_SECONDS = 24*60*60;
const int WEEK_IN_SECONDS = 7*24*60*60; │ const int WEEK_IN_SECONDS = 7*24*60*60;
const int YEAR_IN_SECONDS = 31556952; // Average length of year in Gregorian calenda │ const int YEAR_IN_SECONDS = 31556952; // Average length of year in Gregorian calenda
if(secs < 60) │ if(secs < 60)
{ │ {
timeBehindText = QObject::tr("%n second(s)","",secs); │ timeBehindText = QObject::tr("%n second(s)","",secs);
} │ }
else if(secs < 2*HOUR_IN_SECONDS) │ else if(secs < 2*HOUR_IN_SECONDS)
{ │ {
timeBehindText = QObject::tr("%n minute(s)","",secs/60); │ timeBehindText = QObject::tr("%n minute(s)","",secs/60);
} │ }
else if(secs < 2*DAY_IN_SECONDS) │ else if(secs < 2*DAY_IN_SECONDS)
{ │ {
timeBehindText = QObject::tr("%n hour(s)","",secs/HOUR_IN_SECONDS); │ timeBehindText = QObject::tr("%n hour(s)","",secs/HOUR_IN_SECONDS);
} │ }
else if(secs < 2*WEEK_IN_SECONDS) │ else if(secs < 2*WEEK_IN_SECONDS)
{ │ {
timeBehindText = QObject::tr("%n day(s)","",secs/DAY_IN_SECONDS); │ timeBehindText = QObject::tr("%n day(s)","",secs/DAY_IN_SECONDS);
} │ }
else if(secs < YEAR_IN_SECONDS) │ else if(secs < YEAR_IN_SECONDS)
{ │ {
timeBehindText = QObject::tr("%n week(s)","",secs/WEEK_IN_SECONDS); │ timeBehindText = QObject::tr("%n week(s)","",secs/WEEK_IN_SECONDS);
} │ }
else │ else
{ │ {
qint64 years = secs / YEAR_IN_SECONDS; │ qint64 years = secs / YEAR_IN_SECONDS;
qint64 remainder = secs % YEAR_IN_SECONDS; │ qint64 remainder = secs % YEAR_IN_SECONDS;
timeBehindText = QObject::tr("%1 and %2").arg(QObject::tr("%n year(s)", "", year │ timeBehindText = QObject::tr("%1 and %2").arg(QObject::tr("%n year(s)", "", year
} │ }
return timeBehindText; │ return timeBehindText;
} │
next prev up dogecoin/src/core_write.cpp:22 │ bitcoin/src/core_write.cpp:40
│
std::string ret; │ std::string ret;
CScript::const_iterator it = script.begin(); │ CScript::const_iterator it = script.begin();
opcodetype op; │ opcodetype op;
while (it != script.end()) { │ while (it != script.end()) {
CScript::const_iterator it2 = it; │ CScript::const_iterator it2 = it;
std::vector<unsigned char> vch; │ std::vector<unsigned char> vch;
if (script.GetOp2(it, op, &vch)) { │ if (script.GetOp(it, op, vch)) {
if (op == OP_0) { │ if (op == OP_0) {
ret += "0 "; │ ret += "0 ";
continue; │ continue;
} else if ((op >= OP_1 && op <= OP_16) || op == OP_1NEGATE) { │ } else if ((op >= OP_1 && op <= OP_16) || op == OP_1NEGATE) {
ret += strprintf("%i ", op - OP_1NEGATE - 1); │ ret += strprintf("%i ", op - OP_1NEGATE - 1);
continue; │ continue;
} else if (op >= OP_NOP && op <= OP_NOP10) { │ } else if (op >= OP_NOP && op <= OP_NOP10) {
std::string str(GetOpName(op)); │ std::string str(GetOpName(op));
if (str.substr(0, 3) == std::string("OP_")) { │ if (str.substr(0, 3) == std::string("OP_")) {
ret += str.substr(3, std::string::npos) + " "; │ ret += str.substr(3, std::string::npos) + " ";
continue; │ continue;
} │ }
} │ }
if (vch.size() > 0) { │ if (vch.size() > 0) {
ret += strprintf("0x%x 0x%x ", HexStr(it2, it - vch.size()), HexStr(it - │ ret += strprintf("0x%x 0x%x ", HexStr(std::vector<uint8_t>(it2, it - vch
│ HexStr(std::vector<uint8_t>(it - vch.size
} else { │ } else {
ret += strprintf("0x%x ", HexStr(it2, it)); │ ret += strprintf("0x%x ", HexStr(std::vector<uint8_t>(it2, it)));
} │ }
continue; │ continue;
} │ }
ret += strprintf("0x%x ", HexStr(it2, script.end())); │ ret += strprintf("0x%x ", HexStr(std::vector<uint8_t>(it2, script.end())));
break; │ break;
} │ }
return ret.substr(0, ret.size() - 1); │ return ret.substr(0, ret.empty() ? ret.npos : ret.size() - 1);
} │
next prev up dogecoin/src/univalue/test/object.cpp:366 │ bitcoin/src/univalue/test/object.cpp:366
│
UniValue v; │ UniValue v;
BOOST_CHECK(v.read(json1)); │ BOOST_CHECK(v.read(json1));
│
std::string strJson1(json1); │ std::string strJson1(json1);
BOOST_CHECK(v.read(strJson1)); │ BOOST_CHECK(v.read(strJson1));
│
BOOST_CHECK(v.isArray()); │ BOOST_CHECK(v.isArray());
BOOST_CHECK_EQUAL(v.size(), 2); │ BOOST_CHECK_EQUAL(v.size(), 2);
│
BOOST_CHECK_EQUAL(v[0].getValStr(), "1.10000000"); │ BOOST_CHECK_EQUAL(v[0].getValStr(), "1.10000000");
│
UniValue obj = v[1]; │ UniValue obj = v[1];
BOOST_CHECK(obj.isObject()); │ BOOST_CHECK(obj.isObject());
BOOST_CHECK_EQUAL(obj.size(), 3); │ BOOST_CHECK_EQUAL(obj.size(), 3);
│
BOOST_CHECK(obj["key1"].isStr()); │ BOOST_CHECK(obj["key1"].isStr());
std::string correctValue("str"); │ std::string correctValue("str");
correctValue.push_back('\0'); │ correctValue.push_back('\0');
BOOST_CHECK_EQUAL(obj["key1"].getValStr(), correctValue); │ BOOST_CHECK_EQUAL(obj["key1"].getValStr(), correctValue);
BOOST_CHECK(obj["key2"].isNum()); │ BOOST_CHECK(obj["key2"].isNum());
BOOST_CHECK_EQUAL(obj["key2"].getValStr(), "800"); │ BOOST_CHECK_EQUAL(obj["key2"].getValStr(), "800");
BOOST_CHECK(obj["key3"].isObject()); │ BOOST_CHECK(obj["key3"].isObject());
│
BOOST_CHECK_EQUAL(strJson1, v.write()); │ BOOST_CHECK_EQUAL(strJson1, v.write());
│
/* Check for (correctly reporting) a parsing error if the initial │ /* Check for (correctly reporting) a parsing error if the initial
JSON construct is followed by more stuff. Note that whitespace │ JSON construct is followed by more stuff. Note that whitespace
is, of course, exempt. */ │ is, of course, exempt. */
│
BOOST_CHECK(v.read(" {}\n ")); │ BOOST_CHECK(v.read(" {}\n "));
BOOST_CHECK(v.isObject()); │ BOOST_CHECK(v.isObject());
BOOST_CHECK(v.read(" []\n ")); │ BOOST_CHECK(v.read(" []\n "));
BOOST_CHECK(v.isArray()); │ BOOST_CHECK(v.isArray());
│
BOOST_CHECK(!v.read("@{}")); │ BOOST_CHECK(!v.read("@{}"));
BOOST_CHECK(!v.read("{} garbage")); │ BOOST_CHECK(!v.read("{} garbage"));
BOOST_CHECK(!v.read("[]{}")); │ BOOST_CHECK(!v.read("[]{}"));
BOOST_CHECK(!v.read("{}[]")); │ BOOST_CHECK(!v.read("{}[]"));
BOOST_CHECK(!v.read("{} 42")); │ BOOST_CHECK(!v.read("{} 42"));
} │
next prev up dogecoin/src/test/univalue_tests.cpp:291 │ bitcoin/src/univalue/test/object.cpp:366
│
UniValue v; │ UniValue v;
BOOST_CHECK(v.read(json1)); │ BOOST_CHECK(v.read(json1));
│
std::string strJson1(json1); │ std::string strJson1(json1);
BOOST_CHECK(v.read(strJson1)); │ BOOST_CHECK(v.read(strJson1));
│
BOOST_CHECK(v.isArray()); │ BOOST_CHECK(v.isArray());
BOOST_CHECK_EQUAL(v.size(), 2); │ BOOST_CHECK_EQUAL(v.size(), 2);
│
BOOST_CHECK_EQUAL(v[0].getValStr(), "1.10000000"); │ BOOST_CHECK_EQUAL(v[0].getValStr(), "1.10000000");
│
UniValue obj = v[1]; │ UniValue obj = v[1];
BOOST_CHECK(obj.isObject()); │ BOOST_CHECK(obj.isObject());
BOOST_CHECK_EQUAL(obj.size(), 3); │ BOOST_CHECK_EQUAL(obj.size(), 3);
│
BOOST_CHECK(obj["key1"].isStr()); │ BOOST_CHECK(obj["key1"].isStr());
std::string correctValue("str"); │ std::string correctValue("str");
correctValue.push_back('\0'); │ correctValue.push_back('\0');
BOOST_CHECK_EQUAL(obj["key1"].getValStr(), correctValue); │ BOOST_CHECK_EQUAL(obj["key1"].getValStr(), correctValue);
BOOST_CHECK(obj["key2"].isNum()); │ BOOST_CHECK(obj["key2"].isNum());
BOOST_CHECK_EQUAL(obj["key2"].getValStr(), "800"); │ BOOST_CHECK_EQUAL(obj["key2"].getValStr(), "800");
BOOST_CHECK(obj["key3"].isObject()); │ BOOST_CHECK(obj["key3"].isObject());
│
BOOST_CHECK_EQUAL(strJson1, v.write()); │ BOOST_CHECK_EQUAL(strJson1, v.write());
│
/* Check for (correctly reporting) a parsing error if the initial │ /* Check for (correctly reporting) a parsing error if the initial
JSON construct is followed by more stuff. Note that whitespace │ JSON construct is followed by more stuff. Note that whitespace
is, of course, exempt. */ │ is, of course, exempt. */
│
BOOST_CHECK(v.read(" {}\n ")); │ BOOST_CHECK(v.read(" {}\n "));
BOOST_CHECK(v.isObject()); │ BOOST_CHECK(v.isObject());
BOOST_CHECK(v.read(" []\n ")); │ BOOST_CHECK(v.read(" []\n "));
BOOST_CHECK(v.isArray()); │ BOOST_CHECK(v.isArray());
│
BOOST_CHECK(!v.read("@{}")); │ BOOST_CHECK(!v.read("@{}"));
BOOST_CHECK(!v.read("{} garbage")); │ BOOST_CHECK(!v.read("{} garbage"));
BOOST_CHECK(!v.read("[]{}")); │ BOOST_CHECK(!v.read("[]{}"));
BOOST_CHECK(!v.read("{}[]")); │ BOOST_CHECK(!v.read("{}[]"));
BOOST_CHECK(!v.read("{} 42")); │ BOOST_CHECK(!v.read("{} 42"));
} │
next prev up dogecoin/src/test/univalue_tests.cpp:291 │ dogecoin/src/univalue/test/object.cpp:366
│
UniValue v; │ UniValue v;
BOOST_CHECK(v.read(json1)); │ BOOST_CHECK(v.read(json1));
│
std::string strJson1(json1); │ std::string strJson1(json1);
BOOST_CHECK(v.read(strJson1)); │ BOOST_CHECK(v.read(strJson1));
│
BOOST_CHECK(v.isArray()); │ BOOST_CHECK(v.isArray());
BOOST_CHECK_EQUAL(v.size(), 2); │ BOOST_CHECK_EQUAL(v.size(), 2);
│
BOOST_CHECK_EQUAL(v[0].getValStr(), "1.10000000"); │ BOOST_CHECK_EQUAL(v[0].getValStr(), "1.10000000");
│
UniValue obj = v[1]; │ UniValue obj = v[1];
BOOST_CHECK(obj.isObject()); │ BOOST_CHECK(obj.isObject());
BOOST_CHECK_EQUAL(obj.size(), 3); │ BOOST_CHECK_EQUAL(obj.size(), 3);
│
BOOST_CHECK(obj["key1"].isStr()); │ BOOST_CHECK(obj["key1"].isStr());
std::string correctValue("str"); │ std::string correctValue("str");
correctValue.push_back('\0'); │ correctValue.push_back('\0');
BOOST_CHECK_EQUAL(obj["key1"].getValStr(), correctValue); │ BOOST_CHECK_EQUAL(obj["key1"].getValStr(), correctValue);
BOOST_CHECK(obj["key2"].isNum()); │ BOOST_CHECK(obj["key2"].isNum());
BOOST_CHECK_EQUAL(obj["key2"].getValStr(), "800"); │ BOOST_CHECK_EQUAL(obj["key2"].getValStr(), "800");
BOOST_CHECK(obj["key3"].isObject()); │ BOOST_CHECK(obj["key3"].isObject());
│
BOOST_CHECK_EQUAL(strJson1, v.write()); │ BOOST_CHECK_EQUAL(strJson1, v.write());
│
/* Check for (correctly reporting) a parsing error if the initial │ /* Check for (correctly reporting) a parsing error if the initial
JSON construct is followed by more stuff. Note that whitespace │ JSON construct is followed by more stuff. Note that whitespace
is, of course, exempt. */ │ is, of course, exempt. */
│
BOOST_CHECK(v.read(" {}\n ")); │ BOOST_CHECK(v.read(" {}\n "));
BOOST_CHECK(v.isObject()); │ BOOST_CHECK(v.isObject());
BOOST_CHECK(v.read(" []\n ")); │ BOOST_CHECK(v.read(" []\n "));
BOOST_CHECK(v.isArray()); │ BOOST_CHECK(v.isArray());
│
BOOST_CHECK(!v.read("@{}")); │ BOOST_CHECK(!v.read("@{}"));
BOOST_CHECK(!v.read("{} garbage")); │ BOOST_CHECK(!v.read("{} garbage"));
BOOST_CHECK(!v.read("[]{}")); │ BOOST_CHECK(!v.read("[]{}"));
BOOST_CHECK(!v.read("{}[]")); │ BOOST_CHECK(!v.read("{}[]"));
BOOST_CHECK(!v.read("{} 42")); │ BOOST_CHECK(!v.read("{} 42"));
} │
next prev up bitcoin/src/wallet/rpc/addresses.cpp:88 │ bitcoin/src/wallet/rpc/addresses.cpp:35
│
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request); │ std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
if (!pwallet) return NullUniValue; │ if (!pwallet) return NullUniValue;
│
LOCK(pwallet->cs_wallet); │ LOCK(pwallet->cs_wallet);
│
if (!pwallet->CanGetAddresses(true)) { │ if (!pwallet->CanGetAddresses()) {
throw JSONRPCError(RPC_WALLET_ERROR, "Error: This wallet has no available keys") │ throw JSONRPCError(RPC_WALLET_ERROR, "Error: This wallet has no available keys")
} │ }
│
OutputType output_type = pwallet->m_default_change_type.value_or(pwallet->m_default_ │ // Parse the label first so we don't generate a key if there's an error
if (!request.params[0].isNull()) { │ std::string label;
std::optional<OutputType> parsed = ParseOutputType(request.params[0].get_str()); │ if (!request.params[0].isNull())
│ label = LabelFromValue(request.params[0]);
│
│ OutputType output_type = pwallet->m_default_address_type;
│ if (!request.params[1].isNull()) {
│ std::optional<OutputType> parsed = ParseOutputType(request.params[1].get_str());
if (!parsed) { │ if (!parsed) {
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Unknown address ty │ throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Unknown address ty
} else if (parsed.value() == OutputType::BECH32M && pwallet->GetLegacyScriptPubK │ } else if (parsed.value() == OutputType::BECH32M && pwallet->GetLegacyScriptPubK
throw JSONRPCError(RPC_INVALID_PARAMETER, "Legacy wallets cannot provide bec │ throw JSONRPCError(RPC_INVALID_PARAMETER, "Legacy wallets cannot provide bec
} │ }
output_type = parsed.value(); │ output_type = parsed.value();
} │ }
│
CTxDestination dest; │ CTxDestination dest;
bilingual_str error; │ bilingual_str error;
if (!pwallet->GetNewChangeDestination(output_type, dest, error)) { │ if (!pwallet->GetNewDestination(output_type, label, dest, error)) {
throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, error.original); │ throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, error.original);
} │ }
│
return EncodeDestination(dest); │ return EncodeDestination(dest);
} │
next prev up bitcoin/src/minisketch/src/fields/clmul_8bytes.cpp:102 │ bitcoin/src/minisketch/src/fields/generic_8bytes.cpp:72
0x30268b6fba455d2c, 0x200000006, 0x200000004, 0x3d67cb6c1fe66c76, 0x200000000, 0x3fc4f19 │ 0x30268b6fba455d2c, 0x200000006, 0x200000004, 0x3d67cb6c1fe66c76, 0x200000000, 0x3fc4f1
next prev up dogecoin/src/txmempool.cpp:142 │ bitcoin/src/txmempool.cpp:178
│
// we cache the in-mempool children to avoid duplicate updates │
setEntries setChildren; │
// calculate children from mapNextTx │ // calculate children from mapNextTx
txiter it = mapTx.find(hash); │ txiter it = mapTx.find(hash);
if (it == mapTx.end()) { │ if (it == mapTx.end()) {
continue; │ continue;
} │ }
auto iter = mapNextTx.lower_bound(COutPoint(hash, 0)); │ auto iter = mapNextTx.lower_bound(COutPoint(hash, 0));
// First calculate the children, and update setMemPoolChildren to │ // First calculate the children, and update CTxMemPool::m_children to
// include them, and update their setMemPoolParents to include this tx. │ // include them, and update their CTxMemPoolEntry::m_parents to include this tx.
for (; iter != mapNextTx.end() && iter->first->hash == hash; ++iter) { │ // we cache the in-mempool children to avoid duplicate updates
const uint256 &childHash = iter->second->GetHash(); │ {
txiter childIter = mapTx.find(childHash); │ WITH_FRESH_EPOCH(m_epoch);
assert(childIter != mapTx.end()); │ for (; iter != mapNextTx.end() && iter->first->hash == hash; ++iter) {
// We can skip updating entries we've encountered before or that │ const uint256 &childHash = iter->second->GetHash();
// are in the block (which are already accounted for). │ txiter childIter = mapTx.find(childHash);
if (setChildren.insert(childIter).second && !setAlreadyIncluded.count(childH │ assert(childIter != mapTx.end());
UpdateChild(it, childIter, true); │ // We can skip updating entries we've encountered before or that
UpdateParent(childIter, it, true); │ // are in the block (which are already accounted for).
│ if (!visited(childIter) && !setAlreadyIncluded.count(childHash)) {
│ UpdateChild(it, childIter, true);
│ UpdateParent(childIter, it, true);
│ }
} │ }
} │ } // release epoch guard for UpdateForDescendants
UpdateForDescendants(it, mapMemPoolDescendantsToUpdate, setAlreadyIncluded); │ UpdateForDescendants(it, mapMemPoolDescendantsToUpdate, setAlreadyIncluded, desc
} │
next prev up dogecoin/src/policy/fees.cpp:315 │ bitcoin/src/policy/fees.cpp:545
│
│ LOCK(m_cs_fee_estimator);
unsigned int txHeight = entry.GetHeight(); │ unsigned int txHeight = entry.GetHeight();
uint256 hash = entry.GetTx().GetHash(); │ uint256 hash = entry.GetTx().GetHash();
if (mapMemPoolTxs.count(hash)) { │ if (mapMemPoolTxs.count(hash)) {
LogPrint("estimatefee", "Blockpolicy error mempool tx %s already being tracked\n │ LogPrint(BCLog::ESTIMATEFEE, "Blockpolicy error mempool tx %s already being trac
hash.ToString().c_str()); │ hash.ToString());
return; │ return;
} │ }
│
if (txHeight != nBestSeenHeight) { │ if (txHeight != nBestSeenHeight) {
// Ignore side chains and re-orgs; assuming they are random they don't │ // Ignore side chains and re-orgs; assuming they are random they don't
// affect the estimate. We'll potentially double count transactions in 1-block │ // affect the estimate. We'll potentially double count transactions in 1-block
// Ignore txs if BlockPolicyEstimator is not in sync with chainActive.Tip(). │ // Ignore txs if BlockPolicyEstimator is not in sync with ActiveChain().Tip().
// It will be synced next time a block is processed. │ // It will be synced next time a block is processed.
return; │ return;
} │ }
│
// Only want to be updating estimates when our blockchain is synced, │ // Only want to be updating estimates when our blockchain is synced,
// otherwise we'll miscalculate how many blocks its taking to get included. │ // otherwise we'll miscalculate how many blocks its taking to get included.
if (!validFeeEstimate) { │ if (!validFeeEstimate) {
untrackedTxs++; │ untrackedTxs++;
return; │ return;
} │ }
trackedTxs++; │ trackedTxs++;
│
// Feerates are stored and reported as BTC-per-kb: │ // Feerates are stored and reported as BTC-per-kb:
CFeeRate feeRate(entry.GetFee(), entry.GetTxSize()); │ CFeeRate feeRate(entry.GetFee(), entry.GetTxSize());
│
mapMemPoolTxs[hash].blockHeight = txHeight; │ mapMemPoolTxs[hash].blockHeight = txHeight;
mapMemPoolTxs[hash].bucketIndex = feeStats.NewTx(txHeight, (double)feeRate.GetFeePer │ unsigned int bucketIndex = feeStats->NewTx(txHeight, (double)feeRate.GetFeePerK());
│ mapMemPoolTxs[hash].bucketIndex = bucketIndex;
│ unsigned int bucketIndex2 = shortStats->NewTx(txHeight, (double)feeRate.GetFeePerK()
│ assert(bucketIndex == bucketIndex2);
│ unsigned int bucketIndex3 = longStats->NewTx(txHeight, (double)feeRate.GetFeePerK())
│ assert(bucketIndex == bucketIndex3);
} │
next prev up dogecoin/src/qt/coincontroldialog.cpp:204 │ bitcoin/src/qt/coincontroldialog.cpp:177
│
QTreeWidgetItem *item = ui->treeWidget->itemAt(point); │ QTreeWidgetItem *item = ui->treeWidget->itemAt(point);
if(item) │ if(item)
{ │ {
contextMenuItem = item; │ contextMenuItem = item;
│
// disable some items (like Copy Transaction ID, lock, unlock) for tree roots in │ // disable some items (like Copy Transaction ID, lock, unlock) for tree roots in
if (item->text(COLUMN_TXHASH).length() == 64) // transaction hash is 64 characte │ if (item->data(COLUMN_ADDRESS, TxHashRole).toString().length() == 64) // transac
{ │ {
copyTransactionHashAction->setEnabled(true); │ m_copy_transaction_outpoint_action->setEnabled(true);
if (model->isLockedCoin(uint256S(item->text(COLUMN_TXHASH).toStdString()), i │ if (model->wallet().isLockedCoin(COutPoint(uint256S(item->data(COLUMN_ADDRES
{ │ {
lockAction->setEnabled(false); │ lockAction->setEnabled(false);
unlockAction->setEnabled(true); │ unlockAction->setEnabled(true);
} │ }
else │ else
{ │ {
lockAction->setEnabled(true); │ lockAction->setEnabled(true);
unlockAction->setEnabled(false); │ unlockAction->setEnabled(false);
} │ }
} │ }
else // this means click on parent node in tree mode -> disable all │ else // this means click on parent node in tree mode -> disable all
{ │ {
copyTransactionHashAction->setEnabled(false); │ m_copy_transaction_outpoint_action->setEnabled(false);
lockAction->setEnabled(false); │ lockAction->setEnabled(false);
unlockAction->setEnabled(false); │ unlockAction->setEnabled(false);
} │ }
│
// show context menu │ // show context menu
contextMenu->exec(QCursor::pos()); │ contextMenu->exec(QCursor::pos());
} │ }
} │
next prev up dogecoin/src/qt/transactionview.cpp:500 │ bitcoin/src/qt/transactionview.cpp:551
│
dateRangeWidget = new QFrame(); │ dateRangeWidget = new QFrame();
dateRangeWidget->setFrameStyle(QFrame::Panel | QFrame::Raised); │ dateRangeWidget->setFrameStyle(static_cast<int>(QFrame::Panel) | static_cast<int>(QF
dateRangeWidget->setContentsMargins(1,1,1,1); │ dateRangeWidget->setContentsMargins(1,1,1,1);
QHBoxLayout *layout = new QHBoxLayout(dateRangeWidget); │ QHBoxLayout *layout = new QHBoxLayout(dateRangeWidget);
layout->setContentsMargins(0,0,0,0); │ layout->setContentsMargins(0,0,0,0);
layout->addSpacing(23); │ layout->addSpacing(23);
layout->addWidget(new QLabel(tr("Range:"))); │ layout->addWidget(new QLabel(tr("Range:")));
│
dateFrom = new QDateTimeEdit(this); │ dateFrom = new QDateTimeEdit(this);
dateFrom->setDisplayFormat("dd/MM/yy"); │ dateFrom->setDisplayFormat("dd/MM/yy");
dateFrom->setCalendarPopup(true); │ dateFrom->setCalendarPopup(true);
dateFrom->setMinimumWidth(100); │ dateFrom->setMinimumWidth(100);
dateFrom->setDate(QDate::currentDate().addDays(-7)); │ dateFrom->setDate(QDate::currentDate().addDays(-7));
layout->addWidget(dateFrom); │ layout->addWidget(dateFrom);
layout->addWidget(new QLabel(tr("to"))); │ layout->addWidget(new QLabel(tr("to")));
│
dateTo = new QDateTimeEdit(this); │ dateTo = new QDateTimeEdit(this);
dateTo->setDisplayFormat("dd/MM/yy"); │ dateTo->setDisplayFormat("dd/MM/yy");
dateTo->setCalendarPopup(true); │ dateTo->setCalendarPopup(true);
dateTo->setMinimumWidth(100); │ dateTo->setMinimumWidth(100);
dateTo->setDate(QDate::currentDate()); │ dateTo->setDate(QDate::currentDate());
layout->addWidget(dateTo); │ layout->addWidget(dateTo);
layout->addStretch(); │ layout->addStretch();
│
// Hide by default │ // Hide by default
dateRangeWidget->setVisible(false); │ dateRangeWidget->setVisible(false);
│
// Notify on change │ // Notify on change
connect(dateFrom, SIGNAL(dateChanged(QDate)), this, SLOT(dateRangeChanged())); │ connect(dateFrom, &QDateTimeEdit::dateChanged, this, &TransactionView::dateRangeChan
connect(dateTo, SIGNAL(dateChanged(QDate)), this, SLOT(dateRangeChanged())); │ connect(dateTo, &QDateTimeEdit::dateChanged, this, &TransactionView::dateRangeChange
│
return dateRangeWidget; │ return dateRangeWidget;
} │
next prev up bitcoin/src/crypto/aes.cpp:82 │ dogecoin/src/crypto/aes.cpp:114
│
│ unsigned char padsize = 0;
int written = 0; │ int written = 0;
bool fail = false; │ bool fail = false;
const unsigned char* prev = iv; │ const unsigned char* prev = iv;
│
if (!data || !size || !out) │ if (!data || !size || !out)
return 0; │ return 0;
│
if (size % AES_BLOCKSIZE != 0) │ if (size % AES_BLOCKSIZE != 0)
return 0; │ return 0;
│
// Decrypt all data. Padding will be checked in the output. │ // Decrypt all data. Padding will be checked in the output.
while (written != size) { │ while (written != size) {
dec.Decrypt(out, data + written); │ dec.Decrypt(out, data + written);
for (int i = 0; i != AES_BLOCKSIZE; i++) │ for (int i = 0; i != AES_BLOCKSIZE; i++)
*out++ ^= prev[i]; │ *out++ ^= prev[i];
prev = data + written; │ prev = data + written;
written += AES_BLOCKSIZE; │ written += AES_BLOCKSIZE;
} │ }
│
// When decrypting padding, attempt to run in constant-time │ // When decrypting padding, attempt to run in constant-time
if (pad) { │ if (pad) {
// If used, padding size is the value of the last decrypted byte. For │ // If used, padding size is the value of the last decrypted byte. For
// it to be valid, It must be between 1 and AES_BLOCKSIZE. │ // it to be valid, It must be between 1 and AES_BLOCKSIZE.
unsigned char padsize = *--out; │ padsize = *--out;
fail = !padsize | (padsize > AES_BLOCKSIZE); │ fail = !padsize | (padsize > AES_BLOCKSIZE);
│
// If not well-formed, treat it as though there's no padding. │ // If not well-formed, treat it as though there's no padding.
padsize *= !fail; │ padsize *= !fail;
│
// All padding must equal the last byte otherwise it's not well-formed │ // All padding must equal the last byte otherwise it's not well-formed
for (int i = AES_BLOCKSIZE; i != 0; i--) │ for (int i = AES_BLOCKSIZE; i != 0; i--)
fail |= ((i > AES_BLOCKSIZE - padsize) & (*out-- != padsize)); │ fail |= ((i > AES_BLOCKSIZE - padsize) & (*out-- != padsize));
│
written -= padsize; │ written -= padsize;
} │ }
return written * !fail; │ return written * !fail;
} │
next prev up bitcoin/src/httpserver.cpp:165 │ dogecoin/src/httpserver.cpp:199
│
rpc_allow_subnets.clear(); │ rpc_allow_subnets.clear();
CNetAddr localv4; │ CNetAddr localv4;
CNetAddr localv6; │ CNetAddr localv6;
LookupHost("127.0.0.1", localv4, false); │ LookupHost("127.0.0.1", localv4, false);
LookupHost("::1", localv6, false); │ LookupHost("::1", localv6, false);
rpc_allow_subnets.push_back(CSubNet(localv4, 8)); // always allow IPv4 local su │ rpc_allow_subnets.push_back(CSubNet(localv4, 8)); // always allow IPv4 local su
rpc_allow_subnets.push_back(CSubNet(localv6)); // always allow IPv6 localhos │ rpc_allow_subnets.push_back(CSubNet(localv6)); // always allow IPv6 localhos
for (const std::string& strAllow : gArgs.GetArgs("-rpcallowip")) { │ if (mapMultiArgs.count("-rpcallowip")) {
CSubNet subnet; │ const std::vector<std::string>& vAllow = mapMultiArgs.at("-rpcallowip");
LookupSubNet(strAllow, subnet); │ for (std::string strAllow : vAllow) {
if (!subnet.IsValid()) { │ CSubNet subnet;
uiInterface.ThreadSafeMessageBox( │ LookupSubNet(strAllow.c_str(), subnet);
strprintf(Untranslated("Invalid -rpcallowip subnet specification: %s. Va │ if (!subnet.IsValid()) {
"", CClientUIInterface::MSG_ERROR); │ uiInterface.ThreadSafeMessageBox(
return false; │ strprintf("Invalid -rpcallowip subnet specification: %s. Valid are a
│ "", CClientUIInterface::MSG_ERROR);
│ return false;
│ }
│ rpc_allow_subnets.push_back(subnet);
} │ }
rpc_allow_subnets.push_back(subnet); │
} │ }
std::string strAllowed; │ std::string strAllowed;
for (const CSubNet& subnet : rpc_allow_subnets) │ for (const CSubNet& subnet : rpc_allow_subnets)
strAllowed += subnet.ToString() + " "; │ strAllowed += subnet.ToString() + " ";
LogPrint(BCLog::HTTP, "Allowing HTTP connections from: %s\n", strAllowed); │ LogPrint("http", "Allowing HTTP connections from: %s\n", strAllowed);
return true; │ return true;
} │
next prev up dogecoin/src/test/rpc_tests.cpp:220 │ bitcoin/src/test/rpc_tests.cpp:225
│
// Valid │ // Valid
BOOST_CHECK_EQUAL(ParseNonRFCJSONValue("1.0").get_real(), 1.0); │ BOOST_CHECK_EQUAL(ParseNonRFCJSONValue("1.0").get_real(), 1.0);
// Valid, with leading or trailing whitespace │ // Valid, with leading or trailing whitespace
BOOST_CHECK_EQUAL(ParseNonRFCJSONValue(" 1.0").get_real(), 1.0); │ BOOST_CHECK_EQUAL(ParseNonRFCJSONValue(" 1.0").get_real(), 1.0);
BOOST_CHECK_EQUAL(ParseNonRFCJSONValue("1.0 ").get_real(), 1.0); │ BOOST_CHECK_EQUAL(ParseNonRFCJSONValue("1.0 ").get_real(), 1.0);
│
BOOST_CHECK_THROW(AmountFromValue(ParseNonRFCJSONValue(".19e-6")), std::runtime_erro │ BOOST_CHECK_THROW(AmountFromValue(ParseNonRFCJSONValue(".19e-6")), std::runtime_erro
BOOST_CHECK_EQUAL(AmountFromValue(ParseNonRFCJSONValue("0.00000000000000000000000000 │ BOOST_CHECK_EQUAL(AmountFromValue(ParseNonRFCJSONValue("0.00000000000000000000000000
// Invalid, initial garbage │ // Invalid, initial garbage
BOOST_CHECK_THROW(ParseNonRFCJSONValue("[1.0"), std::runtime_error); │ BOOST_CHECK_THROW(ParseNonRFCJSONValue("[1.0"), std::runtime_error);
BOOST_CHECK_THROW(ParseNonRFCJSONValue("a1.0"), std::runtime_error); │ BOOST_CHECK_THROW(ParseNonRFCJSONValue("a1.0"), std::runtime_error);
// Invalid, trailing garbage │ // Invalid, trailing garbage
BOOST_CHECK_THROW(ParseNonRFCJSONValue("1.0sds"), std::runtime_error); │ BOOST_CHECK_THROW(ParseNonRFCJSONValue("1.0sds"), std::runtime_error);
BOOST_CHECK_THROW(ParseNonRFCJSONValue("1.0]"), std::runtime_error); │ BOOST_CHECK_THROW(ParseNonRFCJSONValue("1.0]"), std::runtime_error);
// BTC addresses should fail parsing │ // BTC addresses should fail parsing
BOOST_CHECK_THROW(ParseNonRFCJSONValue("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"), std::r │ BOOST_CHECK_THROW(ParseNonRFCJSONValue("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"), std::r
BOOST_CHECK_THROW(ParseNonRFCJSONValue("3J98t1WpEZ73CNmQviecrnyiWrnqRhWNL"), std::ru │ BOOST_CHECK_THROW(ParseNonRFCJSONValue("3J98t1WpEZ73CNmQviecrnyiWrnqRhWNL"), std::ru
} │
next prev up dogecoin/src/utilstrencodings.cpp:149 │ bitcoin/src/util/strencodings.cpp:132
│
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, │ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, │ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, │ -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1,
-1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, │ -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, │ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28,
29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, │ 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, │ 49, 50, 51, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, │ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, │ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, │ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, │ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, │ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 │ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
} │
next prev up dogecoin/src/utilstrencodings.cpp:149 │ bitcoin/src/util/strencodings.cpp:187
│
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, │ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, │ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, │ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, │ -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, │ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 0, 1, 2,
29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, │ 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
49, 50, 51, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, │ 23, 24, 25, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, │ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, │ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, │ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, │ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, │ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 │ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
} │
next prev up dogecoin/src/utilstrencodings.cpp:302 │ bitcoin/src/util/strencodings.cpp:187
│
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, │ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, │ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, -1, -1, -1, -1, │ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, │ -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 0, 1, 2, │ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 0, 1, 2,
3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, │ 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
23, 24, 25, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, │ 23, 24, 25, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, │ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, │ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, │ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, │ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, │ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 │ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
} │
next prev up bitcoin/src/minisketch/src/fields/clmul_8bytes.cpp:90 │ bitcoin/src/minisketch/src/fields/generic_8bytes.cpp:63
0x171d34fcdac955d0, 0x12cfc8c049e1c96, 0x12cfc8c049e1c94, 0x71d34fcdac955c2, 0x12cfc8c04 │ 0x171d34fcdac955d0, 0x12cfc8c049e1c96, 0x12cfc8c049e1c94, 0x71d34fcdac955c2, 0x12cfc8c0
next prev up dogecoin/src/policy/fees.cpp:257 │ bitcoin/src/policy/fees.cpp:452
│
//nBestSeenHeight is not updated yet for the new block │ //nBestSeenHeight is not updated yet for the new block
int blocksAgo = nBestSeenHeight - entryHeight; │ int blocksAgo = nBestSeenHeight - entryHeight;
if (nBestSeenHeight == 0) // the BlockPolicyEstimator hasn't seen any blocks yet │ if (nBestSeenHeight == 0) // the BlockPolicyEstimator hasn't seen any blocks yet
blocksAgo = 0; │ blocksAgo = 0;
if (blocksAgo < 0) { │ if (blocksAgo < 0) {
LogPrint("estimatefee", "Blockpolicy error, blocks ago is negative for mempool t │ LogPrint(BCLog::ESTIMATEFEE, "Blockpolicy error, blocks ago is negative for memp
return; //This can't happen because we call this with our best seen height, no │ return; //This can't happen because we call this with our best seen height, no
} │ }
│
if (blocksAgo >= (int)unconfTxs.size()) { │ if (blocksAgo >= (int)unconfTxs.size()) {
if (oldUnconfTxs[bucketindex] > 0) │ if (oldUnconfTxs[bucketindex] > 0) {
oldUnconfTxs[bucketindex]--; │ oldUnconfTxs[bucketindex]--;
else │ } else {
LogPrint("estimatefee", "Blockpolicy error, mempool tx removed from >25 bloc │ LogPrint(BCLog::ESTIMATEFEE, "Blockpolicy error, mempool tx removed from >25
bucketindex); │ bucketindex);
│ }
} │ }
else { │ else {
unsigned int blockIndex = entryHeight % unconfTxs.size(); │ unsigned int blockIndex = entryHeight % unconfTxs.size();
if (unconfTxs[blockIndex][bucketindex] > 0) │ if (unconfTxs[blockIndex][bucketindex] > 0) {
unconfTxs[blockIndex][bucketindex]--; │ unconfTxs[blockIndex][bucketindex]--;
else │ } else {
LogPrint("estimatefee", "Blockpolicy error, mempool tx removed from blockInd │ LogPrint(BCLog::ESTIMATEFEE, "Blockpolicy error, mempool tx removed from blo
blockIndex, bucketindex); │ blockIndex, bucketindex);
│ }
│ }
│ if (!inBlock && (unsigned int)blocksAgo >= scale) { // Only counts as a failure if n
│ assert(scale != 0);
│ unsigned int periodsAgo = blocksAgo / scale;
│ for (size_t i = 0; i < periodsAgo && i < failAvg.size(); i++) {
│ failAvg[i][bucketindex]++;
│ }
} │ }
} │
next prev up bitcoin/src/test/rpc_tests.cpp:106 │ dogecoin/src/test/rpc_tests.cpp:108
│
UniValue r; │ UniValue r;
// input is a 1-of-2 multisig (so is output): │ // input is a 1-of-2 multisig (so is output):
std::string prevout = │ std::string prevout =
"[{\"txid\":\"b4cc287e58f87cdae59417329f710f3ecd75a4ee1d2872b7248f50977c8493f3\"," │ "[{\"txid\":\"b4cc287e58f87cdae59417329f710f3ecd75a4ee1d2872b7248f50977c8493f3\","
"\"vout\":1,\"scriptPubKey\":\"a914b10c9df5f7edf436c697f02f1efdba4cf399615187\"," │ "\"vout\":1,\"scriptPubKey\":\"a914b10c9df5f7edf436c697f02f1efdba4cf399615187\","
"\"redeemScript\":\"512103debedc17b3df2badbcdd86d5feb4562b86fe182e5998abd8bcd4f122 │ "\"redeemScript\":\"512103debedc17b3df2badbcdd86d5feb4562b86fe182e5998abd8bcd4f122
r = CallRPC(std::string("createrawtransaction ")+prevout+" "+ │ r = CallRPC(std::string("createrawtransaction ")+prevout+" "+
"{\"3HqAe9LtNBjnsfM4CyYaWTnvCaUYT7v4oZ\":11}"); │ "{\"A8aRNzQnSFcgn2iXd7CzkbRHu9raZFHSkT\":11}"); // 3HqAe9LtNBjnsfM4CyYaWTnvCaUYT7v
std::string notsigned = r.get_str(); │ std::string notsigned = r.get_str();
std::string privkey1 = "\"KzsXybp9jX64P5ekX1KUxRQ79Jht9uzW7LorgwE65i5rWACL6LQe\""; │ std::string privkey1 = "\"QSGT8Sd8z8aBcc3o7HAGqeEicLjTCU8JzbVmUZcvp4hCx66fsLPE\"";
std::string privkey2 = "\"Kyhdf5LuKTRx4ge69ybABsiUAWjVRK4XGxAKk2FQLp2HjGMy87Z4\""; │ std::string privkey2 = "\"QR6Yov9ta4v5JD38kFRx56Z5dYm4TsCLACrEXeeF5AdeBCNKeB44\"";
r = CallRPC(std::string("signrawtransactionwithkey ")+notsigned+" [] "+prevout); │ r = CallRPC(std::string("signrawtransaction ")+notsigned+" "+prevout+" "+"[]");
BOOST_CHECK(find_value(r.get_obj(), "complete").get_bool() == false); │ BOOST_CHECK(find_value(r.get_obj(), "complete").get_bool() == false);
r = CallRPC(std::string("signrawtransactionwithkey ")+notsigned+" ["+privkey1+","+pr │ r = CallRPC(std::string("signrawtransaction ")+notsigned+" "+prevout+" "+"["+privkey
BOOST_CHECK(find_value(r.get_obj(), "complete").get_bool() == true); │ BOOST_CHECK(find_value(r.get_obj(), "complete").get_bool() == true);
} │
next prev up bitcoin/src/rest.cpp:663 │ bitcoin/src/rest.cpp:312
│
case RESTResponseFormat::BINARY: { │ case RESTResponseFormat::BINARY: {
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION | RPCSerializationFlags()); │ CDataStream ssBlock(SER_NETWORK, PROTOCOL_VERSION | RPCSerializationFlags());
ssTx << tx; │ ssBlock << block;
│ std::string binaryBlock = ssBlock.str();
std::string binaryTx = ssTx.str(); │
req->WriteHeader("Content-Type", "application/octet-stream"); │ req->WriteHeader("Content-Type", "application/octet-stream");
req->WriteReply(HTTP_OK, binaryTx); │ req->WriteReply(HTTP_OK, binaryBlock);
return true; │ return true;
} │ }
│
case RESTResponseFormat::HEX: { │ case RESTResponseFormat::HEX: {
CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION | RPCSerializationFlags()); │ CDataStream ssBlock(SER_NETWORK, PROTOCOL_VERSION | RPCSerializationFlags());
ssTx << tx; │ ssBlock << block;
│ std::string strHex = HexStr(ssBlock) + "\n";
std::string strHex = HexStr(ssTx) + "\n"; │
req->WriteHeader("Content-Type", "text/plain"); │ req->WriteHeader("Content-Type", "text/plain");
req->WriteReply(HTTP_OK, strHex); │ req->WriteReply(HTTP_OK, strHex);
return true; │ return true;
} │ }
│
case RESTResponseFormat::JSON: { │ case RESTResponseFormat::JSON: {
UniValue objTx(UniValue::VOBJ); │ UniValue objBlock = blockToJSON(chainman.m_blockman, block, tip, pblockindex, tx
TxToUniv(*tx, /*block_hash=*/hashBlock, /*entry=*/ objTx); │ std::string strJSON = objBlock.write() + "\n";
std::string strJSON = objTx.write() + "\n"; │
req->WriteHeader("Content-Type", "application/json"); │ req->WriteHeader("Content-Type", "application/json");
req->WriteReply(HTTP_OK, strJSON); │ req->WriteReply(HTTP_OK, strJSON);
return true; │ return true;
} │ }
│
default: { │ default: {
return RESTERR(req, HTTP_NOT_FOUND, "output format not found (available: " + Ava │ return RESTERR(req, HTTP_NOT_FOUND, "output format not found (available: " + Ava
} │ }
} │
next prev up bitcoin/src/compressor.cpp:96 │ dogecoin/src/compressor.cpp:89
│
switch(nSize) { │ switch(nSize) {
case 0x00: │ case 0x00:
script.resize(25); │ script.resize(25);
script[0] = OP_DUP; │ script[0] = OP_DUP;
script[1] = OP_HASH160; │ script[1] = OP_HASH160;
script[2] = 20; │ script[2] = 20;
memcpy(&script[3], in.data(), 20); │ memcpy(&script[3], &in[0], 20);
script[23] = OP_EQUALVERIFY; │ script[23] = OP_EQUALVERIFY;
script[24] = OP_CHECKSIG; │ script[24] = OP_CHECKSIG;
return true; │ return true;
case 0x01: │ case 0x01:
script.resize(23); │ script.resize(23);
script[0] = OP_HASH160; │ script[0] = OP_HASH160;
script[1] = 20; │ script[1] = 20;
memcpy(&script[2], in.data(), 20); │ memcpy(&script[2], &in[0], 20);
script[22] = OP_EQUAL; │ script[22] = OP_EQUAL;
return true; │ return true;
case 0x02: │ case 0x02:
case 0x03: │ case 0x03:
script.resize(35); │ script.resize(35);
script[0] = 33; │ script[0] = 33;
script[1] = nSize; │ script[1] = nSize;
memcpy(&script[2], in.data(), 32); │ memcpy(&script[2], &in[0], 32);
script[34] = OP_CHECKSIG; │ script[34] = OP_CHECKSIG;
return true; │ return true;
case 0x04: │ case 0x04:
case 0x05: │ case 0x05:
unsigned char vch[33] = {}; │ unsigned char vch[33] = {};
vch[0] = nSize - 2; │ vch[0] = nSize - 2;
memcpy(&vch[1], in.data(), 32); │ memcpy(&vch[1], &in[0], 32);
CPubKey pubkey{vch}; │ CPubKey pubkey(&vch[0], &vch[33]);
if (!pubkey.Decompress()) │ if (!pubkey.Decompress())
return false; │ return false;
assert(pubkey.size() == 65); │ assert(pubkey.size() == 65);
script.resize(67); │ script.resize(67);
script[0] = 65; │ script[0] = 65;
memcpy(&script[1], pubkey.begin(), 65); │ memcpy(&script[1], pubkey.begin(), 65);
script[66] = OP_CHECKSIG; │ script[66] = OP_CHECKSIG;
return true; │ return true;
} │ }
return false; │ return false;
} │
next prev up dogecoin/src/univalue/test/object.cpp:39 │ bitcoin/src/univalue/test/object.cpp:39
│
UniValue v1; │ UniValue v1;
BOOST_CHECK(v1.isNull()); │ BOOST_CHECK(v1.isNull());
│
UniValue v2(UniValue::VSTR); │ UniValue v2(UniValue::VSTR);
BOOST_CHECK(v2.isStr()); │ BOOST_CHECK(v2.isStr());
│
UniValue v3(UniValue::VSTR, "foo"); │ UniValue v3(UniValue::VSTR, "foo");
BOOST_CHECK(v3.isStr()); │ BOOST_CHECK(v3.isStr());
BOOST_CHECK_EQUAL(v3.getValStr(), "foo"); │ BOOST_CHECK_EQUAL(v3.getValStr(), "foo");
│
UniValue numTest; │ UniValue numTest;
BOOST_CHECK(numTest.setNumStr("82")); │ BOOST_CHECK(numTest.setNumStr("82"));
BOOST_CHECK(numTest.isNum()); │ BOOST_CHECK(numTest.isNum());
BOOST_CHECK_EQUAL(numTest.getValStr(), "82"); │ BOOST_CHECK_EQUAL(numTest.getValStr(), "82");
│
uint64_t vu64 = 82; │ uint64_t vu64 = 82;
UniValue v4(vu64); │ UniValue v4(vu64);
BOOST_CHECK(v4.isNum()); │ BOOST_CHECK(v4.isNum());
BOOST_CHECK_EQUAL(v4.getValStr(), "82"); │ BOOST_CHECK_EQUAL(v4.getValStr(), "82");
│
int64_t vi64 = -82; │ int64_t vi64 = -82;
UniValue v5(vi64); │ UniValue v5(vi64);
BOOST_CHECK(v5.isNum()); │ BOOST_CHECK(v5.isNum());
BOOST_CHECK_EQUAL(v5.getValStr(), "-82"); │ BOOST_CHECK_EQUAL(v5.getValStr(), "-82");
│
int vi = -688; │ int vi = -688;
UniValue v6(vi); │ UniValue v6(vi);
BOOST_CHECK(v6.isNum()); │ BOOST_CHECK(v6.isNum());
BOOST_CHECK_EQUAL(v6.getValStr(), "-688"); │ BOOST_CHECK_EQUAL(v6.getValStr(), "-688");
│
double vd = -7.21; │ double vd = -7.21;
UniValue v7(vd); │ UniValue v7(vd);
BOOST_CHECK(v7.isNum()); │ BOOST_CHECK(v7.isNum());
BOOST_CHECK_EQUAL(v7.getValStr(), "-7.21"); │ BOOST_CHECK_EQUAL(v7.getValStr(), "-7.21");
│
std::string vs("yawn"); │ std::string vs("yawn");
UniValue v8(vs); │ UniValue v8(vs);
BOOST_CHECK(v8.isStr()); │ BOOST_CHECK(v8.isStr());
BOOST_CHECK_EQUAL(v8.getValStr(), "yawn"); │ BOOST_CHECK_EQUAL(v8.getValStr(), "yawn");
│
const char *vcs = "zappa"; │ const char *vcs = "zappa";
UniValue v9(vcs); │ UniValue v9(vcs);
BOOST_CHECK(v9.isStr()); │ BOOST_CHECK(v9.isStr());
BOOST_CHECK_EQUAL(v9.getValStr(), "zappa"); │ BOOST_CHECK_EQUAL(v9.getValStr(), "zappa");
} │
next prev up dogecoin/src/test/univalue_tests.cpp:18 │ bitcoin/src/univalue/test/object.cpp:39
│
UniValue v1; │ UniValue v1;
BOOST_CHECK(v1.isNull()); │ BOOST_CHECK(v1.isNull());
│
UniValue v2(UniValue::VSTR); │ UniValue v2(UniValue::VSTR);
BOOST_CHECK(v2.isStr()); │ BOOST_CHECK(v2.isStr());
│
UniValue v3(UniValue::VSTR, "foo"); │ UniValue v3(UniValue::VSTR, "foo");
BOOST_CHECK(v3.isStr()); │ BOOST_CHECK(v3.isStr());
BOOST_CHECK_EQUAL(v3.getValStr(), "foo"); │ BOOST_CHECK_EQUAL(v3.getValStr(), "foo");
│
UniValue numTest; │ UniValue numTest;
BOOST_CHECK(numTest.setNumStr("82")); │ BOOST_CHECK(numTest.setNumStr("82"));
BOOST_CHECK(numTest.isNum()); │ BOOST_CHECK(numTest.isNum());
BOOST_CHECK_EQUAL(numTest.getValStr(), "82"); │ BOOST_CHECK_EQUAL(numTest.getValStr(), "82");
│
uint64_t vu64 = 82; │ uint64_t vu64 = 82;
UniValue v4(vu64); │ UniValue v4(vu64);
BOOST_CHECK(v4.isNum()); │ BOOST_CHECK(v4.isNum());
BOOST_CHECK_EQUAL(v4.getValStr(), "82"); │ BOOST_CHECK_EQUAL(v4.getValStr(), "82");
│
int64_t vi64 = -82; │ int64_t vi64 = -82;
UniValue v5(vi64); │ UniValue v5(vi64);
BOOST_CHECK(v5.isNum()); │ BOOST_CHECK(v5.isNum());
BOOST_CHECK_EQUAL(v5.getValStr(), "-82"); │ BOOST_CHECK_EQUAL(v5.getValStr(), "-82");
│
int vi = -688; │ int vi = -688;
UniValue v6(vi); │ UniValue v6(vi);
BOOST_CHECK(v6.isNum()); │ BOOST_CHECK(v6.isNum());
BOOST_CHECK_EQUAL(v6.getValStr(), "-688"); │ BOOST_CHECK_EQUAL(v6.getValStr(), "-688");
│
double vd = -7.21; │ double vd = -7.21;
UniValue v7(vd); │ UniValue v7(vd);
BOOST_CHECK(v7.isNum()); │ BOOST_CHECK(v7.isNum());
BOOST_CHECK_EQUAL(v7.getValStr(), "-7.21"); │ BOOST_CHECK_EQUAL(v7.getValStr(), "-7.21");
│
std::string vs("yawn"); │ std::string vs("yawn");
UniValue v8(vs); │ UniValue v8(vs);
BOOST_CHECK(v8.isStr()); │ BOOST_CHECK(v8.isStr());
BOOST_CHECK_EQUAL(v8.getValStr(), "yawn"); │ BOOST_CHECK_EQUAL(v8.getValStr(), "yawn");
│
const char *vcs = "zappa"; │ const char *vcs = "zappa";
UniValue v9(vcs); │ UniValue v9(vcs);
BOOST_CHECK(v9.isStr()); │ BOOST_CHECK(v9.isStr());
BOOST_CHECK_EQUAL(v9.getValStr(), "zappa"); │ BOOST_CHECK_EQUAL(v9.getValStr(), "zappa");
} │
next prev up dogecoin/src/test/univalue_tests.cpp:18 │ dogecoin/src/univalue/test/object.cpp:39
│
UniValue v1; │ UniValue v1;
BOOST_CHECK(v1.isNull()); │ BOOST_CHECK(v1.isNull());
│
UniValue v2(UniValue::VSTR); │ UniValue v2(UniValue::VSTR);
BOOST_CHECK(v2.isStr()); │ BOOST_CHECK(v2.isStr());
│
UniValue v3(UniValue::VSTR, "foo"); │ UniValue v3(UniValue::VSTR, "foo");
BOOST_CHECK(v3.isStr()); │ BOOST_CHECK(v3.isStr());
BOOST_CHECK_EQUAL(v3.getValStr(), "foo"); │ BOOST_CHECK_EQUAL(v3.getValStr(), "foo");
│
UniValue numTest; │ UniValue numTest;
BOOST_CHECK(numTest.setNumStr("82")); │ BOOST_CHECK(numTest.setNumStr("82"));
BOOST_CHECK(numTest.isNum()); │ BOOST_CHECK(numTest.isNum());
BOOST_CHECK_EQUAL(numTest.getValStr(), "82"); │ BOOST_CHECK_EQUAL(numTest.getValStr(), "82");
│
uint64_t vu64 = 82; │ uint64_t vu64 = 82;
UniValue v4(vu64); │ UniValue v4(vu64);
BOOST_CHECK(v4.isNum()); │ BOOST_CHECK(v4.isNum());
BOOST_CHECK_EQUAL(v4.getValStr(), "82"); │ BOOST_CHECK_EQUAL(v4.getValStr(), "82");
│
int64_t vi64 = -82; │ int64_t vi64 = -82;
UniValue v5(vi64); │ UniValue v5(vi64);
BOOST_CHECK(v5.isNum()); │ BOOST_CHECK(v5.isNum());
BOOST_CHECK_EQUAL(v5.getValStr(), "-82"); │ BOOST_CHECK_EQUAL(v5.getValStr(), "-82");
│
int vi = -688; │ int vi = -688;
UniValue v6(vi); │ UniValue v6(vi);
BOOST_CHECK(v6.isNum()); │ BOOST_CHECK(v6.isNum());
BOOST_CHECK_EQUAL(v6.getValStr(), "-688"); │ BOOST_CHECK_EQUAL(v6.getValStr(), "-688");
│
double vd = -7.21; │ double vd = -7.21;
UniValue v7(vd); │ UniValue v7(vd);
BOOST_CHECK(v7.isNum()); │ BOOST_CHECK(v7.isNum());
BOOST_CHECK_EQUAL(v7.getValStr(), "-7.21"); │ BOOST_CHECK_EQUAL(v7.getValStr(), "-7.21");
│
std::string vs("yawn"); │ std::string vs("yawn");
UniValue v8(vs); │ UniValue v8(vs);
BOOST_CHECK(v8.isStr()); │ BOOST_CHECK(v8.isStr());
BOOST_CHECK_EQUAL(v8.getValStr(), "yawn"); │ BOOST_CHECK_EQUAL(v8.getValStr(), "yawn");
│
const char *vcs = "zappa"; │ const char *vcs = "zappa";
UniValue v9(vcs); │ UniValue v9(vcs);
BOOST_CHECK(v9.isStr()); │ BOOST_CHECK(v9.isStr());
BOOST_CHECK_EQUAL(v9.getValStr(), "zappa"); │ BOOST_CHECK_EQUAL(v9.getValStr(), "zappa");
} │
next prev up dogecoin/src/rpc/mining.cpp:40 │ bitcoin/src/rpc/mining.cpp:54
│
CBlockIndex *pb = chainActive.Tip(); │ const CBlockIndex* pb = active_chain.Tip();
│
if (height >= 0 && height < chainActive.Height()) │ if (height >= 0 && height < active_chain.Height()) {
pb = chainActive[height]; │ pb = active_chain[height];
│ }
│
if (pb == NULL || !pb->nHeight) │ if (pb == nullptr || !pb->nHeight)
return 0; │ return 0;
│
// If lookup is -1, then use blocks since last difficulty change. │ // If lookup is -1, then use blocks since last difficulty change.
if (lookup <= 0) │ if (lookup <= 0)
lookup = pb->nHeight % Params().GetConsensus(pb->nHeight).DifficultyAdjustmentIn │ lookup = pb->nHeight % Params().GetConsensus().DifficultyAdjustmentInterval() +
│
// If lookup is larger than chain, then set it to chain length. │ // If lookup is larger than chain, then set it to chain length.
if (lookup > pb->nHeight) │ if (lookup > pb->nHeight)
lookup = pb->nHeight; │ lookup = pb->nHeight;
│
CBlockIndex *pb0 = pb; │ const CBlockIndex* pb0 = pb;
int64_t minTime = pb0->GetBlockTime(); │ int64_t minTime = pb0->GetBlockTime();
int64_t maxTime = minTime; │ int64_t maxTime = minTime;
for (int i = 0; i < lookup; i++) { │ for (int i = 0; i < lookup; i++) {
pb0 = pb0->pprev; │ pb0 = pb0->pprev;
int64_t time = pb0->GetBlockTime(); │ int64_t time = pb0->GetBlockTime();
minTime = std::min(time, minTime); │ minTime = std::min(time, minTime);
maxTime = std::max(time, maxTime); │ maxTime = std::max(time, maxTime);
} │ }
│
// In case there's a situation where minTime == maxTime, we don't want a divide by z │ // In case there's a situation where minTime == maxTime, we don't want a divide by z
if (minTime == maxTime) │ if (minTime == maxTime)
return 0; │ return 0;
│
arith_uint256 workDiff = pb->nChainWork - pb0->nChainWork; │ arith_uint256 workDiff = pb->nChainWork - pb0->nChainWork;
int64_t timeDiff = maxTime - minTime; │ int64_t timeDiff = maxTime - minTime;
│
return workDiff.getdouble() / timeDiff; │ return workDiff.getdouble() / timeDiff;
} │
next prev up dogecoin/src/script/interpreter.cpp:715 │ bitcoin/src/script/interpreter.cpp:889
│
// (x1 x2 - bool) │ // (x1 x2 - bool)
if (stack.size() < 2) │ if (stack.size() < 2)
return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); │ return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION);
valtype& vch1 = stacktop(-2); │ valtype& vch1 = stacktop(-2);
valtype& vch2 = stacktop(-1); │ valtype& vch2 = stacktop(-1);
bool fEqual = (vch1 == vch2); │ bool fEqual = (vch1 == vch2);
// OP_NOTEQUAL is disabled because it would be too easy to say │ // OP_NOTEQUAL is disabled because it would be too easy to say
// something like n != 1 and have some wiseguy pass in 1 with extra │ // something like n != 1 and have some wiseguy pass in 1 with extra
// zero bytes after it (numerically, 0x01 == 0x0001 == 0x000001) │ // zero bytes after it (numerically, 0x01 == 0x0001 == 0x000001)
//if (opcode == OP_NOTEQUAL) │ //if (opcode == OP_NOTEQUAL)
// fEqual = !fEqual; │ // fEqual = !fEqual;
popstack(stack); │ popstack(stack);
popstack(stack); │ popstack(stack);
stack.push_back(fEqual ? vchTrue : vchFalse); │ stack.push_back(fEqual ? vchTrue : vchFalse);
if (opcode == OP_EQUALVERIFY) │ if (opcode == OP_EQUALVERIFY)
{ │ {
if (fEqual) │ if (fEqual)
popstack(stack); │ popstack(stack);
else │ else
return set_error(serror, SCRIPT_ERR_EQUALVERIFY); │ return set_error(serror, SCRIPT_ERR_EQUALVERIFY);
} │ }
} │
next prev up bitcoin/src/txmempool.cpp:595 │ dogecoin/src/txmempool.cpp:504
│
// Remove transaction from memory pool │ // Remove transaction from memory pool
AssertLockHeld(cs); │ {
│ LOCK(cs);
setEntries txToRemove; │ setEntries txToRemove;
txiter origit = mapTx.find(origTx.GetHash()); │ txiter origit = mapTx.find(origTx.GetHash());
if (origit != mapTx.end()) { │ if (origit != mapTx.end()) {
txToRemove.insert(origit); │ txToRemove.insert(origit);
} else { │ } else {
// When recursively removing but origTx isn't in the mempool │ // When recursively removing but origTx isn't in the mempool
// be sure to remove any children that are in the pool. This can │ // be sure to remove any children that are in the pool. This can
// happen during chain re-orgs if origTx isn't re-accepted into │ // happen during chain re-orgs if origTx isn't re-accepted into
// the mempool for any reason. │ // the mempool for any reason.
for (unsigned int i = 0; i < origTx.vout.size(); i++) { │ for (unsigned int i = 0; i < origTx.vout.size(); i++) {
auto it = mapNextTx.find(COutPoint(origTx.GetHash(), i)); │ auto it = mapNextTx.find(COutPoint(origTx.GetHash(), i));
if (it == mapNextTx.end()) │ if (it == mapNextTx.end())
continue; │ continue;
txiter nextit = mapTx.find(it->second->GetHash()); │ txiter nextit = mapTx.find(it->second->GetHash());
assert(nextit != mapTx.end()); │ assert(nextit != mapTx.end());
txToRemove.insert(nextit); │ txToRemove.insert(nextit);
} │ }
} │ }
setEntries setAllRemoves; │ setEntries setAllRemoves;
for (txiter it : txToRemove) { │ BOOST_FOREACH(txiter it, txToRemove) {
CalculateDescendants(it, setAllRemoves); │ CalculateDescendants(it, setAllRemoves);
} │ }
│
RemoveStaged(setAllRemoves, false, reason); │ RemoveStaged(setAllRemoves, false, reason);
│ }
} │
next prev up dogecoin/src/test/hash_tests.cpp:16 │ bitcoin/src/test/hash_tests.cpp:16
│
│
#define T(expected, seed, data) BOOST_CHECK_EQUAL(MurmurHash3(seed, ParseHex(data)), exp │ #define T(expected, seed, data) BOOST_CHECK_EQUAL(MurmurHash3(seed, ParseHex(data)), exp
│
// Test MurmurHash3 with various inputs. Of course this is retested in the │ // Test MurmurHash3 with various inputs. Of course this is retested in the
// bloom filter tests - they would fail if MurmurHash3() had any problems - │ // bloom filter tests - they would fail if MurmurHash3() had any problems -
// but is useful for those trying to implement Bitcoin libraries as a │ // but is useful for those trying to implement Bitcoin libraries as a
// source of test data for their MurmurHash3() primitive during │ // source of test data for their MurmurHash3() primitive during
// development. │ // development.
// │ //
// The magic number 0xFBA4C795 comes from CBloomFilter::Hash() │ // The magic number 0xFBA4C795 comes from CBloomFilter::Hash()
│
T(0x00000000U, 0x00000000, ""); │ T(0x00000000U, 0x00000000, "");
T(0x6a396f08U, 0xFBA4C795, ""); │ T(0x6a396f08U, 0xFBA4C795, "");
T(0x81f16f39U, 0xffffffff, ""); │ T(0x81f16f39U, 0xffffffff, "");
│
T(0x514e28b7U, 0x00000000, "00"); │ T(0x514e28b7U, 0x00000000, "00");
T(0xea3f0b17U, 0xFBA4C795, "00"); │ T(0xea3f0b17U, 0xFBA4C795, "00");
T(0xfd6cf10dU, 0x00000000, "ff"); │ T(0xfd6cf10dU, 0x00000000, "ff");
│
T(0x16c6b7abU, 0x00000000, "0011"); │ T(0x16c6b7abU, 0x00000000, "0011");
T(0x8eb51c3dU, 0x00000000, "001122"); │ T(0x8eb51c3dU, 0x00000000, "001122");
T(0xb4471bf8U, 0x00000000, "00112233"); │ T(0xb4471bf8U, 0x00000000, "00112233");
T(0xe2301fa8U, 0x00000000, "0011223344"); │ T(0xe2301fa8U, 0x00000000, "0011223344");
T(0xfc2e4a15U, 0x00000000, "001122334455"); │ T(0xfc2e4a15U, 0x00000000, "001122334455");
T(0xb074502cU, 0x00000000, "00112233445566"); │ T(0xb074502cU, 0x00000000, "00112233445566");
T(0x8034d2a0U, 0x00000000, "0011223344556677"); │ T(0x8034d2a0U, 0x00000000, "0011223344556677");
T(0xb4698defU, 0x00000000, "001122334455667788"); │ T(0xb4698defU, 0x00000000, "001122334455667788");
│
#undef T │ #undef T
} │
next prev up bitcoin/src/minisketch/src/fields/clmul_8bytes.cpp:115 │ bitcoin/src/minisketch/src/fields/generic_8bytes.cpp:81
0, 0x100010114, 0x100010116, 0x1001701051372, 0x100010112, 0x1000040220, 0x100170105137a │ 0, 0x100010114, 0x100010116, 0x1001701051372, 0x100010112, 0x1000040220, 0x100170105137
next prev up bitcoin/src/rest.cpp:533 │ bitcoin/src/rest.cpp:663
│
case RESTResponseFormat::BINARY: { │ case RESTResponseFormat::BINARY: {
CDataStream ssResp{SER_NETWORK, PROTOCOL_VERSION}; │ CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION | RPCSerializationFlags());
ssResp << filter; │ ssTx << tx;
│
std::string binaryResp = ssResp.str(); │ std::string binaryTx = ssTx.str();
req->WriteHeader("Content-Type", "application/octet-stream"); │ req->WriteHeader("Content-Type", "application/octet-stream");
req->WriteReply(HTTP_OK, binaryResp); │ req->WriteReply(HTTP_OK, binaryTx);
return true; │ return true;
} │ }
│
case RESTResponseFormat::HEX: { │ case RESTResponseFormat::HEX: {
CDataStream ssResp{SER_NETWORK, PROTOCOL_VERSION}; │ CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION | RPCSerializationFlags());
ssResp << filter; │ ssTx << tx;
│
std::string strHex = HexStr(ssResp) + "\n"; │ std::string strHex = HexStr(ssTx) + "\n";
req->WriteHeader("Content-Type", "text/plain"); │ req->WriteHeader("Content-Type", "text/plain");
req->WriteReply(HTTP_OK, strHex); │ req->WriteReply(HTTP_OK, strHex);
return true; │ return true;
} │ }
│
case RESTResponseFormat::JSON: { │ case RESTResponseFormat::JSON: {
UniValue ret(UniValue::VOBJ); │ UniValue objTx(UniValue::VOBJ);
ret.pushKV("filter", HexStr(filter.GetEncodedFilter())); │ TxToUniv(*tx, /*block_hash=*/hashBlock, /*entry=*/ objTx);
std::string strJSON = ret.write() + "\n"; │ std::string strJSON = objTx.write() + "\n";
req->WriteHeader("Content-Type", "application/json"); │ req->WriteHeader("Content-Type", "application/json");
req->WriteReply(HTTP_OK, strJSON); │ req->WriteReply(HTTP_OK, strJSON);
return true; │ return true;
} │ }
│
default: { │ default: {
return RESTERR(req, HTTP_NOT_FOUND, "output format not found (available: " + Ava │ return RESTERR(req, HTTP_NOT_FOUND, "output format not found (available: " + Ava
} │ }
} │
next prev up bitcoin/src/script/interpreter.cpp:1026 │ dogecoin/src/script/interpreter.cpp:852
│
// (in -- hash) │ // (in -- hash)
if (stack.size() < 1) │ if (stack.size() < 1)
return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION); │ return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION);
valtype& vch = stacktop(-1); │ valtype& vch = stacktop(-1);
valtype vchHash((opcode == OP_RIPEMD160 || opcode == OP_SHA1 || opco │ valtype vchHash((opcode == OP_RIPEMD160 || opcode == OP_SHA1 || opco
if (opcode == OP_RIPEMD160) │ if (opcode == OP_RIPEMD160)
CRIPEMD160().Write(vch.data(), vch.size()).Finalize(vchHash.data │ CRIPEMD160().Write(vch.data(), vch.size()).Finalize(vchHash.data
else if (opcode == OP_SHA1) │ else if (opcode == OP_SHA1)
CSHA1().Write(vch.data(), vch.size()).Finalize(vchHash.data()); │ CSHA1().Write(vch.data(), vch.size()).Finalize(vchHash.data());
else if (opcode == OP_SHA256) │ else if (opcode == OP_SHA256)
CSHA256().Write(vch.data(), vch.size()).Finalize(vchHash.data()) │ CSHA256().Write(vch.data(), vch.size()).Finalize(vchHash.data())
else if (opcode == OP_HASH160) │ else if (opcode == OP_HASH160)
CHash160().Write(vch).Finalize(vchHash); │ CHash160().Write(vch.data(), vch.size()).Finalize(vchHash.data()
else if (opcode == OP_HASH256) │ else if (opcode == OP_HASH256)
CHash256().Write(vch).Finalize(vchHash); │ CHash256().Write(vch.data(), vch.size()).Finalize(vchHash.data()
popstack(stack); │ popstack(stack);
stack.push_back(vchHash); │ stack.push_back(vchHash);
} │
next prev up dogecoin/src/wallet/wallet.cpp:1164 │ dogecoin/src/wallet/wallet.cpp:1102
│
// Block is 'more conflicted' than current confirm; update. │ // If the orig tx was not in block/mempool, none of its spends can be in mem
// Mark transaction as conflicted with this block. │ assert(!wtx.InMempool());
wtx.nIndex = -1; │ wtx.nIndex = -1;
wtx.hashBlock = hashBlock; │ wtx.setAbandoned();
wtx.MarkDirty(); │ wtx.MarkDirty();
walletdb.WriteTx(wtx); │ walletdb.WriteTx(wtx);
// Iterate over all its outputs, and mark transactions in the wallet that sp │ NotifyTransactionChanged(this, wtx.GetHash(), CT_UPDATED);
TxSpends::const_iterator iter = mapTxSpends.lower_bound(COutPoint(now, 0)); │ // Iterate over all its outputs, and mark transactions in the wallet that sp
│ TxSpends::const_iterator iter = mapTxSpends.lower_bound(COutPoint(hashTx, 0)
while (iter != mapTxSpends.end() && iter->first.hash == now) { │ while (iter != mapTxSpends.end() && iter->first.hash == now) {
if (!done.count(iter->second)) { │ if (!done.count(iter->second)) {
todo.insert(iter->second); │ todo.insert(iter->second);
} │ }
iter++; │ iter++;
} │ }
// If a transaction changes 'conflicted' state, that changes the balance │ // If a transaction changes 'conflicted' state, that changes the balance
// available of the outputs it spends. So force those to be recomputed │ // available of the outputs it spends. So force those to be recomputed
BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin) │ BOOST_FOREACH(const CTxIn& txin, wtx.tx->vin)
{ │ {
if (mapWallet.count(txin.prevout.hash)) │ if (mapWallet.count(txin.prevout.hash))
mapWallet[txin.prevout.hash].MarkDirty(); │ mapWallet[txin.prevout.hash].MarkDirty();
} │ }
} │
next prev up bitcoin/src/test/addrman_tests.cpp:196 │ bitcoin/src/test/addrman_tests.cpp:257
│
auto addrman = std::make_unique<AddrMan>(EMPTY_NETGROUPMAN, DETERMINISTIC, GetCheckR │ auto addrman = std::make_unique<AddrMan>(EMPTY_NETGROUPMAN, DETERMINISTIC, GetCheckR
│
CNetAddr source = ResolveIP("252.2.2.2"); │ CNetAddr source = ResolveIP("252.2.2.2");
│
uint32_t num_addrs{0}; │ uint32_t num_addrs{0};
│
BOOST_CHECK_EQUAL(addrman->size(), num_addrs); │ BOOST_CHECK_EQUAL(addrman->size(), num_addrs);
│
while (num_addrs < 22) { // Magic number! 250.1.1.1 - 250.1.1.22 do not collide with │ while (num_addrs < 35) { // Magic number! 250.1.1.1 - 250.1.1.35 do not collide in t
CService addr = ResolveService("250.1.1." + ToString(++num_addrs)); │ CService addr = ResolveService("250.1.1." + ToString(++num_addrs));
BOOST_CHECK(addrman->Add({CAddress(addr, NODE_NONE)}, source)); │ BOOST_CHECK(addrman->Add({CAddress(addr, NODE_NONE)}, source));
│
// Test: No collision in new table yet. │ // Test: Add to tried without collision
BOOST_CHECK_EQUAL(addrman->size(), num_addrs); │ BOOST_CHECK(addrman->Good(CAddress(addr, NODE_NONE)));
│
} │ }
│
// Test: new table collision! │ // Test: Unable to add to tried table due to collision!
CService addr1 = ResolveService("250.1.1." + ToString(++num_addrs)); │ CService addr1 = ResolveService("250.1.1." + ToString(++num_addrs));
uint32_t collisions{1}; │
BOOST_CHECK(addrman->Add({CAddress(addr1, NODE_NONE)}, source)); │ BOOST_CHECK(addrman->Add({CAddress(addr1, NODE_NONE)}, source));
BOOST_CHECK_EQUAL(addrman->size(), num_addrs - collisions); │ BOOST_CHECK(!addrman->Good(CAddress(addr1, NODE_NONE)));
│
│ // Test: Add the next address to tried without collision
CService addr2 = ResolveService("250.1.1." + ToString(++num_addrs)); │ CService addr2 = ResolveService("250.1.1." + ToString(++num_addrs));
BOOST_CHECK(addrman->Add({CAddress(addr2, NODE_NONE)}, source)); │ BOOST_CHECK(addrman->Add({CAddress(addr2, NODE_NONE)}, source));
BOOST_CHECK_EQUAL(addrman->size(), num_addrs - collisions); │ BOOST_CHECK(addrman->Good(CAddress(addr2, NODE_NONE)));
} │
next prev up bitcoin/src/minisketch/src/fields/clmul_8bytes.cpp:78 │ bitcoin/src/minisketch/src/fields/generic_8bytes.cpp:54
0x6983c00fe00104a, 0x804570322e054e6, 0x804570322e054e4, 0x15673387e0a4e4, 0x804570322e0 │ 0x6983c00fe00104a, 0x804570322e054e6, 0x804570322e054e4, 0x15673387e0a4e4, 0x804570322e
next prev up dogecoin/src/validation.cpp:2620 │ bitcoin/src/validation.cpp:3068
│
│ AssertLockNotHeld(m_chainstate_mutex);
│ AssertLockNotHeld(::cs_main);
{ │ {
LOCK(cs_main); │ LOCK(cs_main);
if (pindex->nChainWork < chainActive.Tip()->nChainWork) { │ if (pindex->nChainWork < m_chain.Tip()->nChainWork) {
// Nothing to do, this block is not at the tip. │ // Nothing to do, this block is not at the tip.
return true; │ return true;
} │ }
if (chainActive.Tip()->nChainWork > nLastPreciousChainwork) { │ if (m_chain.Tip()->nChainWork > nLastPreciousChainwork) {
// The chain has been extended since the last call, reset the counter. │ // The chain has been extended since the last call, reset the counter.
nBlockReverseSequenceId = -1; │ nBlockReverseSequenceId = -1;
} │ }
nLastPreciousChainwork = chainActive.Tip()->nChainWork; │ nLastPreciousChainwork = m_chain.Tip()->nChainWork;
setBlockIndexCandidates.erase(pindex); │ setBlockIndexCandidates.erase(pindex);
pindex->nSequenceId = nBlockReverseSequenceId; │ pindex->nSequenceId = nBlockReverseSequenceId;
if (nBlockReverseSequenceId > std::numeric_limits<int32_t>::min()) { │ if (nBlockReverseSequenceId > std::numeric_limits<int32_t>::min()) {
// We can't keep reducing the counter if somebody really wants to │ // We can't keep reducing the counter if somebody really wants to
// call preciousblock 2**31-1 times on the same set of tips... │ // call preciousblock 2**31-1 times on the same set of tips...
nBlockReverseSequenceId--; │ nBlockReverseSequenceId--;
} │ }
if (pindex->IsValid(BLOCK_VALID_TRANSACTIONS) && pindex->nChainTx) { │ if (pindex->IsValid(BLOCK_VALID_TRANSACTIONS) && pindex->HaveTxsDownloaded()) {
setBlockIndexCandidates.insert(pindex); │ setBlockIndexCandidates.insert(pindex);
PruneBlockIndexCandidates(); │ PruneBlockIndexCandidates();
} │ }
} │ }
│
return ActivateBestChain(state, params); │ return ActivateBestChain(state, std::shared_ptr<const CBlock>());
} │
next prev up dogecoin/src/bitcoin-tx.cpp:139 │ bitcoin/src/bitcoin-tx.cpp:152
│
// separate NAME:FILENAME in string │ // separate NAME:FILENAME in string
size_t pos = strInput.find(':'); │ size_t pos = strInput.find(':');
if ((pos == std::string::npos) || │ if ((pos == std::string::npos) ||
(pos == 0) || │ (pos == 0) ||
(pos == (strInput.size() - 1))) │ (pos == (strInput.size() - 1)))
throw std::runtime_error("Register load requires NAME:FILENAME"); │ throw std::runtime_error("Register load requires NAME:FILENAME");
│
std::string key = strInput.substr(0, pos); │ std::string key = strInput.substr(0, pos);
std::string filename = strInput.substr(pos + 1, std::string::npos); │ std::string filename = strInput.substr(pos + 1, std::string::npos);
│
FILE *f = fopen(filename.c_str(), "r"); │ FILE *f = fsbridge::fopen(filename.c_str(), "r");
if (!f) { │ if (!f) {
std::string strErr = "Cannot open file " + filename; │ std::string strErr = "Cannot open file " + filename;
throw std::runtime_error(strErr); │ throw std::runtime_error(strErr);
} │ }
│
// load file chunks into one big buffer │ // load file chunks into one big buffer
std::string valStr; │ std::string valStr;
while ((!feof(f)) && (!ferror(f))) { │ while ((!feof(f)) && (!ferror(f))) {
char buf[4096]; │ char buf[4096];
int bread = fread(buf, 1, sizeof(buf), f); │ int bread = fread(buf, 1, sizeof(buf), f);
if (bread <= 0) │ if (bread <= 0)
break; │ break;
│
valStr.insert(valStr.size(), buf, bread); │ valStr.insert(valStr.size(), buf, bread);
} │ }
│
int error = ferror(f); │ int error = ferror(f);
fclose(f); │ fclose(f);
│
if (error) { │ if (error) {
std::string strErr = "Error reading file " + filename; │ std::string strErr = "Error reading file " + filename;
throw std::runtime_error(strErr); │ throw std::runtime_error(strErr);
} │ }
│
// evaluate as JSON buffer register │ // evaluate as JSON buffer register
RegisterSetJson(key, valStr); │ RegisterSetJson(key, valStr);
} │
next prev up bitcoin/src/minisketch/src/fields/clmul_8bytes.cpp:66 │ bitcoin/src/minisketch/src/fields/generic_8bytes.cpp:45
0x38d905ab028567a, 0x789fa6ed3b44d72, 0x789fa6ed3b44d70, 0x74ec857e93d828c, 0x789fa6ed3b │ 0x38d905ab028567a, 0x789fa6ed3b44d72, 0x789fa6ed3b44d70, 0x74ec857e93d828c, 0x789fa6ed3
next prev up bitcoin/src/qt/platformstyle.cpp:27 │ dogecoin/src/qt/platformstyle.cpp:32
│
/* Local functions for colorizing single-color images */ │ /* Local functions for colorizing single-color images */
│
void MakeSingleColorImage(QImage& img, const QColor& colorbase) │ void MakeSingleColorImage(QImage& img, const QColor& colorbase)
{ │ {
img = img.convertToFormat(QImage::Format_ARGB32); │ img = img.convertToFormat(QImage::Format_ARGB32);
for (int x = img.width(); x--; ) │ for (int x = img.width(); x--; )
{ │ {
for (int y = img.height(); y--; ) │ for (int y = img.height(); y--; )
{ │ {
const QRgb rgb = img.pixel(x, y); │ const QRgb rgb = img.pixel(x, y);
img.setPixel(x, y, qRgba(colorbase.red(), colorbase.green(), colorbase.blue( │ img.setPixel(x, y, qRgba(colorbase.red(), colorbase.green(), colorbase.blue(
} │ }
} │ }
} │ }
│
QIcon ColorizeIcon(const QIcon& ico, const QColor& colorbase) │ QIcon ColorizeIcon(const QIcon& ico, const QColor& colorbase)
{ │ {
QIcon new_ico; │ QIcon new_ico;
for (const QSize& sz : ico.availableSizes()) │ QSize sz;
│ Q_FOREACH(sz, ico.availableSizes())
{ │ {
QImage img(ico.pixmap(sz).toImage()); │ QImage img(ico.pixmap(sz).toImage());
MakeSingleColorImage(img, colorbase); │ MakeSingleColorImage(img, colorbase);
new_ico.addPixmap(QPixmap::fromImage(img)); │ new_ico.addPixmap(QPixmap::fromImage(img));
} │ }
return new_ico; │ return new_ico;
} │ }
│
QImage ColorizeImage(const QString& filename, const QColor& colorbase) │ QImage ColorizeImage(const QString& filename, const QColor& colorbase)
{ │ {
QImage img(filename); │ QImage img(filename);
MakeSingleColorImage(img, colorbase); │ MakeSingleColorImage(img, colorbase);
return img; │ return img;
} │ }
│
QIcon ColorizeIcon(const QString& filename, const QColor& colorbase) │ QIcon ColorizeIcon(const QString& filename, const QColor& colorbase)
{ │ {
return QIcon(QPixmap::fromImage(ColorizeImage(filename, colorbase))); │ return QIcon(QPixmap::fromImage(ColorizeImage(filename, colorbase)));
} │ }
│
} │
next prev up bitcoin/src/validation.cpp:3414 │ dogecoin/src/validation.cpp:3041
│
std::vector<unsigned char> commitment; │ std::vector<unsigned char> commitment;
int commitpos = GetWitnessCommitmentIndex(block); │ int commitpos = GetWitnessCommitmentIndex(block);
std::vector<unsigned char> ret(32, 0x00); │ std::vector<unsigned char> ret(32, 0x00);
if (commitpos == NO_WITNESS_COMMITMENT) { │ if (consensusParams.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout != 0) {
uint256 witnessroot = BlockWitnessMerkleRoot(block, nullptr); │ if (commitpos == -1) {
CHash256().Write(witnessroot).Write(ret).Finalize(witnessroot); │ uint256 witnessroot = BlockWitnessMerkleRoot(block, NULL);
CTxOut out; │ CHash256().Write(witnessroot.begin(), 32).Write(&ret[0], 32).Finalize(witnes
out.nValue = 0; │ CTxOut out;
out.scriptPubKey.resize(MINIMUM_WITNESS_COMMITMENT); │ out.nValue = 0;
out.scriptPubKey[0] = OP_RETURN; │ out.scriptPubKey.resize(38);
out.scriptPubKey[1] = 0x24; │ out.scriptPubKey[0] = OP_RETURN;
out.scriptPubKey[2] = 0xaa; │ out.scriptPubKey[1] = 0x24;
out.scriptPubKey[3] = 0x21; │ out.scriptPubKey[2] = 0xaa;
out.scriptPubKey[4] = 0xa9; │ out.scriptPubKey[3] = 0x21;
out.scriptPubKey[5] = 0xed; │ out.scriptPubKey[4] = 0xa9;
memcpy(&out.scriptPubKey[6], witnessroot.begin(), 32); │ out.scriptPubKey[5] = 0xed;
commitment = std::vector<unsigned char>(out.scriptPubKey.begin(), out.scriptPubK │ memcpy(&out.scriptPubKey[6], witnessroot.begin(), 32);
CMutableTransaction tx(*block.vtx[0]); │ commitment = std::vector<unsigned char>(out.scriptPubKey.begin(), out.script
tx.vout.push_back(out); │ CMutableTransaction tx(*block.vtx[0]);
block.vtx[0] = MakeTransactionRef(std::move(tx)); │ tx.vout.push_back(out);
│ block.vtx[0] = MakeTransactionRef(std::move(tx));
│ }
} │ }
UpdateUncommittedBlockStructures(block, pindexPrev, consensusParams); │ UpdateUncommittedBlockStructures(block, pindexPrev, consensusParams);
return commitment; │ return commitment;
} │
next prev up dogecoin/src/wallet/wallet.cpp:2154 │ bitcoin/src/wallet/coinselection.cpp:217
│
│ for (unsigned int i = 0; i < groups.size(); i++)
│ {
//The solver here uses a randomized algorithm, │ //The solver here uses a randomized algorithm,
//the randomness serves no real security purpose but is just │ //the randomness serves no real security purpose but is just
//needed to prevent degenerate behavior and it is important │ //needed to prevent degenerate behavior and it is important
//that the rng is fast. We do not use a constant random sequence, │ //that the rng is fast. We do not use a constant random sequence,
//because there may be some privacy improvement by making │ //because there may be some privacy improvement by making
//the selection random. │ //the selection random.
if (nPass == 0 ? insecure_rand.rand32()&1 : !vfIncluded[i]) │ if (nPass == 0 ? insecure_rand.randbool() : !vfIncluded[i])
{ │ {
nTotal += vValue[i].first; │ nTotal += groups[i].GetSelectionAmount();
vfIncluded[i] = true; │ vfIncluded[i] = true;
if (nTotal >= nTargetValue) │ if (nTotal >= nTargetValue)
{ │ {
fReachedTarget = true; │ fReachedTarget = true;
│ // If the total is between nTargetValue and nBest, it's our new
│ // approximation.
if (nTotal < nBest) │ if (nTotal < nBest)
{ │ {
nBest = nTotal; │ nBest = nTotal;
vfBest = vfIncluded; │ vfBest = vfIncluded;
} │ }
nTotal -= vValue[i].first; │ nTotal -= groups[i].GetSelectionAmount();
vfIncluded[i] = false; │ vfIncluded[i] = false;
} │ }
} │ }
│
next prev up dogecoin/src/rpc/server.cpp:375 │ bitcoin/src/rpc/request.cpp:159
│
// Parse request │ // Parse request
if (!valRequest.isObject()) │ if (!valRequest.isObject())
throw JSONRPCError(RPC_INVALID_REQUEST, "Invalid Request object"); │ throw JSONRPCError(RPC_INVALID_REQUEST, "Invalid Request object");
const UniValue& request = valRequest.get_obj(); │ const UniValue& request = valRequest.get_obj();
│
// Parse id now so errors from here on will have the id │ // Parse id now so errors from here on will have the id
id = find_value(request, "id"); │ id = find_value(request, "id");
│
// Parse method │ // Parse method
UniValue valMethod = find_value(request, "method"); │ UniValue valMethod = find_value(request, "method");
if (valMethod.isNull()) │ if (valMethod.isNull())
throw JSONRPCError(RPC_INVALID_REQUEST, "Missing method"); │ throw JSONRPCError(RPC_INVALID_REQUEST, "Missing method");
if (!valMethod.isStr()) │ if (!valMethod.isStr())
throw JSONRPCError(RPC_INVALID_REQUEST, "Method must be a string"); │ throw JSONRPCError(RPC_INVALID_REQUEST, "Method must be a string");
strMethod = valMethod.get_str(); │ strMethod = valMethod.get_str();
if (strMethod != "getblocktemplate") │ if (fLogIPs)
LogPrint("rpc", "ThreadRPCServer method=%s\n", SanitizeString(strMethod)); │ LogPrint(BCLog::RPC, "ThreadRPCServer method=%s user=%s peeraddr=%s\n", Sanitize
│ this->authUser, this->peerAddr);
│ else
│ LogPrint(BCLog::RPC, "ThreadRPCServer method=%s user=%s\n", SanitizeString(strMe
│
// Parse params │ // Parse params
UniValue valParams = find_value(request, "params"); │ UniValue valParams = find_value(request, "params");
if (valParams.isArray() || valParams.isObject()) │ if (valParams.isArray() || valParams.isObject())
params = valParams; │ params = valParams;
else if (valParams.isNull()) │ else if (valParams.isNull())
params = UniValue(UniValue::VARR); │ params = UniValue(UniValue::VARR);
else │ else
throw JSONRPCError(RPC_INVALID_REQUEST, "Params must be an array or object"); │ throw JSONRPCError(RPC_INVALID_REQUEST, "Params must be an array or object");
} │
next prev up bitcoin/src/minisketch/src/fields/clmul_8bytes.cpp:54 │ bitcoin/src/minisketch/src/fields/generic_8bytes.cpp:36
0x2450096792a5c5c, 0x610014271011c, 0x610014271011e, 0x1f0cb811314ea88, 0x610014271011a, │ 0x2450096792a5c5c, 0x610014271011c, 0x610014271011e, 0x1f0cb811314ea88, 0x610014271011a
next prev up dogecoin/src/versionbits.cpp:139 │ bitcoin/src/versionbits.cpp:176
│
/** │ /**
* Class to implement versionbits logic. │ * Class to implement versionbits logic.
*/ │ */
class VersionBitsConditionChecker : public AbstractThresholdConditionChecker { │ class VersionBitsConditionChecker : public AbstractThresholdConditionChecker {
private: │ private:
const Consensus::DeploymentPos id; │ const Consensus::DeploymentPos id;
│
protected: │ protected:
int64_t BeginTime(const Consensus::Params& params) const { return params.vDeployment │ int64_t BeginTime(const Consensus::Params& params) const override { return params.vD
int64_t EndTime(const Consensus::Params& params) const { return params.vDeployments[ │ int64_t EndTime(const Consensus::Params& params) const override { return params.vDep
int Period(const Consensus::Params& params) const { return params.nMinerConfirmation │ int MinActivationHeight(const Consensus::Params& params) const override { return par
int Threshold(const Consensus::Params& params) const { return params.nRuleChangeActi │ int Period(const Consensus::Params& params) const override { return params.nMinerCon
│ int Threshold(const Consensus::Params& params) const override { return params.nRuleC
│
bool Condition(const CBlockIndex* pindex, const Consensus::Params& params) const │ bool Condition(const CBlockIndex* pindex, const Consensus::Params& params) const ove
{ │ {
return (((pindex->nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS) && ( │ return (((pindex->nVersion & VERSIONBITS_TOP_MASK) == VERSIONBITS_TOP_BITS) && (
} │ }
│
public: │ public:
VersionBitsConditionChecker(Consensus::DeploymentPos id_) : id(id_) {} │ explicit VersionBitsConditionChecker(Consensus::DeploymentPos id_) : id(id_) {}
uint32_t Mask(const Consensus::Params& params) const { return ((uint32_t)1) << param │ uint32_t Mask(const Consensus::Params& params) const { return ((uint32_t)1) << param
}; │ };
│
} │
next prev up dogecoin/src/test/crypto_tests.cpp:26 │ bitcoin/src/test/crypto_tests.cpp:30
│
Out hash; │ Out hash;
BOOST_CHECK(out.size() == h.OUTPUT_SIZE); │ BOOST_CHECK(out.size() == h.OUTPUT_SIZE);
hash.resize(out.size()); │ hash.resize(out.size());
{ │ {
// Test that writing the whole input string at once works. │ // Test that writing the whole input string at once works.
Hasher(h).Write((unsigned char*)&in[0], in.size()).Finalize(&hash[0]); │ Hasher(h).Write((const uint8_t*)in.data(), in.size()).Finalize(hash.data());
BOOST_CHECK(hash == out); │ BOOST_CHECK(hash == out);
} │ }
for (int i=0; i<32; i++) { │ for (int i=0; i<32; i++) {
// Test that writing the string broken up in random pieces works. │ // Test that writing the string broken up in random pieces works.
Hasher hasher(h); │ Hasher hasher(h);
size_t pos = 0; │ size_t pos = 0;
while (pos < in.size()) { │ while (pos < in.size()) {
size_t len = insecure_rand() % ((in.size() - pos + 1) / 2 + 1); │ size_t len = InsecureRandRange((in.size() - pos + 1) / 2 + 1);
hasher.Write((unsigned char*)&in[pos], len); │ hasher.Write((const uint8_t*)in.data() + pos, len);
pos += len; │ pos += len;
if (pos > 0 && pos + 2 * out.size() > in.size() && pos < in.size()) { │ if (pos > 0 && pos + 2 * out.size() > in.size() && pos < in.size()) {
// Test that writing the rest at once to a copy of a hasher works. │ // Test that writing the rest at once to a copy of a hasher works.
Hasher(hasher).Write((unsigned char*)&in[pos], in.size() - pos).Finalize │ Hasher(hasher).Write((const uint8_t*)in.data() + pos, in.size() - pos).F
BOOST_CHECK(hash == out); │ BOOST_CHECK(hash == out);
} │ }
} │ }
hasher.Finalize(&hash[0]); │ hasher.Finalize(hash.data());
BOOST_CHECK(hash == out); │ BOOST_CHECK(hash == out);
} │ }
} │
next prev up dogecoin/src/qt/transactiontablemodel.cpp:663 │ bitcoin/src/qt/transactiontablemodel.cpp:662
│
if(orientation == Qt::Horizontal) │ if(orientation == Qt::Horizontal)
{ │ {
if(role == Qt::DisplayRole) │ if(role == Qt::DisplayRole)
{ │ {
return columns[section]; │ return columns[section];
} │ }
else if (role == Qt::TextAlignmentRole) │ else if (role == Qt::TextAlignmentRole)
{ │ {
return column_alignments[section]; │ return column_alignments[section];
} else if (role == Qt::ToolTipRole) │ } else if (role == Qt::ToolTipRole)
{ │ {
switch(section) │ switch(section)
{ │ {
case Status: │ case Status:
return tr("Transaction status. Hover over this field to show number of c │ return tr("Transaction status. Hover over this field to show number of c
case Date: │ case Date:
return tr("Date and time that the transaction was received."); │ return tr("Date and time that the transaction was received.");
case Type: │ case Type:
return tr("Type of transaction."); │ return tr("Type of transaction.");
case Watchonly: │ case Watchonly:
return tr("Whether or not a watch-only address is involved in this trans │ return tr("Whether or not a watch-only address is involved in this trans
case ToAddress: │ case ToAddress:
return tr("User-defined intent/purpose of the transaction."); │ return tr("User-defined intent/purpose of the transaction.");
case Amount: │ case Amount:
return tr("Amount removed from or added to balance."); │ return tr("Amount removed from or added to balance.");
} │ }
} │ }
} │ }
return QVariant(); │ return QVariant();
} │
next prev up dogecoin/src/qt/optionsdialog.cpp:303 │ bitcoin/src/qt/optionsdialog.cpp:397
│
proxyType proxy; │ Proxy proxy;
std::string strProxy; │ std::string strProxy;
QString strDefaultProxyGUI; │ QString strDefaultProxyGUI;
│
GetProxy(NET_IPV4, proxy); │ model->node().getProxy(NET_IPV4, proxy);
strProxy = proxy.proxy.ToStringIP() + ":" + proxy.proxy.ToStringPort(); │ strProxy = proxy.proxy.ToStringIP() + ":" + proxy.proxy.ToStringPort();
strDefaultProxyGUI = ui->proxyIp->text() + ":" + ui->proxyPort->text(); │ strDefaultProxyGUI = ui->proxyIp->text() + ":" + ui->proxyPort->text();
(strProxy == strDefaultProxyGUI.toStdString()) ? ui->proxyReachIPv4->setChecked(true │ (strProxy == strDefaultProxyGUI.toStdString()) ? ui->proxyReachIPv4->setChecked(true
│
GetProxy(NET_IPV6, proxy); │ model->node().getProxy(NET_IPV6, proxy);
strProxy = proxy.proxy.ToStringIP() + ":" + proxy.proxy.ToStringPort(); │ strProxy = proxy.proxy.ToStringIP() + ":" + proxy.proxy.ToStringPort();
strDefaultProxyGUI = ui->proxyIp->text() + ":" + ui->proxyPort->text(); │ strDefaultProxyGUI = ui->proxyIp->text() + ":" + ui->proxyPort->text();
(strProxy == strDefaultProxyGUI.toStdString()) ? ui->proxyReachIPv6->setChecked(true │ (strProxy == strDefaultProxyGUI.toStdString()) ? ui->proxyReachIPv6->setChecked(true
│
GetProxy(NET_TOR, proxy); │ model->node().getProxy(NET_ONION, proxy);
strProxy = proxy.proxy.ToStringIP() + ":" + proxy.proxy.ToStringPort(); │ strProxy = proxy.proxy.ToStringIP() + ":" + proxy.proxy.ToStringPort();
strDefaultProxyGUI = ui->proxyIp->text() + ":" + ui->proxyPort->text(); │ strDefaultProxyGUI = ui->proxyIp->text() + ":" + ui->proxyPort->text();
(strProxy == strDefaultProxyGUI.toStdString()) ? ui->proxyReachTor->setChecked(true) │ (strProxy == strDefaultProxyGUI.toStdString()) ? ui->proxyReachTor->setChecked(true)
} │
next prev up dogecoin/src/test/util_tests.cpp:52 │ bitcoin/src/test/util_tests.cpp:157
│
std::vector<unsigned char> result; │ std::vector<unsigned char> result;
std::vector<unsigned char> expected(ParseHex_expected, ParseHex_expected + sizeof(Pa │ std::vector<unsigned char> expected(ParseHex_expected, ParseHex_expected + sizeof(Pa
// Basic test vector │ // Basic test vector
result = ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb │ result = ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb
BOOST_CHECK_EQUAL_COLLECTIONS(result.begin(), result.end(), expected.begin(), expect │ BOOST_CHECK_EQUAL_COLLECTIONS(result.begin(), result.end(), expected.begin(), expect
│
// Spaces between bytes must be supported │ // Spaces between bytes must be supported
result = ParseHex("12 34 56 78"); │ result = ParseHex("12 34 56 78");
BOOST_CHECK(result.size() == 4 && result[0] == 0x12 && result[1] == 0x34 && result[2 │ BOOST_CHECK(result.size() == 4 && result[0] == 0x12 && result[1] == 0x34 && result[2
│
// Leading space must be supported (used in CDBEnv::Salvage) │ // Leading space must be supported (used in BerkeleyEnvironment::Salvage)
result = ParseHex(" 89 34 56 78"); │ result = ParseHex(" 89 34 56 78");
BOOST_CHECK(result.size() == 4 && result[0] == 0x89 && result[1] == 0x34 && result[2 │ BOOST_CHECK(result.size() == 4 && result[0] == 0x89 && result[1] == 0x34 && result[2
│
// Stop parsing at invalid value │ // Stop parsing at invalid value
result = ParseHex("1234 invalid 1234"); │ result = ParseHex("1234 invalid 1234");
BOOST_CHECK(result.size() == 2 && result[0] == 0x12 && result[1] == 0x34); │ BOOST_CHECK(result.size() == 2 && result[0] == 0x12 && result[1] == 0x34);
} │
next prev up dogecoin/src/support/lockedpool.cpp:325 │ bitcoin/src/support/lockedpool.cpp:340
│
bool locked; │ bool locked;
// If this is the first arena, handle this specially: Cap the upper size │ // If this is the first arena, handle this specially: Cap the upper size
// by the process limit. This makes sure that the first arena will at least │ // by the process limit. This makes sure that the first arena will at least
// be locked. An exception to this is if the process limit is 0: │ // be locked. An exception to this is if the process limit is 0:
// in this case no memory can be locked at all so we'll skip past this logic. │ // in this case no memory can be locked at all so we'll skip past this logic.
if (arenas.empty()) { │ if (arenas.empty()) {
size_t limit = allocator->GetLimit(); │ size_t limit = allocator->GetLimit();
if (limit > 0) { │ if (limit > 0) {
size = std::min(size, limit); │ size = std::min(size, limit);
} │ }
} │ }
void *addr = allocator->AllocateLocked(size, &locked); │ void *addr = allocator->AllocateLocked(size, &locked);
if (!addr) { │ if (!addr) {
return false; │ return false;
} │ }
if (locked) { │ if (locked) {
cumulative_bytes_locked += size; │ cumulative_bytes_locked += size;
} else if (lf_cb) { // Call the locking-failed callback if locking failed │ } else if (lf_cb) { // Call the locking-failed callback if locking failed
if (!lf_cb()) { // If the callback returns false, free the memory and fail, othe │ if (!lf_cb()) { // If the callback returns false, free the memory and fail, othe
allocator->FreeLocked(addr, size); │ allocator->FreeLocked(addr, size);
return false; │ return false;
} │ }
} │ }
arenas.emplace_back(allocator.get(), addr, size, align); │ arenas.emplace_back(allocator.get(), addr, size, align);
return true; │ return true;
} │
next prev up dogecoin/src/qt/askpassphrasedialog.cpp:238 │ bitcoin/src/qt/askpassphrasedialog.cpp:238
│
/* Detect Caps Lock. │ /* Detect Caps Lock.
* There is no good OS-independent way to check a key state in Qt, but we │ * There is no good OS-independent way to check a key state in Qt, but we
* can detect Caps Lock by checking for the following condition: │ * can detect Caps Lock by checking for the following condition:
* Shift key is down and the result is a lower case character, or │ * Shift key is down and the result is a lower case character, or
* Shift key is not down and the result is an upper case character. │ * Shift key is not down and the result is an upper case character.
*/ │ */
if (event->type() == QEvent::KeyPress) { │ if (event->type() == QEvent::KeyPress) {
QKeyEvent *ke = static_cast<QKeyEvent *>(event); │ QKeyEvent *ke = static_cast<QKeyEvent *>(event);
QString str = ke->text(); │ QString str = ke->text();
if (str.length() != 0) { │ if (str.length() != 0) {
const QChar *psz = str.unicode(); │ const QChar *psz = str.unicode();
bool fShift = (ke->modifiers() & Qt::ShiftModifier) != 0; │ bool fShift = (ke->modifiers() & Qt::ShiftModifier) != 0;
if ((fShift && *psz >= 'a' && *psz <= 'z') || (!fShift && *psz >= 'A' && *ps │ if ((fShift && *psz >= 'a' && *psz <= 'z') || (!fShift && *psz >= 'A' && *ps
fCapsLock = true; │ fCapsLock = true;
ui->capsLabel->setText(tr("Warning: The Caps Lock key is on!")); │ ui->capsLabel->setText(tr("Warning: The Caps Lock key is on!"));
} else if (psz->isLetter()) { │ } else if (psz->isLetter()) {
fCapsLock = false; │ fCapsLock = false;
ui->capsLabel->clear(); │ ui->capsLabel->clear();
} │ }
} │ }
} │ }
return QDialog::eventFilter(object, event); │ return QDialog::eventFilter(object, event);
} │
next prev up bitcoin/src/policy/rbf.cpp:13 │ dogecoin/src/policy/rbf.cpp:18
│
AssertLockHeld(pool.cs); │ AssertLockHeld(pool.cs);
│
CTxMemPool::setEntries ancestors; │ CTxMemPool::setEntries setAncestors;
│
// First check the transaction itself. │ // First check the transaction itself.
if (SignalsOptInRBF(tx)) { │ if (SignalsOptInRBF(tx)) {
return RBFTransactionState::REPLACEABLE_BIP125; │ return RBF_TRANSACTIONSTATE_REPLACEABLE_BIP125;
} │ }
│
// If this transaction is not in our mempool, then we can't be sure │ // If this transaction is not in our mempool, then we can't be sure
// we will know about all its inputs. │ // we will know about all its inputs.
if (!pool.exists(GenTxid::Txid(tx.GetHash()))) { │ if (!pool.exists(tx.GetHash())) {
return RBFTransactionState::UNKNOWN; │ return RBF_TRANSACTIONSTATE_UNKNOWN;
} │ }
│
// If all the inputs have nSequence >= maxint-1, it still might be │ // If all the inputs have nSequence >= maxint-1, it still might be
// signaled for RBF if any unconfirmed parents have signaled. │ // signaled for RBF if any unconfirmed parents have signaled.
uint64_t noLimit = std::numeric_limits<uint64_t>::max(); │ uint64_t noLimit = std::numeric_limits<uint64_t>::max();
std::string dummy; │ std::string dummy;
CTxMemPoolEntry entry = *pool.mapTx.find(tx.GetHash()); │ CTxMemPoolEntry entry = *pool.mapTx.find(tx.GetHash());
pool.CalculateMemPoolAncestors(entry, ancestors, noLimit, noLimit, noLimit, noLimit, │ pool.CalculateMemPoolAncestors(entry, setAncestors, noLimit, noLimit, noLimit, noLim
│
for (CTxMemPool::txiter it : ancestors) { │ BOOST_FOREACH(CTxMemPool::txiter it, setAncestors) {
if (SignalsOptInRBF(it->GetTx())) { │ if (SignalsOptInRBF(it->GetTx())) {
return RBFTransactionState::REPLACEABLE_BIP125; │ return RBF_TRANSACTIONSTATE_REPLACEABLE_BIP125;
} │ }
} │ }
return RBFTransactionState::FINAL; │ return RBF_TRANSACTIONSTATE_FINAL;
} │
next prev up bitcoin/src/minisketch/src/fields/clmul_8bytes.cpp:31 │ bitcoin/src/minisketch/src/fields/generic_8bytes.cpp:27
0xd0c3a82c902426, 0x232aa54103915e, 0x232aa54103915c, 0x1763e291e61699c, 0x232aa54103915 │ 0xd0c3a82c902426, 0x232aa54103915e, 0x232aa54103915c, 0x1763e291e61699c, 0x232aa5410391
next prev up dogecoin/src/test/crypto_tests.cpp:204 │ bitcoin/src/test/crypto_tests.cpp:207
│
TestRIPEMD160("", "9c1185a5c5e9fc54612808977ee8f548b2258d31"); │ TestRIPEMD160("", "9c1185a5c5e9fc54612808977ee8f548b2258d31");
TestRIPEMD160("abc", "8eb208f7e05d987a9b044a8e98c6b087f15a0bfc"); │ TestRIPEMD160("abc", "8eb208f7e05d987a9b044a8e98c6b087f15a0bfc");
TestRIPEMD160("message digest", "5d0689ef49d2fae572b881b123a85ffa21595f36"); │ TestRIPEMD160("message digest", "5d0689ef49d2fae572b881b123a85ffa21595f36");
TestRIPEMD160("secure hash algorithm", "20397528223b6a5f4cbc2808aba0464e645544f9"); │ TestRIPEMD160("secure hash algorithm", "20397528223b6a5f4cbc2808aba0464e645544f9");
TestRIPEMD160("RIPEMD160 is considered to be safe", "a7d78608c7af8a8e728778e81576870 │ TestRIPEMD160("RIPEMD160 is considered to be safe", "a7d78608c7af8a8e728778e81576870
TestRIPEMD160("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", │ TestRIPEMD160("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
"12a053384a9c0c88e405a06c27dcf49ada62eb2b"); │ "12a053384a9c0c88e405a06c27dcf49ada62eb2b");
TestRIPEMD160("For this sample, this 63-byte string will be used as input data", │ TestRIPEMD160("For this sample, this 63-byte string will be used as input data",
"de90dbfee14b63fb5abf27c2ad4a82aaa5f27a11"); │ "de90dbfee14b63fb5abf27c2ad4a82aaa5f27a11");
TestRIPEMD160("This is exactly 64 bytes long, not counting the terminating byte", │ TestRIPEMD160("This is exactly 64 bytes long, not counting the terminating byte",
"eda31d51d3a623b81e19eb02e24ff65d27d67b37"); │ "eda31d51d3a623b81e19eb02e24ff65d27d67b37");
TestRIPEMD160(std::string(1000000, 'a'), "52783243c1697bdbe16d37f97f68f08325dc1528") │ TestRIPEMD160(std::string(1000000, 'a'), "52783243c1697bdbe16d37f97f68f08325dc1528")
TestRIPEMD160(test1, "464243587bd146ea835cdf57bdae582f25ec45f1"); │ TestRIPEMD160(test1, "464243587bd146ea835cdf57bdae582f25ec45f1");
} │