From c58fef0d01312d6e732d068fa19193301109bb84 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 7 Jan 2020 09:26:49 -0500 Subject: [PATCH 001/255] Dynamic generation of zaddrs not stored in wallet These zaddrs can be created via: z_getnewaddress donotremember and return a zaddr like normal usage, but without storing it's extended spending key in wallet.dat. This will be utilized by Sietch to generate dynamic zdust for every shielded transaction, preventing attacks related to having chain-wide fixed pools of zdust. --- src/init.cpp | 2 +- src/wallet/rpcwallet.cpp | 23 +++++++++++++++-------- src/wallet/wallet.cpp | 6 +++--- src/wallet/wallet.h | 5 +++-- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 36ed5e0cb..7f660c555 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers -// Copyright (c) 2019 The Hush developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 6b145baf6..aa22f7ef0 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -70,8 +70,8 @@ using namespace libzcash; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern std::string ASSETCHAINS_OVERRIDE_PUBKEY; -const std::string ADDR_TYPE_SPROUT = "sprout"; -const std::string ADDR_TYPE_SAPLING = "sapling"; +const std::string ADDR_TYPE_SAPLING = "sapling"; +const std::string ADDR_TYPE_DONOTREMEMBER = "donotremember"; extern UniValue TxJoinSplitToJSON(const CTransaction& tx); extern int32_t KOMODO_INSYNC; uint32_t komodo_segid32(char *coinaddr); @@ -3716,15 +3716,16 @@ UniValue z_getnewaddress(const UniValue& params, bool fHelp, const CPubKey& mypk throw runtime_error( "z_getnewaddress ( type )\n" "\nReturns a new shielded address for receiving payments.\n" - "\nWith no arguments, returns a Sprout address.\n" + "\nWith no arguments, returns a Sapling address.\n" + "\nBe very careful with 'donotremember' address type, the extended spending key (xsk) of that address is not stored in wallet.dat!\n" "\nArguments:\n" - "1. \"type\" (string, optional, default=\"" + defaultType + "\") The type of address. One of [\"" - + ADDR_TYPE_SAPLING + "\"].\n" + "1. \"type\" (string, optional, default=\"" + defaultType + "\") The type of address. Either "+ ADDR_TYPE_SAPLING + " or " + ADDR_TYPE_DONOTREMEMBER + " .\n" "\nResult:\n" "\"" + strprintf("%s",komodo_chainname()) + "_address\" (string) The new shielded address.\n" "\nExamples:\n" + HelpExampleCli("z_getnewaddress", "") + HelpExampleCli("z_getnewaddress", ADDR_TYPE_SAPLING) + + HelpExampleCli("z_getnewaddress", ADDR_TYPE_DONOTREMEMBER) ); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -3735,11 +3736,17 @@ UniValue z_getnewaddress(const UniValue& params, bool fHelp, const CPubKey& mypk if (params.size() > 0) { addrType = params[0].get_str(); } - if (addrType == ADDR_TYPE_SAPLING) { return EncodePaymentAddress(pwalletMain->GenerateNewSaplingZKey()); + } else if (addrType == ADDR_TYPE_DONOTREMEMBER) { + bool addToWallet = false; + auto zaddr = EncodePaymentAddress(pwalletMain->GenerateNewSaplingZKey(addToWallet)); + if(fZdebug) { + fprintf(stderr,"%s: Sietch zaddr=%s created, xsk not stored in wallet.dat!\n", __FUNCTION__, zaddr.c_str() ); + } + return zaddr; } else { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid address type!"); + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid address type! Try " + ADDR_TYPE_SAPLING + " or " + ADDR_TYPE_DONOTREMEMBER); } } @@ -4049,7 +4056,7 @@ UniValue z_gettotalbalance(const UniValue& params, bool fHelp, const CPubKey& my "\nResult:\n" "{\n" " \"transparent\": xxxxx, (numeric) the total balance of transparent funds\n" - " \"private\": xxxxx, (numeric) the total balance of private funds (in both Sprout and Sapling addresses)\n" + " \"private\": xxxxx, (numeric) the total balance of shielded funds\n" " \"total\": xxxxx, (numeric) the total balance of both transparent and private funds\n" "}\n" "\nExamples:\n" diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index b52ccdb9f..a9e79a3a3 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers -// Copyright (c) 2019 The Hush developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -127,7 +127,7 @@ libzcash::SproutPaymentAddress CWallet::GenerateNewSproutZKey() } // Generate a new Sapling spending key and return its public payment address -SaplingPaymentAddress CWallet::GenerateNewSaplingZKey() +SaplingPaymentAddress CWallet::GenerateNewSaplingZKey(bool addToWallet) { AssertLockHeld(cs_wallet); // mapSaplingZKeyMetadata @@ -168,7 +168,7 @@ SaplingPaymentAddress CWallet::GenerateNewSaplingZKey() mapSaplingZKeyMetadata[ivk] = metadata; auto addr = xsk.DefaultAddress(); - if (!AddSaplingZKey(xsk, addr)) { + if (addToWallet && !AddSaplingZKey(xsk, addr)) { throw std::runtime_error("CWallet::GenerateNewSaplingZKey(): AddSaplingZKey failed"); } // return default sapling payment address. diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index eb350fb40..223fecb7d 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1,6 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers -// Copyright (c) 2019 The Hush developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -1093,7 +1093,8 @@ public: * Sapling ZKeys */ //! Generates new Sapling key - libzcash::SaplingPaymentAddress GenerateNewSaplingZKey(); + // Sietch uses addToWallet=false + libzcash::SaplingPaymentAddress GenerateNewSaplingZKey(bool addToWallet=true); //! Adds Sapling spending key to the store, and saves it to disk bool AddSaplingZKey( const libzcash::SaplingExtendedSpendingKey &key, From 89532c4d7b645e3c4b488ad7e1dc8df9a04e8170 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 7 Jan 2020 12:28:57 -0500 Subject: [PATCH 002/255] Use dynamically generated zaddrs in sietch, which are not stored in wallet.dat --- src/sietch.h | 225 ++------------------------------------- src/wallet/rpcwallet.cpp | 15 ++- 2 files changed, 17 insertions(+), 223 deletions(-) diff --git a/src/sietch.h b/src/sietch.h index 64a4fe0ce..3a83b529f 100644 --- a/src/sietch.h +++ b/src/sietch.h @@ -16,222 +16,17 @@ #ifndef SIETCH_H #define SIETCH_H -// The network essentially DoS's these addresses and reduces their privacy slightly -// by making them public, but in return, the rest of the shielded pool benefits -// and so it's a large benefit for a small cost. -string randomSietchZaddr() { - std::vector SietchShieldedPool1 = { - "zs1qqj4aw35ku9yn72g3tha588mxk66mhl5smnn99as40887xvdg49d4yqf43hhqnj9rpsq7qaqqhx", - "zs1qywzq2cutvg6rkynjljtssz246easagumg3hlwjluz4g7qttg9kqrld7s43ewutpph56jmn2zu6", - "zs1qx7swmw28dj992f6zs0aqucds9kag88mnca5u73dddeqek4m97pg7h9qsaxxwwkgqxht6zujaxc", - "zs1q82pkqu58uemrm2749x6g2ta5shnsra9p5jgk0qqzxd3e08ke6vyeezz7lhldj32jxtsuemskk7", - "zs1qvah5w05qq4yhrsqrt73ckgntkmwdv9mntxep8clnxqfph8xggqad96a5nvwg4evfr9pc5ruvc8", - "zs1qwrkjcmnrwrqqkz3dyfjvdvdppe0ndnm8fhhpsz8stje4qcfc54jtuygz2jfwc3aag69wsjcm8h", - "zs1q5pd7h4x7dtnpa4ace7tytye5sd0j4043t4f3jdntyxvg9ex258nu6pw9tthn6t5gmjq5gv0lhc", - "zs1q6vjrpsuf468an545q7fh9cx0xlkwh75a7qjpemjh3ymuqqzxz5ts2n2dcth3yfnlv6vqpjyglr", - "zs1qmsvwtxkwlh3tkh0lqtwqv2mxy94jt778f7j74a8067nejkt4j3m2rkmypccju7cfuw7xyg0gg8", - "zs1qu3jxrw5qwuvl7zfvnsdvywr4a9cn4h00me65te29platx5agek072f5rvxgt8kdt630qs4tgtr", - "zs1qamxwddwrl5xn56alffruk69p304cqf7uf5nhqpwfc374l9ph00m78xv2kzwymyz0fhxcku7v5k", - "zs1q7gv479e6q7d8fxc35v5s27em66mmm5gz50excudf95rzjgnwdy5pnwdfytvm7gt8kt6wpkfphq", - "zs1pqvxd9a2zcsh2v8gaswh3jp2qkzz5umrucl5k4gx0rkvmq68krpx3jesavxftd8t0z56v8whllj", - "zs1ppn2mdznaa2pd9mavfnxrcjtv0c9un8pg6jaa9ww4wy6wdfs8xxwquqk5umtcjwm6vr4zrqy5x7", - "zs1pz9c9ydyrm7e876cvae9ha45ww77ru5fhys2yz33kjy8ej9230wjy8yupfxkynwqr6nfupgmf94", - "zs1p83g95avpsgr847eu3rm3xcmgurt9hc77wtndnmpypa046n529aqdc9ptz04ugsuhvum2ztzwe3", - "zs1p83jle2p8awu4peevq389y5kyrs5tqxxyrk32zy0t98d4cfepmme0myxp68nrq60xwzc5teulvg", - "zs1pg5ggzwx4yaa7g83yuhay8kzh78nahxfe7cgavn88f7rxlnuckhl2vznv0f33yuqhhs3sh62vl6", - "zs1p2nrefmqfhnwrxqfsz4ruvu8wl7742j5rv2fmwlpmpudwqpdn2yrha9rwsu5gc0fdv2j73tfk6a", - "zs1pw29hkrvszxpe2e4tjpj5h9pszjhql2p4tzcj2c5lf67m7d8jtgc22vehftxdnqze33mgtjc25k", - "zs1p0ggg024alu2l5x8df8ucu4lz8r453su56w2mmshru49uh9a0p6ufy3qfj8a9n7xeu8dxxjrk4p", - "zs1psaydszvszu4mar7ef9gk8atmwpnfjjsh8plajn6ttlgdk44jfud5zv8l3uyq73qk3eskec96ut", - "zs1pjf3kczvrwduuy4x99t03wfrgwstueyw0ypvwa44fz2tukux8kqqqs48uag4y39ed4rux8etvv0", - "zs1pnwzzh4mhehkvf4ys9x70q6meq9mgqj6mgl9ddzwvf8excswrj54lfgu4m9slmc90s37q8e63du", - "zs1pnndevupuakjcqyqzu4sfcgdmdzrhutp8ygxwsl5wvq5hgu20u55auu8p08wphvz9mu3k8ynyr5", - "zs1pmy6tvt9p3xxp5edt70mkwfqk0ljgaranzdnluh5ln36g9g3v2udquleuz5974q2mamywmrxl7j", - "zs1pau6lddk3uapms7v7rsmxvxeekqh52z795kzy9z3dv9qvzq3jwh4pr2adg5cf8fw2e3mzqmgstq", - "zs1zpy6wuvy3jlrfmj0363tx6cuume6j0mqfakk7ydw4f6zvn4s7plewk0gtm7r34pjtppvkp8rzl0", - "zs1zpvkccety206ww6c344ehughuyklc3v02q07j4p72pqewxl0n50zugtje6lclj3m292t6vs56fl", - "zs1zzucdg9kalcjnnknt98gpg42qm9aqpkc6qf5ewgr29udu55r0zt862z3zt23sd4mj9t47k7k6w4", - "zs1z9agq4vq7eswwynhmzdsy58nxq3azhn66y853yw9kvercmve8vv6d5pawpwwpwpuyedmzpcqk8q", - "zs1zvddl2e0pve5kl0hu7fcum30lyhx4pdq64jztq2vp09lqtu5gclfg4fe9fqvnm8k2d5svydg7s4", - "zs1zvsmkn6a4celtcg8ece6exnkvnr2u06ej8kjt6mrpm0983e86dr9al6gd5g73k24j0a0zkpjs3w", - "zs1zv33kglx4n5572dg2pez2k3m7tgtz08a70ndpfj6x204pphlm0pzcppetsnjlat3qflswqfmu83", - "zs1zsz5c9xua7arkvd60vsl559d4dvnjz8ejq4rlmmm9cnz942fdmjmvsgrdl7d5ddxh4y9258jk2l", - "zs1z5n6qvch0wfymumxjflezekxa2j5t978eqzh9ldxsl39h2jjrlzdv9rf00wdrvg0t6afq7mq0us", - "zs1z4ymm3gt22f3pcj9p9l2yg00e2m39kfexgaz99s9y4nsuxhlk6u0sl9lsx9awzywumxyuxv9vuw", - "zs1zkjnhz96xepc97rfyven23epymd5s558yqhp488gcxcj794z6p37h5ej5m5waqxfupmc538mej3", - "zs1zcqdekyq656yj2y86lh08u8zpetfanj5u4rhfpcphne9xw7esce8asux2rdr4yjxzds56fuda5r", - "zs1zceru3jt9m3jqzacnffetvrg8zch6le0zactl7ssfky2vwy7pcffkg3pmauqqpkv5v7nv3uzc5a", - "zs1zellp4tdmxdsd6hmg2c4qlx96m39c0cjlqupw085z87lvzcnx2r0gs7plc0wp4m4upk3zcs35e8", - "zs1zm2pcg2d3hnyxufn8cyshjn742gmffwaqdc0nt5uf9gsytdjywsqaasfdxf4sysfu0sgxjwjp0g", - "zs1za9nk7fpgnfetjulq6t8jgfyks06xg4q8rfwpgsfrkn49k34nc7xhm27dnjuzztgnwkww28ztyw", - "zs1zaaz6j6z7z748mck4v55s3fd4htl4f478kulnwr84m8vn4m0r227juddyq0ncu3cyvc765z9gm4", - "zs1zlz59lgwc8pqq33508v5ygk9e58f7fs4rpj3achhwnkcyn2dku44yfjghdf5l2v50nu2gjzgl2l", - "zs1zlgenma0yuqxmqgns2avpnauclxgfvgd6rf0jt09fmfyaflwlhsscem9ypmrvewl9l356dn3jtr", - "zs1rzu2yg2328l2wlfstu27dl024ucqsjx6g635yxmyhs0wr3lduutkc3peuhqe83uueh5n5q624rd", - "zs1rr9jpeemn9ek30x4h65rx0ddul7xet6cc8atwrjftmq9sdrvj9f5zdc9xg7amtc6dv5fxjyhu54", - "zs1rrgccr0yvfn5fdek39x09y2ylyf42xkydcwzq67wdrzyjj2mv874easa4h4tymz5gj852aqpffk", - "zs1rynh7vl05weafzwkp0p5eafuzzqph04prgg74emqq0sx6xudtrs2380v3ycxgp5lzudw6tmc2zd", - "zs1rxqz0a59zx3yduncc3azyzexwu8xl6cc0zu83hfd28mksrgahhvx8604uhf0u5mna9m4znnj4gr", - "zs1rxr2xff2vcv0y9s6ux6c6t9y7r3zvcvrqmwkvsnxj39t0qv7qwyhncnykhzcqg0ggpu423ykzxe", - "zs1r8chvye5uzlskv8jvt6j8nxnyz4lshy3u46yjhc8w9ekhjhneg402knft3t943t5nrhs6d0d5um", - "zs1rgu6mz58xrqxpyl5xw7ss2szz29cg98s8xl25hu7fy4lcxw58zr93a8rgyha52vwxx7hxj2emkw", - "zs1rveutz8ftruljrlctum42kakjqk4cm8dm2807nqm974dz0rptlxcs999ttsvwp65vc9e59vv9fe", - "zs1rwfqhlezm5ln7kq8wp8hkl08ddn74ryr8cs4cu8qc23spdx79xgfqj4lju4u2yqdrkxkwfvk3ed", - "zs1rwklllsk9jwhhf0fedvlzsqfqdkwer05zh8c8hwypl4tls2hdal54lexhca7kghhum5hycurvfe", - "zs1r0ulehrcg9xz0lfdcukjm3qlvqy74t0u8raqf4zn88vdsta8mzp8t8p9ul8jragssvs9qaqpw2e", - "zs1r3t0cve050wufwl8r2tly05vn7w79v53fe6dagjtt2ese0qm6vgjp3rrsfu4n0am840sq5thn72", - "zs1rnd8zwan2xlrnfwylm9khkeutnzg2v9vjdnyellyuzkwmed94uvd2dq8ceumxwspz037zp2ctqa", - "zs1r4tphfnf3zy34dqyjuld2kgtyg88hrxpv756pkkkmrfdeun0cqzpepac4ma9qrjrvdqxg2z5fuv", - "zs1rcpywy0v4sfej85wdaslfwsp4pe9sa87xgzv24ywhps2l4c9jlrqttv0wl9zkc5e7rsekf42wvp", - "zs1r66et0z9xw3qqhzyc2aht294y7yqyz8wx2l2t63unca4k4zh4v9t44kpmg52z9va5968y45fdkx", - "zs1rat3szdulwxwmx7y4rdphvlpjj5phadvz0fsvj7mtg9ggzwd22sn30hzsh27h7t6cvca6a8wu2n", - "zs1rau4jcth66jsg098ucclp9tfa5qe6jmtmfkcluaqnyj3uatkt9dsrgx44xtmxr3e9xuxv6sy208", - "zs1ypf2v2yu4p4mnlmw0wd3mpztpjlhl39jnn6hkvf77ell0h5u6yg2pgeusvku5y5sykyy6kk6yyh", - "zs1yzkt8catgk6slwj7azu79tvwv6tkd6agcykvvht4rxlevtsh99u036jf5503pju3h05w7x02cm8", - "zs1yrty5fmnyaartpcyjnpal0w44g4mt2ey5tyzcmgq4g6qtsfjmxae7fvy2zsw7t0zvseuwcfwt2e", - "zs1y9p5gazcx04kke96xudep0edzkqr06gdjnr5vm99a6qxzatqz5katput4q9nx95e8965sg7d3pl", - "zs1y9vpfgkxwh3xm3j9d38zkeqql2lh8w3ucgerkww2asdv89p87emdavkzurnqpkrmu7e3xv5myue", - "zs1yfa9gwmn0xe4myrg0rf8kmu36243u8773ukeev0set2yv0z9vpxm6ratee52e9zmpvvx7w2xy28", - "zs1ytpjrujfsgs69smqerxeaf8m38jwxc4ejgxxe4pzc5qu4auqrgy8tf7zxc402pxf9uku646kc0q", - "zs1ytvtdwmcn8tnka6w6wa8n3ghnkf7gp2qaudd4233y6m509ntm59rr0n8eudhre0md7m0zedpcsq", - "zs1yjmeu09mzrt8rgehv2gcfhxx6ddqz7ww87ssfapndvc94hxfrfsdkkgm8f8nr36xm8p7q462qy2", - "zs1ynqghdu0r0c20csp3ygrxdw9hk2l89j3g59q8zhht9jyxycpcc9ccvhyyn2f9j0ehp4pk5wkhqs", - "zs1y5ny4jpjm05vp5awjd6muaqqypdv0y9tr6pz0m5t82cwtrearxwf7km4aznydpcjeuzxqvk0z9m", - "zs1yh2vd5usfsyv4pscjrxg9wdy3gnnyuh8vky27ln3u9jspadmpqsjmyvxmvfyyq3nv4deudvygxa", - "zs1yclvhy57hngs7d233e4x8ywfreswslz2gvn0f8epcs0wrzuqqau3hkrvf7ru6jhh0zmsyn5jkj6", - "zs1yunkgwzf0m5suz380j7xqge6rd9e6acjc5wp22z0jhalqdpspdjey7jfjvgrckgsk9ydc9yrnq3", - "zs19p94fnry6p88ms3yh60nl4kxlxmu7uxv9aafmf5pc4nyd64vslaqgmj30nxe3l5j7cxu5kqeqpm", - "zs19x2df6qmd4c9whrgj6m4mssz22x9qj9x8lmcnexnhw32pey24xy9sws5ts2q7guunm7mx9wmllj", - "zs198a984na6qt2z3uyhdkmj7sfevt794dl3mum3782kddjy4uawr2teznpuxvnzc4dvs3c6zyqxey", - "zs192ld62azpypesveqsat6m63sqaw95ejlqfcjsal5t0fea9zjzqnurmpnl6074zdms0amw83rw0x", - "zs19vsx09xmzlj9vr3s3vu8z4237gpcgrl7qs0vapzzawgnu7gxngeaxlgwqf0ppu0f7us9cfe3cqz", - "zs19wfwd8zufu27zugan77wf2g790egdw7vkulf6f375ylq0arnv2nv94l84nl8lp3tpccv763wetn", - "zs19wcqtqqjj0mnrn90ntcmyq5x8qr2wsaslqwt0fysz4xh2mmjy0z9jjh4sj86sjrgen0axx04zt4", - "zs19jypvpjpvhv5et5wq2ny09skt72hxz9adfgk2ev7nza5jyxr6gss5qelygnxn0szmjqyke2h8a7", - "zs195kll03d43her83a65y7z0zsetynlnft4pjxdspegvun0m7cwtx0vsxfm89mv50vxr90qhvcqpz", - "zs195e2g52jpyly7t9vjpfcegt87g7lpa4rm74nxn0zvmtzjhvg7f5gjnskc5ax5skvwprcshenyqs", - "zs194e84mfxc4vn4ssce7hkvgrcm3c8j7vehcetkdf78rele2lwkx9tzcfnrwhykdqa2nmwx5qcr0j", - "zs19cxqspj63ksk6uwtynj0la72zuvh8rxfh0e0pr2y5vuuvw35sm78juzh5gxcuqa8jggv703rplf", - "zs19e04k24qrca0sx5z47dxmtx0swcx2ywxqjt5594gu95rjaeyxrpa2vyylvzxpau5spt2v529me6", - "zs19707gmdvc4hfwg4lgvxg55695gltx3jwye8l2gjekrx4zqz7yr6grq8s8hpfqwggrywx509ln5y", - "zs1xrw8nwla7yrz8l3d7y3rxlhamel2ly4kdmxlc6w4cztxhd6l8wufqv2pcsvtl3d7s6awvjatyx9", - "zs1xymrgyhle6dcvjk5f62k4xygr0vrr2wckqy7sp6wc6cttn29hra77dzhwxst7z9rxqxkz08jd7g", - "zs1x9c8tetxgauxh474hlhnlscuhgzww8vnvxfwm0p8589x73t5yl2fph8q8r8qpl8sh0wfwx0vg62", - "zs1xxcpzsfpyekhvvum3erxjpt34pw3h70ma8vxwecg85tze380f4srlg8zlgxty8yqhutt234nk9q", - "zs1xx6pd3vtj78tg0zpwtc0jjkdxlfy48vegzd6cng4m9w0gtcya8ck7pqgf4l5sxf9ml5zvzru5xg", - "zs1x8qre6x5d8e3tt2m4l9q2tujw8ajun70qelp8tfynyw390rm6vhjtmpf58dmx4hccef9xe50az0", - "zs1x88vjduckqarz2j8tp2me08ya4dgd6pw7j4j98j5jynrze3xy2jjptzye7eftjxd6dn4sj03v7m", - }; +string newSietchZaddr() { + bool addToWallet = false; + auto zaddr = EncodePaymentAddress(pwalletMain->GenerateNewSaplingZKey(addToWallet)); + return zaddr; +} - std::vector SietchShieldedPool2 = { - "zs1ehrs7hetemzsmfz9xwt8xetxag33j3xzj8mhdgywdnvkk4dmtvw6eqys6gm3vr679y865jz7rth", - "zs1ehyr6w0c4mwp0wlp6w5letgm3rjk32rxa9kkkur86e5x8lutr9mwzey0hsesnz0yaarmxra7w2z", - "zs1ec793pjf3anee0qq9ex5u2qygjzk9llmwfygev563l89quc3u8wxvtz9kctlmv2dtjgqwn7krcg", - "zs1eclpgnqy7qll0l5z0gy7m4ew86yjvp397yxyau9y2y43x5mqfdw2sll95l83ux6h8mppzsx3xnp", - "zs1eexedkctuzhjysl00m0j3ekknd32635yd8rejx9ykjp6zz77fyzf5388env642ja2qlg6mrwgsc", - "zs1e77uz8yaj998arp56d0fm4p827wchlf2w09hve6rgkmavhzeyhke8qsk3l7s5k6yh2jwjheqpup", - "zs1elj4qvy42jpts2cu22tcwt0kmwzafpmrjgztwf2xcqaycrlr4rpfxfpswx63e6agvhz96gps9yf", - "zs16q0fzcvf25fh70ysn38v7qkpfspakmelnljgnyrpu7rvllyew57n5cpqjqe0wmy5j57au47j6x8", - "zs16pnkw3mucdef34jjk6q28zd7ghhatdcqn598vs3g70qev234uc5uw6xxxjnzef3pt2t567qev8v", - "zs16rmnl4hd6c226u3v6eekk68y59u0x7v37n8pmytt9xw6drugjml7ryhd243nf3l2pvafw42rnxc", - "zs16ruwvwmetmnnns0rxwtx2kss23da2pccares0tehzw3v3nxd483qn49c9apdfua0hpm8xdecdt4", - "zs16ymafsjd7fp9zdl9vtyvfedecvn7q2vcs7emeglwy7hpuphve97d3j87v2evqs0xm3jrx44nwfe", - "zs1697ggm9zqp4rh0fv4r9hnh9uy6gg4hk7r2lm33tp2we4ry5azpxq6nwuzscha0g2nx03x4sstq8", - "zs168t8u6at9k6kt748dv749dxahnk8rv8yn32z8gcgvc9rkhkewscgu8r8vuzv0zecnq26w9p7x0c", - "zs16gnyx6f8vql24cepamfquhr3jjt7wgmzjcvwtct4lwy9p2studln6ut9kjzf6empwqjtxqmddqy", - "zs1622ra8snywvxufsunk97pccr7k0j32p960evl9yqjadhju22m4sk48md84q5u238gej8xnm4xm5", - "zs162stv8m0udzy4c6ff5kqva2g7pqth2rrdn7rjjgw29dcx7lj3vs4dnj8fz0gczsat3u3q5axgva", - "zs16t78376h9ledgt50k2dmwssuhyy4hn94wfgd8vzegvqy9k9kauuvpe8xz0f3va65l8ufqhgv4gv", - "zs16vxrghgv7mth6k9unzdude9cyt9vl76ms5hm9ce4py92rk69j4p9u570974nh8kqh8e2stqknj5", - "zs1654eafn589g2ujzcasa8caz8exag742tra2dd6mjkp22axh27hda6sy9exh3wkp4c6f5vztafr0", - "zs164u3ntsnn7s3zrp6c5gsqfrwr0ywhspynvunq3fhvr9crwz5eme706j5awwvuatqwh7m2qqkqm9", - "zs16cpqwm4yml5x8j5r3q5j0xljam68pf56xt40hylzn69w45venwdvd4h8drys5t380mspkvt7h8r", - "zs16c6m9aqs0q9kadm4nk6hugmqw6p0lf2h6v5d9ccwszssyecq35sm6284c3uqx2u40da4s2mr2ap", - "zs16u7rc066566j9ux73dcq0m7cq4qdmtd3gefrnhhrpjww3z00j4za7m5mcutmj6qcezkzys87mpp", - "zs1673rm5d5z9sh2k9uc2cvgwk2e44z0sekx6ezt9n4fvgnky5yxa2tc306dw7n2dg5vwfn7ppwr5s", - "zs167nvq5ahvu4s26447rem9j37qglgtle4fghsgpksumkz34g2q9x783pak5jgdhhzylmgs9wemg8", - "zs16lluayez28xevxg0rawxxcd7yx5t7qaraet256sxe8ac69lj7n7ppncsx3m2tddxlzptzyxv0qr", - "zs1mydlmczamey4ydc79n8gj5wtgs79zge4nwhcg8g640r6fvwu6wpt70970p7ptkcrzg6r6frqh0u", - "zs1my6tgqmy3kgdlqncyd5dv9s727x9hcrmj8h06e5whn4hkn5t2x46j84276yd8pw0p6ysx53u38u", - "zs1mte528eue8smvjwpe9cs8qz3wud9735rnk7vrtefu9lhyvh5pyeyenpaq5fa08jpwrl4x7sz069", - "zs1mvmu20syf3u5yzd6hpdd29xfej8237x2k0pcmf7pvra46qem5g0jralrmdcvncgf5j0y5varzr2", - "zs1mw86y6g2c8972a2ndw57648p9qcx2jppxr9g5k24df8hl3rgfzfsfe2xyesemdfmasutk88duht", - "zs1mwca7dqjq0r2mzmn4qarw8acmt4rjk26lyyar35sssqe2fky2nmv3kmf0lfxs2a9htugsadg027", - "zs1m0rpcrkfagzpex9mlw2htyrwpxe48v47pj8zg96l9wm5k8xkj3kev3xca6wumv5avkgsjtygush", - "zs1mjgyju3jnyxjhekv72y448edq3j2cvtk5s4wrej790zzpv3uc20dvewt7nhjdqryuecmykfm0je", - "zs1mjlfwyma3fv45yg50j73wcswnap2s4lsh5c9km6lcem73wky9lej7vy8wrlkr75sy6z2g0agtmw", - "zs1mkh9s9gdfxx4dkug47dqnc98g76dhm09zty779pm6gqc5aye4gvxvduqm5j56nq4lncx5ygqu90", - "zs1mm7tesf30r56l8xmnxjyxvgmnsny2zntsxahllrd930q8ycahz8npdxt7lqwu3k8ljs9sw7uzs8", - "zs1mu34v9wtyhtlr22phfxkp670wt0gj4z8czumx0m4u05elg7kjzu0dzveq5jn28xg5a2wqr6cywd", - "zs1ma3xy4fj0vm0w37a4kur3ghe72f8nstmqmmvh0u48kurtlwg50rqqlw39j6ng8lrxgam2dh0zyr", - "zs1m7yauj7694wjz92m5sxds8udp43z6kclarqwzc22wn2q6svkkk4lpzx53kwctwfn6jqcu4yww5u", - "zs1m77qqksfvuqmjmwdm22xr2u99z3uz4glenk02md4tq5z066gc7jkdayhf2txspqggv29quacpy4", - "zs1uq88d69zrnksytnquejpksdvdlp9e5y3xec3eyf0rrya8zap623zpwjs5mfzadrp7twawkpennl", - "zs1uq0zzag2cmekwn9a35vkf2q45sary5v8nt2adukhej9ydq3qpegskg5naysl3wvvxtzuyv5lu8w", - "zs1uqs3n3j8kfgurz8tj0ea5g2ny200c69rwwpq50kkup8sxntdne6h9uhx3wc2y5jjkcggvpvcl4g", - "zs1uqmnl793xh4cskxjherwlpt7xfnt6fy2sp2l3n58hpmd4msj2g3fjsks02069tqgzzvn77mpfg7", - "zs1uz73f8arfahrvgtxcjwya33ql5w8mwkmyrvxvjrjx5rla07hv3ax49hkeqg3aqynxx39z4y4vtt", - "zs1urzuwedq4qgnqjsjwjeauzyyjwxvs27mau6zmpretn37my92h3jqc0waad4r8s7zeeczq6jfas6", - "zs1urfls60sjxpnla4hhe736qu54w7047akw2p9cksx054y8e8gdyknkhwv6spwzgstf7z2wrsdapw", - "zs1u9jum0rl3959ay3qqxskkak5emv0fpceuhuhcj9rnkzfy6gpe2uv6ny29c399nrc68fx6fffg6c", - "zs1u8fdxg8lu08p6s5z9qe6jf6fkvd74a99yg3n5exlm6wm8paypygy82ue2smf0qqlhdhjzy2jxq4", - "zs1u8u44rlv4ay27248807fqwyf6lw2w76v8evn26nvwv887caqlenjgsw0nqlajzw9equn7phhs95", - "zs1u4jhx25fghqzn2az7he7lrv7xj23xd8spcl660g9kzqa3wyykm5gucuu5wwxvum6l6spq4u4e5s", - "zs1uh85d43vr4wwqnq6e7akxtlwkzx2y8cmdm3wrxzj6m42pzj3xs2heqey79hgxrhwhapwu8tt73g", - "zs1uhwgwkg2y3xex7e34dvnx97d0jdnhmchevcvg54tg4dg00ay9sjucr82py4jqx0kkf7cz5dytad", - "zs1uhkhsv3c3m5r8z7unmceg4zln6edwfr25wjauv5u8fxdqhdflj7vuc2xnkm9028y802w2pyf07g", - "zs1uhuwuzu89j05p9y48nseklu7gfhw4mrwv68f9s66csafrkpsmpsh23zzgxm24nspmsgrvtpttzg", - "zs1ucetuz8ysvz42uvuwndjfnphrtsfgekgef228meuhfrqtm97gql87rsvhxmxplw2xmj27p9jemj", - "zs1ucm95fgyy72rf6x5rwl5m5pldt38lulzqf9ueepel4gvd4cqjhk8xrf4kvl2lnn5ge9fwyfrfva", - "zs1um3pu2u0eu0zpx4czj9dufvxnud2zd0x5lygepp6maz96j572r6mh8gpmlm3w6jhmxxz2sepdfh", - "zs1ulkw8j488xuhhlewedj9dr7atm5jatmlwsxz83lquhz42ln78utqmtqsmhagcquq6uqszk23g9d", - "zs1az03j8f46n2600z47xnf5y28j34rpxljh3j6w5p3xgsmqt2fuklmhyd383aljxf4mx4pcfv0xm8", - "zs1ayal4wq4crwj70u6hae82h6r4jpk7ptycfhs9v5y83lxc7u4gadegu2r5ggsgt95n0rjk284fzj", - "zs1a984wux9sr2594lr24yal43zq6pstczyevj7yr8pn403643zuge88ekrc0cj8n2fk6z6xrxjpsz", - "zs1a95ptq9d6nauwtvgdj2lnct9y6g4cmm258jzyuqhsk4m3gqmaz62t4klqe42eu83n27jcpgz0ed", - "zs1a8xdhdzpjqx0alrjg43enszjnf6nn6nhf6c3xd77ecrvp4kfarvux4u4lcttv3rgyhmgzxukw2q", - "zs1afqnaljmvzunvjhr3m8yf2g4r0pe66kkxkm6ldjhylyjfsclk3nf88u29pskdqx76szdz48tt3m", - "zs1avx0j6mrcqrhp9903xrysptm6gefcyv6uqltta92hsgjpp2f8h8rz8suwxgjkp2f8366y6n6dj8", - "zs1a036amk3q8azryytah2zpdhyazeruq2q7zq2c06l0845kl0v2rmg0h8cdjvta4alxj0my4kcfad", - "zs1ahy2sja2ala03wrc79xx2ks3ujxxnsm44uh6yucmy5p5l0xcfa3g90cdgs4l9rhy975zvd4uzts", - "zs1aeyqta7xs8edzq2c0z6e9v3vjep55e4lg9fp9ls6d55x2mel6snxud6kqcaz8nl7zgrxxj96d6a", - "zs1aap3thj9xna07vlg3yz389c34v9mgd06g234d3htyq667286phjsf98nndm8frts7frmcyjfa90", - "zs17qdqrdgwcafkpgchc4rvk22e4u86alhnmzne5xzantpecwrxf3c6jxqk7xgzanzjj4kmxd2tuwg", - "zs17z3fmn6e84ypzpzn0p0j9nddptrj2nwhk9lhaw952j0lzxslrp24cj0ltuem9g5dustakcq4dsp", - "zs17zut2398dst3hnmnslnk0jv9w4q9yn8akelymvs8ewurdytxushp92nyqv30quqhy0yju7rn7lw", - "zs17r4fuv9ldl3kzwk5stv59exusc7jlsmtcz4t2uzjnrgrr6aj6tvnp04wc9jq2n3eh6fsyqe2ru5", - "zs17rajftxlkcywcenl0cn3fqw4lh2un5lpfegjdz06j3vl9gjmay2d5pk7uequ02vw6tmtzz6jrst", - "zs179rvu8endcr48sft7zg4w6uvxwu4ps94r06uwk7e606yffkgtx7epaamlfdqnc6xa4l9scqcv4v", - "zs178dr2z7zgqrsg5ul3sxx05qky2kemfequf08dxr332n9f5fq9cj98jttssz97lzmf2k22xpn54m", - "zs172zz77ds82urqmsa9pgyz65k04euw7uuk58k4ardcxectjc4t4yjekxm8xxmgd7gqs8k6jupypk", - "zs172eamykp6sl4vx4tsgmg2t0p482hnn3gg4my9y4frd4tl5zgsyrsvjvlxc9zjtqpve6e6djdc4x", - "zs17v4xqdu83fkvrjxrpnjksuanj0pung2kqn9ys533nnm8kq8ad8xv9kd48e4utrz947pejg55p46", - "zs17dgakqvwzgh4dgfe70cjulju698cs50zvchsze2e3zvdp68wytqdcvj4suh4vq2acdg7wuvs7ar", - "zs17snaqr6vukwp4apsdf44h6w3flgphzrnpmdjly662tgqtvkgs72lpz7m7tnkksdmt5uzjgmpg2e", - "zs173ad7l6u8dr90e2t5jkrnw0gc9u2mppv9vjeh8l6q2jdvgnq6tq4anxxltwuxm3wssfzgg6hfcy", - "zs17nez6jn8tnse243f5uf72d8y000ynmjnm6vsrpzpd2fj75wq4u4lu7xc8fmtn2e5v0r7uknphs3", - "zs174c6x8u2yagjnsq2kswnd6fh8u2f3g5dkrk7r7ja5n30zwjm4ke3x84syt9qklqyk0m7vekcx9f", - "zs174mlfm6snsmgj4usez3e6xtd5nkwwl24vgg96srpnv7ulz4de6n4lx6cmxaqszqnk7p9y6wcl8q", - "zs17h5lnrnpprdtkjwq09ax94qetryf65qm5jqv0gpyeesw4wujytks9qljvlry863flf242arvx8f", - "zs1lp07e40usxenrznuuf2nzn5v7tx9pzp9r6eaw6upnm4t9cer8l5fckzm7jr58j5l77tzjrprv8v", - "zs1ly5u5sqeeax9g3uafva7fl35r3wv0nm2aka9m940graqjh0zlw7rrcgay0a7f29j3ar4wrj4uzu", - "zs1lgqckcp2uqx5c6gdm5zklzrxz8ygva9kxtxc4u4dlzpg68m9prga5q3ur3uqutkcy4ztuhclrxw", - "zs1lgz7ychnnhe58hk2e379zhqdxynp30e6fdh6xjxx8u9ga9rmwzdrdvqcq5kps2uetyf6gzeqdn2", - "zs1l2ghymesqwrfw89pqnw08u346es6wn86r77a55n7d7xky2rc58jfhn7man9kjjesnegec3frxeh", - "zs1ls3lyaqhm39zgz3528ereaa48vzsw4cw99k536524a6ruxmdqyvqnv4pl477q7rwptrzx8dhhzu", - "zs1lsnr42d2ez0w55pxws4qn70f68vxllv92wppu24n75y7a0wrmkw6qgup0md5jhjmkwhzu742zx4", - "zs1ljzwlum9nme83hhvkjkxl323u0ezm4sgnk84nzkyu5acum0kxf0s6g06gy78w0hl66f5263g7ha", - "zs1l5kfev0dpl8swjlyvyms5t9yhhnvg0590jfgpxw7zxx6eh29vd7453q9d0ne75x7gsm42j65l3v", - "zs1lhpxmvxmfpdfa5myd35wf24pmacrgdhrcpxydrcwz3qvmfvpt9x78nf2ne3kkqh40m0nvhhd3uj", - "zs1lhkhftvpkvcuyhwgcz4gq9y9l3ly5esglk2g0sgdctrz2cd63lgss2gtn8eedsvtuh8f6shpwww", - }; - //TODO: Assumes pools of 100 - int randIndex = GetRandInt(100); // random int between 0 and 99 - if(randIndex % 2) { - return SietchShieldedPool1[randIndex]; - } else { - return SietchShieldedPool2[randIndex]; - } +SendManyRecipient newSietchRecipient(string zaddr) { + int nAmount = 0; + string memo = "f600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + + return SendManyRecipient( zaddr, nAmount, memo ); } #endif diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index aa22f7ef0..2d1e6d5ff 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4565,30 +4565,29 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) // OK, we identify this xtn as needing privacy zdust, we must decide how much, non-deterministically int nAmount = 0; int decider = 1 + GetRandInt(100); // random int between 1 and 100 - string memo = "f600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; string zdust1, zdust2; - // Which zaddr we send to is non-deterministically chosen from two zpools... - zdust1 = randomSietchZaddr(); + // Which zaddr we send to is dynamically generated + zdust1 = newSietchZaddr(); // And their ordering when given to internals is also non-deterministic, which // helps breaks assumptions blockchain analysts may use from z_sendmany internals if (decider % 2) { - zaddrRecipients.insert(std::begin(zaddrRecipients), SendManyRecipient(zdust1, nAmount, memo) ); + zaddrRecipients.insert(std::begin(zaddrRecipients), newSietchRecipient(zdust1) ); } else { - zaddrRecipients.push_back( SendManyRecipient(zdust1, nAmount, memo) ); + zaddrRecipients.push_back( newSietchRecipient(zdust1) ); } if(fZdebug) fprintf(stderr,"%s: adding %s as zdust receiver\n", __FUNCTION__, zdust1.c_str()); //50% chance of adding another zout if (decider % 2) { - zdust2 = randomSietchZaddr(); + zdust2 = newSietchZaddr(); if(decider % 4 == 3) { - zaddrRecipients.push_back( SendManyRecipient(zdust2, nAmount, memo) ); + zaddrRecipients.push_back( newSietchRecipient(zdust2) ); } else { - zaddrRecipients.insert(std::begin(zaddrRecipients), SendManyRecipient(zdust2, nAmount, memo) ); + zaddrRecipients.insert(std::begin(zaddrRecipients), newSietchRecipient(zdust2) ); } if(fZdebug) fprintf(stderr,"%s: adding %s as zdust receiver\n", __FUNCTION__, zdust2.c_str()); From d58e2473fc76e5f5fec5a8c625bfe36423d4b571 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 10 Jan 2020 07:29:58 -0500 Subject: [PATCH 003/255] Add sapling account counter to getwalletinfo --- src/wallet/rpcwallet.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 2d1e6d5ff..032d3834a 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2810,6 +2810,7 @@ UniValue getwalletinfo(const UniValue& params, bool fHelp, const CPubKey& mypk) LOCK2(cs_main, pwalletMain->cs_wallet); + const CHDChain& hdChain = pwalletMain->GetHDChain(); UniValue obj(UniValue::VOBJ); obj.push_back(Pair("walletversion", pwalletMain->GetVersion())); obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); @@ -2818,6 +2819,7 @@ UniValue getwalletinfo(const UniValue& params, bool fHelp, const CPubKey& mypk) obj.push_back(Pair("txcount", (int)pwalletMain->mapWallet.size())); obj.push_back(Pair("keypoololdest", pwalletMain->GetOldestKeyPoolTime())); obj.push_back(Pair("keypoolsize", (int)pwalletMain->GetKeyPoolSize())); + obj.push_back(Pair("saplingAccountCounter", (int)hdChain.saplingAccountCounter)); if (pwalletMain->IsCrypted()) obj.push_back(Pair("unlocked_until", nWalletUnlockTime)); obj.push_back(Pair("paytxfee", ValueFromAmount(payTxFee.GetFeePerK()))); From bd88898ce037f6ee0e7bb945d9da4b221f931e8f Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 12 Apr 2020 05:55:08 -0400 Subject: [PATCH 004/255] Implement z2z transition period for mempool --- src/main.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 17b89a76b..aa8ba176e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1741,6 +1741,25 @@ CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowF bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,bool* pfMissingInputs, bool fRejectAbsurdFee, int dosLevel) { AssertLockHeld(cs_main); + uint32_t z2zTransitionWindow = 10; + uint32_t z2zTransitionStart = 340000 - z2zTransitionWindow; + uint32_t z2zTransitionEnd = 340000; + bool ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; + uint32_t nHeight = chainActive.Height(); + + // This only applies to HUSH3, other chains can start off z2z via ac_private=1 + if(ishush3) { + if((nHeight >= z2zTransitionStart) || (nHeight <= z2zTransitionEnd)) { + // During the z2z transition window, only coinbase tx's as part of blocks are allowed + // Theory: We want an empty mempool at our fork block height, and the only way to assure that + // is to have an empty mempool for a few previous blocks, to take care of potential re-orgs + // and edge cases. This empty mempool assures there will be no transactions involving taddrs + // stuck in the mempool, when the z2z rule takes effect. + // Thanks to jl777 for helping design this + fprintf(stderr,"%s: rejecting all tx's during z2z transition window at height=%d\n", __func__,nHeight); + return false; + } + } if (pfMissingInputs) *pfMissingInputs = false; uint32_t tiptime; From 3d9e662266a28f6d634185d239b6b23ec362b629 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 14 Apr 2020 07:53:01 -0400 Subject: [PATCH 005/255] Switch to -ac_private=1 at our z2z fork height --- src/main.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index aa8ba176e..7575a4e0a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3368,6 +3368,19 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return(false); //fprintf(stderr,"connectblock ht.%d\n",(int32_t)pindex->GetHeight()); AssertLockHeld(cs_main); + + bool ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; + if(!ASSETCHAINS_PRIVATE && ishush3) { + unsigned int z2zForkHeight = 340000; + unsigned int nHeight = pindex->GetHeight(); + if(nHeight >= z2zForkHeight) { + // At startup, HUSH3 doesn't know a block height yet and so we must wait until + // connecting a block + fprintf(stderr, "%s: Going full z2z at height %d!\n",__func__,nHeight); + ASSETCHAINS_PRIVATE = 1; + } + } + bool fExpensiveChecks = true; if (fCheckpointsEnabled) { CBlockIndex *pindexLastCheckpoint = Checkpoints::GetLastCheckpoint(chainparams.Checkpoints()); From e51556083793c3c5272f31b3e64cf6cfecddae27 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 14 Apr 2020 22:27:24 -0400 Subject: [PATCH 006/255] Improve and remove mention of sprout in this error message --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 7575a4e0a..20c6cffe6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1591,11 +1591,11 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio if ( counter++ < 10 ) fprintf(stderr,"found taddr in private chain: z_z.%d z_t.%d t_z.%d vinsize.%d\n",z_z,z_t,t_z,(int32_t)tx.vin.size()); if ( z_t == 0 || z_z != 0 || t_z != 0 || tx.vin.size() != 0 ) - return state.DoS(100, error("CheckTransaction(): this is a private chain, only sprout -> taddr allowed until deadline"),REJECT_INVALID, "bad-txns-acprivacy-chain"); + return state.DoS(100, error("CheckTransaction(): this is a private chain, sending to taddrs not allowed"),REJECT_INVALID, "bad-txns-acprivacy-chain"); } if ( ASSETCHAINS_TXPOW != 0 ) { - // genesis coinbase 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b + // BTC genesis coinbase 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b uint256 txid = tx.GetHash(); if ( ((ASSETCHAINS_TXPOW & 2) != 0 && iscoinbase != 0) || ((ASSETCHAINS_TXPOW & 1) != 0 && iscoinbase == 0) ) { From 77cc82428bab83079bdd3a0751645b2a8a25cc27 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 15 Apr 2020 00:59:47 -0400 Subject: [PATCH 007/255] Hush Smart Chains --- src/init.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/init.cpp b/src/init.cpp index ac15db192..b9bc096a7 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -581,7 +581,7 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-metricsui", _("Set to 1 for a persistent metrics screen, 0 for sequential metrics output (default: 1 if running in a console, 0 otherwise)")); strUsage += HelpMessageOpt("-metricsrefreshtime", strprintf(_("Number of seconds between metrics refreshes (default: %u if running in a console, %u otherwise)"), 1, 600)); } - strUsage += HelpMessageGroup(_("Komodo Asset Chain options:")); + strUsage += HelpMessageGroup(_("Hush Smart Chain options:")); strUsage += HelpMessageOpt("-ac_algo", _("Choose PoW mining algorithm, default is Equihash")); strUsage += HelpMessageOpt("-ac_blocktime", _("Block time in seconds, default is 60")); strUsage += HelpMessageOpt("-ac_cc", _("Cryptoconditions, default 0")); From a2013ecc39219151067578661b3dbf13b4e1fe7f Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 15 Apr 2020 02:07:19 -0400 Subject: [PATCH 008/255] Fix incorrect error message --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 20c6cffe6..cfe851f7f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6121,7 +6121,7 @@ CBlockIndex * InsertBlockIndex(uint256 hash) // Create new CBlockIndex* pindexNew = new CBlockIndex(); if (!pindexNew) - throw runtime_error("LoadBlockIndex(): new CBlockIndex failed"); + throw runtime_error("InsertBlockIndex(): new CBlockIndex failed"); mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first; pindexNew->phashBlock = &((*mi).first); //fprintf(stderr,"inserted to block index %s\n",hash.ToString().c_str()); From 41a4c84633945f868061abd0b17741ecceaa1935 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 15 Apr 2020 02:39:18 -0400 Subject: [PATCH 009/255] Refactor z2z and additionally set ac_private=1 when loading block index from disk This should avoid the edge case when a node starts up after the z2z block height but has not yet seen a new block and so does not yet know it is an -ac_private=1 chain, as currently that is set in ConnectBlock. --- src/main.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index cfe851f7f..472a8bb90 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -114,6 +114,8 @@ bool fAlerts = DEFAULT_ALERTS; /* If the tip is older than this (in seconds), the node is considered to be in initial block download. */ int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE; +bool ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; +unsigned int z2zForkHeight = 340000; unsigned int expiryDelta = DEFAULT_TX_EXPIRY_DELTA; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; @@ -1742,14 +1744,12 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa { AssertLockHeld(cs_main); uint32_t z2zTransitionWindow = 10; - uint32_t z2zTransitionStart = 340000 - z2zTransitionWindow; - uint32_t z2zTransitionEnd = 340000; - bool ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; - uint32_t nHeight = chainActive.Height(); + uint32_t z2zTransitionStart = z2zForkHeight - z2zTransitionWindow; + uint32_t nHeight = chainActive.Height(); // This only applies to HUSH3, other chains can start off z2z via ac_private=1 if(ishush3) { - if((nHeight >= z2zTransitionStart) || (nHeight <= z2zTransitionEnd)) { + if((nHeight >= z2zTransitionStart) || (nHeight <= z2zForkHeight)) { // During the z2z transition window, only coinbase tx's as part of blocks are allowed // Theory: We want an empty mempool at our fork block height, and the only way to assure that // is to have an empty mempool for a few previous blocks, to take care of potential re-orgs @@ -3371,7 +3371,6 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin bool ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; if(!ASSETCHAINS_PRIVATE && ishush3) { - unsigned int z2zForkHeight = 340000; unsigned int nHeight = pindex->GetHeight(); if(nHeight >= z2zForkHeight) { // At startup, HUSH3 doesn't know a block height yet and so we must wait until @@ -6338,6 +6337,13 @@ bool static LoadBlockIndexDB() chainActive.SetTip(it->second); + // Try to detect if we are z2z based on height of blocks on disk + // This helps to set it correctly on startup before a new block is connected + if(ishush3 && chainActive.Height() >= z2zForkHeight) { + LogPrintf("%s: enabled ac_private=1 at height=%d\n", __func__, chainActive.Height()); + ASSETCHAINS_PRIVATE = 1; + } + // Set hashFinalSproutRoot for the end of best chain it->second->hashFinalSproutRoot = pcoinsTip->GetBestAnchor(SPROUT); From 1009c7933de1d284e83afc139a599b0efd1785cf Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Thu, 16 Apr 2020 22:10:25 -0400 Subject: [PATCH 010/255] CLI arg -z2zforkheight and avoid a compiler warning --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 472a8bb90..e1beb5c5d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -115,7 +115,7 @@ bool fAlerts = DEFAULT_ALERTS; */ int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE; bool ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; -unsigned int z2zForkHeight = 340000; +unsigned int z2zForkHeight = GetArg("-z2zforkheight",340000); unsigned int expiryDelta = DEFAULT_TX_EXPIRY_DELTA; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; @@ -1329,7 +1329,7 @@ bool ContextualCheckTransaction(int32_t slowflag,const CBlock *block, CBlockInde )) { librustzcash_sapling_verification_ctx_free(ctx); - fprintf(stderr,"%s: Invalid sapling binding sig! tx=%s valueBalance=%li, bindingSig.size=%d\n", __func__, tx.GetHash().ToString().c_str(), tx.valueBalance, tx.bindingSig.size() ); + fprintf(stderr,"%s: Invalid sapling binding sig! tx=%s valueBalance=%li, bindingSig.size=%li\n", __func__, tx.GetHash().ToString().c_str(), tx.valueBalance, tx.bindingSig.size() ); return state.DoS(100, error("ContextualCheckTransaction(): Sapling binding signature invalid"), REJECT_INVALID, "bad-txns-sapling-binding-signature-invalid"); } From b3c7e048ab583556e79bd5651abc49b443227740 Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Sat, 25 Apr 2020 00:30:06 +0200 Subject: [PATCH 011/255] add z_getnotescount as rpc call ported for Hush from https://github.com/zcash/zcash/pull/4465 --- src/rpc/client.cpp | 1 + src/wallet/rpcwallet.cpp | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 4107ad6f8..79011da34 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -139,6 +139,7 @@ static const CRPCConvertParam vRPCConvertParams[] = { "z_listunspent", 2 }, { "z_listunspent", 3 }, { "z_getbalance", 1}, + { "z_getnotescount", 0}, { "z_gettotalbalance", 0}, { "z_gettotalbalance", 1}, { "z_gettotalbalance", 2}, diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index b8115767a..5afd0c4e8 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4213,6 +4213,42 @@ UniValue z_getbalance(const UniValue& params, bool fHelp, const CPubKey& mypk) return ValueFromAmount(nBalance); } +UniValue z_getnotescount(const UniValue& params, bool fHelp,const CPubKey& mypk) +{ + if (!EnsureWalletIsAvailable(fHelp)) + return NullUniValue; + + if (fHelp || params.size() > 1) + throw runtime_error( + "z_getnotescount\n" + "\nArguments:\n" + "1. minconf (numeric, optional, default=1) Only include notes in transactions confirmed at least this many times.\n" + "\nReturns the number of sprout and sapling notes available in the wallet.\n" + "\nResult:\n" + "{\n" + " \"sapling\" (numeric) the number of sapling notes in the wallet\n" + "}\n" + "\nExamples:\n" + + HelpExampleCli("z_getnotescount", "0") + ); + + LOCK2(cs_main, pwalletMain->cs_wallet); + + int nMinDepth = 1; + if (params.size() > 0) + nMinDepth = params[0].get_int(); + + int sapling = 0; + for (auto& wtx : pwalletMain->mapWallet) { + if (wtx.second.GetDepthInMainChain() >= nMinDepth) { + sapling += wtx.second.mapSaplingNoteData.size(); + } + } + UniValue ret(UniValue::VOBJ); + ret.push_back(Pair("sapling", sapling)); + + return ret; +} UniValue z_gettotalbalance(const UniValue& params, bool fHelp, const CPubKey& mypk) { @@ -8368,6 +8404,7 @@ static const CRPCCommand commands[] = { "wallet", "z_getinfo", &z_getinfo, true }, { "wallet", "z_listsentbyaddress", &z_listsentbyaddress, true }, { "wallet", "z_listreceivedbyaddress", &z_listreceivedbyaddress, true }, + { "wallet", "z_getnotescount", &z_getnotescount, false }, // TODO: rearrange into another category { "disclosure", "z_getpaymentdisclosure", &z_getpaymentdisclosure, true }, { "disclosure", "z_validatepaymentdisclosure", &z_validatepaymentdisclosure, true } From ed0385b52465bbde771408e83441c7a600dc06f3 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Thu, 30 Apr 2020 06:51:54 -0400 Subject: [PATCH 012/255] Initial merge of subatomic dapp from KMD upstream from dev branch of https://github.com/jl777/komodo/ commit d75041c478bcd721d44be0ab9af45c3d2ba2f69b --- src/cc/dapps/subatomic.c | 1429 +++++++++++++++++++++++++++++++++++ src/cc/dapps/subatomic.json | 26 + 2 files changed, 1455 insertions(+) create mode 100644 src/cc/dapps/subatomic.c create mode 100644 src/cc/dapps/subatomic.json diff --git a/src/cc/dapps/subatomic.c b/src/cc/dapps/subatomic.c new file mode 100644 index 000000000..2f6ebf824 --- /dev/null +++ b/src/cc/dapps/subatomic.c @@ -0,0 +1,1429 @@ +/****************************************************************************** + * Copyright © 2014-2020 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +// build subatomic and put in path: git pull; gcc cc/dapps/subatomic.c -lm -o subatomic; cp subatomic /usr/bin +// alice sends relcoin and gets basecoin + +#define DEXP2P_CHAIN ((char *)"DEX") +#define DEXP2P_PUBKEYS ((char *)"subatomic") +#include "dappinc.h" + +// for OTC mode, the following 4 functions are the only ones that should be needed to support a new "coin" +//int64_t subatomic_getbalance(char *coin); +//bits256 subatomic_coinpayment(int32_t OTCmode,char *coin,char *destaddr,uint64_t paytoshis,char *memostr); +//cJSON *subatomic_txidwait(char *coin,bits256 txid,char *hexstr,int32_t numseconds); +//int64_t subatomic_verifypayment(char *coin,cJSON *rawtx,uint64_t destsatoshis,char *destaddr); + +// TODO: +// address conversion +// new inventory types: +// anonsend + +// bob nodes: +// mutex for bob instances +// "deposits" messages and approved bobs +// volume caps per coin and non-notarized exposure + +// later: +// sharded storage + +#define SUBATOMIC_OTCDEFAULT 1 +#define SUBATOMIC_TIMEOUT 60 +#define SUBATOMIC_LOCKTIME 3600 +#define SUBATOMIC_TXFEE 10000 + +#define SUBATOMIC_PRIORITY 5 + +#define SUBATOMIC_OPENREQUEST 1 +#define SUBATOMIC_APPROVED 2 +#define SUBATOMIC_OPENED 3 +#define SUBATOMIC_PAYMENT 4 +#define SUBATOMIC_PAIDINFULL 5 +#define SUBATOMIC_CLOSED 6 + +cJSON *SUBATOMIC_json; +int32_t SUBATOMIC_retval = -1; + +struct abinfo +{ + char pubkey[67],recvaddr[64],recvZaddr[128],secp[67]; +}; + +struct coininfo +{ + uint64_t satoshis,txfee,maxamount; + char istoken,iszaddr,isfile,isexternal,tokenid[65],coin[16],name[16],cli[256],acname[16],coinstr[16]; +}; + +struct msginfo +{ + UT_hash_handle hh; + bits256 bobpayment,alicepayment; + double price; + uint64_t gotpayment; + uint32_t origid,openrequestid,approvalid,openedid,paymentids[100],paidid,closedid,locktime; + int32_t bobflag,status,OTCmode; + char payload[128],approval[128],senderpub[67],msigaddr[64],redeemscript[256]; + struct coininfo base,rel; + struct abinfo alice,bob; +} *Messages; + +uint64_t subatomic_txfee(char *coin) +{ + return(SUBATOMIC_TXFEE); +} + +char *subatomic_checkname(char *tmpstr,struct msginfo *mp,int32_t baserel,char *coin) +{ + int32_t i,n; cJSON *external,*item; char *coinstr,*clistr; struct coininfo *ptr; + ptr = (baserel == 0) ? &mp->base : &mp->rel; + if ( coin[0] == 0 ) + return(coin); + if ( (external= jarray(&n,SUBATOMIC_json,"externalcoins")) != 0 && n > 0 ) + { + for (i=0; icli) ) + { + ptr->isexternal = 1; + strcpy(ptr->cli,clistr); + //fprintf(stderr,"found external coin %s %s\n",coin,clistr); + } + } + } + if ( coin[0] == '#' ) + { + strcpy(ptr->coinstr,coin); + strcpy(ptr->acname,""); + ptr->isfile = 1; + return(coin); + } + else if ( coin[0] != 'z' ) + { + for (i=1; coin[i]!=0; i++) + if ( coin[i] == '.' ) + { + dpow_tokenregister(ptr->tokenid,0,coin,0); + if ( ptr->tokenid[0] != 0 ) + { + strcpy(tmpstr,coin); + tmpstr[i] = 0; + //fprintf(stderr,"found a tokenmap %s -> %s %s\n",coin,tmpstr,ptr->tokenid); + ptr->istoken = 1; + strcpy(ptr->acname,coin); + strcpy(ptr->coinstr,""); + return(tmpstr); + } + } + if ( ptr->isexternal == 0 ) + { + if ( strcmp(coin,"KMD") != 0 ) + { + strcpy(ptr->acname,coin); + strcpy(ptr->coinstr,""); + } + else + { + strcpy(ptr->coinstr,coin); + strcpy(ptr->acname,""); + } + } + else + { + strcpy(ptr->coinstr,coin); + strcpy(ptr->acname,""); + } + return(coin); + } + else + { + for (i=1; coin[i]!=0; i++) + if ( isupper(coin[i]) == 0 ) + return(coin); + if ( strcmp(coin+1,"KMD") != 0 ) + ptr->iszaddr = 1; + return(coin+1); + } +} + +int32_t subatomic_zonly(struct coininfo *coin) +{ + if ( strcmp(coin->coin,"PIRATE") == 0 ) + return(1); + else return(coin->iszaddr); +} + +// //////////////////////////////// the four key functions needed to support a new item for subatomics + +int64_t _subatomic_getbalance(struct coininfo *coin) +{ + cJSON *retjson; char *retstr,cmpstr[64]; int64_t amount=0; + if ( (retjson= subatomic_cli(coin->cli,&retstr,"getbalance","","","","","","","")) != 0 ) + { + fprintf(stderr,"_subatomic_getbalance.(%s) %s returned json!\n",coin->coinstr,coin->cli); + free_json(retjson); + } + else if ( retstr != 0 ) + { + amount = atof(retstr) * SATOSHIDEN; + sprintf(cmpstr,"%.8f",dstr(amount)); + if ( strcmp(retstr,cmpstr) != 0 ) + amount++; + //printf("retstr %s -> %.8f\n",retstr,dstr(amount)); + free(retstr); + } + return (amount); +} + +bits256 _subatomic_sendtoaddress(struct coininfo *coin,char *destaddr,int64_t satoshis) +{ + char numstr[32],*retstr,str[65]; cJSON *retjson; bits256 txid; + memset(txid.bytes,0,sizeof(txid)); + sprintf(numstr,"%.8f",(double)satoshis/SATOSHIDEN); + if ( (retjson= subatomic_cli(coin->cli,&retstr,"sendtoaddress",destaddr,numstr,"false","","","","")) != 0 ) + { + fprintf(stderr,"unexpected _subatomic_sendtoaddress json.(%s)\n",jprint(retjson,0)); + free_json(retjson); + } + else if ( retstr != 0 ) + { + if ( strlen(retstr) >= 64 ) + { + retstr[64] = 0; + decode_hex(txid.bytes,32,retstr); + } + fprintf(stderr,"_subatomic_sendtoaddress %s %.8f txid.(%s)\n",destaddr,(double)satoshis/SATOSHIDEN,bits256_str(str,txid)); + free(retstr); + } + return(txid); +} + +cJSON *_subatomic_rawtransaction(struct coininfo *coin,bits256 txid) +{ + cJSON *retjson; char *retstr,str[65]; + if ( (retjson= subatomic_cli(coin->cli,&retstr,"getrawtransaction",bits256_str(str,txid),"1","","","","","")) != 0 ) + { + return(retjson); + } + else if ( retstr != 0 ) + { + fprintf(stderr,"_subatomic_rawtransaction.(%s) %s error.(%s)\n",coin->coin,coin->name,retstr); + free(retstr); + } + return(0); +} + +int64_t subatomic_getbalance(struct coininfo *coin) +{ + char *coinstr,*acname=""; FILE *fp; int64_t retval = 0; + if ( strcmp(coin->coin,"KMD") != 0 ) + { + acname = coin->coin; + coinstr = ""; + } else coinstr = coin->coin; + if ( coin->isfile != 0 ) + { + if ( (fp= fopen(coin->name+1,"rb")) != 0 ) // if alice, add bob pubkey to fname + { + fclose(fp); + retval = SATOSHIDEN; + } + return(retval); + } + else if ( subatomic_zonly(coin) != 0 ) + return(z_getbalance(coinstr,acname,DPOW_recvZaddr)); + else + { + if ( coin->istoken != 0 ) + { + if ( get_getbalance(coinstr,acname) < SUBATOMIC_TXFEE ) + { + fprintf(stderr,"not enough balance to send token\n"); + return(0); + } + //fprintf(stderr,"token balance %s\n",coin->tokenid); + return(get_tokenbalance(coinstr,acname,coin->tokenid) * SATOSHIDEN); + } + else if ( coin->isexternal == 0 ) + return(get_getbalance(coinstr,acname)); + else return(_subatomic_getbalance(coin)); + } +} + +bits256 subatomic_coinpayment(uint32_t origid,int32_t OTCmode,struct coininfo *coin,char *destaddr,uint64_t paytoshis,char *memostr,char *destpub,char *senderpub) +{ + bits256 txid; char opidstr[128],opretstr[32],str[65],*status,*coinstr,*acname=""; cJSON *retjson,*retjson2,*item,*res; int32_t i,pending=0; + memset(&txid,0,sizeof(txid)); + if ( OTCmode == 0 ) + { + fprintf(stderr,"micropayment channels are not supported yet\n"); + return(txid); + } + if ( coin->isfile != 0 ) + { + fprintf(stderr,"start broadcast of (%s)\n",coin->coin+1); + if ( (retjson= dpow_publish(SUBATOMIC_PRIORITY,coin->coin+1)) != 0 ) // spawn thread + { + sprintf(opretstr,"%08x",juint(retjson,"id")); + sprintf(opidstr,"%u",origid); + if ( (retjson2= dpow_broadcast(SUBATOMIC_PRIORITY,opretstr,"inbox",opidstr,senderpub,"","")) != 0 ) + free_json(retjson2); + fprintf(stderr,"broadcast file.(%s) and send id.%u to alice (%s)\n",coin->coin+1,juint(retjson,"id"),jprint(retjson,0)); + txid = jbits256(retjson,"filehash"); + free_json(retjson); + } + fprintf(stderr,"end broadcast of (%s) to %s\n",coin->coin+1,senderpub); + return(txid); + } + else if ( subatomic_zonly(coin) != 0 ) + { + if ( memostr[0] == 0 ) + memostr = "beef"; + z_sendmany(opidstr,"",coin->coin,DPOW_recvZaddr,destaddr,paytoshis,memostr); + for (i=0; icoin,opidstr)) != 0 ) + { + item = jitem(retjson,0); + if ( (status= jstr(item,"status")) != 0 ) + { + if ( strcmp(status,"executing") == 0 ) + pending++; + else + { + res = jobj(item,"result"); + txid = jbits256(res,"txid"); + //fprintf(stderr,"got Ztx txid.%s\n",bits256_str(str,txid)); + free_json(retjson); + break; + } + /*else if ( clearresults != 0 ) + { + if ( (result= z_getoperationresult(coinstr,"",jstri(array,i))) != 0 ) + { + free_json(result); + } + }*/ + } + free_json(retjson); + } + sleep(1); + } + if ( i == 60 ) + printf("%u timed out waiting for opid to finish\n",origid); + } + else + { + if ( strcmp(coin->coin,"KMD") != 0 ) + { + acname = coin->coin; + coinstr = ""; + } else coinstr = coin->coin; + if ( coin->istoken != 0 ) + txid = tokentransfer(coinstr,acname,coin->tokenid,destpub,paytoshis/SATOSHIDEN); + else if ( coin->isexternal == 0 ) + { + sprintf(opretstr,"%08x",origid); + txid = sendtoaddress(coinstr,acname,destaddr,paytoshis,opretstr); + } else txid = _subatomic_sendtoaddress(coin,destaddr,paytoshis); + printf("%u got txid.%s\n",origid,bits256_str(str,txid)); + } + return(txid); +} + +cJSON *subatomic_txidwait(struct coininfo *coin,bits256 txid,char *hexstr,int32_t numseconds,char *senderpub) +{ + int32_t i,zflag; char *coinstr,str[65],*acname=""; cJSON *rawtx; bits256 z; bits256 filehash; + memset(&z,0,sizeof(z)); + if ( memcmp(&z,&txid,sizeof(txid)) == 0 ) + return(0); + if ( hexstr != 0 && hexstr[0] != 0 ) // probably not worth doing and zaddr is a problem to decode + { + // compare against txid + // if matches, sendrawtransaction if OTC mode, decoode and return if channels mode + } + zflag = (subatomic_zonly(coin) != 0); + if ( strcmp(coin->coin,"KMD") != 0 ) + { + acname = coin->coin; + coinstr = ""; + } else coinstr = coin->coin; + for (i=0; iisfile != 0 ) + { + if ( (rawtx= dpow_subscribe(SUBATOMIC_PRIORITY,coin->coin+1,senderpub)) != 0 ) + { + filehash = jbits256(rawtx,"filehash"); + if ( memcmp(&filehash,&txid,sizeof(filehash)) != 0 ) + { + fprintf(stderr,"waiting (%s) (%s)\n",coin->coin+1,jprint(rawtx,0)); + free_json(rawtx); + rawtx = 0; + } else return(rawtx); + } + } + else if ( zflag != 0 ) + rawtx = get_z_viewtransaction(coinstr,acname,txid); + else if ( coin->isexternal == 0 ) + rawtx = get_rawtransaction(coinstr,acname,txid); + else rawtx = _subatomic_rawtransaction(coin,txid); + if ( rawtx != 0 ) + return(rawtx); + sleep(1); + } + printf("%s/%s timeout waiting for %s\n",coin->name,coin->coin,bits256_str(str,txid)); + return(0); +} + +int64_t subatomic_verifypayment(struct coininfo *coin,cJSON *rawtx,uint64_t destsatoshis,char *destaddr,bits256 txid) +{ + int32_t i,n,m,valid=0; bits256 tokenid,filehash,checkhash; cJSON *array,*item,*sobj,*a; char *addr,*acname,*coinstr,tokenaddr[64],*hex; uint8_t hexbuf[512],pub33[33]; uint64_t netval,recvsatoshis = 0; + if ( coin->isfile != 0 ) + { + filehash = jbits256(rawtx,"filehash"); + checkhash = jbits256(rawtx,"checkhash"); + if ( memcmp(&txid,&filehash,sizeof(txid)) == 0 && memcmp(&txid,&checkhash,sizeof(txid)) == 0 ) + { + fprintf(stderr,"verified file is matching the filehash (%s)\n",jprint(rawtx,0)); + return(SATOSHIDEN); + } else return(0); + } + else if ( subatomic_zonly(coin) != 0 ) + { + if ( (array= jarray(&n,rawtx,"outputs")) != 0 && n > 0 ) + { + for (i=0; iistoken != 0 ) + { + if ( (array= jarray(&n,rawtx,"vout")) != 0 && n > 0 ) + { + item = jitem(array,0); + if ( (sobj= jobj(item,"scriptPubKey")) != 0 && (a= jarray(&m,sobj,"addresses")) != 0 && m == 1 ) + { + if ( strcmp(coin->coin,"KMD") != 0 ) + { + acname = coin->coin; + coinstr = ""; + } else coinstr = coin->coin; + if ( get_tokenaddress(coinstr,acname,tokenaddr) != 0 ) + { + //fprintf(stderr,"tokenaddr.%s\n",tokenaddr); + if ( (addr= jstri(a,0)) != 0 && strcmp(addr,tokenaddr) == 0 ) + recvsatoshis += SATOSHIDEN * (uint64_t)(jdouble(item,"value")*SATOSHIDEN + 0.000000004999); + else fprintf(stderr,"miscompare (%s) vs %s\n",jprint(sobj,0),addr); + } + } + item = jitem(array,n-1); + if ( (sobj= jobj(item,"scriptPubKey")) != 0 && (hex= jstr(sobj,"hex")) != 0 && (m= is_hexstr(hex,0)) > 1 && m/2 < sizeof(hexbuf) ) + { + m >>= 1; + decode_hex(hexbuf,m,hex); + decode_hex(tokenid.bytes,32,coin->tokenid); + decode_hex(pub33,33,DPOW_secpkeystr); + // opret 69len EVAL_TOKENS 't' tokenid 1 33 pub33 + if ( hexbuf[0] == 0x6a && hexbuf[1] == 0x45 && hexbuf[2] == 0xf2 && hexbuf[3] == 't' && memcmp(&hexbuf[4],&tokenid,sizeof(tokenid)) == 0 && hexbuf[4+32] == 1 && hexbuf[4+32+1] == 33 && memcmp(&hexbuf[4+32+2],pub33,33) == 0 ) + { + valid = 1; + //fprintf(stderr,"validated it is a token transfer!\n"); + } else fprintf(stderr,"need to validate tokentransfer.(%s) %s %d\n",hex,DPOW_secpkeystr,memcmp(&hexbuf[4+32+2],pub33,33) == 0); + //6a 45 f2 74 2b1feef719ecb526b07416dd432bce603ac6dc8bfe794cddf105cb52f6aae3cd 01 21 02b27de3ee5335518b06f69f4fbabb029cfc737613b100996841d5532b324a5a61 + + } + recvsatoshis *= valid; + } + } + else + { + if ( (array= jarray(&n,rawtx,"vout")) != 0 && n > 0 ) + { + for (i=0; iorigid = origid; + HASH_ADD(hh,Messages,origid,sizeof(origid),mp); + return(mp); +} + +int32_t subatomic_status(struct msginfo *mp,int32_t status) +{ + static FILE *fp; + if ( fp == 0 ) + { + int32_t i,oid,s,n,num,count; struct msginfo *m; long fsize; + if ( (fp= fopen("SUBATOMIC.DB","rb+")) == 0 ) + { + if ( (fp= fopen("SUBATOMIC.DB","wb")) == 0 ) + { + fprintf(stderr,"cant create SUBATOMIC.DB\n"); + exit(-1); + } + } + else + { + fseek(fp,0,SEEK_END); + fsize = ftell(fp); + if ( (fsize % (sizeof(uint32_t)*2)) != 0 ) + { + fprintf(stderr,"SUBATOMIC.DB illegal filesize.%ld\n",fsize); + exit(-1); + } + n = (int32_t)(fsize / (sizeof(uint32_t)*2)); + rewind(fp); + for (i=num=count=0; i SUBATOMIC_CLOSED ) + { + fprintf(stderr,"SUBATOMIC.DB corrupted at filepos.%ld: illegal status.%d\n",ftell(fp),s); + exit(-1); + } + //fprintf(stderr,"%u <- %d\n",oid,s); + if ( (m= subatomic_find(oid)) == 0 ) + { + m = subatomic_add(oid); + count++; + } + if ( s > m->status ) + { + m->status = s; + num++; + } + } + fprintf(stderr,"initialized %d messages, updated %d out of total.%d\n",count,num,n); + } + } + if ( mp->status >= status ) + return(-1); + if ( fwrite(&mp->origid,1,sizeof(mp->origid),fp) != sizeof(mp->origid) || fwrite(&status,1,sizeof(status),fp) != sizeof(status) ) + fprintf(stderr,"error updating SUBATOMIC.DB, risk of double spends\n"); + fflush(fp); + mp->status = status; + return(0); +} + +struct msginfo *subatomic_tracker(uint32_t origid) +{ + struct msginfo *mp; + if ( (mp= subatomic_find(origid)) == 0 ) + { + mp = subatomic_add(origid); + subatomic_status(mp,0); + } + return(mp); +} + +char *subatomic_hexstr(char *jsonstr) +{ + char *hexstr; int32_t i,c,n = (int32_t)strlen(jsonstr); + hexstr = malloc(2*n + 3); + strcpy(hexstr,jsonstr); + for (i=0; iorigid); + jaddnum(item,"price",mp->price); + jaddnum(item,"openrequest",mp->openrequestid); + jaddstr(item,"base",mp->base.name); + jaddstr(item,"basecoin",mp->base.coin); + jadd64bits(item,"basesatoshis",mp->base.satoshis); + jadd64bits(item,"basetxfee",mp->base.txfee); + jadd64bits(item,"maxbaseamount",mp->base.maxamount); + jaddstr(item,"rel",mp->rel.name); + jaddstr(item,"relcoin",mp->rel.coin); + jadd64bits(item,"relsatoshis",mp->rel.satoshis); + jadd64bits(item,"reltxfee",mp->rel.txfee); + jadd64bits(item,"maxrelamount",mp->rel.maxamount); + jaddstr(item,"alice",mp->alice.pubkey); + jaddstr(item,"alicesecp",mp->alice.secp); + jaddstr(item,"bob",mp->bob.pubkey); + jaddstr(item,"bobsecp",mp->bob.secp); + if ( subatomic_zonly(&mp->rel) != 0 ) + jaddstr(item,"bobZaddr",mp->bob.recvZaddr); + else jaddstr(item,"bobaddr",mp->bob.recvaddr); + if ( mp->rel.istoken != 0 ) + jaddstr(item,"bobtoken",mp->rel.tokenid); + if ( subatomic_zonly(&mp->base) != 0 ) + jaddstr(item,"aliceZaddr",mp->alice.recvZaddr); + else jaddstr(item,"aliceaddr",mp->alice.recvaddr); + if ( mp->base.istoken != 0 ) + jaddstr(item,"alicetoken",mp->base.tokenid); + return(item); +} + +uint64_t subatomic_orderbook_mpset(struct msginfo *mp,char *basecheck) +{ + cJSON *retjson; char *tagA,*tagB,*senderpub,*str,tmpstr[32]; int32_t matches=0; double volA,volB; int64_t txfee=0; + strcpy(mp->base.name,basecheck); + strcpy(mp->base.coin,subatomic_checkname(tmpstr,mp,0,basecheck)); + mp->rel.txfee = subatomic_txfee(mp->rel.coin); + if ( (retjson= dpow_get(mp->origid)) != 0 ) + { + //fprintf(stderr,"dpow_get.(%s) (%s/%s)\n",jprint(retjson,0),mp->base.coin,mp->rel.coin); + if ( (senderpub= jstr(retjson,"senderpub")) != 0 && is_hexstr(senderpub,0) == 66 && (tagA= jstr(retjson,"tagA")) != 0 && (tagB= jstr(retjson,"tagB")) != 0 && strncmp(tagB,mp->rel.name,strlen(mp->rel.name)) == 0 && strlen(tagA) < sizeof(mp->base.name) ) + { + strcpy(mp->base.name,tagA); + strcpy(mp->base.coin,subatomic_checkname(tmpstr,mp,0,tagA)); + if ( basecheck[0] == 0 || strncmp(basecheck,tagA,strlen(basecheck)) == 0 ) + matches = 1; + else if ( strcmp(tagA,mp->base.name) == 0 ) + matches = 1; + else if ( mp->bobflag != 0 && tagA[0] == '#' && strcmp(mp->base.name,"#allfiles") == 0 ) + matches = 1; + if ( matches != 0 ) + { + if ( (str= jstr(retjson,"decrypted")) != 0 && strlen(str) < 128 ) + strcpy(mp->payload,str); + mp->locktime = juint(retjson,"timestamp") + SUBATOMIC_LOCKTIME; + mp->base.txfee = subatomic_txfee(mp->base.coin); + strcpy(mp->senderpub,senderpub); + volB = jdouble(retjson,"amountB"); + volA = jdouble(retjson,"amountA"); + mp->base.maxamount = volA*SATOSHIDEN + 0.0000000049999; + mp->rel.maxamount = volB*SATOSHIDEN + 0.0000000049999; + if ( 0 && mp->rel.istoken == 0 ) + txfee = mp->rel.txfee; + if ( mp->base.maxamount != 0 && mp->rel.maxamount != 0 && volA > SMALLVAL && volB > SMALLVAL && mp->rel.satoshis <= mp->rel.maxamount ) + { + mp->price = volA / volB; + mp->base.satoshis = (mp->rel.satoshis - txfee) * mp->price; + //fprintf(stderr,"base satoshis.%llu\n",(long long)mp->base.satoshis); + } else fprintf(stderr,"%u rel %llu vs (%llu %llu)\n",mp->origid,(long long)mp->rel.satoshis,(long long)mp->base.maxamount,(long long)mp->rel.maxamount); + } else printf("%u didnt match (%s) tagA.%s %s, tagB.%s %s %d %d\n",mp->origid,basecheck,tagA,mp->base.name,tagB,mp->rel.name,tagA[0] == '#', strcmp(mp->base.name,"#allfiles") == 0); + } else printf("%u didnt compare tagA.%s %s, tagB.%s %s\n",mp->origid,tagA,mp->base.name,tagB,mp->rel.name); + free_json(retjson); + } + return(mp->base.satoshis); +} + +char *randhashstr(char *str) +{ + bits256 rands; int32_t i; + for (i=0; i<32; i++) + rands.bytes[i] = rand() >> 17; + bits256_str(str,rands); + return(str); +} + +void subatomic_extrafields(cJSON *dest,cJSON *src) +{ + char *str; + if ( (str= jstr(src,"approval")) != 0 ) + jaddstr(dest,"approval",str); + if ( (str= jstr(src,"opened")) != 0 ) + jaddstr(dest,"opened",str); + if ( (str= jstr(src,"payamount")) != 0 ) + jaddstr(dest,"payamount",str); + if ( (str= jstr(src,"destaddr")) != 0 ) + jaddstr(dest,"destaddr",str); + if ( (str= jstr(src,"bobpayment")) != 0 ) + jaddstr(dest,"bobpayment",str); + if ( (str= jstr(src,"alicepayment")) != 0 ) + jaddstr(dest,"alicepayment",str); + if ( (str= jstr(src,"bobaddr")) != 0 ) + jaddstr(dest,"bobaddr",str); + if ( (str= jstr(src,"bobZaddr")) != 0 ) + jaddstr(dest,"bobZaddr",str); + if ( (str= jstr(src,"aliceaddr")) != 0 ) + jaddstr(dest,"aliceaddr",str); + if ( (str= jstr(src,"aliceZaddr")) != 0 ) + jaddstr(dest,"aliceZaddr",str); + if ( (str= jstr(src,"alicetoken")) != 0 ) + jaddstr(dest,"alicetoken",str); + if ( (str= jstr(src,"bobtoken")) != 0 ) + jaddstr(dest,"bobtoken",str); +} + +char *subatomic_submit(cJSON *argjson,int32_t tobob) +{ + char *jsonstr,*hexstr; + jaddnum(argjson,"tobob",tobob != 0); + jsonstr = jprint(argjson,1); + hexstr = subatomic_hexstr(jsonstr); + free(jsonstr); + return(hexstr); +} + +#define SCRIPT_OP_IF 0x63 +#define SCRIPT_OP_ELSE 0x67 +#define SCRIPT_OP_DUP 0x76 +#define SCRIPT_OP_ENDIF 0x68 +#define SCRIPT_OP_TRUE 0x51 +#define SCRIPT_OP_2 0x52 +#define SCRIPT_OP_3 0x53 +#define SCRIPT_OP_DROP 0x75 +#define SCRIPT_OP_EQUALVERIFY 0x88 +#define SCRIPT_OP_HASH160 0xa9 +#define SCRIPT_OP_EQUAL 0x87 +#define SCRIPT_OP_CHECKSIG 0xac +#define SCRIPT_OP_CHECKMULTISIG 0xae +#define SCRIPT_OP_CHECKMULTISIGVERIFY 0xaf +#define SCRIPT_OP_CHECKLOCKTIMEVERIFY 0xb1 + +int32_t subatomic_redeemscript(char *redeemscript,uint32_t locktime,char *pubkeyA,char *pubkeyB) // not needed +{ + // if ( refund ) OP_HASH160 <2of2 multisig hash> OP_EQUAL // standard multisig + // else CLTV OP_DROP OP_CHECKSIG // standard spend + uint8_t pubkeyAbytes[33],pubkeyBbytes[33],hex[4096]; int32_t i,n = 0; + decode_hex(pubkeyAbytes,33,pubkeyA); + decode_hex(pubkeyBbytes,33,pubkeyB); + hex[n++] = SCRIPT_OP_IF; + hex[n++] = SCRIPT_OP_2; + hex[n++] = 33, memcpy(&hex[n],pubkeyAbytes,33), n += 33; + hex[n++] = 33, memcpy(&hex[n],pubkeyBbytes,33), n += 33; + hex[n++] = SCRIPT_OP_2; + hex[n++] = SCRIPT_OP_CHECKMULTISIG; + hex[n++] = SCRIPT_OP_ELSE; + hex[n++] = 4; + hex[n++] = locktime & 0xff, locktime >>= 8; + hex[n++] = locktime & 0xff, locktime >>= 8; + hex[n++] = locktime & 0xff, locktime >>= 8; + hex[n++] = locktime & 0xff; + hex[n++] = SCRIPT_OP_CHECKLOCKTIMEVERIFY; + hex[n++] = SCRIPT_OP_DROP; + hex[n++] = 33; memcpy(&hex[n],pubkeyAbytes,33); n += 33; + hex[n++] = SCRIPT_OP_CHECKSIG; + hex[n++] = SCRIPT_OP_ENDIF; + for (i=0; i>4) & 0xf); + redeemscript[i*2 + 1] = hexbyte(hex[i] & 0xf); + } + redeemscript[n*2] = 0; + /*tmpbuf[0] = SCRIPT_OP_HASH160; + tmpbuf[1] = 20; + calc_OP_HASH160(scriptPubKey,tmpbuf+2,redeemscript); + tmpbuf[22] = SCRIPT_OP_EQUAL; + init_hexbytes_noT(scriptPubKey,tmpbuf,23); + if ( p2shaddr != 0 ) + { + p2shaddr[0] = 0; + if ( (btc_addr= base58_encode_check(addrtype,true,tmpbuf+2,20)) != 0 ) + { + if ( strlen(btc_addr->str) < 36 ) + strcpy(p2shaddr,btc_addr->str); + cstr_free(btc_addr,true); + } + }*/ + return(n); +} + +int32_t subatomic_approved(struct msginfo *mp,cJSON *approval,cJSON *msgjson,char *senderpub) +{ + char *hexstr,numstr[32],redeemscript[1024],*coin,*acname=""; cJSON *retjson,*decodejson; int32_t i,retval = 0; + subatomic_extrafields(approval,msgjson); + if ( mp->OTCmode == 0 ) + { + coin = (mp->bobflag != 0) ? mp->base.coin : mp->rel.coin; // the other side gets this coin + if ( strcmp(coin,"KMD") != 0 ) + { + acname = coin; + coin = ""; + } + if ( get_createmultisig2(coin,acname,mp->msigaddr,mp->redeemscript,mp->alice.secp,mp->bob.secp) != 0 ) + { + subatomic_redeemscript(redeemscript,mp->locktime,mp->alice.secp,mp->bob.secp); + if ( (decodejson= get_decodescript(coin,acname,redeemscript)) != 0 ) + { + fprintf(stderr,"%s %s msigaddr.%s %s -> %s %s\n",mp->bobflag!=0?"bob":"alice",(mp->bobflag != 0) ? mp->base.coin : mp->rel.coin,mp->msigaddr,mp->redeemscript,redeemscript,jprint(decodejson,0)); + free(decodejson); + } + } + } + sprintf(numstr,"%u",mp->origid); + for (i=0; numstr[i]!=0; i++) + sprintf(&mp->approval[i<<1],"%02x",numstr[i]); + sprintf(&mp->approval[i<<1],"%02x",' '); + i++; + mp->approval[i<<1] = 0; + jaddstr(approval,"approval",mp->approval); + hexstr = subatomic_submit(approval,!mp->bobflag); + if ( (retjson= dpow_broadcast(SUBATOMIC_PRIORITY,hexstr,(char *)"inbox",(char *)"approved",senderpub,"","")) != 0 ) + { + if ( (mp->approvalid= juint(retjson,"id")) != 0 ) + retval = 1; + printf("%u approvalid.%u (%s)\n",mp->origid,mp->approvalid,senderpub); + subatomic_status(mp,SUBATOMIC_APPROVED); + free_json(retjson); + } + free(hexstr); + return(retval); +} + +int32_t subatomic_opened(struct msginfo *mp,cJSON *opened,cJSON *msgjson,char *senderpub) +{ + char *hexstr,channelstr[65]; cJSON *retjson; int32_t retval = 0; + subatomic_extrafields(opened,msgjson); + jaddstr(opened,"opened",randhashstr(channelstr)); + hexstr = subatomic_submit(opened,!mp->bobflag); + if ( (retjson= dpow_broadcast(SUBATOMIC_PRIORITY,hexstr,(char *)"inbox",(char *)"opened",senderpub,"","")) != 0 ) + { + if ( (mp->openedid= juint(retjson,"id")) != 0 ) + retval = 1; + printf("%u openedid.%u\n",mp->origid,mp->openedid); + subatomic_status(mp,SUBATOMIC_OPENED); + free_json(retjson); + } + free(hexstr); + return(retval); +} + +int32_t subatomic_payment(struct msginfo *mp,cJSON *payment,cJSON *msgjson,char *senderpub) +{ + bits256 txid; uint64_t paytoshis; cJSON *retjson; char numstr[32],*coin,*dest,*hexstr; int32_t retval = 0; + if ( mp->bobflag == 0 ) + { + coin = mp->rel.name; + paytoshis = mp->rel.satoshis; + if ( subatomic_zonly(&mp->rel) != 0 ) + dest = mp->bob.recvZaddr; + else dest = mp->bob.recvaddr; + sprintf(numstr,"%llu",(long long)paytoshis); + jaddstr(payment,"alicepays",numstr); + jaddstr(payment,"bobdestaddr",dest); + txid = subatomic_coinpayment(mp->origid,mp->OTCmode,&mp->rel,dest,paytoshis,mp->approval,mp->bob.secp,senderpub); + jaddbits256(payment,"alicepayment",txid); + mp->alicepayment = txid; + hexstr = 0; // get it from rawtransaction of txid + jaddstr(payment,"alicetx",hexstr); + } + else + { + coin = mp->base.name; + paytoshis = mp->base.satoshis; + if ( subatomic_zonly(&mp->base) != 0 ) + dest = mp->alice.recvZaddr; + else dest = mp->alice.recvaddr; + sprintf(numstr,"%llu",(long long)paytoshis); + jaddstr(payment,"bobpays",numstr); + jaddstr(payment,"alicedestaddr",dest); + txid = subatomic_coinpayment(mp->origid,mp->OTCmode,&mp->base,dest,paytoshis,mp->approval,mp->alice.secp,senderpub); + jaddbits256(payment,"bobpayment",txid); + mp->bobpayment = txid; + hexstr = 0; // get it from rawtransaction of txid + jaddstr(payment,"bobtx",hexstr); + } + hexstr = subatomic_submit(payment,!mp->bobflag); + if ( (retjson= dpow_broadcast(SUBATOMIC_PRIORITY,hexstr,(char *)"inbox",(char *)"payment",senderpub,"","")) != 0 ) + { + if ( (mp->paymentids[0]= juint(retjson,"id")) != 0 ) + retval = 1; + printf("%u: %.8f %s -> %s, paymentid[0] %u\n",mp->origid,dstr(paytoshis),coin,dest,mp->paymentids[0]); + subatomic_status(mp,SUBATOMIC_PAYMENT); + free_json(retjson); + } + free(hexstr); + return(retval); +} + +int32_t subatomic_paidinfull(struct msginfo *mp,cJSON *paid,cJSON *msgjson,char *senderpub) +{ + char *hexstr; cJSON *retjson; int32_t retval = 0; + jaddstr(paid,"paid","in full"); + subatomic_extrafields(paid,msgjson); + hexstr = subatomic_submit(paid,!mp->bobflag); + if ( (retjson= dpow_broadcast(SUBATOMIC_PRIORITY,hexstr,(char *)"inbox",(char *)"paid",senderpub,"","")) != 0 ) + { + if ( (mp->paidid= juint(retjson,"id")) != 0 ) + retval = 1; + printf("%u paidid.%u\n",mp->origid,mp->paidid); + subatomic_status(mp,SUBATOMIC_PAIDINFULL); + free_json(retjson); + } + free(hexstr); + return(retval); +} + +int32_t subatomic_closed(struct msginfo *mp,cJSON *closed,cJSON *msgjson,char *senderpub) +{ + char *hexstr; cJSON *retjson; int32_t retval = 0; + jaddnum(closed,"closed",mp->origid); + subatomic_extrafields(closed,msgjson); + hexstr = subatomic_submit(closed,!mp->bobflag); + if ( (retjson= dpow_broadcast(SUBATOMIC_PRIORITY,hexstr,(char *)"inbox",(char *)"closed",senderpub,"","")) != 0 ) + { + if ( (mp->closedid= juint(retjson,"id")) != 0 ) + retval = 1; + subatomic_status(mp,SUBATOMIC_CLOSED); + printf("%u closedid.%u\n",mp->origid,mp->closedid); + free_json(retjson); + } + free(hexstr); + return(retval); +} + +uint32_t subatomic_alice_openrequest(struct msginfo *origmp) +{ + struct msginfo *mp; cJSON *retjson,*openrequest; char *hexstr,*str,tmpstr[32]; + mp = subatomic_tracker(origmp->origid); + mp->origid = origmp->origid; + mp->rel.satoshis = origmp->rel.satoshis; + mp->rel.istoken = origmp->rel.istoken; + strcpy(mp->rel.tokenid,origmp->rel.tokenid); + strcpy(mp->rel.name,origmp->rel.name); + strcpy(mp->rel.coin,subatomic_checkname(tmpstr,mp,1,origmp->rel.name)); + strcpy(mp->alice.pubkey,DPOW_pubkeystr); + strcpy(mp->alice.secp,DPOW_secpkeystr); + strcpy(mp->alice.recvZaddr,DPOW_recvZaddr); + strcpy(mp->alice.recvaddr,DPOW_recvaddr); + printf("rel.%s/%s %s openrequest %u status.%d (%s/%s)\n",mp->rel.name,mp->rel.coin,mp->rel.tokenid,mp->origid,mp->status,mp->alice.recvaddr,mp->alice.recvZaddr); + if ( mp->status == 0 && subatomic_orderbook_mpset(mp,"") != 0 ) + { + strcpy(mp->bob.pubkey,mp->senderpub); + if ( subatomic_zonly(&mp->base) != 0 || subatomic_zonly(&mp->rel) != 0 ) + mp->OTCmode = 1; + else mp->OTCmode = SUBATOMIC_OTCDEFAULT; + strcpy(origmp->base.name,mp->base.name); + strcpy(origmp->base.coin,mp->base.coin); + origmp->base.istoken = mp->base.istoken; + strcpy(origmp->base.tokenid,mp->base.tokenid); + origmp->OTCmode = mp->OTCmode; + if ( mp->rel.istoken != 0 && ((mp->rel.satoshis % SATOSHIDEN) != 0 || mp->rel.iszaddr != 0) ) + { + printf("%u cant do zaddr or fractional rel %s.%s tokens %.8f\n",mp->origid,mp->rel.coin,mp->rel.tokenid,dstr(mp->rel.satoshis)); + return(0); + } + else if ( mp->base.istoken != 0 && ((mp->base.satoshis % SATOSHIDEN) != 0 || mp->base.iszaddr != 0 ) ) + { + printf("%u cant do zaddr or fractional base %s.%s tokens %.8f\n",mp->origid,mp->base.coin,mp->base.tokenid,dstr(mp->base.satoshis)); + return(0); + } + else if ( (openrequest= subatomic_mpjson(mp)) != 0 ) + { + hexstr = subatomic_submit(openrequest,!mp->bobflag); + if ( (retjson= dpow_broadcast(SUBATOMIC_PRIORITY,hexstr,(char *)"inbox",(char *)"openrequest",mp->bob.pubkey,"","")) != 0 ) + { + mp->openrequestid = juint(retjson,"id"); + printf("%u openrequest.%u -> (%s)\n",mp->origid,mp->openrequestid,mp->bob.pubkey); + subatomic_status(mp,SUBATOMIC_OPENREQUEST); + free_json(retjson); + } + free(hexstr); + } + } + return(mp->openrequestid); +} + +void subatomic_bob_gotopenrequest(uint32_t inboxid,char *senderpub,cJSON *msgjson,char *basename,char *relname) +{ + struct msginfo *mp; cJSON *approval; int32_t origid; char *addr,tmpstr[32],*coin,*acname=""; + origid = juint(msgjson,"origid"); + mp = subatomic_tracker(origid); + strcpy(mp->base.name,basename); + strcpy(mp->base.coin,subatomic_checkname(tmpstr,mp,0,basename)); + strcpy(mp->rel.name,relname); + strcpy(mp->rel.coin,subatomic_checkname(tmpstr,mp,1,relname)); + mp->origid = origid; + mp->rel.satoshis = j64bits(msgjson,"relsatoshis"); + mp->bobflag = 1; + strcpy(mp->bob.pubkey,DPOW_pubkeystr); + strcpy(mp->bob.secp,DPOW_secpkeystr); + strcpy(mp->bob.recvZaddr,DPOW_recvZaddr); + strcpy(mp->bob.recvaddr,DPOW_recvaddr); + if ( (addr= jstr(msgjson,"aliceaddr")) != 0 ) + strcpy(mp->alice.recvaddr,addr); + if ( (addr= jstr(msgjson,"aliceZaddr")) != 0 ) + strcpy(mp->alice.recvZaddr,addr); + if ( (addr= jstr(msgjson,"alicesecp")) != 0 ) + strcpy(mp->alice.secp,addr); + if ( subatomic_zonly(&mp->base) != 0 || subatomic_zonly(&mp->rel) != 0 ) + mp->OTCmode = 1; + else mp->OTCmode = SUBATOMIC_OTCDEFAULT; + printf("%u got open request\n",mp->origid); + if ( mp->status == 0 && subatomic_orderbook_mpset(mp,basename) != 0 && (approval= subatomic_mpjson(mp)) != 0 ) + { + if ( mp->rel.istoken != 0 && ((mp->rel.satoshis % SATOSHIDEN) != 0 || mp->rel.iszaddr != 0) ) + { + printf("%u cant do zaddr or fractional rel %s.%s tokens %.8f\n",mp->origid,mp->rel.coin,mp->rel.tokenid,dstr(mp->rel.satoshis)); + subatomic_closed(mp,approval,msgjson,senderpub); + return; + } + else if ( mp->base.istoken != 0 && ((mp->base.satoshis % SATOSHIDEN) != 0 || mp->base.iszaddr != 0 ) ) + { + printf("%u cant do zaddr or fractional base %s.%s tokens %.8f\n",mp->origid,mp->base.coin,mp->base.tokenid,dstr(mp->base.satoshis)); + subatomic_closed(mp,approval,msgjson,senderpub); + return; + } + else if ( subatomic_getbalance(&mp->base) < mp->base.satoshis ) + { + printf("%u bob node low on %s funds! %.8f not enough for %.8f\n",mp->origid,mp->base.coin,dstr(subatomic_getbalance(&mp->base)),dstr(mp->base.satoshis)); + subatomic_closed(mp,approval,msgjson,senderpub); + } + else + { + printf("%u bob (%s/%s) gotopenrequest origid.%u status.%d (%s/%s) SENDERPUB.(%s)\n",mp->origid,mp->base.name,mp->rel.name,mp->origid,mp->status,mp->bob.recvaddr,mp->bob.recvZaddr,senderpub); + subatomic_approved(mp,approval,msgjson,senderpub); + } + } +} + +int32_t subatomic_channelapproved(uint32_t inboxid,char *senderpub,cJSON *msgjson,struct msginfo *origmp) +{ + struct msginfo *mp; cJSON *approval; char *addr,*coin,*acname; int32_t retval = 0; + mp = subatomic_tracker(juint(msgjson,"origid")); + if ( subatomic_orderbook_mpset(mp,mp->base.name) != 0 && (approval= subatomic_mpjson(mp)) != 0 ) + { + printf("%u iambob.%d (%s/%s) channelapproved origid.%u status.%d\n",mp->origid,mp->bobflag,mp->base.name,mp->rel.name,mp->origid,mp->status); + if ( mp->bobflag == 0 && mp->status == SUBATOMIC_OPENREQUEST ) + { + if ( (addr= jstr(msgjson,"bobaddr")) != 0 ) + strcpy(mp->bob.recvaddr,addr); + if ( (addr= jstr(msgjson,"bobZaddr")) != 0 ) + strcpy(mp->bob.recvZaddr,addr); + if ( (addr= jstr(msgjson,"bobsecp")) != 0 ) + strcpy(mp->bob.secp,addr); + retval = subatomic_approved(mp,approval,msgjson,senderpub); + } + else if ( mp->bobflag != 0 && mp->status == SUBATOMIC_APPROVED ) + retval = subatomic_opened(mp,approval,msgjson,senderpub); + } + return(retval); +} + +int32_t subatomic_incomingopened(uint32_t inboxid,char *senderpub,cJSON *msgjson,struct msginfo *origmp) +{ + struct msginfo *mp; cJSON *payment; int32_t retval = 0; + mp = subatomic_tracker(juint(msgjson,"origid")); + if ( subatomic_orderbook_mpset(mp,mp->base.name) != 0 && (payment= subatomic_mpjson(mp)) != 0 ) + { + printf("%u iambob.%d (%s/%s) incomingchannel status.%d\n",mp->origid,mp->bobflag,mp->base.name,mp->rel.name,mp->status); + if ( mp->bobflag == 0 && mp->status == SUBATOMIC_APPROVED ) + retval = subatomic_payment(mp,payment,msgjson,senderpub); + else if ( mp->bobflag != 0 && mp->status == SUBATOMIC_OPENED ) + retval = 1; // nothing to do + } + return(retval); +} + +int32_t subatomic_incomingpayment(uint32_t inboxid,char *senderpub,cJSON *msgjson,struct msginfo *origmp) +{ + static FILE *fp; + struct msginfo *mp; cJSON *pay,*rawtx,*retjson; bits256 txid; char str[65],*hexstr; int32_t retval = 0; + mp = subatomic_tracker(juint(msgjson,"origid")); + if ( subatomic_orderbook_mpset(mp,mp->base.name) != 0 && (pay= subatomic_mpjson(mp)) != 0 ) + { + printf("%u iambob.%d (%s/%s) incomingpayment status.%d\n",mp->origid,mp->bobflag,mp->base.name,mp->rel.name,mp->status); + if ( mp->bobflag == 0 ) + { + txid = jbits256(msgjson,"bobpayment"); + jaddbits256(msgjson,"alicepayment",mp->alicepayment); + printf("%u alice waits for %s.%s to be in mempool (%.8f -> %s)\n",mp->origid,mp->base.name,bits256_str(str,txid),dstr(mp->base.satoshis),subatomic_zonly(&mp->base) == 0 ? mp->alice.recvaddr : mp->alice.recvZaddr); + hexstr = jstr(msgjson,"bobtx"); + if ( (rawtx= subatomic_txidwait(&mp->base,txid,hexstr,SUBATOMIC_TIMEOUT,senderpub)) != 0 ) + { + if ( subatomic_verifypayment(&mp->base,rawtx,mp->base.satoshis,subatomic_zonly(&mp->base) == 0 ? mp->alice.recvaddr : mp->alice.recvZaddr,txid) >= 0 ) + mp->gotpayment = 1; + free_json(rawtx); + } + if ( mp->gotpayment != 0 ) + { + printf("%u SWAP COMPLETE <<<<<<<<<<<<<<<<\n",mp->origid); + SUBATOMIC_retval = 0; + if ( mp->base.iszaddr == 0 ) + { + sprintf(str,"%u",mp->origid); + if ( (retjson= dpow_broadcast(SUBATOMIC_PRIORITY,bits256_str(str,mp->alicepayment),(char *)"completed",str,DPOW_pubkeystr,"","")) != 0 ) + free_json(retjson); + } + } + else + { + printf("%u SWAP INCOMPLETE, waiting on %s.%s\n",mp->origid,mp->base.name,bits256_str(str,txid)); + if ( (fp= fopen("SUBATOMIC.incomplete","a+")) != 0 ) + { + char *jsonstr = jprint(msgjson,0); + fwrite(jsonstr,1,strlen(jsonstr),fp); + fputc('\n',fp); + fclose(fp); + free(jsonstr); + } + if ( mp->base.iszaddr == 0 ) + { + sprintf(str,"%u",mp->origid); + if ( (retjson= dpow_broadcast(SUBATOMIC_PRIORITY,bits256_str(str,mp->alicepayment),(char *)"incomplete",str,DPOW_pubkeystr,"","")) != 0 ) + free_json(retjson); + } + subatomic_closed(mp,pay,msgjson,senderpub); + exit(-1); + } + } + if ( mp->gotpayment != 0 ) + retval = subatomic_paidinfull(mp,pay,msgjson,senderpub); + else + { + if ( mp->bobflag != 0 && mp->status == SUBATOMIC_OPENED ) + { + txid = jbits256(msgjson,"alicepayment"); + printf("%u bob waits for %s.%s to be in mempool (%.8f -> %s)\n",mp->origid,mp->rel.name,bits256_str(str,txid),dstr(mp->rel.satoshis),subatomic_zonly(&mp->rel) == 0 ? mp->bob.recvaddr : mp->bob.recvZaddr); + hexstr = jstr(msgjson,"alicetx"); + if ( (rawtx= subatomic_txidwait(&mp->rel,txid,hexstr,SUBATOMIC_TIMEOUT,senderpub)) != 0 ) + { + if ( subatomic_verifypayment(&mp->rel,rawtx,mp->rel.satoshis,subatomic_zonly(&mp->rel) == 0 ? mp->bob.recvaddr : mp->bob.recvZaddr,txid) >= 0 ) + mp->gotpayment = 1; + free_json(rawtx); + } + if ( mp->gotpayment != 0 ) + { + retval = subatomic_payment(mp,pay,msgjson,senderpub); + jaddbits256(msgjson,"bobpayment",mp->bobpayment); + if ( mp->rel.iszaddr == 0 ) + { + sprintf(str,"%u",mp->origid); + if ( (retjson= dpow_broadcast(SUBATOMIC_PRIORITY,bits256_str(str,mp->bobpayment),(char *)"completed",str,DPOW_pubkeystr,"","")) != 0 ) + free_json(retjson); + } + printf("%u SWAP COMPLETE <<<<<<<<<<<<<<<<\n",mp->origid); + if ( (fp= fopen("SUBATOMIC.proof","rb+")) == 0 ) + fp = fopen("SUBATOMIC.proof","wb"); + if ( fp != 0 ) + { + char *jsonstr = jprint(msgjson,0); + fseek(fp,0,SEEK_END); + fwrite(jsonstr,1,strlen(jsonstr),fp); + fputc('\n',fp); + fflush(fp); + free(jsonstr); + } + } else printf("%u SWAP INCOMPLETE: %s\n",mp->origid,jprint(msgjson,0)); + } + } + } + return(retval); +} + +int32_t subatomic_incomingfullypaid(uint32_t inboxid,char *senderpub,cJSON *msgjson,struct msginfo *origmp) +{ + struct msginfo *mp; cJSON *closed; int32_t retval = 0; + mp = subatomic_tracker(juint(msgjson,"origid")); + if ( subatomic_orderbook_mpset(mp,mp->base.name) != 0 && (closed= subatomic_mpjson(mp)) != 0 ) + { + printf("%u iambob.%d (%s/%s) incomingfullypaid status.%d\n",mp->origid,mp->bobflag,mp->base.name,mp->rel.name,mp->status); + // error check msgjson vs M + if ( mp->bobflag == 0 && mp->status == SUBATOMIC_PAIDINFULL ) + retval = subatomic_closed(mp,closed,msgjson,senderpub); + else if ( mp->bobflag != 0 && mp->status == SUBATOMIC_PAYMENT ) + retval = subatomic_paidinfull(mp,closed,msgjson,senderpub); + } + return(retval); +} + +int32_t subatomic_incomingclosed(uint32_t inboxid,char *senderpub,cJSON *msgjson,struct msginfo *origmp) +{ + struct msginfo *mp; cJSON *closed; int32_t retval = 0; + mp = subatomic_tracker(juint(msgjson,"origid")); + if ( subatomic_orderbook_mpset(mp,mp->base.name) != 0 && (closed= subatomic_mpjson(mp)) != 0 ) + { + printf("%u iambob.%d (%s/%s) incomingclose status.%d\n",mp->origid,mp->bobflag,mp->base.name,mp->rel.name,mp->status); + if ( mp->bobflag != 0 ) + dpow_cancel(mp->origid); + if ( mp->status < SUBATOMIC_CLOSED ) + { + retval = subatomic_closed(mp,closed,msgjson,senderpub); + subatomic_status(mp,SUBATOMIC_CLOSED); + } + retval = 1; + } + return(retval); +} + +int32_t subatomic_ismine(int32_t bobflag,cJSON *json,char *basename,char *relname) +{ + char *base,*rel; + if ( (base= jstr(json,"base")) != 0 && (rel= jstr(json,"rel")) != 0 ) + { + if ( strcmp(base,basename) == 0 && strcmp(rel,relname) == 0 ) + return(1); + if ( bobflag != 0 ) + { + if ( strcmp(basename,"#allfiles") == 0 && base[0] == '#' ) + return(1); + fprintf(stderr,"skip ismine (%s/%s) vs (%s/%s)\n",basename,relname,base,rel); + } + } + return(0); +} + +void subatomic_tokensregister(int32_t priority) +{ + char *token_name,*tokenid,existing[65]; cJSON *tokens,*token; int32_t i,numtokens; + if ( SUBATOMIC_json != 0 && (tokens= jarray(&numtokens,SUBATOMIC_json,"tokens")) != 0 ) + { + for (i=0; i 0 ) + { + for (j=0; j %s, %u %llu %u\n",mp->bobflag,mp->base.name,mp->rel.name,mp->origid,(long long)mp->rel.satoshis,mp->openrequestid); + while ( 1 ) + { + if ( msgs == 0 ) + { + sleep(1); + fflush(stdout); + if ( mp->bobflag != 0 ) + { + dpow_pubkeyregister(SUBATOMIC_PRIORITY); + subatomic_tokensregister(SUBATOMIC_PRIORITY); + subatomic_filesregister(SUBATOMIC_PRIORITY); + } + } + msgs = 0; + for (iter=0; iter<(int32_t)(sizeof(tagBs)/sizeof(*tagBs)); iter++) + { + tagB = tagBs[iter]; + if ( (ptrs= dpow_inboxcheck(&n,&stopats[iter],tagB)) != 0 ) + { + for (i=0; ijsonstr)) != 0 ) + { + if ( jint(inboxjson,"tobob") != mp->bobflag ) + continue; + if ( subatomic_ismine(mp->bobflag,inboxjson,mp->base.name,mp->rel.name) != 0 ) + { + if ( strcmp(tagB,"openrequest") == 0 && mp->bobflag != 0 ) + subatomic_bob_gotopenrequest(ptr->shorthash,ptr->senderpub,inboxjson,mp->base.name,mp->rel.name); + else if ( strcmp(tagB,"approved") == 0 ) + mask |= subatomic_channelapproved(ptr->shorthash,ptr->senderpub,inboxjson,mp) << 0; + else if ( strcmp(tagB,"opened") == 0 ) + mask |= subatomic_incomingopened(ptr->shorthash,ptr->senderpub,inboxjson,mp) << 1; + else if ( strcmp(tagB,"payment") == 0 ) + mask |= subatomic_incomingpayment(ptr->shorthash,ptr->senderpub,inboxjson,mp) << 2; + else if ( strcmp(tagB,"paid") == 0 ) + mask |= subatomic_incomingfullypaid(ptr->shorthash,ptr->senderpub,inboxjson,mp) << 3; + else if ( strcmp(tagB,"closed") == 0 ) + mask |= subatomic_incomingclosed(ptr->shorthash,ptr->senderpub,inboxjson,mp) * 0x1f; + else fprintf(stderr,"iambob.%d unknown unexpected tagB.(%s)\n",mp->bobflag,tagB); + } + free_json(inboxjson); + } else fprintf(stderr,"subatomic iambob.%d loop got unparseable(%s)\n",mp->bobflag,ptr->jsonstr); + free(ptr); + ptrs[i] = 0; + } + } + free(ptrs); + } + } + if ( mp->bobflag == 0 && (mask & 0x1f) == 0x1f ) + { + printf("alice %u %llu %u finished\n",mp->origid,(long long)mp->rel.satoshis,mp->openrequestid); + break; + } + } +} + +int32_t main(int32_t argc,char **argv) +{ + char *fname = "subatomic.json"; + int32_t i,height; char *coin,*kcli,*subatomic,*hashstr,*acname=(char *)""; cJSON *retjson; bits256 blockhash; char checkstr[65],str[65],str2[65],tmpstr[32]; long fsize; struct msginfo M; + memset(&M,0,sizeof(M)); + srand((int32_t)time(NULL)); + if ( (subatomic= filestr(&fsize,fname)) == 0 ) + { + fprintf(stderr,"cant load %s file\n",fname); + exit(-1); + } + if ( (SUBATOMIC_json= cJSON_Parse(subatomic)) == 0 ) + { + fprintf(stderr,"cant parse subatomic.json file (%s)\n",subatomic); + exit(-1); + } + free(subatomic); + if ( argc >= 4 ) + { + if ( dpow_pubkey() < 0 ) + { + fprintf(stderr,"couldnt set pubkey for DEX\n"); + return(-1); + } + coin = (char *)argv[1]; + if ( argv[2][0] != 0 ) + REFCOIN_CLI = (char *)argv[2]; + else + { + if ( strcmp(coin,"KMD") != 0 ) + { + acname = coin; + } + } + hashstr = (char *)argv[3]; + strcpy(M.rel.coin,subatomic_checkname(tmpstr,&M,1,coin)); + strcpy(M.rel.name,coin); + if ( argc == 4 && strlen(hashstr) == 64 ) // for blocknotify usage, seems not needed + { + height = get_coinheight(coin,acname,&blockhash); + bits256_str(checkstr,blockhash); + if ( strcmp(checkstr,hashstr) == 0 ) + { + fprintf(stderr,"%s: (%s) %s height.%d\n",coin,REFCOIN_CLI!=0?REFCOIN_CLI:"",checkstr,height); + if ( (retjson= dpow_ntzdata(coin,SUBATOMIC_PRIORITY,height,blockhash)) != 0 ) + free_json(retjson); + } else fprintf(stderr,"coin.%s (%s) %s vs %s, height.%d\n",coin,REFCOIN_CLI!=0?REFCOIN_CLI:"",checkstr,hashstr,height); + if ( strcmp("BTC",coin) != 0 ) + { + bits256 prevntzhash,ntzhash; int32_t prevntzheight,ntzheight; uint32_t ntztime,prevntztime; char hexstr[81]; cJSON *retjson2; + prevntzhash = dpow_ntzhash(coin,&prevntzheight,&prevntztime); + if ( (retjson= get_getinfo(coin,acname)) != 0 ) + { + ntzheight = juint(retjson,"notarized"); + ntzhash = jbits256(retjson,"notarizedhash"); + if ( ntzheight > prevntzheight ) + { + get_coinmerkleroot(coin,acname,ntzhash,&ntztime); + fprintf(stderr,"NOTARIZATION %s.%d %s t.%u\n",coin,ntzheight,bits256_str(str,ntzhash),ntztime); + bits256_str(hexstr,ntzhash); + sprintf(&hexstr[64],"%08x",ntzheight); + sprintf(&hexstr[72],"%08x",ntztime); + hexstr[80] = 0; + if ( (retjson2= dpow_broadcast(SUBATOMIC_PRIORITY,hexstr,coin,"notarizations",DPOW_pubkeystr,"","")) != 0 ) + free_json(retjson2); + } + else if ( ntzheight == prevntzheight && memcmp(&prevntzhash,&ntzhash,32) != 0 ) + fprintf(stderr,"NTZ ERROR %s.%d %s != %s\n",coin,ntzheight,bits256_str(str,ntzhash),bits256_str(str2,prevntzhash)); + free_json(retjson); + } + } + } + else if ( argc == 5 && atol(hashstr) > 10000 ) + { + char checkstr[32]; uint64_t mult = 1; + M.origid = (uint32_t)atol(hashstr); + sprintf(checkstr,"%u",M.origid); + if ( strcmp(checkstr,hashstr) == 0 ) // alice + { + M.rel.satoshis = (uint64_t)(atof(argv[4])*SATOSHIDEN+0.0000000049999); + for (i=0; M.rel.name[i]!=0; i++) + if ( M.rel.name[i] == '.' ) + { + mult = SATOSHIDEN; + break; + } + if ( subatomic_getbalance(&M.rel) < M.rel.satoshis/mult ) + { + fprintf(stderr,"not enough balance %s %.8f for %.8f\n",M.rel.coin,dstr(subatomic_getbalance(&M.rel)),dstr(M.rel.satoshis/mult)); + return(-1); + } + fprintf(stderr,"subatomic_channel_alice (%s/%s) %s %u with %.8f %llu\n",M.rel.name,M.rel.coin,hashstr,M.origid,atof(argv[4]),(long long)M.rel.satoshis); + dpow_pubkeyregister(SUBATOMIC_PRIORITY); + M.openrequestid = subatomic_alice_openrequest(&M); + if ( M.openrequestid != 0 ) + subatomic_loop(&M); + } else fprintf(stderr,"checkstr mismatch %s %s != %s\n",coin,hashstr,checkstr); + } + else + { + M.bobflag = 1; + strcpy(M.base.name,hashstr); + strcpy(M.base.coin,subatomic_checkname(tmpstr,&M,0,hashstr)); + subatomic_loop(&M); // while ( 1 ) loop for each relcoin -> basecoin + } + } + return(SUBATOMIC_retval); +} + diff --git a/src/cc/dapps/subatomic.json b/src/cc/dapps/subatomic.json new file mode 100644 index 000000000..7420c712c --- /dev/null +++ b/src/cc/dapps/subatomic.json @@ -0,0 +1,26 @@ +{ +"authorized": [ + {"chmex":"030754bffcf6dfcb34a20c486ff5a5be5546b9cc16fba9692165272b3f8e98c4af" }, + {"SHossain":"03c8657bd57b6ceb14514a10e99fe8a0cec5a9bc24592df7f66f050e670e4f6bac" }, + {"satinder":"03732f8ef851ff234c74d0df575c2c5b159e2bab3faca4ec52b3f217d5cda5361d" }, + {"ml777":"02453d028c74cb9551e1aaf35113383b6ecbd9f06ff23a4ab1a953429b9763e345" }, + {"tonylhub":"0218e0f435d4544404c25a7759b7f7174d821215085ef936218c5569d975af468b" }, + {"gthub":"036c7de9a5090fbad78b9eea41549ccacc07bd0e9e7f8d290c88f470f3569e1a35" }, + {"zkTrader":"026c6b0b35ec0adc2f8a5c648da1fce634f798c69d5e9fe518400447e88398b830" }, + {"nutellalicka":"03aee08860e0340f0f490a3ef3718d6676882f2d63d4f536dfebb1d348b82c79ee" }, + {"gcharang":"02d3431950c2f0f9654217b6ce3d44468d3a9ca7255741767fdeee7c5ec6b47567" }, + {"jl777":"02b27de3ee5335518b06f69f4fbabb029cfc737613b100996841d5532b324a5a61" } +], +"tokens":[ + {"RICK.demo":"2b1feef719ecb526b07416dd432bce603ac6dc8bfe794cddf105cb52f6aae3cd"} +], +"files":[ + {"filename":"komodod","prices":[{"KMD":0.1}, {"PIRATE":1}]} +], +"externalcoins":[ + { "BTC":"bitcoin-cli" }, + { "CHIPS":"chips-cli" }, + { "VRSC":"verus" } +] +} + From 19ddbe12802c690b5eada1627dd58b9707d839d4 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Thu, 30 Apr 2020 06:57:21 -0400 Subject: [PATCH 013/255] Update subatomic json --- src/cc/dapps/subatomic.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/dapps/subatomic.json b/src/cc/dapps/subatomic.json index 7420c712c..7832fdb9e 100644 --- a/src/cc/dapps/subatomic.json +++ b/src/cc/dapps/subatomic.json @@ -15,12 +15,13 @@ {"RICK.demo":"2b1feef719ecb526b07416dd432bce603ac6dc8bfe794cddf105cb52f6aae3cd"} ], "files":[ - {"filename":"komodod","prices":[{"KMD":0.1}, {"PIRATE":1}]} + {"filename":"hushd","prices":[{"HUSH":0.1}, {"PIRATE":1}]} ], "externalcoins":[ { "BTC":"bitcoin-cli" }, + { "KMD":"komodod-cli" }, { "CHIPS":"chips-cli" }, - { "VRSC":"verus" } + { "PIRATE":"pirate-cli" } ] } From 70bd156655a3b92d9e6d3924b8227a0dd8e1d869 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Thu, 30 Apr 2020 07:04:52 -0400 Subject: [PATCH 014/255] Add dapp header to make subatomic happy --- src/cc/dapps/dappinc.h | 1599 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1599 insertions(+) create mode 100644 src/cc/dapps/dappinc.h diff --git a/src/cc/dapps/dappinc.h b/src/cc/dapps/dappinc.h new file mode 100644 index 000000000..3c71dfdec --- /dev/null +++ b/src/cc/dapps/dappinc.h @@ -0,0 +1,1599 @@ +/****************************************************************************** + * Copyright © 2014-2020 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +#include +#include +#include +#include +#include "cJSON.c" + +bits256 zeroid; + +int32_t unstringbits(char *buf,uint64_t bits) +{ + int32_t i; + for (i=0; i<8; i++,bits>>=8) + if ( (buf[i]= (char)(bits & 0xff)) == 0 ) + break; + buf[i] = 0; + return(i); +} + +uint64_t stringbits(char *str) +{ + uint64_t bits = 0; + if ( str == 0 ) + return(0); + int32_t i,n = (int32_t)strlen(str); + if ( n > 8 ) + n = 8; + for (i=n-1; i>=0; i--) + bits = (bits << 8) | (str[i] & 0xff); + //printf("(%s) -> %llx %llu\n",str,(long long)bits,(long long)bits); + return(bits); +} + +char hexbyte(int32_t c) +{ + c &= 0xf; + if ( c < 10 ) + return('0'+c); + else if ( c < 16 ) + return('a'+c-10); + else return(0); +} + +int32_t _unhex(char c) +{ + if ( c >= '0' && c <= '9' ) + return(c - '0'); + else if ( c >= 'a' && c <= 'f' ) + return(c - 'a' + 10); + else if ( c >= 'A' && c <= 'F' ) + return(c - 'A' + 10); + return(-1); +} + +int32_t is_hexstr(char *str,int32_t n) +{ + int32_t i; + if ( str == 0 || str[0] == 0 ) + return(0); + for (i=0; str[i]!=0; i++) + { + if ( n > 0 && i >= n ) + break; + if ( _unhex(str[i]) < 0 ) + break; + } + if ( n == 0 ) + return(i); + return(i == n); +} + +int32_t unhex(char c) +{ + int32_t hex; + if ( (hex= _unhex(c)) < 0 ) + { + //printf("unhex: illegal hexchar.(%c)\n",c); + } + return(hex); +} + +unsigned char _decode_hex(char *hex) { return((unhex(hex[0])<<4) | unhex(hex[1])); } + +int32_t decode_hex(unsigned char *bytes,int32_t n,char *hex) +{ + int32_t adjust,i = 0; + //printf("decode.(%s)\n",hex); + if ( is_hexstr(hex,n) <= 0 ) + { + memset(bytes,0,n); + return(n); + } + if ( hex[n-1] == '\n' || hex[n-1] == '\r' ) + hex[--n] = 0; + if ( hex[n-1] == '\n' || hex[n-1] == '\r' ) + hex[--n] = 0; + if ( n == 0 || (hex[n*2+1] == 0 && hex[n*2] != 0) ) + { + if ( n > 0 ) + { + bytes[0] = unhex(hex[0]); + printf("decode_hex n.%d hex[0] (%c) -> %d hex.(%s) [n*2+1: %d] [n*2: %d %c] len.%ld\n",n,hex[0],bytes[0],hex,hex[n*2+1],hex[n*2],hex[n*2],(long)strlen(hex)); + } + bytes++; + hex++; + adjust = 1; + } else adjust = 0; + if ( n > 0 ) + { + for (i=0; i>4) & 0xf); + hexbytes[i*2 + 1] = hexbyte(message[i] & 0xf); + //printf("i.%d (%02x) [%c%c]\n",i,message[i],hexbytes[i*2],hexbytes[i*2+1]); + } + hexbytes[len*2] = 0; + //printf("len.%ld\n",len*2+1); + return((int32_t)len*2+1); +} + +long _stripwhite(char *buf,int accept) +{ + int32_t i,j,c; + if ( buf == 0 || buf[0] == 0 ) + return(0); + for (i=j=0; buf[i]!=0; i++) + { + buf[j] = c = buf[i]; + if ( c == accept || (c != ' ' && c != '\n' && c != '\r' && c != '\t' && c != '\b') ) + j++; + } + buf[j] = 0; + return(j); +} + +char *clonestr(char *str) +{ + char *clone; + if ( str == 0 || str[0]==0) + { + printf("warning cloning nullstr.%p\n",str); + //#ifdef __APPLE__ + // while ( 1 ) sleep(1); + //#endif + str = (char *)""; + } + clone = (char *)malloc(strlen(str)+16); + strcpy(clone,str); + return(clone); +} + +int32_t safecopy(char *dest,char *src,long len) +{ + int32_t i = -1; + if ( src != 0 && dest != 0 && src != dest ) + { + if ( dest != 0 ) + memset(dest,0,len); + for (i=0; i0; i--) + str[i] = str[i-1]; + str[0] = '/'; + str[n+1] = 0; + }*/ +#endif + return(str); +#endif +} + +void *loadfile(char *fname,uint8_t **bufp,long *lenp,long *allocsizep) +{ + FILE *fp; + long filesize,buflen = *allocsizep; + uint8_t *buf = *bufp; + *lenp = 0; + if ( (fp= fopen(portable_path(fname),"rb")) != 0 ) + { + fseek(fp,0,SEEK_END); + filesize = ftell(fp); + if ( filesize == 0 ) + { + fclose(fp); + *lenp = 0; + //printf("loadfile null size.(%s)\n",fname); + return(0); + } + if ( filesize > buflen ) + { + *allocsizep = filesize; + *bufp = buf = (uint8_t *)realloc(buf,(long)*allocsizep+64); + } + rewind(fp); + if ( buf == 0 ) + printf("Null buf ???\n"); + else + { + if ( fread(buf,1,(long)filesize,fp) != (unsigned long)filesize ) + printf("error reading filesize.%ld\n",(long)filesize); + buf[filesize] = 0; + } + fclose(fp); + *lenp = filesize; + //printf("loaded.(%s)\n",buf); + } //else printf("OS_loadfile couldnt load.(%s)\n",fname); + return(buf); +} + +void *filestr(long *allocsizep,char *_fname) +{ + long filesize = 0; char *fname,*buf = 0; void *retptr; + *allocsizep = 0; + fname = malloc(strlen(_fname)+1); + strcpy(fname,_fname); + retptr = loadfile(fname,(uint8_t **)&buf,&filesize,allocsizep); + free(fname); + return(retptr); +} + +char *send_curl(char *url,char *fname) +{ + long fsize; char curlstr[1024]; + sprintf(curlstr,"curl --url \"%s\" > %s",url,fname); + system(curlstr); + return(filestr(&fsize,fname)); +} + +cJSON *get_urljson(char *url,char *fname) +{ + char *jsonstr; cJSON *json = 0; + if ( (jsonstr= send_curl(url,fname)) != 0 ) + { + //printf("(%s) -> (%s)\n",url,jsonstr); + json = cJSON_Parse(jsonstr); + free(jsonstr); + } + return(json); +} + +////////////////////////////////////////////// +// start of dapp +////////////////////////////////////////////// +int md_unlink(char *file) +{ +#ifdef _WIN32 + _chmod(file, 0600); + return( _unlink(file) ); +#else + return(unlink(file)); +#endif +} + +char *REFCOIN_CLI,DPOW_pubkeystr[67],DPOW_secpkeystr[67],DPOW_handle[67],DPOW_recvaddr[64],DPOW_recvZaddr[128]; + +cJSON *get_komodocli(char *refcoin,char **retstrp,char *acname,char *method,char *arg0,char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6) +{ + long fsize; cJSON *retjson = 0; char cmdstr[32768],*jsonstr,fname[32768]; + sprintf(fname,"/tmp/notarizer_%s_%d",method,(rand() >> 17) % 10000); + //if ( (acname == 0 || acname[0] == 0) && strcmp(refcoin,"KMD") != 0 ) + // acname = refcoin; + if ( acname[0] != 0 ) + { + if ( refcoin[0] != 0 && strcmp(refcoin,"KMD") != 0 && strcmp(refcoin,acname) != 0 ) + printf("unexpected: refcoin.(%s) acname.(%s)\n",refcoin,acname); + sprintf(cmdstr,"komodo-cli -ac_name=%s %s %s %s %s %s %s %s %s > %s\n",acname,method,arg0,arg1,arg2,arg3,arg4,arg5,arg6,fname); + } + else if ( strcmp(refcoin,"KMD") == 0 ) + sprintf(cmdstr,"komodo-cli %s %s %s %s %s %s %s %s > %s\n",method,arg0,arg1,arg2,arg3,arg4,arg5,arg6,fname); + else if ( REFCOIN_CLI != 0 && REFCOIN_CLI[0] != 0 ) + { + sprintf(cmdstr,"%s %s %s %s %s %s %s %s %s > %s\n",REFCOIN_CLI,method,arg0,arg1,arg2,arg3,arg4,arg5,arg6,fname); + //printf("ref.(%s) REFCOIN_CLI (%s)\n",refcoin,cmdstr); + } +//fprintf(stderr,"system(%s)\n",cmdstr); + system(cmdstr); + *retstrp = 0; + if ( (jsonstr= filestr(&fsize,fname)) != 0 ) + { + jsonstr[strlen(jsonstr)-1]='\0'; + //fprintf(stderr,"%s -> jsonstr.(%s)\n",cmdstr,jsonstr); + if ( (jsonstr[0] != '{' && jsonstr[0] != '[') || (retjson= cJSON_Parse(jsonstr)) == 0 ) + *retstrp = jsonstr; + else free(jsonstr); + md_unlink(fname); + } //else fprintf(stderr,"system(%s) -> NULL\n",cmdstr); + return(retjson); +} + +cJSON *subatomic_cli(char *clistr,char **retstrp,char *method,char *arg0,char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6) +{ + long fsize; cJSON *retjson = 0; char cmdstr[32768],*jsonstr,fname[32768]; + sprintf(fname,"/tmp/subatomic_%s_%d",method,(rand() >> 17) % 10000); + sprintf(cmdstr,"%s %s %s %s %s %s %s %s %s > %s\n",clistr,method,arg0,arg1,arg2,arg3,arg4,arg5,arg6,fname); +//fprintf(stderr,"system(%s)\n",cmdstr); + system(cmdstr); + *retstrp = 0; + if ( (jsonstr= filestr(&fsize,fname)) != 0 ) + { + jsonstr[strlen(jsonstr)-1]='\0'; + //fprintf(stderr,"%s -> jsonstr.(%s)\n",cmdstr,jsonstr); + if ( (jsonstr[0] != '{' && jsonstr[0] != '[') || (retjson= cJSON_Parse(jsonstr)) == 0 ) + *retstrp = jsonstr; + else free(jsonstr); + md_unlink(fname); + } //else fprintf(stderr,"system(%s) -> NULL\n",cmdstr); + return(retjson); +} + +bits256 komodobroadcast(char *refcoin,char *acname,cJSON *hexjson) +{ + char *hexstr,*retstr,str[65]; cJSON *retjson; bits256 txid; + memset(txid.bytes,0,sizeof(txid)); + if ( (hexstr= jstr(hexjson,"hex")) != 0 ) + { + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"sendrawtransaction",hexstr,"","","","","","")) != 0 ) + { + //fprintf(stderr,"broadcast.(%s)\n",jprint(retjson,0)); + free_json(retjson); + } + else if ( retstr != 0 ) + { + if ( strlen(retstr) >= 64 ) + { + retstr[64] = 0; + decode_hex(txid.bytes,32,retstr); + } + fprintf(stderr,"broadcast %s txid.(%s)\n",strlen(acname)>0?acname:refcoin,bits256_str(str,txid)); + free(retstr); + } + } + return(txid); +} + +bits256 sendtoaddress(char *refcoin,char *acname,char *destaddr,int64_t satoshis,char *oprethexstr) +{ + char numstr[32],*retstr,str[65]; cJSON *retjson; bits256 txid; + memset(txid.bytes,0,sizeof(txid)); + sprintf(numstr,"%.8f",(double)satoshis/SATOSHIDEN); + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"sendtoaddress",destaddr,numstr,"false","","",oprethexstr,"")) != 0 ) + { + fprintf(stderr,"unexpected sendrawtransaction json.(%s)\n",jprint(retjson,0)); + free_json(retjson); + } + else if ( retstr != 0 ) + { + if ( strlen(retstr) >= 64 ) + { + retstr[64] = 0; + decode_hex(txid.bytes,32,retstr); + } + fprintf(stderr,"sendtoaddress %s %.8f txid.(%s)\n",destaddr,(double)satoshis/SATOSHIDEN,bits256_str(str,txid)); + free(retstr); + } + return(txid); +} + +bits256 tokentransfer(char *refcoin,char *acname,char *tokenid,char *destpub,int64_t units) +{ + char numstr[32],*retstr,str[65]; cJSON *retjson; bits256 txid; + memset(txid.bytes,0,sizeof(txid)); + sprintf(numstr,"%llu",(long long)units); + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"tokentransfer",tokenid,destpub,numstr,"","","","")) != 0 ) + { + txid = komodobroadcast(refcoin,acname,retjson); + fprintf(stderr,"tokentransfer returned (%s)\n",jprint(retjson,0)); + free_json(retjson); + } + else if ( retstr != 0 ) + { + fprintf(stderr,"tokentransfer.(%s) error.(%s)\n",acname,retstr); + free(retstr); + } + return(txid); +} + +char *get_tokenaddress(char *refcoin,char *acname,char *tokenaddr) +{ + char *retstr,*str; cJSON *retjson; + tokenaddr[0] = 0; + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"tokenaddress","","","","","","","")) != 0 ) + { + if ( (str= jstr(retjson,"myCCAddress(Tokens)")) != 0 ) + { + strcpy(tokenaddr,str); + fprintf(stderr,"tokenaddress returned (%s)\n",tokenaddr); + free_json(retjson); + return(tokenaddr); + } + free_json(retjson); + } + else if ( retstr != 0 ) + { + //fprintf(stderr,"tokentransfer.(%s) error.(%s)\n",acname,retstr); + free(retstr); + } + return(0); +} + +int64_t get_tokenbalance(char *refcoin,char *acname,char *tokenid) +{ + cJSON *retjson; char *retstr,cmpstr[64]; int64_t amount=0; + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"tokenbalance",tokenid,"","","","","","")) != 0 ) + { + amount = j64bits(retjson,"balance"); + fprintf(stderr,"tokenbalance %llu\n",(long long)amount); + free_json(retjson); + } + else if ( retstr != 0 ) + { + //printf("retstr %s -> %.8f\n",retstr,dstr(amount)); + free(retstr); + } + return (amount); +} + +cJSON *get_decodescript(char *refcoin,char *acname,char *script) +{ + cJSON *retjson; char *retstr; + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"decodescript",script,"","","","","","")) != 0 ) + { + return(retjson); + } + else if ( retstr != 0 ) + { + fprintf(stderr,"get_decodescript.(%s) error.(%s)\n",acname,retstr); + free(retstr); + } + return(0); +} + +char *get_createmultisig2(char *refcoin,char *acname,char *msigaddr,char *redeemscript,char *pubkeyA,char *pubkeyB) +{ + //char para 2 '["02c3af47b51a506b08b4ededb156cb4c3f9db9e0ac7ad27b8623c08a056fdcc220", "038e61fbface549a850862f12ed99b7cbeef5c2bd2d8f1daddb34809416f0259e1"]' + cJSON *retjson; char *retstr,*str,params[256]; int32_t height=0; + msigaddr[0] = 0; + redeemscript[0] = 0; + sprintf(params,"'[\"%s\", \"%s\"]'",pubkeyA,pubkeyB); + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"createmultisig","2",params,"","","","","")) != 0 ) + { + if ( (str= jstr(retjson,"address")) != 0 ) + strcpy(msigaddr,str); + if ( (str= jstr(retjson,"redeemScript")) != 0 ) + strcpy(redeemscript,str); + free_json(retjson); + if ( msigaddr[0] != 0 && redeemscript[0] != 0 ) + return(msigaddr); + else return(0); + } + else if ( retstr != 0 ) + { + fprintf(stderr,"%s get_createmultisig2.(%s) error.(%s)\n",refcoin,acname,retstr); + free(retstr); + } + return(0); +} + +int32_t get_coinheight(char *refcoin,char *acname,bits256 *blockhashp) +{ + cJSON *retjson; char *retstr; int32_t height=0; + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getblockchaininfo","","","","","","","")) != 0 ) + { + height = jint(retjson,"blocks"); + *blockhashp = jbits256(retjson,"bestblockhash"); + free_json(retjson); + } + else if ( retstr != 0 ) + { + fprintf(stderr,"%s get_coinheight.(%s) error.(%s)\n",refcoin,acname,retstr); + free(retstr); + } + return(height); +} + +bits256 get_coinblockhash(char *refcoin,char *acname,int32_t height) +{ + cJSON *retjson; char *retstr,heightstr[32]; bits256 hash; + memset(hash.bytes,0,sizeof(hash)); + sprintf(heightstr,"%d",height); + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getblockhash",heightstr,"","","","","","")) != 0 ) + { + fprintf(stderr,"unexpected blockhash json.(%s)\n",jprint(retjson,0)); + free_json(retjson); + } + else if ( retstr != 0 ) + { + if ( strlen(retstr) >= 64 ) + { + retstr[64] = 0; + decode_hex(hash.bytes,32,retstr); + } + free(retstr); + } + return(hash); +} + +bits256 get_coinmerkleroot(char *refcoin,char *acname,bits256 blockhash,uint32_t *blocktimep) +{ + cJSON *retjson; char *retstr,str[65]; bits256 merkleroot; + memset(merkleroot.bytes,0,sizeof(merkleroot)); + *blocktimep = 0; + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getblockheader",bits256_str(str,blockhash),"","","","","","")) != 0 ) + { + merkleroot = jbits256(retjson,"merkleroot"); + *blocktimep = juint(retjson,"time"); + //fprintf(stderr,"got merkleroot.(%s)\n",bits256_str(str,merkleroot)); + free_json(retjson); + } + else if ( retstr != 0 ) + { + fprintf(stderr,"%s %s get_coinmerkleroot error.(%s)\n",refcoin,acname,retstr); + free(retstr); + } + return(merkleroot); +} + +uint32_t get_heighttime(char *refcoin,char *acname,int32_t height) +{ + bits256 blockhash; uint32_t blocktime; + blockhash = get_coinblockhash(refcoin,acname,height); + get_coinmerkleroot(refcoin,acname,blockhash,&blocktime); + return(blocktime); +} + +int32_t get_coinheader(char *refcoin,char *acname,bits256 *blockhashp,bits256 *merklerootp,int32_t prevheight) +{ + int32_t height = 0; char str[65]; bits256 bhash; uint32_t blocktime; + if ( prevheight == 0 ) + height = get_coinheight(refcoin,acname,&bhash) - 20; + else height = prevheight + 1; + if ( height > 0 ) + { + *blockhashp = get_coinblockhash(refcoin,acname,height); + if ( bits256_nonz(*blockhashp) != 0 ) + { + *merklerootp = get_coinmerkleroot(refcoin,acname,*blockhashp,&blocktime); + if ( bits256_nonz(*merklerootp) != 0 ) + return(height); + } + } + memset(blockhashp,0,sizeof(*blockhashp)); + memset(merklerootp,0,sizeof(*merklerootp)); + return(0); +} + +cJSON *get_rawmempool(char *refcoin,char *acname) +{ + cJSON *retjson; char *retstr; + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getrawmempool","","","","","","","")) != 0 ) + { + //printf("mempool.(%s)\n",jprint(retjson,0)); + return(retjson); + } + else if ( retstr != 0 ) + { + fprintf(stderr,"get_rawmempool.(%s) error.(%s)\n",acname,retstr); + free(retstr); + } + return(0); +} + +cJSON *get_addressutxos(char *refcoin,char *acname,char *coinaddr) +{ + cJSON *retjson; char *retstr,jsonbuf[256]; + if ( refcoin[0] != 0 && strcmp(refcoin,"KMD") != 0 ) + printf("warning: assumes %s has addressindex enabled\n",refcoin); + sprintf(jsonbuf,"{\\\"addresses\\\":[\\\"%s\\\"]}",coinaddr); + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getaddressutxos",jsonbuf,"","","","","","")) != 0 ) + { + //printf("addressutxos.(%s)\n",jprint(retjson,0)); + return(retjson); + } + else if ( retstr != 0 ) + { + fprintf(stderr,"get_addressutxos.(%s) error.(%s)\n",acname,retstr); + free(retstr); + } + return(0); +} + +cJSON *get_rawtransaction(char *refcoin,char *acname,bits256 txid) +{ + cJSON *retjson; char *retstr,str[65]; + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getrawtransaction",bits256_str(str,txid),"1","","","","","")) != 0 ) + { + return(retjson); + } + else if ( retstr != 0 ) + { + fprintf(stderr,"get_rawtransaction.(%s) %s error.(%s)\n",refcoin,acname,retstr); + free(retstr); + } + return(0); +} + +cJSON *get_z_viewtransaction(char *refcoin,char *acname,bits256 txid) +{ + cJSON *retjson; char *retstr,str[65]; + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_viewtransaction",bits256_str(str,txid),"","","","","","")) != 0 ) + { + return(retjson); + } + else if ( retstr != 0 ) + { + fprintf(stderr,"get_z_viewtransaction.(%s) %s error.(%s)\n",refcoin,acname,retstr); + free(retstr); + } + return(0); +} + +cJSON *get_listunspent(char *refcoin,char *acname) +{ + cJSON *retjson; char *retstr,str[65]; + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"listunspent","","","","","","","")) != 0 ) + { + return(retjson); + } + else if ( retstr != 0 ) + { + fprintf(stderr,"get_listunspent.(%s) %s error.(%s)\n",refcoin,acname,retstr); + free(retstr); + } + return(0); +} + +cJSON *get_getinfo(char *refcoin,char *acname) +{ + cJSON *retjson; char *retstr,str[65]; + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getinfo","","","","","","","")) != 0 ) + { + return(retjson); + } + else if ( retstr != 0 ) + { + fprintf(stderr,"get_getinfo.(%s) %s error.(%s)\n",refcoin,acname,retstr); + free(retstr); + } + return(0); +} + +cJSON *z_listunspent(char *refcoin,char *acname) +{ + cJSON *retjson; char *retstr,str[65]; + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_listunspent","","","","","","","")) != 0 ) + { + return(retjson); + } + else if ( retstr != 0 ) + { + fprintf(stderr,"z_listunspent.(%s) %s error.(%s)\n",refcoin,acname,retstr); + free(retstr); + } + return(0); +} + +cJSON *z_listoperationids(char *refcoin,char *acname) +{ + cJSON *retjson; char *retstr,str[65]; + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_listoperationids","","","","","","","")) != 0 ) + { + return(retjson); + } + else if ( retstr != 0 ) + { + fprintf(stderr,"z_listoperationids.(%s) %s error.(%s)\n",refcoin,acname,retstr); + free(retstr); + } + return(0); +} + +cJSON *z_getoperationstatus(char *refcoin,char *acname,char *opid) +{ + cJSON *retjson; char *retstr,str[65],params[512]; + sprintf(params,"'[\"%s\"]'",opid); + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_getoperationstatus",params,"","","","","","")) != 0 ) + { + //printf("got status (%s)\n",jprint(retjson,0)); + return(retjson); + } + else if ( retstr != 0 ) + { + fprintf(stderr,"z_getoperationstatus.(%s) %s error.(%s)\n",refcoin,acname,retstr); + free(retstr); + } + return(0); +} + +cJSON *z_getoperationresult(char *refcoin,char *acname,char *opid) +{ + cJSON *retjson; char *retstr,str[65],params[512]; + sprintf(params,"'[\"%s\"]'",opid); + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_getoperationresult",params,"","","","","","")) != 0 ) + { + return(retjson); + } + else if ( retstr != 0 ) + { + fprintf(stderr,"z_getoperationresult.(%s) %s error.(%s)\n",refcoin,acname,retstr); + free(retstr); + } + return(0); +} + +int32_t validateaddress(char *refcoin,char *acname,char *depositaddr, char* compare) +{ + cJSON *retjson; char *retstr; int32_t res=0; + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"validateaddress",depositaddr,"","","","","","")) != 0 ) + { + if (is_cJSON_True(jobj(retjson,compare)) != 0 ) res=1; + free_json(retjson); + } + else if ( retstr != 0 ) + { + fprintf(stderr,"validateaddress.(%s) %s error.(%s)\n",refcoin,acname,retstr); + free(retstr); + } + return (res); +} + +int32_t z_validateaddress(char *refcoin,char *acname,char *depositaddr, char *compare) +{ + cJSON *retjson; char *retstr; int32_t res=0; + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_validateaddress",depositaddr,"","","","","","")) != 0 ) + { + if (is_cJSON_True(jobj(retjson,compare)) != 0 ) + res=1; + free_json(retjson); + } + else if ( retstr != 0 ) + { + fprintf(stderr,"z_validateaddress.(%s) %s error.(%s)\n",refcoin,acname,retstr); + free(retstr); + } + return (res); +} + +int64_t get_getbalance(char *refcoin,char *acname) +{ + cJSON *retjson; char *retstr,cmpstr[64]; int64_t amount=0; + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getbalance","","","","","","","")) != 0 ) + { + fprintf(stderr,"get_getbalance.(%s) %s returned json!\n",refcoin,acname); + free_json(retjson); + } + else if ( retstr != 0 ) + { + amount = atof(retstr) * SATOSHIDEN; + sprintf(cmpstr,"%.8f",dstr(amount)); + if ( strcmp(retstr,cmpstr) != 0 ) + amount++; + //printf("retstr %s -> %.8f\n",retstr,dstr(amount)); + free(retstr); + } + return (amount); +} + +int64_t z_getbalance(char *refcoin,char *acname,char *coinaddr) +{ + cJSON *retjson; char *retstr,cmpstr[64]; int64_t amount=0; + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_getbalance",coinaddr,"","","","","","")) != 0 ) + { + fprintf(stderr,"z_getbalance.(%s) %s returned json!\n",refcoin,acname); + free_json(retjson); + } + else if ( retstr != 0 ) + { + amount = atof(retstr) * SATOSHIDEN; + sprintf(cmpstr,"%.8f",dstr(amount)); + if ( strcmp(retstr,cmpstr) != 0 ) + amount++; + //printf("retstr %s -> %.8f\n",retstr,dstr(amount)); + free(retstr); + } + return (amount); +} + +int32_t z_exportkey(char *privkey,char *refcoin,char *acname,char *zaddr) +{ + cJSON *retjson; char *retstr,cmpstr[64]; int64_t amount=0; + privkey[0] = 0; + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_exportkey",zaddr,"","","","","","")) != 0 ) + { + fprintf(stderr,"z_exportkey.(%s) %s returned json!\n",refcoin,acname); + free_json(retjson); + return(-1); + } + else if ( retstr != 0 ) + { + //printf("retstr %s -> %.8f\n",retstr,dstr(amount)); + strcpy(privkey,retstr); + free(retstr); + return(0); + } + return(-1); +} + +int32_t getnewaddress(char *coinaddr,char *refcoin,char *acname) +{ + cJSON *retjson; char *retstr; int64_t amount=0; int32_t retval = -1; + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"getnewaddress","","","","","","","")) != 0 ) + { + fprintf(stderr,"getnewaddress.(%s) %s returned json!\n",refcoin,acname); + free_json(retjson); + } + else if ( retstr != 0 ) + { + strcpy(coinaddr,retstr); + free(retstr); + retval = 0; + } + return(retval); +} + +int32_t z_getnewaddress(char *coinaddr,char *refcoin,char *acname,char *typestr) +{ + cJSON *retjson; char *retstr; int64_t amount=0; int32_t retval = -1; + if ( (retjson= get_komodocli(refcoin,&retstr,acname,"z_getnewaddress",typestr,"","","","","","")) != 0 ) + { + fprintf(stderr,"z_getnewaddress.(%s) %s returned json!\n",refcoin,acname); + free_json(retjson); + } + else if ( retstr != 0 ) + { + strcpy(coinaddr,retstr); + free(retstr); + retval = 0; + } + return(retval); +} + +int64_t find_onetime_amount(char *coinstr,char *coinaddr) +{ + cJSON *array,*item; int32_t i,n; char *addr; int64_t amount = 0; + coinaddr[0] = 0; + if ( (array= get_listunspent(coinstr,"")) != 0 ) + { + //printf("got listunspent.(%s)\n",jprint(array,0)); + if ( (n= cJSON_GetArraySize(array)) > 0 ) + { + for (i=0; i 0 ) + { + for (i=0; i %s\n",coinstr,acname,srcaddr,params); + if ( (retjson= get_komodocli(coinstr,&retstr,acname,"z_sendmany",addr,params,"","","","","")) != 0 ) + { + printf("unexpected json z_sendmany.(%s)\n",jprint(retjson,0)); + free_json(retjson); + } + else if ( retstr != 0 ) + { + fprintf(stderr,"z_sendmany.(%s) -> opid.(%s)\n",coinstr,retstr); + strcpy(opidstr,retstr); + free(retstr); + retval = 0; + } + return(retval); +} + +int32_t z_mergetoaddress(char *opidstr,char *coinstr,char *acname,char *destaddr) +{ + cJSON *retjson; char *retstr,addr[128],*opstr; int32_t retval = -1; + sprintf(addr,"[\\\"ANY_SPROUT\\\"]"); + if ( (retjson= get_komodocli(coinstr,&retstr,acname,"z_mergetoaddress",addr,destaddr,"","","","","")) != 0 ) + { + if ( (opstr= jstr(retjson,"opid")) != 0 ) + strcpy(opidstr,opstr); + retval = jint(retjson,"remainingNotes"); + fprintf(stderr,"%s\n",jprint(retjson,0)); + free_json(retjson); + } + else if ( retstr != 0 ) + { + fprintf(stderr,"z_mergetoaddress.(%s) -> opid.(%s)\n",coinstr,retstr); + strcpy(opidstr,retstr); + free(retstr); + } + return(retval); +} + +int32_t empty_mempool(char *coinstr,char *acname) +{ + cJSON *array; int32_t n; + if ( (array= get_rawmempool(coinstr,acname)) != 0 ) + { + if ( (n= cJSON_GetArraySize(array)) > 0 ) + return(0); + free_json(array); + return(1); + } + return(-1); +} + +cJSON *getinputarray(int64_t *totalp,cJSON *unspents,int64_t required) +{ + cJSON *vin,*item,*vins = cJSON_CreateArray(); int32_t i,n,v; int64_t satoshis; bits256 txid; + *totalp = 0; + if ( (n= cJSON_GetArraySize(unspents)) > 0 ) + { + for (i=0; i= required ) + break; + } + } + } + return(vins); +} + +int32_t tx_has_voutaddress(char *refcoin,char *acname,bits256 txid,char *coinaddr) +{ + cJSON *txobj,*vouts,*vout,*vins,*vin,*sobj,*addresses; char *addr,str[65]; int32_t i,j,n,numarray,retval = 0, hasvout=0; + if ( (txobj= get_rawtransaction(refcoin,acname,txid)) != 0 ) + { + if ( (vouts= jarray(&numarray,txobj,"vout")) != 0 ) + { + for (i=0; i 0 ) + { + for (i=0; i 0 ) + { + for (j=0; j 0 && strcmp(vinaddr,cmpaddr) == 0 ) + return(0); + printf("mismatched vinaddr.(%s) vs %s\n",vinaddr,cmpaddr); + } + } + return(-1); +} + +int32_t txid_in_vins(char *refcoin,bits256 txid,bits256 cmptxid) +{ + cJSON *txjson,*vins,*vin; int32_t numvins,v,vinvout; bits256 vintxid; char str[65]; + if ( (txjson= get_rawtransaction(refcoin,"",txid)) != 0 ) + { + if ( (vins= jarray(&numvins,txjson,"vin")) != 0 ) + { + for (v=0; v n.%d retval.%d\n",tagA,tagB,pubkeystr,n,retval); + } + free_json(retjson); + } + return(retval); +} + +int32_t dpow_hasmessage(char *payload,char *tagA,char *tagB,char *pubkeystr) +{ + cJSON *retjson,*item,*array; char *retstr,*pstr; int32_t i,n,retval = 0; + if ( (retjson= get_komodocli((char *)"",&retstr,DEXP2P_CHAIN,"DEX_list","0","0",tagA,tagB,pubkeystr,"","")) != 0 ) + { + if ( (array= jarray(&n,retjson,"matches")) != 0 ) + { + for (i=0; i 0 ) + { + ptrs = calloc(n,sizeof(*ptrs)); + for (i=0; ishorthash = juint(item,"id"); + ptrs[m]->jsonstr = ptr; + strcpy(ptrs[m]->senderpub,senderpub); + m++; + } + } + } + *nump = m; + } + free_json(retjson); + } + return(ptrs); +} + + From 888efff4d1935266416288a50b1630a481966166 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Thu, 30 Apr 2020 07:06:47 -0400 Subject: [PATCH 015/255] Add subatomic to dapp makefile --- src/cc/dapps/Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cc/dapps/Makefile b/src/cc/dapps/Makefile index 6e7874788..1fea27084 100644 --- a/src/cc/dapps/Makefile +++ b/src/cc/dapps/Makefile @@ -1,6 +1,10 @@ +# Copyright 2020 The Hush Developers # just type make to compile all dapps all: zmigrate oraclefeed +subatomic: + $(CC) subatomic.c -o subatomic -lm + zmigrate: $(CC) zmigrate.c -o zmigrate -lm @@ -9,3 +13,4 @@ oraclefeed: clean: rm zmigrate oraclefeed + From 8a4e72fca2e0b41dc9f6875a40c2ceba048029eb Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 8 May 2020 08:57:34 -0400 Subject: [PATCH 016/255] Remove some sprout code from BuildWitnessCache --- src/wallet/wallet.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 53b3af6a6..546d9a547 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1288,10 +1288,6 @@ void CWallet::BuildWitnessCache(const CBlockIndex* pindex, bool witnessOnly) LogPrintf("Building Witnesses for block %i %.4f complete\n", pblockindex->GetHeight(), pblockindex->GetHeight() / double(height)); } - SproutMerkleTree sproutTree; - sproutRoot = pblockindex->pprev->hashFinalSproutRoot; - pcoinsTip->GetSproutAnchorAt(sproutRoot, sproutTree); - SaplingMerkleTree saplingTree; saplingRoot = pblockindex->pprev->hashFinalSaplingRoot; pcoinsTip->GetSaplingAnchorAt(saplingRoot, saplingTree); From dd5d932f8711c17e66fde407c1cdf2d0ae7aedf1 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 11 May 2020 06:34:48 -0400 Subject: [PATCH 017/255] Only print these when -zdebug is turned on --- src/wallet/rpcwallet.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 5afd0c4e8..37f67042b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4388,7 +4388,9 @@ UniValue z_viewtransaction(const UniValue& params, bool fHelp, const CPubKey& my // Fetch the note that is being spent auto res = pwalletMain->mapSaplingNullifiersToNotes.find(spend.nullifier); if (res == pwalletMain->mapSaplingNullifiersToNotes.end()) { - fprintf(stderr,"Could not find spending note %s", uint256_str(str, spend.nullifier)); + if(fZdebug) { + fprintf(stderr,"Could not find spending note %s\n", uint256_str(str, spend.nullifier)); + } continue; } auto op = res->second; @@ -4442,8 +4444,10 @@ UniValue z_viewtransaction(const UniValue& params, bool fHelp, const CPubKey& my pa = recovered->second; isOutgoing = true; } else { - // Unreadable - fprintf(stderr,"Could not recover Sapling note!"); + // Unreadable or unconfirmed? + if(fZdebug) { + fprintf(stderr,"Could not recover Sapling note!\n"); + } continue; } } From 095157d2d97de6da7de24ab168d36b383a6dbda3 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 11 May 2020 06:42:01 -0400 Subject: [PATCH 018/255] Remove sprout junk --- src/wallet/wallet.cpp | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 546d9a547..8d56fdfae 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1298,7 +1298,7 @@ void CWallet::BuildWitnessCache(const CBlockIndex* pindex, bool witnessOnly) for (std::pair& wtxItem : mapWallet) { - if (wtxItem.second.mapSproutNoteData.empty() && wtxItem.second.mapSaplingNoteData.empty()) + if (wtxItem.second.mapSaplingNoteData.empty()) continue; if (wtxItem.second.GetDepthInMainChain() > 0) { @@ -3062,38 +3062,11 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { continue; } - //Check for unspent inputs or spend less than N Blocks ago. (Sprout) - for (auto & pair : pwtx->mapSproutNoteData) { - SproutNoteData nd = pair.second; - if (!nd.nullifier || pwalletMain->GetSproutSpendDepth(*nd.nullifier) <= fDeleteTransactionsAfterNBlocks) { - LogPrint("deletetx","DeleteTx - Unspent sprout input tx %s\n", pwtx->GetHash().ToString()); - deleteTx = false; - continue; - } - } - if (!deleteTx) { txSaveCount++; continue; } - //Check for outputs that no longer have parents in the wallet. Exclude parents that are in the same transaction. (Sprout) - for (int i = 0; i < pwtx->vjoinsplit.size(); i++) { - const JSDescription& jsdesc = pwtx->vjoinsplit[i]; - for (const uint256 &nullifier : jsdesc.nullifiers) { - // JSOutPoint op = pwalletMain->mapSproutNullifiersToNotes[nullifier]; - if (pwalletMain->IsSproutNullifierFromMe(nullifier)) { - const uint256& parentHash = pwalletMain->mapSproutNullifiersToNotes[nullifier].hash; - const CWalletTx* parent = pwalletMain->GetWalletTx(parentHash); - if (parent != NULL && parentHash != wtxid) { - LogPrint("deletetx","DeleteTx - Parent of sprout tx %s found\n", pwtx->GetHash().ToString()); - deleteTx = false; - continue; - } - } - } - } - if (!deleteTx) { txSaveCount++; continue; From 2324e8ca4b5e6dbd34a51e9e415493742e285464 Mon Sep 17 00:00:00 2001 From: ssadler Date: Mon, 27 Apr 2020 16:10:30 -0300 Subject: [PATCH 019/255] fix fingerprint encoding --- src/cryptoconditions/src/cryptoconditions.c | 20 +++++++++++------- src/cryptoconditions/src/internal.h | 2 +- .../tests/test_failure_modes.py | 21 +++++++++++++++++++ 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/cryptoconditions/src/cryptoconditions.c b/src/cryptoconditions/src/cryptoconditions.c index 74949affc..f7acde1aa 100644 --- a/src/cryptoconditions/src/cryptoconditions.c +++ b/src/cryptoconditions/src/cryptoconditions.c @@ -117,14 +117,15 @@ uint32_t fromAsnSubtypes(const ConditionTypes_t types) { size_t cc_conditionBinary(const CC *cond, unsigned char *buf) { Condition_t *asn = calloc(1, sizeof(Condition_t)); - asnCondition(cond, asn); + bool r = asnCondition(cond, asn); + size_t out = 0; + if (!r) goto end; asn_enc_rval_t rc = der_encode_to_buffer(&asn_DEF_Condition, asn, buf, 1000); - if (rc.encoded == -1) { - fprintf(stderr, "CONDITION NOT ENCODED\n"); - return 0; - } + if (rc.encoded == -1) goto end; + out = rc.encoded; +end: ASN_STRUCT_FREE(asn_DEF_Condition, asn); - return rc.encoded; + return out; } @@ -140,17 +141,22 @@ size_t cc_fulfillmentBinary(const CC *cond, unsigned char *buf, size_t length) { } -void asnCondition(const CC *cond, Condition_t *asn) { +bool asnCondition(const CC *cond, Condition_t *asn) { asn->present = cc_isAnon(cond) ? cond->conditionType->asnType : cond->type->asnType; // This may look a little weird - we dont have a reference here to the correct // union choice for the condition type, so we just assign everything to the threshold // type. This works out nicely since the union choices have the same binary interface. + CompoundSha256Condition_t *choice = &asn->choice.thresholdSha256; choice->cost = cc_getCost(cond); choice->fingerprint.buf = cond->type->fingerprint(cond); + if (choice->fingerprint.buf == 0) { + return 0; + } choice->fingerprint.size = 32; choice->subtypes = asnSubtypes(cond->type->getSubtypes(cond)); + return 1; } diff --git a/src/cryptoconditions/src/internal.h b/src/cryptoconditions/src/internal.h index 790e28962..e2525cbe4 100644 --- a/src/cryptoconditions/src/internal.h +++ b/src/cryptoconditions/src/internal.h @@ -65,7 +65,7 @@ extern int CCTypeRegistryLength; */ uint32_t fromAsnSubtypes(ConditionTypes_t types); CC *mkAnon(const Condition_t *asnCond); -void asnCondition(const CC *cond, Condition_t *asn); +bool asnCondition(const CC *cond, Condition_t *asn); Condition_t *asnConditionNew(const CC *cond); Fulfillment_t *asnFulfillmentNew(const CC *cond); struct CC *fulfillmentToCC(Fulfillment_t *ffill); diff --git a/src/cryptoconditions/tests/test_failure_modes.py b/src/cryptoconditions/tests/test_failure_modes.py index 59b0b3f24..435e20c88 100644 --- a/src/cryptoconditions/tests/test_failure_modes.py +++ b/src/cryptoconditions/tests/test_failure_modes.py @@ -82,4 +82,25 @@ def test_malleability_checked(): assert not cc_rfb(b'\xa2\x13\xa0\x0f\xa0\x06\x80\x04abcd\xa0\x05\x80\x03abc\xa1\x00') +def test_large_threshold(): + conds = [{ + 'type': "secp256k1-sha-256", + "publicKey": "02D5D969305535AC29A77079C11D4F0DD40661CF96E04E974A5E8D7E374EE225AA" + }] + + for i in range(250): + conds.append({ + "type": "eval-sha-256", + "code": "VEVTVAE" + }) + + r = jsonRPC("encodeCondition", { + "type": "threshold-sha-256", + "subfulfillments": conds, + "threshold": 251 + }) + assert 'error' not in r, r + + + so.cc_conditionUri.restype = ctypes.c_char_p From eabcce62f7ddc89d4a6b322e89c8bf3e831e25e6 Mon Sep 17 00:00:00 2001 From: ssadler Date: Thu, 7 May 2020 22:32:59 -0300 Subject: [PATCH 020/255] return void where possible and pass references to indicate that a NULL result is impossible --- src/cryptoconditions/src/anon.c | 5 +---- src/cryptoconditions/src/cryptoconditions.c | 16 ++++++---------- src/cryptoconditions/src/ed25519.c | 5 ++--- src/cryptoconditions/src/eval.c | 9 +++------ .../src/include/secp256k1/src/ecmult_const.h | 2 +- src/cryptoconditions/src/internal.h | 6 +++--- src/cryptoconditions/src/prefix.c | 7 +++---- src/cryptoconditions/src/preimage.c | 7 ++----- src/cryptoconditions/src/secp256k1.c | 5 ++--- src/cryptoconditions/src/threshold.c | 6 ++---- src/cryptoconditions/src/utils.c | 6 ++---- 11 files changed, 27 insertions(+), 47 deletions(-) diff --git a/src/cryptoconditions/src/anon.c b/src/cryptoconditions/src/anon.c index 55d7a3b7f..6a4de4b0b 100644 --- a/src/cryptoconditions/src/anon.c +++ b/src/cryptoconditions/src/anon.c @@ -53,11 +53,8 @@ static void anonToJSON(const CC *cond, cJSON *params) { } -static unsigned char *anonFingerprint(const CC *cond) { - unsigned char *out = calloc(1, 32); - //fprintf(stderr,"anon fingerprint %p %p\n",out,cond->fingerprint); +static void anonFingerprint(const CC *cond, uint8_t *out) { memcpy(out, cond->fingerprint, 32); - return out; } diff --git a/src/cryptoconditions/src/cryptoconditions.c b/src/cryptoconditions/src/cryptoconditions.c index f7acde1aa..303b9aa41 100644 --- a/src/cryptoconditions/src/cryptoconditions.c +++ b/src/cryptoconditions/src/cryptoconditions.c @@ -65,8 +65,8 @@ void appendUriSubtypes(uint32_t mask, unsigned char *buf) { char *cc_conditionUri(const CC *cond) { - unsigned char *fp = cond->type->fingerprint(cond); - if (!fp) return NULL; + unsigned char *fp = calloc(1, 32); + cond->type->fingerprint(cond, fp); unsigned char *encoded = base64_encode(fp, 32); @@ -117,9 +117,8 @@ uint32_t fromAsnSubtypes(const ConditionTypes_t types) { size_t cc_conditionBinary(const CC *cond, unsigned char *buf) { Condition_t *asn = calloc(1, sizeof(Condition_t)); - bool r = asnCondition(cond, asn); + asnCondition(cond, asn); size_t out = 0; - if (!r) goto end; asn_enc_rval_t rc = der_encode_to_buffer(&asn_DEF_Condition, asn, buf, 1000); if (rc.encoded == -1) goto end; out = rc.encoded; @@ -141,7 +140,7 @@ size_t cc_fulfillmentBinary(const CC *cond, unsigned char *buf, size_t length) { } -bool asnCondition(const CC *cond, Condition_t *asn) { +void asnCondition(const CC *cond, Condition_t *asn) { asn->present = cc_isAnon(cond) ? cond->conditionType->asnType : cond->type->asnType; // This may look a little weird - we dont have a reference here to the correct @@ -150,13 +149,10 @@ bool asnCondition(const CC *cond, Condition_t *asn) { CompoundSha256Condition_t *choice = &asn->choice.thresholdSha256; choice->cost = cc_getCost(cond); - choice->fingerprint.buf = cond->type->fingerprint(cond); - if (choice->fingerprint.buf == 0) { - return 0; - } choice->fingerprint.size = 32; + choice->fingerprint.buf = calloc(1, 32); + cond->type->fingerprint(cond, choice->fingerprint.buf); choice->subtypes = asnSubtypes(cond->type->getSubtypes(cond)); - return 1; } diff --git a/src/cryptoconditions/src/ed25519.c b/src/cryptoconditions/src/ed25519.c index 8d73d3cf1..e4d090d1e 100644 --- a/src/cryptoconditions/src/ed25519.c +++ b/src/cryptoconditions/src/ed25519.c @@ -25,11 +25,10 @@ struct CCType CC_Ed25519Type; -static unsigned char *ed25519Fingerprint(const CC *cond) { +static void ed25519Fingerprint(const CC *cond, uint8_t *out) { Ed25519FingerprintContents_t *fp = calloc(1, sizeof(Ed25519FingerprintContents_t)); - //fprintf(stderr,"ed25519 fingerprint %p %p\n",fp,cond->publicKey); OCTET_STRING_fromBuf(&fp->publicKey, cond->publicKey, 32); - return hashFingerprintContents(&asn_DEF_Ed25519FingerprintContents, fp); + hashFingerprintContents(&asn_DEF_Ed25519FingerprintContents, fp, out); } diff --git a/src/cryptoconditions/src/eval.c b/src/cryptoconditions/src/eval.c index 99ff1ebf5..a18d51202 100644 --- a/src/cryptoconditions/src/eval.c +++ b/src/cryptoconditions/src/eval.c @@ -25,11 +25,8 @@ struct CCType CC_EvalType; -static unsigned char *evalFingerprint(const CC *cond) { - unsigned char *hash = calloc(1, 32); - //fprintf(stderr,"evalfingerprint %p %p\n",hash,cond->code); - sha256(cond->code, cond->codeLength, hash); - return hash; +static void evalFingerprint(const CC *cond, uint8_t *out) { + sha256(cond->code, cond->codeLength, out); } @@ -105,7 +102,7 @@ static uint32_t evalSubtypes(const CC *cond) { */ int jsonVerifyEval(CC *cond, void *context) { if (cond->codeLength == 5 && 0 == memcmp(cond->code, "TEST", 4)) { - return cond->code[5]; + return cond->code[4]; } fprintf(stderr, "Cannot verify eval; user function unknown\n"); return 0; diff --git a/src/cryptoconditions/src/include/secp256k1/src/ecmult_const.h b/src/cryptoconditions/src/include/secp256k1/src/ecmult_const.h index bdb9ae43a..5a36ba40b 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/ecmult_const.h +++ b/src/cryptoconditions/src/include/secp256k1/src/ecmult_const.h @@ -36,4 +36,4 @@ static void secp256k1_ecmult_const(secp256k1_gej *r, const secp256k1_ge *a, cons #endif - +#endif diff --git a/src/cryptoconditions/src/internal.h b/src/cryptoconditions/src/internal.h index e2525cbe4..7cfcaa225 100644 --- a/src/cryptoconditions/src/internal.h +++ b/src/cryptoconditions/src/internal.h @@ -41,7 +41,7 @@ typedef struct CCType { char name[100]; Condition_PR asnType; int (*visitChildren)(CC *cond, CCVisitor visitor); - unsigned char *(*fingerprint)(const CC *cond); + void (*fingerprint)(const CC *cond, uint8_t *fp); unsigned long (*getCost)(const CC *cond); uint32_t (*getSubtypes)(const CC *cond); CC *(*fromJSON)(const cJSON *params, char *err); @@ -65,7 +65,7 @@ extern int CCTypeRegistryLength; */ uint32_t fromAsnSubtypes(ConditionTypes_t types); CC *mkAnon(const Condition_t *asnCond); -bool asnCondition(const CC *cond, Condition_t *asn); +void asnCondition(const CC *cond, Condition_t *asn); Condition_t *asnConditionNew(const CC *cond); Fulfillment_t *asnFulfillmentNew(const CC *cond); struct CC *fulfillmentToCC(Fulfillment_t *ffill); @@ -77,7 +77,7 @@ struct CCType *getTypeByAsnEnum(Condition_PR present); */ unsigned char *base64_encode(const unsigned char *data, size_t input_length); unsigned char *base64_decode(const unsigned char *data_, size_t *output_length); -unsigned char *hashFingerprintContents(asn_TYPE_descriptor_t *asnType, void *fp); +void hashFingerprintContents(asn_TYPE_descriptor_t *asnType, void *fp, uint8_t* out); void dumpStr(unsigned char *str, size_t len); int checkString(const cJSON *value, char *key, char *err); int checkDecodeBase64(const cJSON *value, char *key, char *err, unsigned char **data, size_t *size); diff --git a/src/cryptoconditions/src/prefix.c b/src/cryptoconditions/src/prefix.c index 45c6d8033..67dc6f644 100644 --- a/src/cryptoconditions/src/prefix.c +++ b/src/cryptoconditions/src/prefix.c @@ -37,13 +37,12 @@ static int prefixVisitChildren(CC *cond, CCVisitor visitor) { } -static unsigned char *prefixFingerprint(const CC *cond) { +static void prefixFingerprint(const CC *cond, uint8_t *out) { PrefixFingerprintContents_t *fp = calloc(1, sizeof(PrefixFingerprintContents_t)); - //fprintf(stderr,"prefixfinger %p %p\n",fp,cond->prefix); - asnCondition(cond->subcondition, &fp->subcondition); // TODO: check asnCondition for safety + asnCondition(cond->subcondition, &fp->subcondition); fp->maxMessageLength = cond->maxMessageLength; OCTET_STRING_fromBuf(&fp->prefix, cond->prefix, cond->prefixLength); - return hashFingerprintContents(&asn_DEF_PrefixFingerprintContents, fp); + hashFingerprintContents(&asn_DEF_PrefixFingerprintContents, fp, out); } diff --git a/src/cryptoconditions/src/preimage.c b/src/cryptoconditions/src/preimage.c index 9e7fe12f4..a45e621d4 100644 --- a/src/cryptoconditions/src/preimage.c +++ b/src/cryptoconditions/src/preimage.c @@ -44,11 +44,8 @@ static unsigned long preimageCost(const CC *cond) { } -static unsigned char *preimageFingerprint(const CC *cond) { - unsigned char *hash = calloc(1, 32); - //fprintf(stderr,"preimage %p %p\n",hash,cond->preimage); - sha256(cond->preimage, cond->preimageLength, hash); - return hash; +static void preimageFingerprint(const CC *cond, uint8_t *out) { + sha256(cond->preimage, cond->preimageLength, out); } diff --git a/src/cryptoconditions/src/secp256k1.c b/src/cryptoconditions/src/secp256k1.c index a16115bb8..44ff1f0e2 100644 --- a/src/cryptoconditions/src/secp256k1.c +++ b/src/cryptoconditions/src/secp256k1.c @@ -88,11 +88,10 @@ void initVerify() { } -static unsigned char *secp256k1Fingerprint(const CC *cond) { +static void secp256k1Fingerprint(const CC *cond, uint8_t *out) { Secp256k1FingerprintContents_t *fp = calloc(1, sizeof(Secp256k1FingerprintContents_t)); - //fprintf(stderr,"secpfinger %p %p size %d vs %d\n",fp,cond->publicKey,(int32_t)sizeof(Secp256k1FingerprintContents_t),(int32_t)SECP256K1_PK_SIZE); OCTET_STRING_fromBuf(&fp->publicKey, cond->publicKey, SECP256K1_PK_SIZE); - return hashFingerprintContents(&asn_DEF_Secp256k1FingerprintContents, fp); + hashFingerprintContents(&asn_DEF_Secp256k1FingerprintContents, fp, out); } diff --git a/src/cryptoconditions/src/threshold.c b/src/cryptoconditions/src/threshold.c index 9547f4f8c..e94666c3d 100644 --- a/src/cryptoconditions/src/threshold.c +++ b/src/cryptoconditions/src/threshold.c @@ -94,17 +94,15 @@ static int cmpConditionBin(const void *a, const void *b) { } -static unsigned char *thresholdFingerprint(const CC *cond) { - /* Create fingerprint */ +static void thresholdFingerprint(const CC *cond, uint8_t *out) { ThresholdFingerprintContents_t *fp = calloc(1, sizeof(ThresholdFingerprintContents_t)); - //fprintf(stderr,"thresholdfinger %p\n",fp); fp->threshold = cond->threshold; for (int i=0; isize; i++) { Condition_t *asnCond = asnConditionNew(cond->subconditions[i]); asn_set_add(&fp->subconditions2, asnCond); } qsort(fp->subconditions2.list.array, cond->size, sizeof(Condition_t*), cmpConditionBin); - return hashFingerprintContents(&asn_DEF_ThresholdFingerprintContents, fp); + hashFingerprintContents(&asn_DEF_ThresholdFingerprintContents, fp, out); } diff --git a/src/cryptoconditions/src/utils.c b/src/cryptoconditions/src/utils.c index 6a2167119..ebb2bd143 100644 --- a/src/cryptoconditions/src/utils.c +++ b/src/cryptoconditions/src/utils.c @@ -210,7 +210,7 @@ void jsonAddBase64(cJSON *params, char *key, unsigned char *bin, size_t size) { } -unsigned char *hashFingerprintContents(asn_TYPE_descriptor_t *asnType, void *fp) { +void hashFingerprintContents(asn_TYPE_descriptor_t *asnType, void *fp, uint8_t *out) { unsigned char buf[BUF_SIZE]; asn_enc_rval_t rc = der_encode_to_buffer(asnType, fp, buf, BUF_SIZE); ASN_STRUCT_FREE(*asnType, fp); @@ -218,9 +218,7 @@ unsigned char *hashFingerprintContents(asn_TYPE_descriptor_t *asnType, void *fp) fprintf(stderr, "Encoding fingerprint failed\n"); return 0; } - unsigned char *hash = calloc(1,32); - sha256(buf, rc.encoded, hash); - return hash; + sha256(buf, rc.encoded, out); } From f3a4f773687ee6e29eff4801e9880f6c4282827d Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Tue, 19 May 2020 10:03:53 +0200 Subject: [PATCH 021/255] port expired transaction notify from Zcash. Issue #110 --- src/init.cpp | 11 +++++++++++ src/main.cpp | 6 +++++- src/txmempool.cpp | 5 ++++- src/txmempool.h | 2 +- src/ui_interface.h | 3 +++ 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index ac15db192..fd0303786 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -399,6 +399,7 @@ std::string HelpMessage(HelpMessageMode mode) #ifndef _WIN32 strUsage += HelpMessageOpt("-pid=", strprintf(_("Specify pid file (default: %s)"), "komodod.pid")); #endif + strUsage += HelpMessageOpt("-txexpirynotify=", _("Execute command when transaction expires (%s in cmd is replaced by transaction id)")); strUsage += HelpMessageOpt("-prune=", strprintf(_("Reduce storage requirements by pruning (deleting) old blocks. This mode disables wallet support and is incompatible with -txindex. " "Warning: Reverting this setting requires re-downloading the entire blockchain. " "(default: 0 = disable pruning blocks, >%u = target size in MiB to use for block files)"), MIN_DISK_SPACE_FOR_BLOCK_FILES / 1024 / 1024)); @@ -618,6 +619,14 @@ static void BlockNotifyCallback(const uint256& hashNewTip) boost::thread t(runCommand, strCmd); // thread runs free } +static void TxExpiryNotifyCallback(const uint256& txid) +{ + std::string strCmd = GetArg("-txexpirynotify", ""); + + boost::replace_all(strCmd, "%s", txid.GetHex()); + boost::thread t(runCommand, strCmd); // thread runs free +} + struct CImportingNow { CImportingNow() { @@ -2114,6 +2123,8 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (mapArgs.count("-blocknotify")) uiInterface.NotifyBlockTip.connect(BlockNotifyCallback); + if (mapArgs.count("-txexpirynotify")) + uiInterface.NotifyTxExpiration.connect(TxExpiryNotifyCallback); if ( KOMODO_REWIND >= 0 ) { uiInterface.InitMessage(_("Activating best chain...")); diff --git a/src/main.cpp b/src/main.cpp index 17b89a76b..3426facd7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4210,7 +4210,11 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock * mempool.removeForBlock(pblock->vtx, pindexNew->GetHeight(), txConflicted, !IsInitialBlockDownload()); // Remove transactions that expire at new block height from mempool - mempool.removeExpired(pindexNew->GetHeight()); + auto ids = mempool.removeExpired(pindexNew->GetHeight()); + + for (auto id : ids) { + uiInterface.NotifyTxExpiration(id); + } // Update chainActive & related variables. UpdateTip(pindexNew); diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 8a99a99e6..307be723e 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -513,7 +513,7 @@ void CTxMemPool::removeConflicts(const CTransaction &tx, std::list int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_t nTime,int32_t dispflag); extern char ASSETCHAINS_SYMBOL[]; -void CTxMemPool::removeExpired(unsigned int nBlockHeight) +std::vector CTxMemPool::removeExpired(unsigned int nBlockHeight) { CBlockIndex *tipindex; // Remove expired txs from the mempool @@ -528,11 +528,14 @@ void CTxMemPool::removeExpired(unsigned int nBlockHeight) transactionsToRemove.push_back(tx); } } + std::vector ids; for (const CTransaction& tx : transactionsToRemove) { list removed; remove(tx, removed, true); + ids.push_back(tx.GetHash()); LogPrint("mempool", "Removing expired txid: %s\n", tx.GetHash().ToString()); } + return ids; } /** diff --git a/src/txmempool.h b/src/txmempool.h index f8aa0e9a7..59eeb0d98 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -218,7 +218,7 @@ public: void removeWithAnchor(const uint256 &invalidRoot, ShieldedType type); void removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags); void removeConflicts(const CTransaction &tx, std::list& removed); - void removeExpired(unsigned int nBlockHeight); + std::vector removeExpired(unsigned int nBlockHeight); void removeForBlock(const std::vector& vtx, unsigned int nBlockHeight, std::list& conflicts, bool fCurrentEstimate = true); void removeWithoutBranchId(uint32_t nMemPoolBranchId); diff --git a/src/ui_interface.h b/src/ui_interface.h index ee0fd9113..59a549a9d 100644 --- a/src/ui_interface.h +++ b/src/ui_interface.h @@ -98,6 +98,9 @@ public: /** New block has been accepted */ boost::signals2::signal NotifyBlockTip; + + /** Transaction expired */ + boost::signals2::signal NotifyTxExpiration; }; extern CClientUIInterface uiInterface; From 6e4be99c21fb0c14d0475321a11cf136b6b32d1a Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Tue, 19 May 2020 10:20:28 +0200 Subject: [PATCH 022/255] Add dpow season 4 pubkeys Issue #109 --- src/komodo_defs.h | 71 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 2 deletions(-) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 34b1cc364..fa22a49ba 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -47,7 +47,7 @@ // 7113400 = 5x current KMD blockheight. // to add 4th season, change NUM_KMD_SEASONS to 4, and add timestamp and height of activation to these arrays. -#define NUM_KMD_SEASONS 4 +#define NUM_KMD_SEASONS 5 #define NUM_KMD_NOTARIES 64 // $ ./contrib/block_time.pl 166250 @@ -329,7 +329,74 @@ static const char *notaries_elected[NUM_KMD_SEASONS][NUM_KMD_NOTARIES][2] = {"gt_AR", "0307c1cf89bd8ed4db1b09a0a98cf5f746fc77df3803ecc8611cf9455ec0ce6960" }, {"patchkez_SH", "03d7c187689bf829ca076a30bbf36d2e67bb74e16a3290d8a55df21d6cb15c80c1" }, {"decker_AR", "02a85540db8d41c7e60bf0d33d1364b4151cad883dd032878ea4c037f67b769635" } - } + }, + { + // Season 4 + { "alien_AR", "03911a60395801082194b6834244fa78a3c30ff3e888667498e157b4aa80b0a65f" }, + { "alien_EU", "03bb749e337b9074465fa28e757b5aa92cb1f0fea1a39589bca91a602834d443cd" }, + { "strob_NA", "02a1c0bd40b294f06d3e44a52d1b2746c260c475c725e9351f1312e49e01c9a405" }, + { "titomane_SH", "020014ad4eedf6b1aeb0ad3b101a58d0a2fc570719e46530fd98d4e585f63eb4ae" }, + { "fullmoon_AR", "03b251095e747f759505ec745a4bbff9a768b8dce1f65137300b7c21efec01a07a" }, + { "phba2061_EU", "03a9492d2a1601d0d98cfe94d8adf9689d1bb0e600088127a4f6ca937761fb1c66" }, + { "fullmoon_NA", "03931c1d654a99658998ce0ddae108d825943a821d1cddd85e948ac1d483f68fb6" }, + { "fullmoon_SH", "03c2a1ed9ddb7bb8344328946017b9d8d1357b898957dd6aaa8c190ae26740b9ff" }, + { "madmax_AR", "022be5a2829fa0291f9a51ff7aeceef702eef581f2611887c195e29da49092e6de" }, + { "titomane_EU", "0285cf1fdba761daf6f1f611c32d319cd58214972ef822793008b69dde239443dd" }, + { "cipi_NA", "022c6825a24792cc3b010b1531521eba9b5e2662d640ed700fd96167df37e75239" }, + { "indenodes_SH", "0334e6e1ec8285c4b85bd6dae67e17d67d1f20e7328efad17ce6fd24ae97cdd65e" }, + { "decker_AR", "03ffdf1a116300a78729608d9930742cd349f11a9d64fcc336b8f18592dd9c91bc" }, + { "indenodes_EU", "0221387ff95c44cb52b86552e3ec118a3c311ca65b75bf807c6c07eaeb1be8303c" }, + { "madmax_NA", "02997b7ab21b86bbea558ae79acc35d62c9cedf441578f78112f986d72e8eece08" }, + { "chainzilla_SH", "02288ba6dc57936b59d60345e397d62f5d7e7d975f34ed5c2f2e23288325661563" }, + { "peer2cloud_AR", "0250e7e43a3535731b051d1bcc7dc88fbb5163c3fe41c5dee72bd973bcc4dca9f2" }, + { "pirate_EU", "0231c0f50a06655c3d2edf8d7e722d290195d49c78d50de7786b9d196e8820c848" }, + { "webworker01_NA", "02dfd5f3cef1142879a7250752feb91ddd722c497fb98c7377c0fcc5ccc201bd55" }, + { "zatjum_SH", "036066fd638b10e555597623e97e032b28b4d1fa5a13c2b0c80c420dbddad236c2" }, + { "titomane_AR", "0268203a4c80047edcd66385c22e764ea5fb8bc42edae389a438156e7dca9a8251" }, + { "chmex_EU", "025b7209ba37df8d9695a23ea706ea2594863ab09055ca6bf485855937f3321d1d" }, + { "indenodes_NA", "02698c6f1c9e43b66e82dbb163e8df0e5a2f62f3a7a882ca387d82f86e0b3fa988" }, + { "patchkez_SH", "02cabd6c5fc0b5476c7a01e9d7b907e9f0a051d7f4f731959955d3f6b18ee9a242" }, + { "metaphilibert_AR", "02adad675fae12b25fdd0f57250b0caf7f795c43f346153a31fe3e72e7db1d6ac6" }, + { "etszombi_EU", "0341adbf238f33a33cc895633db996c3ad01275313ac6641e046a3db0b27f1c880" }, + { "pirate_NA", "02207f27a13625a0b8caef6a7bb9de613ff16e4a5f232da8d7c235c7c5bad72ffe" }, + { "metaphilibert_SH", "0284af1a5ef01503e6316a2ca4abf8423a794e9fc17ac6846f042b6f4adedc3309" }, + { "indenodes_AR", "02ec0fa5a40f47fd4a38ea5c89e375ad0b6ddf4807c99733c9c3dc15fb978ee147" }, + { "chainmakers_NA", "029415a1609c33dfe4a1016877ba35f9265d25d737649f307048efe96e76512877" }, + { "mihailo_EU", "037f9563f30c609b19fd435a19b8bde7d6db703012ba1aba72e9f42a87366d1941" }, + { "tonyl_AR", "0299684d7291abf90975fa493bf53212cf1456c374aa36f83cc94daece89350ae9" }, + { "alien_NA", "03bea1ac333b95c8669ec091907ea8713cae26f74b9e886e13593400e21c4d30a8" }, + { "pungocloud_SH", "025b97d8c23effaca6fa7efacce20bf54df73081b63004a0fe22f3f98fece5669f" }, + { "node9_EU", "029ffa793b5c3248f8ea3da47fa3cf1810dada5af032ecd0e37bab5b92dd63b34e" }, + { "smdmitry_AR", "022a2a45979a6631a25e4c96469423de720a2f4c849548957c35a35c91041ee7ac" }, + { "nodeone_NA", "03f9dd0484e81174fd50775cb9099691c7d140ff00c0f088847e38dc87da67eb9b" }, + { "gcharang_SH", "02ec4172eab854a0d8cd32bc691c83e93975a3df5a4a453a866736c56e025dc359" }, + { "cipi_EU", "02f2b6defff1c544202f66e47cfd6909c54d67c7c39b9c2a99f137dbaf6d0bd8fa" }, + { "etszombi_AR", "0329944b0ac65b6760787ede042a2fde0be9fca1d80dd756bc0ee0b98d389b7682" }, + { "pbca26_NA", "0387e0fb6f2ca951154c87e16c6cbf93a69862bb165c1a96bcd8722b3af24fe533" }, + { "mylo_SH", "03b58f57822e90fe105e6efb63fd8666033ea503d6cc165b1e479bbd8c2ba033e8" }, + { "swisscertifiers_EU", "03ebcc71b42d88994b8b2134bcde6cb269bd7e71a9dd7616371d9294ec1c1902c5" }, + { "marmarachain_AR", "035bbd81a098172592fe97f50a0ce13cbbf80e55cc7862eccdbd7310fab8a90c4c" }, + { "karasugoi_NA", "0262cf2559703464151153c12e00c4b67a969e39b330301fdcaa6667d7eb02c57d" }, + { "phm87_SH", "021773a38db1bc3ede7f28142f901a161c7b7737875edbb40082a201c55dcf0add" }, + { "oszy_EU", "03d1ffd680491b98a3ec5541715681d1a45293c8efb1722c32392a1d792622596a" }, + { "chmex_AR", "036c856ea778ea105b93c0be187004d4e51161eda32888aa307b8f72d490884005" }, + { "dragonhound_NA", "0227e5cad3731e381df157de189527aac8eb50d82a13ce2bd81153984ebc749515" }, + { "strob_SH", "025ceac4256cef83ca4b110f837a71d70a5a977ecfdf807335e00bc78b560d451a" }, + { "madmax_EU", "02ea0cf4d6d151d0528b07efa79cc7403d77cb9195e2e6c8374f5074b9a787e287" }, + { "dudezmobi_AR", "027ecd974ff2a27a37ee69956cd2e6bb31a608116206f3e31ef186823420182450" }, + { "daemonfox_NA", "022d6f4885f53cbd668ad7d03d4f8e830c233f74e3a918da1ed247edfc71820b3d" }, + { "nutellalicka_SH", "02f4b1e71bc865a79c05fe333952b97cb040d8925d13e83925e170188b3011269b" }, + { "starfleet_EU", "025c7275bd750936862b47793f1f0bb3cbed60fb75a48e7da016e557925fe375eb" }, + { "mrlynch_AR", "031987dc82b087cd53e23df5480e265a5928e9243e0e11849fa12359739d8b18a4" }, + { "greer_NA", "03e0995615d7d3cf1107effa6bdb1133e0876cf1768e923aa533a4e2ee675ec383" }, + { "mcrypt_SH", "025faab3cc2e83bf7dad6a9463cbff86c08800e937942126f258cf219bc2320043" }, + { "decker_EU", "03777777caebce56e17ca3aae4e16374335b156f1dd62ee3c7f8799c6b885f5560" }, + { "dappvader_SH", "02962e2e5af746632016bc7b24d444f7c90141a5f42ce54e361b302cf455d90e6a" }, + { "alright_DEV", "02b73a589d61691efa2ada15c006d27bc18493fea867ce6c14db3d3d28751f8ce3" }, + { "artemii235_DEV", "03bb616b12430bdd0483653de18733597a4fd416623c7065c0e21fe9d96460add1" }, + { "tonyl_DEV", "02d5f7fd6e25d34ab2f3318d60cdb89ff3a812ec5d0212c4c113bb12d12616cfdc" }, + { "decker_DEV", "028eea44a09674dda00d88ffd199a09c9b75ba9782382cc8f1e97c0fd565fe5707" } + } }; #define SETBIT(bits,bitoffset) (((uint8_t *)bits)[(bitoffset) >> 3] |= (1 << ((bitoffset) & 7))) From b879f536e98fb99f4347dcfea6892b611756b765 Mon Sep 17 00:00:00 2001 From: ca333 Date: Sat, 14 Mar 2020 23:18:16 +0100 Subject: [PATCH 023/255] debug.log spam prevention --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 3426facd7..20d4a0355 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1224,9 +1224,9 @@ bool ContextualCheckTransaction(int32_t slowflag,const CBlock *block, CBlockInde if (IsExpiredTx(tx, nHeight)) { // Don't increase banscore if the transaction only just expired int expiredDosLevel = IsExpiredTx(tx, nHeight - 1) ? (dosLevel > 10 ? dosLevel : 10) : 0; - string strHex = EncodeHexTx(tx); + //string strHex = EncodeHexTx(tx); //fprintf(stderr, "transaction exipred.%s\n",strHex.c_str()); - return state.DoS(expiredDosLevel, error("ContextualCheckTransaction(): transaction %s is expired, expiry block %i vs current block %i\n txhex.%s",tx.GetHash().ToString(),tx.nExpiryHeight,nHeight,strHex), REJECT_INVALID, "tx-overwinter-expired"); + return state.DoS(expiredDosLevel, error("ContextualCheckTransaction(): transaction %s is expired, expiry block %i vs current block %i\n",tx.GetHash().ToString(),tx.nExpiryHeight,nHeight), REJECT_INVALID, "tx-overwinter-expired"); } } From 3199c01328989ccca6641d7014dfbc80ba2ddd4e Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Sun, 26 Jan 2020 07:34:49 +0300 Subject: [PATCH 024/255] =?UTF-8?q?CVE-2018=E2=80=9320586=20fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - https://medium.com/@lukedashjr/cve-2018-20586-disclosure-ff3e1ab9a21f - https://github.com/bitcoin/bitcoin/pull/14618/files --- src/httpserver.cpp | 11 ++++++++--- src/utilstrencodings.cpp | 3 ++- src/utilstrencodings.h | 3 ++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/httpserver.cpp b/src/httpserver.cpp index e1d235665..603e1e6ae 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -11,6 +11,7 @@ #include "rpc/protocol.h" // For HTTP status codes #include "sync.h" #include "ui_interface.h" +#include "utilstrencodings.h" #include #include @@ -251,21 +252,25 @@ static void http_request_cb(struct evhttp_request* req, void* arg) { std::unique_ptr hreq(new HTTPRequest(req)); - LogPrint("http", "Received a %s request for %s from %s\n", - RequestMethodString(hreq->GetRequestMethod()), hreq->GetURI(), hreq->GetPeer().ToString()); - // Early address-based allow check if (!ClientAllowed(hreq->GetPeer())) { + LogPrint("http", "HTTP request from %s rejected: Client network is not allowed RPC access\n", + hreq->GetPeer().ToString()); hreq->WriteReply(HTTP_FORBIDDEN); return; } // Early reject unknown HTTP methods if (hreq->GetRequestMethod() == HTTPRequest::UNKNOWN) { + LogPrint("http", "HTTP request from %s rejected: Unknown HTTP request method\n", + hreq->GetPeer().ToString()); hreq->WriteReply(HTTP_BADMETHOD); return; } + LogPrint("http", "Received a %s request for %s from %s\n", + RequestMethodString(hreq->GetRequestMethod()), SanitizeString(hreq->GetURI(), SAFE_CHARS_URI).substr(0, 100), hreq->GetPeer().ToString()); + // Find registered handler for prefix std::string strURI = hreq->GetURI(); std::string path; diff --git a/src/utilstrencodings.cpp b/src/utilstrencodings.cpp index d4bba72ee..132ae82ab 100644 --- a/src/utilstrencodings.cpp +++ b/src/utilstrencodings.cpp @@ -20,7 +20,8 @@ static const string CHARS_ALPHA_NUM = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNO static const string SAFE_CHARS[] = { CHARS_ALPHA_NUM + " .,;_/:?@()", // SAFE_CHARS_DEFAULT - CHARS_ALPHA_NUM + " .,;_?@" // SAFE_CHARS_UA_COMMENT + CHARS_ALPHA_NUM + " .,;_?@", // SAFE_CHARS_UA_COMMENT + CHARS_ALPHA_NUM + "!*'();:@&=+$,/?#[]-_.~%" // SAFE_CHARS_URI }; string SanitizeString(const string& str, int rule) diff --git a/src/utilstrencodings.h b/src/utilstrencodings.h index 37a07ea06..2d851093f 100644 --- a/src/utilstrencodings.h +++ b/src/utilstrencodings.h @@ -26,7 +26,8 @@ enum SafeChars { SAFE_CHARS_DEFAULT, //!< The full set of allowed chars - SAFE_CHARS_UA_COMMENT //!< BIP-0014 subset + SAFE_CHARS_UA_COMMENT, //!< BIP-0014 subset + SAFE_CHARS_URI //!< Chars allowed in URIs (RFC 3986) }; std::string SanitizeFilename(const std::string& str); From bde1f3c632556fdfa4ac210fa0b7994a76c5a911 Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Mon, 27 Jan 2020 05:00:24 +0300 Subject: [PATCH 025/255] limit blockchain progress to a max of 1.000000 Issue: https://github.com/zcash/zcash/issues/3161 Fix commit: https://github.com/zcash/zcash/pull/4176/commits/b3594b52739c96105a3f6976924a9075b1c5bbe2 --- src/checkpoints.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index 7fd94e4e7..026475f88 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -74,7 +74,7 @@ namespace Checkpoints { fWorkAfter = nExpensiveAfter*fSigcheckVerificationFactor; } - return fWorkBefore / (fWorkBefore + fWorkAfter); + return std::min(fWorkBefore / (fWorkBefore + fWorkAfter), 1.0); } int GetTotalBlocksEstimate(const CChainParams::CCheckpointData& data) From c7d96194d6edb348febaea95b829032a504168b8 Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Thu, 19 Mar 2020 01:55:56 +0300 Subject: [PATCH 026/255] [test] proper removing of txes that violates interest validation from mempool In CreateNewBlock of miner https://github.com/KomodoPlatform/komodo/blob/master/src/miner.cpp#L331 we have a condition that prevents miners to include certain txes in block if tx violates komodo_validate_interest check. so, if such txes will exist in mempool and in some reason they was not miner earlier, if they have nExpiryHeight = 0 - they NEVER will be included in block by miners. Also, code in CTxMemPool::removeExpired that should remove such txes from mempool didn't do it due to mistake. As a result these txes stucks in mempool. No one can mine it, bcz no one can include it in block, and no one get success to remove it from mempool. Look on old code: ``` (ASSETCHAINS_SYMBOL[0] == 0 && tipindex != 0 && komodo_validate_interest(...) ) < 0 ``` But should be: ``` (ASSETCHAINS_SYMBOL[0] == 0 && tipindex != 0 && komodo_validate_interest(...) < 0 ) ``` Bcz we should compare with 0 result of komodo_validate_interest, but we had different behaviour, due to typo. --- src/txmempool.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 307be723e..ca0ed7f51 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -523,8 +523,12 @@ std::vector CTxMemPool::removeExpired(unsigned int nBlockHeight) { const CTransaction& tx = it->GetTx(); tipindex = chainActive.LastTip(); - if (IsExpiredTx(tx, nBlockHeight) || (ASSETCHAINS_SYMBOL[0] == 0 && tipindex != 0 && komodo_validate_interest(tx,tipindex->GetHeight()+1,tipindex->GetMedianTimePast() + 777,0)) < 0) + + bool fInterestNotValidated = ASSETCHAINS_SYMBOL[0] == 0 && tipindex != 0 && komodo_validate_interest(tx,tipindex->GetHeight()+1,tipindex->GetMedianTimePast() + 777,0) < 0; + if (IsExpiredTx(tx, nBlockHeight) || fInterestNotValidated) { + if (fInterestNotValidated && tipindex != 0) + LogPrintf("Removing interest violate txid.%s nHeight.%d nTime.%u vs locktime.%u\n",tx.GetHash().ToString(),tipindex->GetHeight()+1,tipindex->GetMedianTimePast() + 777,tx.nLockTime); transactionsToRemove.push_back(tx); } } From 2c60f2ffaeec2a9a8e1960de672bad4f2d965b53 Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Tue, 25 Feb 2020 17:56:17 +0300 Subject: [PATCH 027/255] disable assertion when -debug arg is passed --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 8d3c5d4c4..a91fa9527 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -340,7 +340,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 if (!mempool.mapTx.count(txin.prevout.hash)) { LogPrintf("ERROR: mempool transaction missing input\n"); - if (fDebug) assert("mempool transaction missing input" == 0); + // if (fDebug) assert("mempool transaction missing input" == 0); fMissingInputs = true; if (porphan) vOrphan.pop_back(); From c0834c3cb7bca48b2b9f701c2e2000aa3f2ed919 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 29 May 2020 01:55:00 -0400 Subject: [PATCH 028/255] S4 dpow notaries --- src/komodo_defs.h | 130 +++++++++++++++++++++++----------------------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index fa22a49ba..6d867b229 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -331,71 +331,71 @@ static const char *notaries_elected[NUM_KMD_SEASONS][NUM_KMD_NOTARIES][2] = {"decker_AR", "02a85540db8d41c7e60bf0d33d1364b4151cad883dd032878ea4c037f67b769635" } }, { - // Season 4 - { "alien_AR", "03911a60395801082194b6834244fa78a3c30ff3e888667498e157b4aa80b0a65f" }, - { "alien_EU", "03bb749e337b9074465fa28e757b5aa92cb1f0fea1a39589bca91a602834d443cd" }, - { "strob_NA", "02a1c0bd40b294f06d3e44a52d1b2746c260c475c725e9351f1312e49e01c9a405" }, - { "titomane_SH", "020014ad4eedf6b1aeb0ad3b101a58d0a2fc570719e46530fd98d4e585f63eb4ae" }, - { "fullmoon_AR", "03b251095e747f759505ec745a4bbff9a768b8dce1f65137300b7c21efec01a07a" }, - { "phba2061_EU", "03a9492d2a1601d0d98cfe94d8adf9689d1bb0e600088127a4f6ca937761fb1c66" }, - { "fullmoon_NA", "03931c1d654a99658998ce0ddae108d825943a821d1cddd85e948ac1d483f68fb6" }, - { "fullmoon_SH", "03c2a1ed9ddb7bb8344328946017b9d8d1357b898957dd6aaa8c190ae26740b9ff" }, - { "madmax_AR", "022be5a2829fa0291f9a51ff7aeceef702eef581f2611887c195e29da49092e6de" }, - { "titomane_EU", "0285cf1fdba761daf6f1f611c32d319cd58214972ef822793008b69dde239443dd" }, - { "cipi_NA", "022c6825a24792cc3b010b1531521eba9b5e2662d640ed700fd96167df37e75239" }, - { "indenodes_SH", "0334e6e1ec8285c4b85bd6dae67e17d67d1f20e7328efad17ce6fd24ae97cdd65e" }, - { "decker_AR", "03ffdf1a116300a78729608d9930742cd349f11a9d64fcc336b8f18592dd9c91bc" }, - { "indenodes_EU", "0221387ff95c44cb52b86552e3ec118a3c311ca65b75bf807c6c07eaeb1be8303c" }, - { "madmax_NA", "02997b7ab21b86bbea558ae79acc35d62c9cedf441578f78112f986d72e8eece08" }, - { "chainzilla_SH", "02288ba6dc57936b59d60345e397d62f5d7e7d975f34ed5c2f2e23288325661563" }, - { "peer2cloud_AR", "0250e7e43a3535731b051d1bcc7dc88fbb5163c3fe41c5dee72bd973bcc4dca9f2" }, - { "pirate_EU", "0231c0f50a06655c3d2edf8d7e722d290195d49c78d50de7786b9d196e8820c848" }, - { "webworker01_NA", "02dfd5f3cef1142879a7250752feb91ddd722c497fb98c7377c0fcc5ccc201bd55" }, - { "zatjum_SH", "036066fd638b10e555597623e97e032b28b4d1fa5a13c2b0c80c420dbddad236c2" }, - { "titomane_AR", "0268203a4c80047edcd66385c22e764ea5fb8bc42edae389a438156e7dca9a8251" }, - { "chmex_EU", "025b7209ba37df8d9695a23ea706ea2594863ab09055ca6bf485855937f3321d1d" }, - { "indenodes_NA", "02698c6f1c9e43b66e82dbb163e8df0e5a2f62f3a7a882ca387d82f86e0b3fa988" }, - { "patchkez_SH", "02cabd6c5fc0b5476c7a01e9d7b907e9f0a051d7f4f731959955d3f6b18ee9a242" }, - { "metaphilibert_AR", "02adad675fae12b25fdd0f57250b0caf7f795c43f346153a31fe3e72e7db1d6ac6" }, - { "etszombi_EU", "0341adbf238f33a33cc895633db996c3ad01275313ac6641e046a3db0b27f1c880" }, - { "pirate_NA", "02207f27a13625a0b8caef6a7bb9de613ff16e4a5f232da8d7c235c7c5bad72ffe" }, - { "metaphilibert_SH", "0284af1a5ef01503e6316a2ca4abf8423a794e9fc17ac6846f042b6f4adedc3309" }, - { "indenodes_AR", "02ec0fa5a40f47fd4a38ea5c89e375ad0b6ddf4807c99733c9c3dc15fb978ee147" }, - { "chainmakers_NA", "029415a1609c33dfe4a1016877ba35f9265d25d737649f307048efe96e76512877" }, - { "mihailo_EU", "037f9563f30c609b19fd435a19b8bde7d6db703012ba1aba72e9f42a87366d1941" }, - { "tonyl_AR", "0299684d7291abf90975fa493bf53212cf1456c374aa36f83cc94daece89350ae9" }, - { "alien_NA", "03bea1ac333b95c8669ec091907ea8713cae26f74b9e886e13593400e21c4d30a8" }, - { "pungocloud_SH", "025b97d8c23effaca6fa7efacce20bf54df73081b63004a0fe22f3f98fece5669f" }, - { "node9_EU", "029ffa793b5c3248f8ea3da47fa3cf1810dada5af032ecd0e37bab5b92dd63b34e" }, - { "smdmitry_AR", "022a2a45979a6631a25e4c96469423de720a2f4c849548957c35a35c91041ee7ac" }, - { "nodeone_NA", "03f9dd0484e81174fd50775cb9099691c7d140ff00c0f088847e38dc87da67eb9b" }, - { "gcharang_SH", "02ec4172eab854a0d8cd32bc691c83e93975a3df5a4a453a866736c56e025dc359" }, - { "cipi_EU", "02f2b6defff1c544202f66e47cfd6909c54d67c7c39b9c2a99f137dbaf6d0bd8fa" }, - { "etszombi_AR", "0329944b0ac65b6760787ede042a2fde0be9fca1d80dd756bc0ee0b98d389b7682" }, - { "pbca26_NA", "0387e0fb6f2ca951154c87e16c6cbf93a69862bb165c1a96bcd8722b3af24fe533" }, - { "mylo_SH", "03b58f57822e90fe105e6efb63fd8666033ea503d6cc165b1e479bbd8c2ba033e8" }, - { "swisscertifiers_EU", "03ebcc71b42d88994b8b2134bcde6cb269bd7e71a9dd7616371d9294ec1c1902c5" }, - { "marmarachain_AR", "035bbd81a098172592fe97f50a0ce13cbbf80e55cc7862eccdbd7310fab8a90c4c" }, - { "karasugoi_NA", "0262cf2559703464151153c12e00c4b67a969e39b330301fdcaa6667d7eb02c57d" }, - { "phm87_SH", "021773a38db1bc3ede7f28142f901a161c7b7737875edbb40082a201c55dcf0add" }, - { "oszy_EU", "03d1ffd680491b98a3ec5541715681d1a45293c8efb1722c32392a1d792622596a" }, - { "chmex_AR", "036c856ea778ea105b93c0be187004d4e51161eda32888aa307b8f72d490884005" }, - { "dragonhound_NA", "0227e5cad3731e381df157de189527aac8eb50d82a13ce2bd81153984ebc749515" }, - { "strob_SH", "025ceac4256cef83ca4b110f837a71d70a5a977ecfdf807335e00bc78b560d451a" }, - { "madmax_EU", "02ea0cf4d6d151d0528b07efa79cc7403d77cb9195e2e6c8374f5074b9a787e287" }, - { "dudezmobi_AR", "027ecd974ff2a27a37ee69956cd2e6bb31a608116206f3e31ef186823420182450" }, - { "daemonfox_NA", "022d6f4885f53cbd668ad7d03d4f8e830c233f74e3a918da1ed247edfc71820b3d" }, - { "nutellalicka_SH", "02f4b1e71bc865a79c05fe333952b97cb040d8925d13e83925e170188b3011269b" }, - { "starfleet_EU", "025c7275bd750936862b47793f1f0bb3cbed60fb75a48e7da016e557925fe375eb" }, - { "mrlynch_AR", "031987dc82b087cd53e23df5480e265a5928e9243e0e11849fa12359739d8b18a4" }, - { "greer_NA", "03e0995615d7d3cf1107effa6bdb1133e0876cf1768e923aa533a4e2ee675ec383" }, - { "mcrypt_SH", "025faab3cc2e83bf7dad6a9463cbff86c08800e937942126f258cf219bc2320043" }, - { "decker_EU", "03777777caebce56e17ca3aae4e16374335b156f1dd62ee3c7f8799c6b885f5560" }, - { "dappvader_SH", "02962e2e5af746632016bc7b24d444f7c90141a5f42ce54e361b302cf455d90e6a" }, - { "alright_DEV", "02b73a589d61691efa2ada15c006d27bc18493fea867ce6c14db3d3d28751f8ce3" }, - { "artemii235_DEV", "03bb616b12430bdd0483653de18733597a4fd416623c7065c0e21fe9d96460add1" }, - { "tonyl_DEV", "02d5f7fd6e25d34ab2f3318d60cdb89ff3a812ec5d0212c4c113bb12d12616cfdc" }, - { "decker_DEV", "028eea44a09674dda00d88ffd199a09c9b75ba9782382cc8f1e97c0fd565fe5707" } + // Season 4 https://github.com/KomodoPlatform/dPoW/blob/s4/iguana/3rd_party + {"alien_AR", "024f20c096b085308e21893383f44b4faf1cdedea9ad53cc7d7e7fbfa0c30c1e71" }, + {"alien_EU", "022b85908191788f409506ebcf96a892f3274f352864c3ed566c5a16de63953236" }, + {"alien_NA", "022f62b56ddfd07c9860921c701285ac39bb3ac8f6f083d1b59c8f4943be3de162" }, + {"alright_DEV", "03b6f9493658bdd102503585a08ae642b49d6a68fb69ac3626f9737cd7581abdfa" }, + {"artemii235_DEV", "037a20916d2e9ea575300ac9d729507c23a606b9a200c8e913d7c9832f912a1fa7" }, + {"chainmakers_NA", "028803e07bcc521fde264b7191a944f9b3612e8ee4e24a99bcd903f6976240839a" }, + {"chainzilla_SH", "0311dde03c2dd654ce78323b718ed3ad73a464d1bde97820f3395f54788b5420dd" }, + {"chmex_AR", "030cd487e10fbf142e0e8d582e702ecb775f378569c3cb5acd0ff97b6b12803588" }, + {"chmex_EU", "030bf7bd7ad0515c33b5d5d9a91e0729baf801b9002f80495ae535ea1cebb352cb" }, + {"cipi_EU", "026f4f66385daaf8313ef30ffe4988e7db497132682dca185a70763d93e1417d9d" }, + {"cipi_NA", "03f4e69edcb4fa3b2095cb8cb1ca010f4ec4972eac5d8822397e5c8d87aa21a739" }, + {"daemonfox_NA", "023c7584b1006d4a62a4b4c9c1ede390a3789316547897d5ed49ff9385a3acb411" }, + {"dappvader_SH", "025199bc04bcb8a17976d9fe8bc87763a6150c2727321aa59bf34a2b49f2f3a0ce" }, + {"decker_AR", "02a85540db8d41c7e60bf0d33d1364b4151cad883dd032878ea4c037f67b769635" }, + {"decker_DEV", "02fca8ee50e49f480de275745618db7b0b3680b0bdcce7dcae7d2e0fd5c3345744" }, + {"decker_EU", "027777775b89ff548c3be54fb0c9455437d87f38bfce83bdef113899881b219c9e" }, + {"dragonhound_NA", "029912212d370ee0fb4d38eefd8bfcd8ab04e2c3b0354020789c29ddf2a35c72d6" }, + {"dudezmobi_AR", "033c121d3f8d450174674a73f3b7f140b2717a7d51ea19ee597e2e8e8f9d5ed87f" }, + {"etszombi_AR", "03bfcbca83f11e622fa4eed9a1fa25dba377981ea3b22e3d0a4015f9a932af9272" }, + {"etszombi_EU", "03a5c083c78ba397970f20b544a01c13e7ed36ca8a5ae26d5fe7bd38b92b6a0c94" }, + {"fullmoon_AR", "03639bc56d3fecf856f17759a441c5893668e7c2d460f3d216798a413cd6766bb2" }, + {"fullmoon_NA", "03e388bcc579ac2675f8fadfa921eec186dcea8d2b43de1eed6caba23d5a962b74" }, + {"fullmoon_SH", "03a5cfda2b097c808834ccdd805828c811b519611feabdfe6b3644312e53f6748f" }, + {"gcharang_SH", "02a654037d12cdd609f4fad48e15ec54538e03f61fdae1acb855f16ebacac6bd73" }, + {"greer_NA", "0262da6aaa0b295b8e2f120035924758a4a630f899316dc63ee15ef03e9b7b2b23" }, + {"indenodes_AR", "0242778789986d614f75bcf629081651b851a12ab1cc10c73995b27b90febb75a2" }, + {"indenodes_EU", "03a416533cace0814455a1bb1cd7861ce825a543c6f6284a432c4c8d8875b7ace9" }, + {"indenodes_NA", "02b3908eda4078f0e9b6704451cdc24d418e899c0f515fab338d7494da6f0a647b" }, + {"indenodes_SH", "031d1584cf0eb4a2d314465e49e2677226b1615c3718013b8d6b4854c15676a58c" }, + {"karasugoi_NA", "02f803e6f159824a181cc5d709f3d1e7ff65f19e1899920724aeb4e3d2d869f911" }, + {"madmax_AR", "027afddbcf690230dd8d435ec16a7bfb0083e6b77030f763437f291dfc40a579d0" }, + {"madmax_EU", "0397ec3a4ad84b3009566d260c89f1c4404e86e5d044964747c9371277e38f5995" }, + {"madmax_NA", "036d3afebe1eab09f4c38c3ee6a4659ad390f3df92787c11437a58c59a29e408e6" }, + {"marmarachain_AR", "028690ca1e3afdf8a38b421f6a41f5ff407afc96d5a7a6a488330aae26c8b086bb" }, + {"mcrypt_SH", "027a4ca7b11d3456ff558c08bb04483a89c7f383448461fd0b6b3b07424aabe9a4" }, + {"metaphilibert_AR", "0239e34ad22957bbf4c8df824401f237b2afe8d40f7a645ecd43e8f27dde1ab0da" }, + {"metaphilibert_SH", "03b21ff042bf1730b28bde43f44c064578b41996117ac7634b567c3773089e3be3" }, + {"mihailo_EU", "036494e7c9467c8c7ff3bf29e841907fb0fa24241866569944ea422479ec0e6252" }, + {"mrlynch_AR", "03e67440141f53a08684c329ebc852b018e41f905da88e52aa4a6dc5aa4b12447a" }, + {"mylo_SH", "026d5f29d09ff3f33e14db4811606249b2438c6bcf964876714f81d1f2d952acde" }, + {"node9_EU", "0392e4c9400e69f28c6b9e89d586da69d5a6af7702f1045eaa6ebc1996f0496e1f" }, + {"nodeone_NA", "0310a249c6c2dcc29f2135715138a9ddb8e01c0eab701cbd0b96d9cec660dbdc58" }, + {"nutellalicka_SH", "0284c4d3cb97dd8a32d10fb32b1855ae18cf845dad542e3b8937ca0e998fb54ecc" }, + {"oszy_EU", "03c53bd421de4a29ce68c8cc83f802e1181e77c08f8f16684490d61452ea8d023a" }, + {"patchkez_SH", "028c08db6e7242681f50db6c234fe3d6e12fb1a915350311be26373bac0d457d49" }, + {"pbca26_NA", "03c18431bb6bc95672f640f19998a196becd2851d5dcba4795fe8d85b7d77eab81" }, + {"peer2cloud_AR", "0243958faf9ae4d43b598b859ddc595c170c4cf50f8e4517d660ae5bc72aeb821b" }, + {"phba2061_EU", "03369187ce134bd7793ee34af7756fe1ab27202e09306491cdd5d8ad2c71697937" }, + {"phm87_SH", "03889a10f9df2caef57220628515693cf25316fe1b0693b0241419e75d0d0e66ed" }, + {"pirate_EU", "0240011b95cde819f298fe0f507b2260c9fecdab784924076d4d1e54c522103cb1" }, + {"pirate_NA", "02ad7ef25d2dd461e361120cd3efe7cbce5e9512c361e9185aac33dd303d758613" }, + {"pungocloud_SH", "02641c36ae6747b88150a463a1fe65cf7a9d1c00a64387c73f296f0b64e77c7d3f" }, + {"smdmitry_AR", "0397b7584cb29717b721c0c587d4462477efc1f36a56921f133c9d17b0cd7f278a" }, + {"starfleet_EU", "03c6e047218f34644ccba67e317b9da5d28e68bbbb6b9973aef1281d2bafa46496" }, + {"strob_NA", "02285bf2f9e96068ecac14bc6f770e394927b4da9f5ba833eaa9468b5d47f203a3" }, + {"strob_SH", "0213751a1c59d3489ca85b3d62a3d606dcef7f0428aa021c1978ea16fb38a2fad6" }, + {"swisscertifiers_EU", "02e7722ebba9f8b5ebfb4e87d4fa58cc75aef677535b9cfc060c7d9471aacd9c9e" }, + {"titomane_AR", "03958bd8d13fe6946b8d0d0fbbc3861c72542560d0276e80a4c6b5fe55bc758b81" }, + {"titomane_EU", "02276090e483db1a01a802456b10831b3b6e0a6ad3ece9b2a01f4aad0e480c8edc" }, + {"titomane_SH", "02abf206bafc8048dbdc042b8eb6b1e356ea5dbe149eae3532b4811d4905e5cf01" }, + {"tonyl_AR", "0229e499e3f2e065ced402ceb8aaf3d5ab8bd3793aa074305e9fa30772ce604908" }, + {"tonyl_DEV", "0258b77d7dcfc6c2628b0b6b438951a6e74201fb2cd180a795e4c37fcf8e78a678" }, + {"webworker01_NA", "02de90c720c007229374772505a43917a84ed129d5fbcfa4949cc2e9b563351124" }, + {"zatjum_SH", "0241c5660ca540780be66603b1791127a1261d56abbcb7562c297eec8e4fc078fb" } } }; From ff0ce2b69a16bf2fa7c39bf2bafec0a2199c53d6 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 29 May 2020 02:08:21 -0400 Subject: [PATCH 029/255] Fix warning --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 20d4a0355..c75f51a28 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1327,7 +1327,7 @@ bool ContextualCheckTransaction(int32_t slowflag,const CBlock *block, CBlockInde )) { librustzcash_sapling_verification_ctx_free(ctx); - fprintf(stderr,"%s: Invalid sapling binding sig! tx=%s valueBalance=%li, bindingSig.size=%d\n", __func__, tx.GetHash().ToString().c_str(), tx.valueBalance, tx.bindingSig.size() ); + fprintf(stderr,"%s: Invalid sapling binding sig! tx=%s valueBalance=%li, bindingSig.size=%li\n", __func__, tx.GetHash().ToString().c_str(), tx.valueBalance, tx.bindingSig.size() ); return state.DoS(100, error("ContextualCheckTransaction(): Sapling binding signature invalid"), REJECT_INVALID, "bad-txns-sapling-binding-signature-invalid"); } From 9c5a4e682e67b08153a998072a8f20d69fd60f3f Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 29 May 2020 23:10:05 -0400 Subject: [PATCH 030/255] desprout --- src/wallet/wallet.cpp | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 8d56fdfae..4422cde7b 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2105,27 +2105,6 @@ void CWallet::GetSproutNoteWitnesses(std::vector notes, std::vector>& witnesses, uint256 &final_anchor) { - LOCK(cs_wallet); - witnesses.resize(notes.size()); - boost::optional rt; - int i = 0; - for (JSOutPoint note : notes) { - if (mapWallet.count(note.hash) && - mapWallet[note.hash].mapSproutNoteData.count(note) && - mapWallet[note.hash].mapSproutNoteData[note].witnesses.size() > 0) { - witnesses[i] = mapWallet[note.hash].mapSproutNoteData[note].witnesses.front(); - if (!rt) { - rt = witnesses[i]->root(); - } else { - assert(*rt == witnesses[i]->root()); - } - } - i++; - } - // All returned witnesses have the same anchor - if (rt) { - final_anchor = *rt; - } } void CWallet::GetSaplingNoteWitnesses(std::vector notes, From e35b7e21b3cf64acbd671edd8d2ca7e12cdd5952 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 29 May 2020 23:13:15 -0400 Subject: [PATCH 031/255] Less typing is nice --- build.sh | 5 +++++ 1 file changed, 5 insertions(+) create mode 100755 build.sh diff --git a/build.sh b/build.sh new file mode 100755 index 000000000..2ae8514c3 --- /dev/null +++ b/build.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Copyright (c) 2019-2020 The Hush developers + +set -eu -o pipefail +./zcutil/build.sh $@ From 1010c7e8e453032710519d741d578bbace3586d7 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 29 May 2020 23:32:41 -0400 Subject: [PATCH 032/255] Throw a logic error instead of asserting when we see weird witness shenanigans --- src/wallet/wallet.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 4422cde7b..3145bbd88 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2123,7 +2123,12 @@ void CWallet::GetSaplingNoteWitnesses(std::vector notes, if (!rt) { rt = witnesses[i]->root(); } else { - assert(*rt == witnesses[i]->root()); + if(*rt == witnesses[i]->root()) { + // Something is fucky + std::string err = "CWallet::GetSaplingNoteWitnesses: Invalid witness root:" << rt.GetHash(); + throw std::logic_error(err); + } + } } i++; From d265f782e77e8e262dc668372a32d4f79af9ef45 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 29 May 2020 23:35:11 -0400 Subject: [PATCH 033/255] desprout --- src/wallet/wallet.cpp | 39 +-------------------------------------- 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 3145bbd88..558f2020a 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -234,25 +234,7 @@ bool CWallet::AddSaplingIncomingViewingKey( // Add spending key to keystore and persist to disk bool CWallet::AddSproutZKey(const libzcash::SproutSpendingKey &key) { - AssertLockHeld(cs_wallet); // mapSproutZKeyMetadata - auto addr = key.address(); - - if (!CCryptoKeyStore::AddSproutSpendingKey(key)) - return false; - - // check if we need to remove from viewing keys - if (HaveSproutViewingKey(addr)) - RemoveSproutViewingKey(key.viewing_key()); - - if (!fFileBacked) - return true; - - if (!IsCrypted()) { - return CWalletDB(strWalletFile).WriteZKey(addr, - key, - mapSproutZKeyMetadata[addr]); - } - return true; + return false; } CPubKey CWallet::GenerateNewKey() @@ -2344,13 +2326,6 @@ bool CWallet::IsFromMe(const CTransaction& tx) const if (GetDebit(tx, ISMINE_ALL) > 0) { return true; } - for (const JSDescription& jsdesc : tx.vjoinsplit) { - for (const uint256& nullifier : jsdesc.nullifiers) { - if (IsSproutNullifierFromMe(nullifier)) { - return true; - } - } - } for (const SpendDescription &spend : tx.vShieldedSpend) { if (IsSaplingNullifierFromMe(spend.nullifier)) { return true; @@ -2488,18 +2463,6 @@ bool CWallet::LoadCryptedHDSeed(const uint256& seedFp, const std::vector nd : noteData) { - if (nd.first.js < vjoinsplit.size() && - nd.first.n < vjoinsplit[nd.first.js].ciphertexts.size()) { - // Store the address and nullifier for the Note - mapSproutNoteData[nd.first] = nd.second; - } else { - // If FindMySproutNotes() was used to obtain noteData, - // this should never happen - throw std::logic_error("CWalletTx::SetSproutNoteData(): Invalid note"); - } - } } void CWalletTx::SetSaplingNoteData(mapSaplingNoteData_t ¬eData) From ab0576a72e80c3ba2f9c0411ec69ca98d30504ee Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 29 May 2020 23:47:28 -0400 Subject: [PATCH 034/255] desprout --- src/wallet/wallet.cpp | 76 +------------------------------------------ src/wallet/wallet.h | 11 ------- 2 files changed, 1 insertion(+), 86 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 558f2020a..a455cc2fe 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -117,22 +117,7 @@ const CWalletTx* CWallet::GetWalletTx(const uint256& hash) const // Generate a new spending key and return its public payment address libzcash::SproutPaymentAddress CWallet::GenerateNewSproutZKey() { - AssertLockHeld(cs_wallet); // mapSproutZKeyMetadata - - auto k = SproutSpendingKey::random(); - auto addr = k.address(); - - // Check for collision, even though it is unlikely to ever occur - if (CCryptoKeyStore::HaveSproutSpendingKey(addr)) - throw std::runtime_error("CWallet::GenerateNewSproutZKey(): Collision detected"); - - // Create new metadata - int64_t nCreationTime = GetTime(); - mapSproutZKeyMetadata[addr] = CKeyMetadata(nCreationTime); - - if (!AddSproutZKey(k)) - throw std::runtime_error("CWallet::GenerateNewSproutZKey(): AddSproutZKey failed"); - return addr; + throw std::runtime_error("unsupported"); } // Generate a new Sapling spending key and return its public payment address @@ -313,24 +298,6 @@ bool CWallet::AddCryptedSproutSpendingKey( const libzcash::ReceivingKey &rk, const std::vector &vchCryptedSecret) { - if (!CCryptoKeyStore::AddCryptedSproutSpendingKey(address, rk, vchCryptedSecret)) - return false; - if (!fFileBacked) - return true; - { - LOCK(cs_wallet); - if (pwalletdbEncryption) { - return pwalletdbEncryption->WriteCryptedZKey(address, - rk, - vchCryptedSecret, - mapSproutZKeyMetadata[address]); - } else { - return CWalletDB(strWalletFile).WriteCryptedZKey(address, - rk, - vchCryptedSecret, - mapSproutZKeyMetadata[address]); - } - } return false; } @@ -415,47 +382,6 @@ bool CWallet::LoadZKey(const libzcash::SproutSpendingKey &key) return CCryptoKeyStore::AddSproutSpendingKey(key); } -bool CWallet::AddSproutViewingKey(const libzcash::SproutViewingKey &vk) -{ - if (!CCryptoKeyStore::AddSproutViewingKey(vk)) { - return false; - } - nTimeFirstKey = 1; // No birthday information for viewing keys. - if (!fFileBacked) { - return true; - } - return CWalletDB(strWalletFile).WriteSproutViewingKey(vk); -} - -bool CWallet::RemoveSproutViewingKey(const libzcash::SproutViewingKey &vk) -{ - AssertLockHeld(cs_wallet); - if (!CCryptoKeyStore::RemoveSproutViewingKey(vk)) { - return false; - } - if (fFileBacked) { - if (!CWalletDB(strWalletFile).EraseSproutViewingKey(vk)) { - return false; - } - } - - return true; -} - -bool CWallet::LoadSproutViewingKey(const libzcash::SproutViewingKey &vk) -{ - return CCryptoKeyStore::AddSproutViewingKey(vk); -} - -bool CWallet::AddCScript(const CScript& redeemScript) -{ - if (!CCryptoKeyStore::AddCScript(redeemScript)) - return false; - if (!fFileBacked) - return true; - return CWalletDB(strWalletFile).WriteCScript(Hash160(redeemScript), redeemScript); -} - bool CWallet::LoadCScript(const CScript& redeemScript) { /* A sanity check was added in pull #3843 to avoid adding redeemScripts diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 205a49008..1c46f3f98 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1111,17 +1111,6 @@ public: bool LoadZKeyMetadata(const libzcash::SproutPaymentAddress &addr, const CKeyMetadata &meta); //! Adds an encrypted spending key to the store, without saving it to disk (used by LoadWallet) bool LoadCryptedZKey(const libzcash::SproutPaymentAddress &addr, const libzcash::ReceivingKey &rk, const std::vector &vchCryptedSecret); - //! Adds an encrypted spending key to the store, and saves it to disk (virtual method, declared in crypter.h) - bool AddCryptedSproutSpendingKey( - const libzcash::SproutPaymentAddress &address, - const libzcash::ReceivingKey &rk, - const std::vector &vchCryptedSecret); - - //! Adds a Sprout viewing key to the store, and saves it to disk. - bool AddSproutViewingKey(const libzcash::SproutViewingKey &vk); - bool RemoveSproutViewingKey(const libzcash::SproutViewingKey &vk); - //! Adds a Sprout viewing key to the store, without saving it to disk (used by LoadWallet) - bool LoadSproutViewingKey(const libzcash::SproutViewingKey &dest); /** * Sapling ZKeys From eec2dd51fba8ee8db30055fc55786df9fc3829f2 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 30 May 2020 00:44:20 -0400 Subject: [PATCH 035/255] wallet desprout --- src/wallet/wallet.cpp | 291 +----------------------------------------- src/wallet/wallet.h | 37 ------ 2 files changed, 4 insertions(+), 324 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index a455cc2fe..d0d82a0e8 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -114,11 +114,6 @@ const CWalletTx* CWallet::GetWalletTx(const uint256& hash) const return &(it->second); } -// Generate a new spending key and return its public payment address -libzcash::SproutPaymentAddress CWallet::GenerateNewSproutZKey() -{ - throw std::runtime_error("unsupported"); -} // Generate a new Sapling spending key and return its public payment address SaplingPaymentAddress CWallet::GenerateNewSaplingZKey() @@ -216,12 +211,6 @@ bool CWallet::AddSaplingIncomingViewingKey( } -// Add spending key to keystore and persist to disk -bool CWallet::AddSproutZKey(const libzcash::SproutSpendingKey &key) -{ - return false; -} - CPubKey CWallet::GenerateNewKey() { AssertLockHeld(cs_wallet); // mapKeyMetadata @@ -292,15 +281,6 @@ bool CWallet::AddCryptedKey(const CPubKey &vchPubKey, return false; } - -bool CWallet::AddCryptedSproutSpendingKey( - const libzcash::SproutPaymentAddress &address, - const libzcash::ReceivingKey &rk, - const std::vector &vchCryptedSecret) -{ - return false; -} - bool CWallet::AddCryptedSaplingSpendingKey(const libzcash::SaplingExtendedFullViewingKey &extfvk, const std::vector &vchCryptedSecret, const libzcash::SaplingPaymentAddress &defaultAddr) @@ -589,29 +569,6 @@ std::set> CWallet::GetNullifiersFor return nullifierSet; } -bool CWallet::IsNoteSproutChange( - const std::set> & nullifierSet, - const PaymentAddress & address, - const JSOutPoint & jsop) -{ - // A Note is marked as "change" if the address that received it - // also spent Notes in the same transaction. This will catch, - // for instance: - // - Change created by spending fractions of Notes (because - // z_sendmany sends change to the originating z-address). - // - "Chaining Notes" used to connect JoinSplits together. - // - Notes created by consolidation transactions (e.g. using - // z_mergetoaddress). - // - Notes sent from one address to itself. - for (const JSDescription & jsd : mapWallet[jsop.hash].vjoinsplit) { - for (const uint256 & nullifier : jsd.nullifiers) { - if (nullifierSet.count(std::make_pair(address, nullifier))) { - return true; - } - } - } - return false; -} bool CWallet::IsNoteSaplingChange(const std::set> & nullifierSet, const libzcash::PaymentAddress & address, @@ -849,38 +806,6 @@ unsigned int CWallet::GetSpendDepth(const uint256& hash, unsigned int n) const return 0; } -/** - * Note is spent if any non-conflicted transaction - * spends it: - */ -bool CWallet::IsSproutSpent(const uint256& nullifier) const { - pair range; - range = mapTxSproutNullifiers.equal_range(nullifier); - - for (TxNullifiers::const_iterator it = range.first; it != range.second; ++it) { - const uint256& wtxid = it->second; - std::map::const_iterator mit = mapWallet.find(wtxid); - if (mit != mapWallet.end() && mit->second.GetDepthInMainChain() >= 0) { - return true; // Spent - } - } - return false; -} - -unsigned int CWallet::GetSproutSpendDepth(const uint256& nullifier) const { - pair range; - range = mapTxSproutNullifiers.equal_range(nullifier); - - for (TxNullifiers::const_iterator it = range.first; it != range.second; ++it) { - const uint256& wtxid = it->second; - std::map::const_iterator mit = mapWallet.find(wtxid); - if (mit != mapWallet.end() && mit->second.GetDepthInMainChain() >= 0) { - return mit->second.GetDepthInMainChain(); // Spent - } - } - return 0; -} - bool CWallet::IsSaplingSpent(const uint256& nullifier) const { pair range; range = mapTxSaplingNullifiers.equal_range(nullifier); @@ -918,15 +843,6 @@ void CWallet::AddToTransparentSpends(const COutPoint& outpoint, const uint256& w SyncMetaData(range); } -void CWallet::AddToSproutSpends(const uint256& nullifier, const uint256& wtxid) -{ - mapTxSproutNullifiers.insert(make_pair(nullifier, wtxid)); - - pair range; - range = mapTxSproutNullifiers.equal_range(nullifier); - SyncMetaData(range); -} - void CWallet::AddToSaplingSpends(const uint256& nullifier, const uint256& wtxid) { mapTxSaplingNullifiers.insert(make_pair(nullifier, wtxid)); @@ -946,11 +862,6 @@ void CWallet::AddToSpends(const uint256& wtxid) for (const CTxIn& txin : thisTx.vin) { AddToTransparentSpends(txin.prevout, wtxid); } - for (const JSDescription& jsdesc : thisTx.vjoinsplit) { - for (const uint256& nullifier : jsdesc.nullifiers) { - AddToSproutSpends(nullifier, wtxid); - } - } for (const SpendDescription &spend : thisTx.vShieldedSpend) { AddToSaplingSpends(spend.nullifier, wtxid); } @@ -1006,21 +917,6 @@ void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex) extern int32_t KOMODO_REWIND; for (std::pair& wtxItem : mapWallet) { - //Sprout - for (auto& item : wtxItem.second.mapSproutNoteData) { - auto* nd = &(item.second); - if (nd->nullifier && pwalletMain->GetSproutSpendDepth(*item.second.nullifier) <= WITNESS_CACHE_SIZE) { - // Only decrement witnesses that are not above the current height - if (nd->witnessHeight <= pindex->GetHeight()) { - if (nd->witnesses.size() > 1) { - // indexHeight is the height of the block being removed, so - // the new witness cache height is one below it. - nd->witnesses.pop_front(); - nd->witnessHeight = pindex->GetHeight() - 1; - } - } - } - } //Sapling for (auto& item : wtxItem.second.mapSaplingNoteData) { auto* nd = &(item.second); @@ -1048,14 +944,6 @@ void ClearSingleNoteWitnessCache(NoteData* nd) nd->witnessRootValidated = false; } -int CWallet::SproutWitnessMinimumHeight(const uint256& nullifier, int nWitnessHeight, int nMinimumHeight) -{ - if (GetSproutSpendDepth(nullifier) <= WITNESS_CACHE_SIZE) { - nMinimumHeight = min(nWitnessHeight, nMinimumHeight); - } - return nMinimumHeight; -} - int CWallet::SaplingWitnessMinimumHeight(const uint256& nullifier, int nWitnessHeight, int nMinimumHeight) { if (GetSaplingSpendDepth(nullifier) <= WITNESS_CACHE_SIZE) { @@ -1396,22 +1284,6 @@ bool CWallet::UpdateNullifierNoteMap() ZCNoteDecryption dec; for (std::pair& wtxItem : mapWallet) { - for (mapSproutNoteData_t::value_type& item : wtxItem.second.mapSproutNoteData) { - if (!item.second.nullifier) { - if (GetNoteDecryptor(item.second.address, dec)) { - auto i = item.first.js; - auto hSig = wtxItem.second.vjoinsplit[i].h_sig( - *pzcashParams, wtxItem.second.joinSplitPubKey); - item.second.nullifier = GetSproutNoteNullifier( - wtxItem.second.vjoinsplit[i], - item.second.address, - dec, - hSig, - item.first.n); - } - } - } - // TODO: Sapling. This method is only called from RPC walletpassphrase, which is currently unsupported // as RPC encryptwallet is hidden behind two flags: -developerencryptwallet -experimentalfeatures @@ -1422,7 +1294,7 @@ bool CWallet::UpdateNullifierNoteMap() } /** - * Update mapSproutNullifiersToNotes and mapSaplingNullifiersToNotes + * Update mapSaplingNullifiersToNotes * with the cached nullifiers in this tx. */ void CWallet::UpdateNullifierNoteMapWithTx(const CWalletTx& wtx) @@ -1438,48 +1310,6 @@ void CWallet::UpdateNullifierNoteMapWithTx(const CWalletTx& wtx) } } -/** - * Update mapSproutNullifiersToNotes, computing the nullifier from a cached witness if necessary. - */ -void CWallet::UpdateSproutNullifierNoteMapWithTx(CWalletTx& wtx) { - LOCK(cs_wallet); - - ZCNoteDecryption dec; - for (mapSproutNoteData_t::value_type& item : wtx.mapSproutNoteData) { - SproutNoteData nd = item.second; - - if (nd.witnesses.empty()) { - // If there are no witnesses, erase the nullifier and associated mapping. - if (nd.nullifier) { - mapSproutNullifiersToNotes.erase(nd.nullifier.get()); - } - nd.nullifier = boost::none; - } - else { - if (GetNoteDecryptor(nd.address, dec)) { - auto i = item.first.js; - auto hSig = wtx.vjoinsplit[i].h_sig( - *pzcashParams, wtx.joinSplitPubKey); - auto optNullifier = GetSproutNoteNullifier( - wtx.vjoinsplit[i], - item.second.address, - dec, - hSig, - item.first.n); - - if (!optNullifier) { - // This should not happen. If it does, maybe the position has been corrupted or miscalculated? - assert(false); - } - - uint256 nullifier = optNullifier.get(); - mapSproutNullifiersToNotes[nullifier] = item.first; - item.second.nullifier = nullifier; - } - } - } -} - /** * Update mapSaplingNullifiersToNotes, computing the nullifier from a cached witness if necessary. */ @@ -1577,6 +1407,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletD int64_t latestEntry = 0; { // Tolerate times up to the last timestamp in the wallet not more than 5 minutes into the future + // TODO: this is 2 blocktimes, which will become 150? int64_t latestTolerated = latestNow + 300; std::list acentries; TxItems txOrdered = OrderedTxItems(acentries); @@ -1670,21 +1501,6 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletD bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) { - bool unchangedSproutFlag = (wtxIn.mapSproutNoteData.empty() || wtxIn.mapSproutNoteData == wtx.mapSproutNoteData); - if (!unchangedSproutFlag) { - auto tmp = wtxIn.mapSproutNoteData; - // Ensure we keep any cached witnesses we may already have - for (const std::pair nd : wtx.mapSproutNoteData) { - if (tmp.count(nd.first) && nd.second.witnesses.size() > 0) { - tmp.at(nd.first).witnesses.assign( - nd.second.witnesses.cbegin(), nd.second.witnesses.cend()); - } - tmp.at(nd.first).witnessHeight = nd.second.witnessHeight; - } - // Now copy over the updated note data - wtx.mapSproutNoteData = tmp; - } - bool unchangedSaplingFlag = (wtxIn.mapSaplingNoteData.empty() || wtxIn.mapSaplingNoteData == wtx.mapSaplingNoteData); if (!unchangedSaplingFlag) { auto tmp = wtxIn.mapSaplingNoteData; @@ -1702,7 +1518,7 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) wtx.mapSaplingNoteData = tmp; } - return !unchangedSproutFlag || !unchangedSaplingFlag; + return !unchangedSaplingFlag; } /** @@ -1719,7 +1535,6 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl return false; bool fExisted = mapWallet.count(tx.GetHash()) != 0; if (fExisted && !fUpdate) return false; - auto sproutNoteData = FindMySproutNotes(tx); auto saplingNoteDataAndAddressesToAdd = FindMySaplingNotes(tx); auto saplingNoteData = saplingNoteDataAndAddressesToAdd.first; auto addressesToAdd = saplingNoteDataAndAddressesToAdd.second; @@ -1743,7 +1558,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl fprintf(stderr, " %s\n", wladdr.c_str()); } } - if (fExisted || IsMine(tx) || IsFromMe(tx) || sproutNoteData.size() > 0 || saplingNoteData.size() > 0) + if (fExisted || IsMine(tx) || IsFromMe(tx) || saplingNoteData.size() > 0) { // wallet filter for notary nodes. Enables by setting -whitelistaddress= as startup param or in conf file (works same as -addnode byut with R-address's) if ( !tx.IsCoinBase() && !vWhiteListAddress.empty() && !NotaryAddress.empty() ) @@ -1775,10 +1590,6 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl CWalletTx wtx(this,tx); - if (sproutNoteData.size() > 0) { - wtx.SetSproutNoteData(sproutNoteData); - } - if (saplingNoteData.size() > 0) { wtx.SetSaplingNoteData(saplingNoteData); } @@ -1850,82 +1661,6 @@ void CWallet::RescanWallet() } -/** - * Returns a nullifier if the SpendingKey is available - * Throws std::runtime_error if the decryptor doesn't match this note - */ -boost::optional CWallet::GetSproutNoteNullifier(const JSDescription &jsdesc, - const libzcash::SproutPaymentAddress &address, - const ZCNoteDecryption &dec, - const uint256 &hSig, - uint8_t n) const -{ - boost::optional ret; - auto note_pt = libzcash::SproutNotePlaintext::decrypt( - dec, - jsdesc.ciphertexts[n], - jsdesc.ephemeralKey, - hSig, - (unsigned char) n); - auto note = note_pt.note(address); - // SpendingKeys are only available if: - // - We have them (this isn't a viewing key) - // - The wallet is unlocked - libzcash::SproutSpendingKey key; - if (GetSproutSpendingKey(address, key)) { - ret = note.nullifier(key); - } - return ret; -} - -/** - * Finds all output notes in the given transaction that have been sent to - * PaymentAddresses in this wallet. - * - * It should never be necessary to call this method with a CWalletTx, because - * the result of FindMySproutNotes (for the addresses available at the time) will - * already have been cached in CWalletTx.mapSproutNoteData. - */ -mapSproutNoteData_t CWallet::FindMySproutNotes(const CTransaction &tx) const -{ - LOCK(cs_SpendingKeyStore); - uint256 hash = tx.GetHash(); - - mapSproutNoteData_t noteData; - for (size_t i = 0; i < tx.vjoinsplit.size(); i++) { - auto hSig = tx.vjoinsplit[i].h_sig(*pzcashParams, tx.joinSplitPubKey); - for (uint8_t j = 0; j < tx.vjoinsplit[i].ciphertexts.size(); j++) { - for (const NoteDecryptorMap::value_type& item : mapNoteDecryptors) { - try { - auto address = item.first; - JSOutPoint jsoutpt {hash, i, j}; - auto nullifier = GetSproutNoteNullifier( - tx.vjoinsplit[i], - address, - item.second, - hSig, j); - if (nullifier) { - SproutNoteData nd {address, *nullifier}; - noteData.insert(std::make_pair(jsoutpt, nd)); - } else { - SproutNoteData nd {address}; - noteData.insert(std::make_pair(jsoutpt, nd)); - } - break; - } catch (const note_decryption_failed &err) { - // Couldn't decrypt with this decryptor - } catch (const std::exception &exc) { - // Unexpected failure - LogPrintf("FindMySproutNotes(): Unexpected error while testing decrypt:\n"); - LogPrintf("%s\n", exc.what()); - } - } - } - } - return noteData; -} - - /** * Finds all output notes in the given transaction that have been sent to * SaplingPaymentAddresses in this wallet. @@ -1985,18 +1720,6 @@ std::pair CWallet::FindMySap return std::make_pair(noteData, viewingKeysToAdd); } -bool CWallet::IsSproutNullifierFromMe(const uint256& nullifier) const -{ - { - LOCK(cs_wallet); - if (mapSproutNullifiersToNotes.count(nullifier) && - mapWallet.count(mapSproutNullifiersToNotes.at(nullifier).hash)) { - return true; - } - } - return false; -} - bool CWallet::IsSaplingNullifierFromMe(const uint256& nullifier) const { { @@ -2009,12 +1732,6 @@ bool CWallet::IsSaplingNullifierFromMe(const uint256& nullifier) const return false; } -void CWallet::GetSproutNoteWitnesses(std::vector notes, - std::vector>& witnesses, - uint256 &final_anchor) -{ -} - void CWallet::GetSaplingNoteWitnesses(std::vector notes, std::vector>& witnesses, uint256 &final_anchor) diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 1c46f3f98..d82e100ed 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -589,11 +589,8 @@ public: MarkDirty(); } - void SetSproutNoteData(mapSproutNoteData_t ¬eData); void SetSaplingNoteData(mapSaplingNoteData_t ¬eData); - std::pair DecryptSproutNote( - JSOutPoint jsop) const; boost::optional> DecryptSaplingNote(SaplingOutPoint op) const; @@ -801,14 +798,12 @@ private: * detect and report conflicts (double-spends). */ typedef TxSpendMap TxNullifiers; - TxNullifiers mapTxSproutNullifiers; TxNullifiers mapTxSaplingNullifiers; std::vector pendingSaplingConsolidationTxs; AsyncRPCOperationId saplingConsolidationOperationId; void AddToTransparentSpends(const COutPoint& outpoint, const uint256& wtxid); - void AddToSproutSpends(const uint256& nullifier, const uint256& wtxid); void AddToSaplingSpends(const uint256& nullifier, const uint256& wtxid); void AddToSpends(const uint256& wtxid); @@ -915,7 +910,6 @@ public: std::set setKeyPool; std::map mapKeyMetadata; - std::map mapSproutZKeyMetadata; std::map mapSaplingZKeyMetadata; typedef std::map MasterKeyMap; @@ -1033,8 +1027,6 @@ public: bool IsSpent(const uint256& hash, unsigned int n) const; unsigned int GetSpendDepth(const uint256& hash, unsigned int n) const; - bool IsSproutSpent(const uint256& nullifier) const; - unsigned int GetSproutSpendDepth(const uint256& nullifier) const; bool IsSaplingSpent(const uint256& nullifier) const; unsigned int GetSaplingSpendDepth(const uint256& nullifier) const; @@ -1047,8 +1039,6 @@ public: bool IsLockedNote(const JSOutPoint& outpt) const; void LockNote(const JSOutPoint& output); void UnlockNote(const JSOutPoint& output); - void UnlockAllSproutNotes(); - std::vector ListLockedSproutNotes(); bool IsLockedNote(const SaplingOutPoint& output) const; void LockNote(const SaplingOutPoint& output); @@ -1098,20 +1088,6 @@ public: void GetKeyBirthTimes(std::map &mapKeyBirth) const; - /** - * Sprout ZKeys - */ - //! Generates a new Sprout zaddr - libzcash::SproutPaymentAddress GenerateNewSproutZKey(); - //! Adds spending key to the store, and saves it to disk - bool AddSproutZKey(const libzcash::SproutSpendingKey &key); - //! Adds spending key to the store, without saving it to disk (used by LoadWallet) - bool LoadZKey(const libzcash::SproutSpendingKey &key); - //! Load spending key metadata (used by LoadWallet) - bool LoadZKeyMetadata(const libzcash::SproutPaymentAddress &addr, const CKeyMetadata &meta); - //! Adds an encrypted spending key to the store, without saving it to disk (used by LoadWallet) - bool LoadCryptedZKey(const libzcash::SproutPaymentAddress &addr, const libzcash::ReceivingKey &rk, const std::vector &vchCryptedSecret); - /** * Sapling ZKeys */ @@ -1160,7 +1136,6 @@ public: void MarkDirty(); bool UpdateNullifierNoteMap(); void UpdateNullifierNoteMapWithTx(const CWalletTx& wtx); - void UpdateSproutNullifierNoteMapWithTx(CWalletTx& wtx); void UpdateSaplingNullifierNoteMapWithTx(CWalletTx& wtx); void UpdateNullifierNoteMapForBlock(const CBlock* pblock); bool AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletDB* pwalletdb); @@ -1208,21 +1183,9 @@ public: std::set GetAccountAddresses(const std::string& strAccount) const; - boost::optional GetSproutNoteNullifier( - const JSDescription& jsdesc, - const libzcash::SproutPaymentAddress& address, - const ZCNoteDecryption& dec, - const uint256& hSig, - uint8_t n) const; - mapSproutNoteData_t FindMySproutNotes(const CTransaction& tx) const; std::pair FindMySaplingNotes(const CTransaction& tx) const; - bool IsSproutNullifierFromMe(const uint256& nullifier) const; bool IsSaplingNullifierFromMe(const uint256& nullifier) const; - void GetSproutNoteWitnesses( - std::vector notes, - std::vector>& witnesses, - uint256 &final_anchor); void GetSaplingNoteWitnesses( std::vector notes, std::vector>& witnesses, From c27264eb0ff0f4c29c828146f5dd3d704df256a8 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 1 Jun 2020 01:42:19 -0400 Subject: [PATCH 036/255] desprout --- .../asyncrpcoperation_mergetoaddress.cpp | 336 +----------------- src/zcbenchmarks.cpp | 177 --------- 2 files changed, 2 insertions(+), 511 deletions(-) diff --git a/src/wallet/asyncrpcoperation_mergetoaddress.cpp b/src/wallet/asyncrpcoperation_mergetoaddress.cpp index 2e77195f3..488e7f5b7 100644 --- a/src/wallet/asyncrpcoperation_mergetoaddress.cpp +++ b/src/wallet/asyncrpcoperation_mergetoaddress.cpp @@ -430,6 +430,8 @@ bool AsyncRPCOperation_mergetoaddress::main_impl() */ + UniValue obj(UniValue::VOBJ); + /** * SCENARIO #1 * @@ -438,7 +440,6 @@ bool AsyncRPCOperation_mergetoaddress::main_impl() * There are no zaddrs or joinsplits involved. */ if (isPureTaddrOnlyTx) { - UniValue obj(UniValue::VOBJ); obj.push_back(Pair("rawtxn", EncodeHexTx(tx_))); sign_send_raw_transaction(obj); return true; @@ -447,335 +448,6 @@ bool AsyncRPCOperation_mergetoaddress::main_impl() * END SCENARIO #1 */ - - // Prepare raw transaction to handle JoinSplits - CMutableTransaction mtx(tx_); - crypto_sign_keypair(joinSplitPubKey_.begin(), joinSplitPrivKey_); - mtx.joinSplitPubKey = joinSplitPubKey_; - tx_ = CTransaction(mtx); - std::string hexMemo = std::get<1>(recipient_); - - - /** - * SCENARIO #2 - * - * taddrs -> zaddr - * - * We only need a single JoinSplit. - */ - if (sproutNoteInputs_.empty() && isToZaddr_) { - // Create JoinSplit to target z-addr. - MergeToAddressJSInfo info; - info.vpub_old = sendAmount; - info.vpub_new = 0; - - JSOutput jso = JSOutput(boost::get(toPaymentAddress_), sendAmount); - if (hexMemo.size() > 0) { - jso.memo = get_memo_from_hex_string(hexMemo); - } - info.vjsout.push_back(jso); - - UniValue obj(UniValue::VOBJ); - obj = perform_joinsplit(info); - sign_send_raw_transaction(obj); - return true; - } - /** - * END SCENARIO #2 - */ - - - // Copy zinputs to more flexible containers - std::deque zInputsDeque; - for (const auto& o : sproutNoteInputs_) { - zInputsDeque.push_back(o); - } - - // When spending notes, take a snapshot of note witnesses and anchors as the treestate will - // change upon arrival of new blocks which contain joinsplit transactions. This is likely - // to happen as creating a chained joinsplit transaction can take longer than the block interval. - { - LOCK2(cs_main, pwalletMain->cs_wallet); - for (auto t : sproutNoteInputs_) { - JSOutPoint jso = std::get<0>(t); - std::vector vOutPoints = {jso}; - uint256 inputAnchor; - std::vector> vInputWitnesses; - pwalletMain->GetSproutNoteWitnesses(vOutPoints, vInputWitnesses, inputAnchor); - jsopWitnessAnchorMap[jso.ToString()] = MergeToAddressWitnessAnchorData{vInputWitnesses[0], inputAnchor}; - } - } - - /** - * SCENARIO #3 - * - * zaddrs -> zaddr - * taddrs -> - * - * zaddrs -> - * taddrs -> taddr - * - * Send to zaddr by chaining JoinSplits together and immediately consuming any change - * Send to taddr by creating dummy z outputs and accumulating value in a change note - * which is used to set vpub_new in the last chained joinsplit. - */ - UniValue obj(UniValue::VOBJ); - CAmount jsChange = 0; // this is updated after each joinsplit - int changeOutputIndex = -1; // this is updated after each joinsplit if jsChange > 0 - bool vpubOldProcessed = false; // updated when vpub_old for taddr inputs is set in first joinsplit - bool vpubNewProcessed = false; // updated when vpub_new for miner fee and taddr outputs is set in last joinsplit - - // At this point, we are guaranteed to have at least one input note. - // Use address of first input note as the temporary change address. - SproutSpendingKey changeKey = std::get<3>(zInputsDeque.front()); - SproutPaymentAddress changeAddress = changeKey.address(); - - CAmount vpubOldTarget = 0; - CAmount vpubNewTarget = 0; - if (isToTaddr_) { - vpubNewTarget = z_inputs_total; - } else { - if (utxoInputs_.empty()) { - vpubNewTarget = minersFee; - } else { - vpubOldTarget = t_inputs_total - minersFee; - } - } - - // Keep track of treestate within this transaction - boost::unordered_map intermediates; - std::vector previousCommitments; - - while (!vpubNewProcessed) { - MergeToAddressJSInfo info; - info.vpub_old = 0; - info.vpub_new = 0; - - // Set vpub_old in the first joinsplit - if (!vpubOldProcessed) { - if (t_inputs_total < vpubOldTarget) { - throw JSONRPCError(RPC_WALLET_ERROR, - strprintf("Insufficient transparent funds for vpub_old %s (miners fee %s, taddr inputs %s)", - FormatMoney(vpubOldTarget), FormatMoney(minersFee), FormatMoney(t_inputs_total))); - } - info.vpub_old += vpubOldTarget; // funds flowing from public pool - vpubOldProcessed = true; - } - - CAmount jsInputValue = 0; - uint256 jsAnchor; - std::vector> witnesses; - - JSDescription prevJoinSplit; - - // Keep track of previous JoinSplit and its commitments - if (tx_.vjoinsplit.size() > 0) { - prevJoinSplit = tx_.vjoinsplit.back(); - } - - // If there is no change, the chain has terminated so we can reset the tracked treestate. - if (jsChange == 0 && tx_.vjoinsplit.size() > 0) { - intermediates.clear(); - previousCommitments.clear(); - } - - // - // Consume change as the first input of the JoinSplit. - // - if (jsChange > 0) { - LOCK2(cs_main, pwalletMain->cs_wallet); - - // Update tree state with previous joinsplit - SproutMerkleTree tree; - auto it = intermediates.find(prevJoinSplit.anchor); - if (it != intermediates.end()) { - tree = it->second; - } else if (!pcoinsTip->GetSproutAnchorAt(prevJoinSplit.anchor, tree)) { - throw JSONRPCError(RPC_WALLET_ERROR, "Could not find previous JoinSplit anchor"); - } - - assert(changeOutputIndex != -1); - boost::optional changeWitness; - int n = 0; - for (const uint256& commitment : prevJoinSplit.commitments) { - tree.append(commitment); - previousCommitments.push_back(commitment); - if (!changeWitness && changeOutputIndex == n++) { - changeWitness = tree.witness(); - } else if (changeWitness) { - changeWitness.get().append(commitment); - } - } - if (changeWitness) { - witnesses.push_back(changeWitness); - } - jsAnchor = tree.root(); - intermediates.insert(std::make_pair(tree.root(), tree)); // chained js are interstitial (found in between block boundaries) - - // Decrypt the change note's ciphertext to retrieve some data we need - ZCNoteDecryption decryptor(changeKey.receiving_key()); - auto hSig = prevJoinSplit.h_sig(*pzcashParams, tx_.joinSplitPubKey); - try { - SproutNotePlaintext plaintext = SproutNotePlaintext::decrypt( - decryptor, - prevJoinSplit.ciphertexts[changeOutputIndex], - prevJoinSplit.ephemeralKey, - hSig, - (unsigned char)changeOutputIndex); - - SproutNote note = plaintext.note(changeAddress); - info.notes.push_back(note); - info.zkeys.push_back(changeKey); - - jsInputValue += plaintext.value(); - - LogPrint("zrpcunsafe", "%s: spending change (amount=%s)\n", - getId(), - FormatMoney(plaintext.value())); - - } catch (const std::exception& e) { - throw JSONRPCError(RPC_WALLET_ERROR, strprintf("Error decrypting output note of previous JoinSplit: %s", e.what())); - } - } - - - // - // Consume spendable non-change notes - // - std::vector vInputNotes; - std::vector vInputZKeys; - std::vector vOutPoints; - std::vector> vInputWitnesses; - uint256 inputAnchor; - int numInputsNeeded = (jsChange > 0) ? 1 : 0; - while (numInputsNeeded++ < ZC_NUM_JS_INPUTS && zInputsDeque.size() > 0) { - MergeToAddressInputSproutNote t = zInputsDeque.front(); - JSOutPoint jso = std::get<0>(t); - SproutNote note = std::get<1>(t); - CAmount noteFunds = std::get<2>(t); - SproutSpendingKey zkey = std::get<3>(t); - zInputsDeque.pop_front(); - - MergeToAddressWitnessAnchorData wad = jsopWitnessAnchorMap[jso.ToString()]; - vInputWitnesses.push_back(wad.witness); - if (inputAnchor.IsNull()) { - inputAnchor = wad.anchor; - } else if (inputAnchor != wad.anchor) { - throw JSONRPCError(RPC_WALLET_ERROR, "Selected input notes do not share the same anchor"); - } - - vOutPoints.push_back(jso); - vInputNotes.push_back(note); - vInputZKeys.push_back(zkey); - - jsInputValue += noteFunds; - - int wtxHeight = -1; - int wtxDepth = -1; - { - LOCK2(cs_main, pwalletMain->cs_wallet); - const CWalletTx& wtx = pwalletMain->mapWallet[jso.hash]; - // Zero confirmation notes belong to transactions which have not yet been mined - if (mapBlockIndex.find(wtx.hashBlock) == mapBlockIndex.end()) { - throw JSONRPCError(RPC_WALLET_ERROR, strprintf("mapBlockIndex does not contain block hash %s", wtx.hashBlock.ToString())); - } - wtxHeight = komodo_blockheight(wtx.hashBlock); - wtxDepth = wtx.GetDepthInMainChain(); - } - LogPrint("zrpcunsafe", "%s: spending note (txid=%s, vjoinsplit=%d, ciphertext=%d, amount=%s, height=%d, confirmations=%d)\n", - getId(), - jso.hash.ToString().substr(0, 10), - jso.js, - int(jso.n), // uint8_t - FormatMoney(noteFunds), - wtxHeight, - wtxDepth); - } - - // Add history of previous commitments to witness - if (vInputNotes.size() > 0) { - if (vInputWitnesses.size() == 0) { - throw JSONRPCError(RPC_WALLET_ERROR, "Could not find witness for note commitment"); - } - - for (auto& optionalWitness : vInputWitnesses) { - if (!optionalWitness) { - throw JSONRPCError(RPC_WALLET_ERROR, "Witness for note commitment is null"); - } - SproutWitness w = *optionalWitness; // could use .get(); - if (jsChange > 0) { - for (const uint256& commitment : previousCommitments) { - w.append(commitment); - } - if (jsAnchor != w.root()) { - throw JSONRPCError(RPC_WALLET_ERROR, "Witness for spendable note does not have same anchor as change input"); - } - } - witnesses.push_back(w); - } - - // The jsAnchor is null if this JoinSplit is at the start of a new chain - if (jsAnchor.IsNull()) { - jsAnchor = inputAnchor; - } - - // Add spendable notes as inputs - std::copy(vInputNotes.begin(), vInputNotes.end(), std::back_inserter(info.notes)); - std::copy(vInputZKeys.begin(), vInputZKeys.end(), std::back_inserter(info.zkeys)); - } - - // Accumulate change - jsChange = jsInputValue + info.vpub_old; - - // Set vpub_new in the last joinsplit (when there are no more notes to spend) - if (zInputsDeque.empty()) { - assert(!vpubNewProcessed); - if (jsInputValue < vpubNewTarget) { - throw JSONRPCError(RPC_WALLET_ERROR, - strprintf("Insufficient funds for vpub_new %s (miners fee %s, taddr inputs %s)", - FormatMoney(vpubNewTarget), FormatMoney(minersFee), FormatMoney(t_inputs_total))); - } - info.vpub_new += vpubNewTarget; // funds flowing back to public pool - vpubNewProcessed = true; - jsChange -= vpubNewTarget; - // If we are merging to a t-addr, there should be no change - if (isToTaddr_) assert(jsChange == 0); - } - - // create dummy output - info.vjsout.push_back(JSOutput()); // dummy output while we accumulate funds into a change note for vpub_new - - // create output for any change - if (jsChange > 0) { - std::string outputType = "change"; - auto jso = JSOutput(changeAddress, jsChange); - // If this is the final output, set the target and memo - if (isToZaddr_ && vpubNewProcessed) { - outputType = "target"; - jso.addr = boost::get(toPaymentAddress_); - if (!hexMemo.empty()) { - jso.memo = get_memo_from_hex_string(hexMemo); - } - } - info.vjsout.push_back(jso); - - LogPrint("zrpcunsafe", "%s: generating note for %s (amount=%s)\n", - getId(), - outputType, - FormatMoney(jsChange)); - } - - obj = perform_joinsplit(info, witnesses, jsAnchor); - - if (jsChange > 0) { - changeOutputIndex = mta_find_output(obj, 1); - } - } - - // Sanity check in case changes to code block above exits loop by invoking 'break' - assert(zInputsDeque.size() == 0); - assert(vpubNewProcessed); - sign_send_raw_transaction(obj); return true; } @@ -866,10 +538,6 @@ UniValue AsyncRPCOperation_mergetoaddress::perform_joinsplit(MergeToAddressJSInf { std::vector> witnesses; uint256 anchor; - { - LOCK(cs_main); - pwalletMain->GetSproutNoteWitnesses(outPoints, witnesses, anchor); - } return perform_joinsplit(info, witnesses, anchor); } diff --git a/src/zcbenchmarks.cpp b/src/zcbenchmarks.cpp index 2f79e454b..9af3c184a 100644 --- a/src/zcbenchmarks.cpp +++ b/src/zcbenchmarks.cpp @@ -93,29 +93,6 @@ double benchmark_sleep() return timer_stop(tv_start); } -double benchmark_create_joinsplit() -{ - uint256 joinSplitPubKey; - - /* Get the anchor of an empty commitment tree. */ - uint256 anchor = SproutMerkleTree().root(); - - struct timeval tv_start; - timer_start(tv_start); - JSDescription jsdesc(*pzcashParams, - joinSplitPubKey, - anchor, - {JSInput(), JSInput()}, - {JSOutput(), JSOutput()}, - 0, - 0); - double ret = timer_stop(tv_start); - - auto verifier = libzcash::ProofVerifier::Strict(); - assert(jsdesc.Verify(*pzcashParams, verifier, joinSplitPubKey)); - return ret; -} - std::vector benchmark_create_joinsplit_threaded(int nThreads) { std::vector ret; @@ -263,160 +240,6 @@ double benchmark_large_tx(size_t nInputs) return timer_stop(tv_start); } -double benchmark_try_decrypt_notes(size_t nAddrs) -{ - CWallet wallet; - for (int i = 0; i < nAddrs; i++) { - auto sk = libzcash::SproutSpendingKey::random(); - wallet.AddSproutSpendingKey(sk); - } - - auto sk = libzcash::SproutSpendingKey::random(); - auto tx = GetValidReceive(*pzcashParams, sk, 10, true); - - struct timeval tv_start; - timer_start(tv_start); - auto nd = wallet.FindMySproutNotes(tx); - return timer_stop(tv_start); -} - -double benchmark_increment_note_witnesses(size_t nTxs) -{ - CWallet wallet; - SproutMerkleTree sproutTree; - SaplingMerkleTree saplingTree; - - auto sk = libzcash::SproutSpendingKey::random(); - wallet.AddSproutSpendingKey(sk); - - // First block - CBlock block1; - for (int i = 0; i < nTxs; i++) { - auto wtx = GetValidReceive(*pzcashParams, sk, 10, true); - auto note = GetNote(*pzcashParams, sk, wtx, 0, 1); - auto nullifier = note.nullifier(sk); - - mapSproutNoteData_t noteData; - JSOutPoint jsoutpt {wtx.GetHash(), 0, 1}; - SproutNoteData nd {sk.address(), nullifier}; - noteData[jsoutpt] = nd; - - wtx.SetSproutNoteData(noteData); - wallet.AddToWallet(wtx, true, NULL); - block1.vtx.push_back(wtx); - } - CBlockIndex index1(block1); - index1.SetHeight(1); - - // Increment to get transactions witnessed - wallet.ChainTip(&index1, &block1, std::make_pair(sproutTree, saplingTree)); - - // Second block - CBlock block2; - block2.hashPrevBlock = block1.GetHash(); - { - auto wtx = GetValidReceive(*pzcashParams, sk, 10, true); - auto note = GetNote(*pzcashParams, sk, wtx, 0, 1); - auto nullifier = note.nullifier(sk); - - mapSproutNoteData_t noteData; - JSOutPoint jsoutpt {wtx.GetHash(), 0, 1}; - SproutNoteData nd {sk.address(), nullifier}; - noteData[jsoutpt] = nd; - - wtx.SetSproutNoteData(noteData); - wallet.AddToWallet(wtx, true, NULL); - block2.vtx.push_back(wtx); - } - CBlockIndex index2(block2); - index2.SetHeight(2); - - struct timeval tv_start; - timer_start(tv_start); - wallet.ChainTip(&index2, &block2, std::make_pair(sproutTree, saplingTree)); - return timer_stop(tv_start); -} - -// Fake the input of a given block -class FakeCoinsViewDB : public CCoinsViewDB { - uint256 hash; - SproutMerkleTree t; - -public: - FakeCoinsViewDB(std::string dbName, uint256& hash) : CCoinsViewDB(dbName, 100, false, false), hash(hash) {} - - bool GetAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const { - if (rt == t.root()) { - tree = t; - return true; - } - return false; - } - - bool GetNullifier(const uint256 &nf, ShieldedType type) const { - return false; - } - - uint256 GetBestBlock() const { - return hash; - } - - uint256 GetBestAnchor() const { - return t.root(); - } - - bool BatchWrite(CCoinsMap &mapCoins, - const uint256 &hashBlock, - const uint256 &hashAnchor, - CAnchorsSproutMap &mapSproutAnchors, - CNullifiersMap &mapSproutNullifiers, - CNullifiersMap& mapSaplingNullifiers) { - return false; - } - - bool GetStats(CCoinsStats &stats) const { - return false; - } -}; - -double benchmark_connectblock_slow() -{ - // Test for issue 2017-05-01.a - SelectParams(CBaseChainParams::MAIN); - CBlock block; - FILE* fp = fopen((GetDataDir() / "benchmark/block-107134.dat").string().c_str(), "rb"); - if (!fp) throw new std::runtime_error("Failed to open block data file"); - CAutoFile blkFile(fp, SER_DISK, CLIENT_VERSION); - blkFile >> block; - blkFile.fclose(); - - // Fake its inputs - auto hashPrev = uint256S("00000000159a41f468e22135942a567781c3f3dc7ad62257993eb3c69c3f95ef"); - FakeCoinsViewDB fakeDB("benchmark/block-107134-inputs", hashPrev); - CCoinsViewCache view(&fakeDB); - - // Fake the chain - CBlockIndex index(block); - index.SetHeight(107134); - CBlockIndex indexPrev; - indexPrev.phashBlock = &hashPrev; - indexPrev.SetHeight(index.GetHeight() - 1); - index.pprev = &indexPrev; - mapBlockIndex.insert(std::make_pair(hashPrev, &indexPrev)); - - CValidationState state; - struct timeval tv_start; - timer_start(tv_start); - assert(ConnectBlock(block, state, &index, view, true)); - auto duration = timer_stop(tv_start); - - // Undo alterations to global state - mapBlockIndex.erase(hashPrev); - SelectParamsFromCommandLine(); - - return duration; -} - extern UniValue getnewaddress(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp extern UniValue sendtoaddress(const UniValue& params, bool fHelp, const CPubKey& mypk); From 00bf3255eb4c39586288a4ddd95855986ce2252d Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 1 Jun 2020 10:54:50 -0400 Subject: [PATCH 037/255] desprout --- .../asyncrpcoperation_mergetoaddress.cpp | 7 +- src/wallet/asyncrpcoperation_sendmany.cpp | 631 +----------------- 2 files changed, 4 insertions(+), 634 deletions(-) diff --git a/src/wallet/asyncrpcoperation_mergetoaddress.cpp b/src/wallet/asyncrpcoperation_mergetoaddress.cpp index 488e7f5b7..4dace19bb 100644 --- a/src/wallet/asyncrpcoperation_mergetoaddress.cpp +++ b/src/wallet/asyncrpcoperation_mergetoaddress.cpp @@ -429,9 +429,6 @@ bool AsyncRPCOperation_mergetoaddress::main_impl() * END SCENARIO #0 */ - - UniValue obj(UniValue::VOBJ); - /** * SCENARIO #1 * @@ -440,6 +437,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl() * There are no zaddrs or joinsplits involved. */ if (isPureTaddrOnlyTx) { + UniValue obj(UniValue::VOBJ); obj.push_back(Pair("rawtxn", EncodeHexTx(tx_))); sign_send_raw_transaction(obj); return true; @@ -448,8 +446,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl() * END SCENARIO #1 */ - sign_send_raw_transaction(obj); - return true; + return false; } diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index db7f7bd66..a1ecb296d 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2016 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -566,430 +566,7 @@ bool AsyncRPCOperation_sendmany::main_impl() { * END SCENARIO #0 */ - - // Grab the current consensus branch ID - { - LOCK(cs_main); - consensusBranchId_ = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); - } - - /** - * SCENARIO #1 - * - * taddr -> taddrs - * - * There are no zaddrs or joinsplits involved. - */ - if (isPureTaddrOnlyTx) { - add_taddr_outputs_to_tx(); - - CAmount funds = selectedUTXOAmount; - CAmount fundsSpent = t_outputs_total + minersFee; - CAmount change = funds - fundsSpent; - - if (change > 0) { - add_taddr_change_output_to_tx(0,change); - - LogPrint("zrpc", "%s: transparent change in transaction output (amount=%s)\n", - getId(), - FormatMoney(change) - ); - } - - UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("rawtxn", EncodeHexTx(tx_))); - sign_send_raw_transaction(obj); - return true; - } - /** - * END SCENARIO #1 - */ - - - // Prepare raw transaction to handle JoinSplits - CMutableTransaction mtx(tx_); - crypto_sign_keypair(joinSplitPubKey_.begin(), joinSplitPrivKey_); - mtx.joinSplitPubKey = joinSplitPubKey_; - //if ((uint32_t)chainActive.LastTip()->nTime < ASSETCHAINS_STAKED_HF_TIMESTAMP) - if ( !hush_hardfork_active((uint32_t)chainActive.LastTip()->nTime) ) - mtx.nLockTime = (uint32_t)time(NULL) - 60; // jl777 - else - mtx.nLockTime = (uint32_t)chainActive.Tip()->GetMedianTimePast(); - - tx_ = CTransaction(mtx); - - // Copy zinputs and zoutputs to more flexible containers - std::deque zInputsDeque; // zInputsDeque stores minimum numbers of notes for target amount - CAmount tmp = 0; - for (auto o : z_sprout_inputs_) { - zInputsDeque.push_back(o); - tmp += std::get<2>(o); - if (tmp >= targetAmount) { - break; - } - } - std::deque zOutputsDeque; - for (auto o : z_outputs_) { - zOutputsDeque.push_back(o); - } - - // When spending notes, take a snapshot of note witnesses and anchors as the treestate will - // change upon arrival of new blocks which contain joinsplit transactions. This is likely - // to happen as creating a chained joinsplit transaction can take longer than the block interval. - if (z_sprout_inputs_.size() > 0) { - LOCK2(cs_main, pwalletMain->cs_wallet); - for (auto t : z_sprout_inputs_) { - JSOutPoint jso = std::get<0>(t); - std::vector vOutPoints = { jso }; - uint256 inputAnchor; - std::vector> vInputWitnesses; - pwalletMain->GetSproutNoteWitnesses(vOutPoints, vInputWitnesses, inputAnchor); - jsopWitnessAnchorMap[ jso.ToString() ] = WitnessAnchorData{ vInputWitnesses[0], inputAnchor }; - } - } - - - /** - * SCENARIO #2 - * - * taddr -> taddrs - * -> zaddrs - * - * Note: Consensus rule states that coinbase utxos can only be sent to a zaddr. TODO: Do they? - * Local wallet rule does not allow any change when sending coinbase utxos - * since there is currently no way to specify a change address and we don't - * want users accidentally sending excess funds to a recipient. - */ - if (isfromtaddr_) { - add_taddr_outputs_to_tx(); - - CAmount funds = selectedUTXOAmount; - CAmount fundsSpent = t_outputs_total + minersFee + z_outputs_total; - CAmount change = funds - fundsSpent; - - if (change > 0) { - if (selectedUTXOCoinbase) { - assert(isSingleZaddrOutput); - throw JSONRPCError(RPC_WALLET_ERROR, strprintf( - "Change %s not allowed. When shielding coinbase funds, the wallet does not " - "allow any change as there is currently no way to specify a change address " - "in z_sendmany.", FormatMoney(change))); - } else { - CBitcoinAddress ba = CBitcoinAddress(fromtaddr_); - add_taddr_change_output_to_tx(&ba,change); - LogPrint("zrpc", "%s: transparent change in transaction output (amount=%s)\n", - getId(), - FormatMoney(change) - ); - } - } - - // Create joinsplits, where each output represents a zaddr recipient. - UniValue obj(UniValue::VOBJ); - while (zOutputsDeque.size() > 0) { - AsyncJoinSplitInfo info; - info.vpub_old = 0; - info.vpub_new = 0; - int n = 0; - while (n++ 0) { - SendManyRecipient smr = zOutputsDeque.front(); - std::string address = std::get<0>(smr); - CAmount value = std::get<1>(smr); - std::string hexMemo = std::get<2>(smr); - zOutputsDeque.pop_front(); - - PaymentAddress pa = DecodePaymentAddress(address); - JSOutput jso = JSOutput(boost::get(pa), value); - if (hexMemo.size() > 0) { - jso.memo = get_memo_from_hex_string(hexMemo); - } - info.vjsout.push_back(jso); - - // Funds are removed from the value pool and enter the private pool - info.vpub_old += value; - } - obj = perform_joinsplit(info); - } - sign_send_raw_transaction(obj); - return true; - } - /** - * END SCENARIO #2 - */ - - - - /** - * SCENARIO #3 - * - * zaddr -> taddrs - * -> zaddrs - * - * Send to zaddrs by chaining JoinSplits together and immediately consuming any change - * Send to taddrs by creating dummy z outputs and accumulating value in a change note - * which is used to set vpub_new in the last chained joinsplit. - */ - UniValue obj(UniValue::VOBJ); - CAmount jsChange = 0; // this is updated after each joinsplit - int changeOutputIndex = -1; // this is updated after each joinsplit if jsChange > 0 - bool vpubNewProcessed = false; // updated when vpub_new for miner fee and taddr outputs is set in last joinsplit - CAmount vpubNewTarget = minersFee; - if (t_outputs_total > 0) { - add_taddr_outputs_to_tx(); - vpubNewTarget += t_outputs_total; - } - - // Keep track of treestate within this transaction - boost::unordered_map intermediates; - std::vector previousCommitments; - - while (!vpubNewProcessed) { - AsyncJoinSplitInfo info; - info.vpub_old = 0; - info.vpub_new = 0; - - CAmount jsInputValue = 0; - uint256 jsAnchor; - std::vector> witnesses; - - JSDescription prevJoinSplit; - - // Keep track of previous JoinSplit and its commitments - if (tx_.vjoinsplit.size() > 0) { - prevJoinSplit = tx_.vjoinsplit.back(); - } - - // If there is no change, the chain has terminated so we can reset the tracked treestate. - if (jsChange==0 && tx_.vjoinsplit.size() > 0) { - intermediates.clear(); - previousCommitments.clear(); - } - - // - // Consume change as the first input of the JoinSplit. - // - if (jsChange > 0) { - LOCK2(cs_main, pwalletMain->cs_wallet); - - // Update tree state with previous joinsplit - SproutMerkleTree tree; - auto it = intermediates.find(prevJoinSplit.anchor); - if (it != intermediates.end()) { - tree = it->second; - } else if (!pcoinsTip->GetSproutAnchorAt(prevJoinSplit.anchor, tree)) { - throw JSONRPCError(RPC_WALLET_ERROR, "Could not find previous JoinSplit anchor"); - } - - assert(changeOutputIndex != -1); - boost::optional changeWitness; - int n = 0; - for (const uint256& commitment : prevJoinSplit.commitments) { - tree.append(commitment); - previousCommitments.push_back(commitment); - if (!changeWitness && changeOutputIndex == n++) { - changeWitness = tree.witness(); - } else if (changeWitness) { - changeWitness.get().append(commitment); - } - } - if (changeWitness) { - witnesses.push_back(changeWitness); - } - jsAnchor = tree.root(); - intermediates.insert(std::make_pair(tree.root(), tree)); // chained js are interstitial (found in between block boundaries) - - // Decrypt the change note's ciphertext to retrieve some data we need - ZCNoteDecryption decryptor(boost::get(spendingkey_).receiving_key()); - auto hSig = prevJoinSplit.h_sig(*pzcashParams, tx_.joinSplitPubKey); - try { - SproutNotePlaintext plaintext = SproutNotePlaintext::decrypt( - decryptor, - prevJoinSplit.ciphertexts[changeOutputIndex], - prevJoinSplit.ephemeralKey, - hSig, - (unsigned char) changeOutputIndex); - - SproutNote note = plaintext.note(boost::get(frompaymentaddress_)); - info.notes.push_back(note); - - jsInputValue += plaintext.value(); - - LogPrint("zrpcunsafe", "%s: spending change (amount=%s)\n", - getId(), - FormatMoney(plaintext.value()) - ); - - } catch (const std::exception& e) { - throw JSONRPCError(RPC_WALLET_ERROR, strprintf("Error decrypting output note of previous JoinSplit: %s", e.what())); - } - } - - - // - // Consume spendable non-change notes - // - std::vector vInputNotes; - std::vector vOutPoints; - std::vector> vInputWitnesses; - uint256 inputAnchor; - int numInputsNeeded = (jsChange>0) ? 1 : 0; - while (numInputsNeeded++ < ZC_NUM_JS_INPUTS && zInputsDeque.size() > 0) { - SendManyInputJSOP t = zInputsDeque.front(); - JSOutPoint jso = std::get<0>(t); - SproutNote note = std::get<1>(t); - CAmount noteFunds = std::get<2>(t); - zInputsDeque.pop_front(); - - WitnessAnchorData wad = jsopWitnessAnchorMap[ jso.ToString() ]; - vInputWitnesses.push_back(wad.witness); - if (inputAnchor.IsNull()) { - inputAnchor = wad.anchor; - } else if (inputAnchor != wad.anchor) { - throw JSONRPCError(RPC_WALLET_ERROR, "Selected input notes do not share the same anchor"); - } - - vOutPoints.push_back(jso); - vInputNotes.push_back(note); - - jsInputValue += noteFunds; - - int wtxHeight = -1; - int wtxDepth = -1; - { - LOCK2(cs_main, pwalletMain->cs_wallet); - const CWalletTx& wtx = pwalletMain->mapWallet[jso.hash]; - // Zero-confirmation notes belong to transactions which have not yet been mined - if (mapBlockIndex.find(wtx.hashBlock) == mapBlockIndex.end()) { - throw JSONRPCError(RPC_WALLET_ERROR, strprintf("mapBlockIndex does not contain block hash %s", wtx.hashBlock.ToString())); - } - wtxHeight = komodo_blockheight(wtx.hashBlock); - wtxDepth = wtx.GetDepthInMainChain(); - } - LogPrint("zrpcunsafe", "%s: spending note (txid=%s, vjoinsplit=%d, ciphertext=%d, amount=%s, height=%d, confirmations=%d)\n", - getId(), - jso.hash.ToString().substr(0, 10), - jso.js, - int(jso.n), // uint8_t - FormatMoney(noteFunds), - wtxHeight, - wtxDepth - ); - } - - // Add history of previous commitments to witness - if (vInputNotes.size() > 0) { - - if (vInputWitnesses.size()==0) { - throw JSONRPCError(RPC_WALLET_ERROR, "Could not find witness for note commitment"); - } - - for (auto & optionalWitness : vInputWitnesses) { - if (!optionalWitness) { - throw JSONRPCError(RPC_WALLET_ERROR, "Witness for note commitment is null"); - } - SproutWitness w = *optionalWitness; // could use .get(); - if (jsChange > 0) { - for (const uint256& commitment : previousCommitments) { - w.append(commitment); - } - if (jsAnchor != w.root()) { - throw JSONRPCError(RPC_WALLET_ERROR, "Witness for spendable note does not have same anchor as change input"); - } - } - witnesses.push_back(w); - } - - // The jsAnchor is null if this JoinSplit is at the start of a new chain - if (jsAnchor.IsNull()) { - jsAnchor = inputAnchor; - } - - // Add spendable notes as inputs - std::copy(vInputNotes.begin(), vInputNotes.end(), std::back_inserter(info.notes)); - } - - // Find recipient to transfer funds to - std::string address, hexMemo; - CAmount value = 0; - if (zOutputsDeque.size() > 0) { - SendManyRecipient smr = zOutputsDeque.front(); - address = std::get<0>(smr); - value = std::get<1>(smr); - hexMemo = std::get<2>(smr); - zOutputsDeque.pop_front(); - } - - // Reset change - jsChange = 0; - CAmount outAmount = value; - - // Set vpub_new in the last joinsplit (when there are no more notes to spend or zaddr outputs to satisfy) - if (zOutputsDeque.size() == 0 && zInputsDeque.size() == 0) { - assert(!vpubNewProcessed); - if (jsInputValue < vpubNewTarget) { - throw JSONRPCError(RPC_WALLET_ERROR, - strprintf("Insufficient funds for vpub_new %s (miners fee %s, taddr outputs %s)", - FormatMoney(vpubNewTarget), FormatMoney(minersFee), FormatMoney(t_outputs_total))); - } - outAmount += vpubNewTarget; - info.vpub_new += vpubNewTarget; // funds flowing back to public pool - vpubNewProcessed = true; - jsChange = jsInputValue - outAmount; - assert(jsChange >= 0); - } - else { - // This is not the last joinsplit, so compute change and any amount still due to the recipient - if (jsInputValue > outAmount) { - jsChange = jsInputValue - outAmount; - } else if (outAmount > jsInputValue) { - // Any amount due is owed to the recipient. Let the miners fee get paid first. - CAmount due = outAmount - jsInputValue; - SendManyRecipient r = SendManyRecipient(address, due, hexMemo); - zOutputsDeque.push_front(r); - - // reduce the amount being sent right now to the value of all inputs - value = jsInputValue; - } - } - - // create output for recipient - if (address.empty()) { - assert(value==0); - info.vjsout.push_back(JSOutput()); // dummy output while we accumulate funds into a change note for vpub_new - } else { - PaymentAddress pa = DecodePaymentAddress(address); - // If we are here, we know we have no Sapling outputs. - JSOutput jso = JSOutput(boost::get(pa), value); - if (hexMemo.size() > 0) { - jso.memo = get_memo_from_hex_string(hexMemo); - } - info.vjsout.push_back(jso); - } - - // create output for any change - if (jsChange>0) { - info.vjsout.push_back(JSOutput(boost::get(frompaymentaddress_), jsChange)); - - LogPrint("zrpcunsafe", "%s: generating note for change (amount=%s)\n", - getId(), - FormatMoney(jsChange) - ); - } - - obj = perform_joinsplit(info, witnesses, jsAnchor); - - if (jsChange > 0) { - changeOutputIndex = find_output(obj, 1); - } - } - - // Sanity check in case changes to code block above exits loop by invoking 'break' - assert(zInputsDeque.size() == 0); - assert(zOutputsDeque.size() == 0); - assert(vpubNewProcessed); - - sign_send_raw_transaction(obj); - return true; + return false; } @@ -1143,19 +720,6 @@ bool AsyncRPCOperation_sendmany::find_unspent_notes() { saplingEntries.clear(); } - for (CSproutNotePlaintextEntry & entry : sproutEntries) { - z_sprout_inputs_.push_back(SendManyInputJSOP(entry.jsop, entry.plaintext.note(boost::get(frompaymentaddress_)), CAmount(entry.plaintext.value()))); - std::string data(entry.plaintext.memo().begin(), entry.plaintext.memo().end()); - LogPrint("zrpcunsafe", "%s: found unspent Sprout note (txid=%s, vjoinsplit=%d, ciphertext=%d, amount=%s, memo=%s)\n", - getId(), - entry.jsop.hash.ToString().substr(0, 10), - entry.jsop.js, - int(entry.jsop.n), // uint8_t - FormatMoney(entry.plaintext.value()), - HexStr(data).substr(0, 10) - ); - } - for (auto entry : saplingEntries) { z_sapling_inputs_.push_back(entry); std::string data(entry.memo.begin(), entry.memo.end()); @@ -1167,15 +731,7 @@ bool AsyncRPCOperation_sendmany::find_unspent_notes() { HexStr(data).substr(0, 10)); } - if (z_sprout_inputs_.empty() && z_sapling_inputs_.empty()) { - return false; - } - // sort in descending order, so big notes appear first - std::sort(z_sprout_inputs_.begin(), z_sprout_inputs_.end(), - [](SendManyInputJSOP i, SendManyInputJSOP j) -> bool { - return std::get<2>(i) > std::get<2>(j); - }); std::sort(z_sapling_inputs_.begin(), z_sapling_inputs_.end(), [](SaplingNoteEntry i, SaplingNoteEntry j) -> bool { return i.note.value() > j.note.value(); @@ -1184,189 +740,6 @@ bool AsyncRPCOperation_sendmany::find_unspent_notes() { return true; } -UniValue AsyncRPCOperation_sendmany::perform_joinsplit(AsyncJoinSplitInfo & info) { - std::vector> witnesses; - uint256 anchor; - { - LOCK(cs_main); - anchor = pcoinsTip->GetBestAnchor(SPROUT); // As there are no inputs, ask the wallet for the best anchor - } - return perform_joinsplit(info, witnesses, anchor); -} - - -UniValue AsyncRPCOperation_sendmany::perform_joinsplit(AsyncJoinSplitInfo & info, std::vector & outPoints) { - std::vector> witnesses; - uint256 anchor; - { - LOCK(cs_main); - pwalletMain->GetSproutNoteWitnesses(outPoints, witnesses, anchor); - } - return perform_joinsplit(info, witnesses, anchor); -} - -UniValue AsyncRPCOperation_sendmany::perform_joinsplit( - AsyncJoinSplitInfo & info, - std::vector> witnesses, - uint256 anchor) -{ - if (anchor.IsNull()) { - throw std::runtime_error("anchor is null"); - } - - if (!(witnesses.size() == info.notes.size())) { - throw runtime_error("number of notes and witnesses do not match"); - } - - for (size_t i = 0; i < witnesses.size(); i++) { - if (!witnesses[i]) { - throw runtime_error("joinsplit input could not be found in tree"); - } - info.vjsin.push_back(JSInput(*witnesses[i], info.notes[i], boost::get(spendingkey_))); - } - - // Make sure there are two inputs and two outputs - while (info.vjsin.size() < ZC_NUM_JS_INPUTS) { - info.vjsin.push_back(JSInput()); - } - - while (info.vjsout.size() < ZC_NUM_JS_OUTPUTS) { - info.vjsout.push_back(JSOutput()); - } - - if (info.vjsout.size() != ZC_NUM_JS_INPUTS || info.vjsin.size() != ZC_NUM_JS_OUTPUTS) { - throw runtime_error("unsupported joinsplit input/output counts"); - } - - CMutableTransaction mtx(tx_); - - LogPrint("zrpcunsafe", "%s: creating joinsplit at index %d (vpub_old=%s, vpub_new=%s, in[0]=%s, in[1]=%s, out[0]=%s, out[1]=%s)\n", - getId(), - tx_.vjoinsplit.size(), - FormatMoney(info.vpub_old), FormatMoney(info.vpub_new), - FormatMoney(info.vjsin[0].note.value()), FormatMoney(info.vjsin[1].note.value()), - FormatMoney(info.vjsout[0].value), FormatMoney(info.vjsout[1].value) - ); - - // Generate the proof, this can take over a minute. - std::array inputs - {info.vjsin[0], info.vjsin[1]}; - std::array outputs - {info.vjsout[0], info.vjsout[1]}; - std::array inputMap; - std::array outputMap; - uint256 esk; // payment disclosure - secret - - JSDescription jsdesc = JSDescription::Randomized( - *pzcashParams, - joinSplitPubKey_, - anchor, - inputs, - outputs, - inputMap, - outputMap, - info.vpub_old, - info.vpub_new, - !this->testmode, - &esk); // parameter expects pointer to esk, so pass in address - { - auto verifier = libzcash::ProofVerifier::Strict(); - if (!(jsdesc.Verify(*pzcashParams, verifier, joinSplitPubKey_))) { - throw std::runtime_error("error verifying joinsplit"); - } - } - - mtx.vjoinsplit.push_back(jsdesc); - - // Empty output script. - CScript scriptCode; - CTransaction signTx(mtx); - uint256 dataToBeSigned = SignatureHash(scriptCode, signTx, NOT_AN_INPUT, SIGHASH_ALL, 0, consensusBranchId_); - - // Add the signature - if (!(crypto_sign_detached(&mtx.joinSplitSig[0], NULL, - dataToBeSigned.begin(), 32, - joinSplitPrivKey_ - ) == 0)) - { - throw std::runtime_error("crypto_sign_detached failed"); - } - - // Sanity check - if (!(crypto_sign_verify_detached(&mtx.joinSplitSig[0], - dataToBeSigned.begin(), 32, - mtx.joinSplitPubKey.begin() - ) == 0)) - { - throw std::runtime_error("crypto_sign_verify_detached failed"); - } - - CTransaction rawTx(mtx); - tx_ = rawTx; - - CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - ss << rawTx; - - std::string encryptedNote1; - std::string encryptedNote2; - { - CDataStream ss2(SER_NETWORK, PROTOCOL_VERSION); - ss2 << ((unsigned char) 0x00); - ss2 << jsdesc.ephemeralKey; - ss2 << jsdesc.ciphertexts[0]; - ss2 << jsdesc.h_sig(*pzcashParams, joinSplitPubKey_); - - encryptedNote1 = HexStr(ss2.begin(), ss2.end()); - } - { - CDataStream ss2(SER_NETWORK, PROTOCOL_VERSION); - ss2 << ((unsigned char) 0x01); - ss2 << jsdesc.ephemeralKey; - ss2 << jsdesc.ciphertexts[1]; - ss2 << jsdesc.h_sig(*pzcashParams, joinSplitPubKey_); - - encryptedNote2 = HexStr(ss2.begin(), ss2.end()); - } - - UniValue arrInputMap(UniValue::VARR); - UniValue arrOutputMap(UniValue::VARR); - for (size_t i = 0; i < ZC_NUM_JS_INPUTS; i++) { - arrInputMap.push_back(static_cast(inputMap[i])); - } - for (size_t i = 0; i < ZC_NUM_JS_OUTPUTS; i++) { - arrOutputMap.push_back(static_cast(outputMap[i])); - } - - - // !!! Payment disclosure START - unsigned char buffer[32] = {0}; - memcpy(&buffer[0], &joinSplitPrivKey_[0], 32); // private key in first half of 64 byte buffer - std::vector vch(&buffer[0], &buffer[0] + 32); - uint256 joinSplitPrivKey = uint256(vch); - size_t js_index = tx_.vjoinsplit.size() - 1; - uint256 placeholder; - for (int i = 0; i < ZC_NUM_JS_OUTPUTS; i++) { - uint8_t mapped_index = outputMap[i]; - // placeholder for txid will be filled in later when tx has been finalized and signed. - PaymentDisclosureKey pdKey = {placeholder, js_index, mapped_index}; - JSOutput output = outputs[mapped_index]; - libzcash::SproutPaymentAddress zaddr = output.addr; // randomized output - PaymentDisclosureInfo pdInfo = {PAYMENT_DISCLOSURE_VERSION_EXPERIMENTAL, esk, joinSplitPrivKey, zaddr}; - paymentDisclosureData_.push_back(PaymentDisclosureKeyInfo(pdKey, pdInfo)); - - LogPrint("paymentdisclosure", "%s: Payment Disclosure: js=%d, n=%d, zaddr=%s\n", getId(), js_index, int(mapped_index), EncodePaymentAddress(zaddr)); - } - // !!! Payment disclosure END - - UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("encryptednote1", encryptedNote1)); - obj.push_back(Pair("encryptednote2", encryptedNote2)); - obj.push_back(Pair("rawtxn", HexStr(ss.begin(), ss.end()))); - obj.push_back(Pair("inputmap", arrInputMap)); - obj.push_back(Pair("outputmap", arrOutputMap)); - return obj; -} - void AsyncRPCOperation_sendmany::add_taddr_outputs_to_tx() { CMutableTransaction rawTx(tx_); From 5be12774f4e61f79969b967f458b52424e1657df Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 2 Jun 2020 02:40:18 -0400 Subject: [PATCH 038/255] desprout --- .../asyncrpcoperation_mergetoaddress.cpp | 186 ----------------- .../asyncrpcoperation_shieldcoinbase.cpp | 189 +----------------- src/wallet/wallet.cpp | 140 +------------ src/wallet/walletdb.cpp | 76 ++----- 4 files changed, 22 insertions(+), 569 deletions(-) diff --git a/src/wallet/asyncrpcoperation_mergetoaddress.cpp b/src/wallet/asyncrpcoperation_mergetoaddress.cpp index 4dace19bb..ed4efc014 100644 --- a/src/wallet/asyncrpcoperation_mergetoaddress.cpp +++ b/src/wallet/asyncrpcoperation_mergetoaddress.cpp @@ -518,186 +518,6 @@ void AsyncRPCOperation_mergetoaddress::sign_send_raw_transaction(UniValue obj) tx_ = tx; } - -UniValue AsyncRPCOperation_mergetoaddress::perform_joinsplit(MergeToAddressJSInfo& info) -{ - std::vector> witnesses; - uint256 anchor; - { - LOCK(cs_main); - anchor = pcoinsTip->GetBestAnchor(SPROUT); // As there are no inputs, ask the wallet for the best anchor - } - return perform_joinsplit(info, witnesses, anchor); -} - - -UniValue AsyncRPCOperation_mergetoaddress::perform_joinsplit(MergeToAddressJSInfo& info, std::vector& outPoints) -{ - std::vector> witnesses; - uint256 anchor; - return perform_joinsplit(info, witnesses, anchor); -} - -UniValue AsyncRPCOperation_mergetoaddress::perform_joinsplit( - MergeToAddressJSInfo& info, - std::vector> witnesses, - uint256 anchor) -{ - if (anchor.IsNull()) { - throw std::runtime_error("anchor is null"); - } - - if (witnesses.size() != info.notes.size()) { - throw runtime_error("number of notes and witnesses do not match"); - } - - if (info.notes.size() != info.zkeys.size()) { - throw runtime_error("number of notes and spending keys do not match"); - } - - for (size_t i = 0; i < witnesses.size(); i++) { - if (!witnesses[i]) { - throw runtime_error("joinsplit input could not be found in tree"); - } - info.vjsin.push_back(JSInput(*witnesses[i], info.notes[i], info.zkeys[i])); - } - - // Make sure there are two inputs and two outputs - while (info.vjsin.size() < ZC_NUM_JS_INPUTS) { - info.vjsin.push_back(JSInput()); - } - - while (info.vjsout.size() < ZC_NUM_JS_OUTPUTS) { - info.vjsout.push_back(JSOutput()); - } - - if (info.vjsout.size() != ZC_NUM_JS_INPUTS || info.vjsin.size() != ZC_NUM_JS_OUTPUTS) { - throw runtime_error("unsupported joinsplit input/output counts"); - } - - CMutableTransaction mtx(tx_); - - LogPrint("zrpcunsafe", "%s: creating joinsplit at index %d (vpub_old=%s, vpub_new=%s, in[0]=%s, in[1]=%s, out[0]=%s, out[1]=%s)\n", - getId(), - tx_.vjoinsplit.size(), - FormatMoney(info.vpub_old), FormatMoney(info.vpub_new), - FormatMoney(info.vjsin[0].note.value()), FormatMoney(info.vjsin[1].note.value()), - FormatMoney(info.vjsout[0].value), FormatMoney(info.vjsout[1].value)); - - // Generate the proof, this can take over a minute. - std::array inputs{info.vjsin[0], info.vjsin[1]}; - std::array outputs{info.vjsout[0], info.vjsout[1]}; - std::array inputMap; - std::array outputMap; - - uint256 esk; // payment disclosure - secret - - JSDescription jsdesc = JSDescription::Randomized( - *pzcashParams, - joinSplitPubKey_, - anchor, - inputs, - outputs, - inputMap, - outputMap, - info.vpub_old, - info.vpub_new, - !this->testmode, - &esk); // parameter expects pointer to esk, so pass in address - { - auto verifier = libzcash::ProofVerifier::Strict(); - if (!(jsdesc.Verify(*pzcashParams, verifier, joinSplitPubKey_))) { - throw std::runtime_error("error verifying joinsplit"); - } - } - - mtx.vjoinsplit.push_back(jsdesc); - - // Empty output script. - CScript scriptCode; - CTransaction signTx(mtx); - uint256 dataToBeSigned = SignatureHash(scriptCode, signTx, NOT_AN_INPUT, SIGHASH_ALL, 0, consensusBranchId_); - - // Add the signature - if (!(crypto_sign_detached(&mtx.joinSplitSig[0], NULL, - dataToBeSigned.begin(), 32, - joinSplitPrivKey_) == 0)) { - throw std::runtime_error("crypto_sign_detached failed"); - } - - // Sanity check - if (!(crypto_sign_verify_detached(&mtx.joinSplitSig[0], - dataToBeSigned.begin(), 32, - mtx.joinSplitPubKey.begin()) == 0)) { - throw std::runtime_error("crypto_sign_verify_detached failed"); - } - - CTransaction rawTx(mtx); - tx_ = rawTx; - - CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - ss << rawTx; - - std::string encryptedNote1; - std::string encryptedNote2; - { - CDataStream ss2(SER_NETWORK, PROTOCOL_VERSION); - ss2 << ((unsigned char)0x00); - ss2 << jsdesc.ephemeralKey; - ss2 << jsdesc.ciphertexts[0]; - ss2 << jsdesc.h_sig(*pzcashParams, joinSplitPubKey_); - - encryptedNote1 = HexStr(ss2.begin(), ss2.end()); - } - { - CDataStream ss2(SER_NETWORK, PROTOCOL_VERSION); - ss2 << ((unsigned char)0x01); - ss2 << jsdesc.ephemeralKey; - ss2 << jsdesc.ciphertexts[1]; - ss2 << jsdesc.h_sig(*pzcashParams, joinSplitPubKey_); - - encryptedNote2 = HexStr(ss2.begin(), ss2.end()); - } - - UniValue arrInputMap(UniValue::VARR); - UniValue arrOutputMap(UniValue::VARR); - for (size_t i = 0; i < ZC_NUM_JS_INPUTS; i++) { - arrInputMap.push_back(static_cast(inputMap[i])); - } - for (size_t i = 0; i < ZC_NUM_JS_OUTPUTS; i++) { - arrOutputMap.push_back(static_cast(outputMap[i])); - } - - - // !!! Payment disclosure START - unsigned char buffer[32] = {0}; - memcpy(&buffer[0], &joinSplitPrivKey_[0], 32); // private key in first half of 64 byte buffer - std::vector vch(&buffer[0], &buffer[0] + 32); - uint256 joinSplitPrivKey = uint256(vch); - size_t js_index = tx_.vjoinsplit.size() - 1; - uint256 placeholder; - for (int i = 0; i < ZC_NUM_JS_OUTPUTS; i++) { - uint8_t mapped_index = outputMap[i]; - // placeholder for txid will be filled in later when tx has been finalized and signed. - PaymentDisclosureKey pdKey = {placeholder, js_index, mapped_index}; - JSOutput output = outputs[mapped_index]; - libzcash::SproutPaymentAddress zaddr = output.addr; // randomized output - PaymentDisclosureInfo pdInfo = {PAYMENT_DISCLOSURE_VERSION_EXPERIMENTAL, esk, joinSplitPrivKey, zaddr}; - paymentDisclosureData_.push_back(PaymentDisclosureKeyInfo(pdKey, pdInfo)); - - LogPrint("paymentdisclosure", "%s: Payment Disclosure: js=%d, n=%d, zaddr=%s\n", getId(), js_index, int(mapped_index), EncodePaymentAddress(zaddr)); - } - // !!! Payment disclosure END - - UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("encryptednote1", encryptedNote1)); - obj.push_back(Pair("encryptednote2", encryptedNote2)); - obj.push_back(Pair("rawtxn", HexStr(ss.begin(), ss.end()))); - obj.push_back(Pair("inputmap", arrInputMap)); - obj.push_back(Pair("outputmap", arrOutputMap)); - return obj; -} - std::array AsyncRPCOperation_mergetoaddress::get_memo_from_hex_string(std::string s) { std::array memo = {{0x00}}; @@ -764,9 +584,6 @@ void AsyncRPCOperation_mergetoaddress::unlock_utxos() { */ void AsyncRPCOperation_mergetoaddress::lock_notes() { LOCK2(cs_main, pwalletMain->cs_wallet); - for (auto note : sproutNoteInputs_) { - pwalletMain->LockNote(std::get<0>(note)); - } for (auto note : saplingNoteInputs_) { pwalletMain->LockNote(std::get<0>(note)); } @@ -777,9 +594,6 @@ void AsyncRPCOperation_mergetoaddress::lock_notes() { */ void AsyncRPCOperation_mergetoaddress::unlock_notes() { LOCK2(cs_main, pwalletMain->cs_wallet); - for (auto note : sproutNoteInputs_) { - pwalletMain->UnlockNote(std::get<0>(note)); - } for (auto note : saplingNoteInputs_) { pwalletMain->UnlockNote(std::get<0>(note)); } diff --git a/src/wallet/asyncrpcoperation_shieldcoinbase.cpp b/src/wallet/asyncrpcoperation_shieldcoinbase.cpp index 55feb2cbf..5db0ca51b 100644 --- a/src/wallet/asyncrpcoperation_shieldcoinbase.cpp +++ b/src/wallet/asyncrpcoperation_shieldcoinbase.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2017 The Zcash developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -234,37 +235,6 @@ bool AsyncRPCOperation_shieldcoinbase::main_impl() { return boost::apply_visitor(ShieldToAddress(this, sendAmount), tozaddr_); } -bool ShieldToAddress::operator()(const libzcash::SproutPaymentAddress &zaddr) const { - // update the transaction with these inputs - CMutableTransaction rawTx(m_op->tx_); - for (ShieldCoinbaseUTXO & t : m_op->inputs_) { - CTxIn in(COutPoint(t.txid, t.vout)); - if (t.amount >= ASSETCHAINS_TIMELOCKGTE) - in.nSequence = 0xfffffffe; - rawTx.vin.push_back(in); - } - m_op->tx_ = CTransaction(rawTx); - - // Prepare raw transaction to handle JoinSplits - CMutableTransaction mtx(m_op->tx_); - crypto_sign_keypair(m_op->joinSplitPubKey_.begin(), m_op->joinSplitPrivKey_); - mtx.joinSplitPubKey = m_op->joinSplitPubKey_; - m_op->tx_ = CTransaction(mtx); - - // Create joinsplit - UniValue obj(UniValue::VOBJ); - ShieldCoinbaseJSInfo info; - info.vpub_old = sendAmount; - info.vpub_new = 0; - JSOutput jso = JSOutput(zaddr, sendAmount); - info.vjsout.push_back(jso); - obj = m_op->perform_joinsplit(info); - - m_op->sign_send_raw_transaction(obj); - return true; -} - - extern UniValue signrawtransaction(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue sendrawtransaction(const UniValue& params, bool fHelp, const CPubKey& mypk); @@ -406,163 +376,6 @@ void AsyncRPCOperation_shieldcoinbase::sign_send_raw_transaction(UniValue obj) } -UniValue AsyncRPCOperation_shieldcoinbase::perform_joinsplit(ShieldCoinbaseJSInfo & info) { - uint32_t consensusBranchId; - uint256 anchor; - { - LOCK(cs_main); - consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus()); - anchor = pcoinsTip->GetBestAnchor(SPROUT); - } - - - if (anchor.IsNull()) { - throw std::runtime_error("anchor is null"); - } - - // Make sure there are two inputs and two outputs - while (info.vjsin.size() < ZC_NUM_JS_INPUTS) { - info.vjsin.push_back(JSInput()); - } - - while (info.vjsout.size() < ZC_NUM_JS_OUTPUTS) { - info.vjsout.push_back(JSOutput()); - } - - if (info.vjsout.size() != ZC_NUM_JS_INPUTS || info.vjsin.size() != ZC_NUM_JS_OUTPUTS) { - throw runtime_error("unsupported joinsplit input/output counts"); - } - - CMutableTransaction mtx(tx_); - - LogPrint("zrpcunsafe", "%s: creating joinsplit at index %d (vpub_old=%s, vpub_new=%s, in[0]=%s, in[1]=%s, out[0]=%s, out[1]=%s)\n", - getId(), - tx_.vjoinsplit.size(), - FormatMoney(info.vpub_old), FormatMoney(info.vpub_new), - FormatMoney(info.vjsin[0].note.value()), FormatMoney(info.vjsin[1].note.value()), - FormatMoney(info.vjsout[0].value), FormatMoney(info.vjsout[1].value) - ); - - // Generate the proof, this can take over a minute. - std::array inputs - {info.vjsin[0], info.vjsin[1]}; - std::array outputs - {info.vjsout[0], info.vjsout[1]}; - - std::array inputMap; - std::array outputMap; - - uint256 esk; // payment disclosure - secret - - JSDescription jsdesc = JSDescription::Randomized( - *pzcashParams, - joinSplitPubKey_, - anchor, - inputs, - outputs, - inputMap, - outputMap, - info.vpub_old, - info.vpub_new, - !this->testmode, - &esk); // parameter expects pointer to esk, so pass in address - { - auto verifier = libzcash::ProofVerifier::Strict(); - if (!(jsdesc.Verify(*pzcashParams, verifier, joinSplitPubKey_))) { - throw std::runtime_error("error verifying joinsplit"); - } - } - - mtx.vjoinsplit.push_back(jsdesc); - - // Empty output script. - CScript scriptCode; - CTransaction signTx(mtx); - uint256 dataToBeSigned = SignatureHash(scriptCode, signTx, NOT_AN_INPUT, SIGHASH_ALL, 0, consensusBranchId); - - // Add the signature - if (!(crypto_sign_detached(&mtx.joinSplitSig[0], NULL, - dataToBeSigned.begin(), 32, - joinSplitPrivKey_ - ) == 0)) - { - throw std::runtime_error("crypto_sign_detached failed"); - } - - // Sanity check - if (!(crypto_sign_verify_detached(&mtx.joinSplitSig[0], - dataToBeSigned.begin(), 32, - mtx.joinSplitPubKey.begin() - ) == 0)) - { - throw std::runtime_error("crypto_sign_verify_detached failed"); - } - - CTransaction rawTx(mtx); - tx_ = rawTx; - - CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - ss << rawTx; - - std::string encryptedNote1; - std::string encryptedNote2; - { - CDataStream ss2(SER_NETWORK, PROTOCOL_VERSION); - ss2 << ((unsigned char) 0x00); - ss2 << jsdesc.ephemeralKey; - ss2 << jsdesc.ciphertexts[0]; - ss2 << jsdesc.h_sig(*pzcashParams, joinSplitPubKey_); - - encryptedNote1 = HexStr(ss2.begin(), ss2.end()); - } - { - CDataStream ss2(SER_NETWORK, PROTOCOL_VERSION); - ss2 << ((unsigned char) 0x01); - ss2 << jsdesc.ephemeralKey; - ss2 << jsdesc.ciphertexts[1]; - ss2 << jsdesc.h_sig(*pzcashParams, joinSplitPubKey_); - - encryptedNote2 = HexStr(ss2.begin(), ss2.end()); - } - - UniValue arrInputMap(UniValue::VARR); - UniValue arrOutputMap(UniValue::VARR); - for (size_t i = 0; i < ZC_NUM_JS_INPUTS; i++) { - arrInputMap.push_back(static_cast(inputMap[i])); - } - for (size_t i = 0; i < ZC_NUM_JS_OUTPUTS; i++) { - arrOutputMap.push_back(static_cast(outputMap[i])); - } - - // !!! Payment disclosure START - unsigned char buffer[32] = {0}; - memcpy(&buffer[0], &joinSplitPrivKey_[0], 32); // private key in first half of 64 byte buffer - std::vector vch(&buffer[0], &buffer[0] + 32); - uint256 joinSplitPrivKey = uint256(vch); - size_t js_index = tx_.vjoinsplit.size() - 1; - uint256 placeholder; - for (int i = 0; i < ZC_NUM_JS_OUTPUTS; i++) { - uint8_t mapped_index = outputMap[i]; - // placeholder for txid will be filled in later when tx has been finalized and signed. - PaymentDisclosureKey pdKey = {placeholder, js_index, mapped_index}; - JSOutput output = outputs[mapped_index]; - libzcash::SproutPaymentAddress zaddr = output.addr; // randomized output - PaymentDisclosureInfo pdInfo = {PAYMENT_DISCLOSURE_VERSION_EXPERIMENTAL, esk, joinSplitPrivKey, zaddr}; - paymentDisclosureData_.push_back(PaymentDisclosureKeyInfo(pdKey, pdInfo)); - - LogPrint("paymentdisclosure", "%s: Payment Disclosure: js=%d, n=%d, zaddr=%s\n", getId(), js_index, int(mapped_index), EncodePaymentAddress(zaddr)); - } - // !!! Payment disclosure END - - UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("encryptednote1", encryptedNote1)); - obj.push_back(Pair("encryptednote2", encryptedNote2)); - obj.push_back(Pair("rawtxn", HexStr(ss.begin(), ss.end()))); - obj.push_back(Pair("inputmap", arrInputMap)); - obj.push_back(Pair("outputmap", arrOutputMap)); - return obj; -} - /** * Override getStatus() to append the operation's context object to the default status object. */ diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index d0d82a0e8..4be804abb 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers -// Copyright (c) 2019 The Hush developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -314,22 +314,11 @@ bool CWallet::LoadKeyMetadata(const CPubKey &pubkey, const CKeyMetadata &meta) return true; } -bool CWallet::LoadZKeyMetadata(const SproutPaymentAddress &addr, const CKeyMetadata &meta) -{ - AssertLockHeld(cs_wallet); // mapSproutZKeyMetadata - mapSproutZKeyMetadata[addr] = meta; - return true; -} - bool CWallet::LoadCryptedKey(const CPubKey &vchPubKey, const std::vector &vchCryptedSecret) { return CCryptoKeyStore::AddCryptedKey(vchPubKey, vchCryptedSecret); } -bool CWallet::LoadCryptedZKey(const libzcash::SproutPaymentAddress &addr, const libzcash::ReceivingKey &rk, const std::vector &vchCryptedSecret) -{ - return CCryptoKeyStore::AddCryptedSproutSpendingKey(addr, rk, vchCryptedSecret); -} bool CWallet::LoadCryptedSaplingZKey( const libzcash::SaplingExtendedFullViewingKey &extfvk, @@ -357,10 +346,6 @@ bool CWallet::LoadSaplingPaymentAddress( return CCryptoKeyStore::AddSaplingIncomingViewingKey(ivk, addr); } -bool CWallet::LoadZKey(const libzcash::SproutSpendingKey &key) -{ - return CCryptoKeyStore::AddSproutSpendingKey(key); -} bool CWallet::LoadCScript(const CScript& redeemScript) { @@ -650,20 +635,6 @@ set CWallet::GetConflicts(const uint256& txid) const result.insert(it->second); } - std::pair range_n; - - for (const JSDescription& jsdesc : wtx.vjoinsplit) { - for (const uint256& nullifier : jsdesc.nullifiers) { - if (mapTxSproutNullifiers.count(nullifier) <= 1) { - continue; // No conflict if zero or one spends - } - range_n = mapTxSproutNullifiers.equal_range(nullifier); - for (TxNullifiers::const_iterator it = range_n.first; it != range_n.second; ++it) { - result.insert(it->second); - } - } - } - std::pair range_o; for (const SpendDescription &spend : wtx.vShieldedSpend) { @@ -1367,7 +1338,6 @@ void CWallet::UpdateNullifierNoteMapForBlock(const CBlock *pblock) { auto hash = tx.GetHash(); bool txIsOurs = mapWallet.count(hash); if (txIsOurs) { - UpdateSproutNullifierNoteMapWithTx(mapWallet[hash]); UpdateSaplingNullifierNoteMapWithTx(mapWallet[hash]); } } @@ -1750,7 +1720,7 @@ void CWallet::GetSaplingNoteWitnesses(std::vector notes, } else { if(*rt == witnesses[i]->root()) { // Something is fucky - std::string err = "CWallet::GetSaplingNoteWitnesses: Invalid witness root:" << rt.GetHash(); + std::string err = "CWallet::GetSaplingNoteWitnesses: Invalid witness root!"; throw std::logic_error(err); } @@ -2104,10 +2074,6 @@ bool CWallet::LoadCryptedHDSeed(const uint256& seedFp, const std::vector& listReceived, if (isFromMyTaddr) { CAmount myVpubOld = 0; CAmount myVpubNew = 0; - for (const JSDescription& js : vjoinsplit) { - bool fMyJSDesc = false; - - // Check input side - for (const uint256& nullifier : js.nullifiers) { - if (pwallet->IsSproutNullifierFromMe(nullifier)) { - fMyJSDesc = true; - break; - } - } - - // Check output side - if (!fMyJSDesc) { - for (const std::pair nd : this->mapSproutNoteData) { - if (nd.first.js < vjoinsplit.size() && nd.first.n < vjoinsplit[nd.first.js].ciphertexts.size()) { - fMyJSDesc = true; - break; - } - } - } - - if (fMyJSDesc) { - myVpubOld += js.vpub_old; - myVpubNew += js.vpub_new; - } - - if (!MoneyRange(js.vpub_old) || !MoneyRange(js.vpub_new) || !MoneyRange(myVpubOld) || !MoneyRange(myVpubNew)) { - throw std::runtime_error("CWalletTx::GetAmounts: value out of range"); - } - } // Create an output for the value taken from or added to the transparent value pool by JoinSplits if (myVpubOld > myVpubNew) { @@ -4580,38 +4516,6 @@ void CWallet::ListLockedCoins(std::vector& vOutpts) // Note Locking Operations -void CWallet::LockNote(const JSOutPoint& output) -{ - AssertLockHeld(cs_wallet); // setLockedSproutNotes - setLockedSproutNotes.insert(output); -} - -void CWallet::UnlockNote(const JSOutPoint& output) -{ - AssertLockHeld(cs_wallet); // setLockedSproutNotes - setLockedSproutNotes.erase(output); -} - -void CWallet::UnlockAllSproutNotes() -{ - AssertLockHeld(cs_wallet); // setLockedSproutNotes - setLockedSproutNotes.clear(); -} - -bool CWallet::IsLockedNote(const JSOutPoint& outpt) const -{ - AssertLockHeld(cs_wallet); // setLockedSproutNotes - - return (setLockedSproutNotes.count(outpt) > 0); -} - -std::vector CWallet::ListLockedSproutNotes() -{ - AssertLockHeld(cs_wallet); // setLockedSproutNotes - std::vector vOutpts(setLockedSproutNotes.begin(), setLockedSproutNotes.end()); - return vOutpts; -} - void CWallet::LockNote(const SaplingOutPoint& output) { AssertLockHeld(cs_wallet); @@ -4988,11 +4892,6 @@ void CWallet::GetFilteredNotes( // Shielded key and address generalizations // -bool IncomingViewingKeyBelongsToWallet::operator()(const libzcash::SproutPaymentAddress &zaddr) const -{ - return m_wallet->HaveSproutViewingKey(zaddr); -} - bool IncomingViewingKeyBelongsToWallet::operator()(const libzcash::SaplingPaymentAddress &zaddr) const { libzcash::SaplingIncomingViewingKey ivk; @@ -5004,11 +4903,6 @@ bool IncomingViewingKeyBelongsToWallet::operator()(const libzcash::InvalidEncodi return false; } -bool PaymentAddressBelongsToWallet::operator()(const libzcash::SproutPaymentAddress &zaddr) const -{ - return m_wallet->HaveSproutSpendingKey(zaddr) || m_wallet->HaveSproutViewingKey(zaddr); -} - bool PaymentAddressBelongsToWallet::operator()(const libzcash::SaplingPaymentAddress &zaddr) const { libzcash::SaplingIncomingViewingKey ivk; @@ -5024,11 +4918,6 @@ bool PaymentAddressBelongsToWallet::operator()(const libzcash::InvalidEncoding& return false; } -bool HaveSpendingKeyForPaymentAddress::operator()(const libzcash::SproutPaymentAddress &zaddr) const -{ - return m_wallet->HaveSproutSpendingKey(zaddr); -} - bool HaveSpendingKeyForPaymentAddress::operator()(const libzcash::SaplingPaymentAddress &zaddr) const { libzcash::SaplingIncomingViewingKey ivk; @@ -5044,17 +4933,6 @@ bool HaveSpendingKeyForPaymentAddress::operator()(const libzcash::InvalidEncodin return false; } -boost::optional GetSpendingKeyForPaymentAddress::operator()( - const libzcash::SproutPaymentAddress &zaddr) const -{ - libzcash::SproutSpendingKey k; - if (m_wallet->GetSproutSpendingKey(zaddr, k)) { - return libzcash::SpendingKey(k); - } else { - return boost::none; - } -} - boost::optional GetSpendingKeyForPaymentAddress::operator()( const libzcash::SaplingPaymentAddress &zaddr) const { @@ -5073,20 +4951,6 @@ boost::optional GetSpendingKeyForPaymentAddress::operator return libzcash::SpendingKey(); } -SpendingKeyAddResult AddSpendingKeyToWallet::operator()(const libzcash::SproutSpendingKey &sk) const { - auto addr = sk.address(); - if (log){ - LogPrint("zrpc", "Importing zaddr %s...\n", EncodePaymentAddress(addr)); - } - if (m_wallet->HaveSproutSpendingKey(addr)) { - return KeyAlreadyExists; - } else if (m_wallet-> AddSproutZKey(sk)) { - m_wallet->mapSproutZKeyMetadata[addr].nCreateTime = nTime; - return KeyAdded; - } else { - return KeyNotAdded; - } -} SpendingKeyAddResult AddSpendingKeyToWallet::operator()(const libzcash::SaplingExtendedSpendingKey &sk) const { auto fvk = sk.expsk.full_viewing_key(); diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 952a76735..1177bbedd 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers -// Copyright (c) 2019 The Hush developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -124,26 +124,6 @@ bool CWalletDB::WriteCryptedKey(const CPubKey& vchPubKey, return true; } -bool CWalletDB::WriteCryptedZKey(const libzcash::SproutPaymentAddress & addr, - const libzcash::ReceivingKey &rk, - const std::vector& vchCryptedSecret, - const CKeyMetadata &keyMeta) -{ - const bool fEraseUnencryptedKey = true; - nWalletDBUpdated++; - - if (!Write(std::make_pair(std::string("zkeymeta"), addr), keyMeta)) - return false; - - if (!Write(std::make_pair(std::string("czkey"), addr), std::make_pair(rk, vchCryptedSecret), false)) - return false; - if (fEraseUnencryptedKey) - { - Erase(std::make_pair(std::string("zkey"), addr)); - } - return true; -} - bool CWalletDB::WriteCryptedSaplingZKey( const libzcash::SaplingExtendedFullViewingKey &extfvk, const std::vector& vchCryptedSecret, @@ -172,16 +152,6 @@ bool CWalletDB::WriteMasterKey(unsigned int nID, const CMasterKey& kMasterKey) return Write(std::make_pair(std::string("mkey"), nID), kMasterKey, true); } -bool CWalletDB::WriteZKey(const libzcash::SproutPaymentAddress& addr, const libzcash::SproutSpendingKey& key, const CKeyMetadata &keyMeta) -{ - nWalletDBUpdated++; - - if (!Write(std::make_pair(std::string("zkeymeta"), addr), keyMeta)) - return false; - - // pair is: tuple_key("zkey", paymentaddress) --> secretkey - return Write(std::make_pair(std::string("zkey"), addr), key, false); -} bool CWalletDB::WriteSaplingZKey(const libzcash::SaplingIncomingViewingKey &ivk, const libzcash::SaplingExtendedSpendingKey &key, const CKeyMetadata &keyMeta) @@ -203,18 +173,6 @@ bool CWalletDB::WriteSaplingPaymentAddress( return Write(std::make_pair(std::string("sapzaddr"), addr), ivk, false); } -bool CWalletDB::WriteSproutViewingKey(const libzcash::SproutViewingKey &vk) -{ - nWalletDBUpdated++; - return Write(std::make_pair(std::string("vkey"), vk), '1'); -} - -bool CWalletDB::EraseSproutViewingKey(const libzcash::SproutViewingKey &vk) -{ - nWalletDBUpdated++; - return Erase(std::make_pair(std::string("vkey"), vk)); -} - bool CWalletDB::WriteCScript(const uint160& hash, const CScript& redeemScript) { nWalletDBUpdated++; @@ -552,6 +510,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, } else if (strType == "vkey") { + /* libzcash::SproutViewingKey vk; ssKey >> vk; char fYes; @@ -559,24 +518,27 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, if (fYes == '1') pwallet->LoadSproutViewingKey(vk); - // Viewing keys have no birthday information for now, - // so set the wallet birthday to the beginning of time. + Viewing keys have no birthday information for now, + so set the wallet birthday to the beginning of time. pwallet->nTimeFirstKey = 1; + */ } else if (strType == "zkey") { + /* libzcash::SproutPaymentAddress addr; ssKey >> addr; libzcash::SproutSpendingKey key; ssValue >> key; - if (!pwallet->LoadZKey(key)) - { - strErr = "Error reading wallet database: LoadZKey failed"; - return false; - } + //if (!pwallet->LoadZKey(key)) + //{ + // strErr = "Error reading wallet database: LoadZKey failed"; + // return false; + //} wss.nZKeys++; + */ } else if (strType == "sapzkey") { @@ -701,12 +663,12 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, ssValue >> vchCryptedSecret; wss.nCKeys++; - if (!pwallet->LoadCryptedZKey(addr, rk, vchCryptedSecret)) - { - strErr = "Error reading wallet database: LoadCryptedZKey failed"; - return false; - } - wss.fIsEncrypted = true; + //if (!pwallet->LoadCryptedZKey(addr, rk, vchCryptedSecret)) + //{ + // strErr = "Error reading wallet database: LoadCryptedZKey failed"; + // return false; + //} + //wss.fIsEncrypted = true; } else if (strType == "csapzkey") { @@ -748,7 +710,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, ssValue >> keyMeta; wss.nZKeyMeta++; - pwallet->LoadZKeyMetadata(addr, keyMeta); + // pwallet->LoadZKeyMetadata(addr, keyMeta); // ignore earliest key creation time as taddr will exist before any zaddr } From 62d438e0de9efca81ca6d0de3cec348fea8edfdf Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 2 Jun 2020 02:52:19 -0400 Subject: [PATCH 039/255] desprout --- src/gtest/test_joinsplit.cpp | 585 ------------------ src/gtest/test_keystore.cpp | 95 --- src/keystore.h | 85 +-- ...asyncrpcoperation_saplingconsolidation.cpp | 4 +- 4 files changed, 6 insertions(+), 763 deletions(-) delete mode 100644 src/gtest/test_joinsplit.cpp diff --git a/src/gtest/test_joinsplit.cpp b/src/gtest/test_joinsplit.cpp deleted file mode 100644 index 8032fc972..000000000 --- a/src/gtest/test_joinsplit.cpp +++ /dev/null @@ -1,585 +0,0 @@ -#include - -#include "utilstrencodings.h" - -#include -#include - -#include "zcash/prf.h" -#include "util.h" -#include "streams.h" -#include "version.h" -#include "serialize.h" -#include "primitives/transaction.h" -#include "zcash/JoinSplit.hpp" -#include "zcash/Note.hpp" -#include "zcash/NoteEncryption.hpp" -#include "zcash/IncrementalMerkleTree.hpp" - -#include - -using namespace libzcash; - -extern ZCJoinSplit* params; - -// Make the Groth proof for a Sprout statement, -// and store the result in a JSDescription object. -JSDescription makeSproutProof( - ZCJoinSplit& js, - const std::array& inputs, - const std::array& outputs, - const uint256& joinSplitPubKey, - uint64_t vpub_old, - uint64_t vpub_new, - const uint256& rt -){ - return JSDescription(js, joinSplitPubKey, rt, inputs, outputs, vpub_old, vpub_new); -} - -bool verifySproutProof( - ZCJoinSplit& js, - const JSDescription& jsdesc, - const uint256& joinSplitPubKey -) -{ - auto verifier = libzcash::ProofVerifier::Strict(); - return jsdesc.Verify(js, verifier, joinSplitPubKey); -} - - -void test_full_api(ZCJoinSplit* js) -{ - // Create verification context. - auto verifier = libzcash::ProofVerifier::Strict(); - - // The recipient's information. - SproutSpendingKey recipient_key = SproutSpendingKey::random(); - SproutPaymentAddress recipient_addr = recipient_key.address(); - - // Create the commitment tree - SproutMerkleTree tree; - - // Set up a JoinSplit description - uint64_t vpub_old = 10; - uint64_t vpub_new = 0; - uint256 joinSplitPubKey = random_uint256(); - uint256 rt = tree.root(); - JSDescription jsdesc; - - { - std::array inputs = { - JSInput(), // dummy input - JSInput() // dummy input - }; - - std::array outputs = { - JSOutput(recipient_addr, 10), - JSOutput() // dummy output - }; - - std::array output_notes; - - // Perform the proofs - jsdesc = makeSproutProof( - *js, - inputs, - outputs, - joinSplitPubKey, - vpub_old, - vpub_new, - rt - ); - } - - // Verify both PHGR and Groth Proof: - ASSERT_TRUE(verifySproutProof(*js, jsdesc, joinSplitPubKey)); - - { - SproutMerkleTree tree; - JSDescription jsdesc2; - // Recipient should decrypt - // Now the recipient should spend the money again - auto h_sig = js->h_sig(jsdesc.randomSeed, jsdesc.nullifiers, joinSplitPubKey); - ZCNoteDecryption decryptor(recipient_key.receiving_key()); - - auto note_pt = SproutNotePlaintext::decrypt( - decryptor, - jsdesc.ciphertexts[0], - jsdesc.ephemeralKey, - h_sig, - 0 - ); - - auto decrypted_note = note_pt.note(recipient_addr); - - ASSERT_TRUE(decrypted_note.value() == 10); - - // Insert the commitments from the last tx into the tree - tree.append(jsdesc.commitments[0]); - auto witness_recipient = tree.witness(); - tree.append(jsdesc.commitments[1]); - witness_recipient.append(jsdesc.commitments[1]); - vpub_old = 0; - vpub_new = 1; - rt = tree.root(); - auto joinSplitPubKey2 = random_uint256(); - - { - std::array inputs = { - JSInput(), // dummy input - JSInput(witness_recipient, decrypted_note, recipient_key) - }; - - SproutSpendingKey second_recipient = SproutSpendingKey::random(); - SproutPaymentAddress second_addr = second_recipient.address(); - - std::array outputs = { - JSOutput(second_addr, 9), - JSOutput() // dummy output - }; - - std::array output_notes; - - - // Perform the proofs - jsdesc2 = makeSproutProof( - *js, - inputs, - outputs, - joinSplitPubKey2, - vpub_old, - vpub_new, - rt - ); - - } - - - // Verify Groth Proof: - ASSERT_TRUE(verifySproutProof(*js, jsdesc2, joinSplitPubKey2)); - } -} - -// Invokes the API (but does not compute a proof) -// to test exceptions -void invokeAPI( - ZCJoinSplit* js, - const std::array& inputs, - const std::array& outputs, - uint64_t vpub_old, - uint64_t vpub_new, - const uint256& rt -) { - uint256 ephemeralKey; - uint256 randomSeed; - uint256 joinSplitPubKey = random_uint256(); - std::array macs; - std::array nullifiers; - std::array commitments; - std::array ciphertexts; - - std::array output_notes; - - // Groth - SproutProof proof = js->prove( - inputs, - outputs, - output_notes, - ciphertexts, - ephemeralKey, - joinSplitPubKey, - randomSeed, - macs, - nullifiers, - commitments, - vpub_old, - vpub_new, - rt, - false - ); -} - -void invokeAPIFailure( - ZCJoinSplit* js, - const std::array& inputs, - const std::array& outputs, - uint64_t vpub_old, - uint64_t vpub_new, - const uint256& rt, - std::string reason -) -{ - try { - invokeAPI(js, inputs, outputs, vpub_old, vpub_new, rt); - FAIL() << "It worked, when it shouldn't have!"; - } catch(std::invalid_argument const & err) { - EXPECT_EQ(err.what(), reason); - } catch(...) { - FAIL() << "Expected invalid_argument exception."; - } -} - -TEST(joinsplit, h_sig) -{ -/* -// by Taylor Hornby - -import pyblake2 -import binascii - -def hSig(randomSeed, nf1, nf2, joinSplitPubKey): - return pyblake2.blake2b( - data=(randomSeed + nf1 + nf2 + joinSplitPubKey), - digest_size=32, - person=b"ZcashComputehSig" - ).digest() - -INCREASING = "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F" - -TEST_VECTORS = [ - [b"a" * 32, b"b" * 32, b"c" * 32, b"d" * 32], - [b"\x00" * 32, b"\x00" * 32, b"\x00" * 32, b"\x00" * 32], - [b"\xFF" * 32, b"\xFF" * 32, b"\xFF" * 32, b"\xFF" * 32], - [INCREASING, INCREASING, INCREASING, INCREASING] -] - -for test_input in TEST_VECTORS: - print "---" - print "\"" + binascii.hexlify(test_input[0][::-1]) + "\"" - print "\"" + binascii.hexlify(test_input[1][::-1]) + "\"" - print "\"" + binascii.hexlify(test_input[2][::-1]) + "\"" - print "\"" + binascii.hexlify(test_input[3][::-1]) + "\"" - print "\"" + binascii.hexlify(hSig(test_input[0], test_input[1], test_input[2], test_input[3])[::-1]) + "\"" -*/ - - std::vector> tests = { - { - "6161616161616161616161616161616161616161616161616161616161616161", - "6262626262626262626262626262626262626262626262626262626262626262", - "6363636363636363636363636363636363636363636363636363636363636363", - "6464646464646464646464646464646464646464646464646464646464646464", - "a8cba69f1fa329c055756b4af900f8a00b61e44f4cb8a1824ceb58b90a5b8113" - }, - { - "0000000000000000000000000000000000000000000000000000000000000000", - "0000000000000000000000000000000000000000000000000000000000000000", - "0000000000000000000000000000000000000000000000000000000000000000", - "0000000000000000000000000000000000000000000000000000000000000000", - "697322276b5dd93b12fb1fcbd2144b2960f24c73aac6c6a0811447be1e7f1e19" - }, - { - "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", - "4961048919f0ca79d49c9378c36a91a8767060001f4212fe6f7d426f3ccf9f32" - }, - { - "1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100", - "1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100", - "1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100", - "1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100", - "b61110ec162693bc3d9ca7fb0eec3afd2e278e2f41394b3ff11d7cb761ad4b27" - } - }; - - BOOST_FOREACH(std::vector& v, tests) { - auto expected = ZCJoinSplit::h_sig( - uint256S(v[0]), - {uint256S(v[1]), uint256S(v[2])}, - uint256S(v[3]) - ); - - EXPECT_EQ(expected, uint256S(v[4])); - } -} - -void increment_note_witnesses( - const uint256& element, - std::vector& witnesses, - SproutMerkleTree& tree -) -{ - tree.append(element); - for (SproutWitness& w : witnesses) { - w.append(element); - } - witnesses.push_back(tree.witness()); -} - -TEST(joinsplit, full_api_test) -{ - { - std::vector witnesses; - SproutMerkleTree tree; - increment_note_witnesses(uint256(), witnesses, tree); - SproutSpendingKey sk = SproutSpendingKey::random(); - SproutPaymentAddress addr = sk.address(); - SproutNote note1(addr.a_pk, 100, random_uint256(), random_uint256()); - increment_note_witnesses(note1.cm(), witnesses, tree); - SproutNote note2(addr.a_pk, 100, random_uint256(), random_uint256()); - increment_note_witnesses(note2.cm(), witnesses, tree); - SproutNote note3(addr.a_pk, 2100000000000001, random_uint256(), random_uint256()); - increment_note_witnesses(note3.cm(), witnesses, tree); - SproutNote note4(addr.a_pk, 1900000000000000, random_uint256(), random_uint256()); - increment_note_witnesses(note4.cm(), witnesses, tree); - SproutNote note5(addr.a_pk, 1900000000000000, random_uint256(), random_uint256()); - increment_note_witnesses(note5.cm(), witnesses, tree); - - // Should work - invokeAPI(params, - { - JSInput(), - JSInput() - }, - { - JSOutput(), - JSOutput() - }, - 0, - 0, - tree.root()); - - // lhs > MAX_MONEY - invokeAPIFailure(params, - { - JSInput(), - JSInput() - }, - { - JSOutput(), - JSOutput() - }, - 2100000000000001, - 0, - tree.root(), - "nonsensical vpub_old value"); - - // rhs > MAX_MONEY - invokeAPIFailure(params, - { - JSInput(), - JSInput() - }, - { - JSOutput(), - JSOutput() - }, - 0, - 2100000000000001, - tree.root(), - "nonsensical vpub_new value"); - - // input witness for the wrong element - invokeAPIFailure(params, - { - JSInput(witnesses[0], note1, sk), - JSInput() - }, - { - JSOutput(), - JSOutput() - }, - 0, - 100, - tree.root(), - "witness of wrong element for joinsplit input"); - - // input witness doesn't match up with - // real root - invokeAPIFailure(params, - { - JSInput(witnesses[1], note1, sk), - JSInput() - }, - { - JSOutput(), - JSOutput() - }, - 0, - 100, - uint256(), - "joinsplit not anchored to the correct root"); - - // input is in the tree now! this should work - invokeAPI(params, - { - JSInput(witnesses[1], note1, sk), - JSInput() - }, - { - JSOutput(), - JSOutput() - }, - 0, - 100, - tree.root()); - - // Wrong secret key - invokeAPIFailure(params, - { - JSInput(witnesses[1], note1, SproutSpendingKey::random()), - JSInput() - }, - { - JSOutput(), - JSOutput() - }, - 0, - 0, - tree.root(), - "input note not authorized to spend with given key"); - - // Absurd input value - invokeAPIFailure(params, - { - JSInput(witnesses[3], note3, sk), - JSInput() - }, - { - JSOutput(), - JSOutput() - }, - 0, - 0, - tree.root(), - "nonsensical input note value"); - - // Absurd total input value - invokeAPIFailure(params, - { - JSInput(witnesses[4], note4, sk), - JSInput(witnesses[5], note5, sk) - }, - { - JSOutput(), - JSOutput() - }, - 0, - 0, - tree.root(), - "nonsensical left hand size of joinsplit balance"); - - // Absurd output value - invokeAPIFailure(params, - { - JSInput(), - JSInput() - }, - { - JSOutput(addr, 2100000000000001), - JSOutput() - }, - 0, - 0, - tree.root(), - "nonsensical output value"); - - // Absurd total output value - invokeAPIFailure(params, - { - JSInput(), - JSInput() - }, - { - JSOutput(addr, 1900000000000000), - JSOutput(addr, 1900000000000000) - }, - 0, - 0, - tree.root(), - "nonsensical right hand side of joinsplit balance"); - - // Absurd total output value - invokeAPIFailure(params, - { - JSInput(), - JSInput() - }, - { - JSOutput(addr, 1900000000000000), - JSOutput() - }, - 0, - 0, - tree.root(), - "invalid joinsplit balance"); - } - - test_full_api(params); -} - -TEST(joinsplit, note_plaintexts) -{ - uint252 a_sk = uint252(uint256S("f6da8716682d600f74fc16bd0187faad6a26b4aa4c24d5c055b216d94516840e")); - uint256 a_pk = PRF_addr_a_pk(a_sk); - uint256 sk_enc = ZCNoteEncryption::generate_privkey(a_sk); - uint256 pk_enc = ZCNoteEncryption::generate_pubkey(sk_enc); - SproutPaymentAddress addr_pk(a_pk, pk_enc); - - uint256 h_sig; - - ZCNoteEncryption encryptor(h_sig); - uint256 epk = encryptor.get_epk(); - - SproutNote note(a_pk, - 1945813, - random_uint256(), - random_uint256() - ); - - std::array memo; - - SproutNotePlaintext note_pt(note, memo); - - ZCNoteEncryption::Ciphertext ct = note_pt.encrypt(encryptor, pk_enc); - - ZCNoteDecryption decryptor(sk_enc); - - auto decrypted = SproutNotePlaintext::decrypt(decryptor, ct, epk, h_sig, 0); - auto decrypted_note = decrypted.note(addr_pk); - - ASSERT_TRUE(decrypted_note.a_pk == note.a_pk); - ASSERT_TRUE(decrypted_note.rho == note.rho); - ASSERT_TRUE(decrypted_note.r == note.r); - ASSERT_TRUE(decrypted_note.value() == note.value()); - - ASSERT_TRUE(decrypted.memo() == note_pt.memo()); - - // Check memo() returns by reference, not return by value, for use cases such as: - // std::string data(plaintext.memo().begin(), plaintext.memo().end()); - ASSERT_TRUE(decrypted.memo().data() == decrypted.memo().data()); - - // Check serialization of note plaintext - CDataStream ss(SER_DISK, PROTOCOL_VERSION); - ss << note_pt; - SproutNotePlaintext note_pt2; - ss >> note_pt2; - ASSERT_EQ(note_pt.value(), note.value()); - ASSERT_EQ(note_pt.value(), note_pt2.value()); - ASSERT_EQ(note_pt.memo(), note_pt2.memo()); - ASSERT_EQ(note_pt.rho, note_pt2.rho); - ASSERT_EQ(note_pt.r, note_pt2.r); -} - -TEST(joinsplit, note_class) -{ - uint252 a_sk = uint252(uint256S("f6da8716682d600f74fc16bd0187faad6a26b4aa4c24d5c055b216d94516840e")); - uint256 a_pk = PRF_addr_a_pk(a_sk); - uint256 sk_enc = ZCNoteEncryption::generate_privkey(a_sk); - uint256 pk_enc = ZCNoteEncryption::generate_pubkey(sk_enc); - SproutPaymentAddress addr_pk(a_pk, pk_enc); - - SproutNote note(a_pk, - 1945813, - random_uint256(), - random_uint256()); - - SproutNote clone = note; - ASSERT_NE(¬e, &clone); - ASSERT_EQ(note.value(), clone.value()); - ASSERT_EQ(note.cm(), clone.cm()); - ASSERT_EQ(note.rho, clone.rho); - ASSERT_EQ(note.r, clone.r); - ASSERT_EQ(note.a_pk, clone.a_pk); -} diff --git a/src/gtest/test_keystore.cpp b/src/gtest/test_keystore.cpp index ccf9cb9ba..a6237a0e4 100644 --- a/src/gtest/test_keystore.cpp +++ b/src/gtest/test_keystore.cpp @@ -95,101 +95,6 @@ TEST(keystore_tests, sapling_keys) { } } -TEST(keystore_tests, store_and_retrieve_spending_key) { - CBasicKeyStore keyStore; - libzcash::SproutSpendingKey skOut; - - std::set addrs; - keyStore.GetSproutPaymentAddresses(addrs); - EXPECT_EQ(0, addrs.size()); - - auto sk = libzcash::SproutSpendingKey::random(); - auto addr = sk.address(); - - // Sanity-check: we can't get a key we haven't added - EXPECT_FALSE(keyStore.HaveSproutSpendingKey(addr)); - EXPECT_FALSE(keyStore.GetSproutSpendingKey(addr, skOut)); - - keyStore.AddSproutSpendingKey(sk); - EXPECT_TRUE(keyStore.HaveSproutSpendingKey(addr)); - EXPECT_TRUE(keyStore.GetSproutSpendingKey(addr, skOut)); - EXPECT_EQ(sk, skOut); - - keyStore.GetSproutPaymentAddresses(addrs); - EXPECT_EQ(1, addrs.size()); - EXPECT_EQ(1, addrs.count(addr)); -} - -TEST(keystore_tests, store_and_retrieve_note_decryptor) { - CBasicKeyStore keyStore; - ZCNoteDecryption decOut; - - auto sk = libzcash::SproutSpendingKey::random(); - auto addr = sk.address(); - - EXPECT_FALSE(keyStore.GetNoteDecryptor(addr, decOut)); - - keyStore.AddSproutSpendingKey(sk); - EXPECT_TRUE(keyStore.GetNoteDecryptor(addr, decOut)); - EXPECT_EQ(ZCNoteDecryption(sk.receiving_key()), decOut); -} - -TEST(keystore_tests, StoreAndRetrieveViewingKey) { - CBasicKeyStore keyStore; - libzcash::SproutViewingKey vkOut; - libzcash::SproutSpendingKey skOut; - ZCNoteDecryption decOut; - - auto sk = libzcash::SproutSpendingKey::random(); - auto vk = sk.viewing_key(); - auto addr = sk.address(); - - // Sanity-check: we can't get a viewing key we haven't added - EXPECT_FALSE(keyStore.HaveSproutViewingKey(addr)); - EXPECT_FALSE(keyStore.GetSproutViewingKey(addr, vkOut)); - - // and we shouldn't have a spending key or decryptor either - EXPECT_FALSE(keyStore.HaveSproutSpendingKey(addr)); - EXPECT_FALSE(keyStore.GetSproutSpendingKey(addr, skOut)); - EXPECT_FALSE(keyStore.GetNoteDecryptor(addr, decOut)); - - // and we can't find it in our list of addresses - std::set addresses; - keyStore.GetSproutPaymentAddresses(addresses); - EXPECT_FALSE(addresses.count(addr)); - - keyStore.AddSproutViewingKey(vk); - EXPECT_TRUE(keyStore.HaveSproutViewingKey(addr)); - EXPECT_TRUE(keyStore.GetSproutViewingKey(addr, vkOut)); - EXPECT_EQ(vk, vkOut); - - // We should still not have the spending key... - EXPECT_FALSE(keyStore.HaveSproutSpendingKey(addr)); - EXPECT_FALSE(keyStore.GetSproutSpendingKey(addr, skOut)); - - // ... but we should have a decryptor - EXPECT_TRUE(keyStore.GetNoteDecryptor(addr, decOut)); - EXPECT_EQ(ZCNoteDecryption(sk.receiving_key()), decOut); - - // ... and we should find it in our list of addresses - addresses.clear(); - keyStore.GetSproutPaymentAddresses(addresses); - EXPECT_TRUE(addresses.count(addr)); - - keyStore.RemoveSproutViewingKey(vk); - EXPECT_FALSE(keyStore.HaveSproutViewingKey(addr)); - EXPECT_FALSE(keyStore.GetSproutViewingKey(addr, vkOut)); - EXPECT_FALSE(keyStore.HaveSproutSpendingKey(addr)); - EXPECT_FALSE(keyStore.GetSproutSpendingKey(addr, skOut)); - addresses.clear(); - keyStore.GetSproutPaymentAddresses(addresses); - EXPECT_FALSE(addresses.count(addr)); - - // We still have a decryptor because those are cached in memory - // (and also we only remove viewing keys when adding a spending key) - EXPECT_TRUE(keyStore.GetNoteDecryptor(addr, decOut)); - EXPECT_EQ(ZCNoteDecryption(sk.receiving_key()), decOut); -} // Sapling TEST(keystore_tests, StoreAndRetrieveSaplingSpendingKey) { diff --git a/src/keystore.h b/src/keystore.h index c2e1f25d9..ac2ccf233 100644 --- a/src/keystore.h +++ b/src/keystore.h @@ -1,5 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -70,14 +71,6 @@ public: virtual bool HaveWatchOnly(const CScript &dest) const =0; virtual bool HaveWatchOnly() const =0; - //! Add a spending key to the store. - virtual bool AddSproutSpendingKey(const libzcash::SproutSpendingKey &sk) =0; - - //! Check whether a spending key corresponding to a given payment address is present in the store. - virtual bool HaveSproutSpendingKey(const libzcash::SproutPaymentAddress &address) const =0; - virtual bool GetSproutSpendingKey(const libzcash::SproutPaymentAddress &address, libzcash::SproutSpendingKey& skOut) const =0; - virtual void GetSproutPaymentAddresses(std::set &setAddress) const =0; - //! Add a Sapling spending key to the store. virtual bool AddSaplingSpendingKey( const libzcash::SaplingExtendedSpendingKey &sk, @@ -106,21 +99,11 @@ public: libzcash::SaplingIncomingViewingKey& ivkOut) const =0; virtual void GetSaplingPaymentAddresses(std::set &setAddress) const =0; - //! Support for Sprout viewing keys - virtual bool AddSproutViewingKey(const libzcash::SproutViewingKey &vk) =0; - virtual bool RemoveSproutViewingKey(const libzcash::SproutViewingKey &vk) =0; - virtual bool HaveSproutViewingKey(const libzcash::SproutPaymentAddress &address) const =0; - virtual bool GetSproutViewingKey( - const libzcash::SproutPaymentAddress &address, - libzcash::SproutViewingKey& vkOut) const =0; }; typedef std::map KeyMap; typedef std::map ScriptMap; typedef std::set WatchOnlySet; -typedef std::map SproutSpendingKeyMap; -typedef std::map SproutViewingKeyMap; -typedef std::map NoteDecryptorMap; // Full viewing key has equivalent functionality to a transparent address // When encrypting wallet, encrypt SaplingSpendingKeyMap, while leaving SaplingFullViewingKeyMap unencrypted @@ -137,9 +120,11 @@ protected: KeyMap mapKeys; ScriptMap mapScripts; WatchOnlySet setWatchOnly; + /* SproutSpendingKeyMap mapSproutSpendingKeys; SproutViewingKeyMap mapSproutViewingKeys; NoteDecryptorMap mapNoteDecryptors; + */ SaplingSpendingKeyMap mapSaplingSpendingKeys; SaplingFullViewingKeyMap mapSaplingFullViewingKeys; @@ -195,62 +180,6 @@ public: virtual bool HaveWatchOnly(const CScript &dest) const; virtual bool HaveWatchOnly() const; - bool AddSproutSpendingKey(const libzcash::SproutSpendingKey &sk); - bool HaveSproutSpendingKey(const libzcash::SproutPaymentAddress &address) const - { - bool result; - { - LOCK(cs_SpendingKeyStore); - result = (mapSproutSpendingKeys.count(address) > 0); - } - return result; - } - bool GetSproutSpendingKey(const libzcash::SproutPaymentAddress &address, libzcash::SproutSpendingKey &skOut) const - { - { - LOCK(cs_SpendingKeyStore); - SproutSpendingKeyMap::const_iterator mi = mapSproutSpendingKeys.find(address); - if (mi != mapSproutSpendingKeys.end()) - { - skOut = mi->second; - return true; - } - } - return false; - } - bool GetNoteDecryptor(const libzcash::SproutPaymentAddress &address, ZCNoteDecryption &decOut) const - { - { - LOCK(cs_SpendingKeyStore); - NoteDecryptorMap::const_iterator mi = mapNoteDecryptors.find(address); - if (mi != mapNoteDecryptors.end()) - { - decOut = mi->second; - return true; - } - } - return false; - } - void GetSproutPaymentAddresses(std::set &setAddress) const - { - setAddress.clear(); - { - LOCK(cs_SpendingKeyStore); - SproutSpendingKeyMap::const_iterator mi = mapSproutSpendingKeys.begin(); - while (mi != mapSproutSpendingKeys.end()) - { - setAddress.insert((*mi).first); - mi++; - } - SproutViewingKeyMap::const_iterator mvi = mapSproutViewingKeys.begin(); - while (mvi != mapSproutViewingKeys.end()) - { - setAddress.insert((*mvi).first); - mvi++; - } - } - } - //! Sapling bool AddSaplingSpendingKey( const libzcash::SaplingExtendedSpendingKey &sk, @@ -313,17 +242,11 @@ public: } } - virtual bool AddSproutViewingKey(const libzcash::SproutViewingKey &vk); - virtual bool RemoveSproutViewingKey(const libzcash::SproutViewingKey &vk); - virtual bool HaveSproutViewingKey(const libzcash::SproutPaymentAddress &address) const; - virtual bool GetSproutViewingKey( - const libzcash::SproutPaymentAddress &address, - libzcash::SproutViewingKey& vkOut) const; }; typedef std::vector > CKeyingMaterial; typedef std::map > > CryptedKeyMap; -typedef std::map > CryptedSproutSpendingKeyMap; +//typedef std::map > CryptedSproutSpendingKeyMap; //! Sapling typedef std::map > CryptedSaplingSpendingKeyMap; diff --git a/src/wallet/asyncrpcoperation_saplingconsolidation.cpp b/src/wallet/asyncrpcoperation_saplingconsolidation.cpp index 8f7078c81..0a57b8948 100644 --- a/src/wallet/asyncrpcoperation_saplingconsolidation.cpp +++ b/src/wallet/asyncrpcoperation_saplingconsolidation.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020 The Hush developers +// Copyright (c) 2019-2020 The Hush developers // Copyright (c) 2019 CryptoForge // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -93,7 +93,7 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() { { LOCK2(cs_main, pwalletMain->cs_wallet); // We set minDepth to 11 to avoid unconfirmed notes and in anticipation of specifying - // an anchor at height N-10 for each Sprout JoinSplit description + // an anchor at height N-10 for each SpendDescription // Consider, should notes be sorted? pwalletMain->GetFilteredNotes(sproutEntries, saplingEntries, "", 11); if (fConsolidationMapUsed) { From 2134269e7676b1bac6e0a61c76dde6e01791251c Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 3 Jun 2020 00:12:54 -0400 Subject: [PATCH 040/255] desprout --- src/gtest/test_keystore.cpp | 77 ----------------------------------- src/rpc/misc.cpp | 14 +------ src/test/rpc_wallet_tests.cpp | 57 +++++--------------------- src/txdb.cpp | 12 ------ src/wallet/crypter.h | 34 +--------------- src/wallet/rpcdump.cpp | 77 ++++++++++------------------------- 6 files changed, 34 insertions(+), 237 deletions(-) diff --git a/src/gtest/test_keystore.cpp b/src/gtest/test_keystore.cpp index a6237a0e4..a8c984984 100644 --- a/src/gtest/test_keystore.cpp +++ b/src/gtest/test_keystore.cpp @@ -185,9 +185,6 @@ TEST(keystore_tests, StoreAndRetrieveHDSeedInEncryptedStore) { // 3) Test adding a new seed to an already-encrypted key store TestCCryptoKeyStore keyStore2; - // Add a Sprout address so the wallet has something to test when decrypting - ASSERT_TRUE(keyStore2.AddSproutSpendingKey(libzcash::SproutSpendingKey::random())); - ASSERT_TRUE(keyStore2.EncryptKeys(vMasterKey)); ASSERT_TRUE(keyStore2.Unlock(vMasterKey)); @@ -201,78 +198,4 @@ TEST(keystore_tests, StoreAndRetrieveHDSeedInEncryptedStore) { EXPECT_EQ(seed3, seedOut); } -TEST(keystore_tests, store_and_retrieve_spending_key_in_encrypted_store) { - TestCCryptoKeyStore keyStore; - uint256 r {GetRandHash()}; - CKeyingMaterial vMasterKey (r.begin(), r.end()); - libzcash::SproutSpendingKey keyOut; - ZCNoteDecryption decOut; - std::set addrs; - - // 1) Test adding a key to an unencrypted key store, then encrypting it - auto sk = libzcash::SproutSpendingKey::random(); - auto addr = sk.address(); - EXPECT_FALSE(keyStore.GetNoteDecryptor(addr, decOut)); - - keyStore.AddSproutSpendingKey(sk); - ASSERT_TRUE(keyStore.HaveSproutSpendingKey(addr)); - ASSERT_TRUE(keyStore.GetSproutSpendingKey(addr, keyOut)); - ASSERT_EQ(sk, keyOut); - EXPECT_TRUE(keyStore.GetNoteDecryptor(addr, decOut)); - EXPECT_EQ(ZCNoteDecryption(sk.receiving_key()), decOut); - - ASSERT_TRUE(keyStore.EncryptKeys(vMasterKey)); - ASSERT_TRUE(keyStore.HaveSproutSpendingKey(addr)); - ASSERT_FALSE(keyStore.GetSproutSpendingKey(addr, keyOut)); - EXPECT_TRUE(keyStore.GetNoteDecryptor(addr, decOut)); - EXPECT_EQ(ZCNoteDecryption(sk.receiving_key()), decOut); - - // Unlocking with a random key should fail - uint256 r2 {GetRandHash()}; - CKeyingMaterial vRandomKey (r2.begin(), r2.end()); - EXPECT_FALSE(keyStore.Unlock(vRandomKey)); - - // Unlocking with a slightly-modified vMasterKey should fail - CKeyingMaterial vModifiedKey (r.begin(), r.end()); - vModifiedKey[0] += 1; - EXPECT_FALSE(keyStore.Unlock(vModifiedKey)); - - // Unlocking with vMasterKey should succeed - ASSERT_TRUE(keyStore.Unlock(vMasterKey)); - ASSERT_TRUE(keyStore.GetSproutSpendingKey(addr, keyOut)); - ASSERT_EQ(sk, keyOut); - - keyStore.GetSproutPaymentAddresses(addrs); - ASSERT_EQ(1, addrs.size()); - ASSERT_EQ(1, addrs.count(addr)); - - // 2) Test adding a spending key to an already-encrypted key store - auto sk2 = libzcash::SproutSpendingKey::random(); - auto addr2 = sk2.address(); - EXPECT_FALSE(keyStore.GetNoteDecryptor(addr2, decOut)); - - keyStore.AddSproutSpendingKey(sk2); - ASSERT_TRUE(keyStore.HaveSproutSpendingKey(addr2)); - ASSERT_TRUE(keyStore.GetSproutSpendingKey(addr2, keyOut)); - ASSERT_EQ(sk2, keyOut); - EXPECT_TRUE(keyStore.GetNoteDecryptor(addr2, decOut)); - EXPECT_EQ(ZCNoteDecryption(sk2.receiving_key()), decOut); - - ASSERT_TRUE(keyStore.Lock()); - ASSERT_TRUE(keyStore.HaveSproutSpendingKey(addr2)); - ASSERT_FALSE(keyStore.GetSproutSpendingKey(addr2, keyOut)); - EXPECT_TRUE(keyStore.GetNoteDecryptor(addr2, decOut)); - EXPECT_EQ(ZCNoteDecryption(sk2.receiving_key()), decOut); - - ASSERT_TRUE(keyStore.Unlock(vMasterKey)); - ASSERT_TRUE(keyStore.GetSproutSpendingKey(addr2, keyOut)); - ASSERT_EQ(sk2, keyOut); - EXPECT_TRUE(keyStore.GetNoteDecryptor(addr2, decOut)); - EXPECT_EQ(ZCNoteDecryption(sk2.receiving_key()), decOut); - - keyStore.GetSproutPaymentAddresses(addrs); - ASSERT_EQ(2, addrs.size()); - ASSERT_EQ(1, addrs.count(addr)); - ASSERT_EQ(1, addrs.count(addr2)); -} #endif diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index fc4b39ef0..a0248c2de 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -1,5 +1,6 @@ // Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -594,19 +595,6 @@ class DescribePaymentAddressVisitor : public boost::static_visitor public: UniValue operator()(const libzcash::InvalidEncoding &zaddr) const { return UniValue(UniValue::VOBJ); } - UniValue operator()(const libzcash::SproutPaymentAddress &zaddr) const { - UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("type", "sprout")); - obj.push_back(Pair("payingkey", zaddr.a_pk.GetHex())); - obj.push_back(Pair("transmissionkey", zaddr.pk_enc.GetHex())); -#ifdef ENABLE_WALLET - if (pwalletMain) { - obj.push_back(Pair("ismine", pwalletMain->HaveSproutSpendingKey(zaddr))); - } -#endif - return obj; - } - UniValue operator()(const libzcash::SaplingPaymentAddress &zaddr) const { UniValue obj(UniValue::VOBJ); obj.push_back(Pair("type", "sapling")); diff --git a/src/test/rpc_wallet_tests.cpp b/src/test/rpc_wallet_tests.cpp index 1eaade55b..f68bf8b79 100644 --- a/src/test/rpc_wallet_tests.cpp +++ b/src/test/rpc_wallet_tests.cpp @@ -1,6 +1,7 @@ // Copyright (c) 2013-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "rpc/server.h" #include "rpc/client.h" @@ -341,38 +342,12 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_z_validateaddress) BOOST_CHECK_THROW(CallRPC("z_validateaddress"), runtime_error); BOOST_CHECK_THROW(CallRPC("z_validateaddress toomany args"), runtime_error); - // Wallet should be empty - std::set addrs; - pwalletMain->GetSproutPaymentAddresses(addrs); - BOOST_CHECK(addrs.size()==0); - // This address is not valid, it belongs to another network BOOST_CHECK_NO_THROW(retValue = CallRPC("z_validateaddress ztaaga95QAPyp1kSQ1hD2kguCpzyMHjxWZqaYDEkzbvo7uYQYAw2S8X4Kx98AvhhofMtQL8PAXKHuZsmhRcanavKRKmdCzk")); UniValue resultObj = retValue.get_obj(); bool b = find_value(resultObj, "isvalid").get_bool(); BOOST_CHECK_EQUAL(b, false); - // This address is valid, but the spending key is not in this wallet - BOOST_CHECK_NO_THROW(retValue = CallRPC("z_validateaddress zcfA19SDAKRYHLoRDoShcoz4nPohqWxuHcqg8WAxsiB2jFrrs6k7oSvst3UZvMYqpMNSRBkxBsnyjjngX5L55FxMzLKach8")); - resultObj = retValue.get_obj(); - b = find_value(resultObj, "isvalid").get_bool(); - BOOST_CHECK_EQUAL(b, true); - BOOST_CHECK_EQUAL(find_value(resultObj, "type").get_str(), "sprout"); - b = find_value(resultObj, "ismine").get_bool(); - BOOST_CHECK_EQUAL(b, false); - - // Let's import a spending key to the wallet and validate its payment address - BOOST_CHECK_NO_THROW(CallRPC("z_importkey SKxoWv77WGwFnUJitQKNEcD636bL4X5Gd6wWmgaA4Q9x8jZBPJXT")); - BOOST_CHECK_NO_THROW(retValue = CallRPC("z_validateaddress zcWsmqT4X2V4jgxbgiCzyrAfRT1vi1F4sn7M5Pkh66izzw8Uk7LBGAH3DtcSMJeUb2pi3W4SQF8LMKkU2cUuVP68yAGcomL")); - resultObj = retValue.get_obj(); - b = find_value(resultObj, "isvalid").get_bool(); - BOOST_CHECK_EQUAL(b, true); - BOOST_CHECK_EQUAL(find_value(resultObj, "type").get_str(), "sprout"); - b = find_value(resultObj, "ismine").get_bool(); - BOOST_CHECK_EQUAL(b, true); - BOOST_CHECK_EQUAL(find_value(resultObj, "payingkey").get_str(), "f5bb3c888ccc9831e3f6ba06e7528e26a312eec3acc1823be8918b6a3a5e20ad"); - BOOST_CHECK_EQUAL(find_value(resultObj, "transmissionkey").get_str(), "7a58c7132446564e6b810cf895c20537b3528357dc00150a8e201f491efa9c1a"); - // This Sapling address is not valid, it belongs to another network BOOST_CHECK_NO_THROW(retValue = CallRPC("z_validateaddress ztestsapling1knww2nyjc62njkard0jmx7hlsj6twxmxwprn7anvrv4dc2zxanl3nemc0qx2hvplxmd2uau8gyw")); resultObj = retValue.get_obj(); @@ -398,16 +373,6 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_z_exportwallet) { LOCK2(cs_main, pwalletMain->cs_wallet); - // wallet should be empty - std::set addrs; - pwalletMain->GetSproutPaymentAddresses(addrs); - BOOST_CHECK(addrs.size()==0); - - // wallet should have one key - libzcash::SproutPaymentAddress addr = pwalletMain->GenerateNewSproutZKey(); - pwalletMain->GetSproutPaymentAddresses(addrs); - BOOST_CHECK(addrs.size()==1); - // Set up paths boost::filesystem::path tmppath = boost::filesystem::temp_directory_path(); boost::filesystem::path tmpfilename = boost::filesystem::unique_path("%%%%%%%%"); @@ -429,9 +394,6 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_z_exportwallet) BOOST_CHECK_NO_THROW(CallRPC(string("z_exportwallet ") + tmpfilename.string())); - libzcash::SproutSpendingKey key; - BOOST_CHECK(pwalletMain->GetSproutSpendingKey(addr, key)); - std::string s1 = EncodePaymentAddress(addr); std::string s2 = EncodeSpendingKey(key); @@ -474,13 +436,13 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_z_importwallet) BOOST_CHECK_THROW(CallRPC("z_importwallet toomany args"), runtime_error); // create a random key locally - auto testSpendingKey = libzcash::SproutSpendingKey::random(); + auto testSpendingKey = libzcash::SaplingSpendingKey::random(); auto testPaymentAddress = testSpendingKey.address(); std::string testAddr = EncodePaymentAddress(testPaymentAddress); std::string testKey = EncodeSpendingKey(testSpendingKey); // create test data using the random key - std::string format_str = "# Wallet dump created by Komodo v0.11.2.0.z8-9155cc6-dirty (2016-08-11 11:37:00 -0700)\n" + std::string format_str = "# Wallet dump created by Hush v0.11.2.0.z8-9155cc6-dirty (2016-08-11 11:37:00 -0700)\n" "# * Created on 2016-08-12T21:55:36Z\n" "# * Best block at time of backup was 0 (0de0a3851fef2d433b9b4f51d4342bdd24c5ddd793eb8fba57189f07e9235d52),\n" "# mined on 2009-01-03T18:15:05Z\n" @@ -504,14 +466,14 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_z_importwallet) // wallet should currently be empty std::set addrs; - pwalletMain->GetSproutPaymentAddresses(addrs); + pwalletMain->GetSaplingPaymentAddresses(addrs); BOOST_CHECK(addrs.size()==0); // import test data from file into wallet BOOST_CHECK_NO_THROW(CallRPC(string("z_importwallet ") + path)); // wallet should now have one zkey - pwalletMain->GetSproutPaymentAddresses(addrs); + pwalletMain->GetSaplingPaymentAddresses(addrs); BOOST_CHECK(addrs.size()==1); // check that we have the spending key for the address @@ -521,10 +483,11 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_z_importwallet) auto addr = boost::get(address); BOOST_CHECK(pwalletMain->HaveSproutSpendingKey(addr)); + // Verify the spending key is the same as the test data - libzcash::SproutSpendingKey k; - BOOST_CHECK(pwalletMain->GetSproutSpendingKey(addr, k)); - BOOST_CHECK_EQUAL(testKey, EncodeSpendingKey(k)); + //libzcash::SproutSpendingKey k; + //BOOST_CHECK(pwalletMain->GetSproutSpendingKey(addr, k)); + //BOOST_CHECK_EQUAL(testKey, EncodeSpendingKey(k)); } diff --git a/src/txdb.cpp b/src/txdb.cpp index 46140f546..6fe8bd575 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -67,18 +67,6 @@ CCoinsViewDB::CCoinsViewDB(size_t nCacheSize, bool fMemory, bool fWipe) : db(Get } -bool CCoinsViewDB::GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const { - if (rt == SproutMerkleTree::empty_root()) { - SproutMerkleTree new_tree; - tree = new_tree; - return true; - } - - bool read = db.Read(make_pair(DB_SPROUT_ANCHOR, rt), tree); - - return read; -} - bool CCoinsViewDB::GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const { if (rt == SaplingMerkleTree::empty_root()) { SaplingMerkleTree new_tree; diff --git a/src/wallet/crypter.h b/src/wallet/crypter.h index f42a762af..8a7de32b4 100644 --- a/src/wallet/crypter.h +++ b/src/wallet/crypter.h @@ -1,4 +1,5 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -145,7 +146,7 @@ class CCryptoKeyStore : public CBasicKeyStore private: std::pair> cryptedHDSeed; CryptedKeyMap mapCryptedKeys; - CryptedSproutSpendingKeyMap mapCryptedSproutSpendingKeys; + //CryptedSproutSpendingKeyMap mapCryptedSproutSpendingKeys; CryptedSaplingSpendingKeyMap mapCryptedSaplingSpendingKeys; CKeyingMaterial vMasterKey; @@ -223,37 +224,6 @@ public: mi++; } } - virtual bool AddCryptedSproutSpendingKey( - const libzcash::SproutPaymentAddress &address, - const libzcash::ReceivingKey &rk, - const std::vector &vchCryptedSecret); - bool AddSproutSpendingKey(const libzcash::SproutSpendingKey &sk); - bool HaveSproutSpendingKey(const libzcash::SproutPaymentAddress &address) const - { - { - LOCK(cs_SpendingKeyStore); - if (!IsCrypted()) - return CBasicKeyStore::HaveSproutSpendingKey(address); - return mapCryptedSproutSpendingKeys.count(address) > 0; - } - return false; - } - bool GetSproutSpendingKey(const libzcash::SproutPaymentAddress &address, libzcash::SproutSpendingKey &skOut) const; - void GetSproutPaymentAddresses(std::set &setAddress) const - { - if (!IsCrypted()) - { - CBasicKeyStore::GetSproutPaymentAddresses(setAddress); - return; - } - setAddress.clear(); - CryptedSproutSpendingKeyMap::const_iterator mi = mapCryptedSproutSpendingKeys.begin(); - while (mi != mapCryptedSproutSpendingKeys.end()) - { - setAddress.insert((*mi).first); - mi++; - } - } //! Sapling virtual bool AddCryptedSaplingSpendingKey( const libzcash::SaplingExtendedFullViewingKey &extfvk, diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index 44639f663..1499a58b9 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -856,48 +856,27 @@ UniValue z_importviewingkey(const UniValue& params, bool fHelp, const CPubKey& m throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid viewing key"); } - if (boost::get(&viewingkey) == nullptr) { - if (params.size() < 4) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Missing zaddr for Sapling viewing key."); - } - string strAddress = params[3].get_str(); - auto address = DecodePaymentAddress(strAddress); - if (!IsValidPaymentAddress(address)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid zaddr"); - } + if (params.size() < 4) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Missing zaddr for Sapling viewing key."); + } + string strAddress = params[3].get_str(); + auto address = DecodePaymentAddress(strAddress); + if (!IsValidPaymentAddress(address)) { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid zaddr"); + } - auto addr = boost::get(address); - auto ivk = boost::get(viewingkey); + auto addr = boost::get(address); + auto ivk = boost::get(viewingkey); - if (pwalletMain->HaveSaplingIncomingViewingKey(addr)) { - if (fIgnoreExistingKey) { - return NullUniValue; - } - } else { - pwalletMain->MarkDirty(); - - if (!pwalletMain->AddSaplingIncomingViewingKey(ivk, addr)) { - throw JSONRPCError(RPC_WALLET_ERROR, "Error adding viewing key to wallet"); - } + if (pwalletMain->HaveSaplingIncomingViewingKey(addr)) { + if (fIgnoreExistingKey) { + return NullUniValue; } } else { - auto vkey = boost::get(viewingkey); - auto addr = vkey.address(); - if (pwalletMain->HaveSproutSpendingKey(addr)) { - throw JSONRPCError(RPC_WALLET_ERROR, "The wallet already contains the private key for this viewing key"); - } + pwalletMain->MarkDirty(); - // Don't throw error in case a viewing key is already there - if (pwalletMain->HaveSproutViewingKey(addr)) { - if (fIgnoreExistingKey) { - return NullUniValue; - } - } else { - pwalletMain->MarkDirty(); - - if (!pwalletMain->AddSproutViewingKey(vkey)) { - throw JSONRPCError(RPC_WALLET_ERROR, "Error adding viewing key to wallet"); - } + if (!pwalletMain->AddSaplingIncomingViewingKey(ivk, addr)) { + throw JSONRPCError(RPC_WALLET_ERROR, "Error adding viewing key to wallet"); } } @@ -977,26 +956,12 @@ UniValue z_exportviewingkey(const UniValue& params, bool fHelp, const CPubKey& m throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid zaddr"); } - if (boost::get(&address) == nullptr) { - auto addr = boost::get(address); - libzcash::SaplingIncomingViewingKey ivk; - if(!pwalletMain->GetSaplingIncomingViewingKey(addr, ivk)) { - throw JSONRPCError(RPC_WALLET_ERROR, "Wallet does not hold viewing key for this zaddr"); - } - return EncodeViewingKey(ivk); + auto addr = boost::get(address); + libzcash::SaplingIncomingViewingKey ivk; + if(!pwalletMain->GetSaplingIncomingViewingKey(addr, ivk)) { + throw JSONRPCError(RPC_WALLET_ERROR, "Wallet does not hold viewing key for this zaddr"); } - - auto addr = boost::get(address); - libzcash::SproutViewingKey vk; - if (!pwalletMain->GetSproutViewingKey(addr, vk)) { - libzcash::SproutSpendingKey k; - if (!pwalletMain->GetSproutSpendingKey(addr, k)) { - throw JSONRPCError(RPC_WALLET_ERROR, "Wallet does not hold private key or viewing key for this zaddr"); - } - vk = k.viewing_key(); - } - - return EncodeViewingKey(vk); + return EncodeViewingKey(ivk); } extern int32_t KOMODO_NSPV; From 52e373967199152a6e2e60d090f919d1e831d54b Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 3 Jun 2020 21:59:49 -0400 Subject: [PATCH 041/255] desprout --- src/rpc/misc.cpp | 8 +- src/test/rpc_wallet_tests.cpp | 4 +- src/wallet/gtest/test_wallet_zkeys.cpp | 297 ------------------------- src/wallet/rpcdisclosure.cpp | 7 +- 4 files changed, 13 insertions(+), 303 deletions(-) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index a0248c2de..fb3e21137 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -537,14 +537,14 @@ UniValue validateaddress(const UniValue& params, bool fHelp, const CPubKey& mypk { if (fHelp || params.size() != 1) throw runtime_error( - "validateaddress \"komodoaddress\"\n" - "\nReturn information about the given Komodo address.\n" + "validateaddress \"hushaddress\"\n" + "\nReturn information about the given Hush address.\n" "\nArguments:\n" - "1. \"komodoaddress\" (string, required) The Komodo address to validate\n" + "1. \"hushaddress\" (string, required) The Hush address to validate\n" "\nResult:\n" "{\n" " \"isvalid\" : true|false, (boolean) If the address is valid or not. If not, this is the only property returned.\n" - " \"address\" : \"komodoaddress\", (string) The Komodo address validated\n" + " \"address\" : \"hushaddress\", (string) The Hush address validated\n" " \"scriptPubKey\" : \"hex\", (string) The hex encoded scriptPubKey generated by the address\n" " \"ismine\" : true|false, (boolean) If the address is yours or not\n" " \"isscript\" : true|false, (boolean) If the key is a script\n" diff --git a/src/test/rpc_wallet_tests.cpp b/src/test/rpc_wallet_tests.cpp index f68bf8b79..107188779 100644 --- a/src/test/rpc_wallet_tests.cpp +++ b/src/test/rpc_wallet_tests.cpp @@ -465,7 +465,7 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_z_importwallet) file << std::flush; // wallet should currently be empty - std::set addrs; + std::set addrs; pwalletMain->GetSaplingPaymentAddresses(addrs); BOOST_CHECK(addrs.size()==0); @@ -477,11 +477,13 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_z_importwallet) BOOST_CHECK(addrs.size()==1); // check that we have the spending key for the address + /* auto address = DecodePaymentAddress(testAddr); BOOST_CHECK(IsValidPaymentAddress(address)); BOOST_ASSERT(boost::get(&address) != nullptr); auto addr = boost::get(address); BOOST_CHECK(pwalletMain->HaveSproutSpendingKey(addr)); + */ // Verify the spending key is the same as the test data diff --git a/src/wallet/gtest/test_wallet_zkeys.cpp b/src/wallet/gtest/test_wallet_zkeys.cpp index 365533b6c..7811c9c8a 100644 --- a/src/wallet/gtest/test_wallet_zkeys.cpp +++ b/src/wallet/gtest/test_wallet_zkeys.cpp @@ -106,303 +106,6 @@ TEST(wallet_zkeys_tests, StoreAndLoadSaplingZkeys) { EXPECT_TRUE(wallet.HaveSaplingIncomingViewingKey(dpa2)); } -/** - * This test covers methods on CWallet - * GenerateNewSproutZKey() - * AddSproutZKey() - * LoadZKey() - * LoadZKeyMetadata() - */ -TEST(wallet_zkeys_tests, store_and_load_zkeys) { - SelectParams(CBaseChainParams::MAIN); - - CWallet wallet; - - // wallet should be empty - std::set addrs; - wallet.GetSproutPaymentAddresses(addrs); - ASSERT_EQ(0, addrs.size()); - - // wallet should have one key - auto addr = wallet.GenerateNewSproutZKey(); - wallet.GetSproutPaymentAddresses(addrs); - ASSERT_EQ(1, addrs.size()); - - // verify wallet has spending key for the address - ASSERT_TRUE(wallet.HaveSproutSpendingKey(addr)); - - // manually add new spending key to wallet - auto sk = libzcash::SproutSpendingKey::random(); - ASSERT_TRUE(wallet.AddSproutZKey(sk)); - - // verify wallet did add it - addr = sk.address(); - ASSERT_TRUE(wallet.HaveSproutSpendingKey(addr)); - - // verify spending key stored correctly - libzcash::SproutSpendingKey keyOut; - wallet.GetSproutSpendingKey(addr, keyOut); - ASSERT_EQ(sk, keyOut); - - // verify there are two keys - wallet.GetSproutPaymentAddresses(addrs); - ASSERT_EQ(2, addrs.size()); - ASSERT_EQ(1, addrs.count(addr)); - - // Load a third key into the wallet - sk = libzcash::SproutSpendingKey::random(); - ASSERT_TRUE(wallet.LoadZKey(sk)); - - // attach metadata to this third key - addr = sk.address(); - int64_t now = GetTime(); - CKeyMetadata meta(now); - ASSERT_TRUE(wallet.LoadZKeyMetadata(addr, meta)); - - // check metadata is the same - CKeyMetadata m= wallet.mapSproutZKeyMetadata[addr]; - ASSERT_EQ(m.nCreateTime, now); -} - -/** - * This test covers methods on CWallet - * AddSproutViewingKey() - * RemoveSproutViewingKey() - * LoadSproutViewingKey() - */ -TEST(wallet_zkeys_tests, StoreAndLoadViewingKeys) { - SelectParams(CBaseChainParams::MAIN); - - CWallet wallet; - - // wallet should be empty - std::set addrs; - wallet.GetSproutPaymentAddresses(addrs); - ASSERT_EQ(0, addrs.size()); - - // manually add new viewing key to wallet - auto sk = libzcash::SproutSpendingKey::random(); - auto vk = sk.viewing_key(); - ASSERT_TRUE(wallet.AddSproutViewingKey(vk)); - - // verify wallet did add it - auto addr = sk.address(); - ASSERT_TRUE(wallet.HaveSproutViewingKey(addr)); - // and that we don't have the corresponding spending key - ASSERT_FALSE(wallet.HaveSproutSpendingKey(addr)); - - // verify viewing key stored correctly - libzcash::SproutViewingKey vkOut; - wallet.GetSproutViewingKey(addr, vkOut); - ASSERT_EQ(vk, vkOut); - - // Load a second viewing key into the wallet - auto sk2 = libzcash::SproutSpendingKey::random(); - ASSERT_TRUE(wallet.LoadSproutViewingKey(sk2.viewing_key())); - - // verify wallet did add it - auto addr2 = sk2.address(); - ASSERT_TRUE(wallet.HaveSproutViewingKey(addr2)); - ASSERT_FALSE(wallet.HaveSproutSpendingKey(addr2)); - - // Remove the first viewing key - ASSERT_TRUE(wallet.RemoveSproutViewingKey(vk)); - ASSERT_FALSE(wallet.HaveSproutViewingKey(addr)); - ASSERT_TRUE(wallet.HaveSproutViewingKey(addr2)); -} - -/** - * This test covers methods on CWalletDB - * WriteZKey() - */ -TEST(wallet_zkeys_tests, write_zkey_direct_to_db) { - SelectParams(CBaseChainParams::TESTNET); - - // Get temporary and unique path for file. - // Note: / operator to append paths - boost::filesystem::path pathTemp = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path(); - boost::filesystem::create_directories(pathTemp); - mapArgs["-datadir"] = pathTemp.string(); - - bool fFirstRun; - CWallet wallet("wallet.dat"); - ASSERT_EQ(DB_LOAD_OK, wallet.LoadWallet(fFirstRun)); - - // No default CPubKey set - ASSERT_TRUE(fFirstRun); - - // wallet should be empty - std::set addrs; - wallet.GetSproutPaymentAddresses(addrs); - ASSERT_EQ(0, addrs.size()); - - // Add random key to the wallet - auto paymentAddress = wallet.GenerateNewSproutZKey(); - - // wallet should have one key - wallet.GetSproutPaymentAddresses(addrs); - ASSERT_EQ(1, addrs.size()); - - // create random key and add it to database directly, bypassing wallet - auto sk = libzcash::SproutSpendingKey::random(); - auto addr = sk.address(); - int64_t now = GetTime(); - CKeyMetadata meta(now); - CWalletDB db("wallet.dat"); - db.WriteZKey(addr, sk, meta); - - // wallet should not be aware of key - ASSERT_FALSE(wallet.HaveSproutSpendingKey(addr)); - - // wallet sees one key - wallet.GetSproutPaymentAddresses(addrs); - ASSERT_EQ(1, addrs.size()); - - // wallet should have default metadata for addr with null createtime - CKeyMetadata m = wallet.mapSproutZKeyMetadata[addr]; - ASSERT_EQ(m.nCreateTime, 0); - ASSERT_NE(m.nCreateTime, now); - - // load the wallet again - ASSERT_EQ(DB_LOAD_OK, wallet.LoadWallet(fFirstRun)); - - // wallet can now see the spending key - ASSERT_TRUE(wallet.HaveSproutSpendingKey(addr)); - - // check key is the same - libzcash::SproutSpendingKey keyOut; - wallet.GetSproutSpendingKey(addr, keyOut); - ASSERT_EQ(sk, keyOut); - - // wallet should have two keys - wallet.GetSproutPaymentAddresses(addrs); - ASSERT_EQ(2, addrs.size()); - - // check metadata is now the same - m = wallet.mapSproutZKeyMetadata[addr]; - ASSERT_EQ(m.nCreateTime, now); -} - -/** - * This test covers methods on CWalletDB - * WriteSproutViewingKey() - */ -TEST(wallet_zkeys_tests, WriteViewingKeyDirectToDB) { - SelectParams(CBaseChainParams::TESTNET); - - // Get temporary and unique path for file. - // Note: / operator to append paths - boost::filesystem::path pathTemp = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path(); - boost::filesystem::create_directories(pathTemp); - mapArgs["-datadir"] = pathTemp.string(); - - bool fFirstRun; - CWallet wallet("wallet-vkey.dat"); - ASSERT_EQ(DB_LOAD_OK, wallet.LoadWallet(fFirstRun)); - - // No default CPubKey set - ASSERT_TRUE(fFirstRun); - - // create random viewing key and add it to database directly, bypassing wallet - auto sk = libzcash::SproutSpendingKey::random(); - auto vk = sk.viewing_key(); - auto addr = sk.address(); - int64_t now = GetTime(); - CKeyMetadata meta(now); - CWalletDB db("wallet-vkey.dat"); - db.WriteSproutViewingKey(vk); - - // wallet should not be aware of viewing key - ASSERT_FALSE(wallet.HaveSproutViewingKey(addr)); - - // load the wallet again - ASSERT_EQ(DB_LOAD_OK, wallet.LoadWallet(fFirstRun)); - - // wallet can now see the viewing key - ASSERT_TRUE(wallet.HaveSproutViewingKey(addr)); - - // check key is the same - libzcash::SproutViewingKey vkOut; - wallet.GetSproutViewingKey(addr, vkOut); - ASSERT_EQ(vk, vkOut); -} - - - -/** - * This test covers methods on CWalletDB to load/save crypted z keys. - */ -TEST(wallet_zkeys_tests, write_cryptedzkey_direct_to_db) { - SelectParams(CBaseChainParams::TESTNET); - - // Get temporary and unique path for file. - // Note: / operator to append paths - boost::filesystem::path pathTemp = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path(); - boost::filesystem::create_directories(pathTemp); - mapArgs["-datadir"] = pathTemp.string(); - - bool fFirstRun; - CWallet wallet("wallet_crypted.dat"); - ASSERT_EQ(DB_LOAD_OK, wallet.LoadWallet(fFirstRun)); - - // No default CPubKey set - ASSERT_TRUE(fFirstRun); - - // wallet should be empty - std::set addrs; - wallet.GetSproutPaymentAddresses(addrs); - ASSERT_EQ(0, addrs.size()); - - // Add random key to the wallet - auto paymentAddress = wallet.GenerateNewSproutZKey(); - - // wallet should have one key - wallet.GetSproutPaymentAddresses(addrs); - ASSERT_EQ(1, addrs.size()); - - // encrypt wallet - SecureString strWalletPass; - strWalletPass.reserve(100); - strWalletPass = "hello"; - ASSERT_TRUE(wallet.EncryptWallet(strWalletPass)); - - // adding a new key will fail as the wallet is locked - EXPECT_ANY_THROW(wallet.GenerateNewSproutZKey()); - - // unlock wallet and then add - wallet.Unlock(strWalletPass); - auto paymentAddress2 = wallet.GenerateNewSproutZKey(); - - // Create a new wallet from the existing wallet path - CWallet wallet2("wallet_crypted.dat"); - ASSERT_EQ(DB_LOAD_OK, wallet2.LoadWallet(fFirstRun)); - - // Confirm it's not the same as the other wallet - ASSERT_TRUE(&wallet != &wallet2); - - // wallet should have two keys - wallet2.GetSproutPaymentAddresses(addrs); - ASSERT_EQ(2, addrs.size()); - - // check we have entries for our payment addresses - ASSERT_TRUE(addrs.count(paymentAddress)); - ASSERT_TRUE(addrs.count(paymentAddress2)); - - // spending key is crypted, so we can't extract valid payment address - libzcash::SproutSpendingKey keyOut; - wallet2.GetSproutSpendingKey(paymentAddress, keyOut); - ASSERT_FALSE(paymentAddress == keyOut.address()); - - // unlock wallet to get spending keys and verify payment addresses - wallet2.Unlock(strWalletPass); - - wallet2.GetSproutSpendingKey(paymentAddress, keyOut); - ASSERT_EQ(paymentAddress, keyOut.address()); - - wallet2.GetSproutSpendingKey(paymentAddress2, keyOut); - ASSERT_EQ(paymentAddress2, keyOut.address()); -} - /** * This test covers methods on CWalletDB to load/save crypted sapling z keys. */ diff --git a/src/wallet/rpcdisclosure.cpp b/src/wallet/rpcdisclosure.cpp index cd0cc42a6..918e70cbc 100644 --- a/src/wallet/rpcdisclosure.cpp +++ b/src/wallet/rpcdisclosure.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2017 The Zcash developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -187,6 +188,8 @@ UniValue z_validatepaymentdisclosure(const UniValue& params, bool fHelp, const C throw JSONRPCError(RPC_WALLET_ERROR, "Error: payment disclosure is disabled."); } + throw JSONRPCError(RPC_WALLET_ERROR, "Error: payment disclosures not implemented for Sapling yet"); + LOCK2(cs_main, pwalletMain->cs_wallet); EnsureWalletIsUnlocked(); @@ -269,8 +272,9 @@ UniValue z_validatepaymentdisclosure(const UniValue& params, bool fHelp, const C errs.push_back("Payment disclosure signature does not match transaction signature"); } + /* // Check the payment address is valid - SproutPaymentAddress zaddr = pd.payload.zaddr; + PaymentAddress zaddr = pd.payload.zaddr; { o.push_back(Pair("paymentAddress", EncodePaymentAddress(zaddr))); @@ -308,6 +312,7 @@ UniValue z_validatepaymentdisclosure(const UniValue& params, bool fHelp, const C errs.push_back(string("Error while decrypting payment disclosure note: ") + string(e.what()) ); } } + */ bool isValid = errs.empty(); o.push_back(Pair("valid", isValid)); From 7c6c7150c61e2183bc0af5449b18d8a48266f266 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 3 Jun 2020 22:20:10 -0400 Subject: [PATCH 042/255] desprout --- src/coins.cpp | 27 ----- src/primitives/transaction.cpp | 77 -------------- src/primitives/transaction.h | 177 --------------------------------- src/wallet/rpcwallet.cpp | 2 +- src/wallet/wallet.h | 5 - src/wallet/walletdb.cpp | 4 + src/wallet/walletdb.h | 10 +- 7 files changed, 6 insertions(+), 296 deletions(-) diff --git a/src/coins.cpp b/src/coins.cpp index 38fac8252..f183c99a0 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -628,33 +628,6 @@ bool CCoinsViewCache::HaveJoinSplitRequirements(const CTransaction& tx) const { boost::unordered_map intermediates; - BOOST_FOREACH(const JSDescription &joinsplit, tx.vjoinsplit) - { - BOOST_FOREACH(const uint256& nullifier, joinsplit.nullifiers) - { - if (GetNullifier(nullifier, SPROUT)) { - // If the nullifier is set, this transaction - // double-spends! - return false; - } - } - - SproutMerkleTree tree; - auto it = intermediates.find(joinsplit.anchor); - if (it != intermediates.end()) { - tree = it->second; - } else if (!GetSproutAnchorAt(joinsplit.anchor, tree)) { - return false; - } - - BOOST_FOREACH(const uint256& commitment, joinsplit.commitments) - { - tree.append(commitment); - } - - intermediates.insert(std::make_pair(tree.root(), tree)); - } - for (const SpendDescription &spendDescription : tx.vShieldedSpend) { if (GetNullifier(spendDescription.nullifier, SAPLING)) { // Prevent double spends LogPrintf("%s: sapling nullifier %s exists, preventing double spend\n", __FUNCTION__, spendDescription.nullifier.GetHex().c_str()); diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp index 2cde04f2c..01c95adc3 100644 --- a/src/primitives/transaction.cpp +++ b/src/primitives/transaction.cpp @@ -26,83 +26,6 @@ #include "librustzcash.h" -JSDescription::JSDescription( - ZCJoinSplit& params, - const uint256& joinSplitPubKey, - const uint256& anchor, - const std::array& inputs, - const std::array& outputs, - CAmount vpub_old, - CAmount vpub_new, - bool computeProof, - uint256 *esk // payment disclosure -) : vpub_old(vpub_old), vpub_new(vpub_new), anchor(anchor) -{ - std::array notes; - - proof = params.prove( - inputs, - outputs, - notes, - ciphertexts, - ephemeralKey, - joinSplitPubKey, - randomSeed, - macs, - nullifiers, - commitments, - vpub_old, - vpub_new, - anchor, - computeProof, - esk // payment disclosure - ); -} - -JSDescription JSDescription::Randomized( - ZCJoinSplit& params, - const uint256& joinSplitPubKey, - const uint256& anchor, - std::array& inputs, - std::array& outputs, - std::array& inputMap, - std::array& outputMap, - CAmount vpub_old, - CAmount vpub_new, - bool computeProof, - uint256 *esk, // payment disclosure - std::function gen -) -{ - // Randomize the order of the inputs and outputs - inputMap = {0, 1}; - outputMap = {0, 1}; - - assert(gen); - - MappedShuffle(inputs.begin(), inputMap.begin(), ZC_NUM_JS_INPUTS, gen); - MappedShuffle(outputs.begin(), outputMap.begin(), ZC_NUM_JS_OUTPUTS, gen); - - return JSDescription( - params, joinSplitPubKey, anchor, inputs, outputs, - vpub_old, vpub_new, computeProof, - esk // payment disclosure - ); -} - -bool JSDescription::Verify( - ZCJoinSplit& params, - libzcash::ProofVerifier& verifier, - const uint256& joinSplitPubKey -) const { - return false; -} - -uint256 JSDescription::h_sig(ZCJoinSplit& params, const uint256& joinSplitPubKey) const -{ - return params.h_sig(randomSeed, nullifiers, joinSplitPubKey); -} - std::string COutPoint::ToString() const { return strprintf("COutPoint(%s, %u)", hash.ToString().substr(0,10), n); diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index 2ece7b255..b3afecd87 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -159,183 +159,6 @@ public: } }; -template -class SproutProofSerializer : public boost::static_visitor<> -{ - Stream& s; - bool useGroth; - -public: - SproutProofSerializer(Stream& s, bool useGroth) : s(s), useGroth(useGroth) {} - - void operator()(const libzcash::PHGRProof& proof) const - { - if (useGroth) { - throw std::ios_base::failure("Invalid Sprout proof for transaction format (expected GrothProof, found PHGRProof)"); - } - ::Serialize(s, proof); - } - - void operator()(const libzcash::GrothProof& proof) const - { - if (!useGroth) { - throw std::ios_base::failure("Invalid Sprout proof for transaction format (expected PHGRProof, found GrothProof)"); - } - ::Serialize(s, proof); - } -}; - -template -inline void SerReadWriteSproutProof(Stream& s, const T& proof, bool useGroth, CSerActionSerialize ser_action) -{ - auto ps = SproutProofSerializer(s, useGroth); - boost::apply_visitor(ps, proof); -} - -template -inline void SerReadWriteSproutProof(Stream& s, T& proof, bool useGroth, CSerActionUnserialize ser_action) -{ - if (useGroth) { - libzcash::GrothProof grothProof; - ::Unserialize(s, grothProof); - proof = grothProof; - } else { - libzcash::PHGRProof pghrProof; - ::Unserialize(s, pghrProof); - proof = pghrProof; - } -} - -class JSDescription -{ -public: - // These values 'enter from' and 'exit to' the value - // pool, respectively. - CAmount vpub_old; - CAmount vpub_new; - - // JoinSplits are always anchored to a root in the note - // commitment tree at some point in the blockchain - // history or in the history of the current - // transaction. - uint256 anchor; - - // Nullifiers are used to prevent double-spends. They - // are derived from the secrets placed in the note - // and the secret spend-authority key known by the - // spender. - std::array nullifiers; - - // Note commitments are introduced into the commitment - // tree, blinding the public about the values and - // destinations involved in the JoinSplit. The presence of - // a commitment in the note commitment tree is required - // to spend it. - std::array commitments; - - // Ephemeral key - uint256 ephemeralKey; - - // Ciphertexts - // These contain trapdoors, values and other information - // that the recipient needs, including a memo field. It - // is encrypted using the scheme implemented in crypto/NoteEncryption.cpp - std::array ciphertexts = {{ {{0}} }}; - - // Random seed - uint256 randomSeed; - - // MACs - // The verification of the JoinSplit requires these MACs - // to be provided as an input. - std::array macs; - - // JoinSplit proof - // This is a zk-SNARK which ensures that this JoinSplit is valid. - libzcash::SproutProof proof; - - JSDescription(): vpub_old(0), vpub_new(0) { } - - JSDescription( - ZCJoinSplit& params, - const uint256& joinSplitPubKey, - const uint256& rt, - const std::array& inputs, - const std::array& outputs, - CAmount vpub_old, - CAmount vpub_new, - bool computeProof = true, // Set to false in some tests - uint256 *esk = nullptr // payment disclosure - ); - - static JSDescription Randomized( - ZCJoinSplit& params, - const uint256& joinSplitPubKey, - const uint256& rt, - std::array& inputs, - std::array& outputs, - std::array& inputMap, - std::array& outputMap, - CAmount vpub_old, - CAmount vpub_new, - bool computeProof = true, // Set to false in some tests - uint256 *esk = nullptr, // payment disclosure - std::function gen = GetRandInt - ); - - // Verifies that the JoinSplit proof is correct. - bool Verify( - ZCJoinSplit& params, - libzcash::ProofVerifier& verifier, - const uint256& joinSplitPubKey - ) const; - - // Returns the calculated h_sig - uint256 h_sig(ZCJoinSplit& params, const uint256& joinSplitPubKey) const; - - ADD_SERIALIZE_METHODS; - - template - inline void SerializationOp(Stream& s, Operation ser_action) { - // nVersion is set by CTransaction and CMutableTransaction to - // (tx.fOverwintered << 31) | tx.nVersion - bool fOverwintered = s.GetVersion() >> 31; - int32_t txVersion = s.GetVersion() & 0x7FFFFFFF; - bool useGroth = fOverwintered && txVersion >= SAPLING_TX_VERSION; - - READWRITE(vpub_old); - READWRITE(vpub_new); - READWRITE(anchor); - READWRITE(nullifiers); - READWRITE(commitments); - READWRITE(ephemeralKey); - READWRITE(randomSeed); - READWRITE(macs); - ::SerReadWriteSproutProof(s, proof, useGroth, ser_action); - READWRITE(ciphertexts); - } - - friend bool operator==(const JSDescription& a, const JSDescription& b) - { - return ( - a.vpub_old == b.vpub_old && - a.vpub_new == b.vpub_new && - a.anchor == b.anchor && - a.nullifiers == b.nullifiers && - a.commitments == b.commitments && - a.ephemeralKey == b.ephemeralKey && - a.ciphertexts == b.ciphertexts && - a.randomSeed == b.randomSeed && - a.macs == b.macs && - a.proof == b.proof - ); - } - - friend bool operator!=(const JSDescription& a, const JSDescription& b) - { - return !(a == b); - } -}; class BaseOutPoint { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 37f67042b..604e21799 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4268,7 +4268,7 @@ UniValue z_gettotalbalance(const UniValue& params, bool fHelp, const CPubKey& my "\nResult:\n" "{\n" " \"transparent\": xxxxx, (numeric) the total balance of transparent funds\n" - " \"private\": xxxxx, (numeric) the total balance of private funds (in both Sprout and Sapling addresses)\n" + " \"private\": xxxxx, (numeric) the total balance of private funds (in Sapling addresses)\n" " \"total\": xxxxx, (numeric) the total balance of both transparent and private funds\n" "}\n" "\nExamples:\n" diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index d82e100ed..f3526c583 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1408,7 +1408,6 @@ private: public: PaymentAddressBelongsToWallet(CWallet *wallet) : m_wallet(wallet) {} - bool operator()(const libzcash::SproutPaymentAddress &zaddr) const; bool operator()(const libzcash::SaplingPaymentAddress &zaddr) const; bool operator()(const libzcash::InvalidEncoding& no) const; }; @@ -1421,7 +1420,6 @@ private: public: IncomingViewingKeyBelongsToWallet(CWallet *wallet) : m_wallet(wallet) {} - bool operator()(const libzcash::SproutPaymentAddress &zaddr) const; bool operator()(const libzcash::SaplingPaymentAddress &zaddr) const; bool operator()(const libzcash::InvalidEncoding& no) const; }; @@ -1433,7 +1431,6 @@ private: public: HaveSpendingKeyForPaymentAddress(CWallet *wallet) : m_wallet(wallet) {} - bool operator()(const libzcash::SproutPaymentAddress &zaddr) const; bool operator()(const libzcash::SaplingPaymentAddress &zaddr) const; bool operator()(const libzcash::InvalidEncoding& no) const; }; @@ -1445,7 +1442,6 @@ private: public: GetSpendingKeyForPaymentAddress(CWallet *wallet) : m_wallet(wallet) {} - boost::optional operator()(const libzcash::SproutPaymentAddress &zaddr) const; boost::optional operator()(const libzcash::SaplingPaymentAddress &zaddr) const; boost::optional operator()(const libzcash::InvalidEncoding& no) const; }; @@ -1517,7 +1513,6 @@ public: ) : m_wallet(wallet), params(params), nTime(_nTime), hdKeypath(_hdKeypath), seedFpStr(_seedFp), log(_log) {} - SpendingKeyAddResult operator()(const libzcash::SproutSpendingKey &sk) const; SpendingKeyAddResult operator()(const libzcash::SaplingExtendedSpendingKey &sk) const; SpendingKeyAddResult operator()(const libzcash::InvalidEncoding& no) const; }; diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 1177bbedd..4f6942bb7 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -653,6 +653,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, } else if (strType == "czkey") { + /* libzcash::SproutPaymentAddress addr; ssKey >> addr; // Deserialization of a pair is just one item after another @@ -662,6 +663,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, vector vchCryptedSecret; ssValue >> vchCryptedSecret; wss.nCKeys++; + */ //if (!pwallet->LoadCryptedZKey(addr, rk, vchCryptedSecret)) //{ @@ -704,11 +706,13 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, } else if (strType == "zkeymeta") { + /* libzcash::SproutPaymentAddress addr; ssKey >> addr; CKeyMetadata keyMeta; ssValue >> keyMeta; wss.nZKeyMeta++; + */ // pwallet->LoadZKeyMetadata(addr, keyMeta); diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h index 9069e3a08..8c34588ec 100644 --- a/src/wallet/walletdb.h +++ b/src/wallet/walletdb.h @@ -1,5 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -199,23 +200,14 @@ public: bool WriteHDChain(const CHDChain& chain); /// Write spending key to wallet database, where key is payment address and value is spending key. - bool WriteZKey(const libzcash::SproutPaymentAddress& addr, const libzcash::SproutSpendingKey& key, const CKeyMetadata &keyMeta); bool WriteSaplingZKey(const libzcash::SaplingIncomingViewingKey &ivk, const libzcash::SaplingExtendedSpendingKey &key, const CKeyMetadata &keyMeta); bool WriteSaplingPaymentAddress(const libzcash::SaplingPaymentAddress &addr, const libzcash::SaplingIncomingViewingKey &ivk); - bool WriteCryptedZKey(const libzcash::SproutPaymentAddress & addr, - const libzcash::ReceivingKey & rk, - const std::vector& vchCryptedSecret, - const CKeyMetadata &keyMeta); bool WriteCryptedSaplingZKey(const libzcash::SaplingExtendedFullViewingKey &extfvk, const std::vector& vchCryptedSecret, const CKeyMetadata &keyMeta); - - bool WriteSproutViewingKey(const libzcash::SproutViewingKey &vk); - bool EraseSproutViewingKey(const libzcash::SproutViewingKey &vk); - private: CWalletDB(const CWalletDB&); void operator=(const CWalletDB&); From b32bf1f82c0c4ded804b2b0f009f339677b7a931 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Thu, 4 Jun 2020 21:51:21 -0400 Subject: [PATCH 043/255] Revert "desprout" This reverts commit 7c6c7150c61e2183bc0af5449b18d8a48266f266. --- src/coins.cpp | 27 +++++ src/primitives/transaction.cpp | 77 ++++++++++++++ src/primitives/transaction.h | 177 +++++++++++++++++++++++++++++++++ src/wallet/rpcwallet.cpp | 2 +- src/wallet/wallet.h | 5 + src/wallet/walletdb.cpp | 4 - src/wallet/walletdb.h | 10 +- 7 files changed, 296 insertions(+), 6 deletions(-) diff --git a/src/coins.cpp b/src/coins.cpp index f183c99a0..38fac8252 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -628,6 +628,33 @@ bool CCoinsViewCache::HaveJoinSplitRequirements(const CTransaction& tx) const { boost::unordered_map intermediates; + BOOST_FOREACH(const JSDescription &joinsplit, tx.vjoinsplit) + { + BOOST_FOREACH(const uint256& nullifier, joinsplit.nullifiers) + { + if (GetNullifier(nullifier, SPROUT)) { + // If the nullifier is set, this transaction + // double-spends! + return false; + } + } + + SproutMerkleTree tree; + auto it = intermediates.find(joinsplit.anchor); + if (it != intermediates.end()) { + tree = it->second; + } else if (!GetSproutAnchorAt(joinsplit.anchor, tree)) { + return false; + } + + BOOST_FOREACH(const uint256& commitment, joinsplit.commitments) + { + tree.append(commitment); + } + + intermediates.insert(std::make_pair(tree.root(), tree)); + } + for (const SpendDescription &spendDescription : tx.vShieldedSpend) { if (GetNullifier(spendDescription.nullifier, SAPLING)) { // Prevent double spends LogPrintf("%s: sapling nullifier %s exists, preventing double spend\n", __FUNCTION__, spendDescription.nullifier.GetHex().c_str()); diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp index 01c95adc3..2cde04f2c 100644 --- a/src/primitives/transaction.cpp +++ b/src/primitives/transaction.cpp @@ -26,6 +26,83 @@ #include "librustzcash.h" +JSDescription::JSDescription( + ZCJoinSplit& params, + const uint256& joinSplitPubKey, + const uint256& anchor, + const std::array& inputs, + const std::array& outputs, + CAmount vpub_old, + CAmount vpub_new, + bool computeProof, + uint256 *esk // payment disclosure +) : vpub_old(vpub_old), vpub_new(vpub_new), anchor(anchor) +{ + std::array notes; + + proof = params.prove( + inputs, + outputs, + notes, + ciphertexts, + ephemeralKey, + joinSplitPubKey, + randomSeed, + macs, + nullifiers, + commitments, + vpub_old, + vpub_new, + anchor, + computeProof, + esk // payment disclosure + ); +} + +JSDescription JSDescription::Randomized( + ZCJoinSplit& params, + const uint256& joinSplitPubKey, + const uint256& anchor, + std::array& inputs, + std::array& outputs, + std::array& inputMap, + std::array& outputMap, + CAmount vpub_old, + CAmount vpub_new, + bool computeProof, + uint256 *esk, // payment disclosure + std::function gen +) +{ + // Randomize the order of the inputs and outputs + inputMap = {0, 1}; + outputMap = {0, 1}; + + assert(gen); + + MappedShuffle(inputs.begin(), inputMap.begin(), ZC_NUM_JS_INPUTS, gen); + MappedShuffle(outputs.begin(), outputMap.begin(), ZC_NUM_JS_OUTPUTS, gen); + + return JSDescription( + params, joinSplitPubKey, anchor, inputs, outputs, + vpub_old, vpub_new, computeProof, + esk // payment disclosure + ); +} + +bool JSDescription::Verify( + ZCJoinSplit& params, + libzcash::ProofVerifier& verifier, + const uint256& joinSplitPubKey +) const { + return false; +} + +uint256 JSDescription::h_sig(ZCJoinSplit& params, const uint256& joinSplitPubKey) const +{ + return params.h_sig(randomSeed, nullifiers, joinSplitPubKey); +} + std::string COutPoint::ToString() const { return strprintf("COutPoint(%s, %u)", hash.ToString().substr(0,10), n); diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index b3afecd87..2ece7b255 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -159,6 +159,183 @@ public: } }; +template +class SproutProofSerializer : public boost::static_visitor<> +{ + Stream& s; + bool useGroth; + +public: + SproutProofSerializer(Stream& s, bool useGroth) : s(s), useGroth(useGroth) {} + + void operator()(const libzcash::PHGRProof& proof) const + { + if (useGroth) { + throw std::ios_base::failure("Invalid Sprout proof for transaction format (expected GrothProof, found PHGRProof)"); + } + ::Serialize(s, proof); + } + + void operator()(const libzcash::GrothProof& proof) const + { + if (!useGroth) { + throw std::ios_base::failure("Invalid Sprout proof for transaction format (expected PHGRProof, found GrothProof)"); + } + ::Serialize(s, proof); + } +}; + +template +inline void SerReadWriteSproutProof(Stream& s, const T& proof, bool useGroth, CSerActionSerialize ser_action) +{ + auto ps = SproutProofSerializer(s, useGroth); + boost::apply_visitor(ps, proof); +} + +template +inline void SerReadWriteSproutProof(Stream& s, T& proof, bool useGroth, CSerActionUnserialize ser_action) +{ + if (useGroth) { + libzcash::GrothProof grothProof; + ::Unserialize(s, grothProof); + proof = grothProof; + } else { + libzcash::PHGRProof pghrProof; + ::Unserialize(s, pghrProof); + proof = pghrProof; + } +} + +class JSDescription +{ +public: + // These values 'enter from' and 'exit to' the value + // pool, respectively. + CAmount vpub_old; + CAmount vpub_new; + + // JoinSplits are always anchored to a root in the note + // commitment tree at some point in the blockchain + // history or in the history of the current + // transaction. + uint256 anchor; + + // Nullifiers are used to prevent double-spends. They + // are derived from the secrets placed in the note + // and the secret spend-authority key known by the + // spender. + std::array nullifiers; + + // Note commitments are introduced into the commitment + // tree, blinding the public about the values and + // destinations involved in the JoinSplit. The presence of + // a commitment in the note commitment tree is required + // to spend it. + std::array commitments; + + // Ephemeral key + uint256 ephemeralKey; + + // Ciphertexts + // These contain trapdoors, values and other information + // that the recipient needs, including a memo field. It + // is encrypted using the scheme implemented in crypto/NoteEncryption.cpp + std::array ciphertexts = {{ {{0}} }}; + + // Random seed + uint256 randomSeed; + + // MACs + // The verification of the JoinSplit requires these MACs + // to be provided as an input. + std::array macs; + + // JoinSplit proof + // This is a zk-SNARK which ensures that this JoinSplit is valid. + libzcash::SproutProof proof; + + JSDescription(): vpub_old(0), vpub_new(0) { } + + JSDescription( + ZCJoinSplit& params, + const uint256& joinSplitPubKey, + const uint256& rt, + const std::array& inputs, + const std::array& outputs, + CAmount vpub_old, + CAmount vpub_new, + bool computeProof = true, // Set to false in some tests + uint256 *esk = nullptr // payment disclosure + ); + + static JSDescription Randomized( + ZCJoinSplit& params, + const uint256& joinSplitPubKey, + const uint256& rt, + std::array& inputs, + std::array& outputs, + std::array& inputMap, + std::array& outputMap, + CAmount vpub_old, + CAmount vpub_new, + bool computeProof = true, // Set to false in some tests + uint256 *esk = nullptr, // payment disclosure + std::function gen = GetRandInt + ); + + // Verifies that the JoinSplit proof is correct. + bool Verify( + ZCJoinSplit& params, + libzcash::ProofVerifier& verifier, + const uint256& joinSplitPubKey + ) const; + + // Returns the calculated h_sig + uint256 h_sig(ZCJoinSplit& params, const uint256& joinSplitPubKey) const; + + ADD_SERIALIZE_METHODS; + + template + inline void SerializationOp(Stream& s, Operation ser_action) { + // nVersion is set by CTransaction and CMutableTransaction to + // (tx.fOverwintered << 31) | tx.nVersion + bool fOverwintered = s.GetVersion() >> 31; + int32_t txVersion = s.GetVersion() & 0x7FFFFFFF; + bool useGroth = fOverwintered && txVersion >= SAPLING_TX_VERSION; + + READWRITE(vpub_old); + READWRITE(vpub_new); + READWRITE(anchor); + READWRITE(nullifiers); + READWRITE(commitments); + READWRITE(ephemeralKey); + READWRITE(randomSeed); + READWRITE(macs); + ::SerReadWriteSproutProof(s, proof, useGroth, ser_action); + READWRITE(ciphertexts); + } + + friend bool operator==(const JSDescription& a, const JSDescription& b) + { + return ( + a.vpub_old == b.vpub_old && + a.vpub_new == b.vpub_new && + a.anchor == b.anchor && + a.nullifiers == b.nullifiers && + a.commitments == b.commitments && + a.ephemeralKey == b.ephemeralKey && + a.ciphertexts == b.ciphertexts && + a.randomSeed == b.randomSeed && + a.macs == b.macs && + a.proof == b.proof + ); + } + + friend bool operator!=(const JSDescription& a, const JSDescription& b) + { + return !(a == b); + } +}; class BaseOutPoint { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 604e21799..37f67042b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4268,7 +4268,7 @@ UniValue z_gettotalbalance(const UniValue& params, bool fHelp, const CPubKey& my "\nResult:\n" "{\n" " \"transparent\": xxxxx, (numeric) the total balance of transparent funds\n" - " \"private\": xxxxx, (numeric) the total balance of private funds (in Sapling addresses)\n" + " \"private\": xxxxx, (numeric) the total balance of private funds (in both Sprout and Sapling addresses)\n" " \"total\": xxxxx, (numeric) the total balance of both transparent and private funds\n" "}\n" "\nExamples:\n" diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index f3526c583..d82e100ed 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1408,6 +1408,7 @@ private: public: PaymentAddressBelongsToWallet(CWallet *wallet) : m_wallet(wallet) {} + bool operator()(const libzcash::SproutPaymentAddress &zaddr) const; bool operator()(const libzcash::SaplingPaymentAddress &zaddr) const; bool operator()(const libzcash::InvalidEncoding& no) const; }; @@ -1420,6 +1421,7 @@ private: public: IncomingViewingKeyBelongsToWallet(CWallet *wallet) : m_wallet(wallet) {} + bool operator()(const libzcash::SproutPaymentAddress &zaddr) const; bool operator()(const libzcash::SaplingPaymentAddress &zaddr) const; bool operator()(const libzcash::InvalidEncoding& no) const; }; @@ -1431,6 +1433,7 @@ private: public: HaveSpendingKeyForPaymentAddress(CWallet *wallet) : m_wallet(wallet) {} + bool operator()(const libzcash::SproutPaymentAddress &zaddr) const; bool operator()(const libzcash::SaplingPaymentAddress &zaddr) const; bool operator()(const libzcash::InvalidEncoding& no) const; }; @@ -1442,6 +1445,7 @@ private: public: GetSpendingKeyForPaymentAddress(CWallet *wallet) : m_wallet(wallet) {} + boost::optional operator()(const libzcash::SproutPaymentAddress &zaddr) const; boost::optional operator()(const libzcash::SaplingPaymentAddress &zaddr) const; boost::optional operator()(const libzcash::InvalidEncoding& no) const; }; @@ -1513,6 +1517,7 @@ public: ) : m_wallet(wallet), params(params), nTime(_nTime), hdKeypath(_hdKeypath), seedFpStr(_seedFp), log(_log) {} + SpendingKeyAddResult operator()(const libzcash::SproutSpendingKey &sk) const; SpendingKeyAddResult operator()(const libzcash::SaplingExtendedSpendingKey &sk) const; SpendingKeyAddResult operator()(const libzcash::InvalidEncoding& no) const; }; diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 4f6942bb7..1177bbedd 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -653,7 +653,6 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, } else if (strType == "czkey") { - /* libzcash::SproutPaymentAddress addr; ssKey >> addr; // Deserialization of a pair is just one item after another @@ -663,7 +662,6 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, vector vchCryptedSecret; ssValue >> vchCryptedSecret; wss.nCKeys++; - */ //if (!pwallet->LoadCryptedZKey(addr, rk, vchCryptedSecret)) //{ @@ -706,13 +704,11 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, } else if (strType == "zkeymeta") { - /* libzcash::SproutPaymentAddress addr; ssKey >> addr; CKeyMetadata keyMeta; ssValue >> keyMeta; wss.nZKeyMeta++; - */ // pwallet->LoadZKeyMetadata(addr, keyMeta); diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h index 8c34588ec..9069e3a08 100644 --- a/src/wallet/walletdb.h +++ b/src/wallet/walletdb.h @@ -1,6 +1,5 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers -// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -200,14 +199,23 @@ public: bool WriteHDChain(const CHDChain& chain); /// Write spending key to wallet database, where key is payment address and value is spending key. + bool WriteZKey(const libzcash::SproutPaymentAddress& addr, const libzcash::SproutSpendingKey& key, const CKeyMetadata &keyMeta); bool WriteSaplingZKey(const libzcash::SaplingIncomingViewingKey &ivk, const libzcash::SaplingExtendedSpendingKey &key, const CKeyMetadata &keyMeta); bool WriteSaplingPaymentAddress(const libzcash::SaplingPaymentAddress &addr, const libzcash::SaplingIncomingViewingKey &ivk); + bool WriteCryptedZKey(const libzcash::SproutPaymentAddress & addr, + const libzcash::ReceivingKey & rk, + const std::vector& vchCryptedSecret, + const CKeyMetadata &keyMeta); bool WriteCryptedSaplingZKey(const libzcash::SaplingExtendedFullViewingKey &extfvk, const std::vector& vchCryptedSecret, const CKeyMetadata &keyMeta); + + bool WriteSproutViewingKey(const libzcash::SproutViewingKey &vk); + bool EraseSproutViewingKey(const libzcash::SproutViewingKey &vk); + private: CWalletDB(const CWalletDB&); void operator=(const CWalletDB&); From da6c0028a3e497e4c00f1dc11148be9717cf7108 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Thu, 4 Jun 2020 21:51:49 -0400 Subject: [PATCH 044/255] desprout --- src/coins.cpp | 29 ----------------------------- 1 file changed, 29 deletions(-) diff --git a/src/coins.cpp b/src/coins.cpp index 38fac8252..c0039120a 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -626,35 +626,6 @@ CAmount CCoinsViewCache::GetValueIn(int32_t nHeight,int64_t *interestp,const CTr bool CCoinsViewCache::HaveJoinSplitRequirements(const CTransaction& tx) const { - boost::unordered_map intermediates; - - BOOST_FOREACH(const JSDescription &joinsplit, tx.vjoinsplit) - { - BOOST_FOREACH(const uint256& nullifier, joinsplit.nullifiers) - { - if (GetNullifier(nullifier, SPROUT)) { - // If the nullifier is set, this transaction - // double-spends! - return false; - } - } - - SproutMerkleTree tree; - auto it = intermediates.find(joinsplit.anchor); - if (it != intermediates.end()) { - tree = it->second; - } else if (!GetSproutAnchorAt(joinsplit.anchor, tree)) { - return false; - } - - BOOST_FOREACH(const uint256& commitment, joinsplit.commitments) - { - tree.append(commitment); - } - - intermediates.insert(std::make_pair(tree.root(), tree)); - } - for (const SpendDescription &spendDescription : tx.vShieldedSpend) { if (GetNullifier(spendDescription.nullifier, SAPLING)) { // Prevent double spends LogPrintf("%s: sapling nullifier %s exists, preventing double spend\n", __FUNCTION__, spendDescription.nullifier.GetHex().c_str()); From ed91f0188bba048e0b50197a23853bf14a22afd8 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Thu, 4 Jun 2020 21:56:04 -0400 Subject: [PATCH 045/255] We aint got no JoinSplits around here --- src/coins.cpp | 2 +- src/coins.h | 2 +- src/main.cpp | 6 +++--- src/test/coins_tests.cpp | 10 +++++----- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/coins.cpp b/src/coins.cpp index c0039120a..602d153ec 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -624,7 +624,7 @@ CAmount CCoinsViewCache::GetValueIn(int32_t nHeight,int64_t *interestp,const CTr } -bool CCoinsViewCache::HaveJoinSplitRequirements(const CTransaction& tx) const +bool CCoinsViewCache::HaveShieldedRequirements(const CTransaction& tx) const { for (const SpendDescription &spendDescription : tx.vShieldedSpend) { if (GetNullifier(spendDescription.nullifier, SAPLING)) { // Prevent double spends diff --git a/src/coins.h b/src/coins.h index cc8b19f68..1211e7e07 100644 --- a/src/coins.h +++ b/src/coins.h @@ -563,7 +563,7 @@ public: bool HaveInputs(const CTransaction& tx) const; //! Check whether all joinsplit requirements (anchors/nullifiers) are satisfied - bool HaveJoinSplitRequirements(const CTransaction& tx) const; + bool HaveShieldedRequirements(const CTransaction& tx) const; //! Return priority of tx at height nHeight double GetPriority(const CTransaction &tx, int nHeight) const; diff --git a/src/main.cpp b/src/main.cpp index c75f51a28..f31847b04 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1894,7 +1894,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa } // are the joinsplit's requirements met? - if (!view.HaveJoinSplitRequirements(tx)) + if (!view.HaveShieldedRequirements(tx)) { //fprintf(stderr,"accept failure.2\n"); return state.Invalid(error("AcceptToMemoryPool: joinsplit requirements not met"),REJECT_DUPLICATE, "bad-txns-joinsplit-requirements-not-met"); @@ -2719,7 +2719,7 @@ namespace Consensus { return state.Invalid(error("CheckInputs(): %s inputs unavailable", tx.GetHash().ToString())); // are the JoinSplit's requirements met? - if (!inputs.HaveJoinSplitRequirements(tx)) + if (!inputs.HaveShieldedRequirements(tx)) return state.Invalid(error("CheckInputs(): %s JoinSplit requirements not met", tx.GetHash().ToString())); CAmount nValueIn = 0; @@ -3536,7 +3536,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin REJECT_INVALID, "bad-txns-inputs-missingorspent"); } // are the JoinSplit's requirements met? - if (!view.HaveJoinSplitRequirements(tx)) + if (!view.HaveShieldedRequirements(tx)) return state.DoS(100, error("ConnectBlock(): JoinSplit requirements not met"), REJECT_INVALID, "bad-txns-joinsplit-requirements-not-met"); diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp index dc795ad7a..bb6432a81 100644 --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -632,7 +632,7 @@ BOOST_AUTO_TEST_CASE(chained_joinsplits) CMutableTransaction mtx; mtx.vjoinsplit.push_back(js2); - BOOST_CHECK(!cache.HaveJoinSplitRequirements(mtx)); + BOOST_CHECK(!cache.HaveShieldedRequirements(mtx)); } { @@ -642,7 +642,7 @@ BOOST_AUTO_TEST_CASE(chained_joinsplits) mtx.vjoinsplit.push_back(js2); mtx.vjoinsplit.push_back(js1); - BOOST_CHECK(!cache.HaveJoinSplitRequirements(mtx)); + BOOST_CHECK(!cache.HaveShieldedRequirements(mtx)); } { @@ -650,7 +650,7 @@ BOOST_AUTO_TEST_CASE(chained_joinsplits) mtx.vjoinsplit.push_back(js1); mtx.vjoinsplit.push_back(js2); - BOOST_CHECK(cache.HaveJoinSplitRequirements(mtx)); + BOOST_CHECK(cache.HaveShieldedRequirements(mtx)); } { @@ -659,7 +659,7 @@ BOOST_AUTO_TEST_CASE(chained_joinsplits) mtx.vjoinsplit.push_back(js2); mtx.vjoinsplit.push_back(js3); - BOOST_CHECK(cache.HaveJoinSplitRequirements(mtx)); + BOOST_CHECK(cache.HaveShieldedRequirements(mtx)); } { @@ -669,7 +669,7 @@ BOOST_AUTO_TEST_CASE(chained_joinsplits) mtx.vjoinsplit.push_back(js2); mtx.vjoinsplit.push_back(js3); - BOOST_CHECK(cache.HaveJoinSplitRequirements(mtx)); + BOOST_CHECK(cache.HaveShieldedRequirements(mtx)); } } From ed2c9450f9032833f459816c3f6f91893fc8fcbe Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 5 Jun 2020 01:20:37 -0400 Subject: [PATCH 046/255] desprout --- src/Makefile.am | 2 - src/gtest/test_transaction.cpp | 90 --- src/key_io.cpp | 44 +- src/keystore.cpp | 42 +- src/keystore.h | 8 +- src/paymentdisclosure.h | 1 + src/rpc/misc.cpp | 54 +- src/test/rpc_wallet_tests.cpp | 6 +- src/utiltest.cpp | 154 ----- src/utiltest.h | 19 - src/wallet/asyncrpcoperation_shieldcoinbase.h | 2 +- src/wallet/crypter.cpp | 111 +--- src/wallet/gtest/test_wallet.cpp | 570 +----------------- src/wallet/rpcwallet.cpp | 28 - src/wallet/wallet.h | 5 - src/wallet/walletdb.cpp | 16 +- src/wallet/walletdb.h | 11 +- src/zcash/Address.cpp | 38 +- src/zcbenchmarks.cpp | 34 +- 19 files changed, 52 insertions(+), 1183 deletions(-) delete mode 100644 src/gtest/test_transaction.cpp delete mode 100644 src/utiltest.cpp delete mode 100644 src/utiltest.h diff --git a/src/Makefile.am b/src/Makefile.am index 6277e0f98..2d2d7a691 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -347,8 +347,6 @@ endif libbitcoin_wallet_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) libbitcoin_wallet_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) libbitcoin_wallet_a_SOURCES = \ - utiltest.cpp \ - utiltest.h \ zcbenchmarks.cpp \ zcbenchmarks.h \ wallet/asyncrpcoperation_mergetoaddress.cpp \ diff --git a/src/gtest/test_transaction.cpp b/src/gtest/test_transaction.cpp deleted file mode 100644 index 1350768ff..000000000 --- a/src/gtest/test_transaction.cpp +++ /dev/null @@ -1,90 +0,0 @@ -#include - -#include "primitives/transaction.h" -#include "zcash/Note.hpp" -#include "zcash/Address.hpp" - -#include - -extern ZCJoinSplit* params; -extern int GenZero(int n); -extern int GenMax(int n); - -TEST(Transaction, JSDescriptionRandomized) { - // construct a merkle tree - SproutMerkleTree merkleTree; - - libzcash::SproutSpendingKey k = libzcash::SproutSpendingKey::random(); - libzcash::SproutPaymentAddress addr = k.address(); - - libzcash::SproutNote note(addr.a_pk, 100, uint256(), uint256()); - - // commitment from coin - uint256 commitment = note.cm(); - - // insert commitment into the merkle tree - merkleTree.append(commitment); - - // compute the merkle root we will be working with - uint256 rt = merkleTree.root(); - - auto witness = merkleTree.witness(); - - // create JSDescription - uint256 joinSplitPubKey; - std::array inputs = { - libzcash::JSInput(witness, note, k), - libzcash::JSInput() // dummy input of zero value - }; - std::array outputs = { - libzcash::JSOutput(addr, 50), - libzcash::JSOutput(addr, 50) - }; - std::array inputMap; - std::array outputMap; - - { - auto jsdesc = JSDescription::Randomized( - false, - *params, joinSplitPubKey, rt, - inputs, outputs, - inputMap, outputMap, - 0, 0, false); - - std::set inputSet(inputMap.begin(), inputMap.end()); - std::set expectedInputSet {0, 1}; - EXPECT_EQ(expectedInputSet, inputSet); - - std::set outputSet(outputMap.begin(), outputMap.end()); - std::set expectedOutputSet {0, 1}; - EXPECT_EQ(expectedOutputSet, outputSet); - } - - { - auto jsdesc = JSDescription::Randomized( - false, - *params, joinSplitPubKey, rt, - inputs, outputs, - inputMap, outputMap, - 0, 0, false, nullptr, GenZero); - - std::array expectedInputMap {1, 0}; - std::array expectedOutputMap {1, 0}; - EXPECT_EQ(expectedInputMap, inputMap); - EXPECT_EQ(expectedOutputMap, outputMap); - } - - { - auto jsdesc = JSDescription::Randomized( - false, - *params, joinSplitPubKey, rt, - inputs, outputs, - inputMap, outputMap, - 0, 0, false, nullptr, GenMax); - - std::array expectedInputMap {0, 1}; - std::array expectedOutputMap {0, 1}; - EXPECT_EQ(expectedInputMap, inputMap); - EXPECT_EQ(expectedOutputMap, outputMap); - } -} diff --git a/src/key_io.cpp b/src/key_io.cpp index dd4176fee..dd4bf884c 100644 --- a/src/key_io.cpp +++ b/src/key_io.cpp @@ -1,5 +1,6 @@ // Copyright (c) 2014-2016 The Bitcoin Core developers // Copyright (c) 2016-2018 The Zcash developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -84,15 +85,6 @@ private: public: PaymentAddressEncoder(const CChainParams& params) : m_params(params) {} - std::string operator()(const libzcash::SproutPaymentAddress& zaddr) const - { - CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - ss << zaddr; - std::vector data = m_params.Base58Prefix(CChainParams::ZCPAYMENT_ADDRRESS); - data.insert(data.end(), ss.begin(), ss.end()); - return EncodeBase58Check(data); - } - std::string operator()(const libzcash::SaplingPaymentAddress& zaddr) const { CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); @@ -117,17 +109,6 @@ private: public: ViewingKeyEncoder(const CChainParams& params) : m_params(params) {} - std::string operator()(const libzcash::SproutViewingKey& vk) const - { - CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - ss << vk; - std::vector data = m_params.Base58Prefix(CChainParams::ZCVIEWING_KEY); - data.insert(data.end(), ss.begin(), ss.end()); - std::string ret = EncodeBase58Check(data); - memory_cleanse(data.data(), data.size()); - return ret; - } - std::string operator()(const libzcash::SaplingIncomingViewingKey& vk) const { CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); @@ -152,17 +133,6 @@ private: public: SpendingKeyEncoder(const CChainParams& params) : m_params(params) {} - std::string operator()(const libzcash::SproutSpendingKey& zkey) const - { - CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - ss << zkey; - std::vector data = m_params.Base58Prefix(CChainParams::ZCSPENDING_KEY); - data.insert(data.end(), ss.begin(), ss.end()); - std::string ret = EncodeBase58Check(data); - memory_cleanse(data.data(), data.size()); - return ret; - } - std::string operator()(const libzcash::SaplingExtendedSpendingKey& zkey) const { CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); @@ -324,18 +294,6 @@ std::string EncodePaymentAddress(const libzcash::PaymentAddress& zaddr) libzcash::PaymentAddress DecodePaymentAddress(const std::string& str) { std::vector data; - if (DecodeBase58Check(str, data)) { - const std::vector& zaddr_prefix = Params().Base58Prefix(CChainParams::ZCPAYMENT_ADDRRESS); - if ((data.size() == libzcash::SerializedSproutPaymentAddressSize + zaddr_prefix.size()) && - std::equal(zaddr_prefix.begin(), zaddr_prefix.end(), data.begin())) { - CSerializeData serialized(data.begin() + zaddr_prefix.size(), data.end()); - CDataStream ss(serialized, SER_NETWORK, PROTOCOL_VERSION); - libzcash::SproutPaymentAddress ret; - ss >> ret; - return ret; - } - } - data.clear(); auto bech = bech32::Decode(str); if (bech.first == Params().Bech32HRP(CChainParams::SAPLING_PAYMENT_ADDRESS) && bech.second.size() == ConvertedSaplingPaymentAddressSize) { diff --git a/src/keystore.cpp b/src/keystore.cpp index 34bab456c..ca4fa3712 100644 --- a/src/keystore.cpp +++ b/src/keystore.cpp @@ -1,5 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -128,15 +129,6 @@ bool CBasicKeyStore::HaveWatchOnly() const return (!setWatchOnly.empty()); } -bool CBasicKeyStore::AddSproutSpendingKey(const libzcash::SproutSpendingKey &sk) -{ - LOCK(cs_SpendingKeyStore); - auto address = sk.address(); - mapSproutSpendingKeys[address] = sk; - mapNoteDecryptors.insert(std::make_pair(address, ZCNoteDecryption(sk.receiving_key()))); - return true; -} - //! Sapling bool CBasicKeyStore::AddSaplingSpendingKey( const libzcash::SaplingExtendedSpendingKey &sk, @@ -155,14 +147,6 @@ bool CBasicKeyStore::AddSaplingSpendingKey( return true; } -bool CBasicKeyStore::AddSproutViewingKey(const libzcash::SproutViewingKey &vk) -{ - LOCK(cs_SpendingKeyStore); - auto address = vk.address(); - mapSproutViewingKeys[address] = vk; - mapNoteDecryptors.insert(std::make_pair(address, ZCNoteDecryption(vk.sk_enc))); - return true; -} bool CBasicKeyStore::AddSaplingFullViewingKey( const libzcash::SaplingFullViewingKey &fvk, @@ -190,18 +174,7 @@ bool CBasicKeyStore::AddSaplingIncomingViewingKey( return true; } -bool CBasicKeyStore::RemoveSproutViewingKey(const libzcash::SproutViewingKey &vk) -{ - LOCK(cs_SpendingKeyStore); - mapSproutViewingKeys.erase(vk.address()); - return true; -} -bool CBasicKeyStore::HaveSproutViewingKey(const libzcash::SproutPaymentAddress &address) const -{ - LOCK(cs_SpendingKeyStore); - return mapSproutViewingKeys.count(address) > 0; -} bool CBasicKeyStore::HaveSaplingFullViewingKey(const libzcash::SaplingIncomingViewingKey &ivk) const { @@ -215,19 +188,6 @@ bool CBasicKeyStore::HaveSaplingIncomingViewingKey(const libzcash::SaplingPaymen return mapSaplingIncomingViewingKeys.count(addr) > 0; } -bool CBasicKeyStore::GetSproutViewingKey( - const libzcash::SproutPaymentAddress &address, - libzcash::SproutViewingKey &vkOut) const -{ - LOCK(cs_SpendingKeyStore); - SproutViewingKeyMap::const_iterator mi = mapSproutViewingKeys.find(address); - if (mi != mapSproutViewingKeys.end()) { - vkOut = mi->second; - return true; - } - return false; -} - bool CBasicKeyStore::GetSaplingFullViewingKey(const libzcash::SaplingIncomingViewingKey &ivk, libzcash::SaplingFullViewingKey &fvkOut) const { diff --git a/src/keystore.h b/src/keystore.h index ac2ccf233..6f34d9bc4 100644 --- a/src/keystore.h +++ b/src/keystore.h @@ -120,12 +120,7 @@ protected: KeyMap mapKeys; ScriptMap mapScripts; WatchOnlySet setWatchOnly; - /* - SproutSpendingKeyMap mapSproutSpendingKeys; - SproutViewingKeyMap mapSproutViewingKeys; - NoteDecryptorMap mapNoteDecryptors; - */ - + SaplingSpendingKeyMap mapSaplingSpendingKeys; SaplingFullViewingKeyMap mapSaplingFullViewingKeys; SaplingIncomingViewingKeyMap mapSaplingIncomingViewingKeys; @@ -246,7 +241,6 @@ public: typedef std::vector > CKeyingMaterial; typedef std::map > > CryptedKeyMap; -//typedef std::map > CryptedSproutSpendingKeyMap; //! Sapling typedef std::map > CryptedSaplingSpendingKeyMap; diff --git a/src/paymentdisclosure.h b/src/paymentdisclosure.h index 28a1d4cdc..5c3a20c33 100644 --- a/src/paymentdisclosure.h +++ b/src/paymentdisclosure.h @@ -1,4 +1,5 @@ // Copyright (c) 2017 The Zcash developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index fb3e21137..a41a8169d 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -204,7 +204,7 @@ UniValue getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk) " \"version\": xxxxx, (numeric) the server version\n" " \"protocolversion\": xxxxx, (numeric) the protocol version\n" " \"walletversion\": xxxxx, (numeric) the wallet version\n" - " \"balance\": xxxxxxx, (numeric) the total Komodo balance of the wallet\n" + " \"balance\": xxxxxxx, (numeric) the total Hush balance of the wallet\n" " \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n" " \"timeoffset\": xxxxx, (numeric) the time offset\n" " \"connections\": xxxxx, (numeric) the number of connections\n" @@ -590,30 +590,6 @@ UniValue validateaddress(const UniValue& params, bool fHelp, const CPubKey& mypk } -class DescribePaymentAddressVisitor : public boost::static_visitor -{ -public: - UniValue operator()(const libzcash::InvalidEncoding &zaddr) const { return UniValue(UniValue::VOBJ); } - - UniValue operator()(const libzcash::SaplingPaymentAddress &zaddr) const { - UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("type", "sapling")); - obj.push_back(Pair("diversifier", HexStr(zaddr.d))); - obj.push_back(Pair("diversifiedtransmissionkey", zaddr.pk_d.GetHex())); -#ifdef ENABLE_WALLET - if (pwalletMain) { - libzcash::SaplingIncomingViewingKey ivk; - libzcash::SaplingFullViewingKey fvk; - bool isMine = pwalletMain->GetSaplingIncomingViewingKey(zaddr, ivk) && - pwalletMain->GetSaplingFullViewingKey(ivk, fvk) && - pwalletMain->HaveSaplingSpendingKey(fvk); - obj.push_back(Pair("ismine", isMine)); - } -#endif - return obj; - } -}; - UniValue z_validateaddress(const UniValue& params, bool fHelp, const CPubKey& mypk) { if (fHelp || params.size() != 1) @@ -650,11 +626,25 @@ UniValue z_validateaddress(const UniValue& params, bool fHelp, const CPubKey& my UniValue ret(UniValue::VOBJ); ret.push_back(Pair("isvalid", isValid)); - if (isValid) + auto zaddr = boost::get(&address); + if (isValid && (zaddr != nullptr)) { ret.push_back(Pair("address", strAddress)); - UniValue detail = boost::apply_visitor(DescribePaymentAddressVisitor(), address); - ret.pushKVs(detail); + UniValue obj(UniValue::VOBJ); + obj.push_back(Pair("type", "sapling")); + obj.push_back(Pair("diversifier", HexStr(zaddr->d))); + obj.push_back(Pair("diversifiedtransmissionkey", zaddr->pk_d.GetHex())); +#ifdef ENABLE_WALLET + if (pwalletMain) { + libzcash::SaplingIncomingViewingKey ivk; + libzcash::SaplingFullViewingKey fvk; + bool isMine = pwalletMain->GetSaplingIncomingViewingKey(*zaddr, ivk) && + pwalletMain->GetSaplingFullViewingKey(ivk, fvk) && + pwalletMain->HaveSaplingSpendingKey(fvk); + obj.push_back(Pair("ismine", isMine)); + } +#endif + ret.pushKVs(obj); } return ret; } @@ -733,9 +723,9 @@ UniValue createmultisig(const UniValue& params, bool fHelp, const CPubKey& mypk) "\nArguments:\n" "1. nrequired (numeric, required) The number of required signatures out of the n keys or addresses.\n" - "2. \"keys\" (string, required) A json array of keys which are Komodo addresses or hex-encoded public keys\n" + "2. \"keys\" (string, required) A json array of keys which are Hush addresses or hex-encoded public keys\n" " [\n" - " \"key\" (string) Komodo address or hex-encoded public key\n" + " \"key\" (string) Hush address or hex-encoded public key\n" " ,...\n" " ]\n" @@ -769,10 +759,10 @@ UniValue verifymessage(const UniValue& params, bool fHelp, const CPubKey& mypk) { if (fHelp || params.size() != 3) throw runtime_error( - "verifymessage \"komodoaddress\" \"signature\" \"message\"\n" + "verifymessage \"hushaddress\" \"signature\" \"message\"\n" "\nVerify a signed message\n" "\nArguments:\n" - "1. \"komodoaddress\" (string, required) The Komodo address to use for the signature.\n" + "1. \"hushaddress\" (string, required) The Hush address to use for the signature.\n" "2. \"signature\" (string, required) The signature provided by the signer in base 64 encoding (see signmessage).\n" "3. \"message\" (string, required) The message that was signed.\n" "\nResult:\n" diff --git a/src/test/rpc_wallet_tests.cpp b/src/test/rpc_wallet_tests.cpp index 107188779..2abe2d782 100644 --- a/src/test/rpc_wallet_tests.cpp +++ b/src/test/rpc_wallet_tests.cpp @@ -571,9 +571,8 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_z_importexport) // Verify number of addresses stored in wallet is n1+n2 int numAddrs = myaddrs.size(); BOOST_CHECK(numAddrs == (2 * n1) + n2); - pwalletMain->GetSproutPaymentAddresses(addrs); pwalletMain->GetSaplingPaymentAddresses(saplingAddrs); - BOOST_CHECK(addrs.size() + saplingAddrs.size() == numAddrs); + BOOST_CHECK(saplingAddrs.size() == numAddrs); // Ask wallet to list addresses BOOST_CHECK_NO_THROW(retValue = CallRPC("z_listaddresses")); @@ -595,9 +594,6 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_z_importexport) std::string newaddress = retValue.get_str(); auto address = DecodePaymentAddress(newaddress); BOOST_CHECK(IsValidPaymentAddress(address)); - BOOST_ASSERT(boost::get(&address) != nullptr); - auto newAddr = boost::get(address); - BOOST_CHECK(pwalletMain->HaveSproutSpendingKey(newAddr)); // Check if too many args BOOST_CHECK_THROW(CallRPC("z_getnewaddress toomanyargs"), runtime_error); diff --git a/src/utiltest.cpp b/src/utiltest.cpp deleted file mode 100644 index ead7fe6a0..000000000 --- a/src/utiltest.cpp +++ /dev/null @@ -1,154 +0,0 @@ -// Copyright (c) 2016 The Zcash developers -// Copyright (c) 2019-2020 The Hush developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include "utiltest.h" - -#include "consensus/upgrades.h" - -#include - -CWalletTx GetValidReceive(ZCJoinSplit& params, - const libzcash::SproutSpendingKey& sk, CAmount value, - bool randomInputs, - int32_t version /* = 2 */) { - CMutableTransaction mtx; - mtx.nVersion = version; - mtx.vin.resize(2); - if (randomInputs) { - mtx.vin[0].prevout.hash = GetRandHash(); - mtx.vin[1].prevout.hash = GetRandHash(); - } else { - mtx.vin[0].prevout.hash = uint256S("0000000000000000000000000000000000000000000000000000000000000001"); - mtx.vin[1].prevout.hash = uint256S("0000000000000000000000000000000000000000000000000000000000000002"); - } - mtx.vin[0].prevout.n = 0; - mtx.vin[1].prevout.n = 0; - - // Generate an ephemeral keypair. - uint256 joinSplitPubKey; - unsigned char joinSplitPrivKey[crypto_sign_SECRETKEYBYTES]; - crypto_sign_keypair(joinSplitPubKey.begin(), joinSplitPrivKey); - mtx.joinSplitPubKey = joinSplitPubKey; - - std::array inputs = { - libzcash::JSInput(), // dummy input - libzcash::JSInput() // dummy input - }; - - std::array outputs = { - libzcash::JSOutput(sk.address(), value), - libzcash::JSOutput(sk.address(), value) - }; - - // Prepare JoinSplits - uint256 rt; - JSDescription jsdesc {params, mtx.joinSplitPubKey, rt, - inputs, outputs, 2*value, 0, false}; - mtx.vjoinsplit.push_back(jsdesc); - - if (version >= 4) { - // Shielded Output - OutputDescription od; - mtx.vShieldedOutput.push_back(od); - } - - // Empty output script. - uint32_t consensusBranchId = SPROUT_BRANCH_ID; - CScript scriptCode; - CTransaction signTx(mtx); - uint256 dataToBeSigned = SignatureHash(scriptCode, signTx, NOT_AN_INPUT, SIGHASH_ALL, 0, consensusBranchId); - - // Add the signature - assert(crypto_sign_detached(&mtx.joinSplitSig[0], NULL, - dataToBeSigned.begin(), 32, - joinSplitPrivKey - ) == 0); - - CTransaction tx {mtx}; - CWalletTx wtx {NULL, tx}; - return wtx; -} - -libzcash::SproutNote GetNote(ZCJoinSplit& params, - const libzcash::SproutSpendingKey& sk, - const CTransaction& tx, size_t js, size_t n) { - ZCNoteDecryption decryptor {sk.receiving_key()}; - auto hSig = tx.vjoinsplit[js].h_sig(params, tx.joinSplitPubKey); - auto note_pt = libzcash::SproutNotePlaintext::decrypt( - decryptor, - tx.vjoinsplit[js].ciphertexts[n], - tx.vjoinsplit[js].ephemeralKey, - hSig, - (unsigned char) n); - return note_pt.note(sk.address()); -} - -CWalletTx GetValidSpend(ZCJoinSplit& params, - const libzcash::SproutSpendingKey& sk, - const libzcash::SproutNote& note, CAmount value) { - CMutableTransaction mtx; - mtx.vout.resize(2); - mtx.vout[0].nValue = value; - mtx.vout[1].nValue = 0; - - // Generate an ephemeral keypair. - uint256 joinSplitPubKey; - unsigned char joinSplitPrivKey[crypto_sign_SECRETKEYBYTES]; - crypto_sign_keypair(joinSplitPubKey.begin(), joinSplitPrivKey); - mtx.joinSplitPubKey = joinSplitPubKey; - - // Fake tree for the unused witness - SproutMerkleTree tree; - - libzcash::JSOutput dummyout; - libzcash::JSInput dummyin; - - { - if (note.value() > value) { - libzcash::SproutSpendingKey dummykey = libzcash::SproutSpendingKey::random(); - libzcash::SproutPaymentAddress dummyaddr = dummykey.address(); - dummyout = libzcash::JSOutput(dummyaddr, note.value() - value); - } else if (note.value() < value) { - libzcash::SproutSpendingKey dummykey = libzcash::SproutSpendingKey::random(); - libzcash::SproutPaymentAddress dummyaddr = dummykey.address(); - libzcash::SproutNote dummynote(dummyaddr.a_pk, (value - note.value()), uint256(), uint256()); - tree.append(dummynote.cm()); - dummyin = libzcash::JSInput(tree.witness(), dummynote, dummykey); - } - } - - tree.append(note.cm()); - - std::array inputs = { - libzcash::JSInput(tree.witness(), note, sk), - dummyin - }; - - std::array outputs = { - dummyout, // dummy output - libzcash::JSOutput() // dummy output - }; - - // Prepare JoinSplits - uint256 rt = tree.root(); - JSDescription jsdesc {params, mtx.joinSplitPubKey, rt, - inputs, outputs, 0, value, false}; - mtx.vjoinsplit.push_back(jsdesc); - - // Empty output script. - uint32_t consensusBranchId = SPROUT_BRANCH_ID; - CScript scriptCode; - CTransaction signTx(mtx); - uint256 dataToBeSigned = SignatureHash(scriptCode, signTx, NOT_AN_INPUT, SIGHASH_ALL, 0, consensusBranchId); - - // Add the signature - assert(crypto_sign_detached(&mtx.joinSplitSig[0], NULL, - dataToBeSigned.begin(), 32, - joinSplitPrivKey - ) == 0); - CTransaction tx {mtx}; - CWalletTx wtx {NULL, tx}; - return wtx; -} diff --git a/src/utiltest.h b/src/utiltest.h deleted file mode 100644 index 327dc7be4..000000000 --- a/src/utiltest.h +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2016 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include "wallet/wallet.h" -#include "zcash/JoinSplit.hpp" -#include "zcash/Note.hpp" -#include "zcash/NoteEncryption.hpp" - -CWalletTx GetValidReceive(ZCJoinSplit& params, - const libzcash::SproutSpendingKey& sk, CAmount value, - bool randomInputs, - int32_t version = 2); -libzcash::SproutNote GetNote(ZCJoinSplit& params, - const libzcash::SproutSpendingKey& sk, - const CTransaction& tx, size_t js, size_t n); -CWalletTx GetValidSpend(ZCJoinSplit& params, - const libzcash::SproutSpendingKey& sk, - const libzcash::SproutNote& note, CAmount value); diff --git a/src/wallet/asyncrpcoperation_shieldcoinbase.h b/src/wallet/asyncrpcoperation_shieldcoinbase.h index b3fef0fc1..db4fb83af 100644 --- a/src/wallet/asyncrpcoperation_shieldcoinbase.h +++ b/src/wallet/asyncrpcoperation_shieldcoinbase.h @@ -1,4 +1,5 @@ // Copyright (c) 2017 The Zcash developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -123,7 +124,6 @@ public: ShieldToAddress(AsyncRPCOperation_shieldcoinbase *op, CAmount sendAmount) : m_op(op), sendAmount(sendAmount) {} - bool operator()(const libzcash::SproutPaymentAddress &zaddr) const; bool operator()(const libzcash::SaplingPaymentAddress &zaddr) const; bool operator()(const libzcash::InvalidEncoding& no) const; }; diff --git a/src/wallet/crypter.cpp b/src/wallet/crypter.cpp index 38aff1a04..9d11a55fe 100644 --- a/src/wallet/crypter.cpp +++ b/src/wallet/crypter.cpp @@ -1,6 +1,7 @@ // Copyright (c) 2009-2013 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -168,22 +169,6 @@ static bool DecryptKey(const CKeyingMaterial& vMasterKey, const std::vector& vchCryptedSecret, - const libzcash::SproutPaymentAddress& address, - libzcash::SproutSpendingKey& sk) -{ - CKeyingMaterial vchSecret; - if (!DecryptSecret(vMasterKey, vchCryptedSecret, address.GetHash(), vchSecret)) - return false; - - if (vchSecret.size() != libzcash::SerializedSproutSpendingKeySize) - return false; - - CSecureDataStream ss(vchSecret, SER_NETWORK, PROTOCOL_VERSION); - ss >> sk; - return sk.address() == address; -} static bool DecryptSaplingSpendingKey(const CKeyingMaterial& vMasterKey, const std::vector& vchCryptedSecret, @@ -207,7 +192,7 @@ bool CCryptoKeyStore::SetCrypted() LOCK2(cs_KeyStore, cs_SpendingKeyStore); if (fUseCrypto) return true; - if (!(mapKeys.empty() && mapSproutSpendingKeys.empty() && mapSaplingSpendingKeys.empty())) + if (!(mapKeys.empty() && mapSaplingSpendingKeys.empty())) return false; fUseCrypto = true; return true; @@ -260,21 +245,6 @@ bool CCryptoKeyStore::Unlock(const CKeyingMaterial& vMasterKeyIn) if (fDecryptionThoroughlyChecked) break; } - CryptedSproutSpendingKeyMap::const_iterator miSprout = mapCryptedSproutSpendingKeys.begin(); - for (; miSprout != mapCryptedSproutSpendingKeys.end(); ++miSprout) - { - const libzcash::SproutPaymentAddress &address = (*miSprout).first; - const std::vector &vchCryptedSecret = (*miSprout).second; - libzcash::SproutSpendingKey sk; - if (!DecryptSproutSpendingKey(vMasterKeyIn, vchCryptedSecret, address, sk)) - { - keyFail = true; - break; - } - keyPass = true; - if (fDecryptionThoroughlyChecked) - break; - } CryptedSaplingSpendingKeyMap::const_iterator miSapling = mapCryptedSaplingSpendingKeys.begin(); for (; miSapling != mapCryptedSaplingSpendingKeys.end(); ++miSapling) { @@ -292,7 +262,7 @@ bool CCryptoKeyStore::Unlock(const CKeyingMaterial& vMasterKeyIn) } if (keyPass && keyFail) { - LogPrintf("The wallet is probably corrupted: Some keys decrypt but not all.\n"); + LogPrintf("Oh shit! The wallet is probably corrupted: Some keys decrypt but not all.\n"); assert(false); } if (keyFail || !keyPass) @@ -440,30 +410,6 @@ bool CCryptoKeyStore::GetPubKey(const CKeyID &address, CPubKey& vchPubKeyOut) co return false; } -bool CCryptoKeyStore::AddSproutSpendingKey(const libzcash::SproutSpendingKey &sk) -{ - { - LOCK(cs_SpendingKeyStore); - if (!IsCrypted()) - return CBasicKeyStore::AddSproutSpendingKey(sk); - - if (IsLocked()) - return false; - - std::vector vchCryptedSecret; - CSecureDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - ss << sk; - CKeyingMaterial vchSecret(ss.begin(), ss.end()); - auto address = sk.address(); - if (!EncryptSecret(vMasterKey, vchSecret, address.GetHash(), vchCryptedSecret)) - return false; - - if (!AddCryptedSproutSpendingKey(address, sk.receiving_key(), vchCryptedSecret)) - return false; - } - return true; -} - bool CCryptoKeyStore::AddSaplingSpendingKey( const libzcash::SaplingExtendedSpendingKey &sk, const libzcash::SaplingPaymentAddress &defaultAddr) @@ -494,22 +440,6 @@ bool CCryptoKeyStore::AddSaplingSpendingKey( return true; } -bool CCryptoKeyStore::AddCryptedSproutSpendingKey( - const libzcash::SproutPaymentAddress &address, - const libzcash::ReceivingKey &rk, - const std::vector &vchCryptedSecret) -{ - { - LOCK(cs_SpendingKeyStore); - if (!SetCrypted()) - return false; - - mapCryptedSproutSpendingKeys[address] = vchCryptedSecret; - mapNoteDecryptors.insert(std::make_pair(address, ZCNoteDecryption(rk))); - } - return true; -} - bool CCryptoKeyStore::AddCryptedSaplingSpendingKey( const libzcash::SaplingExtendedFullViewingKey &extfvk, const std::vector &vchCryptedSecret, @@ -531,23 +461,6 @@ bool CCryptoKeyStore::AddCryptedSaplingSpendingKey( return true; } -bool CCryptoKeyStore::GetSproutSpendingKey(const libzcash::SproutPaymentAddress &address, libzcash::SproutSpendingKey &skOut) const -{ - { - LOCK(cs_SpendingKeyStore); - if (!IsCrypted()) - return CBasicKeyStore::GetSproutSpendingKey(address, skOut); - - CryptedSproutSpendingKeyMap::const_iterator mi = mapCryptedSproutSpendingKeys.find(address); - if (mi != mapCryptedSproutSpendingKeys.end()) - { - const std::vector &vchCryptedSecret = (*mi).second; - return DecryptSproutSpendingKey(vMasterKey, vchCryptedSecret, address, skOut); - } - } - return false; -} - bool CCryptoKeyStore::GetSaplingSpendingKey(const libzcash::SaplingFullViewingKey &fvk, libzcash::SaplingExtendedSpendingKey &skOut) const { { @@ -603,22 +516,6 @@ bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn) } } mapKeys.clear(); - BOOST_FOREACH(SproutSpendingKeyMap::value_type& mSproutSpendingKey, mapSproutSpendingKeys) - { - const libzcash::SproutSpendingKey &sk = mSproutSpendingKey.second; - CSecureDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - ss << sk; - CKeyingMaterial vchSecret(ss.begin(), ss.end()); - libzcash::SproutPaymentAddress address = sk.address(); - std::vector vchCryptedSecret; - if (!EncryptSecret(vMasterKeyIn, vchSecret, address.GetHash(), vchCryptedSecret)) { - return false; - } - if (!AddCryptedSproutSpendingKey(address, sk.receiving_key(), vchCryptedSecret)) { - return false; - } - } - mapSproutSpendingKeys.clear(); //! Sapling key support BOOST_FOREACH(SaplingSpendingKeyMap::value_type& mSaplingSpendingKey, mapSaplingSpendingKeys) { diff --git a/src/wallet/gtest/test_wallet.cpp b/src/wallet/gtest/test_wallet.cpp index dcc7fdfdd..0ad789137 100644 --- a/src/wallet/gtest/test_wallet.cpp +++ b/src/wallet/gtest/test_wallet.cpp @@ -139,341 +139,8 @@ TEST(WalletTests, SetupDatadirLocationRunAsFirstTest) { boost::filesystem::create_directories(pathTemp); mapArgs["-datadir"] = pathTemp.string(); } +/* -TEST(WalletTests, SproutNoteDataSerialisation) { - auto sk = libzcash::SproutSpendingKey::random(); - auto wtx = GetValidReceive(sk, 10, true); - auto note = GetNote(sk, wtx, 0, 1); - auto nullifier = note.nullifier(sk); - - mapSproutNoteData_t noteData; - JSOutPoint jsoutpt {wtx.GetHash(), 0, 1}; - SproutNoteData nd {sk.address(), nullifier}; - SproutMerkleTree tree; - nd.witnesses.push_front(tree.witness()); - noteData[jsoutpt] = nd; - - CDataStream ss(SER_DISK, CLIENT_VERSION); - ss << noteData; - - mapSproutNoteData_t noteData2; - ss >> noteData2; - - EXPECT_EQ(noteData, noteData2); - EXPECT_EQ(noteData[jsoutpt].witnesses, noteData2[jsoutpt].witnesses); -} - - -TEST(WalletTests, FindUnspentSproutNotes) { - SelectParams(CBaseChainParams::TESTNET); - CWallet wallet; - auto sk = libzcash::SproutSpendingKey::random(); - wallet.AddSproutSpendingKey(sk); - - auto wtx = GetValidReceive(sk, 10, true); - auto note = GetNote(sk, wtx, 0, 1); - auto nullifier = note.nullifier(sk); - - mapSproutNoteData_t noteData; - JSOutPoint jsoutpt {wtx.GetHash(), 0, 1}; - SproutNoteData nd {sk.address(), nullifier}; - noteData[jsoutpt] = nd; - - wtx.SetSproutNoteData(noteData); - wallet.AddToWallet(wtx, true, NULL); - EXPECT_FALSE(wallet.IsSproutSpent(nullifier)); - - // We currently have an unspent and unconfirmed note in the wallet (depth of -1) - std::vector sproutEntries; - std::vector saplingEntries; - wallet.GetFilteredNotes(sproutEntries, saplingEntries, "", 0); - EXPECT_EQ(0, sproutEntries.size()); - sproutEntries.clear(); - saplingEntries.clear(); - wallet.GetFilteredNotes(sproutEntries, saplingEntries, "", -1); - EXPECT_EQ(1, sproutEntries.size()); - sproutEntries.clear(); - saplingEntries.clear(); - - // Fake-mine the transaction - EXPECT_EQ(-1, chainActive.Height()); - CBlock block; - block.vtx.push_back(wtx); - block.hashMerkleRoot = block.BuildMerkleTree(); - auto blockHash = block.GetHash(); - CBlockIndex fakeIndex {block}; - mapBlockIndex.insert(std::make_pair(blockHash, &fakeIndex)); - chainActive.SetTip(&fakeIndex); - EXPECT_TRUE(chainActive.Contains(&fakeIndex)); - EXPECT_EQ(0, chainActive.Height()); - - wtx.SetMerkleBranch(block); - wallet.AddToWallet(wtx, true, NULL); - EXPECT_FALSE(wallet.IsSproutSpent(nullifier)); - - - // We now have an unspent and confirmed note in the wallet (depth of 1) - wallet.GetFilteredNotes(sproutEntries, saplingEntries, "", 0); - EXPECT_EQ(1, sproutEntries.size()); - sproutEntries.clear(); - saplingEntries.clear(); - wallet.GetFilteredNotes(sproutEntries, saplingEntries, "", 1); - EXPECT_EQ(1, sproutEntries.size()); - sproutEntries.clear(); - saplingEntries.clear(); - wallet.GetFilteredNotes(sproutEntries, saplingEntries, "", 2); - EXPECT_EQ(0, sproutEntries.size()); - sproutEntries.clear(); - saplingEntries.clear(); - - - // Let's spend the note. - auto wtx2 = GetValidSpend(sk, note, 5); - wallet.AddToWallet(wtx2, true, NULL); - EXPECT_FALSE(wallet.IsSproutSpent(nullifier)); - - // Fake-mine a spend transaction - EXPECT_EQ(0, chainActive.Height()); - CBlock block2; - block2.vtx.push_back(wtx2); - block2.hashMerkleRoot = block2.BuildMerkleTree(); - block2.hashPrevBlock = blockHash; - auto blockHash2 = block2.GetHash(); - CBlockIndex fakeIndex2 {block2}; - mapBlockIndex.insert(std::make_pair(blockHash2, &fakeIndex2)); - fakeIndex2.SetHeight(1); - chainActive.SetTip(&fakeIndex2); - EXPECT_TRUE(chainActive.Contains(&fakeIndex2)); - EXPECT_EQ(1, chainActive.Height()); - - wtx2.SetMerkleBranch(block2); - wallet.AddToWallet(wtx2, true, NULL); - EXPECT_TRUE(wallet.IsSproutSpent(nullifier)); - - // The note has been spent. By default, GetFilteredNotes() ignores spent notes. - wallet.GetFilteredNotes(sproutEntries, saplingEntries, "", 0); - EXPECT_EQ(0, sproutEntries.size()); - sproutEntries.clear(); - saplingEntries.clear(); - // Let's include spent notes to retrieve it. - wallet.GetFilteredNotes(sproutEntries, saplingEntries, "", 0, false); - EXPECT_EQ(1, sproutEntries.size()); - sproutEntries.clear(); - saplingEntries.clear(); - // The spent note has two confirmations. - wallet.GetFilteredNotes(sproutEntries, saplingEntries, "", 2, false); - EXPECT_EQ(1, sproutEntries.size()); - sproutEntries.clear(); - saplingEntries.clear(); - // It does not have 3 confirmations. - wallet.GetFilteredNotes(sproutEntries, saplingEntries, "", 3, false); - EXPECT_EQ(0, sproutEntries.size()); - sproutEntries.clear(); - saplingEntries.clear(); - - - // Let's receive a new note - CWalletTx wtx3; - { - auto wtx = GetValidReceive(sk, 20, true); - auto note = GetNote(sk, wtx, 0, 1); - auto nullifier = note.nullifier(sk); - - mapSproutNoteData_t noteData; - JSOutPoint jsoutpt {wtx.GetHash(), 0, 1}; - SproutNoteData nd {sk.address(), nullifier}; - noteData[jsoutpt] = nd; - - wtx.SetSproutNoteData(noteData); - wallet.AddToWallet(wtx, true, NULL); - EXPECT_FALSE(wallet.IsSproutSpent(nullifier)); - - wtx3 = wtx; - } - - // Fake-mine the new transaction - EXPECT_EQ(1, chainActive.Height()); - CBlock block3; - block3.vtx.push_back(wtx3); - block3.hashMerkleRoot = block3.BuildMerkleTree(); - block3.hashPrevBlock = blockHash2; - auto blockHash3 = block3.GetHash(); - CBlockIndex fakeIndex3 {block3}; - mapBlockIndex.insert(std::make_pair(blockHash3, &fakeIndex3)); - fakeIndex3.SetHeight(2); - chainActive.SetTip(&fakeIndex3); - EXPECT_TRUE(chainActive.Contains(&fakeIndex3)); - EXPECT_EQ(2, chainActive.Height()); - - wtx3.SetMerkleBranch(block3); - wallet.AddToWallet(wtx3, true, NULL); - - // We now have an unspent note which has one confirmation, in addition to our spent note. - wallet.GetFilteredNotes(sproutEntries, saplingEntries, "", 1); - EXPECT_EQ(1, sproutEntries.size()); - sproutEntries.clear(); - saplingEntries.clear(); - // Let's return the spent note too. - wallet.GetFilteredNotes(sproutEntries, saplingEntries, "", 1, false); - EXPECT_EQ(2, sproutEntries.size()); - sproutEntries.clear(); - saplingEntries.clear(); - // Increasing number of confirmations will exclude our new unspent note. - wallet.GetFilteredNotes(sproutEntries, saplingEntries, "", 2, false); - EXPECT_EQ(1, sproutEntries.size()); - sproutEntries.clear(); - saplingEntries.clear(); - // If we also ignore spent notes at this depth, we won't find any notes. - wallet.GetFilteredNotes(sproutEntries, saplingEntries, "", 2, true); - EXPECT_EQ(0, sproutEntries.size()); - sproutEntries.clear(); - saplingEntries.clear(); - - // Tear down - chainActive.SetTip(NULL); - mapBlockIndex.erase(blockHash); - mapBlockIndex.erase(blockHash2); - mapBlockIndex.erase(blockHash3); -} - - -TEST(WalletTests, SetSproutNoteAddrsInCWalletTx) { - auto sk = libzcash::SproutSpendingKey::random(); - auto wtx = GetValidReceive(sk, 10, true); - auto note = GetNote(sk, wtx, 0, 1); - auto nullifier = note.nullifier(sk); - EXPECT_EQ(0, wtx.mapSproutNoteData.size()); - - mapSproutNoteData_t noteData; - JSOutPoint jsoutpt {wtx.GetHash(), 0, 1}; - SproutNoteData nd {sk.address(), nullifier}; - noteData[jsoutpt] = nd; - - wtx.SetSproutNoteData(noteData); - EXPECT_EQ(noteData, wtx.mapSproutNoteData); -} - -TEST(WalletTests, SetSaplingNoteAddrsInCWalletTx) { - SelectParams(CBaseChainParams::REGTEST); - UpdateNetworkUpgradeParameters(Consensus::UPGRADE_OVERWINTER, Consensus::NetworkUpgrade::ALWAYS_ACTIVE); - UpdateNetworkUpgradeParameters(Consensus::UPGRADE_SAPLING, Consensus::NetworkUpgrade::ALWAYS_ACTIVE); - auto consensusParams = Params().GetConsensus(); - - TestWallet wallet; - - std::vector> rawSeed(32); - HDSeed seed(rawSeed); - auto sk = libzcash::SaplingExtendedSpendingKey::Master(seed); - auto expsk = sk.expsk; - auto fvk = expsk.full_viewing_key(); - auto ivk = fvk.in_viewing_key(); - auto pk = sk.DefaultAddress(); - - libzcash::SaplingNote note(pk, 50000); - auto cm = note.cm().get(); - SaplingMerkleTree tree; - tree.append(cm); - auto anchor = tree.root(); - auto witness = tree.witness(); - - auto nf = note.nullifier(fvk, witness.position()); - ASSERT_TRUE(nf); - uint256 nullifier = nf.get(); - - auto builder = TransactionBuilder(consensusParams, 1); - ASSERT_TRUE(builder.AddSaplingSpend(expsk, note, anchor, witness)); - builder.AddSaplingOutput(fvk.ovk, pk, 50000, {}); - builder.SetFee(0); - auto maybe_tx = builder.Build(); - ASSERT_EQ(static_cast(maybe_tx), true); - auto tx = maybe_tx.get(); - - CWalletTx wtx {&wallet, tx}; - - EXPECT_EQ(0, wtx.mapSaplingNoteData.size()); - mapSaplingNoteData_t noteData; - - SaplingOutPoint op {wtx.GetHash(), 0}; - SaplingNoteData nd; - nd.nullifier = nullifier; - nd.ivk = ivk; - nd.witnesses.push_front(witness); - nd.witnessHeight = 123; - noteData.insert(std::make_pair(op, nd)); - - wtx.SetSaplingNoteData(noteData); - EXPECT_EQ(noteData, wtx.mapSaplingNoteData); - - // Test individual fields in case equality operator is defined/changed. - EXPECT_EQ(ivk, wtx.mapSaplingNoteData[op].ivk); - EXPECT_EQ(nullifier, wtx.mapSaplingNoteData[op].nullifier); - EXPECT_EQ(nd.witnessHeight, wtx.mapSaplingNoteData[op].witnessHeight); - EXPECT_TRUE(witness == wtx.mapSaplingNoteData[op].witnesses.front()); - - // Revert to default - UpdateNetworkUpgradeParameters(Consensus::UPGRADE_SAPLING, Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT); - UpdateNetworkUpgradeParameters(Consensus::UPGRADE_OVERWINTER, Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT); -} - -TEST(WalletTests, SetSproutInvalidNoteAddrsInCWalletTx) { - CWalletTx wtx; - EXPECT_EQ(0, wtx.mapSproutNoteData.size()); - - mapSproutNoteData_t noteData; - auto sk = libzcash::SproutSpendingKey::random(); - JSOutPoint jsoutpt {wtx.GetHash(), 0, 1}; - SproutNoteData nd {sk.address(), uint256()}; - noteData[jsoutpt] = nd; - - EXPECT_THROW(wtx.SetSproutNoteData(noteData), std::logic_error); -} - -// The following test is the same as SetInvalidSaplingNoteDataInCWalletTx -// TEST(WalletTests, SetSaplingInvalidNoteAddrsInCWalletTx) - -// Cannot add note data for an index which does not exist in tx.vShieldedOutput -TEST(WalletTests, SetInvalidSaplingNoteDataInCWalletTx) { - CWalletTx wtx; - EXPECT_EQ(0, wtx.mapSaplingNoteData.size()); - - mapSaplingNoteData_t noteData; - SaplingOutPoint op {uint256(), 1}; - SaplingNoteData nd; - noteData.insert(std::make_pair(op, nd)); - - EXPECT_THROW(wtx.SetSaplingNoteData(noteData), std::logic_error); -} - -TEST(WalletTests, GetSproutNoteNullifier) { - CWallet wallet; - - auto sk = libzcash::SproutSpendingKey::random(); - auto address = sk.address(); - auto dec = ZCNoteDecryption(sk.receiving_key()); - - auto wtx = GetValidReceive(sk, 10, true); - auto note = GetNote(sk, wtx, 0, 1); - auto nullifier = note.nullifier(sk); - - auto hSig = wtx.vjoinsplit[0].h_sig( - *params, wtx.joinSplitPubKey); - - auto ret = wallet.GetSproutNoteNullifier( - wtx.vjoinsplit[0], - address, - dec, - hSig, 1); - EXPECT_NE(nullifier, ret); - - wallet.AddSproutSpendingKey(sk); - - ret = wallet.GetSproutNoteNullifier( - wtx.vjoinsplit[0], - address, - dec, - hSig, 1); - EXPECT_EQ(nullifier, ret); -} TEST(WalletTests, FindMySaplingNotes) { SelectParams(CBaseChainParams::REGTEST); @@ -577,92 +244,6 @@ TEST(WalletTests, FindMySaplingNotesWithIvkOnly) { UpdateNetworkUpgradeParameters(Consensus::UPGRADE_OVERWINTER, Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT); } -TEST(WalletTests, FindMySproutNotes) { - CWallet wallet; - - auto sk = libzcash::SproutSpendingKey::random(); - auto sk2 = libzcash::SproutSpendingKey::random(); - wallet.AddSproutSpendingKey(sk2); - - auto wtx = GetValidReceive(sk, 10, true); - auto note = GetNote(sk, wtx, 0, 1); - auto nullifier = note.nullifier(sk); - - auto noteMap = wallet.FindMySproutNotes(wtx); - EXPECT_EQ(0, noteMap.size()); - - wallet.AddSproutSpendingKey(sk); - - noteMap = wallet.FindMySproutNotes(wtx); - EXPECT_EQ(2, noteMap.size()); - - JSOutPoint jsoutpt {wtx.GetHash(), 0, 1}; - SproutNoteData nd {sk.address(), nullifier}; - EXPECT_EQ(1, noteMap.count(jsoutpt)); - EXPECT_EQ(nd, noteMap[jsoutpt]); -} - -TEST(WalletTests, FindMySproutNotesInEncryptedWallet) { - TestWallet wallet; - uint256 r {GetRandHash()}; - CKeyingMaterial vMasterKey (r.begin(), r.end()); - - auto sk = libzcash::SproutSpendingKey::random(); - wallet.AddSproutSpendingKey(sk); - - ASSERT_TRUE(wallet.EncryptKeys(vMasterKey)); - - auto wtx = GetValidReceive(sk, 10, true); - auto note = GetNote(sk, wtx, 0, 1); - auto nullifier = note.nullifier(sk); - - auto noteMap = wallet.FindMySproutNotes(wtx); - EXPECT_EQ(2, noteMap.size()); - - JSOutPoint jsoutpt {wtx.GetHash(), 0, 1}; - SproutNoteData nd {sk.address(), nullifier}; - EXPECT_EQ(1, noteMap.count(jsoutpt)); - EXPECT_NE(nd, noteMap[jsoutpt]); - - ASSERT_TRUE(wallet.Unlock(vMasterKey)); - - noteMap = wallet.FindMySproutNotes(wtx); - EXPECT_EQ(2, noteMap.size()); - EXPECT_EQ(1, noteMap.count(jsoutpt)); - EXPECT_EQ(nd, noteMap[jsoutpt]); -} - -TEST(WalletTests, GetConflictedSproutNotes) { - CWallet wallet; - - auto sk = libzcash::SproutSpendingKey::random(); - wallet.AddSproutSpendingKey(sk); - - auto wtx = GetValidReceive(sk, 10, true); - auto note = GetNote(sk, wtx, 0, 1); - auto nullifier = note.nullifier(sk); - - auto wtx2 = GetValidSpend(sk, note, 5); - auto wtx3 = GetValidSpend(sk, note, 10); - auto hash2 = wtx2.GetHash(); - auto hash3 = wtx3.GetHash(); - - // No conflicts for no spends - EXPECT_EQ(0, wallet.GetConflicts(hash2).size()); - wallet.AddToWallet(wtx, true, NULL); - EXPECT_EQ(0, wallet.GetConflicts(hash2).size()); - - // No conflicts for one spend - wallet.AddToWallet(wtx2, true, NULL); - EXPECT_EQ(0, wallet.GetConflicts(hash2).size()); - - // Conflicts for two spends - wallet.AddToWallet(wtx3, true, NULL); - auto c3 = wallet.GetConflicts(hash2); - EXPECT_EQ(2, c3.size()); - EXPECT_EQ(std::set({hash2, hash3}), c3); -} - // Generate note A and spend to create note B, from which we spend to create two conflicting transactions TEST(WalletTests, GetConflictedSaplingNotes) { SelectParams(CBaseChainParams::REGTEST); @@ -1735,88 +1316,6 @@ TEST(WalletTests, SetBestChainIgnoresTxsWithoutShieldedData) { wallet.SetBestChain(walletdb, loc); } -TEST(WalletTests, UpdateSproutNullifierNoteMap) { - TestWallet wallet; - uint256 r {GetRandHash()}; - CKeyingMaterial vMasterKey (r.begin(), r.end()); - - auto sk = libzcash::SproutSpendingKey::random(); - wallet.AddSproutSpendingKey(sk); - - ASSERT_TRUE(wallet.EncryptKeys(vMasterKey)); - - auto wtx = GetValidReceive(sk, 10, true); - auto note = GetNote(sk, wtx, 0, 1); - auto nullifier = note.nullifier(sk); - - // Pretend that we called FindMySproutNotes while the wallet was locked - mapSproutNoteData_t noteData; - JSOutPoint jsoutpt {wtx.GetHash(), 0, 1}; - SproutNoteData nd {sk.address()}; - noteData[jsoutpt] = nd; - wtx.SetSproutNoteData(noteData); - - wallet.AddToWallet(wtx, true, NULL); - EXPECT_EQ(0, wallet.mapSproutNullifiersToNotes.count(nullifier)); - - EXPECT_FALSE(wallet.UpdateNullifierNoteMap()); - - ASSERT_TRUE(wallet.Unlock(vMasterKey)); - - EXPECT_TRUE(wallet.UpdateNullifierNoteMap()); - EXPECT_EQ(1, wallet.mapSproutNullifiersToNotes.count(nullifier)); - EXPECT_EQ(wtx.GetHash(), wallet.mapSproutNullifiersToNotes[nullifier].hash); - EXPECT_EQ(0, wallet.mapSproutNullifiersToNotes[nullifier].js); - EXPECT_EQ(1, wallet.mapSproutNullifiersToNotes[nullifier].n); -} - -TEST(WalletTests, UpdatedSproutNoteData) { - TestWallet wallet; - - auto sk = libzcash::SproutSpendingKey::random(); - wallet.AddSproutSpendingKey(sk); - - auto wtx = GetValidReceive(sk, 10, true); - auto note = GetNote(sk, wtx, 0, 0); - auto note2 = GetNote(sk, wtx, 0, 1); - auto nullifier = note.nullifier(sk); - auto nullifier2 = note2.nullifier(sk); - auto wtx2 = wtx; - - // First pretend we added the tx to the wallet and - // we don't have the key for the second note - mapSproutNoteData_t noteData; - JSOutPoint jsoutpt {wtx.GetHash(), 0, 0}; - SproutNoteData nd {sk.address(), nullifier}; - noteData[jsoutpt] = nd; - wtx.SetSproutNoteData(noteData); - - // Pretend we mined the tx by adding a fake witness - SproutMerkleTree tree; - wtx.mapSproutNoteData[jsoutpt].witnesses.push_front(tree.witness()); - wtx.mapSproutNoteData[jsoutpt].witnessHeight = 100; - - // Now pretend we added the key for the second note, and - // the tx was "added" to the wallet again to update it. - // This happens via the 'z_importkey' RPC method. - JSOutPoint jsoutpt2 {wtx2.GetHash(), 0, 1}; - SproutNoteData nd2 {sk.address(), nullifier2}; - noteData[jsoutpt2] = nd2; - wtx2.SetSproutNoteData(noteData); - - // The txs should initially be different - EXPECT_NE(wtx.mapSproutNoteData, wtx2.mapSproutNoteData); - EXPECT_EQ(1, wtx.mapSproutNoteData[jsoutpt].witnesses.size()); - EXPECT_EQ(100, wtx.mapSproutNoteData[jsoutpt].witnessHeight); - - // After updating, they should be the same - EXPECT_TRUE(wallet.UpdatedNoteData(wtx2, wtx)); - EXPECT_EQ(wtx.mapSproutNoteData, wtx2.mapSproutNoteData); - EXPECT_EQ(1, wtx.mapSproutNoteData[jsoutpt].witnesses.size()); - EXPECT_EQ(100, wtx.mapSproutNoteData[jsoutpt].witnessHeight); - // TODO: The new note should get witnessed (but maybe not here) (#1350) -} - TEST(WalletTests, UpdatedSaplingNoteData) { SelectParams(CBaseChainParams::REGTEST); UpdateNetworkUpgradeParameters(Consensus::UPGRADE_OVERWINTER, Consensus::NetworkUpgrade::ALWAYS_ACTIVE); @@ -1941,37 +1440,6 @@ TEST(WalletTests, UpdatedSaplingNoteData) { UpdateNetworkUpgradeParameters(Consensus::UPGRADE_OVERWINTER, Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT); } -TEST(WalletTests, MarkAffectedSproutTransactionsDirty) { - TestWallet wallet; - - auto sk = libzcash::SproutSpendingKey::random(); - wallet.AddSproutSpendingKey(sk); - - auto wtx = GetValidReceive(sk, 10, true); - auto hash = wtx.GetHash(); - auto note = GetNote(sk, wtx, 0, 1); - auto nullifier = note.nullifier(sk); - auto wtx2 = GetValidSpend(sk, note, 5); - - mapSproutNoteData_t noteData; - JSOutPoint jsoutpt {hash, 0, 1}; - SproutNoteData nd {sk.address(), nullifier}; - noteData[jsoutpt] = nd; - - wtx.SetSproutNoteData(noteData); - wallet.AddToWallet(wtx, true, NULL); - wallet.MarkAffectedTransactionsDirty(wtx); - - // After getting a cached value, the first tx should be clean - wallet.mapWallet[hash].GetDebit(ISMINE_ALL); - EXPECT_TRUE(wallet.mapWallet[hash].fDebitCached); - - // After adding the note spend, the first tx should be dirty - wallet.AddToWallet(wtx2, true, NULL); - wallet.MarkAffectedTransactionsDirty(wtx2); - EXPECT_FALSE(wallet.mapWallet[hash].fDebitCached); -} - TEST(WalletTests, MarkAffectedSaplingTransactionsDirty) { SelectParams(CBaseChainParams::REGTEST); UpdateNetworkUpgradeParameters(Consensus::UPGRADE_OVERWINTER, Consensus::NetworkUpgrade::ALWAYS_ACTIVE); @@ -1999,7 +1467,7 @@ TEST(WalletTests, MarkAffectedSaplingTransactionsDirty) { auto scriptPubKey = GetScriptForDestination(tsk.GetPubKey().GetID()); // Generate shielding tx from transparent to Sapling - // 0.0005 t-ZEC in, 0.0004 z-ZEC out, 0.0001 t-ZEC fee + // 0.0005 t-HUSH in, 0.0004 z-HUSH out, 0.0001 t-HUSH fee auto builder = TransactionBuilder(consensusParams, 1, &keystore); builder.AddTransparentInput(COutPoint(), scriptPubKey, 50000); builder.AddSaplingOutput(fvk.ovk, pk, 40000, {}); @@ -2093,39 +1561,7 @@ TEST(WalletTests, MarkAffectedSaplingTransactionsDirty) { UpdateNetworkUpgradeParameters(Consensus::UPGRADE_SAPLING, Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT); UpdateNetworkUpgradeParameters(Consensus::UPGRADE_OVERWINTER, Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT); } - -TEST(WalletTests, SproutNoteLocking) { - TestWallet wallet; - - auto sk = libzcash::SproutSpendingKey::random(); - wallet.AddSproutSpendingKey(sk); - - auto wtx = GetValidReceive(sk, 10, true); - auto wtx2 = GetValidReceive(sk, 10, true); - - JSOutPoint jsoutpt {wtx.GetHash(), 0, 0}; - JSOutPoint jsoutpt2 {wtx2.GetHash(),0, 0}; - - // Test selective locking - wallet.LockNote(jsoutpt); - EXPECT_TRUE(wallet.IsLockedNote(jsoutpt)); - EXPECT_FALSE(wallet.IsLockedNote(jsoutpt2)); - - // Test selective unlocking - wallet.UnlockNote(jsoutpt); - EXPECT_FALSE(wallet.IsLockedNote(jsoutpt)); - - // Test multiple locking - wallet.LockNote(jsoutpt); - wallet.LockNote(jsoutpt2); - EXPECT_TRUE(wallet.IsLockedNote(jsoutpt)); - EXPECT_TRUE(wallet.IsLockedNote(jsoutpt2)); - - // Test unlock all - wallet.UnlockAllSproutNotes(); - EXPECT_FALSE(wallet.IsLockedNote(jsoutpt)); - EXPECT_FALSE(wallet.IsLockedNote(jsoutpt2)); -} +*/ TEST(WalletTests, SaplingNoteLocking) { TestWallet wallet; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 37f67042b..d3d396bbc 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5487,34 +5487,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp "Cannot send between Sprout and Sapling addresses using z_mergetoaddress"); } - // Find unspent notes and update estimated size - for (const CSproutNotePlaintextEntry& entry : sproutEntries) { - noteCounter++; - CAmount nValue = entry.plaintext.value(); - - if (!maxedOutNotesFlag) { - // If we haven't added any notes yet and the merge is to a - // z-address, we have already accounted for the first JoinSplit. - size_t increase = (sproutNoteInputs.empty() && !isToSproutZaddr) || (sproutNoteInputs.size() % 2 == 0) ? JOINSPLIT_SIZE : 0; - if (estimatedTxSize + increase >= max_tx_size || - (sproutNoteLimit > 0 && noteCounter > sproutNoteLimit)) - { - maxedOutNotesFlag = true; - } else { - estimatedTxSize += increase; - auto zaddr = entry.address; - SproutSpendingKey zkey; - pwalletMain->GetSproutSpendingKey(zaddr, zkey); - sproutNoteInputs.emplace_back(entry.jsop, entry.plaintext.note(zaddr), nValue, zkey); - mergedNoteValue += nValue; - } - } - - if (maxedOutNotesFlag) { - remainingNoteValue += nValue; - } - } - for (const SaplingNoteEntry& entry : saplingEntries) { noteCounter++; CAmount nValue = entry.note.value(); diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index d82e100ed..f3526c583 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1408,7 +1408,6 @@ private: public: PaymentAddressBelongsToWallet(CWallet *wallet) : m_wallet(wallet) {} - bool operator()(const libzcash::SproutPaymentAddress &zaddr) const; bool operator()(const libzcash::SaplingPaymentAddress &zaddr) const; bool operator()(const libzcash::InvalidEncoding& no) const; }; @@ -1421,7 +1420,6 @@ private: public: IncomingViewingKeyBelongsToWallet(CWallet *wallet) : m_wallet(wallet) {} - bool operator()(const libzcash::SproutPaymentAddress &zaddr) const; bool operator()(const libzcash::SaplingPaymentAddress &zaddr) const; bool operator()(const libzcash::InvalidEncoding& no) const; }; @@ -1433,7 +1431,6 @@ private: public: HaveSpendingKeyForPaymentAddress(CWallet *wallet) : m_wallet(wallet) {} - bool operator()(const libzcash::SproutPaymentAddress &zaddr) const; bool operator()(const libzcash::SaplingPaymentAddress &zaddr) const; bool operator()(const libzcash::InvalidEncoding& no) const; }; @@ -1445,7 +1442,6 @@ private: public: GetSpendingKeyForPaymentAddress(CWallet *wallet) : m_wallet(wallet) {} - boost::optional operator()(const libzcash::SproutPaymentAddress &zaddr) const; boost::optional operator()(const libzcash::SaplingPaymentAddress &zaddr) const; boost::optional operator()(const libzcash::InvalidEncoding& no) const; }; @@ -1517,7 +1513,6 @@ public: ) : m_wallet(wallet), params(params), nTime(_nTime), hdKeypath(_hdKeypath), seedFpStr(_seedFp), log(_log) {} - SpendingKeyAddResult operator()(const libzcash::SproutSpendingKey &sk) const; SpendingKeyAddResult operator()(const libzcash::SaplingExtendedSpendingKey &sk) const; SpendingKeyAddResult operator()(const libzcash::InvalidEncoding& no) const; }; diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 1177bbedd..71331ed93 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -653,6 +653,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, } else if (strType == "czkey") { + /* libzcash::SproutPaymentAddress addr; ssKey >> addr; // Deserialization of a pair is just one item after another @@ -663,12 +664,13 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, ssValue >> vchCryptedSecret; wss.nCKeys++; - //if (!pwallet->LoadCryptedZKey(addr, rk, vchCryptedSecret)) - //{ - // strErr = "Error reading wallet database: LoadCryptedZKey failed"; - // return false; - //} - //wss.fIsEncrypted = true; + if (!pwallet->LoadCryptedZKey(addr, rk, vchCryptedSecret)) + { + strErr = "Error reading wallet database: LoadCryptedZKey failed"; + return false; + } + wss.fIsEncrypted = true; + */ } else if (strType == "csapzkey") { @@ -704,11 +706,13 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, } else if (strType == "zkeymeta") { + /* libzcash::SproutPaymentAddress addr; ssKey >> addr; CKeyMetadata keyMeta; ssValue >> keyMeta; wss.nZKeyMeta++; + */ // pwallet->LoadZKeyMetadata(addr, keyMeta); diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h index 9069e3a08..64a4817d9 100644 --- a/src/wallet/walletdb.h +++ b/src/wallet/walletdb.h @@ -1,7 +1,8 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers +// Copyright (c) 2009-2013 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -199,23 +200,15 @@ public: bool WriteHDChain(const CHDChain& chain); /// Write spending key to wallet database, where key is payment address and value is spending key. - bool WriteZKey(const libzcash::SproutPaymentAddress& addr, const libzcash::SproutSpendingKey& key, const CKeyMetadata &keyMeta); bool WriteSaplingZKey(const libzcash::SaplingIncomingViewingKey &ivk, const libzcash::SaplingExtendedSpendingKey &key, const CKeyMetadata &keyMeta); bool WriteSaplingPaymentAddress(const libzcash::SaplingPaymentAddress &addr, const libzcash::SaplingIncomingViewingKey &ivk); - bool WriteCryptedZKey(const libzcash::SproutPaymentAddress & addr, - const libzcash::ReceivingKey & rk, - const std::vector& vchCryptedSecret, - const CKeyMetadata &keyMeta); bool WriteCryptedSaplingZKey(const libzcash::SaplingExtendedFullViewingKey &extfvk, const std::vector& vchCryptedSecret, const CKeyMetadata &keyMeta); - bool WriteSproutViewingKey(const libzcash::SproutViewingKey &vk); - bool EraseSproutViewingKey(const libzcash::SproutViewingKey &vk); - private: CWalletDB(const CWalletDB&); void operator=(const CWalletDB&); diff --git a/src/zcash/Address.cpp b/src/zcash/Address.cpp index 148cd321c..5ce66a82f 100644 --- a/src/zcash/Address.cpp +++ b/src/zcash/Address.cpp @@ -1,3 +1,7 @@ +// Copyright (c) 2019-2020 The Hush developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or https://www.opensource.org/licenses/mit-license.php + #include "Address.hpp" #include "NoteEncryption.hpp" #include "hash.h" @@ -13,36 +17,6 @@ const uint32_t SAPLING_BRANCH_ID = 0x76b809bb; namespace libzcash { -uint256 SproutPaymentAddress::GetHash() const { - CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - ss << *this; - return Hash(ss.begin(), ss.end()); -} - -uint256 ReceivingKey::pk_enc() const { - return ZCNoteEncryption::generate_pubkey(*this); -} - -SproutPaymentAddress SproutViewingKey::address() const { - return SproutPaymentAddress(a_pk, sk_enc.pk_enc()); -} - -ReceivingKey SproutSpendingKey::receiving_key() const { - return ReceivingKey(ZCNoteEncryption::generate_privkey(*this)); -} - -SproutViewingKey SproutSpendingKey::viewing_key() const { - return SproutViewingKey(PRF_addr_a_pk(*this), receiving_key()); -} - -SproutSpendingKey SproutSpendingKey::random() { - return SproutSpendingKey(random_uint252()); -} - -SproutPaymentAddress SproutSpendingKey::address() const { - return viewing_key().address(); -} - //! Sapling uint256 SaplingPaymentAddress::GetHash() const { CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); @@ -119,10 +93,6 @@ class IsValidAddressForNetwork : public boost::static_visitor { public: IsValidAddressForNetwork(uint32_t consensusBranchId) : branchId(consensusBranchId) {} - bool operator()(const libzcash::SproutPaymentAddress &addr) const { - return true; - } - bool operator()(const libzcash::InvalidEncoding &addr) const { return false; } diff --git a/src/zcbenchmarks.cpp b/src/zcbenchmarks.cpp index 9af3c184a..152ad7295 100644 --- a/src/zcbenchmarks.cpp +++ b/src/zcbenchmarks.cpp @@ -25,7 +25,6 @@ #include "sodium.h" #include "streams.h" #include "txdb.h" -#include "utiltest.h" #include "wallet/wallet.h" #include "zcbenchmarks.h" @@ -41,7 +40,7 @@ void pre_wallet_load() { LogPrintf("%s: In progress...\n", __func__); if (ShutdownRequested()) - throw new std::runtime_error("The node is shutting down"); + throw new std::runtime_error("The Hush node is shutting down"); if (pwalletMain) pwalletMain->Flush(false); @@ -93,37 +92,6 @@ double benchmark_sleep() return timer_stop(tv_start); } -std::vector benchmark_create_joinsplit_threaded(int nThreads) -{ - std::vector ret; - std::vector> tasks; - std::vector threads; - for (int i = 0; i < nThreads; i++) { - std::packaged_task task(&benchmark_create_joinsplit); - tasks.emplace_back(task.get_future()); - threads.emplace_back(std::move(task)); - } - std::future_status status; - for (auto it = tasks.begin(); it != tasks.end(); it++) { - it->wait(); - ret.push_back(it->get()); - } - for (auto it = threads.begin(); it != threads.end(); it++) { - it->join(); - } - return ret; -} - -double benchmark_verify_joinsplit(const JSDescription &joinsplit) -{ - struct timeval tv_start; - timer_start(tv_start); - uint256 joinSplitPubKey; - auto verifier = libzcash::ProofVerifier::Strict(); - joinsplit.Verify(*pzcashParams, verifier, joinSplitPubKey); - return timer_stop(tv_start); -} - #ifdef ENABLE_MINING double benchmark_solve_equihash() { From 2c661422928dd1de743b02f29c0dc88cb24608e5 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 5 Jun 2020 01:22:51 -0400 Subject: [PATCH 047/255] desprout --- src/key_io.cpp | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/key_io.cpp b/src/key_io.cpp index dd4bf884c..2626a0b9b 100644 --- a/src/key_io.cpp +++ b/src/key_io.cpp @@ -321,20 +321,6 @@ std::string EncodeViewingKey(const libzcash::ViewingKey& vk) libzcash::ViewingKey DecodeViewingKey(const std::string& str) { std::vector data; - if (DecodeBase58Check(str, data)) { - const std::vector& vk_prefix = Params().Base58Prefix(CChainParams::ZCVIEWING_KEY); - if ((data.size() == libzcash::SerializedSproutViewingKeySize + vk_prefix.size()) && - std::equal(vk_prefix.begin(), vk_prefix.end(), data.begin())) { - CSerializeData serialized(data.begin() + vk_prefix.size(), data.end()); - CDataStream ss(serialized, SER_NETWORK, PROTOCOL_VERSION); - libzcash::SproutViewingKey ret; - ss >> ret; - memory_cleanse(serialized.data(), serialized.size()); - memory_cleanse(data.data(), data.size()); - return ret; - } - } - data.clear(); auto bech = bech32::Decode(str); if(bech.first == Params().Bech32HRP(CChainParams::SAPLING_INCOMING_VIEWING_KEY) && bech.second.size() == ConvertedSaplingIncomingViewingKeySize) { From 42a862650b4cfbe7a3f0c156cef68be4f7fa3a99 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 5 Jun 2020 01:34:55 -0400 Subject: [PATCH 048/255] desprout --- src/key_io.cpp | 14 -------------- src/key_io.h | 1 + src/test/coins_tests.cpp | 17 +---------------- 3 files changed, 2 insertions(+), 30 deletions(-) diff --git a/src/key_io.cpp b/src/key_io.cpp index 2626a0b9b..319c24eef 100644 --- a/src/key_io.cpp +++ b/src/key_io.cpp @@ -344,20 +344,6 @@ std::string EncodeSpendingKey(const libzcash::SpendingKey& zkey) libzcash::SpendingKey DecodeSpendingKey(const std::string& str) { std::vector data; - if (DecodeBase58Check(str, data)) { - const std::vector& zkey_prefix = Params().Base58Prefix(CChainParams::ZCSPENDING_KEY); - if ((data.size() == libzcash::SerializedSproutSpendingKeySize + zkey_prefix.size()) && - std::equal(zkey_prefix.begin(), zkey_prefix.end(), data.begin())) { - CSerializeData serialized(data.begin() + zkey_prefix.size(), data.end()); - CDataStream ss(serialized, SER_NETWORK, PROTOCOL_VERSION); - libzcash::SproutSpendingKey ret; - ss >> ret; - memory_cleanse(serialized.data(), serialized.size()); - memory_cleanse(data.data(), data.size()); - return ret; - } - } - data.clear(); auto bech = bech32::Decode(str); if (bech.first == Params().Bech32HRP(CChainParams::SAPLING_EXTENDED_SPEND_KEY) && bech.second.size() == ConvertedSaplingExtendedSpendingKeySize) { diff --git a/src/key_io.h b/src/key_io.h index 013469ab6..567c9a2f2 100644 --- a/src/key_io.h +++ b/src/key_io.h @@ -1,6 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2015 The Bitcoin Core developers // Copyright (c) 2016-2018 The Zcash developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp index bb6432a81..8067b42b9 100644 --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -39,22 +40,6 @@ public: hashBestSaplingAnchor_ = SaplingMerkleTree::empty_root(); } - bool GetSproutAnchorAt(const uint256& rt, SproutMerkleTree &tree) const { - if (rt == SproutMerkleTree::empty_root()) { - SproutMerkleTree new_tree; - tree = new_tree; - return true; - } - - std::map::const_iterator it = mapSproutAnchors_.find(rt); - if (it == mapSproutAnchors_.end()) { - return false; - } else { - tree = it->second; - return true; - } - } - bool GetSaplingAnchorAt(const uint256& rt, SaplingMerkleTree &tree) const { if (rt == SaplingMerkleTree::empty_root()) { SaplingMerkleTree new_tree; From f7b1c1f26f537c4ba79eef257360aa81ce4a3208 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 5 Jun 2020 07:20:38 -0400 Subject: [PATCH 049/255] Delete Payment Disclosures This code will be "experimental" forever, only supports Sprout, and is a piece of shit. Deleting with fire. Sapling viewing keys are the replacement, which already exist. --- doc/payment-disclosure.md | 107 ------ qa/pull-tester/rpc-tests.sh | 1 - qa/rpc-tests/paymentdisclosure.py | 215 ------------ src/Makefile.am | 7 - src/gtest/test_paymentdisclosure.cpp | 211 ------------ src/paymentdisclosure.cpp | 65 ---- src/paymentdisclosure.h | 149 -------- src/paymentdisclosuredb.cpp | 93 ----- src/paymentdisclosuredb.h | 42 --- .../asyncrpcoperation_mergetoaddress.cpp | 20 +- src/wallet/asyncrpcoperation_mergetoaddress.h | 7 +- src/wallet/asyncrpcoperation_sendmany.cpp | 17 +- src/wallet/asyncrpcoperation_sendmany.h | 7 +- .../asyncrpcoperation_shieldcoinbase.cpp | 19 - src/wallet/asyncrpcoperation_shieldcoinbase.h | 7 - src/wallet/rpcdisclosure.cpp | 324 ------------------ src/zcash/NoteEncryption.cpp | 50 +-- src/zcash/NoteEncryption.hpp | 29 +- 18 files changed, 8 insertions(+), 1362 deletions(-) delete mode 100644 doc/payment-disclosure.md delete mode 100755 qa/rpc-tests/paymentdisclosure.py delete mode 100644 src/gtest/test_paymentdisclosure.cpp delete mode 100644 src/paymentdisclosure.cpp delete mode 100644 src/paymentdisclosure.h delete mode 100644 src/paymentdisclosuredb.cpp delete mode 100644 src/paymentdisclosuredb.h delete mode 100644 src/wallet/rpcdisclosure.cpp diff --git a/doc/payment-disclosure.md b/doc/payment-disclosure.md deleted file mode 100644 index 02b4167da..000000000 --- a/doc/payment-disclosure.md +++ /dev/null @@ -1,107 +0,0 @@ -# Payment Disclosure (Experimental Feature) - -**Summary** - -Use RPC calls `z_getpaymentdisclosure` and `z_validatepaymentdisclosure` to reveal details of a shielded payment. - -**Who should read this document** - -Frequent users of shielded transactions, payment processors, exchanges, block explorer - -### Experimental Feature - -This is an experimental feature. Enable it by launching `zcashd` with flags: - - zcashd -experimentalfeatures -paymentdisclosure -debug=paymentdisclosure -txindex=1 - -These flags can also be set as options in `zcash.conf`. - -All nodes that generate or validate payment disclosures must run with `txindex=1` enabled. - -### Background - -Payment Disclosure is an implementation of the work-in-progress Payment Disclosure ZIP [1]. - -The ZIP describes a method of proving that a payment was sent to a shielded address. In the typical case, this means enabling a sender to present a proof that they transferred funds to a recipient's shielded address. - -[1] https://github.com/zcash/zips/pull/119 - -### Example Use Case - -Alice the customer sends 10 HUSH to Bob the merchant at the shielded address shown on their website. However, Bob is not sure if he received the funds. - -Alice's node is running with payment disclosure enabled, so Alice generates a payment disclosure and provides it to Bob, who verifies the payment was made. - -If Bob is a bad merchant, Alice can present the payment disclosure to a third party to validate that payment was indeed made. - -### Solution - -A payment disclosure can be generated for any output of a JoinSplit using the RPC call: - - z_getpaymentdisclosure txid js_index output_index (message) - -An optional message can be supplied. This could be used for a refund address or some other reference, as currently it is not common practice to (ahead of time) include a refund address in the memo field when making a payment. - -To validate a payment disclosure, the following RPC call can be used: - - z_validatepaymentdisclosure hexdata - -### Example - -Generate a payment disclosure for the first joinsplit, second output (index starts from zero): - - hush-cli z_getpaymentdisclosure 79189528d611e811a1c7bb0358dd31343033d14b4c1e998d7c4799c40f8b652b 0 1 "Hello" - -This returns a payment disclosure in the form of a hex string: - - 706462ff000a3722aafa8190cdf9710bfad6da2af6d3a74262c1fc96ad47df814b0cd5641c2b658b0fc499477c8d991e4c4bd133303431dd5803bbc7a111e811d6289518790000000000000000017e861adb829d8cb1cbcf6330b8c2e25fb0d08041a67a857815a136f0227f8a5342bce5b3c0d894e2983000eb594702d3c1580817d0374e15078528e56bb6f80c0548656c6c6f59a7085395c9e706d82afe3157c54ad4ae5bf144fcc774a8d9c921c58471402019c156ec5641e2173c4fb6467df5f28530dc4636fa71f4d0e48fc5c560fac500 - -To validate the payment disclosure: - - hush-cli z_validatepaymentdisclosure HEXDATA - -This returns data related to the payment and the payment disclosure: - - { - "txid": "79189528d611e811a1c7bb0358dd31343033d14b4c1e998d7c4799c40f8b652b", - "jsIndex": 0, - "outputIndex": 1, - "version": 0, - "onetimePrivKey": "1c64d50c4b81df47ad96fcc16242a7d3f62adad6fa0b71f9cd9081faaa22370a", - "message": "Hello", - "joinSplitPubKey": "d1c465d16166b602992479acfac18e87dc18065f6cefde6a002e70bc371b9faf", - "signatureVerified": true, - "paymentAddress": "ztaZJXy8iX8nrk2ytXKDBoTWqPkhQcj6E2ifARnD3wfkFwsxXs5SoX7NGmrjkzSiSKn8VtLHTJae48vX5NakvmDhtGNY5eb", - "memo": "f600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", - "value": 12.49900000, - "commitmentMatch": true, - "valid": true - } - -The `signatureVerified` field confirms that the payment disclosure was generated and signed with the joinSplitPrivKey, which should only be known by the node generating and sending the transaction 7918...652b in question. - -### Where is the data stored? - -For all nodes, payment disclosure does not touch `wallet.dat` in any way. - -For nodes that only validate payment disclosures, no data is stored locally. - -For nodes that generate payment disclosures, a LevelDB database is created in the node's datadir. For most users, this would be in the folder: - - $HOME/.zcash/paymentdisclosure - -If you decide you don't want to use payment disclosure, it is safe to shut down your node and delete the database folder. - -### Security Properties - -Please consult the work-in-progress ZIP for details about the protocol, security properties and caveats. - -### Reminder - -Feedback is most welcome! - -This is an experimental feature so there are no guarantees that the protocol, database format, RPC interface etc. will remain the same in the future. - -### Notes - -Currently there is no user friendly way to help senders identify which joinsplit output index maps to a given payment they made. It is possible to construct this from `debug.log`. Ideas and feedback are most welcome on how to improve the user experience. diff --git a/qa/pull-tester/rpc-tests.sh b/qa/pull-tester/rpc-tests.sh index a23f2908d..94429cb7f 100755 --- a/qa/pull-tester/rpc-tests.sh +++ b/qa/pull-tester/rpc-tests.sh @@ -17,7 +17,6 @@ testScripts=( 'dpow.py' 'dpowconfs.py' 'ac_private.py' - 'paymentdisclosure.py' 'prioritisetransaction.py' 'wallet_treestate.py' 'wallet_anchorfork.py' diff --git a/qa/rpc-tests/paymentdisclosure.py b/qa/rpc-tests/paymentdisclosure.py deleted file mode 100755 index 48d4712a9..000000000 --- a/qa/rpc-tests/paymentdisclosure.py +++ /dev/null @@ -1,215 +0,0 @@ -#!/usr/bin/env python2 -# Copyright (c) 2017 The Zcash developers -# Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. - -from test_framework.test_framework import BitcoinTestFramework -from test_framework.authproxy import JSONRPCException -from test_framework.util import assert_equal, initialize_chain_clean, \ - start_node, connect_nodes_bi, wait_and_assert_operationid_status - -from decimal import Decimal - -class PaymentDisclosureTest (BitcoinTestFramework): - - def setup_chain(self): - print("Initializing test directory "+self.options.tmpdir) - initialize_chain_clean(self.options.tmpdir, 4) - - def setup_network(self, split=False): - args = ['-debug=zrpcunsafe,paymentdisclosure', '-experimentalfeatures', '-paymentdisclosure', '-txindex=1'] - self.nodes = [] - self.nodes.append(start_node(0, self.options.tmpdir, args)) - self.nodes.append(start_node(1, self.options.tmpdir, args)) - # node 2 does not enable payment disclosure - args2 = ['-debug=zrpcunsafe', '-experimentalfeatures', '-txindex=1'] - self.nodes.append(start_node(2, self.options.tmpdir, args2)) - connect_nodes_bi(self.nodes,0,1) - connect_nodes_bi(self.nodes,1,2) - connect_nodes_bi(self.nodes,0,2) - self.is_network_split=False - self.sync_all() - - def run_test (self): - print "Mining blocks..." - - self.nodes[0].generate(4) - walletinfo = self.nodes[0].getwalletinfo() - assert_equal(walletinfo['immature_balance'], 40) - assert_equal(walletinfo['balance'], 0) - self.sync_all() - self.nodes[2].generate(3) - self.sync_all() - self.nodes[1].generate(101) - self.sync_all() - assert_equal(self.nodes[0].getbalance(), 40) - assert_equal(self.nodes[1].getbalance(), 10) - assert_equal(self.nodes[2].getbalance(), 30) - - mytaddr = self.nodes[0].getnewaddress() - myzaddr = self.nodes[0].z_getnewaddress() - - # Check that Node 2 has payment disclosure disabled. - try: - self.nodes[2].z_getpaymentdisclosure("invalidtxid", 0, 0) - assert(False) - except JSONRPCException as e: - errorString = e.error['message'] - assert("payment disclosure is disabled" in errorString) - - # Check that Node 0 returns an error for an unknown txid - try: - self.nodes[0].z_getpaymentdisclosure("invalidtxid", 0, 0) - assert(False) - except JSONRPCException as e: - errorString = e.error['message'] - assert("No information available about transaction" in errorString) - - # Shield coinbase utxos from node 0 of value 40, standard fee of 0.00010000 - recipients = [{"address":myzaddr, "amount":Decimal('40.0')-Decimal('0.0001')}] - myopid = self.nodes[0].z_sendmany(mytaddr, recipients) - txid = wait_and_assert_operationid_status(self.nodes[0], myopid) - - # Check the tx has joinsplits - assert( len(self.nodes[0].getrawtransaction("" + txid, 1)["vjoinsplit"]) > 0 ) - - # Sync mempools - self.sync_all() - - # Confirm that you can't create a payment disclosure for an unconfirmed tx - try: - self.nodes[0].z_getpaymentdisclosure(txid, 0, 0) - assert(False) - except JSONRPCException as e: - errorString = e.error['message'] - assert("Transaction has not been confirmed yet" in errorString) - - try: - self.nodes[1].z_getpaymentdisclosure(txid, 0, 0) - assert(False) - except JSONRPCException as e: - errorString = e.error['message'] - assert("Transaction has not been confirmed yet" in errorString) - - # Mine tx - self.nodes[0].generate(1) - self.sync_all() - - # Confirm that Node 1 cannot create a payment disclosure for a transaction which does not impact its wallet - try: - self.nodes[1].z_getpaymentdisclosure(txid, 0, 0) - assert(False) - except JSONRPCException as e: - errorString = e.error['message'] - assert("Transaction does not belong to the wallet" in errorString) - - # Check that an invalid joinsplit index is rejected - try: - self.nodes[0].z_getpaymentdisclosure(txid, 1, 0) - assert(False) - except JSONRPCException as e: - errorString = e.error['message'] - assert("Invalid js_index" in errorString) - - try: - self.nodes[0].z_getpaymentdisclosure(txid, -1, 0) - assert(False) - except JSONRPCException as e: - errorString = e.error['message'] - assert("Invalid js_index" in errorString) - - # Check that an invalid output index is rejected - try: - self.nodes[0].z_getpaymentdisclosure(txid, 0, 2) - assert(False) - except JSONRPCException as e: - errorString = e.error['message'] - assert("Invalid output_index" in errorString) - - try: - self.nodes[0].z_getpaymentdisclosure(txid, 0, -1) - assert(False) - except JSONRPCException as e: - errorString = e.error['message'] - assert("Invalid output_index" in errorString) - - # Ask Node 0 to create and validate a payment disclosure for output 0 - message = "Here is proof of my payment!" - pd = self.nodes[0].z_getpaymentdisclosure(txid, 0, 0, message) - result = self.nodes[0].z_validatepaymentdisclosure(pd) - assert(result["valid"]) - output_value_sum = Decimal(result["value"]) - - # Ask Node 1 to confirm the payment disclosure is valid - result = self.nodes[1].z_validatepaymentdisclosure(pd) - assert(result["valid"]) - assert_equal(result["message"], message) - assert_equal(result["value"], output_value_sum) - - # Confirm that payment disclosure begins with prefix zpd: - assert(pd.startswith("zpd:")) - - # Confirm that payment disclosure without prefix zpd: fails validation - try: - self.nodes[1].z_validatepaymentdisclosure(pd[4:]) - assert(False) - except JSONRPCException as e: - errorString = e.error['message'] - assert("payment disclosure prefix not found" in errorString) - - # Check that total value of output index 0 and index 1 should equal shielding amount of 40 less standard fee. - pd = self.nodes[0].z_getpaymentdisclosure(txid, 0, 1) - result = self.nodes[0].z_validatepaymentdisclosure(pd) - output_value_sum += Decimal(result["value"]) - assert_equal(output_value_sum, Decimal('39.99990000')) - - # Create a z->z transaction, sending shielded funds from node 0 to node 1 - node1zaddr = self.nodes[1].z_getnewaddress() - recipients = [{"address":node1zaddr, "amount":Decimal('1')}] - myopid = self.nodes[0].z_sendmany(myzaddr, recipients) - txid = wait_and_assert_operationid_status(self.nodes[0], myopid) - self.sync_all() - self.nodes[0].generate(1) - self.sync_all() - - # Confirm that Node 0 can create a valid payment disclosure - pd = self.nodes[0].z_getpaymentdisclosure(txid, 0, 0, "a message of your choice") - result = self.nodes[0].z_validatepaymentdisclosure(pd) - assert(result["valid"]) - - # Confirm that Node 1, even as recipient of shielded funds, cannot create a payment disclosure - # as the transaction was created by Node 0 and Node 1's payment disclosure database does not - # contain the necessary data to do so, where the data would only have been available on Node 0 - # when executing z_shieldcoinbase. - try: - self.nodes[1].z_getpaymentdisclosure(txid, 0, 0) - assert(False) - except JSONRPCException as e: - errorString = e.error['message'] - assert("Could not find payment disclosure info for the given joinsplit output" in errorString) - - # Payment disclosures cannot be created for transparent transactions. - txid = self.nodes[2].sendtoaddress(mytaddr, 1.0) - self.sync_all() - - # No matter the type of transaction, if it has not been confirmed, it is ignored. - try: - self.nodes[0].z_getpaymentdisclosure(txid, 0, 0) - assert(False) - except JSONRPCException as e: - errorString = e.error['message'] - assert("Transaction has not been confirmed yet" in errorString) - - self.nodes[0].generate(1) - self.sync_all() - - # Confirm that a payment disclosure can only be generated for a shielded transaction. - try: - self.nodes[0].z_getpaymentdisclosure(txid, 0, 0) - assert(False) - except JSONRPCException as e: - errorString = e.error['message'] - assert("Transaction is not a shielded transaction" in errorString) - -if __name__ == '__main__': - PaymentDisclosureTest().main() diff --git a/src/Makefile.am b/src/Makefile.am index 2d2d7a691..ab04c24bc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -181,8 +181,6 @@ BITCOIN_CORE_H = \ netbase.h \ notaries_staked.h \ noui.h \ - paymentdisclosure.h \ - paymentdisclosuredb.h \ policy/fees.h \ pow.h \ prevector.h \ @@ -303,8 +301,6 @@ libbitcoin_server_a_SOURCES = \ notaries_staked.cpp \ noui.cpp \ notarisationdb.cpp \ - paymentdisclosure.cpp \ - paymentdisclosuredb.cpp \ policy/fees.cpp \ pow.cpp \ rest.cpp \ @@ -355,10 +351,7 @@ libbitcoin_wallet_a_SOURCES = \ wallet/asyncrpcoperation_shieldcoinbase.cpp \ wallet/crypter.cpp \ wallet/db.cpp \ - paymentdisclosure.cpp \ - paymentdisclosuredb.cpp \ transaction_builder.cpp \ - wallet/rpcdisclosure.cpp \ wallet/rpcdump.cpp \ cc/CCtokens.cpp \ cc/CCassetsCore.cpp \ diff --git a/src/gtest/test_paymentdisclosure.cpp b/src/gtest/test_paymentdisclosure.cpp deleted file mode 100644 index c166cdbe1..000000000 --- a/src/gtest/test_paymentdisclosure.cpp +++ /dev/null @@ -1,211 +0,0 @@ -#include - -#include "main.h" -#include "utilmoneystr.h" -#include "chainparams.h" -#include "utilstrencodings.h" -#include "zcash/Address.hpp" -#include "wallet/wallet.h" -#include "amount.h" - -#include -#include -#include -#include -#include -#include -#include -#include "util.h" - -#include "paymentdisclosure.h" -#include "paymentdisclosuredb.h" - -#include "sodium.h" - -#include -#include -#include - -using namespace std; - -/* - To run tests: - ./zcash-gtest --gtest_filter="paymentdisclosure.*" - - Note: As an experimental feature, writing your own tests may require option flags to be set. - mapArgs["-experimentalfeatures"] = true; - mapArgs["-paymentdisclosure"] = true; -*/ - -#define NUM_TRIES 10000 - -#define DUMP_DATABASE_TO_STDOUT false - -static boost::uuids::random_generator uuidgen; - -static uint256 random_uint256() -{ - uint256 ret; - randombytes_buf(ret.begin(), 32); - return ret; -} - -// Subclass of PaymentDisclosureDB to add debugging methods -class PaymentDisclosureDBTest : public PaymentDisclosureDB { -public: - PaymentDisclosureDBTest(const boost::filesystem::path& dbPath) : PaymentDisclosureDB(dbPath) {} - - void DebugDumpAllStdout() { - ASSERT_NE(db, nullptr); - std::lock_guard guard(lock_); - - // Iterate over each item in the database and print them - leveldb::Iterator* it = db->NewIterator(leveldb::ReadOptions()); - - for (it->SeekToFirst(); it->Valid(); it->Next()) { - cout << it->key().ToString() << " : "; - // << it->value().ToString() << endl; - try { - std::string strValue = it->value().ToString(); - PaymentDisclosureInfo info; - CDataStream ssValue(strValue.data(), strValue.data() + strValue.size(), SER_DISK, CLIENT_VERSION); - ssValue >> info; - cout << info.ToString() << std::endl; - } catch (const std::exception& e) { - cout << e.what() << std::endl; - } - } - - if (false == it->status().ok()) { - cerr << "An error was found iterating over the database" << endl; - cerr << it->status().ToString() << endl; - } - - delete it; - } -}; - - - -// This test creates random payment disclosure blobs and checks that they can be -// 1. inserted and retrieved from a database -// 2. serialized and deserialized without corruption -// Note that the zpd: prefix is not part of the payment disclosure blob itself. It is only -// used as convention to improve the user experience when sharing payment disclosure blobs. -TEST(paymentdisclosure, mainnet) { - SelectParams(CBaseChainParams::MAIN); - - boost::filesystem::path pathTemp = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path(); - boost::filesystem::create_directories(pathTemp); - mapArgs["-datadir"] = pathTemp.string(); - - std::cout << "Test payment disclosure database created in folder: " << pathTemp.string() << std::endl; - - PaymentDisclosureDBTest mydb(pathTemp); - - for (int i=0; i vch(&buffer[0], &buffer[0] + 32); - uint256 joinSplitPrivKey = uint256(vch); - - // Create payment disclosure key and info data to store in test database - size_t js = random_uint256().GetCheapHash() % std::numeric_limits::max(); - uint8_t n = random_uint256().GetCheapHash() % std::numeric_limits::max(); - PaymentDisclosureKey key { random_uint256(), js, n}; - PaymentDisclosureInfo info; - info.esk = random_uint256(); - info.joinSplitPrivKey = joinSplitPrivKey; - info.zaddr = libzcash::SproutSpendingKey::random().address(); - ASSERT_TRUE(mydb.Put(key, info)); - - // Retrieve info from test database into new local variable and test it matches - PaymentDisclosureInfo info2; - ASSERT_TRUE(mydb.Get(key, info2)); - ASSERT_EQ(info, info2); - - // Modify this local variable and confirm it no longer matches - info2.esk = random_uint256(); - info2.joinSplitPrivKey = random_uint256(); - info2.zaddr = libzcash::SproutSpendingKey::random().address(); - ASSERT_NE(info, info2); - - // Using the payment info object, let's create a dummy payload - PaymentDisclosurePayload payload; - payload.version = PAYMENT_DISCLOSURE_VERSION_EXPERIMENTAL; - payload.esk = info.esk; - payload.txid = key.hash; - payload.js = key.js; - payload.n = key.n; - payload.message = "random-" + boost::uuids::to_string(uuidgen()); // random message - payload.zaddr = info.zaddr; - - // Serialize and hash the payload to generate a signature - uint256 dataToBeSigned = SerializeHash(payload, SER_GETHASH, 0); - - // Compute the payload signature - unsigned char payloadSig[64]; - if (!(crypto_sign_detached(&payloadSig[0], NULL, - dataToBeSigned.begin(), 32, - &buffer[0] // buffer containing both private and public key required - ) == 0)) - { - throw std::runtime_error("crypto_sign_detached failed"); - } - - // Sanity check - if (!(crypto_sign_verify_detached(&payloadSig[0], - dataToBeSigned.begin(), 32, - joinSplitPubKey.begin() - ) == 0)) - { - throw std::runtime_error("crypto_sign_verify_detached failed"); - } - - // Convert signature buffer to boost array - std::array arrayPayloadSig; - memcpy(arrayPayloadSig.data(), &payloadSig[0], 64); - - // Payment disclosure blob to pass around - PaymentDisclosure pd = {payload, arrayPayloadSig}; - - // Test payment disclosure constructors - PaymentDisclosure pd2(payload, arrayPayloadSig); - ASSERT_EQ(pd, pd2); - PaymentDisclosure pd3(joinSplitPubKey, key, info, payload.message); - ASSERT_EQ(pd, pd3); - - // Verify serialization and deserialization works - CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - ss << pd; - std::string ssHexString = HexStr(ss.begin(), ss.end()); - - PaymentDisclosure pdTmp; - CDataStream ssTmp(ParseHex(ssHexString), SER_NETWORK, PROTOCOL_VERSION); - ssTmp >> pdTmp; - ASSERT_EQ(pd, pdTmp); - - CDataStream ss2(SER_NETWORK, PROTOCOL_VERSION); - ss2 << pdTmp; - std::string ss2HexString = HexStr(ss2.begin(), ss2.end()); - ASSERT_EQ(ssHexString, ss2HexString); - - // Verify marker - ASSERT_EQ(pd.payload.marker, PAYMENT_DISCLOSURE_PAYLOAD_MAGIC_BYTES); - ASSERT_EQ(pdTmp.payload.marker, PAYMENT_DISCLOSURE_PAYLOAD_MAGIC_BYTES); - ASSERT_EQ(0, ssHexString.find("706462ff")); // Little endian encoding of PAYMENT_DISCLOSURE_PAYLOAD_MAGIC_BYTES value - - // Sanity check - PaymentDisclosure pdDummy; - ASSERT_NE(pd, pdDummy); - } - -#if DUMP_DATABASE_TO_STDOUT == true - mydb.DebugDumpAllStdout(); -#endif -} diff --git a/src/paymentdisclosure.cpp b/src/paymentdisclosure.cpp deleted file mode 100644 index eb55a0536..000000000 --- a/src/paymentdisclosure.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include "paymentdisclosure.h" - -#include "key_io.h" -#include "util.h" - -std::string PaymentDisclosureInfo::ToString() const { - return strprintf("PaymentDisclosureInfo(version=%d, esk=%s, joinSplitPrivKey=, address=%s)", - version, esk.ToString(), EncodePaymentAddress(zaddr)); -} - -std::string PaymentDisclosure::ToString() const { - std::string s = HexStr(payloadSig.begin(), payloadSig.end()); - return strprintf("PaymentDisclosure(payload=%s, payloadSig=%s)", payload.ToString(), s); -} - -std::string PaymentDisclosurePayload::ToString() const { - return strprintf("PaymentDisclosurePayload(version=%d, esk=%s, txid=%s, js=%d, n=%d, address=%s, message=%s)", - version, esk.ToString(), txid.ToString(), js, n, EncodePaymentAddress(zaddr), message); -} - -PaymentDisclosure::PaymentDisclosure(const uint256 &joinSplitPubKey, const PaymentDisclosureKey &key, const PaymentDisclosureInfo &info, const std::string &message) -{ - // Populate payload member variable - payload.version = info.version; // experimental = 0, production = 1 etc. - payload.esk = info.esk; - payload.txid = key.hash; - payload.js = key.js; - payload.n = key.n; - payload.zaddr = info.zaddr; - payload.message = message; - - // Serialize and hash the payload to generate a signature - uint256 dataToBeSigned = SerializeHash(payload, SER_GETHASH, 0); - - LogPrint("paymentdisclosure", "Payment Disclosure: signing raw payload = %s\n", dataToBeSigned.ToString()); - - // Prepare buffer to store ed25519 key pair in libsodium-compatible format - unsigned char bufferKeyPair[64]; - memcpy(&bufferKeyPair[0], info.joinSplitPrivKey.begin(), 32); - memcpy(&bufferKeyPair[32], joinSplitPubKey.begin(), 32); - - // Compute payload signature member variable - if (!(crypto_sign_detached(payloadSig.data(), NULL, - dataToBeSigned.begin(), 32, - &bufferKeyPair[0] - ) == 0)) - { - throw std::runtime_error("crypto_sign_detached failed"); - } - - // Sanity check - if (!(crypto_sign_verify_detached(payloadSig.data(), - dataToBeSigned.begin(), 32, - joinSplitPubKey.begin()) == 0)) - { - throw std::runtime_error("crypto_sign_verify_detached failed"); - } - - std::string sigString = HexStr(payloadSig.data(), payloadSig.data() + payloadSig.size()); - LogPrint("paymentdisclosure", "Payment Disclosure: signature = %s\n", sigString); -} diff --git a/src/paymentdisclosure.h b/src/paymentdisclosure.h deleted file mode 100644 index 5c3a20c33..000000000 --- a/src/paymentdisclosure.h +++ /dev/null @@ -1,149 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Copyright (c) 2019-2020 The Hush developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef ZCASH_PAYMENTDISCLOSURE_H -#define ZCASH_PAYMENTDISCLOSURE_H - -#include "uint256.h" -#include "clientversion.h" -#include "serialize.h" -#include "streams.h" -#include "version.h" - -// For JSOutPoint -#include "wallet/wallet.h" - -#include -#include -#include - - -// Ensure that the two different protocol messages, payment disclosure blobs and transactions, -// which are signed with the same key, joinSplitPrivKey, have disjoint encodings such that an -// encoding from one context will be rejected in the other. We know that the set of valid -// transaction versions is currently ({1..INT32_MAX}) so we will use a negative value for -// payment disclosure of -10328976 which in hex is 0xFF626470. Serialization is in little endian -// format, so a payment disclosure hex string begins 706462FF, which in ISO-8859-1 is "pdbÿ". -#define PAYMENT_DISCLOSURE_PAYLOAD_MAGIC_BYTES -10328976 - -#define PAYMENT_DISCLOSURE_VERSION_EXPERIMENTAL 0 - -#define PAYMENT_DISCLOSURE_BLOB_STRING_PREFIX "zpd:" - -typedef JSOutPoint PaymentDisclosureKey; - -struct PaymentDisclosureInfo { - uint8_t version; // 0 = experimental, 1 = first production version, etc. - uint256 esk; // zcash/NoteEncryption.cpp - uint256 joinSplitPrivKey; // primitives/transaction.h - // ed25519 - not tied to implementation e.g. libsodium, see ed25519 rfc - - libzcash::SproutPaymentAddress zaddr; - - PaymentDisclosureInfo() : version(PAYMENT_DISCLOSURE_VERSION_EXPERIMENTAL) { - } - - PaymentDisclosureInfo(uint8_t v, uint256 esk, uint256 key, libzcash::SproutPaymentAddress zaddr) : version(v), esk(esk), joinSplitPrivKey(key), zaddr(zaddr) { } - - ADD_SERIALIZE_METHODS; - - template - inline void SerializationOp(Stream& s, Operation ser_action) { - READWRITE(version); - READWRITE(esk); - READWRITE(joinSplitPrivKey); - READWRITE(zaddr); - } - - std::string ToString() const; - - friend bool operator==(const PaymentDisclosureInfo& a, const PaymentDisclosureInfo& b) { - return (a.version == b.version && a.esk == b.esk && a.joinSplitPrivKey == b.joinSplitPrivKey && a.zaddr == b.zaddr); - } - - friend bool operator!=(const PaymentDisclosureInfo& a, const PaymentDisclosureInfo& b) { - return !(a == b); - } - -}; - - -struct PaymentDisclosurePayload { - int32_t marker = PAYMENT_DISCLOSURE_PAYLOAD_MAGIC_BYTES; // to be disjoint from transaction encoding - uint8_t version; // 0 = experimental, 1 = first production version, etc. - uint256 esk; // zcash/NoteEncryption.cpp - uint256 txid; // primitives/transaction.h - uint64_t js; // Index into CTransaction.vjoinsplit - uint8_t n; // Index into JSDescription fields of length ZC_NUM_JS_OUTPUTS - libzcash::SproutPaymentAddress zaddr; // zcash/Address.hpp - std::string message; // parameter to RPC call - - ADD_SERIALIZE_METHODS; - - template - inline void SerializationOp(Stream& s, Operation ser_action) { - READWRITE(marker); - READWRITE(version); - READWRITE(esk); - READWRITE(txid); - READWRITE(js); - READWRITE(n); - READWRITE(zaddr); - READWRITE(message); - } - - std::string ToString() const; - - friend bool operator==(const PaymentDisclosurePayload& a, const PaymentDisclosurePayload& b) { - return ( - a.version == b.version && - a.esk == b.esk && - a.txid == b.txid && - a.js == b.js && - a.n == b.n && - a.zaddr == b.zaddr && - a.message == b.message - ); - } - - friend bool operator!=(const PaymentDisclosurePayload& a, const PaymentDisclosurePayload& b) { - return !(a == b); - } -}; - -struct PaymentDisclosure { - PaymentDisclosurePayload payload; - std::array payloadSig; - // We use boost array because serialize doesn't like char buffer, otherwise we could do: unsigned char payloadSig[64]; - - PaymentDisclosure() {}; - PaymentDisclosure(const PaymentDisclosurePayload payload, const std::array sig) : payload(payload), payloadSig(sig) {}; - PaymentDisclosure(const uint256& joinSplitPubKey, const PaymentDisclosureKey& key, const PaymentDisclosureInfo& info, const std::string& message); - - ADD_SERIALIZE_METHODS; - - template - inline void SerializationOp(Stream& s, Operation ser_action) { - READWRITE(payload); - READWRITE(payloadSig); - } - - std::string ToString() const; - - friend bool operator==(const PaymentDisclosure& a, const PaymentDisclosure& b) { - return (a.payload == b.payload && a.payloadSig == b.payloadSig); - } - - friend bool operator!=(const PaymentDisclosure& a, const PaymentDisclosure& b) { - return !(a == b); - } -}; - - - -typedef std::pair PaymentDisclosureKeyInfo; - - -#endif // ZCASH_PAYMENTDISCLOSURE_H diff --git a/src/paymentdisclosuredb.cpp b/src/paymentdisclosuredb.cpp deleted file mode 100644 index 8840dcda0..000000000 --- a/src/paymentdisclosuredb.cpp +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include "paymentdisclosuredb.h" - -#include "util.h" -#include "dbwrapper.h" - -#include - -using namespace std; - -static boost::filesystem::path emptyPath; - -/** - * Static method to return the shared/default payment disclosure database. - */ -shared_ptr PaymentDisclosureDB::sharedInstance() { - // Thread-safe in C++11 and gcc 4.3 - static shared_ptr ptr = std::make_shared(); - return ptr; -} - -// C++11 delegated constructor -PaymentDisclosureDB::PaymentDisclosureDB() : PaymentDisclosureDB(emptyPath) { -} - -PaymentDisclosureDB::PaymentDisclosureDB(const boost::filesystem::path& dbPath) { - boost::filesystem::path path(dbPath); - if (path.empty()) { - path = GetDataDir() / "paymentdisclosure"; - LogPrintf("PaymentDisclosure: using default path for database: %s\n", path.string()); - } else { - LogPrintf("PaymentDisclosure: using custom path for database: %s\n", path.string()); - } - - TryCreateDirectory(path); - options.create_if_missing = true; - leveldb::Status status = leveldb::DB::Open(options, path.string(), &db); - dbwrapper_private::HandleError(status); // throws exception - LogPrintf("PaymentDisclosure: Opened LevelDB successfully\n"); -} - -PaymentDisclosureDB::~PaymentDisclosureDB() { - if (db != nullptr) { - delete db; - } -} - -bool PaymentDisclosureDB::Put(const PaymentDisclosureKey& key, const PaymentDisclosureInfo& info) -{ - if (db == nullptr) { - return false; - } - - std::lock_guard guard(lock_); - - CDataStream ssValue(SER_DISK, CLIENT_VERSION); - ssValue.reserve(GetSerializeSize(ssValue, info)); - ssValue << info; - leveldb::Slice slice(&ssValue[0], ssValue.size()); - - leveldb::Status status = db->Put(writeOptions, key.ToString(), slice); - dbwrapper_private::HandleError(status); - return true; -} - -bool PaymentDisclosureDB::Get(const PaymentDisclosureKey& key, PaymentDisclosureInfo& info) -{ - if (db == nullptr) { - return false; - } - - std::lock_guard guard(lock_); - - std::string strValue; - leveldb::Status status = db->Get(readOptions, key.ToString(), &strValue); - if (!status.ok()) { - if (status.IsNotFound()) - return false; - LogPrintf("PaymentDisclosure: LevelDB read failure: %s\n", status.ToString()); - dbwrapper_private::HandleError(status); - } - - try { - CDataStream ssValue(strValue.data(), strValue.data() + strValue.size(), SER_DISK, CLIENT_VERSION); - ssValue >> info; - } catch (const std::exception&) { - return false; - } - return true; -} diff --git a/src/paymentdisclosuredb.h b/src/paymentdisclosuredb.h deleted file mode 100644 index 9352cac8f..000000000 --- a/src/paymentdisclosuredb.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef ZCASH_PAYMENTDISCLOSUREDB_H -#define ZCASH_PAYMENTDISCLOSUREDB_H - -#include "paymentdisclosure.h" - -#include -#include -#include -#include -#include - -#include - -#include - - -class PaymentDisclosureDB -{ -protected: - leveldb::DB* db = nullptr; - leveldb::Options options; - leveldb::ReadOptions readOptions; - leveldb::WriteOptions writeOptions; - mutable std::mutex lock_; - -public: - static std::shared_ptr sharedInstance(); - - PaymentDisclosureDB(); - PaymentDisclosureDB(const boost::filesystem::path& dbPath); - ~PaymentDisclosureDB(); - - bool Put(const PaymentDisclosureKey& key, const PaymentDisclosureInfo& info); - bool Get(const PaymentDisclosureKey& key, PaymentDisclosureInfo& info); -}; - - -#endif // ZCASH_PAYMENTDISCLOSUREDB_H diff --git a/src/wallet/asyncrpcoperation_mergetoaddress.cpp b/src/wallet/asyncrpcoperation_mergetoaddress.cpp index ed4efc014..4e47a5a2d 100644 --- a/src/wallet/asyncrpcoperation_mergetoaddress.cpp +++ b/src/wallet/asyncrpcoperation_mergetoaddress.cpp @@ -133,9 +133,6 @@ saplingNoteInputs_(saplingNoteInputs), recipient_(recipient), fee_(fee), context // Lock UTXOs lock_utxos(); lock_notes(); - - // Enable payment disclosure if requested - paymentDisclosureMode = fExperimentalMode && GetBoolArg("-paymentdisclosure", true); } AsyncRPCOperation_mergetoaddress::~AsyncRPCOperation_mergetoaddress() @@ -210,25 +207,10 @@ void AsyncRPCOperation_mergetoaddress::main() unlock_utxos(); // clean up unlock_notes(); // clean up - - // !!! Payment disclosure START - if (success && paymentDisclosureMode && paymentDisclosureData_.size() > 0) { - uint256 txidhash = tx_.GetHash(); - std::shared_ptr db = PaymentDisclosureDB::sharedInstance(); - for (PaymentDisclosureKeyInfo p : paymentDisclosureData_) { - p.first.hash = txidhash; - if (!db->Put(p.first, p.second)) { - LogPrint("paymentdisclosure", "%s: Payment Disclosure: Error writing entry to database for key %s\n", getId(), p.first.ToString()); - } else { - LogPrint("paymentdisclosure", "%s: Payment Disclosure: Successfully added entry to database for key %s\n", getId(), p.first.ToString()); - } - } - } - // !!! Payment disclosure END } // Notes: -// 1. #1359 Currently there is no limit set on the number of joinsplits, so size of tx could be invalid. +// 1. #1359 Currently there is no limit set on the number of inputs+outputs, so size of tx could be invalid. // 2. #1277 Spendable notes are not locked, so an operation running in parallel could also try to use them. bool AsyncRPCOperation_mergetoaddress::main_impl() { diff --git a/src/wallet/asyncrpcoperation_mergetoaddress.h b/src/wallet/asyncrpcoperation_mergetoaddress.h index be49baff0..4876921db 100644 --- a/src/wallet/asyncrpcoperation_mergetoaddress.h +++ b/src/wallet/asyncrpcoperation_mergetoaddress.h @@ -1,4 +1,6 @@ // Copyright (c) 2017 The Zcash developers +// Copyright (c) 2019-2020 The Hush developers + // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -22,7 +24,6 @@ #include "amount.h" #include "asyncrpcoperation.h" -#include "paymentdisclosure.h" #include "primitives/transaction.h" #include "transaction_builder.h" #include "wallet.h" @@ -93,8 +94,6 @@ public: bool testmode = false; // Set to true to disable sending txs and generating proofs - bool paymentDisclosureMode = true; // Set to true to save esk for encrypted notes in payment disclosure database. - private: friend class TEST_FRIEND_AsyncRPCOperation_mergetoaddress; // class for unit testing @@ -148,8 +147,6 @@ private: void unlock_notes(); - // payment disclosure! - std::vector paymentDisclosureData_; }; diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index a1ecb296d..31f987bef 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -211,25 +211,10 @@ void AsyncRPCOperation_sendmany::main() { s += strprintf(", error=%s)\n", getErrorMessage()); } LogPrintf("%s",s); - - // !!! Payment disclosure START - if (success && paymentDisclosureMode && paymentDisclosureData_.size()>0) { - uint256 txidhash = tx_.GetHash(); - std::shared_ptr db = PaymentDisclosureDB::sharedInstance(); - for (PaymentDisclosureKeyInfo p : paymentDisclosureData_) { - p.first.hash = txidhash; - if (!db->Put(p.first, p.second)) { - LogPrint("paymentdisclosure", "%s: Payment Disclosure: Error writing entry to database for key %s\n", getId(), p.first.ToString()); - } else { - LogPrint("paymentdisclosure", "%s: Payment Disclosure: Successfully added entry to database for key %s\n", getId(), p.first.ToString()); - } - } - } - // !!! Payment disclosure END } // Notes: -// 1. #1159 Currently there is no limit set on the number of joinsplits, so size of tx could be invalid. +// 1. #1159 Currently there is no limit set on the number of shielded spends, so size of tx could be invalid. // 2. #1360 Note selection is not optimal // 3. #1277 Spendable notes are not locked, so an operation running in parallel could also try to use them bool AsyncRPCOperation_sendmany::main_impl() { diff --git a/src/wallet/asyncrpcoperation_sendmany.h b/src/wallet/asyncrpcoperation_sendmany.h index 8e39f341a..0b803ddd9 100644 --- a/src/wallet/asyncrpcoperation_sendmany.h +++ b/src/wallet/asyncrpcoperation_sendmany.h @@ -1,4 +1,5 @@ // Copyright (c) 2016 The Zcash developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -27,7 +28,6 @@ #include "zcash/JoinSplit.hpp" #include "zcash/Address.hpp" #include "wallet.h" -#include "paymentdisclosure.h" #include #include @@ -90,8 +90,6 @@ public: bool testmode = false; // Set to true to disable sending txs and generating proofs - bool paymentDisclosureMode = true; // Set to true to save esk for encrypted notes in payment disclosure database. - private: friend class TEST_FRIEND_AsyncRPCOperation_sendmany; // class for unit testing @@ -143,9 +141,6 @@ private: uint256 anchor); void sign_send_raw_transaction(UniValue obj); // throws exception if there was an error - - // payment disclosure! - std::vector paymentDisclosureData_; }; diff --git a/src/wallet/asyncrpcoperation_shieldcoinbase.cpp b/src/wallet/asyncrpcoperation_shieldcoinbase.cpp index 5db0ca51b..de56ba3bc 100644 --- a/src/wallet/asyncrpcoperation_shieldcoinbase.cpp +++ b/src/wallet/asyncrpcoperation_shieldcoinbase.cpp @@ -48,9 +48,6 @@ #include "asyncrpcoperation_shieldcoinbase.h" -#include "paymentdisclosure.h" -#include "paymentdisclosuredb.h" - using namespace libzcash; extern uint64_t ASSETCHAINS_TIMELOCKGTE; @@ -108,8 +105,6 @@ AsyncRPCOperation_shieldcoinbase::AsyncRPCOperation_shieldcoinbase( // Lock UTXOs lock_utxos(); - // Enable payment disclosure if requested - paymentDisclosureMode = fExperimentalMode && GetBoolArg("-paymentdisclosure", true); } AsyncRPCOperation_shieldcoinbase::~AsyncRPCOperation_shieldcoinbase() { @@ -181,20 +176,6 @@ void AsyncRPCOperation_shieldcoinbase::main() { unlock_utxos(); // clean up - // !!! Payment disclosure START - if (success && paymentDisclosureMode && paymentDisclosureData_.size()>0) { - uint256 txidhash = tx_.GetHash(); - std::shared_ptr db = PaymentDisclosureDB::sharedInstance(); - for (PaymentDisclosureKeyInfo p : paymentDisclosureData_) { - p.first.hash = txidhash; - if (!db->Put(p.first, p.second)) { - LogPrint("paymentdisclosure", "%s: Payment Disclosure: Error writing entry to database for key %s\n", getId(), p.first.ToString()); - } else { - LogPrint("paymentdisclosure", "%s: Payment Disclosure: Successfully added entry to database for key %s\n", getId(), p.first.ToString()); - } - } - } - // !!! Payment disclosure END } bool AsyncRPCOperation_shieldcoinbase::main_impl() { diff --git a/src/wallet/asyncrpcoperation_shieldcoinbase.h b/src/wallet/asyncrpcoperation_shieldcoinbase.h index db4fb83af..3eb1a6cfc 100644 --- a/src/wallet/asyncrpcoperation_shieldcoinbase.h +++ b/src/wallet/asyncrpcoperation_shieldcoinbase.h @@ -34,8 +34,6 @@ #include -#include "paymentdisclosure.h" - // Default transaction fee if caller does not specify one. #define SHIELD_COINBASE_DEFAULT_MINERS_FEE 10000 @@ -81,8 +79,6 @@ public: bool testmode = false; // Set to true to disable sending txs and generating proofs bool cheatSpend = false; // set when this is shielding a cheating coinbase - bool paymentDisclosureMode = true; // Set to true to save esk for encrypted notes in payment disclosure database. - private: friend class ShieldToAddress; friend class TEST_FRIEND_AsyncRPCOperation_shieldcoinbase; // class for unit testing @@ -110,9 +106,6 @@ private: void lock_utxos(); void unlock_utxos(); - - // payment disclosure! - std::vector paymentDisclosureData_; }; class ShieldToAddress : public boost::static_visitor diff --git a/src/wallet/rpcdisclosure.cpp b/src/wallet/rpcdisclosure.cpp deleted file mode 100644 index 918e70cbc..000000000 --- a/src/wallet/rpcdisclosure.cpp +++ /dev/null @@ -1,324 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Copyright (c) 2019-2020 The Hush developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -/****************************************************************************** - * Copyright © 2014-2019 The SuperNET Developers. * - * * - * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * - * the top-level directory of this distribution for the individual copyright * - * holder information and the developer policies on copyright and licensing. * - * * - * Unless otherwise agreed in a custom licensing agreement, no part of the * - * SuperNET software, including this file may be copied, modified, propagated * - * or distributed except according to the terms contained in the LICENSE file * - * * - * Removal or modification of this copyright notice is prohibited. * - * * - ******************************************************************************/ - -#include "rpc/server.h" -#include "init.h" -#include "key_io.h" -#include "main.h" -#include "script/script.h" -#include "script/standard.h" -#include "sync.h" -#include "util.h" -#include "utiltime.h" -#include "wallet.h" - -#include -#include - -#include -#include - -#include - -#include "paymentdisclosure.h" -#include "paymentdisclosuredb.h" - -#include "zcash/Note.hpp" -#include "zcash/NoteEncryption.hpp" - -using namespace std; -using namespace libzcash; - -// Function declaration for function implemented in wallet/rpcwallet.cpp -bool EnsureWalletIsAvailable(bool avoidException); - -/** - * RPC call to generate a payment disclosure - */ -UniValue z_getpaymentdisclosure(const UniValue& params, bool fHelp, const CPubKey& mypk) -{ - if (!EnsureWalletIsAvailable(fHelp)) - return NullUniValue; - - string enableArg = "paymentdisclosure"; - auto fEnablePaymentDisclosure = fExperimentalMode && GetBoolArg("-" + enableArg, true); - string strPaymentDisclosureDisabledMsg = ""; - if (!fEnablePaymentDisclosure) { - strPaymentDisclosureDisabledMsg = experimentalDisabledHelpMsg("z_getpaymentdisclosure", enableArg); - } - - if (fHelp || params.size() < 3 || params.size() > 4 ) - throw runtime_error( - "z_getpaymentdisclosure \"txid\" \"js_index\" \"output_index\" (\"message\") \n" - "\nGenerate a payment disclosure for a given joinsplit output.\n" - "\nEXPERIMENTAL FEATURE\n" - + strPaymentDisclosureDisabledMsg + - "\nArguments:\n" - "1. \"txid\" (string, required) \n" - "2. \"js_index\" (string, required) \n" - "3. \"output_index\" (string, required) \n" - "4. \"message\" (string, optional) \n" - "\nResult:\n" - "\"paymentdisclosure\" (string) Hex data string, with \"zpd:\" prefix.\n" - "\nExamples:\n" - + HelpExampleCli("z_getpaymentdisclosure", "96f12882450429324d5f3b48630e3168220e49ab7b0f066e5c2935a6b88bb0f2 0 0 \"refund\"") - + HelpExampleRpc("z_getpaymentdisclosure", "\"96f12882450429324d5f3b48630e3168220e49ab7b0f066e5c2935a6b88bb0f2\", 0, 0, \"refund\"") - ); - - if (!fEnablePaymentDisclosure) { - throw JSONRPCError(RPC_WALLET_ERROR, "Error: payment disclosure is disabled."); - } - - LOCK2(cs_main, pwalletMain->cs_wallet); - - EnsureWalletIsUnlocked(); - - // Check wallet knows about txid - string txid = params[0].get_str(); - uint256 hash; - hash.SetHex(txid); - - CTransaction tx; - uint256 hashBlock; - - // Check txid has been seen - if (!GetTransaction(hash, tx, hashBlock, true)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available about transaction"); - } - - // Check tx has been confirmed - if (hashBlock.IsNull()) { - throw JSONRPCError(RPC_MISC_ERROR, "Transaction has not been confirmed yet"); - } - - // Check is mine - if (!pwalletMain->mapWallet.count(hash)) { - throw JSONRPCError(RPC_MISC_ERROR, "Transaction does not belong to the wallet"); - } - const CWalletTx& wtx = pwalletMain->mapWallet[hash]; - - // Check if shielded tx - if (wtx.vjoinsplit.empty()) { - throw JSONRPCError(RPC_MISC_ERROR, "Transaction is not a shielded transaction"); - } - - // Check js_index - int js_index = params[1].get_int(); - if (js_index < 0 || js_index >= wtx.vjoinsplit.size()) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid js_index"); - } - - // Check output_index - int output_index = params[2].get_int(); - if (output_index < 0 || output_index >= ZC_NUM_JS_OUTPUTS) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid output_index"); - } - - // Get message if it exists - string msg; - if (params.size() == 4) { - msg = params[3].get_str(); - } - - // Create PaymentDisclosureKey - PaymentDisclosureKey key = {hash, (size_t)js_index, (uint8_t)output_index }; - - // TODO: In future, perhaps init the DB in init.cpp - shared_ptr db = PaymentDisclosureDB::sharedInstance(); - PaymentDisclosureInfo info; - if (!db->Get(key, info)) { - throw JSONRPCError(RPC_DATABASE_ERROR, "Could not find payment disclosure info for the given joinsplit output"); - } - - PaymentDisclosure pd( wtx.joinSplitPubKey, key, info, msg ); - CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - ss << pd; - string strHex = HexStr(ss.begin(), ss.end()); - return PAYMENT_DISCLOSURE_BLOB_STRING_PREFIX + strHex; -} - - - -/** - * RPC call to validate a payment disclosure data blob. - */ -UniValue z_validatepaymentdisclosure(const UniValue& params, bool fHelp, const CPubKey& mypk) -{ - if (!EnsureWalletIsAvailable(fHelp)) - return NullUniValue; - - string enableArg = "paymentdisclosure"; - auto fEnablePaymentDisclosure = fExperimentalMode && GetBoolArg("-" + enableArg, true); - string strPaymentDisclosureDisabledMsg = ""; - if (!fEnablePaymentDisclosure) { - strPaymentDisclosureDisabledMsg = experimentalDisabledHelpMsg("z_validatepaymentdisclosure", enableArg); - } - - if (fHelp || params.size() != 1) - throw runtime_error( - "z_validatepaymentdisclosure \"paymentdisclosure\"\n" - "\nValidates a payment disclosure.\n" - "\nEXPERIMENTAL FEATURE\n" - + strPaymentDisclosureDisabledMsg + - "\nArguments:\n" - "1. \"paymentdisclosure\" (string, required) Hex data string, with \"zpd:\" prefix.\n" - "\nExamples:\n" - + HelpExampleCli("z_validatepaymentdisclosure", "\"zpd:706462ff004c561a0447ba2ec51184e6c204...\"") - + HelpExampleRpc("z_validatepaymentdisclosure", "\"zpd:706462ff004c561a0447ba2ec51184e6c204...\"") - ); - - if (!fEnablePaymentDisclosure) { - throw JSONRPCError(RPC_WALLET_ERROR, "Error: payment disclosure is disabled."); - } - - throw JSONRPCError(RPC_WALLET_ERROR, "Error: payment disclosures not implemented for Sapling yet"); - - LOCK2(cs_main, pwalletMain->cs_wallet); - - EnsureWalletIsUnlocked(); - - // Verify the payment disclosure input begins with "zpd:" prefix. - string strInput = params[0].get_str(); - size_t pos = strInput.find(PAYMENT_DISCLOSURE_BLOB_STRING_PREFIX); - if (pos != 0) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, payment disclosure prefix not found."); - } - string hexInput = strInput.substr(strlen(PAYMENT_DISCLOSURE_BLOB_STRING_PREFIX)); - if (!IsHex(hexInput)) - { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected payment disclosure data in hexadecimal format."); - } - - // Unserialize the payment disclosure data into an object - PaymentDisclosure pd; - CDataStream ss(ParseHex(hexInput), SER_NETWORK, PROTOCOL_VERSION); - try { - ss >> pd; - // too much data is ignored, but if not enough data, exception of type ios_base::failure is thrown, - // CBaseDataStream::read(): end of data: iostream error - } catch (const std::exception &e) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, payment disclosure data is malformed."); - } - - if (pd.payload.marker != PAYMENT_DISCLOSURE_PAYLOAD_MAGIC_BYTES) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, payment disclosure marker not found."); - } - - if (pd.payload.version != PAYMENT_DISCLOSURE_VERSION_EXPERIMENTAL) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Payment disclosure version is unsupported."); - } - - uint256 hash = pd.payload.txid; - CTransaction tx; - uint256 hashBlock; - // Check if we have seen the transaction - if (!GetTransaction(hash, tx, hashBlock, true)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available about transaction"); - } - - // Check if the transaction has been confirmed - if (hashBlock.IsNull()) { - throw JSONRPCError(RPC_MISC_ERROR, "Transaction has not been confirmed yet"); - } - - // Check if shielded tx - if (tx.vjoinsplit.empty()) { - throw JSONRPCError(RPC_MISC_ERROR, "Transaction is not a shielded transaction"); - } - - UniValue errs(UniValue::VARR); - UniValue o(UniValue::VOBJ); - o.push_back(Pair("txid", pd.payload.txid.ToString())); - - // Check js_index - if (pd.payload.js >= tx.vjoinsplit.size()) { - errs.push_back("Payment disclosure refers to an invalid joinsplit index"); - } - o.push_back(Pair("jsIndex", pd.payload.js)); - - if (pd.payload.n < 0 || pd.payload.n >= ZC_NUM_JS_OUTPUTS) { - errs.push_back("Payment disclosure refers to an invalid output index"); - } - o.push_back(Pair("outputIndex", pd.payload.n)); - o.push_back(Pair("version", pd.payload.version)); - o.push_back(Pair("onetimePrivKey", pd.payload.esk.ToString())); - o.push_back(Pair("message", pd.payload.message)); - o.push_back(Pair("joinSplitPubKey", tx.joinSplitPubKey.ToString())); - - // Verify the payment disclosure was signed using the same key as the transaction i.e. the joinSplitPrivKey. - uint256 dataToBeSigned = SerializeHash(pd.payload, SER_GETHASH, 0); - bool sigVerified = (crypto_sign_verify_detached(pd.payloadSig.data(), - dataToBeSigned.begin(), 32, - tx.joinSplitPubKey.begin()) == 0); - o.push_back(Pair("signatureVerified", sigVerified)); - if (!sigVerified) { - errs.push_back("Payment disclosure signature does not match transaction signature"); - } - - /* - // Check the payment address is valid - PaymentAddress zaddr = pd.payload.zaddr; - { - o.push_back(Pair("paymentAddress", EncodePaymentAddress(zaddr))); - - try { - // Decrypt the note to get value and memo field - JSDescription jsdesc = tx.vjoinsplit[pd.payload.js]; - uint256 h_sig = jsdesc.h_sig(*pzcashParams, tx.joinSplitPubKey); - - ZCPaymentDisclosureNoteDecryption decrypter; - - ZCNoteEncryption::Ciphertext ciphertext = jsdesc.ciphertexts[pd.payload.n]; - - uint256 pk_enc = zaddr.pk_enc; - auto plaintext = decrypter.decryptWithEsk(ciphertext, pk_enc, pd.payload.esk, h_sig, pd.payload.n); - - CDataStream ssPlain(SER_NETWORK, PROTOCOL_VERSION); - ssPlain << plaintext; - SproutNotePlaintext npt; - ssPlain >> npt; - - string memoHexString = HexStr(npt.memo().data(), npt.memo().data() + npt.memo().size()); - o.push_back(Pair("memo", memoHexString)); - o.push_back(Pair("value", ValueFromAmount(npt.value()))); - - // Check the blockchain commitment matches decrypted note commitment - uint256 cm_blockchain = jsdesc.commitments[pd.payload.n]; - SproutNote note = npt.note(zaddr); - uint256 cm_decrypted = note.cm(); - bool cm_match = (cm_decrypted == cm_blockchain); - o.push_back(Pair("commitmentMatch", cm_match)); - if (!cm_match) { - errs.push_back("Commitment derived from payment disclosure does not match blockchain commitment"); - } - } catch (const std::exception &e) { - errs.push_back(string("Error while decrypting payment disclosure note: ") + string(e.what()) ); - } - } - */ - - bool isValid = errs.empty(); - o.push_back(Pair("valid", isValid)); - if (!isValid) { - o.push_back(Pair("errors", errs)); - } - - return o; -} diff --git a/src/zcash/NoteEncryption.cpp b/src/zcash/NoteEncryption.cpp index 63e073265..9f2d64563 100644 --- a/src/zcash/NoteEncryption.cpp +++ b/src/zcash/NoteEncryption.cpp @@ -1,3 +1,5 @@ +// Copyright (c) 2019-2020 The Hush developers + #include "NoteEncryption.hpp" #include #include "sodium.h" @@ -374,52 +376,6 @@ typename NoteDecryption::Plaintext NoteDecryption::decrypt return plaintext; } -// -// Payment disclosure - decrypt with esk -// -template -typename PaymentDisclosureNoteDecryption::Plaintext PaymentDisclosureNoteDecryption::decryptWithEsk - (const PaymentDisclosureNoteDecryption::Ciphertext &ciphertext, - const uint256 &pk_enc, - const uint256 &esk, - const uint256 &hSig, - unsigned char nonce - ) const -{ - uint256 dhsecret; - - if (crypto_scalarmult(dhsecret.begin(), esk.begin(), pk_enc.begin()) != 0) { - throw std::logic_error("Could not create DH secret"); - } - - // Regenerate keypair - uint256 epk = NoteEncryption::generate_pubkey(esk); - - unsigned char K[NOTEENCRYPTION_CIPHER_KEYSIZE]; - KDF(K, dhsecret, epk, pk_enc, hSig, nonce); - - // The nonce is zero because we never reuse keys - unsigned char cipher_nonce[crypto_aead_chacha20poly1305_IETF_NPUBBYTES] = {}; - - PaymentDisclosureNoteDecryption::Plaintext plaintext; - - // Message length is always NOTEENCRYPTION_AUTH_BYTES less than - // the ciphertext length. - if (crypto_aead_chacha20poly1305_ietf_decrypt(plaintext.begin(), NULL, - NULL, - ciphertext.begin(), PaymentDisclosureNoteDecryption::CLEN, - NULL, - 0, - cipher_nonce, K) != 0) { - throw note_decryption_failed(); - } - - return plaintext; -} - - - - template uint256 NoteEncryption::generate_privkey(const uint252 &a_sk) { @@ -461,6 +417,4 @@ uint252 random_uint252() template class NoteEncryption; template class NoteDecryption; -template class PaymentDisclosureNoteDecryption; - } diff --git a/src/zcash/NoteEncryption.hpp b/src/zcash/NoteEncryption.hpp index f6e692028..9c726d5cf 100644 --- a/src/zcash/NoteEncryption.hpp +++ b/src/zcash/NoteEncryption.hpp @@ -1,7 +1,4 @@ -/* -See the Zcash protocol specification for more information. -https://github.com/zcash/zips/blob/master/protocol/protocol.pdf -*/ +// Copyright (c) 2019-2020 The Hush developers #ifndef ZC_NOTE_ENCRYPTION_H_ #define ZC_NOTE_ENCRYPTION_H_ @@ -169,33 +166,9 @@ public: }; - -// Subclass PaymentDisclosureNoteDecryption provides a method to decrypt a note with esk. -template -class PaymentDisclosureNoteDecryption : public NoteDecryption { -protected: -public: - enum { CLEN=MLEN+NOTEENCRYPTION_AUTH_BYTES }; - typedef std::array Ciphertext; - typedef std::array Plaintext; - - PaymentDisclosureNoteDecryption() : NoteDecryption() {} - PaymentDisclosureNoteDecryption(uint256 sk_enc) : NoteDecryption(sk_enc) {} - - Plaintext decryptWithEsk( - const Ciphertext &ciphertext, - const uint256 &pk_enc, - const uint256 &esk, - const uint256 &hSig, - unsigned char nonce - ) const; -}; - } typedef libzcash::NoteEncryption ZCNoteEncryption; typedef libzcash::NoteDecryption ZCNoteDecryption; -typedef libzcash::PaymentDisclosureNoteDecryption ZCPaymentDisclosureNoteDecryption; - #endif /* ZC_NOTE_ENCRYPTION_H_ */ From 7e48b4f8ec46125a64c58d2901849e83c84ec258 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 5 Jun 2020 09:31:31 -0400 Subject: [PATCH 050/255] desprout --- src/amount.h | 1 + src/key.h | 1 + src/key_io.cpp | 1 + src/primitives/block.h | 2 +- src/test/key_tests.cpp | 37 ++----------------------------------- src/util.h | 1 + 6 files changed, 7 insertions(+), 36 deletions(-) diff --git a/src/amount.h b/src/amount.h index be1c39a6e..c5f49593c 100644 --- a/src/amount.h +++ b/src/amount.h @@ -1,5 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/key.h b/src/key.h index 857e8a8ae..16492b151 100644 --- a/src/key.h +++ b/src/key.h @@ -1,6 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2017 The Zcash developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/key_io.cpp b/src/key_io.cpp index 319c24eef..2e0dfeb9a 100644 --- a/src/key_io.cpp +++ b/src/key_io.cpp @@ -99,6 +99,7 @@ public: } std::string operator()(const libzcash::InvalidEncoding& no) const { return {}; } + std::string operator()(const libzcash::SproutPaymentAddress& zaddr) const { return {}; } }; class ViewingKeyEncoder : public boost::static_visitor diff --git a/src/primitives/block.h b/src/primitives/block.h index ea93d6f50..a2d0ba708 100644 --- a/src/primitives/block.h +++ b/src/primitives/block.h @@ -1,6 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers -// Copyright (c) 2019 The Hush developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/test/key_tests.cpp b/src/test/key_tests.cpp index 220d6a9b7..390b2bc7b 100644 --- a/src/test/key_tests.cpp +++ b/src/test/key_tests.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -22,6 +23,7 @@ using namespace std; using namespace libzcash; +//TODO: convert to Hush addresses static const std::string strSecret1 = "5HxWvvfubhXpYYpS3tJkw6fq9jE9j18THftkZjHHfmFiWtmAbrj"; static const std::string strSecret2 = "5KC4ejrDjv152FGwP386VD1i2NYc5KkfSMyv1nGy1VGDxGHqVY3"; static const std::string strSecret1C = "Kwr371tjA9u2rFSMZjTNun2PXXP3WPZu2afRHTcta6KxEUdm1vEw"; @@ -186,41 +188,6 @@ BOOST_AUTO_TEST_CASE(key_test1) BOOST_CHECK(detsigc == ParseHex("2052d8a32079c11e79db95af63bb9600c5b04f21a9ca33dc129c2bfa8ac9dc1cd561d8ae5e0f6c1a16bde3719c64c2fd70e404b6428ab9a69566962e8771b5944d")); } -BOOST_AUTO_TEST_CASE(zc_address_test) -{ - for (size_t i = 0; i < 1000; i++) { - auto sk = SproutSpendingKey::random(); - { - string sk_string = EncodeSpendingKey(sk); - - BOOST_CHECK(sk_string[0] == 'S'); - BOOST_CHECK(sk_string[1] == 'K'); - - auto spendingkey2 = DecodeSpendingKey(sk_string); - BOOST_CHECK(IsValidSpendingKey(spendingkey2)); - BOOST_ASSERT(boost::get(&spendingkey2) != nullptr); - auto sk2 = boost::get(spendingkey2); - BOOST_CHECK(sk.inner() == sk2.inner()); - } - { - auto addr = sk.address(); - - std::string addr_string = EncodePaymentAddress(addr); - - BOOST_CHECK(addr_string[0] == 'z'); - BOOST_CHECK(addr_string[1] == 'c'); - - auto paymentaddr2 = DecodePaymentAddress(addr_string); - BOOST_ASSERT(IsValidPaymentAddress(paymentaddr2)); - - BOOST_ASSERT(boost::get(&paymentaddr2) != nullptr); - auto addr2 = boost::get(paymentaddr2); - BOOST_CHECK(addr.a_pk == addr2.a_pk); - BOOST_CHECK(addr.pk_enc == addr2.pk_enc); - } - } -} - BOOST_AUTO_TEST_CASE(zs_address_test) { SelectParams(CBaseChainParams::REGTEST); diff --git a/src/util.h b/src/util.h index 2e8232871..d1bbdd26d 100644 --- a/src/util.h +++ b/src/util.h @@ -1,5 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. From b089972147348bbb3e633aaec3b232225ef455d1 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 5 Jun 2020 10:07:36 -0400 Subject: [PATCH 051/255] delete --- src/rpcblockchain.old | 1625 ----------------------------------------- 1 file changed, 1625 deletions(-) delete mode 100644 src/rpcblockchain.old diff --git a/src/rpcblockchain.old b/src/rpcblockchain.old deleted file mode 100644 index a91f73a63..000000000 --- a/src/rpcblockchain.old +++ /dev/null @@ -1,1625 +0,0 @@ -// Copyright (c) 2010 Satoshi Nakamoto -// Copyright (c) 2009-2014 The Bitcoin Core developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include "amount.h" -#include "chain.h" -#include "chainparams.h" -#include "checkpoints.h" -#include "crosschain.h" -#include "base58.h" -#include "consensus/validation.h" -#include "cc/eval.h" -#include "main.h" -#include "primitives/transaction.h" -#include "rpcserver.h" -#include "sync.h" -#include "util.h" -#include "script/script.h" -#include "script/script_error.h" -#include "script/sign.h" -#include "script/standard.h" - -#include - -#include - -#include - -using namespace std; - -extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry); -void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex); -int32_t komodo_longestchain(); -int32_t komodo_dpowconfs(int32_t height,int32_t numconfs); -<<<<<<< HEAD:src/rpcblockchain.old -extern int32_t KOMODO_LONGESTCHAIN; -======= ->>>>>>> master:src/rpcblockchain.cpp - -double GetDifficultyINTERNAL(const CBlockIndex* blockindex, bool networkDifficulty) -{ - // Floating point number that is a multiple of the minimum difficulty, - // minimum difficulty = 1.0. - if (blockindex == NULL) - { - if (chainActive.LastTip() == NULL) - return 1.0; - else - blockindex = chainActive.LastTip(); - } - - uint32_t bits; - if (networkDifficulty) { - bits = GetNextWorkRequired(blockindex, nullptr, Params().GetConsensus()); - } else { - bits = blockindex->nBits; - } - - uint32_t powLimit = - UintToArith256(Params().GetConsensus().powLimit).GetCompact(); - int nShift = (bits >> 24) & 0xff; - int nShiftAmount = (powLimit >> 24) & 0xff; - - double dDiff = - (double)(powLimit & 0x00ffffff) / - (double)(bits & 0x00ffffff); - - while (nShift < nShiftAmount) - { - dDiff *= 256.0; - nShift++; - } - while (nShift > nShiftAmount) - { - dDiff /= 256.0; - nShift--; - } - - return dDiff; -} - -double GetDifficulty(const CBlockIndex* blockindex) -{ - return GetDifficultyINTERNAL(blockindex, false); -} - -double GetNetworkDifficulty(const CBlockIndex* blockindex) -{ - return GetDifficultyINTERNAL(blockindex, true); -} - -static UniValue ValuePoolDesc( - const std::string &name, - const boost::optional chainValue, - const boost::optional valueDelta) -{ - UniValue rv(UniValue::VOBJ); - rv.push_back(Pair("id", name)); - rv.push_back(Pair("monitored", (bool)chainValue)); - if (chainValue) { - rv.push_back(Pair("chainValue", ValueFromAmount(*chainValue))); - rv.push_back(Pair("chainValueZat", *chainValue)); - } - if (valueDelta) { - rv.push_back(Pair("valueDelta", ValueFromAmount(*valueDelta))); - rv.push_back(Pair("valueDeltaZat", *valueDelta)); - } - return rv; -} - -UniValue blockheaderToJSON(const CBlockIndex* blockindex) -{ - UniValue result(UniValue::VOBJ); - if ( blockindex == 0 ) - { - result.push_back(Pair("error", "null blockhash")); - return(result); - } - result.push_back(Pair("hash", blockindex->GetBlockHash().GetHex())); - int confirmations = -1; - // Only report confirmations if the block is on the main chain - if (chainActive.Contains(blockindex)) - confirmations = chainActive.Height() - blockindex->nHeight + 1; - result.push_back(Pair("confirmations", komodo_dpowconfs(blockindex->nHeight,confirmations))); - result.push_back(Pair("rawconfirmations", confirmations)); - result.push_back(Pair("height", blockindex->nHeight)); - result.push_back(Pair("version", blockindex->nVersion)); - result.push_back(Pair("merkleroot", blockindex->hashMerkleRoot.GetHex())); - result.push_back(Pair("time", (int64_t)blockindex->nTime)); - result.push_back(Pair("nonce", blockindex->nNonce.GetHex())); - result.push_back(Pair("solution", HexStr(blockindex->nSolution))); - result.push_back(Pair("bits", strprintf("%08x", blockindex->nBits))); - result.push_back(Pair("difficulty", GetDifficulty(blockindex))); - result.push_back(Pair("chainwork", blockindex->nChainWork.GetHex())); - result.push_back(Pair("segid", (int64_t)blockindex->segid)); - - if (blockindex->pprev) - result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex())); - CBlockIndex *pnext = chainActive.Next(blockindex); - if (pnext) - result.push_back(Pair("nextblockhash", pnext->GetBlockHash().GetHex())); - return result; -} - -UniValue blockToDeltasJSON(const CBlock& block, const CBlockIndex* blockindex) -{ - UniValue result(UniValue::VOBJ); - result.push_back(Pair("hash", block.GetHash().GetHex())); - int confirmations = -1; - // Only report confirmations if the block is on the main chain - if (chainActive.Contains(blockindex)) { - confirmations = chainActive.Height() - blockindex->nHeight + 1; - } else { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block is an orphan"); - } - result.push_back(Pair("confirmations", komodo_dpowconfs(blockindex->nHeight,confirmations))); - result.push_back(Pair("rawconfirmations", confirmations)); - result.push_back(Pair("size", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION))); - result.push_back(Pair("height", blockindex->nHeight)); - result.push_back(Pair("version", block.nVersion)); - result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex())); - result.push_back(Pair("segid", (int64_t)blockindex->segid)); - - UniValue deltas(UniValue::VARR); - - for (unsigned int i = 0; i < block.vtx.size(); i++) { - const CTransaction &tx = block.vtx[i]; - const uint256 txhash = tx.GetHash(); - - UniValue entry(UniValue::VOBJ); - entry.push_back(Pair("txid", txhash.GetHex())); - entry.push_back(Pair("index", (int)i)); - - UniValue inputs(UniValue::VARR); - - if (!tx.IsCoinBase()) { - - for (size_t j = 0; j < tx.vin.size(); j++) { - const CTxIn input = tx.vin[j]; - - UniValue delta(UniValue::VOBJ); - - CSpentIndexValue spentInfo; - CSpentIndexKey spentKey(input.prevout.hash, input.prevout.n); - - if (GetSpentIndex(spentKey, spentInfo)) { - if (spentInfo.addressType == 1) { - delta.push_back(Pair("address", CBitcoinAddress(CKeyID(spentInfo.addressHash)).ToString())); - } - else if (spentInfo.addressType == 2) { - delta.push_back(Pair("address", CBitcoinAddress(CScriptID(spentInfo.addressHash)).ToString())); - } - else { - continue; - } - delta.push_back(Pair("satoshis", -1 * spentInfo.satoshis)); - delta.push_back(Pair("index", (int)j)); - delta.push_back(Pair("prevtxid", input.prevout.hash.GetHex())); - delta.push_back(Pair("prevout", (int)input.prevout.n)); - - inputs.push_back(delta); - } else { - throw JSONRPCError(RPC_INTERNAL_ERROR, "Spent information not available"); - } - - } - } - - entry.push_back(Pair("inputs", inputs)); - - UniValue outputs(UniValue::VARR); - - for (unsigned int k = 0; k < tx.vout.size(); k++) { - const CTxOut &out = tx.vout[k]; - - UniValue delta(UniValue::VOBJ); - - if (out.scriptPubKey.IsPayToScriptHash()) { - vector hashBytes(out.scriptPubKey.begin()+2, out.scriptPubKey.begin()+22); - delta.push_back(Pair("address", CBitcoinAddress(CScriptID(uint160(hashBytes))).ToString())); - - } - else if (out.scriptPubKey.IsPayToPublicKeyHash()) { - vector hashBytes(out.scriptPubKey.begin()+3, out.scriptPubKey.begin()+23); - delta.push_back(Pair("address", CBitcoinAddress(CKeyID(uint160(hashBytes))).ToString())); - } - else if (out.scriptPubKey.IsPayToPublicKey() || out.scriptPubKey.IsPayToCryptoCondition()) { - CTxDestination address; - if (ExtractDestination(out.scriptPubKey, address)) - { - //vector hashBytes(out.scriptPubKey.begin()+1, out.scriptPubKey.begin()+34); - //xxx delta.push_back(Pair("address", CBitcoinAddress(CKeyID(uint160(hashBytes))).ToString())); - delta.push_back(Pair("address", CBitcoinAddress(address).ToString())); - } - } - else { - continue; - } - - delta.push_back(Pair("satoshis", out.nValue)); - delta.push_back(Pair("index", (int)k)); - - outputs.push_back(delta); - } - - entry.push_back(Pair("outputs", outputs)); - deltas.push_back(entry); - - } - result.push_back(Pair("deltas", deltas)); - result.push_back(Pair("time", block.GetBlockTime())); - result.push_back(Pair("mediantime", (int64_t)blockindex->GetMedianTimePast())); - result.push_back(Pair("nonce", block.nNonce.GetHex())); - result.push_back(Pair("bits", strprintf("%08x", block.nBits))); - result.push_back(Pair("difficulty", GetDifficulty(blockindex))); - result.push_back(Pair("chainwork", blockindex->nChainWork.GetHex())); - - if (blockindex->pprev) - result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex())); - CBlockIndex *pnext = chainActive.Next(blockindex); - if (pnext) - result.push_back(Pair("nextblockhash", pnext->GetBlockHash().GetHex())); - return result; -} - -UniValue blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool txDetails = false) -{ - UniValue result(UniValue::VOBJ); - result.push_back(Pair("hash", block.GetHash().GetHex())); - int confirmations = -1; - // Only report confirmations if the block is on the main chain - if (chainActive.Contains(blockindex)) - confirmations = chainActive.Height() - blockindex->nHeight + 1; - result.push_back(Pair("confirmations", komodo_dpowconfs(blockindex->nHeight,confirmations))); - result.push_back(Pair("rawconfirmations", confirmations)); - result.push_back(Pair("size", (int)::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION))); - result.push_back(Pair("height", blockindex->nHeight)); - result.push_back(Pair("version", block.nVersion)); - result.push_back(Pair("merkleroot", block.hashMerkleRoot.GetHex())); - result.push_back(Pair("segid", (int64_t)blockindex->segid)); - UniValue txs(UniValue::VARR); - BOOST_FOREACH(const CTransaction&tx, block.vtx) - { - if(txDetails) - { - UniValue objTx(UniValue::VOBJ); - TxToJSON(tx, uint256(), objTx); - txs.push_back(objTx); - } - else - txs.push_back(tx.GetHash().GetHex()); - } - result.push_back(Pair("tx", txs)); - result.push_back(Pair("time", block.GetBlockTime())); - result.push_back(Pair("nonce", block.nNonce.GetHex())); - result.push_back(Pair("solution", HexStr(block.nSolution))); - result.push_back(Pair("bits", strprintf("%08x", block.nBits))); - result.push_back(Pair("difficulty", GetDifficulty(blockindex))); - result.push_back(Pair("chainwork", blockindex->nChainWork.GetHex())); - result.push_back(Pair("anchor", blockindex->hashAnchorEnd.GetHex())); - - UniValue valuePools(UniValue::VARR); - valuePools.push_back(ValuePoolDesc("sprout", blockindex->nChainSproutValue, blockindex->nSproutValue)); - result.push_back(Pair("valuePools", valuePools)); - - if (blockindex->pprev) - result.push_back(Pair("previousblockhash", blockindex->pprev->GetBlockHash().GetHex())); - CBlockIndex *pnext = chainActive.Next(blockindex); - if (pnext) - result.push_back(Pair("nextblockhash", pnext->GetBlockHash().GetHex())); - return result; -} - -UniValue getblockcount(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 0) - throw runtime_error( - "getblockcount\n" - "\nReturns the number of blocks in the best valid block chain.\n" - "\nResult:\n" - "n (numeric) The current block count\n" - "\nExamples:\n" - + HelpExampleCli("getblockcount", "") - + HelpExampleRpc("getblockcount", "") - ); - - LOCK(cs_main); - return chainActive.Height(); -} - -UniValue getbestblockhash(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 0) - throw runtime_error( - "getbestblockhash\n" - "\nReturns the hash of the best (tip) block in the longest block chain.\n" - "\nResult\n" - "\"hex\" (string) the block hash hex encoded\n" - "\nExamples\n" - + HelpExampleCli("getbestblockhash", "") - + HelpExampleRpc("getbestblockhash", "") - ); - - LOCK(cs_main); - return chainActive.LastTip()->GetBlockHash().GetHex(); -} - -UniValue getdifficulty(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 0) - throw runtime_error( - "getdifficulty\n" - "\nReturns the proof-of-work difficulty as a multiple of the minimum difficulty.\n" - "\nResult:\n" - "n.nnn (numeric) the proof-of-work difficulty as a multiple of the minimum difficulty.\n" - "\nExamples:\n" - + HelpExampleCli("getdifficulty", "") - + HelpExampleRpc("getdifficulty", "") - ); - - LOCK(cs_main); - return GetNetworkDifficulty(); -} - -bool myIsutxo_spentinmempool(uint256 txid,int32_t vout) -{ - //char *uint256_str(char *str,uint256); char str[65]; - //LOCK(mempool.cs); - BOOST_FOREACH(const CTxMemPoolEntry &e,mempool.mapTx) - { - const CTransaction &tx = e.GetTx(); - const uint256 &hash = tx.GetHash(); - BOOST_FOREACH(const CTxIn &txin,tx.vin) - { - //fprintf(stderr,"%s/v%d ",uint256_str(str,txin.prevout.hash),txin.prevout.n); - if ( txin.prevout.n == vout && txin.prevout.hash == txid ) - return(true); - } - //fprintf(stderr,"are vins for %s\n",uint256_str(str,hash)); - } - return(false); -} - -bool mytxid_inmempool(uint256 txid) -{ - BOOST_FOREACH(const CTxMemPoolEntry &e,mempool.mapTx) - { - const CTransaction &tx = e.GetTx(); - const uint256 &hash = tx.GetHash(); - if ( txid == hash ) - return(true); - } - return(false); -} - -UniValue mempoolToJSON(bool fVerbose = false) -{ - if (fVerbose) - { - LOCK(mempool.cs); - UniValue o(UniValue::VOBJ); - BOOST_FOREACH(const CTxMemPoolEntry& e, mempool.mapTx) - { - const uint256& hash = e.GetTx().GetHash(); - UniValue info(UniValue::VOBJ); - info.push_back(Pair("size", (int)e.GetTxSize())); - info.push_back(Pair("fee", ValueFromAmount(e.GetFee()))); - info.push_back(Pair("time", e.GetTime())); - info.push_back(Pair("height", (int)e.GetHeight())); - info.push_back(Pair("startingpriority", e.GetPriority(e.GetHeight()))); - info.push_back(Pair("currentpriority", e.GetPriority(chainActive.Height()))); - const CTransaction& tx = e.GetTx(); - set setDepends; - BOOST_FOREACH(const CTxIn& txin, tx.vin) - { - if (mempool.exists(txin.prevout.hash)) - setDepends.insert(txin.prevout.hash.ToString()); - } - - UniValue depends(UniValue::VARR); - BOOST_FOREACH(const string& dep, setDepends) - { - depends.push_back(dep); - } - - info.push_back(Pair("depends", depends)); - o.push_back(Pair(hash.ToString(), info)); - } - return o; - } - else - { - vector vtxid; - mempool.queryHashes(vtxid); - - UniValue a(UniValue::VARR); - BOOST_FOREACH(const uint256& hash, vtxid) - a.push_back(hash.ToString()); - - return a; - } -} - -UniValue getrawmempool(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() > 1) - throw runtime_error( - "getrawmempool ( verbose )\n" - "\nReturns all transaction ids in memory pool as a json array of string transaction ids.\n" - "\nArguments:\n" - "1. verbose (boolean, optional, default=false) true for a json object, false for array of transaction ids\n" - "\nResult: (for verbose = false):\n" - "[ (json array of string)\n" - " \"transactionid\" (string) The transaction id\n" - " ,...\n" - "]\n" - "\nResult: (for verbose = true):\n" - "{ (json object)\n" - " \"transactionid\" : { (json object)\n" - " \"size\" : n, (numeric) transaction size in bytes\n" - " \"fee\" : n, (numeric) transaction fee in " + CURRENCY_UNIT + "\n" - " \"time\" : n, (numeric) local time transaction entered pool in seconds since 1 Jan 1970 GMT\n" - " \"height\" : n, (numeric) block height when transaction entered pool\n" - " \"startingpriority\" : n, (numeric) priority when transaction entered pool\n" - " \"currentpriority\" : n, (numeric) transaction priority now\n" - " \"depends\" : [ (array) unconfirmed transactions used as inputs for this transaction\n" - " \"transactionid\", (string) parent transaction id\n" - " ... ]\n" - " }, ...\n" - "}\n" - "\nExamples\n" - + HelpExampleCli("getrawmempool", "true") - + HelpExampleRpc("getrawmempool", "true") - ); - - LOCK(cs_main); - - bool fVerbose = false; - if (params.size() > 0) - fVerbose = params[0].get_bool(); - - return mempoolToJSON(fVerbose); -} - -UniValue getblockdeltas(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 1) - throw runtime_error(""); - - std::string strHash = params[0].get_str(); - uint256 hash(uint256S(strHash)); - - if (mapBlockIndex.count(hash) == 0) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); - - CBlock block; - CBlockIndex* pblockindex = mapBlockIndex[hash]; - - if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0) - throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not available (pruned data)"); - - if(!ReadBlockFromDisk(block, pblockindex,1)) - throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk"); - - return blockToDeltasJSON(block, pblockindex); -} - -UniValue getblockhashes(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() < 2) - throw runtime_error( - "getblockhashes timestamp\n" - "\nReturns array of hashes of blocks within the timestamp range provided.\n" - "\nArguments:\n" - "1. high (numeric, required) The newer block timestamp\n" - "2. low (numeric, required) The older block timestamp\n" - "3. options (string, required) A json object\n" - " {\n" - " \"noOrphans\":true (boolean) will only include blocks on the main chain\n" - " \"logicalTimes\":true (boolean) will include logical timestamps with hashes\n" - " }\n" - "\nResult:\n" - "[\n" - " \"hash\" (string) The block hash\n" - "]\n" - "[\n" - " {\n" - " \"blockhash\": (string) The block hash\n" - " \"logicalts\": (numeric) The logical timestamp\n" - " }\n" - "]\n" - "\nExamples:\n" - + HelpExampleCli("getblockhashes", "1231614698 1231024505") - + HelpExampleRpc("getblockhashes", "1231614698, 1231024505") - + HelpExampleCli("getblockhashes", "1231614698 1231024505 '{\"noOrphans\":false, \"logicalTimes\":true}'") - ); - - unsigned int high = params[0].get_int(); - unsigned int low = params[1].get_int(); - bool fActiveOnly = false; - bool fLogicalTS = false; - - if (params.size() > 2) { - if (params[2].isObject()) { - UniValue noOrphans = find_value(params[2].get_obj(), "noOrphans"); - UniValue returnLogical = find_value(params[2].get_obj(), "logicalTimes"); - - if (noOrphans.isBool()) - fActiveOnly = noOrphans.get_bool(); - - if (returnLogical.isBool()) - fLogicalTS = returnLogical.get_bool(); - } - } - - std::vector > blockHashes; - - if (fActiveOnly) - LOCK(cs_main); - - if (!GetTimestampIndex(high, low, fActiveOnly, blockHashes)) { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "No information available for block hashes"); - } - - UniValue result(UniValue::VARR); - - for (std::vector >::const_iterator it=blockHashes.begin(); it!=blockHashes.end(); it++) { - if (fLogicalTS) { - UniValue item(UniValue::VOBJ); - item.push_back(Pair("blockhash", it->first.GetHex())); - item.push_back(Pair("logicalts", (int)it->second)); - result.push_back(item); - } else { - result.push_back(it->first.GetHex()); - } - } - - return result; -} - -UniValue getblockhash(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 1) - throw runtime_error( - "getblockhash index\n" - "\nReturns hash of block in best-block-chain at index provided.\n" - "\nArguments:\n" - "1. index (numeric, required) The block index\n" - "\nResult:\n" - "\"hash\" (string) The block hash\n" - "\nExamples:\n" - + HelpExampleCli("getblockhash", "1000") - + HelpExampleRpc("getblockhash", "1000") - ); - - LOCK(cs_main); - - int nHeight = params[0].get_int(); - if (nHeight < 0 || nHeight > chainActive.Height()) - throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); - - CBlockIndex* pblockindex = chainActive[nHeight]; - return pblockindex->GetBlockHash().GetHex(); -} - -/*uint256 _komodo_getblockhash(int32_t nHeight) -{ - uint256 hash; - LOCK(cs_main); - if ( nHeight >= 0 && nHeight <= chainActive.Height() ) - { - CBlockIndex* pblockindex = chainActive[nHeight]; - hash = pblockindex->GetBlockHash(); - int32_t i; - for (i=0; i<32; i++) - printf("%02x",((uint8_t *)&hash)[i]); - printf(" blockhash.%d\n",nHeight); - } else memset(&hash,0,sizeof(hash)); - return(hash); -}*/ - -UniValue getblockheader(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() < 1 || params.size() > 2) - throw runtime_error( - "getblockheader \"hash\" ( verbose )\n" - "\nIf verbose is false, returns a string that is serialized, hex-encoded data for blockheader 'hash'.\n" - "If verbose is true, returns an Object with information about blockheader .\n" - "\nArguments:\n" - "1. \"hash\" (string, required) The block hash\n" - "2. verbose (boolean, optional, default=true) true for a json object, false for the hex encoded data\n" - "\nResult (for verbose = true):\n" - "{\n" - " \"hash\" : \"hash\", (string) the block hash (same as provided)\n" - " \"confirmations\" : n, (numeric) The number of confirmations, or -1 if the block is not on the main chain\n" - " \"height\" : n, (numeric) The block height or index\n" - " \"version\" : n, (numeric) The block version\n" - " \"merkleroot\" : \"xxxx\", (string) The merkle root\n" - " \"time\" : ttt, (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)\n" - " \"nonce\" : n, (numeric) The nonce\n" - " \"bits\" : \"1d00ffff\", (string) The bits\n" - " \"difficulty\" : x.xxx, (numeric) The difficulty\n" - " \"previousblockhash\" : \"hash\", (string) The hash of the previous block\n" - " \"nextblockhash\" : \"hash\" (string) The hash of the next block\n" - "}\n" - "\nResult (for verbose=false):\n" - "\"data\" (string) A string that is serialized, hex-encoded data for block 'hash'.\n" - "\nExamples:\n" - + HelpExampleCli("getblockheader", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"") - + HelpExampleRpc("getblockheader", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"") - ); - - LOCK(cs_main); - - std::string strHash = params[0].get_str(); - uint256 hash(uint256S(strHash)); - - bool fVerbose = true; - if (params.size() > 1) - fVerbose = params[1].get_bool(); - - if (mapBlockIndex.count(hash) == 0) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); - - CBlockIndex* pblockindex = mapBlockIndex[hash]; - - if (!fVerbose) - { - CDataStream ssBlock(SER_NETWORK, PROTOCOL_VERSION); - ssBlock << pblockindex->GetBlockHeader(); - std::string strHex = HexStr(ssBlock.begin(), ssBlock.end()); - return strHex; - } - - return blockheaderToJSON(pblockindex); -} - -UniValue getblock(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() < 1 || params.size() > 2) - throw runtime_error( - "getblock \"hash|height\" ( verbose )\n" - "\nIf verbose is false, returns a string that is serialized, hex-encoded data for block 'hash|height'.\n" - "If verbose is true, returns an Object with information about block .\n" - "\nArguments:\n" - "1. \"hash|height\" (string, required) The block hash or height\n" - "2. verbose (boolean, optional, default=true) true for a json object, false for the hex encoded data\n" - "\nResult (for verbose = true):\n" - "{\n" - " \"hash\" : \"hash\", (string) the block hash (same as provided hash)\n" - " \"confirmations\" : n, (numeric) The number of confirmations, or -1 if the block is not on the main chain\n" - " \"size\" : n, (numeric) The block size\n" - " \"height\" : n, (numeric) The block height or index (same as provided height)\n" - " \"version\" : n, (numeric) The block version\n" - " \"merkleroot\" : \"xxxx\", (string) The merkle root\n" - " \"tx\" : [ (array of string) The transaction ids\n" - " \"transactionid\" (string) The transaction id\n" - " ,...\n" - " ],\n" - " \"time\" : ttt, (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)\n" - " \"nonce\" : n, (numeric) The nonce\n" - " \"bits\" : \"1d00ffff\", (string) The bits\n" - " \"difficulty\" : x.xxx, (numeric) The difficulty\n" - " \"previousblockhash\" : \"hash\", (string) The hash of the previous block\n" - " \"nextblockhash\" : \"hash\" (string) The hash of the next block\n" - "}\n" - "\nResult (for verbose=false):\n" - "\"data\" (string) A string that is serialized, hex-encoded data for block 'hash'.\n" - "\nExamples:\n" - + HelpExampleCli("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"") - + HelpExampleRpc("getblock", "\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"") - + HelpExampleCli("getblock", "12800") - + HelpExampleRpc("getblock", "12800") - ); - - LOCK(cs_main); - - std::string strHash = params[0].get_str(); - - // If height is supplied, find the hash - if (strHash.size() < (2 * sizeof(uint256))) { - // std::stoi allows characters, whereas we want to be strict - regex r("[[:digit:]]+"); - if (!regex_match(strHash, r)) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid block height parameter"); - } - - int nHeight = -1; - try { - nHeight = std::stoi(strHash); - } - catch (const std::exception &e) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid block height parameter"); - } - - if (nHeight < 0 || nHeight > chainActive.Height()) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); - } - strHash = chainActive[nHeight]->GetBlockHash().GetHex(); - } - - uint256 hash(uint256S(strHash)); - - bool fVerbose = true; - if (params.size() > 1) - fVerbose = params[1].get_bool(); - - if (mapBlockIndex.count(hash) == 0) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); - - CBlock block; - CBlockIndex* pblockindex = mapBlockIndex[hash]; - - if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0) - throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not available (pruned data)"); - - if(!ReadBlockFromDisk(block, pblockindex,1)) - throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk"); - - if (!fVerbose) - { - CDataStream ssBlock(SER_NETWORK, PROTOCOL_VERSION); - ssBlock << block; - std::string strHex = HexStr(ssBlock.begin(), ssBlock.end()); - return strHex; - } - - return blockToJSON(block, pblockindex); -} - -UniValue gettxoutsetinfo(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 0) - throw runtime_error( - "gettxoutsetinfo\n" - "\nReturns statistics about the unspent transaction output set.\n" - "Note this call may take some time.\n" - "\nResult:\n" - "{\n" - " \"height\":n, (numeric) The current block height (index)\n" - " \"bestblock\": \"hex\", (string) the best block hash hex\n" - " \"transactions\": n, (numeric) The number of transactions\n" - " \"txouts\": n, (numeric) The number of output transactions\n" - " \"bytes_serialized\": n, (numeric) The serialized size\n" - " \"hash_serialized\": \"hash\", (string) The serialized hash\n" - " \"total_amount\": x.xxx (numeric) The total amount\n" - "}\n" - "\nExamples:\n" - + HelpExampleCli("gettxoutsetinfo", "") - + HelpExampleRpc("gettxoutsetinfo", "") - ); - - UniValue ret(UniValue::VOBJ); - - CCoinsStats stats; - FlushStateToDisk(); - if (pcoinsTip->GetStats(stats)) { - ret.push_back(Pair("height", (int64_t)stats.nHeight)); - ret.push_back(Pair("bestblock", stats.hashBlock.GetHex())); - ret.push_back(Pair("transactions", (int64_t)stats.nTransactions)); - ret.push_back(Pair("txouts", (int64_t)stats.nTransactionOutputs)); - ret.push_back(Pair("bytes_serialized", (int64_t)stats.nSerializedSize)); - ret.push_back(Pair("hash_serialized", stats.hashSerialized.GetHex())); - ret.push_back(Pair("total_amount", ValueFromAmount(stats.nTotalAmount))); - } - return ret; -} - -#include "komodo_defs.h" -#include "komodo_structs.h" - -#define IGUANA_MAXSCRIPTSIZE 10001 -#define KOMODO_KVDURATION 1440 -#define KOMODO_KVBINARY 2 -extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; -uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume); -int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *base,char *rel); -int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp); -char *bitcoin_address(char *coinaddr,uint8_t addrtype,uint8_t *pubkey_or_rmd160,int32_t len); -int32_t komodo_minerids(uint8_t *minerids,int32_t height,int32_t width); -int32_t komodo_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[IGUANA_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen); - -UniValue kvsearch(const UniValue& params, bool fHelp) -{ - UniValue ret(UniValue::VOBJ); uint32_t flags; uint8_t value[IGUANA_MAXSCRIPTSIZE*8],key[IGUANA_MAXSCRIPTSIZE*8]; int32_t duration,j,height,valuesize,keylen; uint256 refpubkey; static uint256 zeroes; - if (fHelp || params.size() != 1 ) - throw runtime_error( - "kvsearch key\n" - "\nSearch for a key stored via the kvupdate command. This feature is only available for asset chains.\n" - "\nArguments:\n" - "1. key (string, required) search the chain for this key\n" - "\nResult:\n" - "{\n" - " \"coin\": \"xxxxx\", (string) chain the key is stored on\n" - " \"currentheight\": xxxxx, (numeric) current height of the chain\n" - " \"key\": \"xxxxx\", (string) key\n" - " \"keylen\": xxxxx, (string) length of the key \n" - " \"owner\": \"xxxxx\" (string) hex string representing the owner of the key \n" - " \"height\": xxxxx, (numeric) height the key was stored at\n" - " \"expiration\": xxxxx, (numeric) height the key will expire\n" - " \"flags\": x (numeric) 1 if the key was created with a password; 0 otherwise.\n" - " \"value\": \"xxxxx\", (string) stored value\n" - " \"valuesize\": xxxxx (string) amount of characters stored\n" - "}\n" - "\nExamples:\n" - + HelpExampleCli("kvsearch", "examplekey") - + HelpExampleRpc("kvsearch", "\"examplekey\"") - ); - LOCK(cs_main); - if ( (keylen= (int32_t)strlen(params[0].get_str().c_str())) > 0 ) - { - ret.push_back(Pair("coin",(char *)(ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL))); - ret.push_back(Pair("currentheight", (int64_t)chainActive.LastTip()->nHeight)); - ret.push_back(Pair("key",params[0].get_str())); - ret.push_back(Pair("keylen",keylen)); - if ( keylen < sizeof(key) ) - { - memcpy(key,params[0].get_str().c_str(),keylen); - if ( (valuesize= komodo_kvsearch(&refpubkey,chainActive.LastTip()->nHeight,&flags,&height,value,key,keylen)) >= 0 ) - { - std::string val; char *valuestr; - val.resize(valuesize); - valuestr = (char *)val.data(); - memcpy(valuestr,value,valuesize); - if ( memcmp(&zeroes,&refpubkey,sizeof(refpubkey)) != 0 ) - ret.push_back(Pair("owner",refpubkey.GetHex())); - ret.push_back(Pair("height",height)); - duration = ((flags >> 2) + 1) * KOMODO_KVDURATION; - ret.push_back(Pair("expiration", (int64_t)(height+duration))); - ret.push_back(Pair("flags",(int64_t)flags)); - ret.push_back(Pair("value",val)); - ret.push_back(Pair("valuesize",valuesize)); - } else ret.push_back(Pair("error",(char *)"cant find key")); - } else ret.push_back(Pair("error",(char *)"key too big")); - } else ret.push_back(Pair("error",(char *)"null key")); - return ret; -} - -UniValue minerids(const UniValue& params, bool fHelp) -{ - uint32_t timestamp = 0; UniValue ret(UniValue::VOBJ); UniValue a(UniValue::VARR); uint8_t minerids[2000],pubkeys[65][33]; int32_t i,j,n,numnotaries,tally[129]; - if ( fHelp || params.size() != 1 ) - throw runtime_error("minerids needs height\n"); - LOCK(cs_main); - int32_t height = atoi(params[0].get_str().c_str()); - if ( height <= 0 ) - height = chainActive.LastTip()->nHeight; - else - { - CBlockIndex *pblockindex = chainActive[height]; - if ( pblockindex != 0 ) - timestamp = pblockindex->GetBlockTime(); - } - if ( (n= komodo_minerids(minerids,height,(int32_t)(sizeof(minerids)/sizeof(*minerids)))) > 0 ) - { - memset(tally,0,sizeof(tally)); - numnotaries = komodo_notaries(pubkeys,height,timestamp); - if ( numnotaries > 0 ) - { - for (i=0; i= numnotaries ) - tally[128]++; - else tally[minerids[i]]++; - } - for (i=0; i<64; i++) - { - UniValue item(UniValue::VOBJ); std::string hex,kmdaddress; char *hexstr,kmdaddr[64],*ptr; int32_t m; - hex.resize(66); - hexstr = (char *)hex.data(); - for (j=0; j<33; j++) - sprintf(&hexstr[j*2],"%02x",pubkeys[i][j]); - item.push_back(Pair("notaryid", i)); - - bitcoin_address(kmdaddr,60,pubkeys[i],33); - m = (int32_t)strlen(kmdaddr); - kmdaddress.resize(m); - ptr = (char *)kmdaddress.data(); - memcpy(ptr,kmdaddr,m); - item.push_back(Pair("KMDaddress", kmdaddress)); - - item.push_back(Pair("pubkey", hex)); - item.push_back(Pair("blocks", tally[i])); - a.push_back(item); - } - UniValue item(UniValue::VOBJ); - item.push_back(Pair("pubkey", (char *)"external miners")); - item.push_back(Pair("blocks", tally[128])); - a.push_back(item); - } - ret.push_back(Pair("mined", a)); - ret.push_back(Pair("numnotaries", numnotaries)); - } else ret.push_back(Pair("error", (char *)"couldnt extract minerids")); - return ret; -} - -UniValue notaries(const UniValue& params, bool fHelp) -{ - UniValue a(UniValue::VARR); uint32_t timestamp=0; UniValue ret(UniValue::VOBJ); int32_t i,j,n,m; char *hexstr; uint8_t pubkeys[64][33]; char btcaddr[64],kmdaddr[64],*ptr; - if ( fHelp || (params.size() != 1 && params.size() != 2) ) - throw runtime_error("notaries height timestamp\n"); - LOCK(cs_main); - int32_t height = atoi(params[0].get_str().c_str()); - if ( params.size() == 2 ) - timestamp = (uint32_t)atol(params[1].get_str().c_str()); - else timestamp = (uint32_t)time(NULL); - if ( height < 0 ) - { - height = chainActive.LastTip()->nHeight; - timestamp = chainActive.LastTip()->GetBlockTime(); - } - else if ( params.size() < 2 ) - { - CBlockIndex *pblockindex = chainActive[height]; - if ( pblockindex != 0 ) - timestamp = pblockindex->GetBlockTime(); - } - if ( (n= komodo_notaries(pubkeys,height,timestamp)) > 0 ) - { - for (i=0; i 0 ) - ret.push_back(Pair("withdraws", opretbuf)); - else ret.push_back(Pair("withdraws", (char *)"")); - for (baseid=0; baseid<32; baseid++) - { - UniValue item(UniValue::VOBJ); UniValue obj(UniValue::VOBJ); - if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,CURRENCIES[baseid]) == 0 ) - { - if ( deposited != 0 || issued != 0 || withdrawn != 0 || approved != 0 || redeemed != 0 ) - { - item.push_back(Pair("available", ValueFromAmount(available))); - item.push_back(Pair("deposited", ValueFromAmount(deposited))); - item.push_back(Pair("issued", ValueFromAmount(issued))); - item.push_back(Pair("withdrawn", ValueFromAmount(withdrawn))); - item.push_back(Pair("approved", ValueFromAmount(approved))); - item.push_back(Pair("redeemed", ValueFromAmount(redeemed))); - obj.push_back(Pair(CURRENCIES[baseid],item)); - a.push_back(obj); - } - } - } - ret.push_back(Pair("fiatstatus", a)); - return ret; -} - -UniValue paxprice(const UniValue& params, bool fHelp) -{ - if ( fHelp || params.size() > 4 || params.size() < 2 ) - throw runtime_error("paxprice \"base\" \"rel\" height\n"); - LOCK(cs_main); - UniValue ret(UniValue::VOBJ); uint64_t basevolume=0,relvolume,seed; - std::string base = params[0].get_str(); - std::string rel = params[1].get_str(); - int32_t height; - if ( params.size() == 2 ) - height = chainActive.LastTip()->nHeight; - else height = atoi(params[2].get_str().c_str()); - //if ( params.size() == 3 || (basevolume= COIN * atof(params[3].get_str().c_str())) == 0 ) - basevolume = 100000; - relvolume = komodo_paxprice(&seed,height,(char *)base.c_str(),(char *)rel.c_str(),basevolume); - ret.push_back(Pair("base", base)); - ret.push_back(Pair("rel", rel)); - ret.push_back(Pair("height", height)); - char seedstr[32]; - sprintf(seedstr,"%llu",(long long)seed); - ret.push_back(Pair("seed", seedstr)); - if ( height < 0 || height > chainActive.Height() ) - throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); - else - { - CBlockIndex *pblockindex = chainActive[height]; - if ( pblockindex != 0 ) - ret.push_back(Pair("timestamp", (int64_t)pblockindex->nTime)); - if ( basevolume != 0 && relvolume != 0 ) - { - ret.push_back(Pair("price",((double)relvolume / (double)basevolume))); - ret.push_back(Pair("invprice",((double)basevolume / (double)relvolume))); - ret.push_back(Pair("basevolume",ValueFromAmount(basevolume))); - ret.push_back(Pair("relvolume",ValueFromAmount(relvolume))); - } else ret.push_back(Pair("error", "overflow or error in one or more of parameters")); - } - return ret; -} - -UniValue paxprices(const UniValue& params, bool fHelp) -{ - if ( fHelp || params.size() != 3 ) - throw runtime_error("paxprices \"base\" \"rel\" maxsamples\n"); - LOCK(cs_main); - UniValue ret(UniValue::VOBJ); uint64_t relvolume,prices[4096]; uint32_t i,n; int32_t heights[sizeof(prices)/sizeof(*prices)]; - std::string base = params[0].get_str(); - std::string rel = params[1].get_str(); - int32_t maxsamples = atoi(params[2].get_str().c_str()); - if ( maxsamples < 1 ) - maxsamples = 1; - else if ( maxsamples > sizeof(heights)/sizeof(*heights) ) - maxsamples = sizeof(heights)/sizeof(*heights); - ret.push_back(Pair("base", base)); - ret.push_back(Pair("rel", rel)); - n = komodo_paxprices(heights,prices,maxsamples,(char *)base.c_str(),(char *)rel.c_str()); - UniValue a(UniValue::VARR); - for (i=0; i chainActive.Height() ) - throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); - else - { - CBlockIndex *pblockindex = chainActive[heights[i]]; - - item.push_back(Pair("t", (int64_t)pblockindex->nTime)); - item.push_back(Pair("p", (double)prices[i] / COIN)); - a.push_back(item); - } - } - ret.push_back(Pair("array", a)); - return ret; -} - -uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue,int32_t tipheight); - -UniValue gettxout(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() < 2 || params.size() > 3) - throw runtime_error( - "gettxout \"txid\" n ( includemempool )\n" - "\nReturns details about an unspent transaction output.\n" - "\nArguments:\n" - "1. \"txid\" (string, required) The transaction id\n" - "2. n (numeric, required) vout value\n" - "3. includemempool (boolean, optional) Whether to include the mempool\n" - "\nResult:\n" - "{\n" - " \"bestblock\" : \"hash\", (string) the block hash\n" - " \"confirmations\" : n, (numeric) The number of confirmations\n" - " \"value\" : x.xxx, (numeric) The transaction value in " + CURRENCY_UNIT + "\n" - " \"scriptPubKey\" : { (json object)\n" - " \"asm\" : \"code\", (string) \n" - " \"hex\" : \"hex\", (string) \n" - " \"reqSigs\" : n, (numeric) Number of required signatures\n" - " \"type\" : \"pubkeyhash\", (string) The type, eg pubkeyhash\n" - " \"addresses\" : [ (array of string) array of Komodo addresses\n" - " \"komodoaddress\" (string) Komodo address\n" - " ,...\n" - " ]\n" - " },\n" - " \"version\" : n, (numeric) The version\n" - " \"coinbase\" : true|false (boolean) Coinbase or not\n" - "}\n" - - "\nExamples:\n" - "\nGet unspent transactions\n" - + HelpExampleCli("listunspent", "") + - "\nView the details\n" - + HelpExampleCli("gettxout", "\"txid\" 1") + - "\nAs a json rpc call\n" - + HelpExampleRpc("gettxout", "\"txid\", 1") - ); - - LOCK(cs_main); - - UniValue ret(UniValue::VOBJ); - - std::string strHash = params[0].get_str(); - uint256 hash(uint256S(strHash)); - int n = params[1].get_int(); - bool fMempool = true; - if (params.size() > 2) - fMempool = params[2].get_bool(); - - CCoins coins; - if (fMempool) { - LOCK(mempool.cs); - CCoinsViewMemPool view(pcoinsTip, mempool); - if (!view.GetCoins(hash, coins)) - return NullUniValue; - mempool.pruneSpent(hash, coins); // TODO: this should be done by the CCoinsViewMemPool - } else { - if (!pcoinsTip->GetCoins(hash, coins)) - return NullUniValue; - } - if (n<0 || (unsigned int)n>=coins.vout.size() || coins.vout[n].IsNull()) - return NullUniValue; - - BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock()); - CBlockIndex *pindex = it->second; - ret.push_back(Pair("bestblock", pindex->GetBlockHash().GetHex())); - if ((unsigned int)coins.nHeight == MEMPOOL_HEIGHT) - ret.push_back(Pair("confirmations", 0)); - else - { - ret.push_back(Pair("confirmations", komodo_dpowconfs(coins.nHeight,pindex->nHeight - coins.nHeight + 1))); - ret.push_back(Pair("rawconfirmations", pindex->nHeight - coins.nHeight + 1)); - } - ret.push_back(Pair("value", ValueFromAmount(coins.vout[n].nValue))); - uint64_t interest; int32_t txheight; uint32_t locktime; - if ( (interest= komodo_accrued_interest(&txheight,&locktime,hash,n,coins.nHeight,coins.vout[n].nValue,(int32_t)pindex->nHeight)) != 0 ) - ret.push_back(Pair("interest", ValueFromAmount(interest))); - UniValue o(UniValue::VOBJ); - ScriptPubKeyToJSON(coins.vout[n].scriptPubKey, o, true); - ret.push_back(Pair("scriptPubKey", o)); - ret.push_back(Pair("version", coins.nVersion)); - ret.push_back(Pair("coinbase", coins.fCoinBase)); - - return ret; -} - -UniValue verifychain(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() > 2) - throw runtime_error( - "verifychain ( checklevel numblocks )\n" - "\nVerifies blockchain database.\n" - "\nArguments:\n" - "1. checklevel (numeric, optional, 0-4, default=3) How thorough the block verification is.\n" - "2. numblocks (numeric, optional, default=288, 0=all) The number of blocks to check.\n" - "\nResult:\n" - "true|false (boolean) Verified or not\n" - "\nExamples:\n" - + HelpExampleCli("verifychain", "") - + HelpExampleRpc("verifychain", "") - ); - - LOCK(cs_main); - - int nCheckLevel = GetArg("-checklevel", 3); - int nCheckDepth = GetArg("-checkblocks", 288); - if (params.size() > 0) - nCheckLevel = params[0].get_int(); - if (params.size() > 1) - nCheckDepth = params[1].get_int(); - - return CVerifyDB().VerifyDB(pcoinsTip, nCheckLevel, nCheckDepth); -} - -/** Implementation of IsSuperMajority with better feedback */ -static UniValue SoftForkMajorityDesc(int minVersion, CBlockIndex* pindex, int nRequired, const Consensus::Params& consensusParams) -{ - int nFound = 0; - CBlockIndex* pstart = pindex; - for (int i = 0; i < consensusParams.nMajorityWindow && pstart != NULL; i++) - { - if (pstart->nVersion >= minVersion) - ++nFound; - pstart = pstart->pprev; - } - - UniValue rv(UniValue::VOBJ); - rv.push_back(Pair("status", nFound >= nRequired)); - rv.push_back(Pair("found", nFound)); - rv.push_back(Pair("required", nRequired)); - rv.push_back(Pair("window", consensusParams.nMajorityWindow)); - return rv; -} - -static UniValue SoftForkDesc(const std::string &name, int version, CBlockIndex* pindex, const Consensus::Params& consensusParams) -{ - UniValue rv(UniValue::VOBJ); - rv.push_back(Pair("id", name)); - rv.push_back(Pair("version", version)); - rv.push_back(Pair("enforce", SoftForkMajorityDesc(version, pindex, consensusParams.nMajorityEnforceBlockUpgrade, consensusParams))); - rv.push_back(Pair("reject", SoftForkMajorityDesc(version, pindex, consensusParams.nMajorityRejectBlockOutdated, consensusParams))); - return rv; -} - -static UniValue NetworkUpgradeDesc(const Consensus::Params& consensusParams, Consensus::UpgradeIndex idx, int height) -{ - UniValue rv(UniValue::VOBJ); - auto upgrade = NetworkUpgradeInfo[idx]; - rv.push_back(Pair("name", upgrade.strName)); - rv.push_back(Pair("activationheight", consensusParams.vUpgrades[idx].nActivationHeight)); - switch (NetworkUpgradeState(height, consensusParams, idx)) { - case UPGRADE_DISABLED: rv.push_back(Pair("status", "disabled")); break; - case UPGRADE_PENDING: rv.push_back(Pair("status", "pending")); break; - case UPGRADE_ACTIVE: rv.push_back(Pair("status", "active")); break; - } - rv.push_back(Pair("info", upgrade.strInfo)); - return rv; -} - -void NetworkUpgradeDescPushBack( - UniValue& networkUpgrades, - const Consensus::Params& consensusParams, - Consensus::UpgradeIndex idx, - int height) -{ - // Network upgrades with an activation height of NO_ACTIVATION_HEIGHT are - // hidden. This is used when network upgrade implementations are merged - // without specifying the activation height. - if (consensusParams.vUpgrades[idx].nActivationHeight != Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT) { - networkUpgrades.push_back(Pair( - HexInt(NetworkUpgradeInfo[idx].nBranchId), - NetworkUpgradeDesc(consensusParams, idx, height))); - } -} - - -UniValue getblockchaininfo(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 0) - throw runtime_error( - "getblockchaininfo\n" - "Returns an object containing various state info regarding block chain processing.\n" - "\nNote that when the chain tip is at the last block before a network upgrade activation,\n" - "consensus.chaintip != consensus.nextblock.\n" - "\nResult:\n" - "{\n" - " \"chain\": \"xxxx\", (string) current network name as defined in BIP70 (main, test, regtest)\n" - " \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n" - " \"headers\": xxxxxx, (numeric) the current number of headers we have validated\n" - " \"bestblockhash\": \"...\", (string) the hash of the currently best block\n" - " \"difficulty\": xxxxxx, (numeric) the current difficulty\n" - " \"verificationprogress\": xxxx, (numeric) estimate of verification progress [0..1]\n" - " \"chainwork\": \"xxxx\" (string) total amount of work in active chain, in hexadecimal\n" - " \"size_on_disk\": xxxxxx, (numeric) the estimated size of the block and undo files on disk\n" - " \"commitments\": xxxxxx, (numeric) the current number of note commitments in the commitment tree\n" - " \"softforks\": [ (array) status of softforks in progress\n" - " {\n" - " \"id\": \"xxxx\", (string) name of softfork\n" - " \"version\": xx, (numeric) block version\n" - " \"enforce\": { (object) progress toward enforcing the softfork rules for new-version blocks\n" - " \"status\": xx, (boolean) true if threshold reached\n" - " \"found\": xx, (numeric) number of blocks with the new version found\n" - " \"required\": xx, (numeric) number of blocks required to trigger\n" - " \"window\": xx, (numeric) maximum size of examined window of recent blocks\n" - " },\n" - " \"reject\": { ... } (object) progress toward rejecting pre-softfork blocks (same fields as \"enforce\")\n" - " }, ...\n" - " ],\n" - " \"upgrades\": { (object) status of network upgrades\n" - " \"xxxx\" : { (string) branch ID of the upgrade\n" - " \"name\": \"xxxx\", (string) name of upgrade\n" - " \"activationheight\": xxxxxx, (numeric) block height of activation\n" - " \"status\": \"xxxx\", (string) status of upgrade\n" - " \"info\": \"xxxx\", (string) additional information about upgrade\n" - " }, ...\n" - " },\n" - " \"consensus\": { (object) branch IDs of the current and upcoming consensus rules\n" - " \"chaintip\": \"xxxxxxxx\", (string) branch ID used to validate the current chain tip\n" - " \"nextblock\": \"xxxxxxxx\" (string) branch ID that the next block will be validated under\n" - " }\n" - "}\n" - "\nExamples:\n" - + HelpExampleCli("getblockchaininfo", "") - + HelpExampleRpc("getblockchaininfo", "") - ); - - LOCK(cs_main); - double progress; - if ( ASSETCHAINS_SYMBOL[0] == 0 ) { - progress = Checkpoints::GuessVerificationProgress(Params().Checkpoints(), chainActive.LastTip()); - } else { - int32_t longestchain = KOMODO_LONGESTCHAIN;//komodo_longestchain(); - progress = (longestchain > 0 ) ? (double) chainActive.Height() / longestchain : 1.0; - } - UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("chain", Params().NetworkIDString())); - obj.push_back(Pair("blocks", (int)chainActive.Height())); - obj.push_back(Pair("headers", pindexBestHeader ? pindexBestHeader->nHeight : -1)); - obj.push_back(Pair("bestblockhash", chainActive.LastTip()->GetBlockHash().GetHex())); - obj.push_back(Pair("difficulty", (double)GetNetworkDifficulty())); - obj.push_back(Pair("verificationprogress", progress)); - obj.push_back(Pair("chainwork", chainActive.LastTip()->nChainWork.GetHex())); - obj.push_back(Pair("pruned", fPruneMode)); - obj.push_back(Pair("size_on_disk", CalculateCurrentUsage())); - - ZCIncrementalMerkleTree tree; - pcoinsTip->GetAnchorAt(pcoinsTip->GetBestAnchor(), tree); - #ifdef __APPLE__ - obj.push_back(Pair("commitments", (uint64_t)tree.size())); - #else - obj.push_back(Pair("commitments", tree.size())); - #endif - - CBlockIndex* tip = chainActive.LastTip(); - UniValue valuePools(UniValue::VARR); - valuePools.push_back(ValuePoolDesc("sprout", tip->nChainSproutValue, boost::none)); - obj.push_back(Pair("valuePools", valuePools)); - - const Consensus::Params& consensusParams = Params().GetConsensus(); - UniValue softforks(UniValue::VARR); - softforks.push_back(SoftForkDesc("bip34", 2, tip, consensusParams)); - softforks.push_back(SoftForkDesc("bip66", 3, tip, consensusParams)); - softforks.push_back(SoftForkDesc("bip65", 4, tip, consensusParams)); - obj.push_back(Pair("softforks", softforks)); - - UniValue upgrades(UniValue::VOBJ); - for (int i = Consensus::UPGRADE_OVERWINTER; i < Consensus::MAX_NETWORK_UPGRADES; i++) { - NetworkUpgradeDescPushBack(upgrades, consensusParams, Consensus::UpgradeIndex(i), tip->nHeight); - } - obj.push_back(Pair("upgrades", upgrades)); - - UniValue consensus(UniValue::VOBJ); - consensus.push_back(Pair("chaintip", HexInt(CurrentEpochBranchId(tip->nHeight, consensusParams)))); - consensus.push_back(Pair("nextblock", HexInt(CurrentEpochBranchId(tip->nHeight + 1, consensusParams)))); - obj.push_back(Pair("consensus", consensus)); - - if (fPruneMode) - { - CBlockIndex *block = chainActive.LastTip(); - while (block && block->pprev && (block->pprev->nStatus & BLOCK_HAVE_DATA)) - block = block->pprev; - - obj.push_back(Pair("pruneheight", block->nHeight)); - } - return obj; -} - -/** Comparison function for sorting the getchaintips heads. */ -struct CompareBlocksByHeight -{ - bool operator()(const CBlockIndex* a, const CBlockIndex* b) const - { - /* Make sure that unequal blocks with the same height do not compare - equal. Use the pointers themselves to make a distinction. */ - - if (a->nHeight != b->nHeight) - return (a->nHeight > b->nHeight); - - return a < b; - } -}; - -#include - -UniValue getchaintips(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 0) - throw runtime_error( - "getchaintips\n" - "Return information about all known tips in the block tree," - " including the main chain as well as orphaned branches.\n" - "\nResult:\n" - "[\n" - " {\n" - " \"height\": xxxx, (numeric) height of the chain tip\n" - " \"hash\": \"xxxx\", (string) block hash of the tip\n" - " \"branchlen\": 0 (numeric) zero for main chain\n" - " \"status\": \"active\" (string) \"active\" for the main chain\n" - " },\n" - " {\n" - " \"height\": xxxx,\n" - " \"hash\": \"xxxx\",\n" - " \"branchlen\": 1 (numeric) length of branch connecting the tip to the main chain\n" - " \"status\": \"xxxx\" (string) status of the chain (active, valid-fork, valid-headers, headers-only, invalid)\n" - " }\n" - "]\n" - "Possible values for status:\n" - "1. \"invalid\" This branch contains at least one invalid block\n" - "2. \"headers-only\" Not all blocks for this branch are available, but the headers are valid\n" - "3. \"valid-headers\" All blocks are available for this branch, but they were never fully validated\n" - "4. \"valid-fork\" This branch is not part of the active chain, but is fully validated\n" - "5. \"active\" This is the tip of the active main chain, which is certainly valid\n" - "\nExamples:\n" - + HelpExampleCli("getchaintips", "") - + HelpExampleRpc("getchaintips", "") - ); - - LOCK(cs_main); - - /* Build up a list of chain tips. We start with the list of all - known blocks, and successively remove blocks that appear as pprev - of another block. */ - /*static pthread_mutex_t mutex; static int32_t didinit; - if ( didinit == 0 ) - { - pthread_mutex_init(&mutex,NULL); - didinit = 1; - } - pthread_mutex_lock(&mutex);*/ - std::set setTips; - int32_t n = 0; - BOOST_FOREACH(const PAIRTYPE(const uint256, CBlockIndex*)& item, mapBlockIndex) - { - n++; - setTips.insert(item.second); - } - fprintf(stderr,"iterations getchaintips %d\n",n); - n = 0; - BOOST_FOREACH(const PAIRTYPE(const uint256, CBlockIndex*)& item, mapBlockIndex) - { - const CBlockIndex* pprev=0; - n++; - if ( item.second != 0 ) - pprev = item.second->pprev; - if (pprev) - setTips.erase(pprev); - } - fprintf(stderr,"iterations getchaintips %d\n",n); - //pthread_mutex_unlock(&mutex); - - // Always report the currently active tip. - setTips.insert(chainActive.LastTip()); - - /* Construct the output array. */ - UniValue res(UniValue::VARR); const CBlockIndex *forked; - BOOST_FOREACH(const CBlockIndex* block, setTips) - BOOST_FOREACH(const CBlockIndex* block, setTips) - { - UniValue obj(UniValue::VOBJ); - obj.push_back(Pair("height", block->nHeight)); - obj.push_back(Pair("hash", block->phashBlock->GetHex())); - forked = chainActive.FindFork(block); - if ( forked != 0 ) - { - const int branchLen = block->nHeight - forked->nHeight; - obj.push_back(Pair("branchlen", branchLen)); - - string status; - if (chainActive.Contains(block)) { - // This block is part of the currently active chain. - status = "active"; - } else if (block->nStatus & BLOCK_FAILED_MASK) { - // This block or one of its ancestors is invalid. - status = "invalid"; - } else if (block->nChainTx == 0) { - // This block cannot be connected because full block data for it or one of its parents is missing. - status = "headers-only"; - } else if (block->IsValid(BLOCK_VALID_SCRIPTS)) { - // This block is fully validated, but no longer part of the active chain. It was probably the active block once, but was reorganized. - status = "valid-fork"; - } else if (block->IsValid(BLOCK_VALID_TREE)) { - // The headers for this block are valid, but it has not been validated. It was probably never part of the most-work chain. - status = "valid-headers"; - } else { - // No clue. - status = "unknown"; - } - obj.push_back(Pair("status", status)); - } - res.push_back(obj); - } - - return res; -} - -UniValue mempoolInfoToJSON() -{ - UniValue ret(UniValue::VOBJ); - ret.push_back(Pair("size", (int64_t) mempool.size())); - ret.push_back(Pair("bytes", (int64_t) mempool.GetTotalTxSize())); - ret.push_back(Pair("usage", (int64_t) mempool.DynamicMemoryUsage())); - - return ret; -} - -UniValue getmempoolinfo(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 0) - throw runtime_error( - "getmempoolinfo\n" - "\nReturns details on the active state of the TX memory pool.\n" - "\nResult:\n" - "{\n" - " \"size\": xxxxx (numeric) Current tx count\n" - " \"bytes\": xxxxx (numeric) Sum of all tx sizes\n" - " \"usage\": xxxxx (numeric) Total memory usage for the mempool\n" - "}\n" - "\nExamples:\n" - + HelpExampleCli("getmempoolinfo", "") - + HelpExampleRpc("getmempoolinfo", "") - ); - - return mempoolInfoToJSON(); -} - -UniValue invalidateblock(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 1) - throw runtime_error( - "invalidateblock \"hash\"\n" - "\nPermanently marks a block as invalid, as if it violated a consensus rule.\n" - "\nArguments:\n" - "1. hash (string, required) the hash of the block to mark as invalid\n" - "\nResult:\n" - "\nExamples:\n" - + HelpExampleCli("invalidateblock", "\"blockhash\"") - + HelpExampleRpc("invalidateblock", "\"blockhash\"") - ); - - std::string strHash = params[0].get_str(); - uint256 hash(uint256S(strHash)); - CValidationState state; - - { - LOCK(cs_main); - if (mapBlockIndex.count(hash) == 0) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); - - CBlockIndex* pblockindex = mapBlockIndex[hash]; - InvalidateBlock(state, pblockindex); - } - - if (state.IsValid()) { - ActivateBestChain(state); - } - - if (!state.IsValid()) { - throw JSONRPCError(RPC_DATABASE_ERROR, state.GetRejectReason()); - } - - return NullUniValue; -} - -UniValue reconsiderblock(const UniValue& params, bool fHelp) -{ - if (fHelp || params.size() != 1) - throw runtime_error( - "reconsiderblock \"hash\"\n" - "\nRemoves invalidity status of a block and its descendants, reconsider them for activation.\n" - "This can be used to undo the effects of invalidateblock.\n" - "\nArguments:\n" - "1. hash (string, required) the hash of the block to reconsider\n" - "\nResult:\n" - "\nExamples:\n" - + HelpExampleCli("reconsiderblock", "\"blockhash\"") - + HelpExampleRpc("reconsiderblock", "\"blockhash\"") - ); - - std::string strHash = params[0].get_str(); - uint256 hash(uint256S(strHash)); - CValidationState state; - - { - LOCK(cs_main); - if (mapBlockIndex.count(hash) == 0) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Block not found"); - - CBlockIndex* pblockindex = mapBlockIndex[hash]; - ReconsiderBlock(state, pblockindex); - } - - if (state.IsValid()) { - ActivateBestChain(state); - } - - if (!state.IsValid()) { - throw JSONRPCError(RPC_DATABASE_ERROR, state.GetRejectReason()); - } - - return NullUniValue; -} From 86a98587a1d1fa7c89f77ef213416eed7b5eb1b2 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 5 Jun 2020 10:14:52 -0400 Subject: [PATCH 052/255] desprout --- src/consensus/upgrades.cpp | 1 + src/serialize.h | 1 + src/wallet/asyncrpcoperation_mergetoaddress.h | 49 ---------- src/wallet/gtest/test_wallet.cpp | 5 - src/wallet/rpcwallet.cpp | 4 +- src/wallet/wallet.cpp | 2 +- src/wallet/wallet.h | 91 ++----------------- src/zcash/Address.hpp | 73 +-------------- src/zcash/JoinSplit.cpp | 18 ---- src/zcash/JoinSplit.hpp | 56 ------------ src/zcash/Note.hpp | 63 +------------ src/zcash/prf.h | 10 +- src/zcash/zip32.h | 3 +- 13 files changed, 24 insertions(+), 352 deletions(-) diff --git a/src/consensus/upgrades.cpp b/src/consensus/upgrades.cpp index b75e0c002..984ca377e 100644 --- a/src/consensus/upgrades.cpp +++ b/src/consensus/upgrades.cpp @@ -1,3 +1,4 @@ +// Copyright (c) 2019-2020 The Hush developers // Copyright (c) 2018 The Zcash developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/serialize.h b/src/serialize.h index 3d9c3fae6..9d23b469c 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -1,5 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2009-2014 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/wallet/asyncrpcoperation_mergetoaddress.h b/src/wallet/asyncrpcoperation_mergetoaddress.h index 4876921db..32dbcf015 100644 --- a/src/wallet/asyncrpcoperation_mergetoaddress.h +++ b/src/wallet/asyncrpcoperation_mergetoaddress.h @@ -44,29 +44,11 @@ using namespace libzcash; // Input UTXO is a tuple of txid, vout, amount, script typedef std::tuple MergeToAddressInputUTXO; -// Input JSOP is a tuple of JSOutpoint, note, amount, spending key -typedef std::tuple MergeToAddressInputSproutNote; - typedef std::tuple MergeToAddressInputSaplingNote; // A recipient is a tuple of address, memo (optional if zaddr) typedef std::tuple MergeToAddressRecipient; -// Package of info which is passed to perform_joinsplit methods. -struct MergeToAddressJSInfo { - std::vector vjsin; - std::vector vjsout; - std::vector notes; - std::vector zkeys; - CAmount vpub_old = 0; - CAmount vpub_new = 0; -}; - -// A struct to help us track the witness and anchor for a given JSOutPoint -struct MergeToAddressWitnessAnchorData { - boost::optional witness; - uint256 anchor; -}; class AsyncRPCOperation_mergetoaddress : public AsyncRPCOperation { @@ -116,7 +98,6 @@ private: std::unordered_map jsopWitnessAnchorMap; std::vector utxoInputs_; - std::vector sproutNoteInputs_; std::vector saplingNoteInputs_; TransactionBuilder builder_; @@ -125,18 +106,6 @@ private: std::array get_memo_from_hex_string(std::string s); bool main_impl(); - // JoinSplit without any input notes to spend - UniValue perform_joinsplit(MergeToAddressJSInfo&); - - // JoinSplit with input notes to spend (JSOutPoints)) - UniValue perform_joinsplit(MergeToAddressJSInfo&, std::vector&); - - // JoinSplit where you have the witnesses and anchor - UniValue perform_joinsplit( - MergeToAddressJSInfo& info, - std::vector> witnesses, - uint256 anchor); - void sign_send_raw_transaction(UniValue obj); // throws exception if there was an error void lock_utxos(); @@ -180,24 +149,6 @@ public: return delegate->main_impl(); } - UniValue perform_joinsplit(MergeToAddressJSInfo& info) - { - return delegate->perform_joinsplit(info); - } - - UniValue perform_joinsplit(MergeToAddressJSInfo& info, std::vector& v) - { - return delegate->perform_joinsplit(info, v); - } - - UniValue perform_joinsplit( - MergeToAddressJSInfo& info, - std::vector> witnesses, - uint256 anchor) - { - return delegate->perform_joinsplit(info, witnesses, anchor); - } - void sign_send_raw_transaction(UniValue obj) { delegate->sign_send_raw_transaction(obj); diff --git a/src/wallet/gtest/test_wallet.cpp b/src/wallet/gtest/test_wallet.cpp index 0ad789137..6373b6e9f 100644 --- a/src/wallet/gtest/test_wallet.cpp +++ b/src/wallet/gtest/test_wallet.cpp @@ -75,11 +75,6 @@ CWalletTx GetValidReceive(const libzcash::SproutSpendingKey& sk, CAmount value, return GetValidReceive(*params, sk, value, randomInputs, version); } -libzcash::SproutNote GetNote(const libzcash::SproutSpendingKey& sk, - const CTransaction& tx, size_t js, size_t n) { - return GetNote(*params, sk, tx, js, n); -} - CWalletTx GetValidSpend(const libzcash::SproutSpendingKey& sk, const libzcash::SproutNote& note, CAmount value) { return GetValidSpend(*params, sk, note, value); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index d3d396bbc..2a451dc12 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3123,7 +3123,7 @@ UniValue getalldata(const UniValue& params, bool fHelp,const CPubKey&) if (wtx.GetDepthInMainChain() < 0) continue; - if (wtx.mapSaplingNoteData.size() == 0 && wtx.mapSproutNoteData.size() == 0 && !wtx.IsTrusted()) + if (wtx.mapSaplingNoteData.size() == 0 && !wtx.IsTrusted()) continue; //Assign Immature @@ -3309,7 +3309,7 @@ UniValue getalldata(const UniValue& params, bool fHelp,const CPubKey&) if (!CheckFinalTx(wtx)) continue; - if (wtx.mapSaplingNoteData.size() == 0 && wtx.mapSproutNoteData.size() == 0 && !wtx.IsTrusted()) + if (wtx.mapSaplingNoteData.size() == 0 && !wtx.IsTrusted()) continue; //Excude transactions with less confirmations than required diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 4be804abb..a346a547f 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -934,7 +934,7 @@ int CWallet::VerifyAndSetInitialWitness(const CBlockIndex* pindex, bool witnessO for (std::pair& wtxItem : mapWallet) { nWitnessTxIncrement += 1; - if (wtxItem.second.mapSproutNoteData.empty() && wtxItem.second.mapSaplingNoteData.empty()) + if (wtxItem.second.mapSaplingNoteData.empty()) continue; if (wtxItem.second.GetDepthInMainChain() > 0) { diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index f3526c583..0cd7d8bb6 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -236,82 +236,19 @@ public: std::string ToString() const; }; -class SproutNoteData +class SaplingNoteData { public: - libzcash::SproutPaymentAddress address; - - /** - * Cached note nullifier. May not be set if the wallet was not unlocked when - * this was SproutNoteData was created. If not set, we always assume that the - * note has not been spent. - * - * It's okay to cache the nullifier in the wallet, because we are storing - * the spending key there too, which could be used to derive this. - * If the wallet is encrypted, this means that someone with access to the - * locked wallet cannot spend notes, but can connect received notes to the - * transactions they are spent in. This is the same security semantics as - * for transparent addresses. - */ - boost::optional nullifier; - - /** - * Cached incremental witnesses for spendable Notes. - * Beginning of the list is the most recent witness. - */ - std::list witnesses; - /** * Block height corresponding to the most current witness. * - * When we first create a SproutNoteData in CWallet::FindMySproutNotes, this is set to + * When we first create a SaplingNoteData in CWallet::FindMySaplingNotes, this is set to * -1 as a placeholder. The next time CWallet::ChainTip is called, we can * determine what height the witness cache for this note is valid for (even * if no witnesses were cached), and so can set the correct value in * CWallet::BuildWitnessCache and CWallet::DecrementNoteWitnesses. */ - int witnessHeight; - //In Memory Only - bool witnessRootValidated; - - SproutNoteData() : address(), nullifier(), witnessHeight {-1}, witnessRootValidated {false} { } - SproutNoteData(libzcash::SproutPaymentAddress a) : - address {a}, nullifier(), witnessHeight {-1}, witnessRootValidated {false} { } - SproutNoteData(libzcash::SproutPaymentAddress a, uint256 n) : - address {a}, nullifier {n}, witnessHeight {-1}, witnessRootValidated {false} { } - - ADD_SERIALIZE_METHODS; - - template - inline void SerializationOp(Stream& s, Operation ser_action) { - READWRITE(address); - READWRITE(nullifier); - READWRITE(witnesses); - READWRITE(witnessHeight); - } - - friend bool operator<(const SproutNoteData& a, const SproutNoteData& b) { - return (a.address < b.address || - (a.address == b.address && a.nullifier < b.nullifier)); - } - - friend bool operator==(const SproutNoteData& a, const SproutNoteData& b) { - return (a.address == b.address && a.nullifier == b.nullifier); - } - - friend bool operator!=(const SproutNoteData& a, const SproutNoteData& b) { - return !(a == b); - } -}; - -class SaplingNoteData -{ -public: - /** - * We initialize the height to -1 for the same reason as we do in SproutNoteData. - * See the comment in that class for a full description. - */ SaplingNoteData() : witnessHeight {-1}, nullifier() { } SaplingNoteData(libzcash::SaplingIncomingViewingKey ivk) : ivk {ivk}, witnessHeight {-1}, nullifier() { } SaplingNoteData(libzcash::SaplingIncomingViewingKey ivk, uint256 n) : ivk {ivk}, witnessHeight {-1}, nullifier(n) { } @@ -347,18 +284,11 @@ public: } }; + +// NOTE: this sprout structure is serialized into wallet.dat, removing it would change wallet.dat format on disk :( typedef std::map mapSproutNoteData_t; typedef std::map mapSaplingNoteData_t; -/** Decrypted note, its location in a transaction, and number of confirmations. */ -struct CSproutNotePlaintextEntry -{ - JSOutPoint jsop; - libzcash::SproutPaymentAddress address; - libzcash::SproutNotePlaintext plaintext; - int confirmations; -}; - /** Sapling note, its location in a transaction, and number of confirmations. */ struct SaplingNoteEntry { @@ -824,7 +754,6 @@ public: protected: - int SproutWitnessMinimumHeight(const uint256& nullifier, int nWitnessHeight, int nMinimumHeight); int SaplingWitnessMinimumHeight(const uint256& nullifier, int nWitnessHeight, int nMinimumHeight); /** @@ -848,11 +777,11 @@ protected: try { for (std::pair& wtxItem : mapWallet) { auto wtx = wtxItem.second; - // We skip transactions for which mapSproutNoteData and mapSaplingNoteData - // are empty. This covers transactions that have no Sprout or Sapling data + // We skip transactions for which mapSaplingNoteData + // is empty. This covers transactions that have no Sapling data // (i.e. are purely transparent), as well as shielding and unshielding // transactions in which we only have transparent addresses involved. - if (!(wtx.mapSproutNoteData.empty() && wtx.mapSaplingNoteData.empty())) { + if (!(wtx.mapSaplingNoteData.empty())) { if (!walletdb.WriteTx(wtxItem.first, wtx)) { LogPrintf("SetBestChain(): Failed to write CWalletTx, aborting atomic write\n"); walletdb.TxnAbort(); @@ -1319,8 +1248,7 @@ public: bool LoadCryptedHDSeed(const uint256& seedFp, const std::vector& seed); /* Find notes filtered by payment address, min depth, ability to spend */ - void GetFilteredNotes(std::vector& sproutEntries, - std::vector& saplingEntries, + void GetFilteredNotes(std::vector& saplingEntries, std::string address, int minDepth=1, bool ignoreSpent=true, @@ -1328,8 +1256,7 @@ public: /* Find notes filtered by payment addresses, min depth, max depth, if they are spent, if a spending key is required, and if they are locked */ - void GetFilteredNotes(std::vector& sproutEntries, - std::vector& saplingEntries, + void GetFilteredNotes(std::vector& saplingEntries, std::set& filterAddresses, int minDepth=1, int maxDepth=INT_MAX, diff --git a/src/zcash/Address.hpp b/src/zcash/Address.hpp index 42ee0031b..df9034bce 100644 --- a/src/zcash/Address.hpp +++ b/src/zcash/Address.hpp @@ -1,3 +1,5 @@ +// Copyright (c) 2019-2020 The Hush developers + #ifndef ZC_ADDRESS_H_ #define ZC_ADDRESS_H_ @@ -26,34 +28,6 @@ const size_t SerializedSaplingSpendingKeySize = 32; typedef std::array diversifier_t; -class SproutPaymentAddress { -public: - uint256 a_pk; - uint256 pk_enc; - - SproutPaymentAddress() : a_pk(), pk_enc() { } - SproutPaymentAddress(uint256 a_pk, uint256 pk_enc) : a_pk(a_pk), pk_enc(pk_enc) { } - - ADD_SERIALIZE_METHODS; - - template - inline void SerializationOp(Stream& s, Operation ser_action) { - READWRITE(a_pk); - READWRITE(pk_enc); - } - - //! Get the 256-bit SHA256d hash of this payment address. - uint256 GetHash() const; - - friend inline bool operator==(const SproutPaymentAddress& a, const SproutPaymentAddress& b) { - return a.a_pk == b.a_pk && a.pk_enc == b.pk_enc; - } - friend inline bool operator<(const SproutPaymentAddress& a, const SproutPaymentAddress& b) { - return (a.a_pk < b.a_pk || - (a.a_pk == b.a_pk && a.pk_enc < b.pk_enc)); - } -}; - class ReceivingKey : public uint256 { public: ReceivingKey() { } @@ -62,45 +36,6 @@ public: uint256 pk_enc() const; }; -class SproutViewingKey { -public: - uint256 a_pk; - ReceivingKey sk_enc; - - SproutViewingKey() : a_pk(), sk_enc() { } - SproutViewingKey(uint256 a_pk, ReceivingKey sk_enc) : a_pk(a_pk), sk_enc(sk_enc) { } - - ADD_SERIALIZE_METHODS; - - template - inline void SerializationOp(Stream& s, Operation ser_action) { - READWRITE(a_pk); - READWRITE(sk_enc); - } - - SproutPaymentAddress address() const; - - friend inline bool operator==(const SproutViewingKey& a, const SproutViewingKey& b) { - return a.a_pk == b.a_pk && a.sk_enc == b.sk_enc; - } - friend inline bool operator<(const SproutViewingKey& a, const SproutViewingKey& b) { - return (a.a_pk < b.a_pk || - (a.a_pk == b.a_pk && a.sk_enc < b.sk_enc)); - } -}; - -class SproutSpendingKey : public uint252 { -public: - SproutSpendingKey() : uint252() { } - SproutSpendingKey(uint252 a_sk) : uint252(a_sk) { } - - static SproutSpendingKey random(); - - ReceivingKey receiving_key() const; - SproutViewingKey viewing_key() const; - SproutPaymentAddress address() const; -}; - //! Sapling functions. class SaplingPaymentAddress { public: @@ -218,8 +153,8 @@ public: SaplingPaymentAddress default_address() const; }; -typedef boost::variant PaymentAddress; -typedef boost::variant ViewingKey; +typedef boost::variant PaymentAddress; +typedef boost::variant ViewingKey; } diff --git a/src/zcash/JoinSplit.cpp b/src/zcash/JoinSplit.cpp index 0a052209a..e71bf25b1 100644 --- a/src/zcash/JoinSplit.cpp +++ b/src/zcash/JoinSplit.cpp @@ -246,24 +246,6 @@ uint256 JoinSplit::h_sig( return output; } -SproutNote JSOutput::note(const uint252& phi, const uint256& r, size_t i, const uint256& h_sig) const { - uint256 rho = PRF_rho(phi, i, h_sig); - - return SproutNote(addr.a_pk, value, rho, r); -} - -JSOutput::JSOutput() : addr(uint256(), uint256()), value(0) { - SproutSpendingKey a_sk = SproutSpendingKey::random(); - addr = a_sk.address(); -} - -JSInput::JSInput() : witness(SproutMerkleTree().witness()), - key(SproutSpendingKey::random()) { - note = SproutNote(key.address().a_pk, 0, random_uint256(), random_uint256()); - SproutMerkleTree dummy_tree; - dummy_tree.append(note.cm()); - witness = dummy_tree.witness(); -} template class JoinSplit; diff --git a/src/zcash/JoinSplit.hpp b/src/zcash/JoinSplit.hpp index 09e31570f..27df05db0 100644 --- a/src/zcash/JoinSplit.hpp +++ b/src/zcash/JoinSplit.hpp @@ -24,69 +24,13 @@ typedef std::array GrothProof; typedef boost::variant SproutProof; class JSInput { -public: - SproutWitness witness; - SproutNote note; - SproutSpendingKey key; - - JSInput(); - JSInput(SproutWitness witness, - SproutNote note, - SproutSpendingKey key) : witness(witness), note(note), key(key) { } - - uint256 nullifier() const { - return note.nullifier(key); - } }; class JSOutput { -public: - SproutPaymentAddress addr; - uint64_t value; - std::array memo = {{0xF6}}; // 0xF6 is invalid UTF8 as per spec, rest of array is 0x00 - - JSOutput(); - JSOutput(SproutPaymentAddress addr, uint64_t value) : addr(addr), value(value) { } - - SproutNote note(const uint252& phi, const uint256& r, size_t i, const uint256& h_sig) const; }; template class JoinSplit { -public: - virtual ~JoinSplit() {} - - static JoinSplit* Prepared(); - - static uint256 h_sig(const uint256& randomSeed, - const std::array& nullifiers, - const uint256& joinSplitPubKey - ); - - // Compute nullifiers, macs, note commitments & encryptions, and SNARK proof - virtual SproutProof prove( - const std::array& inputs, - const std::array& outputs, - std::array& out_notes, - std::array& out_ciphertexts, - uint256& out_ephemeralKey, - const uint256& joinSplitPubKey, - uint256& out_randomSeed, - std::array& out_hmacs, - std::array& out_nullifiers, - std::array& out_commitments, - uint64_t vpub_old, - uint64_t vpub_new, - const uint256& rt, - bool computeProof = true, - // For paymentdisclosure, we need to retrieve the esk. - // Reference as non-const parameter with default value leads to compile error. - // So use pointer for simplicity. - uint256 *out_esk = nullptr - ) = 0; - -protected: - JoinSplit() {} }; } diff --git a/src/zcash/Note.hpp b/src/zcash/Note.hpp index 7d3377306..5b16d95c5 100644 --- a/src/zcash/Note.hpp +++ b/src/zcash/Note.hpp @@ -1,3 +1,5 @@ +// Copyright (c) 2019-2020 The Hush developers + #ifndef ZC_NOTE_H_ #define ZC_NOTE_H_ @@ -22,25 +24,6 @@ public: inline uint64_t value() const { return value_; }; }; -class SproutNote : public BaseNote { -public: - uint256 a_pk; - uint256 rho; - uint256 r; - - SproutNote(uint256 a_pk, uint64_t value, uint256 rho, uint256 r) - : BaseNote(value), a_pk(a_pk), rho(rho), r(r) {} - - SproutNote(); - - virtual ~SproutNote() {}; - - uint256 cm() const; - - uint256 nullifier(const SproutSpendingKey& a_sk) const; -}; - - class SaplingNote : public BaseNote { public: diversifier_t d; @@ -74,48 +57,6 @@ public: inline const std::array & memo() const { return memo_; } }; -class SproutNotePlaintext : public BaseNotePlaintext { -public: - uint256 rho; - uint256 r; - - SproutNotePlaintext() {} - - SproutNotePlaintext(const SproutNote& note, std::array memo); - - SproutNote note(const SproutPaymentAddress& addr) const; - - virtual ~SproutNotePlaintext() {} - - ADD_SERIALIZE_METHODS; - - template - inline void SerializationOp(Stream& s, Operation ser_action) { - unsigned char leadingByte = 0x00; - READWRITE(leadingByte); - - if (leadingByte != 0x00) { - throw std::ios_base::failure("lead byte of SproutNotePlaintext is not recognized"); - } - - READWRITE(value_); - READWRITE(rho); - READWRITE(r); - READWRITE(memo_); - } - - static SproutNotePlaintext decrypt(const ZCNoteDecryption& decryptor, - const ZCNoteDecryption::Ciphertext& ciphertext, - const uint256& ephemeralKey, - const uint256& h_sig, - unsigned char nonce - ); - - ZCNoteEncryption::Ciphertext encrypt(ZCNoteEncryption& encryptor, - const uint256& pk_enc - ) const; -}; - typedef std::pair SaplingNotePlaintextEncryptionResult; class SaplingNotePlaintext : public BaseNotePlaintext { diff --git a/src/zcash/prf.h b/src/zcash/prf.h index f666cfa23..adfd7d710 100644 --- a/src/zcash/prf.h +++ b/src/zcash/prf.h @@ -1,5 +1,6 @@ +// Copyright (c) 2019-2020 The Hush developers /* -Zcash uses SHA256Compress as a PRF for various components +Hush uses SHA256Compress as a PRF for various components within the zkSNARK circuit. */ @@ -11,13 +12,6 @@ within the zkSNARK circuit. #include -//! Sprout functions -uint256 PRF_addr_a_pk(const uint252& a_sk); -uint256 PRF_addr_sk_enc(const uint252& a_sk); -uint256 PRF_nf(const uint252& a_sk, const uint256& rho); -uint256 PRF_pk(const uint252& a_sk, size_t i0, const uint256& h_sig); -uint256 PRF_rho(const uint252& phi, size_t i0, const uint256& h_sig); - //! Sapling functions uint256 PRF_ask(const uint256& sk); uint256 PRF_nsk(const uint256& sk); diff --git a/src/zcash/zip32.h b/src/zcash/zip32.h index 44bc58598..1521dddd1 100644 --- a/src/zcash/zip32.h +++ b/src/zcash/zip32.h @@ -1,4 +1,5 @@ // Copyright (c) 2018 The Zcash developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -134,7 +135,7 @@ struct SaplingExtendedSpendingKey { } }; -typedef boost::variant SpendingKey; +typedef boost::variant SpendingKey; } From a44fa2ede4f474ed5a70dfa7a391ead3bf60075d Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 5 Jun 2020 10:24:22 -0400 Subject: [PATCH 053/255] This datastructure is tied to the wallet.dat format on disk --- src/wallet/wallet.h | 50 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 0cd7d8bb6..f6e6274d1 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -236,6 +236,56 @@ public: std::string ToString() const; }; +// NOTE: wallet.dat format depends on this data structure :( +class SproutNoteData + { + public: + libzcash::SproutPaymentAddress address; + + /** + * Cached note nullifier. May not be set if the wallet was not unlocked when + * this was SproutNoteData was created. If not set, we always assume that the + * note has not been spent. + * + * It's okay to cache the nullifier in the wallet, because we are storing + * the spending key there too, which could be used to derive this. + * If the wallet is encrypted, this means that someone with access to the + * locked wallet cannot spend notes, but can connect received notes to the + * transactions they are spent in. This is the same security semantics as + * for transparent addresses. + */ + boost::optional nullifier; + + /** + * Cached incremental witnesses for spendable Notes. + * Beginning of the list is the most recent witness. + */ + std::list witnesses; + + /** + * Block height corresponding to the most current witness. + * + * When we first create a SaplingNoteData in CWallet::FindMySaplingNotes, this is set to + * -1 as a placeholder. The next time CWallet::ChainTip is called, we can + * determine what height the witness cache for this note is valid for (even + * if no witnesses were cached), and so can set the correct value in + * CWallet::BuildWitnessCache and CWallet::DecrementNoteWitnesses. + */ + int witnessHeight; + + ADD_SERIALIZE_METHODS; + + template + inline void SerializationOp(Stream& s, Operation ser_action) { + READWRITE(address); + READWRITE(nullifier); + READWRITE(witnesses); + READWRITE(witnessHeight); + } + +}; + + class SaplingNoteData { public: From 90406d601c9ece64697379568982224af1970d87 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 5 Jun 2020 11:13:30 -0400 Subject: [PATCH 054/255] desprout --- src/primitives/transaction.cpp | 78 +------------------------ src/wallet/asyncrpcoperation_sendmany.h | 43 +------------- src/zcash/Address.hpp | 31 ++++++++++ 3 files changed, 33 insertions(+), 119 deletions(-) diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp index 2cde04f2c..53aeeda99 100644 --- a/src/primitives/transaction.cpp +++ b/src/primitives/transaction.cpp @@ -1,5 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -26,83 +27,6 @@ #include "librustzcash.h" -JSDescription::JSDescription( - ZCJoinSplit& params, - const uint256& joinSplitPubKey, - const uint256& anchor, - const std::array& inputs, - const std::array& outputs, - CAmount vpub_old, - CAmount vpub_new, - bool computeProof, - uint256 *esk // payment disclosure -) : vpub_old(vpub_old), vpub_new(vpub_new), anchor(anchor) -{ - std::array notes; - - proof = params.prove( - inputs, - outputs, - notes, - ciphertexts, - ephemeralKey, - joinSplitPubKey, - randomSeed, - macs, - nullifiers, - commitments, - vpub_old, - vpub_new, - anchor, - computeProof, - esk // payment disclosure - ); -} - -JSDescription JSDescription::Randomized( - ZCJoinSplit& params, - const uint256& joinSplitPubKey, - const uint256& anchor, - std::array& inputs, - std::array& outputs, - std::array& inputMap, - std::array& outputMap, - CAmount vpub_old, - CAmount vpub_new, - bool computeProof, - uint256 *esk, // payment disclosure - std::function gen -) -{ - // Randomize the order of the inputs and outputs - inputMap = {0, 1}; - outputMap = {0, 1}; - - assert(gen); - - MappedShuffle(inputs.begin(), inputMap.begin(), ZC_NUM_JS_INPUTS, gen); - MappedShuffle(outputs.begin(), outputMap.begin(), ZC_NUM_JS_OUTPUTS, gen); - - return JSDescription( - params, joinSplitPubKey, anchor, inputs, outputs, - vpub_old, vpub_new, computeProof, - esk // payment disclosure - ); -} - -bool JSDescription::Verify( - ZCJoinSplit& params, - libzcash::ProofVerifier& verifier, - const uint256& joinSplitPubKey -) const { - return false; -} - -uint256 JSDescription::h_sig(ZCJoinSplit& params, const uint256& joinSplitPubKey) const -{ - return params.h_sig(randomSeed, nullifiers, joinSplitPubKey); -} - std::string COutPoint::ToString() const { return strprintf("COutPoint(%s, %u)", hash.ToString().substr(0,10), n); diff --git a/src/wallet/asyncrpcoperation_sendmany.h b/src/wallet/asyncrpcoperation_sendmany.h index 0b803ddd9..86e6ef775 100644 --- a/src/wallet/asyncrpcoperation_sendmany.h +++ b/src/wallet/asyncrpcoperation_sendmany.h @@ -46,19 +46,6 @@ typedef std::tuple SendManyRecipient; // Input UTXO is a tuple (quadruple) of txid, vout, amount, coinbase) typedef std::tuple SendManyInputUTXO; -// Input JSOP is a tuple of JSOutpoint, note and amount -typedef std::tuple SendManyInputJSOP; - -// Package of info which is passed to perform_joinsplit methods. -struct AsyncJoinSplitInfo -{ - std::vector vjsin; - std::vector vjsout; - std::vector notes; - CAmount vpub_old = 0; - CAmount vpub_new = 0; -}; - // A struct to help us track the witness and anchor for a given JSOutPoint struct WitnessAnchorData { boost::optional witness; @@ -115,7 +102,7 @@ private: std::vector t_outputs_; std::vector z_outputs_; std::vector t_inputs_; - std::vector z_sprout_inputs_; + //std::vector z_sprout_inputs_; std::vector z_sapling_inputs_; TransactionBuilder builder_; @@ -128,18 +115,6 @@ private: std::array get_memo_from_hex_string(std::string s); bool main_impl(); - // JoinSplit without any input notes to spend - UniValue perform_joinsplit(AsyncJoinSplitInfo &); - - // JoinSplit with input notes to spend (JSOutPoints)) - UniValue perform_joinsplit(AsyncJoinSplitInfo &, std::vector & ); - - // JoinSplit where you have the witnesses and anchor - UniValue perform_joinsplit( - AsyncJoinSplitInfo & info, - std::vector> witnesses, - uint256 anchor); - void sign_send_raw_transaction(UniValue obj); // throws exception if there was an error }; @@ -185,22 +160,6 @@ public: return delegate->main_impl(); } - UniValue perform_joinsplit(AsyncJoinSplitInfo &info) { - return delegate->perform_joinsplit(info); - } - - UniValue perform_joinsplit(AsyncJoinSplitInfo &info, std::vector &v ) { - return delegate->perform_joinsplit(info, v); - } - - UniValue perform_joinsplit( - AsyncJoinSplitInfo & info, - std::vector> witnesses, - uint256 anchor) - { - return delegate->perform_joinsplit(info, witnesses, anchor); - } - void sign_send_raw_transaction(UniValue obj) { delegate->sign_send_raw_transaction(obj); } diff --git a/src/zcash/Address.hpp b/src/zcash/Address.hpp index df9034bce..ac90120a5 100644 --- a/src/zcash/Address.hpp +++ b/src/zcash/Address.hpp @@ -36,6 +36,37 @@ public: uint256 pk_enc() const; }; + +// NOTE: wallet.dat format depends on this +class SproutPaymentAddress { +public: + uint256 a_pk; + uint256 pk_enc; + + SproutPaymentAddress() : a_pk(), pk_enc() { } + SproutPaymentAddress(uint256 a_pk, uint256 pk_enc) : a_pk(a_pk), pk_enc(pk_enc) { } + + ADD_SERIALIZE_METHODS; + + template + inline void SerializationOp(Stream& s, Operation ser_action) { + READWRITE(a_pk); + READWRITE(pk_enc); + } + + //! Get the 256-bit SHA256d hash of this payment address. + uint256 GetHash() const; + + friend inline bool operator==(const SproutPaymentAddress& a, const SproutPaymentAddress& b) { + return a.a_pk == b.a_pk && a.pk_enc == b.pk_enc; + } + friend inline bool operator<(const SproutPaymentAddress& a, const SproutPaymentAddress& b) { + return (a.a_pk < b.a_pk || + (a.a_pk == b.a_pk && a.pk_enc < b.pk_enc)); + } +}; + + //! Sapling functions. class SaplingPaymentAddress { public: From 3cb215e39ad5fc163cfb4b726d6eb3e6ad13bde7 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 5 Jun 2020 12:17:41 -0400 Subject: [PATCH 055/255] more desprout, ugh --- src/init.cpp | 5 +- src/rpc/client.cpp | 2 - src/rpc/server.cpp | 6 +- .../asyncrpcoperation_mergetoaddress.cpp | 1 - src/wallet/asyncrpcoperation_sendmany.cpp | 4 +- src/wallet/rpcwallet.cpp | 8 +- src/zcash/JoinSplit.cpp | 163 +----------------- src/zcash/Note.cpp | 4 + src/zcash/prf.h | 10 +- 9 files changed, 21 insertions(+), 182 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index fd0303786..32cefbe91 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1042,10 +1042,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (mapArgs.count("-developerencryptwallet")) { fprintf(stderr,"%s wallet encryption error\n", __FUNCTION__); return InitError(_("Wallet encryption requires -experimentalfeatures.")); - } - else if (mapArgs.count("-paymentdisclosure")) { - fprintf(stderr,"%s payment disclosure error\n", __FUNCTION__); - return InitError(_("Payment disclosure requires -experimentalfeatures.")); + //TODO: make this non experimental } else if (mapArgs.count("-zmergetoaddress")) { fprintf(stderr,"%s zmerge error\n", __FUNCTION__); return InitError(_("RPC method z_mergetoaddress requires -experimentalfeatures.")); diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 79011da34..4f11a476f 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -164,8 +164,6 @@ static const CRPCConvertParam vRPCConvertParams[] = { "kvupdate", 4 }, { "z_importkey", 2 }, { "z_importviewingkey", 2 }, - { "z_getpaymentdisclosure", 1}, - { "z_getpaymentdisclosure", 2}, { "z_listsentbyaddress", 1}, { "z_listsentbyaddress", 2}, { "z_listsentbyaddress", 3}, diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 181de29bb..cfe21a6d5 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -669,11 +669,7 @@ static const CRPCCommand vRPCCommands[] = { "wallet", "z_importviewingkey", &z_importviewingkey, true }, { "wallet", "z_exportwallet", &z_exportwallet, true }, { "wallet", "z_importwallet", &z_importwallet, true }, - { "wallet", "opreturn_burn", &opreturn_burn, true }, - - // TODO: rearrange into another category - { "disclosure", "z_getpaymentdisclosure", &z_getpaymentdisclosure, true }, - { "disclosure", "z_validatepaymentdisclosure", &z_validatepaymentdisclosure, true } + { "wallet", "opreturn_burn", &opreturn_burn, true } #endif // ENABLE_WALLET }; diff --git a/src/wallet/asyncrpcoperation_mergetoaddress.cpp b/src/wallet/asyncrpcoperation_mergetoaddress.cpp index 4e47a5a2d..0ecb1ec12 100644 --- a/src/wallet/asyncrpcoperation_mergetoaddress.cpp +++ b/src/wallet/asyncrpcoperation_mergetoaddress.cpp @@ -46,7 +46,6 @@ #include #include -#include "paymentdisclosuredb.h" int32_t komodo_blockheight(uint256 hash); using namespace libzcash; diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index 31f987bef..06b8960cf 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -49,7 +49,6 @@ #include #include -#include "paymentdisclosuredb.h" #include using namespace libzcash; @@ -142,9 +141,8 @@ AsyncRPCOperation_sendmany::AsyncRPCOperation_sendmany( LogPrint("zrpc", "%s: z_sendmany initialized\n", getId()); } - // Enable payment disclosure if requested - paymentDisclosureMode = fExperimentalMode && GetBoolArg("-paymentdisclosure", true); + paymentDisclosureMode = false; } AsyncRPCOperation_sendmany::~AsyncRPCOperation_sendmany() { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 2a451dc12..340f62a9c 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -8309,9 +8309,6 @@ extern UniValue z_importviewingkey(const UniValue& params, bool fHelp, const CPu extern UniValue z_exportwallet(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue z_importwallet(const UniValue& params, bool fHelp, const CPubKey& mypk); -extern UniValue z_getpaymentdisclosure(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcdisclosure.cpp -extern UniValue z_validatepaymentdisclosure(const UniValue& params, bool fHelp, const CPubKey& mypk); - static const CRPCCommand commands[] = { // category name actor (function) okSafeMode // --------------------- ------------------------ ----------------------- ---------- @@ -8380,10 +8377,7 @@ static const CRPCCommand commands[] = { "wallet", "z_getinfo", &z_getinfo, true }, { "wallet", "z_listsentbyaddress", &z_listsentbyaddress, true }, { "wallet", "z_listreceivedbyaddress", &z_listreceivedbyaddress, true }, - { "wallet", "z_getnotescount", &z_getnotescount, false }, - // TODO: rearrange into another category - { "disclosure", "z_getpaymentdisclosure", &z_getpaymentdisclosure, true }, - { "disclosure", "z_validatepaymentdisclosure", &z_validatepaymentdisclosure, true } + { "wallet", "z_getnotescount", &z_getnotescount, false } }; diff --git a/src/zcash/JoinSplit.cpp b/src/zcash/JoinSplit.cpp index e71bf25b1..db51ff1fd 100644 --- a/src/zcash/JoinSplit.cpp +++ b/src/zcash/JoinSplit.cpp @@ -1,3 +1,4 @@ +// Copyright (c) 2019-2020 The Hush developers #include "JoinSplit.hpp" #include "prf.h" #include "sodium.h" @@ -28,6 +29,7 @@ public: JoinSplitCircuit() {} ~JoinSplitCircuit() {} + /* SproutProof prove( const std::array& inputs, const std::array& outputs, @@ -45,169 +47,13 @@ public: bool computeProof, uint256 *out_esk // Payment disclosure ) { - if (vpub_old > MAX_MONEY) { - throw std::invalid_argument("nonsensical vpub_old value"); - } - - if (vpub_new > MAX_MONEY) { - throw std::invalid_argument("nonsensical vpub_new value"); - } - - uint64_t lhs_value = vpub_old; - uint64_t rhs_value = vpub_new; - - for (size_t i = 0; i < NumInputs; i++) { - // Sanity checks of input - { - // If note has nonzero value - if (inputs[i].note.value() != 0) { - // The witness root must equal the input root. - if (inputs[i].witness.root() != rt) { - throw std::invalid_argument("joinsplit not anchored to the correct root"); - } - - // The tree must witness the correct element - if (inputs[i].note.cm() != inputs[i].witness.element()) { - throw std::invalid_argument("witness of wrong element for joinsplit input"); - } - } - - // Ensure we have the key to this note. - if (inputs[i].note.a_pk != inputs[i].key.address().a_pk) { - throw std::invalid_argument("input note not authorized to spend with given key"); - } - - // Balance must be sensical - if (inputs[i].note.value() > MAX_MONEY) { - throw std::invalid_argument("nonsensical input note value"); - } - - lhs_value += inputs[i].note.value(); - - if (lhs_value > MAX_MONEY) { - throw std::invalid_argument("nonsensical left hand size of joinsplit balance"); - } - } - - // Compute nullifier of input - out_nullifiers[i] = inputs[i].nullifier(); - } - - // Sample randomSeed - out_randomSeed = random_uint256(); - - // Compute h_sig - uint256 h_sig = this->h_sig(out_randomSeed, out_nullifiers, joinSplitPubKey); - - // Sample phi - uint252 phi = random_uint252(); - - // Compute notes for outputs - for (size_t i = 0; i < NumOutputs; i++) { - // Sanity checks of output - { - if (outputs[i].value > MAX_MONEY) { - throw std::invalid_argument("nonsensical output value"); - } - - rhs_value += outputs[i].value; - - if (rhs_value > MAX_MONEY) { - throw std::invalid_argument("nonsensical right hand side of joinsplit balance"); - } - } - - // Sample r - uint256 r = random_uint256(); - - out_notes[i] = outputs[i].note(phi, r, i, h_sig); - } - - if (lhs_value != rhs_value) { - throw std::invalid_argument("invalid joinsplit balance"); - } - - // Compute the output commitments - for (size_t i = 0; i < NumOutputs; i++) { - out_commitments[i] = out_notes[i].cm(); - } - - // Encrypt the ciphertexts containing the note - // plaintexts to the recipients of the value. - { - ZCNoteEncryption encryptor(h_sig); - - for (size_t i = 0; i < NumOutputs; i++) { - SproutNotePlaintext pt(out_notes[i], outputs[i].memo); - - out_ciphertexts[i] = pt.encrypt(encryptor, outputs[i].addr.pk_enc); - } - - out_ephemeralKey = encryptor.get_epk(); - - // !!! Payment disclosure START - if (out_esk != nullptr) { - *out_esk = encryptor.get_esk(); - } - // !!! Payment disclosure END - } - - // Authenticate h_sig with each of the input - // spending keys, producing macs which protect - // against malleability. - for (size_t i = 0; i < NumInputs; i++) { - out_macs[i] = PRF_pk(inputs[i].key, i, h_sig); - } - - if (!computeProof) { - return GrothProof(); - } - GrothProof proof; - - CDataStream ss1(SER_NETWORK, PROTOCOL_VERSION); - ss1 << inputs[0].witness.path(); - std::vector auth1(ss1.begin(), ss1.end()); - - CDataStream ss2(SER_NETWORK, PROTOCOL_VERSION); - ss2 << inputs[1].witness.path(); - std::vector auth2(ss2.begin(), ss2.end()); - - librustzcash_sprout_prove( - proof.begin(), - - phi.begin(), - rt.begin(), - h_sig.begin(), - - inputs[0].key.begin(), - inputs[0].note.value(), - inputs[0].note.rho.begin(), - inputs[0].note.r.begin(), - auth1.data(), - - inputs[1].key.begin(), - inputs[1].note.value(), - inputs[1].note.rho.begin(), - inputs[1].note.r.begin(), - auth2.data(), - - out_notes[0].a_pk.begin(), - out_notes[0].value(), - out_notes[0].r.begin(), - - out_notes[1].a_pk.begin(), - out_notes[1].value(), - out_notes[1].r.begin(), - - vpub_old, - vpub_new - ); - return proof; } + */ }; +/* template JoinSplit* JoinSplit::Prepared() { @@ -250,4 +96,5 @@ uint256 JoinSplit::h_sig( template class JoinSplit; +*/ } diff --git a/src/zcash/Note.cpp b/src/zcash/Note.cpp index 23210c784..f9e9a2058 100644 --- a/src/zcash/Note.cpp +++ b/src/zcash/Note.cpp @@ -1,3 +1,5 @@ +// Copyright (c) 2019-2020 The Hush developers + #include "Note.hpp" #include "prf.h" #include "crypto/sha256.h" @@ -11,6 +13,7 @@ using namespace libzcash; +/* SproutNote::SproutNote() { a_pk = random_uint256(); rho = random_uint256(); @@ -39,6 +42,7 @@ uint256 SproutNote::cm() const { uint256 SproutNote::nullifier(const SproutSpendingKey& a_sk) const { return PRF_nf(a_sk, rho); } +*/ // Construct and populate Sapling note for a given payment address and value. SaplingNote::SaplingNote(const SaplingPaymentAddress& address, const uint64_t value) : BaseNote(value) { diff --git a/src/zcash/prf.h b/src/zcash/prf.h index adfd7d710..f666cfa23 100644 --- a/src/zcash/prf.h +++ b/src/zcash/prf.h @@ -1,6 +1,5 @@ -// Copyright (c) 2019-2020 The Hush developers /* -Hush uses SHA256Compress as a PRF for various components +Zcash uses SHA256Compress as a PRF for various components within the zkSNARK circuit. */ @@ -12,6 +11,13 @@ within the zkSNARK circuit. #include +//! Sprout functions +uint256 PRF_addr_a_pk(const uint252& a_sk); +uint256 PRF_addr_sk_enc(const uint252& a_sk); +uint256 PRF_nf(const uint252& a_sk, const uint256& rho); +uint256 PRF_pk(const uint252& a_sk, size_t i0, const uint256& h_sig); +uint256 PRF_rho(const uint252& phi, size_t i0, const uint256& h_sig); + //! Sapling functions uint256 PRF_ask(const uint256& sk); uint256 PRF_nsk(const uint256& sk); From 0cc4772c2559daf5616c03e8c217c3a2a0f26361 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 5 Jun 2020 12:43:01 -0400 Subject: [PATCH 056/255] desprout --- src/zcash/Note.cpp | 51 ---------------------------------------------- 1 file changed, 51 deletions(-) diff --git a/src/zcash/Note.cpp b/src/zcash/Note.cpp index f9e9a2058..9cd327d1b 100644 --- a/src/zcash/Note.cpp +++ b/src/zcash/Note.cpp @@ -92,57 +92,6 @@ boost::optional SaplingNote::nullifier(const SaplingFullViewingKey& vk, return result; } -SproutNotePlaintext::SproutNotePlaintext( - const SproutNote& note, - std::array memo) : BaseNotePlaintext(note, memo) -{ - rho = note.rho; - r = note.r; -} - -SproutNote SproutNotePlaintext::note(const SproutPaymentAddress& addr) const -{ - return SproutNote(addr.a_pk, value_, rho, r); -} - -SproutNotePlaintext SproutNotePlaintext::decrypt(const ZCNoteDecryption& decryptor, - const ZCNoteDecryption::Ciphertext& ciphertext, - const uint256& ephemeralKey, - const uint256& h_sig, - unsigned char nonce - ) -{ - auto plaintext = decryptor.decrypt(ciphertext, ephemeralKey, h_sig, nonce); - - CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - ss << plaintext; - - SproutNotePlaintext ret; - ss >> ret; - - assert(ss.size() == 0); - - return ret; -} - -ZCNoteEncryption::Ciphertext SproutNotePlaintext::encrypt(ZCNoteEncryption& encryptor, - const uint256& pk_enc - ) const -{ - CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - ss << (*this); - - ZCNoteEncryption::Plaintext pt; - - assert(pt.size() == ss.size()); - - memcpy(&pt[0], &ss[0], pt.size()); - - return encryptor.encrypt(pk_enc, pt); -} - - - // Construct and populate SaplingNotePlaintext for a given note and memo. SaplingNotePlaintext::SaplingNotePlaintext( const SaplingNote& note, From 22d4d1a06e88d0cc6bae7bc8dc4665931d5b11a8 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 6 Jun 2020 04:34:30 -0400 Subject: [PATCH 057/255] desprout --- .../asyncrpcoperation_mergetoaddress.cpp | 21 +-- src/wallet/asyncrpcoperation_mergetoaddress.h | 4 - ...asyncrpcoperation_saplingconsolidation.cpp | 3 +- src/wallet/asyncrpcoperation_sendmany.cpp | 18 +-- src/wallet/rpcwallet.cpp | 125 ++++-------------- 5 files changed, 31 insertions(+), 140 deletions(-) diff --git a/src/wallet/asyncrpcoperation_mergetoaddress.cpp b/src/wallet/asyncrpcoperation_mergetoaddress.cpp index 0ecb1ec12..79eaee5a9 100644 --- a/src/wallet/asyncrpcoperation_mergetoaddress.cpp +++ b/src/wallet/asyncrpcoperation_mergetoaddress.cpp @@ -74,19 +74,17 @@ AsyncRPCOperation_mergetoaddress::AsyncRPCOperation_mergetoaddress( boost::optional builder, CMutableTransaction contextualTx, std::vector utxoInputs, - std::vector sproutNoteInputs, std::vector saplingNoteInputs, MergeToAddressRecipient recipient, CAmount fee, UniValue contextInfo) : -tx_(contextualTx), utxoInputs_(utxoInputs), sproutNoteInputs_(sproutNoteInputs), -saplingNoteInputs_(saplingNoteInputs), recipient_(recipient), fee_(fee), contextinfo_(contextInfo) +tx_(contextualTx), utxoInputs_(utxoInputs), saplingNoteInputs_(saplingNoteInputs), recipient_(recipient), fee_(fee), contextinfo_(contextInfo) { if (fee < 0 || fee > MAX_MONEY) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Fee is out of range"); } - if (utxoInputs.empty() && sproutNoteInputs.empty() && saplingNoteInputs.empty()) { + if (utxoInputs.empty() && saplingNoteInputs.empty()) { throw JSONRPCError(RPC_INVALID_PARAMETER, "No inputs"); } @@ -94,14 +92,6 @@ saplingNoteInputs_(saplingNoteInputs), recipient_(recipient), fee_(fee), context throw JSONRPCError(RPC_INVALID_PARAMETER, "Recipient parameter missing"); } - if (sproutNoteInputs.size() > 0 && saplingNoteInputs.size() > 0) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot send from both Sprout and Sapling addresses using z_mergetoaddress"); - } - - if (sproutNoteInputs.size() > 0 && builder) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Sprout notes are not supported by the TransactionBuilder"); - } - isUsingBuilder_ = false; if (builder) { isUsingBuilder_ = true; @@ -215,7 +205,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl() { assert(isToTaddr_ != isToZaddr_); - bool isPureTaddrOnlyTx = (sproutNoteInputs_.empty() && saplingNoteInputs_.empty() && isToTaddr_); + bool isPureTaddrOnlyTx = (saplingNoteInputs_.empty() && isToTaddr_); CAmount minersFee = fee_; size_t numInputs = utxoInputs_.size(); @@ -240,9 +230,6 @@ bool AsyncRPCOperation_mergetoaddress::main_impl() } CAmount z_inputs_total = 0; - for (const MergeToAddressInputSproutNote& t : sproutNoteInputs_) { - z_inputs_total += std::get<2>(t); - } for (const MergeToAddressInputSaplingNote& t : saplingNoteInputs_) { z_inputs_total += std::get<2>(t); @@ -293,7 +280,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl() /** * SCENARIO #0 * - * Sprout not involved, so we just use the TransactionBuilder and we're done. + * Only sapling involved, so we just use the TransactionBuilder and we're done. * * This is based on code from AsyncRPCOperation_sendmany::main_impl() and should be refactored. */ diff --git a/src/wallet/asyncrpcoperation_mergetoaddress.h b/src/wallet/asyncrpcoperation_mergetoaddress.h index 32dbcf015..69150161e 100644 --- a/src/wallet/asyncrpcoperation_mergetoaddress.h +++ b/src/wallet/asyncrpcoperation_mergetoaddress.h @@ -57,7 +57,6 @@ public: boost::optional builder, CMutableTransaction contextualTx, std::vector utxoInputs, - std::vector sproutNoteInputs, std::vector saplingNoteInputs, MergeToAddressRecipient recipient, CAmount fee = MERGE_TO_ADDRESS_OPERATION_DEFAULT_MINERS_FEE, @@ -94,9 +93,6 @@ private: uint256 joinSplitPubKey_; unsigned char joinSplitPrivKey_[crypto_sign_SECRETKEYBYTES]; - // The key is the result string from calling JSOutPoint::ToString() - std::unordered_map jsopWitnessAnchorMap; - std::vector utxoInputs_; std::vector saplingNoteInputs_; diff --git a/src/wallet/asyncrpcoperation_saplingconsolidation.cpp b/src/wallet/asyncrpcoperation_saplingconsolidation.cpp index 0a57b8948..477545348 100644 --- a/src/wallet/asyncrpcoperation_saplingconsolidation.cpp +++ b/src/wallet/asyncrpcoperation_saplingconsolidation.cpp @@ -87,7 +87,6 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() { return status; } - std::vector sproutEntries; std::vector saplingEntries; std::set addresses; { @@ -95,7 +94,7 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() { // We set minDepth to 11 to avoid unconfirmed notes and in anticipation of specifying // an anchor at height N-10 for each SpendDescription // Consider, should notes be sorted? - pwalletMain->GetFilteredNotes(sproutEntries, saplingEntries, "", 11); + pwalletMain->GetFilteredNotes(saplingEntries, "", 11); if (fConsolidationMapUsed) { const vector& v = mapMultiArgs["-consolidatesaplingaddress"]; for(int i = 0; i < v.size(); i++) { diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index 06b8960cf..9e82e41db 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -248,18 +248,12 @@ bool AsyncRPCOperation_sendmany::main_impl() { throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds, no unspent notes found for zaddr from address."); } - // At least one of z_sprout_inputs_ and z_sapling_inputs_ must be empty by design - assert(z_sprout_inputs_.empty() || z_sapling_inputs_.empty()); - CAmount t_inputs_total = 0; for (SendManyInputUTXO & t : t_inputs_) { t_inputs_total += std::get<2>(t); } CAmount z_inputs_total = 0; - for (SendManyInputJSOP & t : z_sprout_inputs_) { - z_inputs_total += std::get<2>(t); - } for (auto t : z_sapling_inputs_) { z_inputs_total += t.note.value(); } @@ -687,20 +681,10 @@ bool AsyncRPCOperation_sendmany::find_utxos(bool fAcceptCoinbase=false) { bool AsyncRPCOperation_sendmany::find_unspent_notes() { - std::vector sproutEntries; std::vector saplingEntries; { LOCK2(cs_main, pwalletMain->cs_wallet); - pwalletMain->GetFilteredNotes(sproutEntries, saplingEntries, fromaddress_, mindepth_); - } - - // If using the TransactionBuilder, we only want Sapling notes. - // If not using it, we only want Sprout notes. - // TODO: Refactor `GetFilteredNotes()` so we only fetch what we need. - if (isUsingBuilder_) { - sproutEntries.clear(); - } else { - saplingEntries.clear(); + pwalletMain->GetFilteredNotes(saplingEntries, fromaddress_, mindepth_); } for (auto entry : saplingEntries) { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 340f62a9c..b65e6a839 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -70,7 +70,6 @@ using namespace libzcash; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern std::string ASSETCHAINS_OVERRIDE_PUBKEY; -const std::string ADDR_TYPE_SPROUT = "sprout"; const std::string ADDR_TYPE_SAPLING = "sapling"; extern UniValue TxJoinSplitToJSON(const CTransaction& tx); extern int32_t KOMODO_INSYNC; @@ -3787,9 +3786,8 @@ UniValue z_listunspent(const UniValue& params, bool fHelp, const CPubKey& mypk) UniValue results(UniValue::VARR); if (zaddrs.size() > 0) { - std::vector sproutEntries; std::vector saplingEntries; - pwalletMain->GetFilteredNotes(sproutEntries, saplingEntries, zaddrs, nMinDepth, nMaxDepth, true, !fIncludeWatchonly, false); + pwalletMain->GetFilteredNotes(saplingEntries, zaddrs, nMinDepth, nMaxDepth, true, !fIncludeWatchonly, false); std::set> nullifierSet = pwalletMain->GetNullifiersForAddresses(zaddrs); for (auto & entry : saplingEntries) { @@ -4047,10 +4045,9 @@ CAmount getBalanceTaddr(std::string transparentAddress, int minDepth=1, bool ign CAmount getBalanceZaddr(std::string address, int minDepth = 1, bool ignoreUnspendable=true) { CAmount balance = 0; - std::vector sproutEntries; std::vector saplingEntries; LOCK2(cs_main, pwalletMain->cs_wallet); - pwalletMain->GetFilteredNotes(sproutEntries, saplingEntries, address, minDepth, true, ignoreUnspendable); + pwalletMain->GetFilteredNotes(saplingEntries, address, minDepth, true, ignoreUnspendable); for (auto & entry : saplingEntries) { balance += CAmount(entry.note.value()); } @@ -4102,16 +4099,14 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp, const CPubK throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid zaddr."); } - // Visitor to support Sprout and Sapling addrs if (!boost::apply_visitor(PaymentAddressBelongsToWallet(pwalletMain), zaddr) && !boost::apply_visitor(IncomingViewingKeyBelongsToWallet(pwalletMain), zaddr)) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "From address does not belong to this node, zaddr spending key or viewing key not found."); } UniValue result(UniValue::VARR); - std::vector sproutEntries; std::vector saplingEntries; - pwalletMain->GetFilteredNotes(sproutEntries, saplingEntries, fromaddress, nMinDepth, false, false); + pwalletMain->GetFilteredNotes(saplingEntries, fromaddress, nMinDepth, false, false); std::set> nullifierSet; auto hasSpendingKey = boost::apply_visitor(HaveSpendingKeyForPaymentAddress(pwalletMain), zaddr); @@ -4223,7 +4218,7 @@ UniValue z_getnotescount(const UniValue& params, bool fHelp,const CPubKey& mypk) "z_getnotescount\n" "\nArguments:\n" "1. minconf (numeric, optional, default=1) Only include notes in transactions confirmed at least this many times.\n" - "\nReturns the number of sprout and sapling notes available in the wallet.\n" + "\nReturns the number of sapling notes available in the wallet.\n" "\nResult:\n" "{\n" " \"sapling\" (numeric) the number of sapling notes in the wallet\n" @@ -4268,7 +4263,7 @@ UniValue z_gettotalbalance(const UniValue& params, bool fHelp, const CPubKey& my "\nResult:\n" "{\n" " \"transparent\": xxxxx, (numeric) the total balance of transparent funds\n" - " \"private\": xxxxx, (numeric) the total balance of private funds (in both Sprout and Sapling addresses)\n" + " \"private\": xxxxx, (numeric) the total balance of private funds\n" " \"total\": xxxxx, (numeric) the total balance of both transparent and private funds\n" "}\n" "\nExamples:\n" @@ -4650,14 +4645,9 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "From address does not belong to this node, zaddr spending key not found."); } - // Remember whether this is a Sprout or Sapling address + // Remember whether this is a Sapling address fromSapling = boost::get(&res) != nullptr; } - // This logic will need to be updated if we add a new shielded pool - bool fromSprout = !(fromTaddr || fromSapling); - - if (fromSprout) - throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot send from a Sprout zaddr, only Sapling zaddrs supported."); UniValue outputs = params[1].get_array(); @@ -4667,15 +4657,11 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) // Keep track of addresses to spot duplicates set setAddress; - // Track whether we see any Sprout addresses - bool noSproutAddrs = !fromSprout; - // Recipients std::vector taddrRecipients; std::vector zaddrRecipients; CAmount nTotalOut = 0; - bool containsSproutOutput = false; bool containsSaplingOutput = false; for (const UniValue& o : outputs.getValues()) { @@ -4696,35 +4682,6 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) auto res = DecodePaymentAddress(address); if (IsValidPaymentAddress(res, branchId)) { isZaddr = true; - - bool toSapling = boost::get(&res) != nullptr; - bool toSprout = !toSapling; - noSproutAddrs = noSproutAddrs && toSapling; - - containsSproutOutput |= toSprout; - containsSaplingOutput |= toSapling; - - // Sending to both Sprout and Sapling is currently unsupported using z_sendmany - if (containsSproutOutput && containsSaplingOutput) { - throw JSONRPCError( - RPC_INVALID_PARAMETER, - "Cannot send to both Sprout and Sapling addresses using z_sendmany"); - } - if ( GetTime() > KOMODO_SAPLING_DEADLINE ) - { - if ( fromSprout || toSprout ) - throw JSONRPCError(RPC_INVALID_PARAMETER,"Sprout usage has expired"); - } - if ( toSapling && ASSETCHAINS_SYMBOL[0] == 0 ) - throw JSONRPCError(RPC_INVALID_PARAMETER,"Sprout usage will expire soon"); - - // If we are sending from a shielded address, all recipient - // shielded addresses must be of the same type. - if ((fromSprout && toSapling) || (fromSapling && toSprout)) { - throw JSONRPCError( - RPC_INVALID_PARAMETER, - "Cannot send between Sprout and Sapling addresses using z_sendmany"); - } } else { throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, unknown address format: ")+address ); } @@ -4915,9 +4872,7 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) // Builder (used if Sapling addresses are involved) boost::optional builder; - if (noSproutAddrs) { - builder = TransactionBuilder(Params().GetConsensus(), nextBlockHeight, pwalletMain); - } + builder = TransactionBuilder(Params().GetConsensus(), nextBlockHeight, pwalletMain); // Contextual transaction we will build on // (used if no Sapling addresses are involved) @@ -5190,11 +5145,11 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp return NullUniValue; string enableArg = "zmergetoaddress"; - auto fEnableMergeToAddress = fExperimentalMode && GetBoolArg("-" + enableArg, true); - std::string strDisabledMsg = ""; - if (!fEnableMergeToAddress) { - strDisabledMsg = experimentalDisabledHelpMsg("z_mergetoaddress", enableArg); - } + //auto fEnableMergeToAddress = fExperimentalMode && GetBoolArg("-" + enableArg, true); + //std::string strDisabledMsg = ""; + //if (!fEnableMergeToAddress) { + // strDisabledMsg = experimentalDisabledHelpMsg("z_mergetoaddress", enableArg); + //} if (fHelp || params.size() < 2 || params.size() > 7) throw runtime_error( @@ -5256,7 +5211,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp THROW_IF_SYNCING(KOMODO_INSYNC); bool useAnyUTXO = false; - bool useAnySprout = false; bool useAnySapling = false; std::set taddrs = {}; std::set zaddrs = {}; @@ -5277,8 +5231,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp if (address == "ANY_TADDR") { useAnyUTXO = true; - } else if (address == "ANY_SPROUT") { - useAnySprout = true; } else if (address == "ANY_SAPLING") { useAnySapling = true; } else { @@ -5303,8 +5255,8 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp if (useAnyUTXO && taddrs.size() > 0) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot specify specific t-addrs when using \"ANY_TADDR\""); } - if ((useAnySprout || useAnySapling) && zaddrs.size() > 0) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot specify specific z-addrs when using \"ANY_SPROUT\" or \"ANY_SAPLING\""); + if ((useAnySapling) && zaddrs.size() > 0) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot specify specific z-addrs when using \"ANY_SAPLING\""); } const int nextBlockHeight = chainActive.Height() + 1; @@ -5313,7 +5265,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp // Validate the destination address auto destaddress = params[1].get_str(); - bool isToSproutZaddr = false; bool isToSaplingZaddr = false; CTxDestination taddr = DecodeDestination(destaddress); if (!IsValidDestination(taddr)) { @@ -5326,7 +5277,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, Sapling has not activated"); } } else { - isToSproutZaddr = true; + throw JSONRPCError(RPC_INVALID_PARAMETER, "Only Sapling zaddrs allowed!"); } } else { throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, unknown address format: ") + destaddress ); @@ -5351,14 +5302,12 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp } } - int sproutNoteLimit = MERGE_TO_ADDRESS_DEFAULT_SPROUT_LIMIT; int saplingNoteLimit = MERGE_TO_ADDRESS_DEFAULT_SAPLING_LIMIT; if (params.size() > 4) { int nNoteLimit = params[4].get_int(); if (nNoteLimit < 0) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Limit on maximum number of notes cannot be negative"); } - sproutNoteLimit = nNoteLimit; saplingNoteLimit = nNoteLimit; } @@ -5375,7 +5324,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp std::string memo; if (params.size() > 6) { memo = params[6].get_str(); - if (!(isToSproutZaddr || isToSaplingZaddr)) { + if (!isToSaplingZaddr) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Memo can not be used with a taddr. It can only be used with a zaddr."); } else if (!IsHex(memo)) { throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected memo data in hexadecimal format."); @@ -5389,7 +5338,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp // Prepare to get UTXOs and notes std::vector utxoInputs; - std::vector sproutNoteInputs; std::vector saplingNoteInputs; CAmount mergedUTXOValue = 0; CAmount mergedNoteValue = 0; @@ -5403,9 +5351,8 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp unsigned int max_tx_size = saplingActive ? MAX_TX_SIZE_AFTER_SAPLING : MAX_TX_SIZE_BEFORE_SAPLING; size_t estimatedTxSize = 200; // tx overhead + wiggle room - if (isToSproutZaddr) { - estimatedTxSize += JOINSPLIT_SIZE; - } else if (isToSaplingZaddr) { + + if (isToSaplingZaddr) { estimatedTxSize += OUTPUTDESCRIPTION_SIZE; } @@ -5463,29 +5410,10 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp } } - if (useAnySprout || useAnySapling || zaddrs.size() > 0) { + if (useAnySapling || zaddrs.size() > 0) { // Get available notes - std::vector sproutEntries; - //std::vector saplingEntries; - //pwalletMain->GetFilteredNotes(sproutEntries, saplingEntries, zaddrs); - std::vector saplingEntries,skipsapling; - pwalletMain->GetFilteredNotes(sproutEntries, useAnySprout == 0 ? saplingEntries : skipsapling, zaddrs); - // If Sapling is not active, do not allow sending from a sapling addresses. - if (!saplingActive && saplingEntries.size() > 0) { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, Sapling has not activated"); - } - // Sending from both Sprout and Sapling is currently unsupported using z_mergetoaddress - if (sproutEntries.size() > 0 && saplingEntries.size() > 0) { - throw JSONRPCError( - RPC_INVALID_PARAMETER, - "Cannot send from both Sprout and Sapling addresses using z_mergetoaddress"); - } - // If sending between shielded addresses, they must be the same type - if ((saplingEntries.size() > 0 && isToSproutZaddr) || (sproutEntries.size() > 0 && isToSaplingZaddr)) { - throw JSONRPCError( - RPC_INVALID_PARAMETER, - "Cannot send between Sprout and Sapling addresses using z_mergetoaddress"); - } + std::vector saplingEntries; + pwalletMain->GetFilteredNotes(saplingEntries, zaddrs); for (const SaplingNoteEntry& entry : saplingEntries) { noteCounter++; @@ -5514,7 +5442,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp } size_t numUtxos = utxoInputs.size(); - size_t numNotes = sproutNoteInputs.size() + saplingNoteInputs.size(); + size_t numNotes = saplingNoteInputs.size(); //fprintf(stderr, "num utxos.%li\n", numUtxos); if (numUtxos < 2 && numNotes == 0) { @@ -5552,22 +5480,19 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp CMutableTransaction contextualTx = CreateNewContextualCMutableTransaction( Params().GetConsensus(), nextBlockHeight); - bool isSproutShielded = sproutNoteInputs.size() > 0 || isToSproutZaddr; - if (contextualTx.nVersion == 1 && isSproutShielded) { - contextualTx.nVersion = 2; // Tx format should support vjoinsplit - } // Builder (used if Sapling addresses are involved) boost::optional builder; if (isToSaplingZaddr || saplingNoteInputs.size() > 0) { builder = TransactionBuilder(Params().GetConsensus(), nextBlockHeight, pwalletMain); - } else + } else { contextualTx.nExpiryHeight = 0; // set non z-tx to have no expiry height. + } // Create operation and add to global queue std::shared_ptr q = getAsyncRPCQueue(); std::shared_ptr operation( - new AsyncRPCOperation_mergetoaddress(builder, contextualTx, utxoInputs, sproutNoteInputs, saplingNoteInputs, recipient, nFee, contextInfo) ); + new AsyncRPCOperation_mergetoaddress(builder, contextualTx, utxoInputs, saplingNoteInputs, recipient, nFee, contextInfo) ); q->addOperation(operation); AsyncRPCOperationId operationId = operation->getId(); From f13171efc69f907c631255b5438ebdcd48c04e95 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 6 Jun 2020 05:14:21 -0400 Subject: [PATCH 058/255] desprout --- src/init.cpp | 6 +++--- src/init.h | 4 ++-- src/main.cpp | 9 --------- src/metrics.cpp | 2 +- src/wallet/asyncrpcoperation_sendmany.cpp | 3 --- src/wallet/rpcwallet.cpp | 10 ++-------- src/wallet/wallet.cpp | 4 +--- 7 files changed, 9 insertions(+), 29 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 32cefbe91..7d9733372 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -101,7 +101,7 @@ extern int32_t KOMODO_SNAPSHOT_INTERVAL; extern void komodo_init(int32_t height); -ZCJoinSplit* pzcashParams = NULL; +//ZCJoinSplit* pzcashParams = NULL; #ifdef ENABLE_WALLET CWallet* pwalletMain = NULL; @@ -305,8 +305,8 @@ void Shutdown() delete pwalletMain; pwalletMain = NULL; #endif - delete pzcashParams; - pzcashParams = NULL; + //delete pzcashParams; + //pzcashParams = NULL; globalVerifyHandle.reset(); ECC_Stop(); LogPrintf("%s: done\n", __func__); diff --git a/src/init.h b/src/init.h index 108339865..c68d59419 100644 --- a/src/init.h +++ b/src/init.h @@ -23,7 +23,7 @@ #include -#include "zcash/JoinSplit.hpp" +//#include "zcash/JoinSplit.hpp" class CScheduler; class CWallet; @@ -34,7 +34,7 @@ class thread_group; } // namespace boost extern CWallet* pwalletMain; -extern ZCJoinSplit* pzcashParams; +//extern ZCJoinSplit* pzcashParams; void StartShutdown(); bool ShutdownRequested(); diff --git a/src/main.cpp b/src/main.cpp index f31847b04..c2e9c5bfb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1367,15 +1367,6 @@ bool CheckTransaction(uint32_t tiptime,const CTransaction& tx, CValidationState if (!CheckTransactionWithoutProofVerification(tiptime,tx, state)) { return false; - } else { - // Ensure that zk-SNARKs v|| y - BOOST_FOREACH(const JSDescription &joinsplit, tx.vjoinsplit) { - if (!joinsplit.Verify(*pzcashParams, verifier, tx.joinSplitPubKey)) { - return state.DoS(100, error("CheckTransaction(): joinsplit does not verify"), - REJECT_INVALID, "bad-txns-joinsplit-verification-failed"); - } - } - return true; } } diff --git a/src/metrics.cpp b/src/metrics.cpp index ff0863a19..adbef02f2 100644 --- a/src/metrics.cpp +++ b/src/metrics.cpp @@ -288,7 +288,7 @@ int printMiningStatus(bool mining) } else if (IsInitialBlockDownload()) { std::cout << _("Mining is paused while downloading blocks.") << std::endl; } else { - std::cout << _("Mining is paused (a JoinSplit may be in progress).") << std::endl; + std::cout << _("Mining is paused, enhance your calm") << std::endl; } } lines++; diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index 9e82e41db..1b709b142 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -140,9 +140,6 @@ AsyncRPCOperation_sendmany::AsyncRPCOperation_sendmany( } else { LogPrint("zrpc", "%s: z_sendmany initialized\n", getId()); } - - // Enable payment disclosure if requested - paymentDisclosureMode = false; } AsyncRPCOperation_sendmany::~AsyncRPCOperation_sendmany() { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index b65e6a839..66ab58f47 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5135,7 +5135,6 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp, const CPubKey& myp #define MERGE_TO_ADDRESS_DEFAULT_SPROUT_LIMIT 10 #define MERGE_TO_ADDRESS_DEFAULT_SAPLING_LIMIT 90 -#define JOINSPLIT_SIZE GetSerializeSize(JSDescription(), SER_NETWORK, PROTOCOL_VERSION) #define OUTPUTDESCRIPTION_SIZE GetSerializeSize(OutputDescription(), SER_NETWORK, PROTOCOL_VERSION) #define SPENDDESCRIPTION_SIZE GetSerializeSize(SpendDescription(), SER_NETWORK, PROTOCOL_VERSION) @@ -5154,7 +5153,6 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp if (fHelp || params.size() < 2 || params.size() > 7) throw runtime_error( "z_mergetoaddress [\"fromaddress\", ... ] \"toaddress\" ( fee ) ( transparent_limit ) ( shielded_limit ) ( memo )\n" - + strDisabledMsg + "\nMerge multiple UTXOs and notes into a single UTXO or note. Coinbase UTXOs are ignored; use `z_shieldcoinbase`" "\nto combine those into a single note." "\n\nThis is an asynchronous operation, and UTXOs selected for merging will be locked. If there is an error, they" @@ -5198,14 +5196,10 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp " \"opid\": xxx (string) An operationid to pass to z_getoperationstatus to get the result of the operation.\n" "}\n" "\nExamples:\n" - + HelpExampleCli("z_mergetoaddress", "'[\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\"]' ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf") - + HelpExampleRpc("z_mergetoaddress", "[\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\"], \"ztfaW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf\"") + + HelpExampleCli("z_mergetoaddress", "'[\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\"]' zs1aW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf") + + HelpExampleRpc("z_mergetoaddress", "[\"RD6GgnrMpPaTSMn8vai6yiGA7mN4QGPV\"], \"zs1aW34Gj9FrnGUEf833ywDVL62NWXBM81u6EQnM6VR45eYnXhwztecW1SjxA7JrmAXKJhxhj3vDNEpVCQoSvVoSpmbhtjf\"") ); - if (!fEnableMergeToAddress) { - throw JSONRPCError(RPC_WALLET_ERROR, "Error: z_mergetoaddress is disabled."); - } - LOCK2(cs_main, pwalletMain->cs_wallet); THROW_IF_SYNCING(KOMODO_INSYNC); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index a346a547f..725f04764 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -4781,7 +4781,6 @@ bool CMerkleTx::AcceptToMemoryPool(bool fLimitFree, bool fRejectAbsurdFee) * These notes are decrypted and added to the output parameter vector, outEntries. */ void CWallet::GetFilteredNotes( - std::vector& sproutEntries, std::vector& saplingEntries, std::string address, int minDepth, @@ -4794,7 +4793,7 @@ void CWallet::GetFilteredNotes( filterAddresses.insert(DecodePaymentAddress(address)); } - GetFilteredNotes(sproutEntries, saplingEntries, filterAddresses, minDepth, INT_MAX, ignoreSpent, requireSpendingKey); + GetFilteredNotes(saplingEntries, filterAddresses, minDepth, INT_MAX, ignoreSpent, requireSpendingKey); } /** @@ -4803,7 +4802,6 @@ void CWallet::GetFilteredNotes( * These notes are decrypted and added to the output parameter vector, outEntries. */ void CWallet::GetFilteredNotes( - std::vector& sproutEntries, std::vector& saplingEntries, std::set& filterAddresses, int minDepth, From b5a0d3b8b7dab495cc67c02758fe4e7621586eba Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 6 Jun 2020 14:11:30 -0400 Subject: [PATCH 059/255] desprout --- src/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.cpp b/src/main.cpp index c2e9c5bfb..2532dd2b1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1368,6 +1368,7 @@ bool CheckTransaction(uint32_t tiptime,const CTransaction& tx, CValidationState if (!CheckTransactionWithoutProofVerification(tiptime,tx, state)) { return false; } + return true; } int32_t komodo_isnotaryvout(char *coinaddr,uint32_t tiptime) // from ac_private chains only From dd95b1471cefc19501631fc84875b5a919105e1f Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 6 Jun 2020 14:48:16 -0400 Subject: [PATCH 060/255] desprout --- src/coins.cpp | 33 ++-------------------- src/coins.h | 5 ---- src/main.cpp | 12 ++++---- src/rpc/blockchain.cpp | 7 +++-- src/txmempool.cpp | 4 ++- src/validationinterface.cpp | 4 ++- src/wallet/wallet.cpp | 55 ++----------------------------------- 7 files changed, 22 insertions(+), 98 deletions(-) diff --git a/src/coins.cpp b/src/coins.cpp index 602d153ec..03b046a70 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers -// Copyright (c) 2019 The Hush developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -65,7 +65,6 @@ bool CCoins::Spend(uint32_t nPos) Cleanup(); return true; } -bool CCoinsView::GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const { return false; } bool CCoinsView::GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const { return false; } bool CCoinsView::GetNullifier(const uint256 &nullifier, ShieldedType type) const { return false; } bool CCoinsView::GetCoins(const uint256 &txid, CCoins &coins) const { return false; } @@ -85,7 +84,6 @@ bool CCoinsView::GetStats(CCoinsStats &stats) const { return false; } CCoinsViewBacked::CCoinsViewBacked(CCoinsView *viewIn) : base(viewIn) { } -bool CCoinsViewBacked::GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const { return base->GetSproutAnchorAt(rt, tree); } bool CCoinsViewBacked::GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const { return base->GetSaplingAnchorAt(rt, tree); } bool CCoinsViewBacked::GetNullifier(const uint256 &nullifier, ShieldedType type) const { return base->GetNullifier(nullifier, type); } bool CCoinsViewBacked::GetCoins(const uint256 &txid, CCoins &coins) const { return base->GetCoins(txid, coins); } @@ -139,30 +137,6 @@ CCoinsMap::const_iterator CCoinsViewCache::FetchCoins(const uint256 &txid) const return ret; } - -bool CCoinsViewCache::GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const { - CAnchorsSproutMap::const_iterator it = cacheSproutAnchors.find(rt); - if (it != cacheSproutAnchors.end()) { - if (it->second.entered) { - tree = it->second.tree; - return true; - } else { - return false; - } - } - - if (!base->GetSproutAnchorAt(rt, tree)) { - return false; - } - - CAnchorsSproutMap::iterator ret = cacheSproutAnchors.insert(std::make_pair(rt, CAnchorsSproutCacheEntry())).first; - ret->second.entered = true; - ret->second.tree = tree; - cachedCoinsUsage += ret->second.tree.DynamicMemoryUsage(); - - return true; -} - bool CCoinsViewCache::GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const { CAnchorsSaplingMap::const_iterator it = cacheSaplingAnchors.find(rt); if (it != cacheSaplingAnchors.end()) { @@ -271,7 +245,6 @@ void CCoinsViewCache::BringBestAnchorIntoCache( SproutMerkleTree &tree ) { - assert(GetSproutAnchorAt(currentRoot, tree)); } template<> @@ -550,9 +523,9 @@ bool CCoinsViewCache::BatchWrite(CCoinsMap &mapCoins, bool CCoinsViewCache::Flush() { bool fOk = base->BatchWrite(cacheCoins, hashBlock, hashSproutAnchor, hashSaplingAnchor, cacheSproutAnchors, cacheSaplingAnchors, cacheSproutNullifiers, cacheSaplingNullifiers); cacheCoins.clear(); - cacheSproutAnchors.clear(); + //cacheSproutAnchors.clear(); cacheSaplingAnchors.clear(); - cacheSproutNullifiers.clear(); + //cacheSproutNullifiers.clear(); cacheSaplingNullifiers.clear(); cachedCoinsUsage = 0; return fOk; diff --git a/src/coins.h b/src/coins.h index 1211e7e07..3e8f674fb 100644 --- a/src/coins.h +++ b/src/coins.h @@ -372,9 +372,6 @@ struct CCoinsStats class CCoinsView { public: - //! Retrieve the tree (Sprout) at a particular anchored root in the chain - virtual bool GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const; - //! Retrieve the tree (Sapling) at a particular anchored root in the chain virtual bool GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const; @@ -421,7 +418,6 @@ protected: public: CCoinsViewBacked(CCoinsView *viewIn); - bool GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const; bool GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const; bool GetNullifier(const uint256 &nullifier, ShieldedType type) const; bool GetCoins(const uint256 &txid, CCoins &coins) const; @@ -493,7 +489,6 @@ public: CNullifiersMap getNullifiers(); // Standard CCoinsView methods - bool GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const; bool GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const; bool GetNullifier(const uint256 &nullifier, ShieldedType type) const; bool GetCoins(const uint256 &txid, CCoins &coins) const; diff --git a/src/main.cpp b/src/main.cpp index 2532dd2b1..6ca7b68a2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3493,13 +3493,13 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin // This should never fail: we should always be able to get the root // that is on the tip of our chain - assert(view.GetSproutAnchorAt(old_sprout_tree_root, sprout_tree)); + //assert(view.GetSproutAnchorAt(old_sprout_tree_root, sprout_tree)); - { + //{ // Consistency check: the root of the tree we're given should // match what we asked for. - assert(sprout_tree.root() == old_sprout_tree_root); - } + //assert(sprout_tree.root() == old_sprout_tree_root); + //} SaplingMerkleTree sapling_tree; assert(view.GetSaplingAnchorAt(view.GetBestAnchor(SAPLING), sapling_tree)); @@ -3636,6 +3636,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin } UpdateCoins(tx, view, i == 0 ? undoDummy : blockundo.vtxundo.back(), pindex->GetHeight()); + /* BOOST_FOREACH(const JSDescription &joinsplit, tx.vjoinsplit) { BOOST_FOREACH(const uint256 ¬e_commitment, joinsplit.commitments) { // Insert the note commitments into our temporary tree. @@ -3643,6 +3644,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin sprout_tree.append(note_commitment); } } + */ BOOST_FOREACH(const OutputDescription &outputDescription, tx.vShieldedOutput) { sapling_tree.append(outputDescription.cm); @@ -3652,7 +3654,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin pos.nTxOffset += ::GetSerializeSize(tx, SER_DISK, CLIENT_VERSION); } - view.PushAnchor(sprout_tree); + //view.PushAnchor(sprout_tree); view.PushAnchor(sapling_tree); if (!fJustCheck) { pindex->hashFinalSproutRoot = sprout_tree.root(); diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 76375b80c..faed5b957 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1668,9 +1668,10 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp, const CPubKey& my obj.push_back(Pair("chainwork", chainActive.LastTip()->chainPower.chainWork.GetHex())); obj.push_back(Pair("pruned", fPruneMode)); - SproutMerkleTree tree; - pcoinsTip->GetSproutAnchorAt(pcoinsTip->GetBestAnchor(SPROUT), tree); - obj.push_back(Pair("commitments", static_cast(tree.size()))); + //SproutMerkleTree tree; + //pcoinsTip->GetSproutAnchorAt(pcoinsTip->GetBestAnchor(SPROUT), tree); + //obj.push_back(Pair("commitments", static_cast(tree.size()))); + obj.push_back(Pair("commitments", 0)); CBlockIndex* tip = chainActive.LastTip(); UniValue valuePools(UniValue::VARR); diff --git a/src/txmempool.cpp b/src/txmempool.cpp index ca0ed7f51..2f10856d4 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -644,8 +644,9 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const i++; } - boost::unordered_map intermediates; + /* + boost::unordered_map intermediates; BOOST_FOREACH(const JSDescription &joinsplit, tx.vjoinsplit) { BOOST_FOREACH(const uint256 &nf, joinsplit.nullifiers) { assert(!pcoins->GetNullifier(nf, SPROUT)); @@ -666,6 +667,7 @@ void CTxMemPool::check(const CCoinsViewCache *pcoins) const intermediates.insert(std::make_pair(tree.root(), tree)); } + */ for (const SpendDescription &spendDescription : tx.vShieldedSpend) { SaplingMerkleTree tree; diff --git a/src/validationinterface.cpp b/src/validationinterface.cpp index 799a60ceb..44b5115d6 100644 --- a/src/validationinterface.cpp +++ b/src/validationinterface.cpp @@ -1,5 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or https://www.opensource.org/licenses/mit-license.php . @@ -138,7 +139,8 @@ void ThreadNotifyWallets(CBlockIndex *pindexLastTip) while (pindex && pindex != pindexFork) { // Get the Sprout commitment tree as of the start of this block. SproutMerkleTree oldSproutTree; - assert(pcoinsTip->GetSproutAnchorAt(pindex->hashSproutAnchor, oldSproutTree)); + //TODO: how important is oldSproutTree ? + //assert(pcoinsTip->GetSproutAnchorAt(pindex->hashSproutAnchor, oldSproutTree)); // Get the Sapling commitment tree as of the start of this block. // We can get this from the `hashFinalSaplingRoot` of the last block diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 725f04764..b492ee8a2 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2334,57 +2334,6 @@ void CWallet::WitnessNoteCommitment(std::vector commitments, std::vector>& witnesses, uint256 &final_anchor) { - witnesses.resize(commitments.size()); - CBlockIndex* pindex = chainActive.Genesis(); - SproutMerkleTree tree; - - while (pindex) { - CBlock block; - ReadBlockFromDisk(block, pindex,1); - - BOOST_FOREACH(const CTransaction& tx, block.vtx) - { - BOOST_FOREACH(const JSDescription& jsdesc, tx.vjoinsplit) - { - BOOST_FOREACH(const uint256 ¬e_commitment, jsdesc.commitments) - { - tree.append(note_commitment); - - BOOST_FOREACH(boost::optional& wit, witnesses) { - if (wit) { - wit->append(note_commitment); - } - } - - size_t i = 0; - BOOST_FOREACH(uint256& commitment, commitments) { - if (note_commitment == commitment) { - witnesses.at(i) = tree.witness(); - } - i++; - } - } - } - } - - uint256 current_anchor = tree.root(); - - // Consistency check: we should be able to find the current tree - // in our CCoins view. - SproutMerkleTree dummy_tree; - assert(pcoinsTip->GetSproutAnchorAt(current_anchor, dummy_tree)); - - pindex = chainActive.Next(pindex); - } - - // TODO: #93; Select a root via some heuristic. - final_anchor = tree.root(); - - BOOST_FOREACH(boost::optional& wit, witnesses) { - if (wit) { - assert(final_anchor == wit->root()); - } - } } /** @@ -2697,11 +2646,11 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) } } - SproutMerkleTree sproutTree; + //SproutMerkleTree sproutTree; SaplingMerkleTree saplingTree; // This should never fail: we should always be able to get the tree // state on the path to the tip of our chain - assert(pcoinsTip->GetSproutAnchorAt(pindex->hashSproutAnchor, sproutTree)); + //assert(pcoinsTip->GetSproutAnchorAt(pindex->hashSproutAnchor, sproutTree)); if (pindex->pprev) { if (NetworkUpgradeActive(pindex->pprev->GetHeight(), Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) { assert(pcoinsTip->GetSaplingAnchorAt(pindex->pprev->hashFinalSaplingRoot, saplingTree)); From 0eec14fb01c6b5200398fe4262f8f42e55587438 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 6 Jun 2020 20:28:02 -0400 Subject: [PATCH 061/255] desprout --- src/transaction_builder.cpp | 1 - src/transaction_builder.h | 1 + src/txdb.h | 2 +- src/zcash/IncrementalMerkleTree.cpp | 2 ++ src/zcash/IncrementalMerkleTree.hpp | 2 ++ src/zcash/JoinSplit.hpp | 2 ++ src/zcash/Proof.cpp | 2 ++ src/zcash/Proof.hpp | 2 ++ src/zcash/prf.cpp | 2 ++ src/zcash/util.cpp | 2 ++ src/zcash/zip32.cpp | 1 + 11 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/transaction_builder.cpp b/src/transaction_builder.cpp index 8b1acaca9..d821a266f 100644 --- a/src/transaction_builder.cpp +++ b/src/transaction_builder.cpp @@ -1,6 +1,5 @@ // Copyright (c) 2018 The Zcash developers // Copyright (c) 2019-2020 The Hush developers -// Released under the GPLv3 // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/transaction_builder.h b/src/transaction_builder.h index 49c09294d..39225433a 100644 --- a/src/transaction_builder.h +++ b/src/transaction_builder.h @@ -1,4 +1,5 @@ // Copyright (c) 2018 The Zcash developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/txdb.h b/src/txdb.h index e089d0190..81c0bb3ad 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -63,7 +63,7 @@ protected: public: CCoinsViewDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false); - bool GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const; + //bool GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const; bool GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const; bool GetNullifier(const uint256 &nf, ShieldedType type) const; bool GetCoins(const uint256 &txid, CCoins &coins) const; diff --git a/src/zcash/IncrementalMerkleTree.cpp b/src/zcash/IncrementalMerkleTree.cpp index b8b3cd183..4d3ff8c2b 100644 --- a/src/zcash/IncrementalMerkleTree.cpp +++ b/src/zcash/IncrementalMerkleTree.cpp @@ -1,3 +1,5 @@ +// Copyright (c) 2019-2020 The Hush developers + #include #include diff --git a/src/zcash/IncrementalMerkleTree.hpp b/src/zcash/IncrementalMerkleTree.hpp index 1ebb2b499..ab55e8ad4 100644 --- a/src/zcash/IncrementalMerkleTree.hpp +++ b/src/zcash/IncrementalMerkleTree.hpp @@ -1,3 +1,5 @@ +// Copyright (c) 2019-2020 The Hush developers + #ifndef ZC_INCREMENTALMERKLETREE_H_ #define ZC_INCREMENTALMERKLETREE_H_ diff --git a/src/zcash/JoinSplit.hpp b/src/zcash/JoinSplit.hpp index 27df05db0..e7aded3c1 100644 --- a/src/zcash/JoinSplit.hpp +++ b/src/zcash/JoinSplit.hpp @@ -1,3 +1,5 @@ +// Copyright (c) 2019-2020 The Hush developers + #ifndef ZC_JOINSPLIT_H_ #define ZC_JOINSPLIT_H_ diff --git a/src/zcash/Proof.cpp b/src/zcash/Proof.cpp index 7ab1298a8..1a0ebfe75 100644 --- a/src/zcash/Proof.cpp +++ b/src/zcash/Proof.cpp @@ -1,3 +1,5 @@ +// Copyright (c) 2019-2020 The Hush developers + #include "Proof.hpp" #include "crypto/common.h" diff --git a/src/zcash/Proof.hpp b/src/zcash/Proof.hpp index 7c9b7f7f5..0a3d0bb14 100644 --- a/src/zcash/Proof.hpp +++ b/src/zcash/Proof.hpp @@ -1,3 +1,5 @@ +// Copyright (c) 2019-2020 The Hush developers + #ifndef ZC_PROOF_H_ #define ZC_PROOF_H_ diff --git a/src/zcash/prf.cpp b/src/zcash/prf.cpp index 2491de83e..9ab3d0f10 100644 --- a/src/zcash/prf.cpp +++ b/src/zcash/prf.cpp @@ -1,3 +1,5 @@ +// Copyright (c) 2019-2020 The Hush developers + #include "prf.h" #include "crypto/sha256.h" #include "hash.h" diff --git a/src/zcash/util.cpp b/src/zcash/util.cpp index 6f32bf79a..064e1cca9 100644 --- a/src/zcash/util.cpp +++ b/src/zcash/util.cpp @@ -1,3 +1,5 @@ +// Copyright (c) 2019-2020 The Hush developers + #include "zcash/util.h" #include #include diff --git a/src/zcash/zip32.cpp b/src/zcash/zip32.cpp index 15478843e..615c5896d 100644 --- a/src/zcash/zip32.cpp +++ b/src/zcash/zip32.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2018 The Zcash developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. From f725a8362c138e3e75085c47788feefb1fe7db2e Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 6 Jun 2020 23:17:49 -0400 Subject: [PATCH 062/255] desprout --- src/timedata.cpp | 1 + src/timedata.h | 1 + src/torcontrol.cpp | 1 + src/torcontrol.h | 1 + src/transaction_builder.cpp | 1 - 5 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/timedata.cpp b/src/timedata.cpp index 584e0db8c..64a3955ff 100644 --- a/src/timedata.cpp +++ b/src/timedata.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/timedata.h b/src/timedata.h index 2296baf11..13cff12b3 100644 --- a/src/timedata.h +++ b/src/timedata.h @@ -1,4 +1,5 @@ // Copyright (c) 2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp index 99c76995b..c2eb490da 100644 --- a/src/torcontrol.cpp +++ b/src/torcontrol.cpp @@ -1,5 +1,6 @@ // Copyright (c) 2015-2017 The Bitcoin Core developers // Copyright (c) 2017 The Zcash developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/torcontrol.h b/src/torcontrol.h index 72dc82c5b..44611c7b6 100644 --- a/src/torcontrol.h +++ b/src/torcontrol.h @@ -1,4 +1,5 @@ // Copyright (c) 2015 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/transaction_builder.cpp b/src/transaction_builder.cpp index d821a266f..08953ee02 100644 --- a/src/transaction_builder.cpp +++ b/src/transaction_builder.cpp @@ -1,6 +1,5 @@ // Copyright (c) 2018 The Zcash developers // Copyright (c) 2019-2020 The Hush developers - // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. From 0c118eb129f06ec6a9ff5ca9750b75b3417a8a2d Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 7 Jun 2020 00:04:15 -0400 Subject: [PATCH 063/255] delete --- src/Makefile.am | 2 -- src/komodo_bitcoind.h | 2 +- src/primitives/block.h | 2 +- src/primitives/nonce.cpp | 24 ------------------------ src/primitives/nonce.h | 29 ----------------------------- src/test/transaction_tests.cpp | 1 + 6 files changed, 3 insertions(+), 57 deletions(-) delete mode 100644 src/primitives/nonce.cpp delete mode 100644 src/primitives/nonce.h diff --git a/src/Makefile.am b/src/Makefile.am index ab04c24bc..a1cae78a2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -427,7 +427,6 @@ libbitcoin_common_a_SOURCES = \ metrics.cpp \ primitives/block.cpp \ primitives/transaction.cpp \ - primitives/nonce.cpp \ protocol.cpp \ pubkey.cpp \ scheduler.cpp \ @@ -652,7 +651,6 @@ libzcashconsensus_la_SOURCES = \ crypto/sha512.cpp \ hash.cpp \ primitives/transaction.cpp \ - primitives/nonce.cpp \ pubkey.cpp \ script/zcashconsensus.cpp \ script/interpreter.cpp \ diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 39cf5da63..e1748c191 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -20,7 +20,7 @@ #include #include #include "consensus/params.h" -#include "primitives/nonce.h" +//#include "primitives/nonce.h" #include "komodo_defs.h" #include "script/standard.h" #include "cc/CCinclude.h" diff --git a/src/primitives/block.h b/src/primitives/block.h index a2d0ba708..9a6ddf100 100644 --- a/src/primitives/block.h +++ b/src/primitives/block.h @@ -23,7 +23,7 @@ #define BITCOIN_PRIMITIVES_BLOCK_H #include "primitives/transaction.h" -#include "primitives/nonce.h" +//#include "primitives/nonce.h" #include "serialize.h" #include "uint256.h" #include "arith_uint256.h" diff --git a/src/primitives/nonce.cpp b/src/primitives/nonce.cpp deleted file mode 100644 index a1fbd667d..000000000 --- a/src/primitives/nonce.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2019 The Hush Developers -// Copyright (c) 2018 Michael Toutonghi -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -/****************************************************************************** - * Copyright © 2014-2019 The SuperNET Developers. * - * * - * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * - * the top-level directory of this distribution for the individual copyright * - * holder information and the developer policies on copyright and licensing. * - * * - * Unless otherwise agreed in a custom licensing agreement, no part of the * - * SuperNET software, including this file may be copied, modified, propagated * - * or distributed except according to the terms contained in the LICENSE file * - * * - * Removal or modification of this copyright notice is prohibited. * - * * - ******************************************************************************/ - -#include "hash.h" -#include "nonce.h" -#include - diff --git a/src/primitives/nonce.h b/src/primitives/nonce.h deleted file mode 100644 index b17a9f01b..000000000 --- a/src/primitives/nonce.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2019 Hush Developers -// Copyright (c) 2018 Michael Toutonghi -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -/****************************************************************************** - * Copyright © 2014-2019 The SuperNET Developers. * - * * - * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * - * the top-level directory of this distribution for the individual copyright * - * holder information and the developer policies on copyright and licensing. * - * * - * Unless otherwise agreed in a custom licensing agreement, no part of the * - * SuperNET software, including this file may be copied, modified, propagated * - * or distributed except according to the terms contained in the LICENSE file * - * * - * Removal or modification of this copyright notice is prohibited. * - * * - ******************************************************************************/ - -#ifndef BITCOIN_PRIMITIVES_NONCE_H -#define BITCOIN_PRIMITIVES_NONCE_H - -#include "serialize.h" -#include "uint256.h" -#include "arith_uint256.h" - - -#endif // BITCOIN_PRIMITIVES_NONCE_H diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index b6a6ebc26..eb948f92d 100644 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -1,3 +1,4 @@ +// Copyright (c) 2019-2020 The Hush developers // Copyright (c) 2011-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. From b0ea67d5bea4e4692a9567a2f8dc7d41e1c89ec9 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 7 Jun 2020 16:10:49 -0400 Subject: [PATCH 064/255] desprout --- src/Makefile.am | 11 +++++------ src/primitives/transaction.h | 1 + src/transaction_builder.cpp | 1 + src/wallet/rpchushwallet.cpp | 2 +- src/zcash/Note.cpp | 31 ------------------------------- 5 files changed, 8 insertions(+), 38 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index a1cae78a2..ec3f562f2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,3 +1,5 @@ +# Copyright 2019-2020 The Hush developers + DIST_SUBDIRS = secp256k1 univalue cryptoconditions AM_LDFLAGS = $(PTHREAD_CFLAGS) $(LIBTOOL_LDFLAGS) $(SAN_LDFLAGS) $(HARDENED_LDFLAGS) @@ -186,7 +188,6 @@ BITCOIN_CORE_H = \ prevector.h \ primitives/block.h \ primitives/transaction.h \ - primitives/nonce.h \ protocol.h \ pubkey.h \ random.h \ @@ -486,7 +487,7 @@ libbitcoin_cli_a_SOURCES = \ nodist_libbitcoin_util_a_SOURCES = $(srcdir)/obj/build.h # -# bitcoind binary # +# komodod binary # komodod_SOURCES = bitcoind.cpp komodod_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) komodod_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) @@ -545,7 +546,7 @@ if TARGET_DARWIN komodod_LDFLAGS += -static-libgcc endif -# bitcoin-cli binary # +# komodo-cli binary # komodo_cli_SOURCES = bitcoin-cli.cpp komodo_cli_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS) komodo_cli_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) @@ -593,7 +594,7 @@ wallet_utility_LDADD = \ $(LIBCRYPTOCONDITIONS) endif -# zcash-tx binary # +# komodo-tx binary # komodo_tx_SOURCES = komodo-tx.cpp komodo_tx_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) komodo_tx_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) @@ -603,7 +604,6 @@ if TARGET_WINDOWS komodo_tx_SOURCES += bitcoin-tx-res.rc endif -# FIXME: Is libzcash needed for hush-tx ? komodo_tx_LDADD = \ $(LIBUNIVALUE) \ $(LIBBITCOIN_COMMON) \ @@ -615,7 +615,6 @@ komodo_tx_LDADD = \ $(LIBCRYPTOCONDITIONS) komodo_tx_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS) -# # zcash protocol primitives # libzcash_a_SOURCES = \ diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index 2ece7b255..7a46b9c00 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -44,6 +44,7 @@ #include "zcash/Zcash.h" #include "zcash/JoinSplit.hpp" #include "zcash/Proof.hpp" +#include "zcash/Note.hpp" extern uint32_t ASSETCHAINS_MAGIC; extern std::string ASSETCHAINS_SELFIMPORT; diff --git a/src/transaction_builder.cpp b/src/transaction_builder.cpp index 08953ee02..e1879e1d4 100644 --- a/src/transaction_builder.cpp +++ b/src/transaction_builder.cpp @@ -12,6 +12,7 @@ #include #include #include +#include "zcash/Note.hpp" SpendDescriptionInfo::SpendDescriptionInfo( libzcash::SaplingExpandedSpendingKey expsk, diff --git a/src/wallet/rpchushwallet.cpp b/src/wallet/rpchushwallet.cpp index 62b7a4fc9..64cd0e4a5 100644 --- a/src/wallet/rpchushwallet.cpp +++ b/src/wallet/rpchushwallet.cpp @@ -1,4 +1,4 @@ -// Copyright (c) 2020 The Hush developers +// Copyright (c) 2019-2020 The Hush developers // Copyright (c) 2019 Cryptoforge // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/zcash/Note.cpp b/src/zcash/Note.cpp index 9cd327d1b..e6d185a0e 100644 --- a/src/zcash/Note.cpp +++ b/src/zcash/Note.cpp @@ -13,37 +13,6 @@ using namespace libzcash; -/* -SproutNote::SproutNote() { - a_pk = random_uint256(); - rho = random_uint256(); - r = random_uint256(); -} - -uint256 SproutNote::cm() const { - unsigned char discriminant = 0xb0; - - CSHA256 hasher; - hasher.Write(&discriminant, 1); - hasher.Write(a_pk.begin(), 32); - - auto value_vec = convertIntToVectorLE(value_); - - hasher.Write(&value_vec[0], value_vec.size()); - hasher.Write(rho.begin(), 32); - hasher.Write(r.begin(), 32); - - uint256 result; - hasher.Finalize(result.begin()); - - return result; -} - -uint256 SproutNote::nullifier(const SproutSpendingKey& a_sk) const { - return PRF_nf(a_sk, rho); -} -*/ - // Construct and populate Sapling note for a given payment address and value. SaplingNote::SaplingNote(const SaplingPaymentAddress& address, const uint64_t value) : BaseNote(value) { d = address.d; From 0ca0637323d6da126d127feea4ce50c0df2efadd Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 7 Jun 2020 17:31:27 -0400 Subject: [PATCH 065/255] Use our mirror of boost, bintray is returning 403 currently --- depends/packages/boost.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk index 48c60710d..3112ca7be 100644 --- a/depends/packages/boost.mk +++ b/depends/packages/boost.mk @@ -1,7 +1,7 @@ package=boost $(package)_version=1_72_0 -$(package)_download_path=https://dl.bintray.com/boostorg/release/1.72.0/source/ +$(package)_download_path=https://github.com/MyHush/boost/releases/download/v1.72.0/ $(package)_sha256_hash=59c9b274bc451cf91a9ba1dd2c7fdcaf5d60b1b3aa83f2c9fa143417cc660722 $(package)_file_name=$(package)_$($(package)_version).tar.bz2 From 5a601d143196cf9dff7bc4a0beb28dbe890f8713 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 8 Jun 2020 11:13:17 -0400 Subject: [PATCH 066/255] desprout --- src/wallet/rpcwallet.cpp | 1 + src/wallet/wallet.cpp | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 66ab58f47..873d8eb87 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -38,6 +38,7 @@ #include "zcbenchmarks.h" #include "script/interpreter.h" #include "zcash/zip32.h" +#include "zcash/Note.hpp" #include "notaries_staked.h" #include "utiltime.h" diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index b492ee8a2..a7ca3d74d 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -346,6 +346,14 @@ bool CWallet::LoadSaplingPaymentAddress( return CCryptoKeyStore::AddSaplingIncomingViewingKey(ivk, addr); } +bool CWallet::AddCScript(const CScript& redeemScript) +{ + if (!CCryptoKeyStore::AddCScript(redeemScript)) + return false; + if (!fFileBacked) + return true; + return CWalletDB(strWalletFile).WriteCScript(Hash160(redeemScript), redeemScript); +} bool CWallet::LoadCScript(const CScript& redeemScript) { From f4dd9fe3bbd6b57cd55d5b638322028e54dba3e9 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 13 Jun 2020 08:50:52 -0400 Subject: [PATCH 067/255] desprout --- src/paymentdisclosure.cpp | 9 +++++++++ src/paymentdisclosure.h | 19 +++++++++++++++++++ src/paymentdisclosuredb.cpp | 11 +++++++++++ src/paymentdisclosuredb.h | 21 +++++++++++++++++++++ src/primitives/nonce.cpp | 24 ++++++++++++++++++++++++ src/primitives/nonce.h | 29 +++++++++++++++++++++++++++++ 6 files changed, 113 insertions(+) create mode 100644 src/paymentdisclosure.cpp create mode 100644 src/paymentdisclosure.h create mode 100644 src/paymentdisclosuredb.cpp create mode 100644 src/paymentdisclosuredb.h create mode 100644 src/primitives/nonce.cpp create mode 100644 src/primitives/nonce.h diff --git a/src/paymentdisclosure.cpp b/src/paymentdisclosure.cpp new file mode 100644 index 000000000..d442c40f6 --- /dev/null +++ b/src/paymentdisclosure.cpp @@ -0,0 +1,9 @@ +// Copyright (c) 2017 The Zcash developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "paymentdisclosure.h" + +#include "key_io.h" +#include "util.h" + diff --git a/src/paymentdisclosure.h b/src/paymentdisclosure.h new file mode 100644 index 000000000..9855e1de0 --- /dev/null +++ b/src/paymentdisclosure.h @@ -0,0 +1,19 @@ +#ifndef ZCASH_PAYMENTDISCLOSURE_H +#define ZCASH_PAYMENTDISCLOSURE_H + +#include "uint256.h" +#include "clientversion.h" +#include "serialize.h" +#include "streams.h" +#include "version.h" + +// For JSOutPoint +#include "wallet/wallet.h" + +#include +#include +#include + + +// Ensure that the two different protocol messages, payment disclosure blobs and transactions, +#endif // ZCASH_PAYMENTDISCLOSURE_H diff --git a/src/paymentdisclosuredb.cpp b/src/paymentdisclosuredb.cpp new file mode 100644 index 000000000..559e5688b --- /dev/null +++ b/src/paymentdisclosuredb.cpp @@ -0,0 +1,11 @@ +// Copyright (c) 2017 The Zcash developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "paymentdisclosuredb.h" + +#include "util.h" +#include "dbwrapper.h" + +#include + diff --git a/src/paymentdisclosuredb.h b/src/paymentdisclosuredb.h new file mode 100644 index 000000000..f239c5118 --- /dev/null +++ b/src/paymentdisclosuredb.h @@ -0,0 +1,21 @@ +// Copyright (c) 2017 The Zcash developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef ZCASH_PAYMENTDISCLOSUREDB_H +#define ZCASH_PAYMENTDISCLOSUREDB_H + +#include "paymentdisclosure.h" + +#include +#include +#include +#include +#include + +#include + +#include + + +#endif // ZCASH_PAYMENTDISCLOSUREDB_H diff --git a/src/primitives/nonce.cpp b/src/primitives/nonce.cpp new file mode 100644 index 000000000..a1fbd667d --- /dev/null +++ b/src/primitives/nonce.cpp @@ -0,0 +1,24 @@ +// Copyright (c) 2019 The Hush Developers +// Copyright (c) 2018 Michael Toutonghi +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +/****************************************************************************** + * Copyright © 2014-2019 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +#include "hash.h" +#include "nonce.h" +#include + diff --git a/src/primitives/nonce.h b/src/primitives/nonce.h new file mode 100644 index 000000000..b17a9f01b --- /dev/null +++ b/src/primitives/nonce.h @@ -0,0 +1,29 @@ +// Copyright (c) 2019 Hush Developers +// Copyright (c) 2018 Michael Toutonghi +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +/****************************************************************************** + * Copyright © 2014-2019 The SuperNET Developers. * + * * + * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * + * the top-level directory of this distribution for the individual copyright * + * holder information and the developer policies on copyright and licensing. * + * * + * Unless otherwise agreed in a custom licensing agreement, no part of the * + * SuperNET software, including this file may be copied, modified, propagated * + * or distributed except according to the terms contained in the LICENSE file * + * * + * Removal or modification of this copyright notice is prohibited. * + * * + ******************************************************************************/ + +#ifndef BITCOIN_PRIMITIVES_NONCE_H +#define BITCOIN_PRIMITIVES_NONCE_H + +#include "serialize.h" +#include "uint256.h" +#include "arith_uint256.h" + + +#endif // BITCOIN_PRIMITIVES_NONCE_H From 89bfb4d4a61150790db9a014e9c0270048b7c814 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 13 Jun 2020 08:51:59 -0400 Subject: [PATCH 068/255] desprout --- src/paymentdisclosure.cpp | 9 --------- src/paymentdisclosure.h | 19 ------------------- src/paymentdisclosuredb.cpp | 11 ----------- src/paymentdisclosuredb.h | 21 --------------------- src/primitives/nonce.cpp | 24 ------------------------ src/primitives/nonce.h | 29 ----------------------------- 6 files changed, 113 deletions(-) delete mode 100644 src/paymentdisclosure.cpp delete mode 100644 src/paymentdisclosure.h delete mode 100644 src/paymentdisclosuredb.cpp delete mode 100644 src/paymentdisclosuredb.h delete mode 100644 src/primitives/nonce.cpp delete mode 100644 src/primitives/nonce.h diff --git a/src/paymentdisclosure.cpp b/src/paymentdisclosure.cpp deleted file mode 100644 index d442c40f6..000000000 --- a/src/paymentdisclosure.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include "paymentdisclosure.h" - -#include "key_io.h" -#include "util.h" - diff --git a/src/paymentdisclosure.h b/src/paymentdisclosure.h deleted file mode 100644 index 9855e1de0..000000000 --- a/src/paymentdisclosure.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef ZCASH_PAYMENTDISCLOSURE_H -#define ZCASH_PAYMENTDISCLOSURE_H - -#include "uint256.h" -#include "clientversion.h" -#include "serialize.h" -#include "streams.h" -#include "version.h" - -// For JSOutPoint -#include "wallet/wallet.h" - -#include -#include -#include - - -// Ensure that the two different protocol messages, payment disclosure blobs and transactions, -#endif // ZCASH_PAYMENTDISCLOSURE_H diff --git a/src/paymentdisclosuredb.cpp b/src/paymentdisclosuredb.cpp deleted file mode 100644 index 559e5688b..000000000 --- a/src/paymentdisclosuredb.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include "paymentdisclosuredb.h" - -#include "util.h" -#include "dbwrapper.h" - -#include - diff --git a/src/paymentdisclosuredb.h b/src/paymentdisclosuredb.h deleted file mode 100644 index f239c5118..000000000 --- a/src/paymentdisclosuredb.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef ZCASH_PAYMENTDISCLOSUREDB_H -#define ZCASH_PAYMENTDISCLOSUREDB_H - -#include "paymentdisclosure.h" - -#include -#include -#include -#include -#include - -#include - -#include - - -#endif // ZCASH_PAYMENTDISCLOSUREDB_H diff --git a/src/primitives/nonce.cpp b/src/primitives/nonce.cpp deleted file mode 100644 index a1fbd667d..000000000 --- a/src/primitives/nonce.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2019 The Hush Developers -// Copyright (c) 2018 Michael Toutonghi -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -/****************************************************************************** - * Copyright © 2014-2019 The SuperNET Developers. * - * * - * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * - * the top-level directory of this distribution for the individual copyright * - * holder information and the developer policies on copyright and licensing. * - * * - * Unless otherwise agreed in a custom licensing agreement, no part of the * - * SuperNET software, including this file may be copied, modified, propagated * - * or distributed except according to the terms contained in the LICENSE file * - * * - * Removal or modification of this copyright notice is prohibited. * - * * - ******************************************************************************/ - -#include "hash.h" -#include "nonce.h" -#include - diff --git a/src/primitives/nonce.h b/src/primitives/nonce.h deleted file mode 100644 index b17a9f01b..000000000 --- a/src/primitives/nonce.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2019 Hush Developers -// Copyright (c) 2018 Michael Toutonghi -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -/****************************************************************************** - * Copyright © 2014-2019 The SuperNET Developers. * - * * - * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * - * the top-level directory of this distribution for the individual copyright * - * holder information and the developer policies on copyright and licensing. * - * * - * Unless otherwise agreed in a custom licensing agreement, no part of the * - * SuperNET software, including this file may be copied, modified, propagated * - * or distributed except according to the terms contained in the LICENSE file * - * * - * Removal or modification of this copyright notice is prohibited. * - * * - ******************************************************************************/ - -#ifndef BITCOIN_PRIMITIVES_NONCE_H -#define BITCOIN_PRIMITIVES_NONCE_H - -#include "serialize.h" -#include "uint256.h" -#include "arith_uint256.h" - - -#endif // BITCOIN_PRIMITIVES_NONCE_H From 96c50683e9baca74d0cd23feba43ccc7c1e6baa4 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 13 Jun 2020 09:01:06 -0400 Subject: [PATCH 069/255] Fix the fucking linker bug --- src/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Makefile.am b/src/Makefile.am index ec3f562f2..b44dd13c5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -340,7 +340,7 @@ libbitcoin_proton_a_SOURCES = \ amqp/amqppublishnotifier.cpp endif -# wallet: zcashd, but only linked when wallet enabled +# wallet: komodod, but only linked when wallet enabled libbitcoin_wallet_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) libbitcoin_wallet_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) libbitcoin_wallet_a_SOURCES = \ @@ -352,6 +352,7 @@ libbitcoin_wallet_a_SOURCES = \ wallet/asyncrpcoperation_shieldcoinbase.cpp \ wallet/crypter.cpp \ wallet/db.cpp \ + zcash/Note.cpp \ transaction_builder.cpp \ wallet/rpcdump.cpp \ cc/CCtokens.cpp \ From f7a9db724a6180594921c03d5764f0dd385753f9 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 13 Jun 2020 09:24:58 -0400 Subject: [PATCH 070/255] More error detection --- contrib/block_time.pl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contrib/block_time.pl b/contrib/block_time.pl index dff43ea4e..b4b039a60 100755 --- a/contrib/block_time.pl +++ b/contrib/block_time.pl @@ -9,6 +9,11 @@ my $block = shift || die "Usage: $0 123"; my $hush = "./src/hush-cli"; my $blockcount = qx{$hush getblockcount}; +unless ($blockcount = int($blockcount)) { + print "Invalid response from hush-cli\n"; + exit 1; +} + if ($block <= $blockcount) { die "That block has already happened!"; } else { From cc3ae8164493320a24b165f101444109a28d5ff3 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 13 Jun 2020 09:29:24 -0400 Subject: [PATCH 071/255] 2020 --- contrib/block_time.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/block_time.pl b/contrib/block_time.pl index b4b039a60..17da3c461 100755 --- a/contrib/block_time.pl +++ b/contrib/block_time.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# Copyright 2019 The Hush developers +# Copyright 2019-2020 The Hush developers # Released under the GPLv3 use warnings; use strict; From 6a4c86e3cd9d477122a0a209623890118123fa4f Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 13 Jun 2020 10:14:41 -0400 Subject: [PATCH 072/255] define next hardfork height --- src/komodo_defs.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 6d867b229..97a21969f 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -54,13 +54,19 @@ // Hush Block 166250 will happen at roughly: // Wed Jan 29 08:14:12 2020 Eastern # 1580303652 // Wed Jan 29 13:14:12 2020 GMT # 1580303652 -const uint32_t nHushHardforkHeight = 166250; +const uint32_t nHushHardforkHeight = 166250; +// $ ./contrib/block_time.pl 255555 +// Hush Block 255555 will happen at roughly: +// Sat Jul 11 21:41:12 2020 Eastern # 1594518072 +// Sun Jul 12 01:41:12 2020 GMT # 1594518072 +const uint32_t nHushHardforkHeight2 = 255555; // No coins/code are currently using timestamp activated fork -const uint32_t nHushHardforkTimestamp = 1580303652; // Jan 29nd 1pm GMT +const uint32_t nHushHardforkTimestamp = 1580303652; // Jan 29nd 1pm GMT +const uint32_t nHushHardforkTimestamp2 = 1594425600; // Jul 11th 12a GMT -static const uint32_t KMD_SEASON_TIMESTAMPS[NUM_KMD_SEASONS] = {1525132800, 1563148800, nHushHardforkTimestamp, 1751328000}; -static const int32_t KMD_SEASON_HEIGHTS[NUM_KMD_SEASONS] = {1,2,nHushHardforkHeight, 5*nHushHardforkHeight}; +static const uint32_t KMD_SEASON_TIMESTAMPS[NUM_KMD_SEASONS] = {1525132800, 1563148800, nHushHardforkTimestamp, nHushHardforkTimestamp2, nHushHardforkTimestamp2*5}; +static const int32_t KMD_SEASON_HEIGHTS[NUM_KMD_SEASONS] = {1,2,nHushHardforkHeight, nHushHardforkHeight2, 5*nHushHardforkHeight2}; // Era array of pubkeys. Add extra seasons to bottom as requried, after adding appropriate info above. static const char *notaries_elected[NUM_KMD_SEASONS][NUM_KMD_NOTARIES][2] = From 2fbcca4167cf41fa7f6f553046a3f113e2b60d14 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 13 Jun 2020 10:14:51 -0400 Subject: [PATCH 073/255] add rescan rpc --- src/rpc/server.h | 1 + src/wallet/rpcdump.cpp | 37 +++++++++++++++++++++++++++++++++++++ src/wallet/rpcwallet.cpp | 3 +++ 3 files changed, 41 insertions(+) diff --git a/src/rpc/server.h b/src/rpc/server.h index 1cd4e993d..6568977d7 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -489,6 +489,7 @@ extern UniValue z_getoperationstatus(const UniValue& params, bool fHelp, const C extern UniValue z_getoperationresult(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp extern UniValue z_listoperationids(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp extern UniValue opreturn_burn(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp +extern UniValue rescan(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp extern UniValue z_validateaddress(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcmisc.cpp extern UniValue z_getpaymentdisclosure(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcdisclosure.cpp extern UniValue z_validatepaymentdisclosure(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcdisclosure.cpp diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index 1499a58b9..72af5d930 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -149,6 +149,43 @@ UniValue convertpassphrase(const UniValue& params, bool fHelp, const CPubKey& my return ret; } +UniValue rescan(const UniValue& params, bool fHelp, const CPubKey& mypk) +{ + //LOCK2(cs_main, pwalletMain->cs_wallet); + + if (!EnsureWalletIsAvailable(fHelp)) + return NullUniValue; + + if (fHelp || params.size() > 1) + throw runtime_error( + "rescan \"height\"\n" + "\nRescan all transactions from genesis or given block height.\n" + "\nArguments:\n" + "1. \"height\" (integer, optional) The block height to rescan from\n" + "\nExamples:\n" + "\nRescan from block height 555\n" + + HelpExampleCli("rescan", "\"555\"") + + "\nRescan from genesis block\n" + + HelpExampleCli("rescan","") + ); + + // Height to rescan from + int nRescanHeight = 0; + if (params.size() > 0) + nRescanHeight = params[0].get_int(); + if (nRescanHeight < 0 || nRescanHeight > chainActive.Height()) { + throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range"); + } + + LogPrintf("Rescanning from height=%d\n", nRescanHeight); + //pwalletMain->ScanForWalletTransactions(chainActive[nRescanHeight],true); + bool update = false; + pwalletMain->ScanForWalletTransactions(chainActive.Genesis(),update); + //TODO: can we return something more useful? + return NullUniValue; +} + + UniValue importprivkey(const UniValue& params, bool fHelp, const CPubKey& mypk) { if (!EnsureWalletIsAvailable(fHelp)) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 873d8eb87..867de51a7 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -8228,6 +8228,8 @@ extern UniValue z_exportviewingkey(const UniValue& params, bool fHelp, const CPu extern UniValue z_importviewingkey(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue z_exportwallet(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue z_importwallet(const UniValue& params, bool fHelp, const CPubKey& mypk); +extern UniValue rescan(const UniValue& params, bool fHelp, const CPubKey& mypk); + static const CRPCCommand commands[] = { // category name actor (function) okSafeMode @@ -8266,6 +8268,7 @@ static const CRPCCommand commands[] = { "wallet", "listunspent", &listunspent, false }, { "wallet", "lockunspent", &lockunspent, true }, { "wallet", "move", &movecmd, false }, + { "wallet", "rescan", &rescan, false }, { "wallet", "sendfrom", &sendfrom, false }, { "wallet", "sendmany", &sendmany, false }, { "wallet", "sendtoaddress", &sendtoaddress, false }, From 3a28e7bab8e10edcf87573844fbef891fae04aac Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 13 Jun 2020 11:09:00 -0400 Subject: [PATCH 074/255] bump version to 3.4.0 --- configure.ac | 4 ++-- src/clientversion.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index cf712cc67..e3be0c9dd 100644 --- a/configure.ac +++ b/configure.ac @@ -1,8 +1,8 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N) AC_PREREQ([2.60]) define(_CLIENT_VERSION_MAJOR, 3) -define(_CLIENT_VERSION_MINOR, 3) -define(_CLIENT_VERSION_REVISION, 2) +define(_CLIENT_VERSION_MINOR, 4) +define(_CLIENT_VERSION_REVISION, 0) define(_CLIENT_VERSION_BUILD, 50) define(_ZC_BUILD_VAL, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, m4_incr(_CLIENT_VERSION_BUILD), m4_eval(_CLIENT_VERSION_BUILD < 50), 1, m4_eval(_CLIENT_VERSION_BUILD - 24), m4_eval(_CLIENT_VERSION_BUILD == 50), 1, , m4_eval(_CLIENT_VERSION_BUILD - 50))) define(_CLIENT_VERSION_SUFFIX, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, _CLIENT_VERSION_REVISION-beta$1, m4_eval(_CLIENT_VERSION_BUILD < 50), 1, _CLIENT_VERSION_REVISION-rc$1, m4_eval(_CLIENT_VERSION_BUILD == 50), 1, _CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION-$1))) diff --git a/src/clientversion.h b/src/clientversion.h index 71fcee16f..c62e6d3e0 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -33,8 +33,8 @@ //! These need to be macros, as clientversion.cpp's and bitcoin*-res.rc's voodoo requires it // Must be kept in sync with configure.ac ! #define CLIENT_VERSION_MAJOR 3 -#define CLIENT_VERSION_MINOR 3 -#define CLIENT_VERSION_REVISION 2 +#define CLIENT_VERSION_MINOR 4 +#define CLIENT_VERSION_REVISION 0 #define CLIENT_VERSION_BUILD 50 //! Set to true for release, false for prerelease or test build From 717533f7115001bb759742170ef65f93fdc9798f Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 13 Jun 2020 11:09:41 -0400 Subject: [PATCH 075/255] Update unix man pages --- doc/man/hush-cli.1 | 8 ++++---- doc/man/hush-tx.1 | 8 ++++---- doc/man/hushd.1 | 18 ++++++++++++++---- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/doc/man/hush-cli.1 b/doc/man/hush-cli.1 index 0c9080b59..5d87d8205 100644 --- a/doc/man/hush-cli.1 +++ b/doc/man/hush-cli.1 @@ -1,9 +1,9 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.10. -.TH HUSH-CLI "1" "March 2020" "hush-cli v3.3.2" "User Commands" +.TH HUSH-CLI "1" "June 2020" "hush-cli v3.4.0" "User Commands" .SH NAME -hush-cli \- manual page for hush-cli v3.3.2 +hush-cli \- manual page for hush-cli v3.4.0 .SH DESCRIPTION -Komodo RPC client version v3.3.2\-699b59037 +Komodo RPC client version v3.4.0\-2fbcca416\-dirty .PP In order to ensure you are adequately protecting your privacy when using Hush, please see . @@ -71,7 +71,7 @@ Timeout in seconds during HTTP requests, or 0 for no timeout. (default: Read extra arguments from standard input, one per line until EOF/Ctrl\-D (recommended for sensitive information such as passphrases) .SH COPYRIGHT -Hush Daemon version v3.3.2-699b59037 +Hush Daemon version v3.4.0-2fbcca416-dirty In order to ensure you are adequately protecting your privacy when using Hush, please see . diff --git a/doc/man/hush-tx.1 b/doc/man/hush-tx.1 index 9004dcade..a6d3be7ef 100644 --- a/doc/man/hush-tx.1 +++ b/doc/man/hush-tx.1 @@ -1,9 +1,9 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.10. -.TH HUSH-TX "1" "March 2020" "hush-tx v3.3.2" "User Commands" +.TH HUSH-TX "1" "June 2020" "hush-tx v3.4.0" "User Commands" .SH NAME -hush-tx \- manual page for hush-tx v3.3.2 +hush-tx \- manual page for hush-tx v3.4.0 .SH DESCRIPTION -Hush komodo\-tx utility version v3.3.2\-699b59037 +Hush komodo\-tx utility version v3.4.0\-2fbcca416\-dirty .SS "Usage:" .TP komodo\-tx [options] [commands] @@ -84,7 +84,7 @@ set=NAME:JSON\-STRING .IP Set register NAME to given JSON\-STRING .SH COPYRIGHT -Hush Daemon version v3.3.2-699b59037 +Hush Daemon version v3.4.0-2fbcca416-dirty In order to ensure you are adequately protecting your privacy when using Hush, please see . diff --git a/doc/man/hushd.1 b/doc/man/hushd.1 index 0cde080df..6e57386b7 100644 --- a/doc/man/hushd.1 +++ b/doc/man/hushd.1 @@ -1,10 +1,10 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.10. -.TH HUSHD "1" "March 2020" "hushd v3.3.2" "User Commands" +.TH HUSHD "1" "June 2020" "hushd v3.4.0" "User Commands" .SH NAME -hushd \- manual page for hushd v3.3.2 +hushd \- manual page for hushd v3.4.0 .SH DESCRIPTION Found binary: ./komodod -Hush Daemon version v3.3.2\-699b59037 +Hush Daemon version v3.4.0\-2fbcca416\-dirty .PP In order to ensure you are adequately protecting your privacy when using Hush, please see . @@ -87,6 +87,11 @@ leave that many cores free, default: 0) .IP Specify pid file (default: komodod.pid) .HP +\fB\-txexpirynotify=\fR +.IP +Execute command when transaction expires (%s in cmd is replaced by +transaction id) +.HP \fB\-prune=\fR .IP Reduce storage requirements by pruning (deleting) old blocks. This mode @@ -295,6 +300,11 @@ Keep the last transactions (default: 200) .IP Keep transactions for at least blocks (default: 10000) .HP +\fB\-opretmintxfee=\fR +.IP +Minimum fee (in KMD/kB) to allow for OP_RETURN transactions (default: +400000) +.HP \fB\-paytxfee=\fR .IP Fee (in KMD/kB) to add to transactions you send (default: 0.00) @@ -629,7 +639,7 @@ Starting supply, default is 0 .IP Enforce transaction\-rate limit, default 0 .SH COPYRIGHT -Hush Daemon version v3.3.2-699b59037 +Hush Daemon version v3.4.0-2fbcca416-dirty In order to ensure you are adequately protecting your privacy when using Hush, please see . From a053d212b8e22d1d8ffe08a2e0955f1854055702 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 13 Jun 2020 21:34:20 -0400 Subject: [PATCH 076/255] Randomize sietch memos and increase min zouts to 3 --- src/wallet/rpcwallet.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 867de51a7..221bef44e 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4590,6 +4590,15 @@ UniValue z_getoperationstatus_IMPL(const UniValue& params, bool fRemoveFinishedO #define CTXIN_SPEND_DUST_SIZE 148 #define CTXOUT_REGULAR_SIZE 34 +void random_hex(char str[], int len) +{ + char hex[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; + for(int i=0;iMAX_ZOUTS)) { - fprintf(stderr,"%s: Sietch min zouts must be >=2 and <= 25, setting to default value of %d\n", __FUNCTION__, DEFAULT_MIN_ZOUTS ); + if((MIN_ZOUTSMAX_ZOUTS)) { + fprintf(stderr,"%s: Sietch min zouts must be >=%d and <= %d, setting to default value of %d\n", __FUNCTION__, ABSOLUTE_MIN_ZOUTS, MAX_ZOUTS, DEFAULT_MIN_ZOUTS ); MIN_ZOUTS=DEFAULT_MIN_ZOUTS; } @@ -4739,8 +4748,9 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) // OK, we identify this xtn as needing privacy zdust, we must decide how much, non-deterministically int nAmount = 0; int decider = 1 + GetRandInt(100); // random int between 1 and 100 - string memo = "f600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - + char *str; + random_hex(str,512); + string memo = string(str); string zdust1, zdust2; // Which zaddr we send to is non-deterministically chosen from two zpools... From a9d04b1e3f7d62c78e4c80f4d9f0e92394947bf9 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 13 Jun 2020 22:38:38 -0400 Subject: [PATCH 077/255] Include z2z fork height in our future seasons --- src/komodo_defs.h | 13 +++++++------ src/main.cpp | 8 ++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 97a21969f..17d276c4e 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019 The Hush developers +// Copyright (c) 2019-2020 The Hush developers /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * @@ -42,12 +42,12 @@ // KMD Notary Seasons // 1: May 1st 2018 1530921600 // 2: July 15th 2019 1563148800 -> estimated height 1444000 -// 3: 3rd season ending isnt known, so use very far times in future. +// 3: 3rd season // 1751328000 = dummy timestamp, 1 July 2025! // 7113400 = 5x current KMD blockheight. -// to add 4th season, change NUM_KMD_SEASONS to 4, and add timestamp and height of activation to these arrays. +// to add seasons, change NUM_KMD_SEASONS, and add timestamp and height of activation to these arrays. -#define NUM_KMD_SEASONS 5 +#define NUM_KMD_SEASONS 6 #define NUM_KMD_NOTARIES 64 // $ ./contrib/block_time.pl 166250 @@ -64,9 +64,10 @@ const uint32_t nHushHardforkHeight2 = 255555; // No coins/code are currently using timestamp activated fork const uint32_t nHushHardforkTimestamp = 1580303652; // Jan 29nd 1pm GMT const uint32_t nHushHardforkTimestamp2 = 1594425600; // Jul 11th 12a GMT +extern const uint32_t z2zForkHeight; -static const uint32_t KMD_SEASON_TIMESTAMPS[NUM_KMD_SEASONS] = {1525132800, 1563148800, nHushHardforkTimestamp, nHushHardforkTimestamp2, nHushHardforkTimestamp2*5}; -static const int32_t KMD_SEASON_HEIGHTS[NUM_KMD_SEASONS] = {1,2,nHushHardforkHeight, nHushHardforkHeight2, 5*nHushHardforkHeight2}; +static const uint32_t KMD_SEASON_TIMESTAMPS[NUM_KMD_SEASONS] = {1525132800, 1563148800, nHushHardforkTimestamp, nHushHardforkTimestamp2, nHushHardforkTimestamp2*5, nHushHardforkTimestamp2*6}; +static const int32_t KMD_SEASON_HEIGHTS[NUM_KMD_SEASONS] = {1,2,nHushHardforkHeight, nHushHardforkHeight2, (int)z2zForkHeight, 5*nHushHardforkHeight2}; // Era array of pubkeys. Add extra seasons to bottom as requried, after adding appropriate info above. static const char *notaries_elected[NUM_KMD_SEASONS][NUM_KMD_NOTARIES][2] = diff --git a/src/main.cpp b/src/main.cpp index 291706141..d5afa5baf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -115,7 +115,7 @@ bool fAlerts = DEFAULT_ALERTS; */ int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE; bool ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; -unsigned int z2zForkHeight = GetArg("-z2zforkheight",340000); +const uint32_t z2zForkHeight = GetArg("-z2zforkheight",340000); unsigned int expiryDelta = DEFAULT_TX_EXPIRY_DELTA; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; @@ -1735,9 +1735,9 @@ CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowF bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,bool* pfMissingInputs, bool fRejectAbsurdFee, int dosLevel) { AssertLockHeld(cs_main); - uint32_t z2zTransitionWindow = 10; - uint32_t z2zTransitionStart = z2zForkHeight - z2zTransitionWindow; - uint32_t nHeight = chainActive.Height(); + const uint32_t z2zTransitionWindow = 10; + const uint32_t z2zTransitionStart = z2zForkHeight - z2zTransitionWindow; + const uint32_t nHeight = chainActive.Height(); // This only applies to HUSH3, other chains can start off z2z via ac_private=1 if(ishush3) { From 500dcabf53536e051751015bc301fde6f6507d3e Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 13 Jun 2020 22:43:08 -0400 Subject: [PATCH 078/255] Fix a compiler warning in cc and add some copyrights --- src/cryptoconditions/src/anon.c | 1 + src/cryptoconditions/src/cryptoconditions.c | 1 + src/cryptoconditions/src/ed25519.c | 1 + src/cryptoconditions/src/eval.c | 1 + src/cryptoconditions/src/internal.h | 1 + src/cryptoconditions/src/json_rpc.c | 1 + src/cryptoconditions/src/prefix.c | 1 + src/cryptoconditions/src/preimage.c | 1 + src/cryptoconditions/src/secp256k1.c | 1 + src/cryptoconditions/src/threshold.c | 1 + src/cryptoconditions/src/utils.c | 5 ++--- 11 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/cryptoconditions/src/anon.c b/src/cryptoconditions/src/anon.c index 6a4de4b0b..a1bd6b4a3 100644 --- a/src/cryptoconditions/src/anon.c +++ b/src/cryptoconditions/src/anon.c @@ -1,3 +1,4 @@ +// Copyright (c) 2019-2020 The Hush developers /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * diff --git a/src/cryptoconditions/src/cryptoconditions.c b/src/cryptoconditions/src/cryptoconditions.c index 303b9aa41..6642b0345 100644 --- a/src/cryptoconditions/src/cryptoconditions.c +++ b/src/cryptoconditions/src/cryptoconditions.c @@ -1,3 +1,4 @@ +// Copyright (c) 2019-2020 The Hush developers /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * diff --git a/src/cryptoconditions/src/ed25519.c b/src/cryptoconditions/src/ed25519.c index e4d090d1e..33b332071 100644 --- a/src/cryptoconditions/src/ed25519.c +++ b/src/cryptoconditions/src/ed25519.c @@ -1,3 +1,4 @@ +// Copyright (c) 2019-2020 The Hush developers /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * diff --git a/src/cryptoconditions/src/eval.c b/src/cryptoconditions/src/eval.c index a18d51202..a017d181d 100644 --- a/src/cryptoconditions/src/eval.c +++ b/src/cryptoconditions/src/eval.c @@ -1,3 +1,4 @@ +// Copyright (c) 2019-2020 The Hush developers /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * diff --git a/src/cryptoconditions/src/internal.h b/src/cryptoconditions/src/internal.h index 7cfcaa225..3d24214ce 100644 --- a/src/cryptoconditions/src/internal.h +++ b/src/cryptoconditions/src/internal.h @@ -1,3 +1,4 @@ +// Copyright (c) 2019-2020 The Hush developers /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * diff --git a/src/cryptoconditions/src/json_rpc.c b/src/cryptoconditions/src/json_rpc.c index 150bcb12b..c4fde8080 100644 --- a/src/cryptoconditions/src/json_rpc.c +++ b/src/cryptoconditions/src/json_rpc.c @@ -1,3 +1,4 @@ +// Copyright (c) 2019-2020 The Hush developers /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * diff --git a/src/cryptoconditions/src/prefix.c b/src/cryptoconditions/src/prefix.c index 67dc6f644..ea339df35 100644 --- a/src/cryptoconditions/src/prefix.c +++ b/src/cryptoconditions/src/prefix.c @@ -1,3 +1,4 @@ +// Copyright (c) 2019-2020 The Hush developers /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * diff --git a/src/cryptoconditions/src/preimage.c b/src/cryptoconditions/src/preimage.c index a45e621d4..2fee86b88 100644 --- a/src/cryptoconditions/src/preimage.c +++ b/src/cryptoconditions/src/preimage.c @@ -1,3 +1,4 @@ +// Copyright (c) 2019-2020 The Hush developers /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * diff --git a/src/cryptoconditions/src/secp256k1.c b/src/cryptoconditions/src/secp256k1.c index 44ff1f0e2..d5319d32b 100644 --- a/src/cryptoconditions/src/secp256k1.c +++ b/src/cryptoconditions/src/secp256k1.c @@ -1,3 +1,4 @@ +// Copyright (c) 2019-2020 The Hush developers /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * diff --git a/src/cryptoconditions/src/threshold.c b/src/cryptoconditions/src/threshold.c index e94666c3d..e8e12435e 100644 --- a/src/cryptoconditions/src/threshold.c +++ b/src/cryptoconditions/src/threshold.c @@ -1,3 +1,4 @@ +// Copyright (c) 2019-2020 The Hush developers /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * diff --git a/src/cryptoconditions/src/utils.c b/src/cryptoconditions/src/utils.c index ebb2bd143..ac2256f18 100644 --- a/src/cryptoconditions/src/utils.c +++ b/src/cryptoconditions/src/utils.c @@ -1,3 +1,4 @@ +// Copyright (c) 2019-2020 The Hush developers /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * @@ -216,7 +217,7 @@ void hashFingerprintContents(asn_TYPE_descriptor_t *asnType, void *fp, uint8_t * ASN_STRUCT_FREE(*asnType, fp); if (rc.encoded < 1) { fprintf(stderr, "Encoding fingerprint failed\n"); - return 0; + return; } sha256(buf, rc.encoded, out); } @@ -299,5 +300,3 @@ int jsonGetHexOptional(const cJSON *params, char *key, char *err, unsigned char } return checkDecodeHex(item, key, err, data, size); } - - From 53172831d8dc5a39aeccdb862b4a1d77ed413601 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 13 Jun 2020 23:05:51 -0400 Subject: [PATCH 079/255] Delete sprout tests --- qa/pull-tester/rpc-tests.sh | 2 - qa/rpc-tests/zcjoinsplit.py | 59 -------- qa/rpc-tests/zcjoinsplitdoublespend.py | 182 ------------------------- 3 files changed, 243 deletions(-) delete mode 100755 qa/rpc-tests/zcjoinsplit.py delete mode 100755 qa/rpc-tests/zcjoinsplitdoublespend.py diff --git a/qa/pull-tester/rpc-tests.sh b/qa/pull-tester/rpc-tests.sh index 94429cb7f..8c4ad0277 100755 --- a/qa/pull-tester/rpc-tests.sh +++ b/qa/pull-tester/rpc-tests.sh @@ -64,8 +64,6 @@ testScripts=( 'decodescript.py' 'blockchain.py' 'disablewallet.py' - 'zcjoinsplit.py' - 'zcjoinsplitdoublespend.py' 'ivk_import_export.py' 'zkey_import_export.py' 'getblocktemplate.py' diff --git a/qa/rpc-tests/zcjoinsplit.py b/qa/rpc-tests/zcjoinsplit.py deleted file mode 100755 index b3ca745f8..000000000 --- a/qa/rpc-tests/zcjoinsplit.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env python2 - -# -# Test joinsplit semantics -# - -from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal, start_node, \ - gather_inputs - - -class JoinSplitTest(BitcoinTestFramework): - def setup_network(self): - self.nodes = [] - self.is_network_split = False - self.nodes.append(start_node(0, self.options.tmpdir)) - - def run_test(self): - zckeypair = self.nodes[0].zcrawkeygen() - zcsecretkey = zckeypair["zcsecretkey"] - zcaddress = zckeypair["zcaddress"] - - (total_in, inputs) = gather_inputs(self.nodes[0], 40) - protect_tx = self.nodes[0].createrawtransaction(inputs, {}) - joinsplit_result = self.nodes[0].zcrawjoinsplit(protect_tx, {}, {zcaddress:39.99}, 39.99, 0) - - receive_result = self.nodes[0].zcrawreceive(zcsecretkey, joinsplit_result["encryptednote1"]) - assert_equal(receive_result["exists"], False) - - protect_tx = self.nodes[0].signrawtransaction(joinsplit_result["rawtxn"]) - self.nodes[0].sendrawtransaction(protect_tx["hex"]) - self.nodes[0].generate(1) - self.sync_all() - - receive_result = self.nodes[0].zcrawreceive(zcsecretkey, joinsplit_result["encryptednote1"]) - assert_equal(receive_result["exists"], True) - - # The pure joinsplit we create should be mined in the next block - # despite other transactions being in the mempool. - addrtest = self.nodes[0].getnewaddress() - for xx in range(0,10): - self.nodes[0].generate(1) - self.sync_all() - for x in range(0,50): - self.nodes[0].sendtoaddress(addrtest, 0.01); - - joinsplit_tx = self.nodes[0].createrawtransaction([], {}) - joinsplit_result = self.nodes[0].zcrawjoinsplit(joinsplit_tx, {receive_result["note"] : zcsecretkey}, {zcaddress: 39.98}, 0, 0.01) - - self.nodes[0].sendrawtransaction(joinsplit_result["rawtxn"]) - self.nodes[0].generate(1) - self.sync_all() - - print "Done!" - receive_result = self.nodes[0].zcrawreceive(zcsecretkey, joinsplit_result["encryptednote1"]) - assert_equal(receive_result["exists"], True) - -if __name__ == '__main__': - JoinSplitTest().main() diff --git a/qa/rpc-tests/zcjoinsplitdoublespend.py b/qa/rpc-tests/zcjoinsplitdoublespend.py deleted file mode 100755 index b56e7475a..000000000 --- a/qa/rpc-tests/zcjoinsplitdoublespend.py +++ /dev/null @@ -1,182 +0,0 @@ -#!/usr/bin/env python2 - -# -# Tests a joinsplit double-spend and a subsequent reorg. -# - -from test_framework.test_framework import BitcoinTestFramework -from test_framework.authproxy import JSONRPCException -from test_framework.util import assert_equal, connect_nodes, \ - gather_inputs, sync_blocks - -import time - -class JoinSplitTest(BitcoinTestFramework): - def setup_network(self): - # Start with split network: - return super(JoinSplitTest, self).setup_network(True) - - def txid_in_mempool(self, node, txid): - exception_triggered = False - - try: - node.getrawtransaction(txid) - except JSONRPCException: - exception_triggered = True - - return not exception_triggered - - def cannot_joinsplit(self, node, txn): - exception_triggered = False - - try: - node.sendrawtransaction(txn) - except JSONRPCException: - exception_triggered = True - - return exception_triggered - - def expect_cannot_joinsplit(self, node, txn): - assert_equal(self.cannot_joinsplit(node, txn), True) - - def run_test(self): - # All nodes should start with 250 HUSH: - starting_balance = 250 - for i in range(4): - assert_equal(self.nodes[i].getbalance(), starting_balance) - self.nodes[i].getnewaddress("") # bug workaround, coins generated assigned to first getnewaddress! - - # Generate zcaddress keypairs - zckeypair = self.nodes[0].zcrawkeygen() - zcsecretkey = zckeypair["zcsecretkey"] - zcaddress = zckeypair["zcaddress"] - - pool = [0, 1, 2, 3] - for i in range(4): - (total_in, inputs) = gather_inputs(self.nodes[i], 40) - pool[i] = self.nodes[i].createrawtransaction(inputs, {}) - pool[i] = self.nodes[i].zcrawjoinsplit(pool[i], {}, {zcaddress:39.99}, 39.99, 0) - signed = self.nodes[i].signrawtransaction(pool[i]["rawtxn"]) - - # send the tx to both halves of the network - self.nodes[0].sendrawtransaction(signed["hex"]) - self.nodes[0].generate(1) - self.nodes[2].sendrawtransaction(signed["hex"]) - self.nodes[2].generate(1) - pool[i] = pool[i]["encryptednote1"] - - sync_blocks(self.nodes[0:2]) - sync_blocks(self.nodes[2:4]) - - # Confirm that the protects have taken place - for i in range(4): - enc_note = pool[i] - receive_result = self.nodes[0].zcrawreceive(zcsecretkey, enc_note) - assert_equal(receive_result["exists"], True) - pool[i] = receive_result["note"] - - # Extra confirmations - receive_result = self.nodes[1].zcrawreceive(zcsecretkey, enc_note) - assert_equal(receive_result["exists"], True) - - receive_result = self.nodes[2].zcrawreceive(zcsecretkey, enc_note) - assert_equal(receive_result["exists"], True) - - receive_result = self.nodes[3].zcrawreceive(zcsecretkey, enc_note) - assert_equal(receive_result["exists"], True) - - blank_tx = self.nodes[0].createrawtransaction([], {}) - # Create joinsplit {A, B}->{*} - joinsplit_AB = self.nodes[0].zcrawjoinsplit(blank_tx, - {pool[0] : zcsecretkey, pool[1] : zcsecretkey}, - {zcaddress:(39.99*2)-0.01}, - 0, 0.01) - - # Create joinsplit {B, C}->{*} - joinsplit_BC = self.nodes[0].zcrawjoinsplit(blank_tx, - {pool[1] : zcsecretkey, pool[2] : zcsecretkey}, - {zcaddress:(39.99*2)-0.01}, - 0, 0.01) - - # Create joinsplit {C, D}->{*} - joinsplit_CD = self.nodes[0].zcrawjoinsplit(blank_tx, - {pool[2] : zcsecretkey, pool[3] : zcsecretkey}, - {zcaddress:(39.99*2)-0.01}, - 0, 0.01) - - # Create joinsplit {A, D}->{*} - joinsplit_AD = self.nodes[0].zcrawjoinsplit(blank_tx, - {pool[0] : zcsecretkey, pool[3] : zcsecretkey}, - {zcaddress:(39.99*2)-0.01}, - 0, 0.01) - - # (a) Node 0 will spend joinsplit AB, then attempt to - # double-spend it with BC. It should fail before and - # after Node 0 mines blocks. - # - # (b) Then, Node 2 will spend BC, and mine 5 blocks. - # Node 1 connects, and AB will be reorg'd from the chain. - # Any attempts to spend AB or CD should fail for - # both nodes. - # - # (c) Then, Node 0 will spend AD, which should work - # because the previous spend for A (AB) is considered - # invalid due to the reorg. - - # (a) - - AB_txid = self.nodes[0].sendrawtransaction(joinsplit_AB["rawtxn"]) - - self.expect_cannot_joinsplit(self.nodes[0], joinsplit_BC["rawtxn"]) - - # Wait until node[1] receives AB before we attempt to double-spend - # with BC. - print "Waiting for AB_txid...\n" - while True: - if self.txid_in_mempool(self.nodes[1], AB_txid): - break - time.sleep(0.2) - print "Done!\n" - - self.expect_cannot_joinsplit(self.nodes[1], joinsplit_BC["rawtxn"]) - - # Generate a block - self.nodes[0].generate(1) - sync_blocks(self.nodes[0:2]) - - self.expect_cannot_joinsplit(self.nodes[0], joinsplit_BC["rawtxn"]) - self.expect_cannot_joinsplit(self.nodes[1], joinsplit_BC["rawtxn"]) - - # (b) - self.nodes[2].sendrawtransaction(joinsplit_BC["rawtxn"]) - self.nodes[2].generate(5) - - # Connect the two nodes - - connect_nodes(self.nodes[1], 2) - sync_blocks(self.nodes) - - # AB and CD should all be impossible to spend for each node. - self.expect_cannot_joinsplit(self.nodes[0], joinsplit_AB["rawtxn"]) - self.expect_cannot_joinsplit(self.nodes[0], joinsplit_CD["rawtxn"]) - - self.expect_cannot_joinsplit(self.nodes[1], joinsplit_AB["rawtxn"]) - self.expect_cannot_joinsplit(self.nodes[1], joinsplit_CD["rawtxn"]) - - self.expect_cannot_joinsplit(self.nodes[2], joinsplit_AB["rawtxn"]) - self.expect_cannot_joinsplit(self.nodes[2], joinsplit_CD["rawtxn"]) - - self.expect_cannot_joinsplit(self.nodes[3], joinsplit_AB["rawtxn"]) - self.expect_cannot_joinsplit(self.nodes[3], joinsplit_CD["rawtxn"]) - - # (c) - # AD should be possible to send due to the reorg that - # tossed out AB. - - self.nodes[0].sendrawtransaction(joinsplit_AD["rawtxn"]) - self.nodes[0].generate(1) - - sync_blocks(self.nodes) - -if __name__ == '__main__': - JoinSplitTest().main() From ede0f21e6745fe2368dfc91bd8b2f231d9cabecd Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 16 Jun 2020 09:32:48 -0400 Subject: [PATCH 080/255] desprout --- qa/pull-tester/rpc-tests.sh | 2 - qa/rpc-tests/p2p_nu_peer_management.py | 192 ------------------------- qa/rpc-tests/wallet_listnotes.py | 81 +---------- 3 files changed, 1 insertion(+), 274 deletions(-) delete mode 100755 qa/rpc-tests/p2p_nu_peer_management.py diff --git a/qa/pull-tester/rpc-tests.sh b/qa/pull-tester/rpc-tests.sh index 8c4ad0277..35bf5a7e9 100755 --- a/qa/pull-tester/rpc-tests.sh +++ b/qa/pull-tester/rpc-tests.sh @@ -23,7 +23,6 @@ testScripts=( 'wallet_changeindicator.py' 'wallet_import_export.py' 'wallet_protectcoinbase.py' - 'wallet_shieldcoinbase_sprout.py' 'wallet_shieldcoinbase_sapling.py' 'wallet_listreceived.py' 'wallet_mergetoaddress.py' @@ -69,7 +68,6 @@ testScripts=( 'getblocktemplate.py' 'bip65-cltv-p2p.py' 'bipdersig-p2p.py' - 'p2p_nu_peer_management.py' 'rewind_index.py' 'p2p_txexpiry_dos.py' 'p2p_node_bloom.py' diff --git a/qa/rpc-tests/p2p_nu_peer_management.py b/qa/rpc-tests/p2p_nu_peer_management.py deleted file mode 100755 index 6cedf66bb..000000000 --- a/qa/rpc-tests/p2p_nu_peer_management.py +++ /dev/null @@ -1,192 +0,0 @@ -#!/usr/bin/env python2 -# Copyright (c) 2018 The Zcash developers -# Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. - -from test_framework.mininode import ( - NodeConn, - NodeConnCB, - NetworkThread, - msg_ping, - SPROUT_PROTO_VERSION, - OVERWINTER_PROTO_VERSION, - SAPLING_PROTO_VERSION, -) -from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import initialize_chain_clean, start_nodes, \ - p2p_port, assert_equal - -import time - -# -# In this test we connect Sprout, Overwinter, and Sapling mininodes to a Zcashd -# node which will activate Overwinter at block 10 and Sapling at block 15. -# -# We test: -# 1. the mininodes stay connected to Zcash with Sprout consensus rules -# 2. when Overwinter activates, the Sprout mininodes are dropped -# 3. new Overwinter and Sapling nodes can connect to Zcash -# 4. new Sprout nodes cannot connect to Zcash -# 5. when Sapling activates, the Overwinter mininodes are dropped -# 6. new Sapling nodes can connect to Zcash -# 7. new Sprout and Overwinter nodes cannot connect to Zcash -# -# This test *does not* verify that prior to each activation, the Zcashd -# node will prefer connections with NU-aware nodes, with an eviction process -# that prioritizes non-NU-aware connections. -# - - -class TestManager(NodeConnCB): - def __init__(self): - NodeConnCB.__init__(self) - self.create_callback_map() - - def on_close(self, conn): - pass - - def on_reject(self, conn, message): - conn.rejectMessage = message - - -class NUPeerManagementTest(BitcoinTestFramework): - - def setup_chain(self): - print "Initializing test directory "+self.options.tmpdir - initialize_chain_clean(self.options.tmpdir, 1) - - def setup_network(self): - self.nodes = start_nodes(1, self.options.tmpdir, extra_args=[[ - '-nuparams=5ba81b19:10', # Overwinter - '-nuparams=76b809bb:15', # Sapling - '-debug', - '-whitelist=127.0.0.1', - ]]) - - def run_test(self): - test = TestManager() - - # Launch Sprout, Overwinter, and Sapling mininodes - nodes = [] - for x in xrange(10): - nodes.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], - test, "regtest", SPROUT_PROTO_VERSION)) - nodes.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], - test, "regtest", OVERWINTER_PROTO_VERSION)) - nodes.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], - test, "regtest", SAPLING_PROTO_VERSION)) - - # Start up network handling in another thread - NetworkThread().start() - - # Sprout consensus rules apply at block height 9 - self.nodes[0].generate(9) - assert_equal(9, self.nodes[0].getblockcount()) - - # Verify mininodes are still connected to zcashd node - peerinfo = self.nodes[0].getpeerinfo() - versions = [x["version"] for x in peerinfo] - assert_equal(10, versions.count(SPROUT_PROTO_VERSION)) - assert_equal(10, versions.count(OVERWINTER_PROTO_VERSION)) - assert_equal(10, versions.count(SAPLING_PROTO_VERSION)) - - # Overwinter consensus rules activate at block height 10 - self.nodes[0].generate(1) - assert_equal(10, self.nodes[0].getblockcount()) - print('Overwinter active') - - # Mininodes send ping message to zcashd node. - pingCounter = 1 - for node in nodes: - node.send_message(msg_ping(pingCounter)) - pingCounter = pingCounter + 1 - - time.sleep(3) - - # Verify Sprout mininodes have been dropped, while Overwinter and - # Sapling mininodes are still connected. - peerinfo = self.nodes[0].getpeerinfo() - versions = [x["version"] for x in peerinfo] - assert_equal(0, versions.count(SPROUT_PROTO_VERSION)) - assert_equal(10, versions.count(OVERWINTER_PROTO_VERSION)) - assert_equal(10, versions.count(SAPLING_PROTO_VERSION)) - - # Extend the Overwinter chain with another block. - self.nodes[0].generate(1) - - # Connect a new Overwinter mininode to the zcashd node, which is accepted. - nodes.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test, "regtest", OVERWINTER_PROTO_VERSION)) - time.sleep(3) - assert_equal(21, len(self.nodes[0].getpeerinfo())) - - # Connect a new Sapling mininode to the zcashd node, which is accepted. - nodes.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test, "regtest", SAPLING_PROTO_VERSION)) - time.sleep(3) - assert_equal(22, len(self.nodes[0].getpeerinfo())) - - # Try to connect a new Sprout mininode to the zcashd node, which is rejected. - sprout = NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test, "regtest", SPROUT_PROTO_VERSION) - nodes.append(sprout) - time.sleep(3) - assert("Version must be 170003 or greater" in str(sprout.rejectMessage)) - - # Verify that only Overwinter and Sapling mininodes are connected. - peerinfo = self.nodes[0].getpeerinfo() - versions = [x["version"] for x in peerinfo] - assert_equal(0, versions.count(SPROUT_PROTO_VERSION)) - assert_equal(11, versions.count(OVERWINTER_PROTO_VERSION)) - assert_equal(11, versions.count(SAPLING_PROTO_VERSION)) - - # Sapling consensus rules activate at block height 15 - self.nodes[0].generate(4) - assert_equal(15, self.nodes[0].getblockcount()) - print('Sapling active') - - # Mininodes send ping message to zcashd node. - pingCounter = 1 - for node in nodes: - node.send_message(msg_ping(pingCounter)) - pingCounter = pingCounter + 1 - - time.sleep(3) - - # Verify Sprout and Overwinter mininodes have been dropped, while - # Sapling mininodes are still connected. - peerinfo = self.nodes[0].getpeerinfo() - versions = [x["version"] for x in peerinfo] - assert_equal(0, versions.count(SPROUT_PROTO_VERSION)) - assert_equal(0, versions.count(OVERWINTER_PROTO_VERSION)) - assert_equal(11, versions.count(SAPLING_PROTO_VERSION)) - - # Extend the Sapling chain with another block. - self.nodes[0].generate(1) - - # Connect a new Sapling mininode to the zcashd node, which is accepted. - nodes.append(NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test, "regtest", SAPLING_PROTO_VERSION)) - time.sleep(3) - assert_equal(12, len(self.nodes[0].getpeerinfo())) - - # Try to connect a new Sprout mininode to the zcashd node, which is rejected. - sprout = NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test, "regtest", SPROUT_PROTO_VERSION) - nodes.append(sprout) - time.sleep(3) - assert("Version must be 170006 or greater" in str(sprout.rejectMessage)) - - # Try to connect a new Overwinter mininode to the zcashd node, which is rejected. - sprout = NodeConn('127.0.0.1', p2p_port(0), self.nodes[0], test, "regtest", OVERWINTER_PROTO_VERSION) - nodes.append(sprout) - time.sleep(3) - assert("Version must be 170006 or greater" in str(sprout.rejectMessage)) - - # Verify that only Sapling mininodes are connected. - peerinfo = self.nodes[0].getpeerinfo() - versions = [x["version"] for x in peerinfo] - assert_equal(0, versions.count(SPROUT_PROTO_VERSION)) - assert_equal(0, versions.count(OVERWINTER_PROTO_VERSION)) - assert_equal(12, versions.count(SAPLING_PROTO_VERSION)) - - for node in nodes: - node.disconnect_node() - -if __name__ == '__main__': - NUPeerManagementTest().main() diff --git a/qa/rpc-tests/wallet_listnotes.py b/qa/rpc-tests/wallet_listnotes.py index 5cd89c661..90fbcced1 100755 --- a/qa/rpc-tests/wallet_listnotes.py +++ b/qa/rpc-tests/wallet_listnotes.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2019-2020 The Hush developers # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -20,89 +21,9 @@ class WalletListNotes(BitcoinTestFramework): def run_test(self): # Current height = 200 -> Sprout assert_equal(200, self.nodes[0].getblockcount()) - sproutzaddr = self.nodes[0].z_getnewaddress('sprout') # test that we can create a sapling zaddr before sapling activates saplingzaddr = self.nodes[0].z_getnewaddress('sapling') - - # we've got lots of coinbase (taddr) but no shielded funds yet - assert_equal(0, Decimal(self.nodes[0].z_gettotalbalance()['private'])) - - # Set current height to 201 -> Sprout - self.nodes[0].generate(1) - self.sync_all() - assert_equal(201, self.nodes[0].getblockcount()) - - mining_addr = self.nodes[0].listunspent()[0]['address'] - - # Shield coinbase funds (must be a multiple of 10, no change allowed pre-sapling) - receive_amount_10 = Decimal('10.0') - Decimal('0.0001') - recipients = [{"address":sproutzaddr, "amount":receive_amount_10}] - myopid = self.nodes[0].z_sendmany(mining_addr, recipients) - txid_1 = wait_and_assert_operationid_status(self.nodes[0], myopid) - self.sync_all() - - # No funds (with (default) one or more confirmations) in sproutzaddr yet - assert_equal(0, len(self.nodes[0].z_listunspent())) - assert_equal(0, len(self.nodes[0].z_listunspent(1))) - - # no private balance because no confirmations yet - assert_equal(0, Decimal(self.nodes[0].z_gettotalbalance()['private'])) - - # list private unspent, this time allowing 0 confirmations - unspent_cb = self.nodes[0].z_listunspent(0) - assert_equal(1, len(unspent_cb)) - assert_equal(False, unspent_cb[0]['change']) - assert_equal(txid_1, unspent_cb[0]['txid']) - assert_equal(True, unspent_cb[0]['spendable']) - assert_equal(sproutzaddr, unspent_cb[0]['address']) - assert_equal(receive_amount_10, unspent_cb[0]['amount']) - - # list unspent, filtering by address, should produce same result - unspent_cb_filter = self.nodes[0].z_listunspent(0, 9999, False, [sproutzaddr]) - assert_equal(unspent_cb, unspent_cb_filter) - - # Generate a block to confirm shield coinbase tx - self.nodes[0].generate(1) - self.sync_all() - - # Current height = 202 -> Overwinter. Default address type remains Sprout - assert_equal(202, self.nodes[0].getblockcount()) - - # Send 1.0 (actually 0.9999) from sproutzaddr to a new zaddr - sproutzaddr2 = self.nodes[0].z_getnewaddress() - receive_amount_1 = Decimal('1.0') - Decimal('0.0001') - change_amount_9 = receive_amount_10 - Decimal('1.0') - assert_equal('sprout', self.nodes[0].z_validateaddress(sproutzaddr2)['type']) - recipients = [{"address": sproutzaddr2, "amount":receive_amount_1}] - myopid = self.nodes[0].z_sendmany(sproutzaddr, recipients) - txid_2 = wait_and_assert_operationid_status(self.nodes[0], myopid) - self.sync_all() - - # list unspent, allowing 0conf txs - unspent_tx = self.nodes[0].z_listunspent(0) - assert_equal(len(unspent_tx), 2) - # sort low-to-high by amount (order of returned entries is not guaranteed) - unspent_tx = sorted(unspent_tx, key=lambda k: k['amount']) - assert_equal(False, unspent_tx[0]['change']) - assert_equal(txid_2, unspent_tx[0]['txid']) - assert_equal(True, unspent_tx[0]['spendable']) - assert_equal(sproutzaddr2, unspent_tx[0]['address']) - assert_equal(receive_amount_1, unspent_tx[0]['amount']) - - assert_equal(True, unspent_tx[1]['change']) - assert_equal(txid_2, unspent_tx[1]['txid']) - assert_equal(True, unspent_tx[1]['spendable']) - assert_equal(sproutzaddr, unspent_tx[1]['address']) - assert_equal(change_amount_9, unspent_tx[1]['amount']) - - unspent_tx_filter = self.nodes[0].z_listunspent(0, 9999, False, [sproutzaddr2]) - assert_equal(1, len(unspent_tx_filter)) - assert_equal(unspent_tx[0], unspent_tx_filter[0]) - - unspent_tx_filter = self.nodes[0].z_listunspent(0, 9999, False, [sproutzaddr]) - assert_equal(1, len(unspent_tx_filter)) - assert_equal(unspent_tx[1], unspent_tx_filter[0]) # Set current height to 204 -> Sapling self.nodes[0].generate(2) From 9b6bc6cf1437e72711e458b3bad77e44b39a5ccd Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 16 Jun 2020 09:34:30 -0400 Subject: [PATCH 081/255] desprout --- qa/rpc-tests/regtest_signrawtransaction.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qa/rpc-tests/regtest_signrawtransaction.py b/qa/rpc-tests/regtest_signrawtransaction.py index 2e0273677..78ec1fbc8 100755 --- a/qa/rpc-tests/regtest_signrawtransaction.py +++ b/qa/rpc-tests/regtest_signrawtransaction.py @@ -1,4 +1,5 @@ #!/usr/bin/env python2 +# Copyright (c) 2019-2020 The Hush developers # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying # file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -18,7 +19,7 @@ class RegtestSignrawtransactionTest (BitcoinTestFramework): self.nodes[0].generate(1) self.sync_all() taddr = self.nodes[1].getnewaddress() - zaddr1 = self.nodes[1].z_getnewaddress('sprout') + zaddr1 = self.nodes[1].z_getnewaddress('sapling') self.nodes[0].sendtoaddress(taddr, 2.0) self.nodes[0].generate(1) From b5c9453129d68a7bd4537bdfeb7114aa28b7fcf9 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 16 Jun 2020 10:46:25 -0400 Subject: [PATCH 082/255] Declare S4 to have happened already. This is now now --- src/komodo_defs.h | 8 +++----- src/komodo_notary.h | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 17d276c4e..423d556d0 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -55,11 +55,9 @@ // Wed Jan 29 08:14:12 2020 Eastern # 1580303652 // Wed Jan 29 13:14:12 2020 GMT # 1580303652 const uint32_t nHushHardforkHeight = 166250; -// $ ./contrib/block_time.pl 255555 -// Hush Block 255555 will happen at roughly: -// Sat Jul 11 21:41:12 2020 Eastern # 1594518072 -// Sun Jul 12 01:41:12 2020 GMT # 1594518072 -const uint32_t nHushHardforkHeight2 = 255555; +// $ ./contrib/block_time.pl 245555 +// Hush Block 245555 will happen at roughly... now +const uint32_t nHushHardforkHeight2 = 245055; // No coins/code are currently using timestamp activated fork const uint32_t nHushHardforkTimestamp = 1580303652; // Jan 29nd 1pm GMT diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 8114a86af..d5591aa29 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -1,4 +1,4 @@ -// Copyright (c) 2019 The Hush developers +// Copyright (c) 2019-2020 The Hush developers /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * From 07d7aacd901d7d40a30ecee9e3219fabc46c331a Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 16 Jun 2020 11:24:12 -0400 Subject: [PATCH 083/255] destake --- src/komodo_defs.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 423d556d0..3a4af6f48 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -34,9 +34,6 @@ #define KOMODO_FIRSTFUNGIBLEID 100 #define KOMODO_SAPLING_ACTIVATION 1544832000 // Dec 15th, 2018 #define KOMODO_SAPLING_DEADLINE 1550188800 // Feb 15th, 2019 -#define ASSETCHAINS_STAKED_BLOCK_FUTURE_MAX 57 -#define ASSETCHAINS_STAKED_BLOCK_FUTURE_HALF 27 -#define ASSETCHAINS_STAKED_MIN_POW_DIFF 536900000 // 537000000 537300000 #define _COINBASE_MATURITY 100 // KMD Notary Seasons From 40f68d0d0581aab8eaba17ec19c3a3b689cb7f6b Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 16 Jun 2020 11:43:18 -0400 Subject: [PATCH 084/255] HUSH dpow --- src/komodo_defs.h | 74 +++++++++-------------------------------------- 1 file changed, 14 insertions(+), 60 deletions(-) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 3a4af6f48..0b51c09af 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -333,71 +333,25 @@ static const char *notaries_elected[NUM_KMD_SEASONS][NUM_KMD_NOTARIES][2] = {"decker_AR", "02a85540db8d41c7e60bf0d33d1364b4151cad883dd032878ea4c037f67b769635" } }, { - // Season 4 https://github.com/KomodoPlatform/dPoW/blob/s4/iguana/3rd_party - {"alien_AR", "024f20c096b085308e21893383f44b4faf1cdedea9ad53cc7d7e7fbfa0c30c1e71" }, - {"alien_EU", "022b85908191788f409506ebcf96a892f3274f352864c3ed566c5a16de63953236" }, - {"alien_NA", "022f62b56ddfd07c9860921c701285ac39bb3ac8f6f083d1b59c8f4943be3de162" }, - {"alright_DEV", "03b6f9493658bdd102503585a08ae642b49d6a68fb69ac3626f9737cd7581abdfa" }, - {"artemii235_DEV", "037a20916d2e9ea575300ac9d729507c23a606b9a200c8e913d7c9832f912a1fa7" }, - {"chainmakers_NA", "028803e07bcc521fde264b7191a944f9b3612e8ee4e24a99bcd903f6976240839a" }, - {"chainzilla_SH", "0311dde03c2dd654ce78323b718ed3ad73a464d1bde97820f3395f54788b5420dd" }, - {"chmex_AR", "030cd487e10fbf142e0e8d582e702ecb775f378569c3cb5acd0ff97b6b12803588" }, - {"chmex_EU", "030bf7bd7ad0515c33b5d5d9a91e0729baf801b9002f80495ae535ea1cebb352cb" }, + // Season 4 HUSH notaries. A new DPoW network is born. {"cipi_EU", "026f4f66385daaf8313ef30ffe4988e7db497132682dca185a70763d93e1417d9d" }, {"cipi_NA", "03f4e69edcb4fa3b2095cb8cb1ca010f4ec4972eac5d8822397e5c8d87aa21a739" }, - {"daemonfox_NA", "023c7584b1006d4a62a4b4c9c1ede390a3789316547897d5ed49ff9385a3acb411" }, - {"dappvader_SH", "025199bc04bcb8a17976d9fe8bc87763a6150c2727321aa59bf34a2b49f2f3a0ce" }, - {"decker_AR", "02a85540db8d41c7e60bf0d33d1364b4151cad883dd032878ea4c037f67b769635" }, - {"decker_DEV", "02fca8ee50e49f480de275745618db7b0b3680b0bdcce7dcae7d2e0fd5c3345744" }, - {"decker_EU", "027777775b89ff548c3be54fb0c9455437d87f38bfce83bdef113899881b219c9e" }, - {"dragonhound_NA", "029912212d370ee0fb4d38eefd8bfcd8ab04e2c3b0354020789c29ddf2a35c72d6" }, - {"dudezmobi_AR", "033c121d3f8d450174674a73f3b7f140b2717a7d51ea19ee597e2e8e8f9d5ed87f" }, - {"etszombi_AR", "03bfcbca83f11e622fa4eed9a1fa25dba377981ea3b22e3d0a4015f9a932af9272" }, - {"etszombi_EU", "03a5c083c78ba397970f20b544a01c13e7ed36ca8a5ae26d5fe7bd38b92b6a0c94" }, - {"fullmoon_AR", "03639bc56d3fecf856f17759a441c5893668e7c2d460f3d216798a413cd6766bb2" }, - {"fullmoon_NA", "03e388bcc579ac2675f8fadfa921eec186dcea8d2b43de1eed6caba23d5a962b74" }, - {"fullmoon_SH", "03a5cfda2b097c808834ccdd805828c811b519611feabdfe6b3644312e53f6748f" }, - {"gcharang_SH", "02a654037d12cdd609f4fad48e15ec54538e03f61fdae1acb855f16ebacac6bd73" }, - {"greer_NA", "0262da6aaa0b295b8e2f120035924758a4a630f899316dc63ee15ef03e9b7b2b23" }, - {"indenodes_AR", "0242778789986d614f75bcf629081651b851a12ab1cc10c73995b27b90febb75a2" }, - {"indenodes_EU", "03a416533cace0814455a1bb1cd7861ce825a543c6f6284a432c4c8d8875b7ace9" }, - {"indenodes_NA", "02b3908eda4078f0e9b6704451cdc24d418e899c0f515fab338d7494da6f0a647b" }, - {"indenodes_SH", "031d1584cf0eb4a2d314465e49e2677226b1615c3718013b8d6b4854c15676a58c" }, - {"karasugoi_NA", "02f803e6f159824a181cc5d709f3d1e7ff65f19e1899920724aeb4e3d2d869f911" }, - {"madmax_AR", "027afddbcf690230dd8d435ec16a7bfb0083e6b77030f763437f291dfc40a579d0" }, - {"madmax_EU", "0397ec3a4ad84b3009566d260c89f1c4404e86e5d044964747c9371277e38f5995" }, - {"madmax_NA", "036d3afebe1eab09f4c38c3ee6a4659ad390f3df92787c11437a58c59a29e408e6" }, - {"marmarachain_AR", "028690ca1e3afdf8a38b421f6a41f5ff407afc96d5a7a6a488330aae26c8b086bb" }, - {"mcrypt_SH", "027a4ca7b11d3456ff558c08bb04483a89c7f383448461fd0b6b3b07424aabe9a4" }, - {"metaphilibert_AR", "0239e34ad22957bbf4c8df824401f237b2afe8d40f7a645ecd43e8f27dde1ab0da" }, - {"metaphilibert_SH", "03b21ff042bf1730b28bde43f44c064578b41996117ac7634b567c3773089e3be3" }, - {"mihailo_EU", "036494e7c9467c8c7ff3bf29e841907fb0fa24241866569944ea422479ec0e6252" }, - {"mrlynch_AR", "03e67440141f53a08684c329ebc852b018e41f905da88e52aa4a6dc5aa4b12447a" }, - {"mylo_SH", "026d5f29d09ff3f33e14db4811606249b2438c6bcf964876714f81d1f2d952acde" }, {"node9_EU", "0392e4c9400e69f28c6b9e89d586da69d5a6af7702f1045eaa6ebc1996f0496e1f" }, - {"nodeone_NA", "0310a249c6c2dcc29f2135715138a9ddb8e01c0eab701cbd0b96d9cec660dbdc58" }, - {"nutellalicka_SH", "0284c4d3cb97dd8a32d10fb32b1855ae18cf845dad542e3b8937ca0e998fb54ecc" }, - {"oszy_EU", "03c53bd421de4a29ce68c8cc83f802e1181e77c08f8f16684490d61452ea8d023a" }, - {"patchkez_SH", "028c08db6e7242681f50db6c234fe3d6e12fb1a915350311be26373bac0d457d49" }, - {"pbca26_NA", "03c18431bb6bc95672f640f19998a196becd2851d5dcba4795fe8d85b7d77eab81" }, - {"peer2cloud_AR", "0243958faf9ae4d43b598b859ddc595c170c4cf50f8e4517d660ae5bc72aeb821b" }, - {"phba2061_EU", "03369187ce134bd7793ee34af7756fe1ab27202e09306491cdd5d8ad2c71697937" }, {"phm87_SH", "03889a10f9df2caef57220628515693cf25316fe1b0693b0241419e75d0d0e66ed" }, - {"pirate_EU", "0240011b95cde819f298fe0f507b2260c9fecdab784924076d4d1e54c522103cb1" }, - {"pirate_NA", "02ad7ef25d2dd461e361120cd3efe7cbce5e9512c361e9185aac33dd303d758613" }, - {"pungocloud_SH", "02641c36ae6747b88150a463a1fe65cf7a9d1c00a64387c73f296f0b64e77c7d3f" }, - {"smdmitry_AR", "0397b7584cb29717b721c0c587d4462477efc1f36a56921f133c9d17b0cd7f278a" }, - {"starfleet_EU", "03c6e047218f34644ccba67e317b9da5d28e68bbbb6b9973aef1281d2bafa46496" }, - {"strob_NA", "02285bf2f9e96068ecac14bc6f770e394927b4da9f5ba833eaa9468b5d47f203a3" }, - {"strob_SH", "0213751a1c59d3489ca85b3d62a3d606dcef7f0428aa021c1978ea16fb38a2fad6" }, - {"swisscertifiers_EU", "02e7722ebba9f8b5ebfb4e87d4fa58cc75aef677535b9cfc060c7d9471aacd9c9e" }, - {"titomane_AR", "03958bd8d13fe6946b8d0d0fbbc3861c72542560d0276e80a4c6b5fe55bc758b81" }, - {"titomane_EU", "02276090e483db1a01a802456b10831b3b6e0a6ad3ece9b2a01f4aad0e480c8edc" }, - {"titomane_SH", "02abf206bafc8048dbdc042b8eb6b1e356ea5dbe149eae3532b4811d4905e5cf01" }, - {"tonyl_AR", "0229e499e3f2e065ced402ceb8aaf3d5ab8bd3793aa074305e9fa30772ce604908" }, - {"tonyl_DEV", "0258b77d7dcfc6c2628b0b6b438951a6e74201fb2cd180a795e4c37fcf8e78a678" }, {"webworker01_NA", "02de90c720c007229374772505a43917a84ed129d5fbcfa4949cc2e9b563351124" }, - {"zatjum_SH", "0241c5660ca540780be66603b1791127a1261d56abbcb7562c297eec8e4fc078fb" } + + //TODO: placeholders so we have 16 NNs, details to be filled soon + {"webworker01_NA", "02de90c720c007229374772505a43917a84ed129d5fbcfa4949cc2e9b563351124" }, + {"webworker01_NA", "02de90c720c007229374772505a43917a84ed129d5fbcfa4949cc2e9b563351124" }, + {"webworker01_NA", "02de90c720c007229374772505a43917a84ed129d5fbcfa4949cc2e9b563351124" }, + {"webworker01_NA", "02de90c720c007229374772505a43917a84ed129d5fbcfa4949cc2e9b563351124" }, + {"webworker01_NA", "02de90c720c007229374772505a43917a84ed129d5fbcfa4949cc2e9b563351124" }, + {"webworker01_NA", "02de90c720c007229374772505a43917a84ed129d5fbcfa4949cc2e9b563351124" }, + {"webworker01_NA", "02de90c720c007229374772505a43917a84ed129d5fbcfa4949cc2e9b563351124" }, + {"webworker01_NA", "02de90c720c007229374772505a43917a84ed129d5fbcfa4949cc2e9b563351124" }, + {"webworker01_NA", "02de90c720c007229374772505a43917a84ed129d5fbcfa4949cc2e9b563351124" }, + {"webworker01_NA", "02de90c720c007229374772505a43917a84ed129d5fbcfa4949cc2e9b563351124" }, + {"webworker01_NA", "02de90c720c007229374772505a43917a84ed129d5fbcfa4949cc2e9b563351124" }, } }; From 94134862e5c9021eb86dab1dcb071521287b03c8 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 16 Jun 2020 11:44:38 -0400 Subject: [PATCH 085/255] try to make linker happy --- src/cc/cclib.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 364953148..e8b4a32b2 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -1,3 +1,4 @@ +// Copyright © 2019-2020 The Hush Developers /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * @@ -34,6 +35,9 @@ #define EVAL_ROGUE 17 std::string MYCCLIBNAME = (char *)"rogue"; +extern const uint32_t z2zForkHeight; + + #elif BUILD_CUSTOMCC #include "customcc.h" From 0c5923d7492f3d5452eeb5b9bc62479c0a1a77d9 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 16 Jun 2020 12:04:12 -0400 Subject: [PATCH 086/255] Revert "HUSH dpow" This reverts commit 40f68d0d0581aab8eaba17ec19c3a3b689cb7f6b. --- src/komodo_defs.h | 74 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 60 insertions(+), 14 deletions(-) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 0b51c09af..3a4af6f48 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -333,25 +333,71 @@ static const char *notaries_elected[NUM_KMD_SEASONS][NUM_KMD_NOTARIES][2] = {"decker_AR", "02a85540db8d41c7e60bf0d33d1364b4151cad883dd032878ea4c037f67b769635" } }, { - // Season 4 HUSH notaries. A new DPoW network is born. + // Season 4 https://github.com/KomodoPlatform/dPoW/blob/s4/iguana/3rd_party + {"alien_AR", "024f20c096b085308e21893383f44b4faf1cdedea9ad53cc7d7e7fbfa0c30c1e71" }, + {"alien_EU", "022b85908191788f409506ebcf96a892f3274f352864c3ed566c5a16de63953236" }, + {"alien_NA", "022f62b56ddfd07c9860921c701285ac39bb3ac8f6f083d1b59c8f4943be3de162" }, + {"alright_DEV", "03b6f9493658bdd102503585a08ae642b49d6a68fb69ac3626f9737cd7581abdfa" }, + {"artemii235_DEV", "037a20916d2e9ea575300ac9d729507c23a606b9a200c8e913d7c9832f912a1fa7" }, + {"chainmakers_NA", "028803e07bcc521fde264b7191a944f9b3612e8ee4e24a99bcd903f6976240839a" }, + {"chainzilla_SH", "0311dde03c2dd654ce78323b718ed3ad73a464d1bde97820f3395f54788b5420dd" }, + {"chmex_AR", "030cd487e10fbf142e0e8d582e702ecb775f378569c3cb5acd0ff97b6b12803588" }, + {"chmex_EU", "030bf7bd7ad0515c33b5d5d9a91e0729baf801b9002f80495ae535ea1cebb352cb" }, {"cipi_EU", "026f4f66385daaf8313ef30ffe4988e7db497132682dca185a70763d93e1417d9d" }, {"cipi_NA", "03f4e69edcb4fa3b2095cb8cb1ca010f4ec4972eac5d8822397e5c8d87aa21a739" }, + {"daemonfox_NA", "023c7584b1006d4a62a4b4c9c1ede390a3789316547897d5ed49ff9385a3acb411" }, + {"dappvader_SH", "025199bc04bcb8a17976d9fe8bc87763a6150c2727321aa59bf34a2b49f2f3a0ce" }, + {"decker_AR", "02a85540db8d41c7e60bf0d33d1364b4151cad883dd032878ea4c037f67b769635" }, + {"decker_DEV", "02fca8ee50e49f480de275745618db7b0b3680b0bdcce7dcae7d2e0fd5c3345744" }, + {"decker_EU", "027777775b89ff548c3be54fb0c9455437d87f38bfce83bdef113899881b219c9e" }, + {"dragonhound_NA", "029912212d370ee0fb4d38eefd8bfcd8ab04e2c3b0354020789c29ddf2a35c72d6" }, + {"dudezmobi_AR", "033c121d3f8d450174674a73f3b7f140b2717a7d51ea19ee597e2e8e8f9d5ed87f" }, + {"etszombi_AR", "03bfcbca83f11e622fa4eed9a1fa25dba377981ea3b22e3d0a4015f9a932af9272" }, + {"etszombi_EU", "03a5c083c78ba397970f20b544a01c13e7ed36ca8a5ae26d5fe7bd38b92b6a0c94" }, + {"fullmoon_AR", "03639bc56d3fecf856f17759a441c5893668e7c2d460f3d216798a413cd6766bb2" }, + {"fullmoon_NA", "03e388bcc579ac2675f8fadfa921eec186dcea8d2b43de1eed6caba23d5a962b74" }, + {"fullmoon_SH", "03a5cfda2b097c808834ccdd805828c811b519611feabdfe6b3644312e53f6748f" }, + {"gcharang_SH", "02a654037d12cdd609f4fad48e15ec54538e03f61fdae1acb855f16ebacac6bd73" }, + {"greer_NA", "0262da6aaa0b295b8e2f120035924758a4a630f899316dc63ee15ef03e9b7b2b23" }, + {"indenodes_AR", "0242778789986d614f75bcf629081651b851a12ab1cc10c73995b27b90febb75a2" }, + {"indenodes_EU", "03a416533cace0814455a1bb1cd7861ce825a543c6f6284a432c4c8d8875b7ace9" }, + {"indenodes_NA", "02b3908eda4078f0e9b6704451cdc24d418e899c0f515fab338d7494da6f0a647b" }, + {"indenodes_SH", "031d1584cf0eb4a2d314465e49e2677226b1615c3718013b8d6b4854c15676a58c" }, + {"karasugoi_NA", "02f803e6f159824a181cc5d709f3d1e7ff65f19e1899920724aeb4e3d2d869f911" }, + {"madmax_AR", "027afddbcf690230dd8d435ec16a7bfb0083e6b77030f763437f291dfc40a579d0" }, + {"madmax_EU", "0397ec3a4ad84b3009566d260c89f1c4404e86e5d044964747c9371277e38f5995" }, + {"madmax_NA", "036d3afebe1eab09f4c38c3ee6a4659ad390f3df92787c11437a58c59a29e408e6" }, + {"marmarachain_AR", "028690ca1e3afdf8a38b421f6a41f5ff407afc96d5a7a6a488330aae26c8b086bb" }, + {"mcrypt_SH", "027a4ca7b11d3456ff558c08bb04483a89c7f383448461fd0b6b3b07424aabe9a4" }, + {"metaphilibert_AR", "0239e34ad22957bbf4c8df824401f237b2afe8d40f7a645ecd43e8f27dde1ab0da" }, + {"metaphilibert_SH", "03b21ff042bf1730b28bde43f44c064578b41996117ac7634b567c3773089e3be3" }, + {"mihailo_EU", "036494e7c9467c8c7ff3bf29e841907fb0fa24241866569944ea422479ec0e6252" }, + {"mrlynch_AR", "03e67440141f53a08684c329ebc852b018e41f905da88e52aa4a6dc5aa4b12447a" }, + {"mylo_SH", "026d5f29d09ff3f33e14db4811606249b2438c6bcf964876714f81d1f2d952acde" }, {"node9_EU", "0392e4c9400e69f28c6b9e89d586da69d5a6af7702f1045eaa6ebc1996f0496e1f" }, + {"nodeone_NA", "0310a249c6c2dcc29f2135715138a9ddb8e01c0eab701cbd0b96d9cec660dbdc58" }, + {"nutellalicka_SH", "0284c4d3cb97dd8a32d10fb32b1855ae18cf845dad542e3b8937ca0e998fb54ecc" }, + {"oszy_EU", "03c53bd421de4a29ce68c8cc83f802e1181e77c08f8f16684490d61452ea8d023a" }, + {"patchkez_SH", "028c08db6e7242681f50db6c234fe3d6e12fb1a915350311be26373bac0d457d49" }, + {"pbca26_NA", "03c18431bb6bc95672f640f19998a196becd2851d5dcba4795fe8d85b7d77eab81" }, + {"peer2cloud_AR", "0243958faf9ae4d43b598b859ddc595c170c4cf50f8e4517d660ae5bc72aeb821b" }, + {"phba2061_EU", "03369187ce134bd7793ee34af7756fe1ab27202e09306491cdd5d8ad2c71697937" }, {"phm87_SH", "03889a10f9df2caef57220628515693cf25316fe1b0693b0241419e75d0d0e66ed" }, + {"pirate_EU", "0240011b95cde819f298fe0f507b2260c9fecdab784924076d4d1e54c522103cb1" }, + {"pirate_NA", "02ad7ef25d2dd461e361120cd3efe7cbce5e9512c361e9185aac33dd303d758613" }, + {"pungocloud_SH", "02641c36ae6747b88150a463a1fe65cf7a9d1c00a64387c73f296f0b64e77c7d3f" }, + {"smdmitry_AR", "0397b7584cb29717b721c0c587d4462477efc1f36a56921f133c9d17b0cd7f278a" }, + {"starfleet_EU", "03c6e047218f34644ccba67e317b9da5d28e68bbbb6b9973aef1281d2bafa46496" }, + {"strob_NA", "02285bf2f9e96068ecac14bc6f770e394927b4da9f5ba833eaa9468b5d47f203a3" }, + {"strob_SH", "0213751a1c59d3489ca85b3d62a3d606dcef7f0428aa021c1978ea16fb38a2fad6" }, + {"swisscertifiers_EU", "02e7722ebba9f8b5ebfb4e87d4fa58cc75aef677535b9cfc060c7d9471aacd9c9e" }, + {"titomane_AR", "03958bd8d13fe6946b8d0d0fbbc3861c72542560d0276e80a4c6b5fe55bc758b81" }, + {"titomane_EU", "02276090e483db1a01a802456b10831b3b6e0a6ad3ece9b2a01f4aad0e480c8edc" }, + {"titomane_SH", "02abf206bafc8048dbdc042b8eb6b1e356ea5dbe149eae3532b4811d4905e5cf01" }, + {"tonyl_AR", "0229e499e3f2e065ced402ceb8aaf3d5ab8bd3793aa074305e9fa30772ce604908" }, + {"tonyl_DEV", "0258b77d7dcfc6c2628b0b6b438951a6e74201fb2cd180a795e4c37fcf8e78a678" }, {"webworker01_NA", "02de90c720c007229374772505a43917a84ed129d5fbcfa4949cc2e9b563351124" }, - - //TODO: placeholders so we have 16 NNs, details to be filled soon - {"webworker01_NA", "02de90c720c007229374772505a43917a84ed129d5fbcfa4949cc2e9b563351124" }, - {"webworker01_NA", "02de90c720c007229374772505a43917a84ed129d5fbcfa4949cc2e9b563351124" }, - {"webworker01_NA", "02de90c720c007229374772505a43917a84ed129d5fbcfa4949cc2e9b563351124" }, - {"webworker01_NA", "02de90c720c007229374772505a43917a84ed129d5fbcfa4949cc2e9b563351124" }, - {"webworker01_NA", "02de90c720c007229374772505a43917a84ed129d5fbcfa4949cc2e9b563351124" }, - {"webworker01_NA", "02de90c720c007229374772505a43917a84ed129d5fbcfa4949cc2e9b563351124" }, - {"webworker01_NA", "02de90c720c007229374772505a43917a84ed129d5fbcfa4949cc2e9b563351124" }, - {"webworker01_NA", "02de90c720c007229374772505a43917a84ed129d5fbcfa4949cc2e9b563351124" }, - {"webworker01_NA", "02de90c720c007229374772505a43917a84ed129d5fbcfa4949cc2e9b563351124" }, - {"webworker01_NA", "02de90c720c007229374772505a43917a84ed129d5fbcfa4949cc2e9b563351124" }, - {"webworker01_NA", "02de90c720c007229374772505a43917a84ed129d5fbcfa4949cc2e9b563351124" }, + {"zatjum_SH", "0241c5660ca540780be66603b1791127a1261d56abbcb7562c297eec8e4fc078fb" } } }; From a470c4e2510be7c232b4830e7701cebbdf3624a5 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 16 Jun 2020 12:21:30 -0400 Subject: [PATCH 087/255] get rid of z2zforkheight which causes linker bugz --- src/cc/cclib.cpp | 3 --- src/komodo_defs.h | 3 +-- src/main.cpp | 10 +++++----- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index e8b4a32b2..67440f3da 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -35,9 +35,6 @@ #define EVAL_ROGUE 17 std::string MYCCLIBNAME = (char *)"rogue"; -extern const uint32_t z2zForkHeight; - - #elif BUILD_CUSTOMCC #include "customcc.h" diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 3a4af6f48..e482390bb 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -59,10 +59,9 @@ const uint32_t nHushHardforkHeight2 = 245055; // No coins/code are currently using timestamp activated fork const uint32_t nHushHardforkTimestamp = 1580303652; // Jan 29nd 1pm GMT const uint32_t nHushHardforkTimestamp2 = 1594425600; // Jul 11th 12a GMT -extern const uint32_t z2zForkHeight; static const uint32_t KMD_SEASON_TIMESTAMPS[NUM_KMD_SEASONS] = {1525132800, 1563148800, nHushHardforkTimestamp, nHushHardforkTimestamp2, nHushHardforkTimestamp2*5, nHushHardforkTimestamp2*6}; -static const int32_t KMD_SEASON_HEIGHTS[NUM_KMD_SEASONS] = {1,2,nHushHardforkHeight, nHushHardforkHeight2, (int)z2zForkHeight, 5*nHushHardforkHeight2}; +static const int32_t KMD_SEASON_HEIGHTS[NUM_KMD_SEASONS] = {1,2,nHushHardforkHeight, nHushHardforkHeight2, (int)340000, 5*nHushHardforkHeight2}; // Era array of pubkeys. Add extra seasons to bottom as requried, after adding appropriate info above. static const char *notaries_elected[NUM_KMD_SEASONS][NUM_KMD_NOTARIES][2] = diff --git a/src/main.cpp b/src/main.cpp index d5afa5baf..f0bc7793a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -115,7 +115,7 @@ bool fAlerts = DEFAULT_ALERTS; */ int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE; bool ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; -const uint32_t z2zForkHeight = GetArg("-z2zforkheight",340000); +const uint32_t 340000 = GetArg("-z2zforkheight",340000); unsigned int expiryDelta = DEFAULT_TX_EXPIRY_DELTA; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; @@ -1736,12 +1736,12 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa { AssertLockHeld(cs_main); const uint32_t z2zTransitionWindow = 10; - const uint32_t z2zTransitionStart = z2zForkHeight - z2zTransitionWindow; + const uint32_t z2zTransitionStart = 340000 - z2zTransitionWindow; const uint32_t nHeight = chainActive.Height(); // This only applies to HUSH3, other chains can start off z2z via ac_private=1 if(ishush3) { - if((nHeight >= z2zTransitionStart) || (nHeight <= z2zForkHeight)) { + if((nHeight >= z2zTransitionStart) || (nHeight <= 340000)) { // During the z2z transition window, only coinbase tx's as part of blocks are allowed // Theory: We want an empty mempool at our fork block height, and the only way to assure that // is to have an empty mempool for a few previous blocks, to take care of potential re-orgs @@ -3364,7 +3364,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin bool ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; if(!ASSETCHAINS_PRIVATE && ishush3) { unsigned int nHeight = pindex->GetHeight(); - if(nHeight >= z2zForkHeight) { + if(nHeight >= 340000) { // At startup, HUSH3 doesn't know a block height yet and so we must wait until // connecting a block fprintf(stderr, "%s: Going full z2z at height %d!\n",__func__,nHeight); @@ -6337,7 +6337,7 @@ bool static LoadBlockIndexDB() // Try to detect if we are z2z based on height of blocks on disk // This helps to set it correctly on startup before a new block is connected - if(ishush3 && chainActive.Height() >= z2zForkHeight) { + if(ishush3 && chainActive.Height() >= 340000) { LogPrintf("%s: enabled ac_private=1 at height=%d\n", __func__, chainActive.Height()); ASSETCHAINS_PRIVATE = 1; } From 7f7876d2084daebc89b1914c870fa407c4fbef4e Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 16 Jun 2020 12:25:47 -0400 Subject: [PATCH 088/255] oops --- src/main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index f0bc7793a..317be206d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -115,7 +115,6 @@ bool fAlerts = DEFAULT_ALERTS; */ int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE; bool ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; -const uint32_t 340000 = GetArg("-z2zforkheight",340000); unsigned int expiryDelta = DEFAULT_TX_EXPIRY_DELTA; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; From 4de60497c866c82330defd63b11884ab8991f973 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 17 Jun 2020 00:04:55 -0400 Subject: [PATCH 089/255] Refactor GetSaplingWitnesses code and add some logging --- src/wallet/wallet.cpp | 13 ++++++++----- src/zcash/Zcash.h | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index a7ca3d74d..b9ad1919d 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1719,16 +1719,19 @@ void CWallet::GetSaplingNoteWitnesses(std::vector notes, boost::optional rt; int i = 0; for (SaplingOutPoint note : notes) { - if (mapWallet.count(note.hash) && - mapWallet[note.hash].mapSaplingNoteData.count(note) && - mapWallet[note.hash].mapSaplingNoteData[note].witnesses.size() > 0) { - witnesses[i] = mapWallet[note.hash].mapSaplingNoteData[note].witnesses.front(); + fprintf(stderr,"%s: i=%d\n", __func__,i); + auto noteData = mapWallet[note.hash].mapSaplingNoteData; + auto witnessess = noteData[note].witnesses; + if (mapWallet.count(note.hash) && noteData.count(note) && witnesses.size() > 0) { + fprintf(stderr,"%s: Found %lu witnesses for note %s\n", __func__, witnesses.size(), note.hash.ToString().c_str() ); + witnesses[i] = witnesses.front(); if (!rt) { rt = witnesses[i]->root(); } else { if(*rt == witnesses[i]->root()) { // Something is fucky - std::string err = "CWallet::GetSaplingNoteWitnesses: Invalid witness root!"; + std::string err = "CWallet::GetSaplingNoteWitnesses: Invalid witness root! i="; + err += i; throw std::logic_error(err); } diff --git a/src/zcash/Zcash.h b/src/zcash/Zcash.h index 84dfe9525..e45aa1d02 100644 --- a/src/zcash/Zcash.h +++ b/src/zcash/Zcash.h @@ -1,3 +1,4 @@ +// Copyright (c) 2019-2020 The Hush developers #ifndef ZC_ZCASH_H_ #define ZC_ZCASH_H_ From d0dade1d2c76d43cc8c7f245718e11997b2fc59d Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 17 Jun 2020 10:13:57 -0400 Subject: [PATCH 090/255] desprout --- src/zcash/JoinSplit.cpp | 68 ----------------------------------------- 1 file changed, 68 deletions(-) diff --git a/src/zcash/JoinSplit.cpp b/src/zcash/JoinSplit.cpp index db51ff1fd..5cd7627dc 100644 --- a/src/zcash/JoinSplit.cpp +++ b/src/zcash/JoinSplit.cpp @@ -28,73 +28,5 @@ class JoinSplitCircuit : public JoinSplit { public: JoinSplitCircuit() {} ~JoinSplitCircuit() {} - - /* - SproutProof prove( - const std::array& inputs, - const std::array& outputs, - std::array& out_notes, - std::array& out_ciphertexts, - uint256& out_ephemeralKey, - const uint256& joinSplitPubKey, - uint256& out_randomSeed, - std::array& out_macs, - std::array& out_nullifiers, - std::array& out_commitments, - uint64_t vpub_old, - uint64_t vpub_new, - const uint256& rt, - bool computeProof, - uint256 *out_esk // Payment disclosure - ) { - GrothProof proof; - return proof; - } - */ }; - -/* -template -JoinSplit* JoinSplit::Prepared() -{ - return new JoinSplitCircuit(); -} - -template -uint256 JoinSplit::h_sig( - const uint256& randomSeed, - const std::array& nullifiers, - const uint256& joinSplitPubKey -) { - const unsigned char personalization[crypto_generichash_blake2b_PERSONALBYTES] - = {'Z','c','a','s','h','C','o','m','p','u','t','e','h','S','i','g'}; - - std::vector block(randomSeed.begin(), randomSeed.end()); - - for (size_t i = 0; i < NumInputs; i++) { - block.insert(block.end(), nullifiers[i].begin(), nullifiers[i].end()); - } - - block.insert(block.end(), joinSplitPubKey.begin(), joinSplitPubKey.end()); - - uint256 output; - - if (crypto_generichash_blake2b_salt_personal(output.begin(), 32, - &block[0], block.size(), - NULL, 0, // No key. - NULL, // No salt. - personalization - ) != 0) - { - throw std::logic_error("hash function failure"); - } - - return output; -} - - -template class JoinSplit; - -*/ } From 6e31ee3b1d3a790f5603ccbc1a1c3f6fa0c2d45b Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 17 Jun 2020 10:41:33 -0400 Subject: [PATCH 091/255] fix --- src/wallet/wallet.cpp | 11 +++++++---- src/zcash/IncrementalMerkleTree.cpp | 1 + src/zcash/util.h | 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index b9ad1919d..b3d759f83 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1721,14 +1721,17 @@ void CWallet::GetSaplingNoteWitnesses(std::vector notes, for (SaplingOutPoint note : notes) { fprintf(stderr,"%s: i=%d\n", __func__,i); auto noteData = mapWallet[note.hash].mapSaplingNoteData; - auto witnessess = noteData[note].witnesses; - if (mapWallet.count(note.hash) && noteData.count(note) && witnesses.size() > 0) { - fprintf(stderr,"%s: Found %lu witnesses for note %s\n", __func__, witnesses.size(), note.hash.ToString().c_str() ); - witnesses[i] = witnesses.front(); + auto nWitnesses = noteData[note].witnesses.size(); + if (mapWallet.count(note.hash) && noteData.count(note) && nWitnesses > 0) { + fprintf(stderr,"%s: Found %lu witnesses for note %s\n", __func__, nWitnesses, note.hash.ToString().c_str() ); + witnesses[i] = noteData[note].witnesses.front(); if (!rt) { + fprintf(stderr,"%s: Setting witness root\n",__func__); rt = witnesses[i]->root(); } else { if(*rt == witnesses[i]->root()) { + //fprintf(stderr,"%s: rt=%s\n",__func__,rt.GetHash().ToString().c_str()); + //fprintf(stderr,"%s: witnesses[%d]->root()=%s\n",__func__,i,witnesses[i]->root().GetHash().ToString().c_str()); // Something is fucky std::string err = "CWallet::GetSaplingNoteWitnesses: Invalid witness root! i="; err += i; diff --git a/src/zcash/IncrementalMerkleTree.cpp b/src/zcash/IncrementalMerkleTree.cpp index 4d3ff8c2b..247eaf80c 100644 --- a/src/zcash/IncrementalMerkleTree.cpp +++ b/src/zcash/IncrementalMerkleTree.cpp @@ -1018,6 +1018,7 @@ size_t IncrementalMerkleTree::next_depth(size_t skip) const { template Hash IncrementalMerkleTree::root(size_t depth, std::deque filler_hashes) const { + fprintf(stderr,"%s: depth=%d\n",__func__,depth); PathFiller filler(filler_hashes); Hash combine_left = left ? *left : filler.next(0); diff --git a/src/zcash/util.h b/src/zcash/util.h index 10886e3ca..0c04a5aac 100644 --- a/src/zcash/util.h +++ b/src/zcash/util.h @@ -1,3 +1,4 @@ +// Copyright (c) 2019-2020 The Hush developers #ifndef ZC_UTIL_H_ #define ZC_UTIL_H_ From 280cc4cfdad1e0a6053b643142e56fa4092629e0 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 17 Jun 2020 12:36:08 -0400 Subject: [PATCH 092/255] oops --- src/zcash/IncrementalMerkleTree.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/zcash/IncrementalMerkleTree.cpp b/src/zcash/IncrementalMerkleTree.cpp index 247eaf80c..d4411c11b 100644 --- a/src/zcash/IncrementalMerkleTree.cpp +++ b/src/zcash/IncrementalMerkleTree.cpp @@ -1018,7 +1018,7 @@ size_t IncrementalMerkleTree::next_depth(size_t skip) const { template Hash IncrementalMerkleTree::root(size_t depth, std::deque filler_hashes) const { - fprintf(stderr,"%s: depth=%d\n",__func__,depth); + //fprintf(stderr,"%s: depth=%d\n",__func__,depth); PathFiller filler(filler_hashes); Hash combine_left = left ? *left : filler.next(0); From f8972d4150318631b19ab3abff9ce237783ac034 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 17 Jun 2020 17:49:18 -0400 Subject: [PATCH 093/255] Remove mention of joinsplit from some error messages --- src/coins.h | 4 ++-- src/main.cpp | 15 +++++++-------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/coins.h b/src/coins.h index 3e8f674fb..2d08be42c 100644 --- a/src/coins.h +++ b/src/coins.h @@ -545,7 +545,7 @@ public: size_t DynamicMemoryUsage() const; /** - * Amount of bitcoins coming in to a transaction + * Amount of HUSH coming in to a transaction * Note that lightweight clients may not know anything besides the hash of previous transactions, * so may not be able to calculate this. * @@ -557,7 +557,7 @@ public: //! Check whether all prevouts of the transaction are present in the UTXO set represented by this view bool HaveInputs(const CTransaction& tx) const; - //! Check whether all joinsplit requirements (anchors/nullifiers) are satisfied + //! Check whether all shielded requirements (anchors/nullifiers) are satisfied bool HaveShieldedRequirements(const CTransaction& tx) const; //! Return priority of tx at height nHeight diff --git a/src/main.cpp b/src/main.cpp index 317be206d..ada7ab8a6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1907,7 +1907,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa if (!view.HaveShieldedRequirements(tx)) { //fprintf(stderr,"accept failure.2\n"); - return state.Invalid(error("AcceptToMemoryPool: joinsplit requirements not met"),REJECT_DUPLICATE, "bad-txns-joinsplit-requirements-not-met"); + return state.Invalid(error("AcceptToMemoryPool: shielded requirements not met"),REJECT_DUPLICATE, "bad-txns-joinsplit-requirements-not-met"); } // Bring the best block into scope @@ -2728,9 +2728,9 @@ namespace Consensus { if (!inputs.HaveInputs(tx)) return state.Invalid(error("CheckInputs(): %s inputs unavailable", tx.GetHash().ToString())); - // are the JoinSplit's requirements met? + // are the shielded requirements met? if (!inputs.HaveShieldedRequirements(tx)) - return state.Invalid(error("CheckInputs(): %s JoinSplit requirements not met", tx.GetHash().ToString())); + return state.Invalid(error("CheckInputs(): %s shielded requirements not met", tx.GetHash().ToString())); CAmount nValueIn = 0; CAmount nFees = 0; @@ -3464,7 +3464,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin // Before the genesis block, there was an empty tree SproutMerkleTree tree; pindex->hashSproutAnchor = tree.root(); - // The genesis block contained no JoinSplits + // The genesis block contained no JoinSplits, lulz pindex->hashFinalSproutRoot = pindex->hashSproutAnchor; } return true; @@ -3557,10 +3557,9 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return state.DoS(100, error("ConnectBlock(): inputs missing/spent"), REJECT_INVALID, "bad-txns-inputs-missingorspent"); } - // are the JoinSplit's requirements met? + // are the shielded requirements met? if (!view.HaveShieldedRequirements(tx)) - return state.DoS(100, error("ConnectBlock(): JoinSplit requirements not met"), - REJECT_INVALID, "bad-txns-joinsplit-requirements-not-met"); + return state.DoS(100, error("ConnectBlock(): shielded requirements not met"), REJECT_INVALID, "bad-txns-joinsplit-requirements-not-met"); if (fAddressIndex || fSpentIndex) { @@ -6403,7 +6402,7 @@ bool CVerifyDB::VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth CBlockIndex* pindexFailure = NULL; int nGoodTransactions = 0; CValidationState state; - // No need to verify JoinSplits twice + // No need to verify shielded req's twice auto verifier = libzcash::ProofVerifier::Disabled(); //fprintf(stderr,"start VerifyDB %u\n",(uint32_t)time(NULL)); for (CBlockIndex* pindex = chainActive.Tip(); pindex && pindex->pprev; pindex = pindex->pprev) From 646c68490b5aa87ef50db127fa1ef7dd425425a7 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 17 Jun 2020 17:53:12 -0400 Subject: [PATCH 094/255] cleanup --- src/main.cpp | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index ada7ab8a6..fb53e2c28 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1578,6 +1578,7 @@ bool CheckTransactionWithoutProofVerification(uint32_t tiptime,const CTransactio else if ( joinsplit.vpub_new != 0 && joinsplit.vpub_old == 0 ) z_t++; } + if ( ASSETCHAINS_PRIVATE != 0 && invalid_private_taddr != 0 ) { static uint32_t counter; @@ -3657,23 +3658,12 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin } } - //if ( ASSETCHAINS_SYMBOL[0] == 0 ) - // komodo_earned_interest(pindex->GetHeight(),sum); CTxUndo undoDummy; if (i > 0) { blockundo.vtxundo.push_back(CTxUndo()); } UpdateCoins(tx, view, i == 0 ? undoDummy : blockundo.vtxundo.back(), pindex->GetHeight()); - /* - BOOST_FOREACH(const JSDescription &joinsplit, tx.vjoinsplit) { - BOOST_FOREACH(const uint256 ¬e_commitment, joinsplit.commitments) { - // Insert the note commitments into our temporary tree. - - sprout_tree.append(note_commitment); - } - } - */ BOOST_FOREACH(const OutputDescription &outputDescription, tx.vShieldedOutput) { sapling_tree.append(outputDescription.cm); From 36e917f1d3e1d014deb53e7ec178f13afa954312 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 17 Jun 2020 20:43:58 -0400 Subject: [PATCH 095/255] copyright --- src/rpc/server.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index cfe21a6d5..56c038596 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers -// Copyright (c) 2019 The Hush developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. From 83be5195e93b4977d602ad8f055320858a25e07f Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 17 Jun 2020 20:44:54 -0400 Subject: [PATCH 096/255] Revert "Randomize sietch memos and increase min zouts to 3" This reverts commit a053d212b8e22d1d8ffe08a2e0955f1854055702. --- src/wallet/rpcwallet.cpp | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 221bef44e..867de51a7 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4590,15 +4590,6 @@ UniValue z_getoperationstatus_IMPL(const UniValue& params, bool fRemoveFinishedO #define CTXIN_SPEND_DUST_SIZE 148 #define CTXOUT_REGULAR_SIZE 34 -void random_hex(char str[], int len) -{ - char hex[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'}; - for(int i=0;iMAX_ZOUTS)) { - fprintf(stderr,"%s: Sietch min zouts must be >=%d and <= %d, setting to default value of %d\n", __FUNCTION__, ABSOLUTE_MIN_ZOUTS, MAX_ZOUTS, DEFAULT_MIN_ZOUTS ); + if((MIN_ZOUTS<2) || (MIN_ZOUTS>MAX_ZOUTS)) { + fprintf(stderr,"%s: Sietch min zouts must be >=2 and <= 25, setting to default value of %d\n", __FUNCTION__, DEFAULT_MIN_ZOUTS ); MIN_ZOUTS=DEFAULT_MIN_ZOUTS; } @@ -4748,9 +4739,8 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) // OK, we identify this xtn as needing privacy zdust, we must decide how much, non-deterministically int nAmount = 0; int decider = 1 + GetRandInt(100); // random int between 1 and 100 - char *str; - random_hex(str,512); - string memo = string(str); + string memo = "f600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + string zdust1, zdust2; // Which zaddr we send to is non-deterministically chosen from two zpools... From 4800f497aa9d7f6a496985ecf4756f0c354bd040 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 17 Jun 2020 22:32:00 -0400 Subject: [PATCH 097/255] Fix copyright --- src/wallet/asyncrpcoperation_saplingconsolidation.cpp | 11 +++++++++-- src/wallet/asyncrpcoperation_saplingconsolidation.h | 2 +- src/wallet/wallet.cpp | 3 +-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/wallet/asyncrpcoperation_saplingconsolidation.cpp b/src/wallet/asyncrpcoperation_saplingconsolidation.cpp index 477545348..0c6cae7c1 100644 --- a/src/wallet/asyncrpcoperation_saplingconsolidation.cpp +++ b/src/wallet/asyncrpcoperation_saplingconsolidation.cpp @@ -95,15 +95,22 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() { // an anchor at height N-10 for each SpendDescription // Consider, should notes be sorted? pwalletMain->GetFilteredNotes(saplingEntries, "", 11); + + if(saplingEntries.size() == 0) { + LogPrint("zrpcunsafe", "%s: Nothing to consolidate, done.\n",opid); + return true; + } + if (fConsolidationMapUsed) { const vector& v = mapMultiArgs["-consolidatesaplingaddress"]; for(int i = 0; i < v.size(); i++) { auto zAddress = DecodePaymentAddress(v[i]); if (boost::get(&zAddress) != nullptr) { libzcash::SaplingPaymentAddress saplingAddress = boost::get(zAddress); - addresses.insert(saplingAddress ); + addresses.insert(saplingAddress); } else { - //TODO: how to handle invalid zaddrs? + LogPrint("zrpcunsafe", "%s: Invalid zaddr, exiting\n", opid); + return false; } } } else { diff --git a/src/wallet/asyncrpcoperation_saplingconsolidation.h b/src/wallet/asyncrpcoperation_saplingconsolidation.h index 9a80ff7c7..5d14b9335 100644 --- a/src/wallet/asyncrpcoperation_saplingconsolidation.h +++ b/src/wallet/asyncrpcoperation_saplingconsolidation.h @@ -1,5 +1,5 @@ // Copyright (c) 2020 The Hush developers -// TODO: Forge should add his preferred copyright line here +// Copyright (c) 2019 CryptoForge // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index b3d759f83..c0f449a56 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1733,8 +1733,7 @@ void CWallet::GetSaplingNoteWitnesses(std::vector notes, //fprintf(stderr,"%s: rt=%s\n",__func__,rt.GetHash().ToString().c_str()); //fprintf(stderr,"%s: witnesses[%d]->root()=%s\n",__func__,i,witnesses[i]->root().GetHash().ToString().c_str()); // Something is fucky - std::string err = "CWallet::GetSaplingNoteWitnesses: Invalid witness root! i="; - err += i; + std::string err = "CWallet::GetSaplingNoteWitnesses: Invalid witness root!"; throw std::logic_error(err); } From 9bcf13bf4a7ef40a0a177aee5eb6b0a9a2769f03 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Thu, 18 Jun 2020 05:40:04 -0400 Subject: [PATCH 098/255] report invalid roots --- src/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index c0f449a56..4581dae00 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1733,7 +1733,7 @@ void CWallet::GetSaplingNoteWitnesses(std::vector notes, //fprintf(stderr,"%s: rt=%s\n",__func__,rt.GetHash().ToString().c_str()); //fprintf(stderr,"%s: witnesses[%d]->root()=%s\n",__func__,i,witnesses[i]->root().GetHash().ToString().c_str()); // Something is fucky - std::string err = "CWallet::GetSaplingNoteWitnesses: Invalid witness root!"; + std::string err = std::string("CWallet::GetSaplingNoteWitnesses: Invalid witness root! rt=") + rt.get().ToString(); throw std::logic_error(err); } From a7cd2b375096149f9793a4c5788af237b7b2be68 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Thu, 18 Jun 2020 06:41:26 -0400 Subject: [PATCH 099/255] Chill out on the logspam --- src/wallet/wallet.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 4581dae00..ae845cb21 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1719,22 +1719,24 @@ void CWallet::GetSaplingNoteWitnesses(std::vector notes, boost::optional rt; int i = 0; for (SaplingOutPoint note : notes) { - fprintf(stderr,"%s: i=%d\n", __func__,i); + //fprintf(stderr,"%s: i=%d\n", __func__,i); auto noteData = mapWallet[note.hash].mapSaplingNoteData; auto nWitnesses = noteData[note].witnesses.size(); if (mapWallet.count(note.hash) && noteData.count(note) && nWitnesses > 0) { fprintf(stderr,"%s: Found %lu witnesses for note %s\n", __func__, nWitnesses, note.hash.ToString().c_str() ); witnesses[i] = noteData[note].witnesses.front(); if (!rt) { - fprintf(stderr,"%s: Setting witness root\n",__func__); + //fprintf(stderr,"%s: Setting witness root\n",__func__); rt = witnesses[i]->root(); } else { if(*rt == witnesses[i]->root()) { //fprintf(stderr,"%s: rt=%s\n",__func__,rt.GetHash().ToString().c_str()); //fprintf(stderr,"%s: witnesses[%d]->root()=%s\n",__func__,i,witnesses[i]->root().GetHash().ToString().c_str()); // Something is fucky - std::string err = std::string("CWallet::GetSaplingNoteWitnesses: Invalid witness root! rt=") + rt.get().ToString(); - throw std::logic_error(err); + std::string err = string("CWallet::GetSaplingNoteWitnesses: Invalid witness root! rt=") + rt.get().ToString(); + err += string("\n!= witness[i]->root()=") + witnesses[i]->root().ToString(); + //throw std::logic_error(err); + fprintf(stderr,"%s: IGNORING %s\n", __func__,err.c_str()); } } @@ -1744,6 +1746,7 @@ void CWallet::GetSaplingNoteWitnesses(std::vector notes, // All returned witnesses have the same anchor if (rt) { final_anchor = *rt; + //fprintf(stderr,"%s: final_anchor=%s\n", __func__, rt.get().ToString().c_str() ); } } From 8c0faf62efb1eb3b4163d41b6c2e7b4127fbaf86 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Thu, 18 Jun 2020 10:06:35 -0400 Subject: [PATCH 100/255] Update build instructions --- INSTALL.md | 6 ++---- README.md | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index c47c6ddfe..bb667b7be 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -39,7 +39,7 @@ sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib \ git clone https://github.com/MyHush/hush3.git cd hush3 # Build -./zcutil/build.sh -j$(nproc) +./build.sh -j$(nproc) ``` ## Run a HUSH Node @@ -63,10 +63,8 @@ Downloading Git source repo, building and running Hush: # pull git clone https://github.com/MyHush/hush3.git cd hush -# fetch key -./zcutil/fetch-params.sh # Build -./zcutil/build-win.sh -j$(nproc) +./build-win.sh -j$(nproc) # Run a HUSH node ./src/hushd ``` diff --git a/README.md b/README.md index 1ec5dd7b1..95c8999fe 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# HUSH 3 +# HUSH ## What is HUSH? From 9db4440ec18d1c558628ecd9e9e6de49df4e50ff Mon Sep 17 00:00:00 2001 From: crackfoo Date: Thu, 18 Jun 2020 14:05:58 -0300 Subject: [PATCH 101/255] Update funcs.mk fix tar permissions/ownership on linux for depends Cheers http://zpool.ca --- depends/funcs.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/depends/funcs.mk b/depends/funcs.mk index 3d89de8a7..5d3939348 100644 --- a/depends/funcs.mk +++ b/depends/funcs.mk @@ -92,7 +92,7 @@ $(1)_download_path_fixed=$(subst :,\:,$$($(1)_download_path)) #default commands $(1)_fetch_cmds ?= $(call fetch_file,$(1),$(subst \:,:,$$($(1)_download_path_fixed)),$$($(1)_download_file),$($(1)_file_name),$($(1)_sha256_hash)) -$(1)_extract_cmds ?= mkdir -p $$($(1)_extract_dir) && echo "$$($(1)_sha256_hash) $$($(1)_source)" > $$($(1)_extract_dir)/.$$($(1)_file_name).hash && $(build_SHA256SUM) -c $$($(1)_extract_dir)/.$$($(1)_file_name).hash && tar --strip-components=1 -xf $$($(1)_source) +$(1)_extract_cmds ?= mkdir -p $$($(1)_extract_dir) && echo "$$($(1)_sha256_hash) $$($(1)_source)" > $$($(1)_extract_dir)/.$$($(1)_file_name).hash && $(build_SHA256SUM) -c $$($(1)_extract_dir)/.$$($(1)_file_name).hash && tar --no-same-owner --strip-components=1 -xf $$($(1)_source) $(1)_preprocess_cmds ?= $(1)_build_cmds ?= $(1)_config_cmds ?= From 920667dd73a64958b9aa8ce26b0938db892dceb6 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 23 Jun 2020 12:48:29 -0400 Subject: [PATCH 102/255] Delete tests from ZEC that do not apply to us --- src/Makefile.gtest.include | 4 +- src/gtest/test_foundersreward.cpp | 194 ------------------------------ 2 files changed, 2 insertions(+), 196 deletions(-) delete mode 100644 src/gtest/test_foundersreward.cpp diff --git a/src/Makefile.gtest.include b/src/Makefile.gtest.include index 1f1b511db..66105ca70 100644 --- a/src/Makefile.gtest.include +++ b/src/Makefile.gtest.include @@ -1,4 +1,5 @@ - +# Copyright (c) 2019-2020 Hush developers +# Released under the GPLv3 TESTS += komodo-gtest bin_PROGRAMS += komodo-gtest @@ -9,7 +10,6 @@ komodo_gtest_SOURCES = \ gtest/test_checktransaction.cpp \ gtest/json_test_vectors.cpp \ gtest/json_test_vectors.h \ - # gtest/test_foundersreward.cpp \ gtest/test_wallet_zkeys.cpp \ # These tests are order-dependent, because they # depend on global state (see #1539) diff --git a/src/gtest/test_foundersreward.cpp b/src/gtest/test_foundersreward.cpp deleted file mode 100644 index 7e5a3cf05..000000000 --- a/src/gtest/test_foundersreward.cpp +++ /dev/null @@ -1,194 +0,0 @@ -#include - -#include "main.h" -#include "utilmoneystr.h" -#include "chainparams.h" -#include "utilstrencodings.h" -#include "zcash/Address.hpp" -#include "wallet/wallet.h" -#include "amount.h" -#include -#include -#include -#include -#include -#include "util.h" - -#ifndef disable_founders -// To run tests: -// ./zcash-gtest --gtest_filter="founders_reward_test.*" - -// -// Enable this test to generate and print 48 testnet 2-of-3 multisig addresses. -// The output can be copied into chainparams.cpp. -// The temporary wallet file can be renamed as wallet.dat and used for testing with zcashd. -// -#if 0 -TEST(founders_reward_test, create_testnet_2of3multisig) { - SelectParams(CBaseChainParams::TESTNET); - boost::filesystem::path pathTemp = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path(); - boost::filesystem::create_directories(pathTemp); - mapArgs["-datadir"] = pathTemp.string(); - bool fFirstRun; - auto pWallet = std::make_shared("wallet.dat"); - ASSERT_EQ(DB_LOAD_OK, pWallet->LoadWallet(fFirstRun)); - pWallet->TopUpKeyPool(); - std::cout << "Test wallet and logs saved in folder: " << pathTemp.native() << std::endl; - - int numKeys = 48; - std::vector pubkeys; - pubkeys.resize(3); - CPubKey newKey; - std::vector addresses; - for (int i = 0; i < numKeys; i++) { - ASSERT_TRUE(pWallet->GetKeyFromPool(newKey)); - pubkeys[0] = newKey; - pWallet->SetAddressBook(newKey.GetID(), "", "receive"); - - ASSERT_TRUE(pWallet->GetKeyFromPool(newKey)); - pubkeys[1] = newKey; - pWallet->SetAddressBook(newKey.GetID(), "", "receive"); - - ASSERT_TRUE(pWallet->GetKeyFromPool(newKey)); - pubkeys[2] = newKey; - pWallet->SetAddressBook(newKey.GetID(), "", "receive"); - - CScript result = GetScriptForMultisig(2, pubkeys); - ASSERT_FALSE(result.size() > MAX_SCRIPT_ELEMENT_SIZE); - CScriptID innerID(result); - pWallet->AddCScript(result); - pWallet->SetAddressBook(innerID, "", "receive"); - - std::string address = EncodeDestination(innerID); - addresses.push_back(address); - } - - // Print out the addresses, 4 on each line. - std::string s = "vFoundersRewardAddress = {\n"; - int i=0; - int colsPerRow = 4; - ASSERT_TRUE(numKeys % colsPerRow == 0); - int numRows = numKeys/colsPerRow; - for (int row=0; rowFlush(true); -} -#endif - - -// Utility method to check the number of unique addresses from height 1 to maxHeight -void checkNumberOfUniqueAddresses(int nUnique) { - int maxHeight = Params().GetConsensus().GetLastFoundersRewardBlockHeight(); - std::set addresses; - for (int i = 1; i <= maxHeight; i++) { - addresses.insert(Params().GetFoundersRewardAddressAtHeight(i)); - } - ASSERT_TRUE(addresses.size() == nUnique); -} - - -TEST(founders_reward_test, general) { - SelectParams(CBaseChainParams::TESTNET); - - CChainParams params = Params(); - - // Fourth testnet reward: - // address = t2ENg7hHVqqs9JwU5cgjvSbxnT2a9USNfhy - // script.ToString() = OP_HASH160 55d64928e69829d9376c776550b6cc710d427153 OP_EQUAL - // HexStr(script) = a91455d64928e69829d9376c776550b6cc710d42715387 - EXPECT_EQ(HexStr(params.GetFoundersRewardScriptAtHeight(1)), "a914ef775f1f997f122a062fff1a2d7443abd1f9c64287"); - EXPECT_EQ(params.GetFoundersRewardAddressAtHeight(1), "t2UNzUUx8mWBCRYPRezvA363EYXyEpHokyi"); - EXPECT_EQ(HexStr(params.GetFoundersRewardScriptAtHeight(53126)), "a914ac67f4c072668138d88a86ff21b27207b283212f87"); - EXPECT_EQ(params.GetFoundersRewardAddressAtHeight(53126), "t2NGQjYMQhFndDHguvUw4wZdNdsssA6K7x2"); - EXPECT_EQ(HexStr(params.GetFoundersRewardScriptAtHeight(53127)), "a91455d64928e69829d9376c776550b6cc710d42715387"); - EXPECT_EQ(params.GetFoundersRewardAddressAtHeight(53127), "t2ENg7hHVqqs9JwU5cgjvSbxnT2a9USNfhy"); - - int maxHeight = params.GetConsensus().GetLastFoundersRewardBlockHeight(); - - // If the block height parameter is out of bounds, there is an assert. - EXPECT_DEATH(params.GetFoundersRewardScriptAtHeight(0), "nHeight"); - EXPECT_DEATH(params.GetFoundersRewardScriptAtHeight(maxHeight+1), "nHeight"); - EXPECT_DEATH(params.GetFoundersRewardAddressAtHeight(0), "nHeight"); - EXPECT_DEATH(params.GetFoundersRewardAddressAtHeight(maxHeight+1), "nHeight"); -} - - -#define NUM_MAINNET_FOUNDER_ADDRESSES 48 - -TEST(founders_reward_test, mainnet) { - SelectParams(CBaseChainParams::MAIN); - checkNumberOfUniqueAddresses(NUM_MAINNET_FOUNDER_ADDRESSES); -} - - -#define NUM_TESTNET_FOUNDER_ADDRESSES 48 - -TEST(founders_reward_test, testnet) { - SelectParams(CBaseChainParams::TESTNET); - checkNumberOfUniqueAddresses(NUM_TESTNET_FOUNDER_ADDRESSES); -} - - -#define NUM_REGTEST_FOUNDER_ADDRESSES 1 - -TEST(founders_reward_test, regtest) { - SelectParams(CBaseChainParams::REGTEST); - checkNumberOfUniqueAddresses(NUM_REGTEST_FOUNDER_ADDRESSES); -} - - - -// Test that 10% founders reward is fully rewarded after the first halving and slow start shift. -// On Mainnet, this would be 2,100,000 ZEC after 850,000 blocks (840,000 + 10,000). -TEST(founders_reward_test, slow_start_subsidy) { - SelectParams(CBaseChainParams::MAIN); - CChainParams params = Params(); - - int maxHeight = params.GetConsensus().GetLastFoundersRewardBlockHeight(); - CAmount totalSubsidy = 0; - for (int nHeight = 1; nHeight <= maxHeight; nHeight++) { - CAmount nSubsidy = GetBlockSubsidy(nHeight, params.GetConsensus()) / 5; - totalSubsidy += nSubsidy; - } - - ASSERT_TRUE(totalSubsidy == MAX_MONEY/10.0); -} - - -// For use with mainnet and testnet which each have 48 addresses. -// Verify the number of rewards each individual address receives. -void verifyNumberOfRewards() { - CChainParams params = Params(); - int maxHeight = params.GetConsensus().GetLastFoundersRewardBlockHeight(); - std::multiset ms; - for (int nHeight = 1; nHeight <= maxHeight; nHeight++) { - ms.insert(params.GetFoundersRewardAddressAtHeight(nHeight)); - } - - ASSERT_TRUE(ms.count(params.GetFoundersRewardAddressAtIndex(0)) == 17708); - for (int i = 1; i <= 46; i++) { - ASSERT_TRUE(ms.count(params.GetFoundersRewardAddressAtIndex(i)) == 17709); - } - ASSERT_TRUE(ms.count(params.GetFoundersRewardAddressAtIndex(47)) == 17677); -} - -// Verify the number of rewards going to each mainnet address -TEST(founders_reward_test, per_address_reward_mainnet) { - SelectParams(CBaseChainParams::MAIN); - verifyNumberOfRewards(); -} - -// Verify the number of rewards going to each testnet address -TEST(founders_reward_test, per_address_reward_testnet) { - SelectParams(CBaseChainParams::TESTNET); - verifyNumberOfRewards(); -} -#endif From f03a7b0e7e5ebc87f999376b7ba3df1b10ea81b9 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 23 Jun 2020 12:48:36 -0400 Subject: [PATCH 103/255] Copyright --- src/hush-cli | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hush-cli b/src/hush-cli index bf4511073..9cc47207a 100755 --- a/src/hush-cli +++ b/src/hush-cli @@ -1,5 +1,6 @@ #!/bin/bash -# Copyright (c) 2019 Hush developers +# Copyright (c) 2019-2020 Hush developers +# Released under the GPLv3 # set working directory to the location of this script # readlink -f does not always exist From 828fff6168b4ddce5d430294864136dbe8747ad1 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 23 Jun 2020 12:59:32 -0400 Subject: [PATCH 104/255] Update some tests --- qa/hush/full_test_suite.py | 30 ++++++++++++++++-------------- src/hush-tx | 3 ++- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/qa/hush/full_test_suite.py b/qa/hush/full_test_suite.py index fcbdf0cd8..deee55881 100755 --- a/qa/hush/full_test_suite.py +++ b/qa/hush/full_test_suite.py @@ -1,6 +1,8 @@ #!/usr/bin/env python2 +# Copyright (c) 2019-2020 Hush developers +# Released under the GPLv3 # -# Execute all of the automated tests related to Zcash. +# Execute all of the automated tests related to Hush # import argparse @@ -32,7 +34,7 @@ RE_FORTIFY_USED = re.compile('Binary compiled with FORTIFY_SOURCE support.*Yes') def test_rpath_runpath(filename): output = subprocess.check_output( - [repofile('qa/zcash/checksec.sh'), '--file', repofile(filename)] + [repofile('qa/hush/checksec.sh'), '--file', repofile(filename)] ) if RE_RPATH_RUNPATH.search(output): print('PASS: %s has no RPATH or RUNPATH.' % filename) @@ -44,7 +46,7 @@ def test_rpath_runpath(filename): def test_fortify_source(filename): proc = subprocess.Popen( - [repofile('qa/zcash/checksec.sh'), '--fortify-file', repofile(filename)], + [repofile('qa/hush/checksec.sh'), '--fortify-file', repofile(filename)], stdout=subprocess.PIPE, ) line1 = proc.stdout.readline() @@ -64,24 +66,24 @@ def check_security_hardening(): ret &= subprocess.call(['make', '-C', repofile('src'), 'check-security']) == 0 # The remaining checks are only for ELF binaries - # Assume that if zcashd is an ELF binary, they all are - with open(repofile('src/zcashd'), 'rb') as f: + # Assume that if hushd is an ELF binary, they all are + with open(repofile('src/hushd'), 'rb') as f: magic = f.read(4) if not magic.startswith(b'\x7fELF'): return ret - ret &= test_rpath_runpath('src/zcashd') - ret &= test_rpath_runpath('src/zcash-cli') - ret &= test_rpath_runpath('src/zcash-gtest') - ret &= test_rpath_runpath('src/zcash-tx') + ret &= test_rpath_runpath('src/hushd') + ret &= test_rpath_runpath('src/hush-cli') + ret &= test_rpath_runpath('src/hush-gtest') + ret &= test_rpath_runpath('src/hush-tx') ret &= test_rpath_runpath('src/test/test_bitcoin') # NOTE: checksec.sh does not reliably determine whether FORTIFY_SOURCE # is enabled for the entire binary. See issue #915. - ret &= test_fortify_source('src/zcashd') - ret &= test_fortify_source('src/zcash-cli') - ret &= test_fortify_source('src/zcash-gtest') - ret &= test_fortify_source('src/zcash-tx') + ret &= test_fortify_source('src/hushd') + ret &= test_fortify_source('src/hush-cli') + ret &= test_fortify_source('src/hush-gtest') + ret &= test_fortify_source('src/hush-tx') ret &= test_fortify_source('src/test/test_bitcoin') return ret @@ -144,7 +146,7 @@ STAGES = [ STAGE_COMMANDS = { 'btest': [repofile('src/test/test_bitcoin'), '-p'], - 'gtest': [repofile('src/zcash-gtest')], + 'gtest': [repofile('src/komodo-gtest')], 'sec-hard': check_security_hardening, 'no-dot-so': ensure_no_dot_so_in_depends, 'util-test': util_test, diff --git a/src/hush-tx b/src/hush-tx index 2152315ad..17f8bc6b8 100755 --- a/src/hush-tx +++ b/src/hush-tx @@ -1,5 +1,6 @@ #!/bin/bash -# Copyright (c) 2019 Hush developers +# Copyright (c) 2019-2020 Hush developers +# Released under the GPLv3 # set working directory to the location of this script DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" From 2cf9b80b8c98ebc008993f3d618d96e687940389 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 24 Jun 2020 17:56:50 -0400 Subject: [PATCH 105/255] cleanup --- src/main.cpp | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index fb53e2c28..f7e3fb74e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3976,33 +3976,6 @@ void static UpdateTip(CBlockIndex *pindexNew) { pcoinsTip->DynamicMemoryUsage() * (1.0 / (1<<20)), pcoinsTip->GetCacheSize()); cvBlockChange.notify_all(); - - /* - // https://github.com/zcash/zcash/issues/3992 -> https://github.com/zcash/zcash/commit/346d11d3eb2f8162df0cb00b1d1f49d542495198 - - // Check the version of the last 100 blocks to see if we need to upgrade: - static bool fWarned = false; - if (!IsInitialBlockDownload() && !fWarned) - { - int nUpgraded = 0; - const CBlockIndex* pindex = chainActive.Tip(); - for (int i = 0; i < 100 && pindex != NULL; i++) - { - if (pindex->nVersion > CBlock::CURRENT_VERSION) - ++nUpgraded; - pindex = pindex->pprev; - } - if (nUpgraded > 0) - LogPrintf("%s: %d of last 100 blocks above version %d\n", __func__, nUpgraded, (int)CBlock::CURRENT_VERSION); - if (nUpgraded > 100/2) - { - // strMiscWarning is read by GetWarnings(), called by the JSON-RPC code to warn the user: - strMiscWarning = _("Warning: This version is obsolete; upgrade required!"); - CAlert::Notify(strMiscWarning, true); - fWarned = true; - } - } - */ } /** From e4d2ada7282b36921a9b460fc8fa8e5d01b1d104 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 24 Jun 2020 17:58:03 -0400 Subject: [PATCH 106/255] formatting --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index f7e3fb74e..73f49eb38 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3964,8 +3964,8 @@ void static UpdateTip(CBlockIndex *pindexNew) { if ( ASSETCHAINS_SYMBOL[0] == 0 ) { progress = Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), chainActive.LastTip()); } else { - int32_t longestchain = komodo_longestchain(); - progress = (longestchain > 0 ) ? (double) chainActive.Height() / longestchain : 1.0; + int32_t longestchain = komodo_longestchain(); + progress = (longestchain > 0 ) ? (double) chainActive.Height() / longestchain : 1.0; } LogPrintf("%s: new best=%s height=%d log2_work=%.8g tx=%lu date=%s progress=%f cache=%.1fMiB(%utx)\n", __func__, From bb6565d9661e2405f6ff543ef5256bc8932709f3 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 24 Jun 2020 20:49:53 -0400 Subject: [PATCH 107/255] Block time halving at height 340000 --- src/main.cpp | 22 ++++++++++++++++++---- src/pow.cpp | 5 ++++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 73f49eb38..5b70ed2fd 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3350,6 +3350,8 @@ static int64_t nTimeTotal = 0; bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown = false); bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBlockIndex *pindexNew, const CDiskBlockPos& pos); +int32_t nFirstHalvingHeight = 340000; + bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool fJustCheck,bool fCheckPOW) { CDiskBlockPos blockPos; @@ -3362,15 +3364,20 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin AssertLockHeld(cs_main); bool ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; + + // At startup, HUSH3 doesn't know a block height yet and so we must wait until + // connecting a block to set our private/blocktime flags, which are height-dependent if(!ASSETCHAINS_PRIVATE && ishush3) { unsigned int nHeight = pindex->GetHeight(); - if(nHeight >= 340000) { - // At startup, HUSH3 doesn't know a block height yet and so we must wait until - // connecting a block - fprintf(stderr, "%s: Going full z2z at height %d!\n",__func__,nHeight); + if(nHeight >= nFirstHalvingHeight) { + fprintf(stderr, "%s: Going full z2z at height %d!\n",__func__,pindex->GetHeight()); ASSETCHAINS_PRIVATE = 1; } } + if (ishush3 && (ASSETCHAINS_BLOCKTIME != 75) && (chainActive.Height() >= nFirstHalvingHeight)) { + LogPrintf("%s: Blocktime halving to 75s at height %d!\n",__func__,pindex->GetHeight()); + ASSETCHAINS_BLOCKTIME = 75; + } bool fExpensiveChecks = true; if (fCheckpointsEnabled) { @@ -3968,6 +3975,13 @@ void static UpdateTip(CBlockIndex *pindexNew) { progress = (longestchain > 0 ) ? (double) chainActive.Height() / longestchain : 1.0; } + if(ishush3) { + if (ASSETCHAINS_BLOCKTIME != 75 && (chainActive.Height() >= nFirstHalvingHeight)) { + LogPrintf("%s: Blocktime halving to 75s at height %d!\n",__func__,chainActive.Height()); + ASSETCHAINS_BLOCKTIME = 75; + } + } + LogPrintf("%s: new best=%s height=%d log2_work=%.8g tx=%lu date=%s progress=%f cache=%.1fMiB(%utx)\n", __func__, chainActive.LastTip()->GetBlockHash().ToString(), chainActive.Height(), log(chainActive.Tip()->chainPower.chainWork.getdouble())/log(2.0), diff --git a/src/pow.cpp b/src/pow.cpp index 79c41feb4..6d0262699 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers -// Copyright (c) 2019 The Hush developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -298,6 +298,9 @@ arith_uint256 zawy_TSA_EMA(int32_t height,int32_t tipdiff,arith_uint256 prevTarg unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params) { + if (pindexLast->GetHeight() == 340000) { + LogPrintf("%s: Using blocktime=%d\n",__func__,ASSETCHAINS_BLOCKTIME); + } if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH && ASSETCHAINS_STAKED == 0) return lwmaGetNextWorkRequired(pindexLast, pblock, params); From eb935e3c93c98fba5ca0f37dc0fbc4e7b8aee816 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Thu, 9 Jul 2020 07:22:33 -0400 Subject: [PATCH 108/255] Set correct blocktime when disconnecting a block and rewinding before our block time halving --- src/main.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 5b70ed2fd..2681723c9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -115,6 +115,7 @@ bool fAlerts = DEFAULT_ALERTS; */ int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE; bool ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; +int32_t nFirstHalvingHeight = 340000; unsigned int expiryDelta = DEFAULT_TX_EXPIRY_DELTA; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; @@ -3227,6 +3228,15 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex // move best block pointer to prevout block view.SetBestBlock(pindex->pprev->GetBlockHash()); + // If disconnecting a block brings us back before our blocktime halving height, go back + // to our original blocktime so our DAA has the correct target for that height + int nHeight = pindex->pprev->GetHeight(); + if (ishush3 && (ASSETCHAINS_BLOCKTIME != 150) && (nHeight < nFirstHalvingHeight)) { + LogPrintf("%s: Setting blocktime to 150s at height %d!\n",__func__,nHeight); + ASSETCHAINS_BLOCKTIME = 150; + } + + if (pfClean) { *pfClean = fClean; return true; @@ -3350,7 +3360,6 @@ static int64_t nTimeTotal = 0; bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown = false); bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBlockIndex *pindexNew, const CDiskBlockPos& pos); -int32_t nFirstHalvingHeight = 340000; bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool fJustCheck,bool fCheckPOW) { From e959ea976839041c0d287b7f3e865754596fc1e9 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Thu, 9 Jul 2020 08:35:04 -0400 Subject: [PATCH 109/255] Timedata changes from KMD 0.6 --- src/timedata.cpp | 149 +++++++++++++++-------------------------------- src/timedata.h | 78 +++++++------------------ 2 files changed, 66 insertions(+), 161 deletions(-) diff --git a/src/timedata.cpp b/src/timedata.cpp index 64a3955ff..246159a50 100644 --- a/src/timedata.cpp +++ b/src/timedata.cpp @@ -1,10 +1,11 @@ // Copyright (c) 2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers +// Copyright (c) 2020 The Zcash developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** - * Copyright © 2014-2019 The SuperNET Developers. * + * Copyright © 2014-2020 The SuperNET Developers. * * * * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at * * the top-level directory of this distribution for the individual copyright * @@ -26,114 +27,56 @@ #include "util.h" #include "utilstrencodings.h" -#include - -using namespace std; - -static CCriticalSection cs_nTimeOffset; -static int64_t nTimeOffset = 0; -#define KOMODO_ASSETCHAIN_MAXLEN 65 -extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; +CTimeWarning timeWarning; /** - * "Never go to sea with two chronometers; take one or three." - * Our three time sources are: - * - System clock - * - Median of other nodes clocks - * - The user (asking the user to fix the system clock if the first two disagree) + * Warn if we have seen TIMEDATA_WARNING_SAMPLES peer times, in the version messages of the + * first TIMEDATA_MAX_SAMPLES unique (by IP address) peers that connect, that are more than + * TIMEDATA_WARNING_THRESHOLD seconds but less than TIMEDATA_IGNORE_THRESHOLD seconds away + * from local time. */ -int64_t GetTimeOffset() + +int64_t CTimeWarning::AddTimeData(const CNetAddr& ip, int64_t nTime, int64_t now) { - LOCK(cs_nTimeOffset); + assert(now >= 0 && now <= INT64_MAX - TIMEDATA_IGNORE_THRESHOLD); + + if (nTime <= now - TIMEDATA_IGNORE_THRESHOLD || nTime >= now + TIMEDATA_IGNORE_THRESHOLD) { + return 0; + } + + int64_t nTimeOffset = nTime - now; + + LOCK(cs); + // Ignore duplicate IPs. + if (setKnown.size() == TIMEDATA_MAX_SAMPLES || !setKnown.insert(ip).second) { + return nTimeOffset; + } + + LogPrintf("Added time data, samples %d, offset %+d (%+d minutes)\n", setKnown.size(), nTimeOffset, nTimeOffset/60); + + if (nPeersBehind + nPeersAhead < TIMEDATA_WARNING_SAMPLES) { + if (nTimeOffset < -TIMEDATA_WARNING_THRESHOLD) { + nPeersBehind++; + } else if (nTimeOffset > TIMEDATA_WARNING_THRESHOLD) { + nPeersAhead++; + } + if (nPeersBehind + nPeersAhead == TIMEDATA_WARNING_SAMPLES) { + Warn(nPeersAhead, nPeersBehind); + } + } return nTimeOffset; } -int64_t GetAdjustedTime() +void CTimeWarning::Warn(size_t peersAhead, size_t peersBehind) { - return GetTime() + GetTimeOffset(); -} - -static int64_t abs64(int64_t n) -{ - return (n >= 0 ? n : -n); -} - -#define BITCOIN_TIMEDATA_MAX_SAMPLES 200 - -void AddTimeData(const CNetAddr& ip, int64_t nOffsetSample) -{ - LOCK(cs_nTimeOffset); - // Ignore duplicates - static set setKnown; - if (setKnown.size() == BITCOIN_TIMEDATA_MAX_SAMPLES) - return; - if (!setKnown.insert(ip).second) - return; - - // Add data - static CMedianFilter vTimeOffsets(BITCOIN_TIMEDATA_MAX_SAMPLES, 0); - vTimeOffsets.input(nOffsetSample); - LogPrintf("Added time data, samples %d, offset %+d (%+d minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample/60); - - // There is a known issue here (see issue #4521): - // - // - The structure vTimeOffsets contains up to 200 elements, after which - // any new element added to it will not increase its size, replacing the - // oldest element. - // - // - The condition to update nTimeOffset includes checking whether the - // number of elements in vTimeOffsets is odd, which will never happen after - // there are 200 elements. - // - // But in this case the 'bug' is protective against some attacks, and may - // actually explain why we've never seen attacks which manipulate the - // clock offset. - // - // So we should hold off on fixing this and clean it up as part of - // a timing cleanup that strengthens it in a number of other ways. - // - if (vTimeOffsets.size() >= 5 && vTimeOffsets.size() % 2 == 1) - { - int64_t nMedian = vTimeOffsets.median(); - std::vector vSorted = vTimeOffsets.sorted(); - // Only let other nodes change our time by so much - if (abs64(nMedian) < 30) // thanks to zawy for pointing this out!! zcash issues 4021 //70 * 60) - { - nTimeOffset = nMedian; - } - else - { - nTimeOffset = 0; - - static bool fDone; - if (!fDone) - { - // If nobody has a time different than ours but within 5 minutes of ours, give a warning - bool fMatch = false; - BOOST_FOREACH(int64_t nOffset, vSorted) - if (nOffset != 0 && abs64(nOffset) < 5 * 60) - fMatch = true; - - if (!fMatch) - { - fDone = true; - string strMessage; - if( strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ) { - strMessage = _("Warning: Please check that your computer's date and time are correct! If your clock is wrong Hush will not work properly."); - } else { - strMessage = _("Warning: Please check that your computer's date and time are correct! If your clock is wrong Komodo will not work properly."); - } - strMiscWarning = strMessage; - LogPrintf("*** %s\n", strMessage); - uiInterface.ThreadSafeMessageBox(strMessage, "", CClientUIInterface::MSG_WARNING); - } - } - } - if (fDebug) { - BOOST_FOREACH(int64_t n, vSorted) - LogPrintf("%+d ", n); - LogPrintf("| "); - } - LogPrintf("nTimeOffset = %+d (%+d minutes)\n", nTimeOffset, nTimeOffset/60); + std::string strMessage; + if (peersBehind >= TIMEDATA_WARNING_MAJORITY) { + strMessage = _("Warning: Your computer's date and time may be ahead of the rest of the network! If your clock is wrong Hush will not work properly."); + } else if (peersAhead >= TIMEDATA_WARNING_MAJORITY) { + strMessage = _("Warning: Your computer's date and time may be behind the rest of the network! If your clock is wrong Hush will not work properly."); + } else { + strMessage = _("Warning: Please check that your computer's date and time are correct! If your clock is wrong Hush will not work properly."); } + LogPrintf("*** %s\n", strMessage); + uiInterface.ThreadSafeMessageBox(strMessage, "", CClientUIInterface::MSG_WARNING); } diff --git a/src/timedata.h b/src/timedata.h index 13cff12b3..4ced093b6 100644 --- a/src/timedata.h +++ b/src/timedata.h @@ -1,77 +1,39 @@ // Copyright (c) 2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers +// Copyright (c) 2020 The Zcash developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_TIMEDATA_H #define BITCOIN_TIMEDATA_H -#include -#include +#include #include -#include +#include "netbase.h" +#include "sync.h" -class CNetAddr; - -/** - * Median filter over a stream of values. - * Returns the median of the last N numbers - */ -template -class CMedianFilter +class CTimeWarning { private: - std::vector vValues; - std::vector vSorted; - unsigned int nSize; + CCriticalSection cs; + std::set setKnown; + size_t nPeersAhead; + size_t nPeersBehind; public: - CMedianFilter(unsigned int size, T initial_value) : nSize(size) - { - vValues.reserve(size); - vValues.push_back(initial_value); - vSorted = vValues; - } + static const size_t TIMEDATA_WARNING_SAMPLES = 8; + static const size_t TIMEDATA_WARNING_MAJORITY = 6; + static const size_t TIMEDATA_MAX_SAMPLES = 20; + static const int64_t TIMEDATA_WARNING_THRESHOLD = 10 * 60; + static const int64_t TIMEDATA_IGNORE_THRESHOLD = 10 * 24 * 60 * 60; - void input(T value) - { - if (vValues.size() == nSize) { - vValues.erase(vValues.begin()); - } - vValues.push_back(value); + CTimeWarning() : nPeersBehind(0), nPeersAhead(0) {} + virtual ~CTimeWarning() {} - vSorted.resize(vValues.size()); - std::copy(vValues.begin(), vValues.end(), vSorted.begin()); - std::sort(vSorted.begin(), vSorted.end()); - } - - T median() const - { - int size = vSorted.size(); - assert(size > 0); - if (size & 1) // Odd number of elements - { - return vSorted[size / 2]; - } else // Even number of elements - { - return (vSorted[size / 2 - 1] + vSorted[size / 2]) / 2; - } - } - - int size() const - { - return vValues.size(); - } - - std::vector sorted() const - { - return vSorted; - } + int64_t AddTimeData(const CNetAddr& ip, int64_t nTime, int64_t now); + virtual void Warn(size_t peersAhead, size_t peersBehind); }; -/** Functions to keep track of adjusted P2P time */ -int64_t GetTimeOffset(); -int64_t GetAdjustedTime(); -void AddTimeData(const CNetAddr& ip, int64_t nTime); +extern CTimeWarning timeWarning; #endif // BITCOIN_TIMEDATA_H From d4883bce7c94499fee425ebe472d1b6d9ce36d25 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Thu, 9 Jul 2020 10:31:12 -0400 Subject: [PATCH 110/255] More timedate changes from KMD 0.6 --- src/addrman.cpp | 3 ++- src/addrman.h | 13 +++++++------ src/alert.cpp | 7 ++++--- src/komodo_bitcoind.h | 4 ++-- src/main.cpp | 39 +++++++++++++++++++------------------- src/miner.cpp | 28 +++++++++++++-------------- src/net.cpp | 10 +++++----- src/rpc/misc.cpp | 4 ++-- src/rpc/net.cpp | 11 ++++++----- src/test/addrman_tests.cpp | 12 ++++++------ src/wallet/rpcwallet.cpp | 2 +- src/wallet/wallet.cpp | 15 +++++++-------- 12 files changed, 76 insertions(+), 72 deletions(-) diff --git a/src/addrman.cpp b/src/addrman.cpp index 1c8bf4b7c..3ff108c44 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2012 Pieter Wuille +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -268,7 +269,7 @@ bool CAddrMan::Add_(const CAddress& addr, const CNetAddr& source, int64_t nTimeP if (pinfo) { // periodically update nTime - bool fCurrentlyOnline = (GetAdjustedTime() - addr.nTime < 24 * 60 * 60); + bool fCurrentlyOnline = (GetTime() - addr.nTime < 24 * 60 * 60); int64_t nUpdateInterval = (fCurrentlyOnline ? 60 * 60 : 24 * 60 * 60); if (addr.nTime && (!pinfo->nTime || pinfo->nTime < addr.nTime - nUpdateInterval - nTimePenalty)) pinfo->nTime = std::max((int64_t)0, addr.nTime - nTimePenalty); diff --git a/src/addrman.h b/src/addrman.h index 0390b4e9b..b23ab5aa3 100644 --- a/src/addrman.h +++ b/src/addrman.h @@ -1,6 +1,7 @@ // Copyright (c) 2012 Pieter Wuille +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -112,10 +113,10 @@ public: int GetBucketPosition(const uint256 &nKey, bool fNew, int nBucket) const; //! Determine whether the statistics about this entry are bad enough so that it can just be deleted - bool IsTerrible(int64_t nNow = GetAdjustedTime()) const; + bool IsTerrible(int64_t nNow = GetTime()) const; //! Calculate the relative chance this entry should be given when selecting nodes to connect to - double GetChance(int64_t nNow = GetAdjustedTime()) const; + double GetChance(int64_t nNow = GetTime()) const; }; @@ -530,7 +531,7 @@ public: } //! Mark an entry as accessible. - void Good(const CService &addr, int64_t nTime = GetAdjustedTime()) + void Good(const CService &addr, int64_t nTime = GetTime()) { { LOCK(cs); @@ -541,7 +542,7 @@ public: } //! Mark an entry as connection attempted to. - void Attempt(const CService &addr, int64_t nTime = GetAdjustedTime()) + void Attempt(const CService &addr, int64_t nTime = GetTime()) { { LOCK(cs); @@ -580,7 +581,7 @@ public: } //! Mark an entry as currently-connected-to. - void Connected(const CService &addr, int64_t nTime = GetAdjustedTime()) + void Connected(const CService &addr, int64_t nTime = GetTime()) { { LOCK(cs); diff --git a/src/alert.cpp b/src/alert.cpp index 99f6472e9..db70cd620 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -1,7 +1,8 @@ // Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -117,7 +118,7 @@ uint256 CAlert::GetHash() const bool CAlert::IsInEffect() const { - return (GetAdjustedTime() < nExpiration); + return (GetTime() < nExpiration); } bool CAlert::Cancels(const CAlert& alert) const @@ -152,7 +153,7 @@ bool CAlert::RelayTo(CNode* pnode) const { if (AppliesTo(pnode->nVersion, pnode->strSubVer) || AppliesToMe() || - GetAdjustedTime() < nRelayUntil) + GetTime() < nRelayUntil) { pnode->PushMessage("alert", *this); return true; diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index e1748c191..930d7ddf8 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1535,8 +1535,8 @@ uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeigh //fprintf(stderr,"blocktime.%u -> ",blocktime); if ( blocktime < prevtime+3 ) blocktime = prevtime+3; - if ( blocktime < GetAdjustedTime()-60 ) - blocktime = GetAdjustedTime()+30; + if ( blocktime < GetTime()-60 ) + blocktime = GetTime()+30; //fprintf(stderr,"blocktime.%u txtime.%u\n",blocktime,txtime); } if ( value == 0 || txtime == 0 || blocktime == 0 || prevtime == 0 ) diff --git a/src/main.cpp b/src/main.cpp index 2681723c9..ea7fa7a1f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1000,7 +1000,7 @@ bool CheckFinalTx(const CTransaction &tx, int flags) // However this changes once median past time-locks are enforced: const int64_t nBlockTime = (flags & LOCKTIME_MEDIAN_TIME_PAST) ? chainActive.Tip()->GetMedianTimePast() - : GetAdjustedTime(); + : GetTime(); return IsFinalTx(tx, nBlockHeight, nBlockTime); } @@ -3297,7 +3297,7 @@ void PartitionCheck(bool (*initialDownloadCheck)(), CCriticalSection& cs, const if (bestHeader == NULL || initialDownloadCheck()) return; static int64_t lastAlertTime = 0; - int64_t now = GetAdjustedTime(); + int64_t now = GetTime(); if (lastAlertTime > now-60*60*24) return; // Alert at most once per day const int SPAN_HOURS=4; @@ -3307,7 +3307,7 @@ void PartitionCheck(bool (*initialDownloadCheck)(), CCriticalSection& cs, const boost::math::poisson_distribution poisson(BLOCKS_EXPECTED); std::string strWarning; - int64_t startTime = GetAdjustedTime()-SPAN_SECONDS; + int64_t startTime = GetTime()-SPAN_SECONDS; LOCK(cs); const CBlockIndex* i = bestHeader; @@ -5119,28 +5119,28 @@ bool CheckBlockHeader(int32_t *futureblockp,int32_t height,CBlockIndex *pindex, *futureblockp = 0; if ( ASSETCHAINS_ADAPTIVEPOW > 0 ) { - if (blockhdr.GetBlockTime() > GetAdjustedTime() + 4) + if (blockhdr.GetBlockTime() > GetTime() + 4) { - //LogPrintf("CheckBlockHeader block from future %d error",blockhdr.GetBlockTime() - GetAdjustedTime()); + //LogPrintf("CheckBlockHeader block from future %d error",blockhdr.GetBlockTime() - GetTime()); return false; } } - else if (blockhdr.GetBlockTime() > GetAdjustedTime() + 60) + else if (blockhdr.GetBlockTime() > GetTime() + 60) { /*CBlockIndex *tipindex; - //fprintf(stderr,"ht.%d future block %u vs time.%u + 60\n",height,(uint32_t)blockhdr.GetBlockTime(),(uint32_t)GetAdjustedTime()); - if ( (tipindex= chainActive.Tip()) != 0 && tipindex->GetBlockHash() == blockhdr.hashPrevBlock && blockhdr.GetBlockTime() < GetAdjustedTime() + 60 + 5 ) + //fprintf(stderr,"ht.%d future block %u vs time.%u + 60\n",height,(uint32_t)blockhdr.GetBlockTime(),(uint32_t)GetTime()); + if ( (tipindex= chainActive.Tip()) != 0 && tipindex->GetBlockHash() == blockhdr.hashPrevBlock && blockhdr.GetBlockTime() < GetTime() + 60 + 5 ) { - //fprintf(stderr,"it is the next block, let's wait for %d seconds\n",GetAdjustedTime() + 60 - blockhdr.GetBlockTime()); - while ( blockhdr.GetBlockTime() > GetAdjustedTime() + 60 ) + //fprintf(stderr,"it is the next block, let's wait for %d seconds\n",GetTime() + 60 - blockhdr.GetBlockTime()); + while ( blockhdr.GetBlockTime() > GetTime() + 60 ) sleep(1); //fprintf(stderr,"now its valid\n"); } else*/ { - if (blockhdr.GetBlockTime() < GetAdjustedTime() + 300) + if (blockhdr.GetBlockTime() < GetTime() + 300) *futureblockp = 1; - //LogPrintf("CheckBlockHeader block from future %d error",blockhdr.GetBlockTime() - GetAdjustedTime()); + //LogPrintf("CheckBlockHeader block from future %d error",blockhdr.GetBlockTime() - GetTime()); return false; //state.Invalid(error("CheckBlockHeader(): block timestamp too far in the future"),REJECT_INVALID, "time-too-new"); } } @@ -5388,7 +5388,7 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta } // Check that timestamp is not too far in the future - if (block.GetBlockTime() > GetAdjustedTime() + consensusParams.nMaxFutureBlockTime) + if (block.GetBlockTime() > GetTime() + consensusParams.nMaxFutureBlockTime) { return state.Invalid(error("%s: block timestamp too far in the future", __func__), REJECT_INVALID, "time-too-new"); @@ -7406,9 +7406,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, pfrom->nStartingHeight, addrMe.ToString(), pfrom->id, remoteAddr); - int64_t nTimeOffset = nTime - GetTime(); - pfrom->nTimeOffset = nTimeOffset; - AddTimeData(pfrom->addr, nTimeOffset); + //int64_t nTimeOffset = nTime - GetTime(); + //pfrom->nTimeOffset = nTimeOffset; + //AddTimeData(pfrom->addr, nTimeOffset); + pfrom->nTimeOffset = timeWarning.AddTimeData(pfrom->addr, nTime, GetTime()); } @@ -7484,7 +7485,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, // Store the new addresses vector vAddrOk; - int64_t nNow = GetAdjustedTime(); + int64_t nNow = GetTime(); int64_t nSince = nNow - 10 * 60; BOOST_FOREACH(CAddress& addr, vAddr) { @@ -7694,7 +7695,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, // not a direct successor. pfrom->PushMessage("getheaders", chainActive.GetLocator(pindexBestHeader), inv.hash); CNodeState *nodestate = State(pfrom->GetId()); - if (chainActive.Tip()->GetBlockTime() > GetAdjustedTime() - chainparams.GetConsensus().nPowTargetSpacing * 20 && + if (chainActive.Tip()->GetBlockTime() > GetTime() - chainparams.GetConsensus().nPowTargetSpacing * 20 && nodestate->nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) { vToFetch.push_back(inv); // Mark block as in flight already, even though the actual "getdata" message only goes out @@ -8457,7 +8458,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) bool fFetch = state.fPreferredDownload || (nPreferredDownload == 0 && !pto->fClient && !pto->fOneShot); // Download if this is a nice peer, or we have no nice peers and this one might do. if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex && pindexBestHeader!=0) { // Only actively request headers from a single peer, unless we're close to today. - if ((nSyncStarted == 0 && fFetch) || pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) { + if ((nSyncStarted == 0 && fFetch) || pindexBestHeader->GetBlockTime() > GetTime() - 24 * 60 * 60) { state.fSyncStarted = true; nSyncStarted++; CBlockIndex *pindexStart = pindexBestHeader->pprev ? pindexBestHeader->pprev : pindexBestHeader; diff --git a/src/miner.cpp b/src/miner.cpp index a91fa9527..4ab19638b 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -1,8 +1,8 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers -// Copyright (c) 2019 The Hush developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -126,8 +126,8 @@ extern int8_t ASSETCHAINS_ADAPTIVEPOW; void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev) { if ( ASSETCHAINS_ADAPTIVEPOW <= 0 ) - pblock->nTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); - else pblock->nTime = std::max((int64_t)(pindexPrev->nTime+1), GetAdjustedTime()); + pblock->nTime = std::max(pindexPrev->GetMedianTimePast()+1, GetTime()); + else pblock->nTime = std::max((int64_t)(pindexPrev->nTime+1), GetTime()); // Updating time can change work required on testnet: if (ASSETCHAINS_ADAPTIVEPOW > 0 || consensusParams.nPowAllowMinDifficultyBlocksAfterHeight != boost::none) @@ -239,7 +239,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 bool sapling = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING); const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); - uint32_t proposedTime = GetAdjustedTime(); + uint32_t proposedTime = GetTime(); voutsum = GetBlockSubsidy(nHeight,consensusParams) + 10000*COIN; // approx fees if (proposedTime == nMedianTimePast) @@ -248,12 +248,12 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 // forward as quickly as possible for (int i; i < 100; i++) { - proposedTime = GetAdjustedTime(); + proposedTime = GetTime(); if (proposedTime == nMedianTimePast) MilliSleep(10); } } - pblock->nTime = GetAdjustedTime(); + pblock->nTime = GetTime(); // Now we have the block time + height, we can get the active notaries. int8_t numSN = 0; uint8_t notarypubkeys[64][33] = {0}; if ( ASSETCHAINS_NOTARY_PAY[0] != 0 ) @@ -603,8 +603,8 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 nLastBlockTx = nBlockTx; nLastBlockSize = nBlockSize; if ( ASSETCHAINS_ADAPTIVEPOW <= 0 ) - blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); - else blocktime = 1 + std::max((int64_t)(pindexPrev->nTime+1), GetAdjustedTime()); + blocktime = 1 + std::max(pindexPrev->GetMedianTimePast()+1, GetTime()); + else blocktime = 1 + std::max((int64_t)(pindexPrev->nTime+1), GetTime()); //pblock->nTime = blocktime + 1; pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus()); @@ -624,8 +624,8 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 //fprintf(stderr,"mine ht.%d with %.8f\n",nHeight,(double)txNew.vout[0].nValue/COIN); txNew.nExpiryHeight = 0; if ( ASSETCHAINS_ADAPTIVEPOW <= 0 ) - txNew.nLockTime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime()); - else txNew.nLockTime = std::max((int64_t)(pindexPrev->nTime+1), GetAdjustedTime()); + txNew.nLockTime = std::max(pindexPrev->GetMedianTimePast()+1, GetTime()); + else txNew.nLockTime = std::max((int64_t)(pindexPrev->nTime+1), GetTime()); if ( ASSETCHAINS_SYMBOL[0] == 0 && IS_KOMODO_NOTARY != 0 && My_notaryid >= 0 ) @@ -1368,10 +1368,10 @@ void static BitcoinMiner() // MilliSleep(30); return false; } - if ( IS_KOMODO_NOTARY != 0 && B.nTime > GetAdjustedTime() ) + if ( IS_KOMODO_NOTARY != 0 && B.nTime > GetTime() ) { - //fprintf(stderr,"need to wait %d seconds to submit block\n",(int32_t)(B.nTime - GetAdjustedTime())); - while ( GetAdjustedTime() < B.nTime-2 ) + //fprintf(stderr,"need to wait %d seconds to submit block\n",(int32_t)(B.nTime - GetTime())); + while ( GetTime() < B.nTime-2 ) { sleep(1); if ( chainActive.LastTip()->GetHeight() >= Mining_height ) diff --git a/src/net.cpp b/src/net.cpp index efb69bfe9..5be64b291 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers -// Copyright (c) 2019 The Hush developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -193,7 +193,7 @@ CAddress GetLocalAddress(const CNetAddr *paddrPeer) ret = CAddress(addr); } ret.nServices = nLocalServices; - ret.nTime = GetAdjustedTime(); + ret.nTime = GetTime(); return ret; } @@ -393,7 +393,7 @@ CNode* ConnectNode(CAddress addrConnect, const char *pszDest) /// debug print LogPrint("net", "trying connection %s lastseen=%.1fhrs\n", pszDest ? pszDest : addrConnect.ToString(), - pszDest ? 0.0 : (double)(GetAdjustedTime() - addrConnect.nTime)/3600.0); + pszDest ? 0.0 : (double)(GetTime() - addrConnect.nTime)/3600.0); // Connect SOCKET hSocket; @@ -458,7 +458,7 @@ void CNode::PushVersion() { int nBestHeight = g_signals.GetHeight().get_value_or(0); - int64_t nTime = (fInbound ? GetAdjustedTime() : GetTime()); + int64_t nTime = (fInbound ? GetTime() : GetTime()); CAddress addrYou = (addr.IsRoutable() && !IsProxy(addr) ? addr : CAddress(CService("0.0.0.0",0))); CAddress addrMe = GetLocalAddress(&addr); GetRandBytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce)); @@ -1429,7 +1429,7 @@ void ThreadOpenConnections() } } - int64_t nANow = GetAdjustedTime(); + int64_t nANow = GetTime(); int nTries = 0; while (true) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index a41a8169d..d741a9748 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -206,7 +206,7 @@ UniValue getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk) " \"walletversion\": xxxxx, (numeric) the wallet version\n" " \"balance\": xxxxxxx, (numeric) the total Hush balance of the wallet\n" " \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n" - " \"timeoffset\": xxxxx, (numeric) the time offset\n" + " \"timeoffset\": xxxxx, (numeric) the time offset (deprecated, always 0)\n" " \"connections\": xxxxx, (numeric) the number of connections\n" " \"proxy\": \"host:port\", (string, optional) the proxy used by the server\n" " \"difficulty\": xxxxxx, (numeric) the current difficulty\n" @@ -286,7 +286,7 @@ UniValue getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk) #endif obj.push_back(Pair("sapling", ASSETCHAINS_SAPLING)); } - obj.push_back(Pair("timeoffset", GetTimeOffset())); + obj.push_back(Pair("timeoffset", 0)); obj.push_back(Pair("connections", (int)vNodes.size())); obj.push_back(Pair("proxy", (proxy.IsValid() ? proxy.proxy.ToStringIPPort() : string()))); obj.push_back(Pair("testnet", Params().TestnetToBeDeprecatedFieldRPC())); diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index 39e080d86..c93f6a409 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -1,6 +1,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -108,7 +109,7 @@ UniValue getpeerinfo(const UniValue& params, bool fHelp, const CPubKey& mypk) " \"bytessent\": n, (numeric) The total bytes sent\n" " \"bytesrecv\": n, (numeric) The total bytes received\n" " \"conntime\": ttt, (numeric) The connection time in seconds since epoch (Jan 1 1970 GMT)\n" - " \"timeoffset\": ttt, (numeric) The time offset in seconds\n" + " \"timeoffset\": ttt, (numeric) The time offset in seconds (deprecated, always 0)\n" " \"pingtime\": n, (numeric) ping time\n" " \"pingwait\": n, (numeric) ping wait\n" " \"version\": v, (numeric) The peer version, such as 170002\n" @@ -151,7 +152,7 @@ UniValue getpeerinfo(const UniValue& params, bool fHelp, const CPubKey& mypk) obj.push_back(Pair("bytessent", stats.nSendBytes)); obj.push_back(Pair("bytesrecv", stats.nRecvBytes)); obj.push_back(Pair("conntime", stats.nTimeConnected)); - obj.push_back(Pair("timeoffset", stats.nTimeOffset)); + obj.push_back(Pair("timeoffset", 0)); obj.push_back(Pair("pingtime", stats.dPingTime)); if (stats.dPingWait > 0.0) obj.push_back(Pair("pingwait", stats.dPingWait)); @@ -502,7 +503,7 @@ UniValue getnetworkinfo(const UniValue& params, bool fHelp, const CPubKey& mypk) " \"subversion\": \"/MagicBean:x.y.z[-v]/\", (string) the server subversion string\n" " \"protocolversion\": xxxxx, (numeric) the protocol version\n" " \"localservices\": \"xxxxxxxxxxxxxxxx\", (string) the services we offer to the network\n" - " \"timeoffset\": xxxxx, (numeric) the time offset\n" + " \"timeoffset\": xxxxx, (numeric) the time offset (deprecated, always 0)\n" " \"connections\": xxxxx, (numeric) the number of connections\n" " \"networks\": [ (array) information per network\n" " {\n" @@ -536,7 +537,7 @@ UniValue getnetworkinfo(const UniValue& params, bool fHelp, const CPubKey& mypk) obj.push_back(Pair("subversion", strSubVersion)); obj.push_back(Pair("protocolversion",PROTOCOL_VERSION)); obj.push_back(Pair("localservices", strprintf("%016x", nLocalServices))); - obj.push_back(Pair("timeoffset", GetTimeOffset())); + obj.push_back(Pair("timeoffset", 0)); obj.push_back(Pair("connections", (int)vNodes.size())); obj.push_back(Pair("networks", GetNetworksInfo())); obj.push_back(Pair("relayfee", ValueFromAmount(::minRelayTxFee.GetFeePerK()))); diff --git a/src/test/addrman_tests.cpp b/src/test/addrman_tests.cpp index fc0600dfc..612802445 100644 --- a/src/test/addrman_tests.cpp +++ b/src/test/addrman_tests.cpp @@ -345,15 +345,15 @@ BOOST_AUTO_TEST_CASE(addrman_getaddr) BOOST_CHECK(vAddr1.size() == 0); CAddress addr1 = CAddress(CService("250.250.2.1", 8333)); - addr1.nTime = GetAdjustedTime(); // Set time so isTerrible = false + addr1.nTime = GetTime(); // Set time so isTerrible = false CAddress addr2 = CAddress(CService("250.251.2.2", 9999)); - addr2.nTime = GetAdjustedTime(); + addr2.nTime = GetTime(); CAddress addr3 = CAddress(CService("251.252.2.3", 8333)); - addr3.nTime = GetAdjustedTime(); + addr3.nTime = GetTime(); CAddress addr4 = CAddress(CService("252.253.3.4", 8333)); - addr4.nTime = GetAdjustedTime(); + addr4.nTime = GetTime(); CAddress addr5 = CAddress(CService("252.254.4.5", 8333)); - addr5.nTime = GetAdjustedTime(); + addr5.nTime = GetTime(); CNetAddr source1 = CNetAddr("250.1.2.1"); CNetAddr source2 = CNetAddr("250.2.3.3"); @@ -381,7 +381,7 @@ BOOST_AUTO_TEST_CASE(addrman_getaddr) CAddress addr = CAddress(CService(strAddr)); // Ensure that for all addrs in addrman, isTerrible == false. - addr.nTime = GetAdjustedTime(); + addr.nTime = GetTime(); addrman.Add(addr, CNetAddr(strAddr)); if (i % 8 == 0) addrman.Good(addr); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 867de51a7..ed4d64f31 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -1345,7 +1345,7 @@ UniValue movecmd(const UniValue& params, bool fHelp, const CPubKey& mypk) if (!walletdb.TxnBegin()) throw JSONRPCError(RPC_DATABASE_ERROR, "database error"); - int64_t nNow = GetAdjustedTime(); + int64_t nNow = GetTime(); // Debit CAccountingEntry debit; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index ae845cb21..ad52964be 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -472,12 +472,13 @@ void CWallet::ChainTip(const CBlockIndex *pindex, boost::optional> added) { if (added) { - // Prevent witness cache building && consolidation transactions + bool initialDownloadCheck = IsInitialBlockDownload(); + // Prevent witness cache building && consolidation transactions // from being created when node is syncing after launch, // and also when node wakes up from suspension/hibernation and incoming blocks are old. - bool initialDownloadCheck = IsInitialBlockDownload(); + // 144 blocks = 3hrs @ 75s blocktime if (!initialDownloadCheck && - pblock->GetBlockTime() > GetAdjustedTime() - 8640) //Last 144 blocks 2.4 * 60 * 60 + pblock->GetBlockTime() > GetTime() - 144*ASSETCHAINS_BLOCKTIME) { BuildWitnessCache(pindex, false); RunSaplingConsolidation(pindex->GetHeight()); @@ -1373,10 +1374,9 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletD bool fInsertedNew = ret.second; if (fInsertedNew) { - wtx.nTimeReceived = GetAdjustedTime(); - wtx.nOrderPos = IncOrderPosNext(pwalletdb); - - wtx.nTimeSmart = wtx.nTimeReceived; + wtx.nTimeReceived = GetTime(); + wtx.nOrderPos = IncOrderPosNext(pwalletdb); + wtx.nTimeSmart = wtx.nTimeReceived; if (!wtxIn.hashBlock.IsNull()) { if (mapBlockIndex.count(wtxIn.hashBlock)) @@ -1385,7 +1385,6 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn, bool fFromLoadWallet, CWalletD int64_t latestEntry = 0; { // Tolerate times up to the last timestamp in the wallet not more than 5 minutes into the future - // TODO: this is 2 blocktimes, which will become 150? int64_t latestTolerated = latestNow + 300; std::list acentries; TxItems txOrdered = OrderedTxItems(acentries); From 55890a05430c2ec3a500d71b2a983918c1312ac3 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 11 Jul 2020 01:19:08 -0400 Subject: [PATCH 111/255] Set various chain params when changing blocktime --- src/main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index ea7fa7a1f..00d470573 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3234,6 +3234,8 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex if (ishush3 && (ASSETCHAINS_BLOCKTIME != 150) && (nHeight < nFirstHalvingHeight)) { LogPrintf("%s: Setting blocktime to 150s at height %d!\n",__func__,nHeight); ASSETCHAINS_BLOCKTIME = 150; + Params.GetConsensus().nMaxFutureBlockTime = 7 * ASSETCHAINS_BLOCKTIME; + Params.GetConsensus().nPowTargetSpacing = ASSETCHAINS_BLOCKTIME; } @@ -3386,6 +3388,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin if (ishush3 && (ASSETCHAINS_BLOCKTIME != 75) && (chainActive.Height() >= nFirstHalvingHeight)) { LogPrintf("%s: Blocktime halving to 75s at height %d!\n",__func__,pindex->GetHeight()); ASSETCHAINS_BLOCKTIME = 75; + Params.GetConsensus().nMaxFutureBlockTime = 7 * ASSETCHAINS_BLOCKTIME; + Params.GetConsensus().nPowTargetSpacing = ASSETCHAINS_BLOCKTIME; } bool fExpensiveChecks = true; @@ -3988,6 +3992,8 @@ void static UpdateTip(CBlockIndex *pindexNew) { if (ASSETCHAINS_BLOCKTIME != 75 && (chainActive.Height() >= nFirstHalvingHeight)) { LogPrintf("%s: Blocktime halving to 75s at height %d!\n",__func__,chainActive.Height()); ASSETCHAINS_BLOCKTIME = 75; + Params.GetConsensus().nMaxFutureBlockTime = 7 * ASSETCHAINS_BLOCKTIME; + Params.GetConsensus().nPowTargetSpacing = ASSETCHAINS_BLOCKTIME; } } From d516a21d54aed18aa678b4f556fe28758b6b286b Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 11 Jul 2020 11:10:15 -0400 Subject: [PATCH 112/255] Create setter to modify blocktime consensus params at run-time --- src/chainparams.cpp | 8 ++++++++ src/chainparams.h | 1 + src/main.cpp | 12 +++++------- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 0a2b819e7..f14e2d9ef 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -544,6 +544,14 @@ int32_t MAX_BLOCK_SIZE(int32_t height) else return(2000000); } +// Change the Hush blocktime at run-time(!) +void hush_changeblocktime() +{ + pCurrentParams->consensus.nMaxFutureBlockTime = 7 * ASSETCHAINS_BLOCKTIME; + pCurrentParams->consensus.nPowTargetSpacing = ASSETCHAINS_BLOCKTIME; + fprintf(stderr,"HUSH blocktime changing to %d seconds\n",ASSETCHAINS_BLOCKTIME); +} + void komodo_setactivation(int32_t height) { pCurrentParams->consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight = height; diff --git a/src/chainparams.h b/src/chainparams.h index daa16af8c..7bd1057ec 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -1,5 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/main.cpp b/src/main.cpp index 00d470573..d4426e181 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -85,6 +85,7 @@ int32_t komodo_block2pubkey33(uint8_t *pubkey33,CBlock *block); //void komodo_broadcast(CBlock *pblock,int32_t limit); bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey); void komodo_setactivation(int32_t height); +void hush_changeblocktime(); void komodo_pricesupdate(int32_t height,CBlock *pblock); BlockMap mapBlockIndex; @@ -3233,9 +3234,8 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex int nHeight = pindex->pprev->GetHeight(); if (ishush3 && (ASSETCHAINS_BLOCKTIME != 150) && (nHeight < nFirstHalvingHeight)) { LogPrintf("%s: Setting blocktime to 150s at height %d!\n",__func__,nHeight); - ASSETCHAINS_BLOCKTIME = 150; - Params.GetConsensus().nMaxFutureBlockTime = 7 * ASSETCHAINS_BLOCKTIME; - Params.GetConsensus().nPowTargetSpacing = ASSETCHAINS_BLOCKTIME; + ASSETCHAINS_BLOCKTIME = 150; + hush_changeblocktime(); } @@ -3388,8 +3388,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin if (ishush3 && (ASSETCHAINS_BLOCKTIME != 75) && (chainActive.Height() >= nFirstHalvingHeight)) { LogPrintf("%s: Blocktime halving to 75s at height %d!\n",__func__,pindex->GetHeight()); ASSETCHAINS_BLOCKTIME = 75; - Params.GetConsensus().nMaxFutureBlockTime = 7 * ASSETCHAINS_BLOCKTIME; - Params.GetConsensus().nPowTargetSpacing = ASSETCHAINS_BLOCKTIME; + hush_changeblocktime(); } bool fExpensiveChecks = true; @@ -3992,8 +3991,7 @@ void static UpdateTip(CBlockIndex *pindexNew) { if (ASSETCHAINS_BLOCKTIME != 75 && (chainActive.Height() >= nFirstHalvingHeight)) { LogPrintf("%s: Blocktime halving to 75s at height %d!\n",__func__,chainActive.Height()); ASSETCHAINS_BLOCKTIME = 75; - Params.GetConsensus().nMaxFutureBlockTime = 7 * ASSETCHAINS_BLOCKTIME; - Params.GetConsensus().nPowTargetSpacing = ASSETCHAINS_BLOCKTIME; + hush_changeblocktime(); } } From 40f0745fabdd46a7b79b94e981caa7c6c2af18f0 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 11 Jul 2020 11:11:14 -0400 Subject: [PATCH 113/255] Track shielded spends on disk so we can calculate anonset in real-time correctly --- src/chain.h | 15 ++++++++++++--- src/consensus/params.h | 3 ++- src/komodo-tx.cpp | 1 + src/main.cpp | 6 ++++-- src/rpc/blockchain.cpp | 3 ++- src/txdb.cpp | 1 + 6 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/chain.h b/src/chain.h index 03fc75660..77d17114e 100644 --- a/src/chain.h +++ b/src/chain.h @@ -1,6 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers -// Copyright (c) 2019 The Hush developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -276,9 +276,12 @@ public: //! inputs and outputs. int64_t nShieldedTx; - //! (memory only) Number of shielded outputs in the block up to and including this block. + //! (memory only) Number of shielded outputs int64_t nShieldedOutputs; + //! (memory only) Number of shielded spends + int64_t nShieldedSpends; + //! (memory only) Number of fully shielded transactions. A fully shielded transaction is defined //! as a transaction containing JoinSplits and only shielded inputs and outputs, i.e. no transparent // inputs or outputs: z->z or z->(z,z) or z->(z,z,z,) etc... @@ -332,6 +335,9 @@ public: //! (memory only) Number of shielded outputs in the chain up to and including this block. int64_t nChainShieldedOutputs; + //! (memory only) Number of shielded spends in the chain up to and including this block. + int64_t nChainShieldedSpends; + //! (memory only) Number of fully shielded transactions. A fully shielded transaction is defined //! as a transaction containing JoinSplits and only shielded inputs and outputs, i.e. no transparent // inputs or outputs: z->z or z->(z,z) or z->(z,z,z,) etc... @@ -429,18 +435,20 @@ public: nChainNotarizations = 0; nChainFullyShieldedTx = 0; nChainShieldedOutputs = 0; + nChainShieldedSpends = 0; nChainShieldedPayments = 0; nChainShieldingPayments = 0; nChainDeshieldingPayments = 0; nChainFullyShieldedPayments = 0; - // Shieldex Index stats + // Shielded Index stats nPayments = 0; nShieldedTx = 0; nShieldingTx = 0; nNotarizations = 0; nDeshieldingTx = 0; nShieldedOutputs = 0; + nShieldedSpends = 0; nFullyShieldedTx = 0; nShieldedPayments = 0; nShieldingPayments = 0; @@ -679,6 +687,7 @@ public: READWRITE(nDeshieldingPayments); READWRITE(nFullyShieldedPayments); READWRITE(nShieldedOutputs); + READWRITE(nShieldedSpends); } } diff --git a/src/consensus/params.h b/src/consensus/params.h index 67d84af0b..e4242ad33 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -1,7 +1,8 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/komodo-tx.cpp b/src/komodo-tx.cpp index 7e0477eb7..0f0b59421 100644 --- a/src/komodo-tx.cpp +++ b/src/komodo-tx.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/main.cpp b/src/main.cpp index d4426e181..0dc0cf87e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4734,7 +4734,7 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl CAmount sproutValue = 0; CAmount saplingValue = 0; bool isShieldedTx = false; - unsigned int nShieldedSpends=0,nShieldedOutputs=0,nPayments=0, nShieldedOutputsInBlock=0; + unsigned int nShieldedSpends=0,nShieldedSpendsInBlock=0,nShieldedOutputs=0,nPayments=0, nShieldedOutputsInBlock=0; unsigned int nShieldedTx=0,nFullyShieldedTx=0,nDeshieldingTx=0,nShieldingTx=0; unsigned int nShieldedPayments=0,nFullyShieldedPayments=0,nShieldingPayments=0,nDeshieldingPayments=0; unsigned int nNotarizations=0; @@ -4822,8 +4822,9 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl // No shielded payments, add transparent payments minus a change address nPayments += tx.vout.size() > 1 ? tx.vout.size()-1 : tx.vout.size(); } - // To calculate the anonset we must track the sum of zouts in every tx, in every block. -- Duke + // To calculate the anonset we must track the sum of spends and zouts in every tx, in every block. -- Duke nShieldedOutputsInBlock += nShieldedOutputs; + nShieldedSpendsInBlock += nShieldedSpends; } pindexNew->nSproutValue = sproutValue; @@ -4840,6 +4841,7 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl pindexNew->nPayments = nPayments; pindexNew->nShieldedTx = nShieldedTx; pindexNew->nShieldedOutputs = nShieldedOutputsInBlock; + pindexNew->nShieldedSpends = nShieldedSpendsInBlock; pindexNew->nFullyShieldedTx = nFullyShieldedTx; pindexNew->nDeshieldingTx = nDeshieldingTx; pindexNew->nShieldingTx = nShieldingTx; diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index faed5b957..3bdce7eb2 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -2003,8 +2003,9 @@ UniValue getchaintxstats(const UniValue& params, bool fHelp, const CPubKey& mypk ret.pushKV("shielding_payments", (int64_t)pindex->nChainShieldingPayments); int64_t nullifierCount = pwalletMain->NullifierCount(); + //TODO: this is unreliable, is only a cache or subset of total nullifiers ret.pushKV("nullifiers", (int64_t)nullifierCount); - ret.pushKV("shielded_pool_size", (int64_t)pindex->nChainShieldedOutputs - nullifierCount); + ret.pushKV("shielded_pool_size", (int64_t)(pindex->nChainShieldedOutputs - pindex->nChainShieldedSpends)); ret.pushKV("shielded_outputs", (int64_t)pindex->nChainShieldedOutputs); } diff --git a/src/txdb.cpp b/src/txdb.cpp index 6fe8bd575..78769c07c 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -723,6 +723,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts() pindexNew->nPayments = diskindex.nPayments; pindexNew->nShieldedTx = diskindex.nShieldedTx; pindexNew->nShieldedOutputs = diskindex.nShieldedOutputs; + pindexNew->nShieldedSpends = diskindex.nShieldedSpends; pindexNew->nShieldedPayments = diskindex.nShieldedPayments; pindexNew->nShieldingTx = diskindex.nShieldingTx; pindexNew->nShieldingPayments = diskindex.nShieldingPayments; From 9544bd0ffcb60165ec1efc8f25aeb6dfc1521ea7 Mon Sep 17 00:00:00 2001 From: miodragpop Date: Sun, 12 Jul 2020 11:47:00 +0200 Subject: [PATCH 114/255] adjustments for cross build of aarch64 binaries on x86_64 linux --- configure.ac | 47 +- depends/.gitignore | 1 + depends/Makefile | 1 + depends/config.site.in | 3 + depends/funcs.mk | 11 +- depends/packages/bdb.mk | 5 + depends/packages/libcurl.mk | 2 +- depends/packages/librustzcash.mk | 18 +- depends/packages/packages.mk | 2 - depends/packages/proton.mk | 7 +- depends/packages/rust.mk | 51 +- depends/patches/proton/minimal-build.patch | 530 +++++++++--------- src/Makefile.am | 6 +- src/cc/Makefile_custom | 5 + src/cc/makecustom | 2 +- src/cryptoconditions/Makefile.am | 2 +- .../src/include/secp256k1/Makefile.am | 2 +- zcutil/build-cross-aarch64.sh | 64 +++ 18 files changed, 450 insertions(+), 309 deletions(-) mode change 100755 => 100644 src/cc/Makefile_custom mode change 100755 => 100644 src/cc/makecustom create mode 100644 zcutil/build-cross-aarch64.sh diff --git a/configure.ac b/configure.ac index e3be0c9dd..f0474aec0 100644 --- a/configure.ac +++ b/configure.ac @@ -334,11 +334,11 @@ case $host in dnl AC_CHECK_PROG([BREW],brew, brew) dnl if test x$BREW = xbrew; then - dnl These Homebrew packages may be keg-only, meaning that they won't be found - dnl in expected paths because they may conflict with system files. Ask - dnl Homebrew where each one is located, then adjust paths accordingly. - dnl It's safe to add these paths even if the functionality is disabled by - dnl the user (--without-wallet for example). + dnl These Homebrew packages may be keg-only, meaning that they won't be found + dnl in expected paths because they may conflict with system files. Ask + dnl Homebrew where each one is located, then adjust paths accordingly. + dnl It's safe to add these paths even if the functionality is disabled by + dnl the user (--without-wallet for example). dnl openssl_prefix=`$BREW --prefix openssl 2>/dev/null` dnl bdb_prefix=`$BREW --prefix berkeley-db4 2>/dev/null` @@ -507,15 +507,24 @@ if test x$use_hardening != xno; then HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -D_FORTIFY_SOURCE=2" ],[AC_MSG_ERROR(Cannot enable -D_FORTIFY_SOURCE=2)]) - #AX_CHECK_LINK_FLAG([[-Wl,-z,relro]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,relro"],[AC_MSG_ERROR(Cannot enable RELRO)]) - #AX_CHECK_LINK_FLAG([[-Wl,-z,now]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"],[AC_MSG_ERROR(Cannot enable BIND_NOW)]) + if test x$BUILD_OS = xdarwin || test x$TARGET_OS = xwindows; then + # Xcode's ld (at least ld64-302.3) doesn't support -z + # mingw-w64's ld (at least mingw-w64 4.0.4-2) also appears to not support -z + AX_CHECK_LINK_FLAG([[-Wl,-z,relro]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,relro"],[AC_MSG_WARN(Cannot enable RELRO)]) + AX_CHECK_LINK_FLAG([[-Wl,-z,now]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"],[AC_MSG_WARN(Cannot enable BIND_NOW)]) + else + AX_CHECK_LINK_FLAG([[-Wl,-z,relro]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,relro"],[AC_MSG_ERROR(Cannot enable RELRO)]) + AX_CHECK_LINK_FLAG([[-Wl,-z,now]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"],[AC_MSG_ERROR(Cannot enable BIND_NOW)]) + fi if test x$TARGET_OS != xwindows; then # All windows code is PIC, forcing it on just adds useless compile warnings - AX_CHECK_LINK_FLAG([[-Wl,-z,relro]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,relro"],[AC_MSG_ERROR(Cannot enable RELRO)]) - AX_CHECK_LINK_FLAG([[-Wl,-z,now]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"],[AC_MSG_ERROR(Cannot enable BIND_NOW)]) - AX_CHECK_COMPILE_FLAG([-fPIE],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fPIE"],[AC_MSG_ERROR(Cannot enable -fPIE)]) - AX_CHECK_LINK_FLAG([[-pie]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -pie"],[AC_MSG_ERROR(Cannot enable -pie)]) + AX_CHECK_COMPILE_FLAG([-fPIE],[PIE_FLAGS="-fPIE"],[AC_MSG_ERROR(Cannot enable -fPIE)]) + if test x$BUILD_OS = xdarwin; then + AX_CHECK_LINK_FLAG([[-Wl,-pie]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-pie"],[AC_MSG_ERROR(Cannot enable -Wl,-pie)]) + else + AX_CHECK_LINK_FLAG([[-pie]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -pie"],[AC_MSG_ERROR(Cannot enable -pie)]) + fi else # These are only available on Windows. AX_CHECK_LINK_FLAG([[-Wl,--dynamicbase]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--dynamicbase"],[AC_MSG_ERROR(Cannot enable --dynamicbase)]) @@ -700,7 +709,7 @@ if test x$use_pkgconfig = xyes; then ) else # BUG: Fix this: - echo 'BUG: configure does not yet check for the following dependencies if pkg-config is not on the system: libcrypto++, gmp' + echo 'BUG: configure does not yet check for the following dependencies if pkg-config is not on the system: libcrypto++, libgmp' AC_CHECK_HEADER([openssl/crypto.h],,AC_MSG_ERROR(libcrypto headers missing)) AC_CHECK_LIB([crypto], [main],CRYPTO_LIBS=-lcrypto, AC_MSG_ERROR(libcrypto missing)) @@ -756,6 +765,14 @@ fi fi fi +# These packages don't provide pkgconfig config files across all +# platforms, so we use older autoconf detection mechanisms: +AC_CHECK_HEADER([gmp.h],,AC_MSG_ERROR(libgmp headers missing)) +AC_CHECK_LIB([gmp],[[__gmpn_sub_n]],GMP_LIBS=-lgmp, [AC_MSG_ERROR(libgmp missing)]) + +AC_CHECK_HEADER([gmpxx.h],,AC_MSG_ERROR(libgmpxx headers missing)) +AC_CHECK_LIB([gmpxx],[main],GMPXX_LIBS=-lgmpxx, [AC_MSG_ERROR(libgmpxx missing)]) + RUST_LIBS="-lrustzcash" case $host in *mingw*) @@ -950,7 +967,7 @@ case $host in ;; esac -echo +echo echo "Options used to compile and link:" echo " with wallet = $enable_wallet" echo " with proton = $use_proton" @@ -958,7 +975,7 @@ echo " with zmq = $use_zmq" echo " with test = $use_tests" echo " debug enabled = $enable_debug" echo " werror = $enable_werror" -echo +echo echo " target os = $TARGET_OS" echo " build os = $BUILD_OS" echo @@ -969,4 +986,4 @@ echo " CXX = $CXX" echo " CXXFLAGS = $CXXFLAGS" echo " LDFLAGS = $LDFLAGS" echo " ARFLAGS = $ARFLAGS" -echo +echo diff --git a/depends/.gitignore b/depends/.gitignore index 1f163897b..3cb4b9ac1 100644 --- a/depends/.gitignore +++ b/depends/.gitignore @@ -7,3 +7,4 @@ x86_64* i686* mips* arm* +aarch64* diff --git a/depends/Makefile b/depends/Makefile index 636577d13..9d53bd1be 100644 --- a/depends/Makefile +++ b/depends/Makefile @@ -112,6 +112,7 @@ $(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_ -e 's|@CXXFLAGS@|$(strip $(host_CXXFLAGS) $(host_$(release_type)_CXXFLAGS))|' \ -e 's|@CPPFLAGS@|$(strip $(host_CPPFLAGS) $(host_$(release_type)_CPPFLAGS))|' \ -e 's|@LDFLAGS@|$(strip $(host_LDFLAGS) $(host_$(release_type)_LDFLAGS))|' \ + -e 's|@rust_target@|$(call rust_target,rust,$(canonical_host),$(host_os))|' \ -e 's|@no_wallet@|$(NO_WALLET)|' \ -e 's|@debug@|$(DEBUG)|' \ $< > $@ diff --git a/depends/config.site.in b/depends/config.site.in index 8cdbcd2e4..dbcb7a6e4 100644 --- a/depends/config.site.in +++ b/depends/config.site.in @@ -13,6 +13,9 @@ if test -z $enable_wallet && test -n "@no_wallet@"; then enable_wallet=no fi +RUST_TARGET="@rust_target@" +RUST_VENDORED_SOURCES="$depends_prefix/vendored-sources" + if test x@host_os@ = xdarwin; then BREW=no PORT=no diff --git a/depends/funcs.mk b/depends/funcs.mk index 3d89de8a7..35ca5abcf 100644 --- a/depends/funcs.mk +++ b/depends/funcs.mk @@ -40,7 +40,7 @@ endef define vendor_crate_source mkdir -p $($(1)_staging_prefix_dir)/$(CRATE_REGISTRY) && \ -cp -r $($(1)_extract_dir) $($(1)_staging_prefix_dir)/$(CRATE_REGISTRY)/$($(1)_crate_name) && \ +cp -r $($(1)_extract_dir) $($(1)_staging_prefix_dir)/$(CRATE_REGISTRY)/$($(1)_crate_versioned_name) && \ cd $($(1)_staging_prefix_dir)/$(CRATE_REGISTRY)/$($(1)_crate_versioned_name) && \ rm -r `basename $($(1)_patch_dir)` .stamp_* .$($(1)_file_name).hash endef @@ -59,8 +59,8 @@ $(eval $(1)_build_id:=$(shell echo -n "$($(1)_build_id_long)" | $(build_SHA256SU final_build_id_long+=$($(package)_build_id_long) #override platform specific files and hashes -$(eval $(1)_file_name=$(if $($(1)_file_name_$(host_os)),$($(1)_file_name_$(host_os)),$($(1)_file_name))) -$(eval $(1)_sha256_hash=$(if $($(1)_sha256_hash_$(host_os)),$($(1)_sha256_hash_$(host_os)),$($(1)_sha256_hash))) +$(eval $(1)_file_name=$(if $($(1)_exact_file_name),$($(1)_exact_file_name),$(if $($(1)_file_name_$(host_os)),$($(1)_file_name_$(host_os)),$($(1)_file_name)))) +$(eval $(1)_sha256_hash=$(if $($(1)_exact_sha256_hash),$($(1)_exact_sha256_hash),$(if $($(1)_sha256_hash_$(host_os)),$($(1)_sha256_hash_$(host_os)),$($(1)_sha256_hash)))) #compute package-specific paths $(1)_build_subdir?=. @@ -91,8 +91,9 @@ $(1)_download_path_fixed=$(subst :,\:,$$($(1)_download_path)) #default commands +# The default behavior for tar will try to set ownership when running as uid 0 and may not succeed, --no-same-owner disables this behavior $(1)_fetch_cmds ?= $(call fetch_file,$(1),$(subst \:,:,$$($(1)_download_path_fixed)),$$($(1)_download_file),$($(1)_file_name),$($(1)_sha256_hash)) -$(1)_extract_cmds ?= mkdir -p $$($(1)_extract_dir) && echo "$$($(1)_sha256_hash) $$($(1)_source)" > $$($(1)_extract_dir)/.$$($(1)_file_name).hash && $(build_SHA256SUM) -c $$($(1)_extract_dir)/.$$($(1)_file_name).hash && tar --strip-components=1 -xf $$($(1)_source) +$(1)_extract_cmds ?= mkdir -p $$($(1)_extract_dir) && echo "$$($(1)_sha256_hash) $$($(1)_source)" > $$($(1)_extract_dir)/.$$($(1)_file_name).hash && $(build_SHA256SUM) -c $$($(1)_extract_dir)/.$$($(1)_file_name).hash && tar --no-same-owner --strip-components=1 -xf $$($(1)_source) $(1)_preprocess_cmds ?= $(1)_build_cmds ?= $(1)_config_cmds ?= @@ -193,7 +194,7 @@ $($(1)_preprocessed): | $($(1)_dependencies) $($(1)_extracted) $(AT)touch $$@ $($(1)_configured): | $($(1)_preprocessed) $(AT)echo Configuring $(1)... - $(AT)rm -rf $(host_prefix); mkdir -p $(host_prefix)/lib; cd $(host_prefix); $(foreach package,$($(1)_all_dependencies), tar xf $($(package)_cached); ) + $(AT)rm -rf $(host_prefix); mkdir -p $(host_prefix)/lib; cd $(host_prefix); $(foreach package,$($(1)_all_dependencies), tar --no-same-owner -xf $($(package)_cached); ) $(AT)mkdir -p $$(@D) $(AT)+cd $$(@D); $($(1)_config_env) $(call $(1)_config_cmds, $(1)) $(AT)touch $$@ diff --git a/depends/packages/bdb.mk b/depends/packages/bdb.mk index 404d94c51..c8f677490 100644 --- a/depends/packages/bdb.mk +++ b/depends/packages/bdb.mk @@ -9,6 +9,11 @@ define $(package)_set_vars $(package)_config_opts=--disable-shared --enable-cxx --disable-replication $(package)_config_opts_mingw32=--enable-mingw $(package)_config_opts_linux=--with-pic +$(package)_config_opts_freebsd=--with-pic +ifneq ($(build_os),darwin) +$(package)_config_opts_darwin=--disable-atomicsupport +endif +$(package)_config_opts_aarch64=--disable-atomicsupport $(package)_cxxflags=-std=c++11 endef diff --git a/depends/packages/libcurl.mk b/depends/packages/libcurl.mk index fd82dc4e0..91ff1c0f1 100644 --- a/depends/packages/libcurl.mk +++ b/depends/packages/libcurl.mk @@ -4,7 +4,7 @@ $(package)_dependencies=openssl $(package)_download_path=https://curl.haxx.se/download $(package)_file_name=curl-$($(package)_version).tar.gz $(package)_sha256_hash=52af3361cf806330b88b4fe6f483b6844209d47ae196ac46da4de59bb361ab02 -$(package)_config_opts_linux=--disable-shared --enable-static --prefix=$(host_prefix) --host=x86_64-unknown-linux-gnu +$(package)_config_opts_linux=--disable-shared --enable-static --prefix=$(host_prefix) --host=$(host) $(package)_config_opts_mingw32=--enable-mingw --disable-shared --enable-static --prefix=$(host_prefix) --host=x86_64-w64-mingw32 $(package)_config_opts_darwin=--disable-shared --enable-static --prefix=$(host_prefix) $(package)_cflags_darwin=-mmacosx-version-min=10.9 diff --git a/depends/packages/librustzcash.mk b/depends/packages/librustzcash.mk index 8612ac05a..fe6ef8a58 100644 --- a/depends/packages/librustzcash.mk +++ b/depends/packages/librustzcash.mk @@ -8,15 +8,29 @@ $(package)_git_commit=06da3b9ac8f278e5d4ae13088cf0a4c03d2c13f5 $(package)_dependencies=rust $(rust_crates) $(package)_patches=cargo.config 0001-Start-using-cargo-clippy-for-CI.patch remove-dev-dependencies.diff no-groth16.patch +$(package)_rust_target=$(if $(rust_rust_target_$(canonical_host)),$(rust_rust_target_$(canonical_host)),$(canonical_host)) + ifeq ($(host_os),mingw32) $(package)_library_file=target/x86_64-pc-windows-gnu/release/rustzcash.lib +else ifneq ($(canonical_host),$(build)) +ifeq ($(host_os),darwin) +$(package)_library_file=target/x86_64-apple-darwin/release/librustzcash.a +else +$(package)_library_file=target/$($(package)_rust_target)/release/librustzcash.a +endif else $(package)_library_file=target/release/librustzcash.a endif define $(package)_set_vars $(package)_build_opts=--frozen --release -$(package)_build_opts_mingw32=--target=x86_64-pc-windows-gnu +ifneq ($(canonical_host),$(build)) +ifeq ($(host_os),darwin) +$(package)_build_opts+=--target=x86_64-apple-darwin +else +$(package)_build_opts+=--target=$($(package)_rust_target) +endif +endif endef define $(package)_preprocess_cmds @@ -27,7 +41,7 @@ define $(package)_preprocess_cmds endef define $(package)_build_cmds - cargo build --package librustzcash $($(package)_build_opts) + $(host_prefix)/native/bin/cargo build --package librustzcash $($(package)_build_opts) endef define $(package)_stage_cmds diff --git a/depends/packages/packages.mk b/depends/packages/packages.mk index 8abb7c708..8a56f73f3 100644 --- a/depends/packages/packages.mk +++ b/depends/packages/packages.mk @@ -1,5 +1,3 @@ -rust_packages := rust librustzcash - ifeq ($(build_os),darwin) zcash_packages := libgmp libsodium utfcpp else diff --git a/depends/packages/proton.mk b/depends/packages/proton.mk index 1bb5c8865..d974fa5fa 100644 --- a/depends/packages/proton.mk +++ b/depends/packages/proton.mk @@ -1,8 +1,8 @@ package=proton -$(package)_version=0.26.0 +$(package)_version=0.30.0 $(package)_download_path=https://archive.apache.org/dist/qpid/proton/$($(package)_version) $(package)_file_name=qpid-proton-$($(package)_version).tar.gz -$(package)_sha256_hash=0eddac870f0085b9aeb0c9da333bd3f53fedb7c872164171a7cc06761ddbbd75 +$(package)_sha256_hash=e37fd8fb13391c3996f927839969a8f66edf35612392d0611eeac6e39e48dd33 $(package)_patches=minimal-build.patch define $(package)_preprocess_cmds @@ -11,7 +11,7 @@ define $(package)_preprocess_cmds endef define $(package)_config_cmds - cd build; cmake .. -DCMAKE_CXX_STANDARD=11 -DCMAKE_INSTALL_PREFIX=/ -DSYSINSTALL_BINDINGS=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_PYTHON=OFF -DBUILD_PHP=OFF -DBUILD_JAVA=OFF -DBUILD_PERL=OFF -DBUILD_RUBY=OFF -DBUILD_JAVASCRIPT=OFF -DBUILD_GO=OFF -DBUILD_STATIC_LIBS=ON + cd build; cmake .. -DCMAKE_CXX_STANDARD=11 -DCMAKE_INSTALL_PREFIX=/ -DSYSINSTALL_BINDINGS=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_PYTHON=OFF -DBUILD_RUBY=OFF -DBUILD_GO=OFF -DBUILD_STATIC_LIBS=ON -DLIB_SUFFIX= -DENABLE_JSONCPP= endef define $(package)_build_cmds @@ -21,3 +21,4 @@ endef define $(package)_stage_cmds cd build; $(MAKE) VERBOSE=1 DESTDIR=$($(package)_staging_prefix_dir) install endef + diff --git a/depends/packages/rust.mk b/depends/packages/rust.mk index 9cfb95054..2546a733e 100644 --- a/depends/packages/rust.mk +++ b/depends/packages/rust.mk @@ -1,28 +1,33 @@ package=rust -$(package)_version=1.32.0 +$(package)_version=1.42.0 $(package)_download_path=https://static.rust-lang.org/dist - $(package)_file_name_linux=rust-$($(package)_version)-x86_64-unknown-linux-gnu.tar.gz -$(package)_sha256_hash_linux=e024698320d76b74daf0e6e71be3681a1e7923122e3ebd03673fcac3ecc23810 +$(package)_sha256_hash_linux=7d1e07ad9c8a33d8d039def7c0a131c5917aa3ea0af3d0cc399c6faf7b789052 $(package)_file_name_darwin=rust-$($(package)_version)-x86_64-apple-darwin.tar.gz -$(package)_sha256_hash_darwin=f0dfba507192f9b5c330b5984ba71d57d434475f3d62bd44a39201e36fa76304 -$(package)_file_name_mingw32=rust-$($(package)_version)-x86_64-pc-windows-gnu.tar.gz -$(package)_sha256_hash_mingw32=358e1435347c67dbf33aa9cad6fe501a833d6633ed5d5aa1863d5dffa0349be9 +$(package)_sha256_hash_darwin=db1055c46e0d54b99da05e88c71fea21b3897e74a4f5ff9390e934f3f050c0a8 +$(package)_file_name_freebsd=rust-$($(package)_version)-x86_64-unknown-freebsd.tar.gz +$(package)_sha256_hash_freebsd=230bcf17e4383fba85d3c87fe25d17737459fe561a5f4668fe70dcac2da4e17c -ifeq ($(build_os),darwin) -$(package)_file_name=$($(package)_file_name_darwin) -$(package)_sha256_hash=$($(package)_sha256_hash_darwin) -else ifeq ($(host_os),mingw32) -$(package)_file_name=$($(package)_file_name_mingw32) -$(package)_sha256_hash=$($(package)_sha256_hash_mingw32) -else -$(package)_file_name=$($(package)_file_name_linux) -$(package)_sha256_hash=$($(package)_sha256_hash_linux) -endif +# Mapping from GCC canonical hosts to Rust targets +# If a mapping is not present, we assume they are identical, unless $host_os is +# "darwin", in which case we assume x86_64-apple-darwin. +$(package)_rust_target_x86_64-w64-mingw32=x86_64-pc-windows-gnu -ifeq ($(host_os),mingw32) +# Mapping from Rust targets to SHA-256 hashes +$(package)_rust_std_sha256_hash_aarch64-unknown-linux-gnu=1343f51fc87049327233cee8941629c3d7dfdc425d359385f93665de3d46711b +$(package)_rust_std_sha256_hash_x86_64-apple-darwin=1d61e9ed5d29e1bb4c18e13d551c6d856c73fb8b410053245dc6e0d3b3a0e92c +$(package)_rust_std_sha256_hash_x86_64-pc-windows-gnu=8a8389f3860df6f42fbf8b76a62ddc7b9b6fe6d0fb526dcfc42faab1005bfb6d + +define rust_target +$(if $($(1)_rust_target_$(2)),$($(1)_rust_target_$(2)),$(if $(findstring darwin,$(3)),x86_64-apple-darwin,$(2))) +endef + +ifneq ($(canonical_host),$(build)) +$(package)_rust_target=$(call rust_target,$(package),$(canonical_host),$(host_os)) +$(package)_exact_file_name=rust-std-$($(package)_version)-$($(package)_rust_target).tar.gz +$(package)_exact_sha256_hash=$($(package)_rust_std_sha256_hash_$($(package)_rust_target)) $(package)_build_subdir=buildos -$(package)_extra_sources = $($(package)_file_name_$(build_os)) +$(package)_extra_sources=$($(package)_file_name_$(build_os)) define $(package)_fetch_cmds $(call fetch_file,$(package),$($(package)_download_path),$($(package)_download_file),$($(package)_file_name),$($(package)_sha256_hash)) && \ @@ -34,19 +39,19 @@ define $(package)_extract_cmds echo "$($(package)_sha256_hash) $($(package)_source)" > $($(package)_extract_dir)/.$($(package)_file_name).hash && \ echo "$($(package)_sha256_hash_$(build_os)) $($(package)_source_dir)/$($(package)_file_name_$(build_os))" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ $(build_SHA256SUM) -c $($(package)_extract_dir)/.$($(package)_file_name).hash && \ - mkdir mingw32 && \ - tar --strip-components=1 -xf $($(package)_source) -C mingw32 && \ + mkdir $(canonical_host) && \ + tar --strip-components=1 -xf $($(package)_source) -C $(canonical_host) && \ mkdir buildos && \ tar --strip-components=1 -xf $($(package)_source_dir)/$($(package)_file_name_$(build_os)) -C buildos endef define $(package)_stage_cmds - ./install.sh --destdir=$($(package)_staging_dir) --prefix=$(host_prefix)/native --disable-ldconfig && \ - cp -r ../mingw32/rust-std-x86_64-pc-windows-gnu/lib/rustlib/x86_64-pc-windows-gnu $($(package)_staging_dir)$(host_prefix)/native/lib/rustlib + bash ./install.sh --destdir=$($(package)_staging_dir) --prefix=$(host_prefix)/native --disable-ldconfig && \ + ../$(canonical_host)/install.sh --destdir=$($(package)_staging_dir) --prefix=$(host_prefix)/native --disable-ldconfig endef else define $(package)_stage_cmds - ./install.sh --destdir=$($(package)_staging_dir) --prefix=$(host_prefix)/native --disable-ldconfig + bash ./install.sh --destdir=$($(package)_staging_dir) --prefix=$(host_prefix)/native --disable-ldconfig endef endif diff --git a/depends/patches/proton/minimal-build.patch b/depends/patches/proton/minimal-build.patch index 90588929f..dd138d2f6 100644 --- a/depends/patches/proton/minimal-build.patch +++ b/depends/patches/proton/minimal-build.patch @@ -1,288 +1,314 @@ -From 03f5fc0826115edbfca468261b70c0daf627f488 Mon Sep 17 00:00:00 2001 -From: Simon -Date: Thu, 27 Apr 2017 17:15:59 -0700 -Subject: [PATCH] Enable C++11, build static library and cpp bindings with minimal dependencies. - ---- - CMakeLists.txt | 13 +++++++------ - examples/cpp/CMakeLists.txt | 1 + - proton-c/CMakeLists.txt | 32 +++++++++++++++---------------- - proton-c/bindings/CMakeLists.txt | 6 +++--- - proton-c/bindings/cpp/CMakeLists.txt | 24 +++++++++++------------ - proton-c/bindings/cpp/docs/CMakeLists.txt | 2 +- - proton-c/docs/api/CMakeLists.txt | 2 +- - 7 files changed, 41 insertions(+), 39 deletions(-) - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index b538ffd..4a5e787 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -18,14 +18,15 @@ - # - cmake_minimum_required (VERSION 2.8.7) +diff -ur a/c/CMakeLists.txt b/c/CMakeLists.txt +--- a/c/CMakeLists.txt 2019-12-09 07:17:00.000000000 -0700 ++++ b/c/CMakeLists.txt 2020-01-08 16:15:26.837987469 -0700 +@@ -428,18 +428,18 @@ + # Can't use target_link_libraries() because cmake 2.8.12 doesn't allow object libraries as the first param + # otherwise for cmake 3.9 and on this would be: + # target_link_libraries (qpid-proton-core-objects ${SSL_LIB} ${SASL_LIB} ${TIME_LIB} ${PLATFORM_LIBS}) +-target_compile_definitions(qpid-proton-core-objects PRIVATE $) +-target_compile_options (qpid-proton-core-objects PRIVATE $) +-target_include_directories(qpid-proton-core-objects PRIVATE $) +- +-add_library (qpid-proton-core SHARED $) +-target_link_libraries (qpid-proton-core ${SSL_LIB} ${SASL_LIB} ${TIME_LIB} ${PLATFORM_LIBS}) +-set_target_properties (qpid-proton-core +- PROPERTIES +- VERSION "${PN_LIB_CORE_VERSION}" +- SOVERSION "${PN_LIB_CORE_MAJOR_VERSION}" +- LINK_FLAGS "${CATCH_UNDEFINED} ${LTO}" +-) ++#target_compile_definitions(qpid-proton-core-objects PRIVATE $) ++#target_compile_options (qpid-proton-core-objects PRIVATE $) ++#target_include_directories(qpid-proton-core-objects PRIVATE $) ++ ++#add_library (qpid-proton-core SHARED $) ++#target_link_libraries (qpid-proton-core ${SSL_LIB} ${SASL_LIB} ${TIME_LIB} ${PLATFORM_LIBS}) ++#set_target_properties (qpid-proton-core ++# PROPERTIES ++# VERSION "${PN_LIB_CORE_VERSION}" ++# SOVERSION "${PN_LIB_CORE_MAJOR_VERSION}" ++# LINK_FLAGS "${CATCH_UNDEFINED} ${LTO}" ++#) -+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - project (Proton C) + if (BUILD_STATIC_LIBS) + add_library (qpid-proton-core-static STATIC ${qpid-proton-core-src}) +@@ -454,14 +454,14 @@ + ${qpid-proton-include-extra} + ) - # Enable C++ now for examples and bindings subdirectories, but make it optional. - enable_language(CXX OPTIONAL) +-add_library (qpid-proton SHARED $ ${qpid-proton-noncore-src}) +-target_link_libraries (qpid-proton LINK_PRIVATE ${SSL_LIB} ${SASL_LIB} ${TIME_LIB} ${PLATFORM_LIBS} ${PROACTOR_LIBS}) +-set_target_properties (qpid-proton +- PROPERTIES +- VERSION "${PN_LIB_LEGACY_VERSION}" +- SOVERSION "${PN_LIB_LEGACY_MAJOR_VERSION}" +- LINK_FLAGS "${CATCH_UNDEFINED} ${LTO}" +-) ++# add_library (qpid-proton SHARED $ ${qpid-proton-noncore-src}) ++# target_link_libraries (qpid-proton LINK_PRIVATE ${SSL_LIB} ${SASL_LIB} ${TIME_LIB} ${PLATFORM_LIBS} ${PROACTOR_LIBS}) ++# set_target_properties (qpid-proton ++# PROPERTIES ++# VERSION "${PN_LIB_LEGACY_VERSION}" ++# SOVERSION "${PN_LIB_LEGACY_MAJOR_VERSION}" ++# LINK_FLAGS "${CATCH_UNDEFINED} ${LTO}" ++# ) + + if (BUILD_STATIC_LIBS) + add_library(qpid-proton-static STATIC ${qpid-proton-core-src} ${qpid-proton-noncore-src}) +@@ -482,15 +482,15 @@ + + if (qpid-proton-proactor) + set(HAS_PROACTOR True) +- add_library (qpid-proton-proactor SHARED ${qpid-proton-proactor}) +- target_link_libraries (qpid-proton-proactor LINK_PUBLIC qpid-proton-core) +- target_link_libraries (qpid-proton-proactor LINK_PRIVATE ${PLATFORM_LIBS} ${PROACTOR_LIBS}) +- set_target_properties (qpid-proton-proactor +- PROPERTIES +- VERSION "${PN_LIB_PROACTOR_VERSION}" +- SOVERSION "${PN_LIB_PROACTOR_MAJOR_VERSION}" +- LINK_FLAGS "${CATCH_UNDEFINED} ${LTO}" +- ) ++ # add_library (qpid-proton-proactor SHARED ${qpid-proton-proactor}) ++ # target_link_libraries (qpid-proton-proactor LINK_PUBLIC qpid-proton-core) ++ # target_link_libraries (qpid-proton-proactor LINK_PRIVATE ${PLATFORM_LIBS} ${PROACTOR_LIBS}) ++ # set_target_properties (qpid-proton-proactor ++ # PROPERTIES ++ # VERSION "${PN_LIB_PROACTOR_VERSION}" ++ # SOVERSION "${PN_LIB_PROACTOR_MAJOR_VERSION}" ++ # LINK_FLAGS "${CATCH_UNDEFINED} ${LTO}" ++ # ) + if (BUILD_STATIC_LIBS) + add_library (qpid-proton-proactor-static STATIC ${qpid-proton-proactor}) + endif(BUILD_STATIC_LIBS) +@@ -500,11 +500,11 @@ + if (BUILD_STATIC_LIBS) + set(STATIC_LIBS qpid-proton-static qpid-proton-core-static) + endif() +-install(TARGETS qpid-proton qpid-proton-core ${STATIC_LIBS} +- EXPORT proton +- RUNTIME DESTINATION bin +- ARCHIVE DESTINATION ${LIB_INSTALL_DIR} +- LIBRARY DESTINATION ${LIB_INSTALL_DIR}) ++# install(TARGETS qpid-proton qpid-proton-core ${STATIC_LIBS} ++# EXPORT proton ++# RUNTIME DESTINATION bin ++# ARCHIVE DESTINATION ${LIB_INSTALL_DIR} ++# LIBRARY DESTINATION ${LIB_INSTALL_DIR}) + + # Install windows pdb files + if (MSVC) +@@ -520,11 +520,11 @@ + if (BUILD_STATIC_LIBS) + set(STATIC_LIBS qpid-proton-proactor-static) + endif() +- install(TARGETS qpid-proton-proactor ${STATIC_LIBS} +- EXPORT proton +- RUNTIME DESTINATION bin +- ARCHIVE DESTINATION ${LIB_INSTALL_DIR} +- LIBRARY DESTINATION ${LIB_INSTALL_DIR}) ++ # install(TARGETS qpid-proton-proactor ${STATIC_LIBS} ++ # EXPORT proton ++ # RUNTIME DESTINATION bin ++ # ARCHIVE DESTINATION ${LIB_INSTALL_DIR} ++ # LIBRARY DESTINATION ${LIB_INSTALL_DIR}) + + # Install windows pdb files + if (MSVC) +@@ -576,10 +576,10 @@ + ${CMAKE_CURRENT_BINARY_DIR}/ProtonConfigVersion.cmake + DESTINATION ${LIB_INSTALL_DIR}/cmake/Proton) + +-add_subdirectory(docs) +-add_subdirectory(examples) +-add_subdirectory(tests) +-add_subdirectory(tools) ++# add_subdirectory(docs) ++# add_subdirectory(examples) ++# add_subdirectory(tests) ++# add_subdirectory(tools) + + install (DIRECTORY examples/ + DESTINATION "${PROTON_SHARE}/examples/c" +diff -ur a/CMakeLists.txt b/CMakeLists.txt +--- a/CMakeLists.txt 2019-12-09 07:17:00.000000000 -0700 ++++ b/CMakeLists.txt 2019-12-19 18:11:57.128248724 -0700 +@@ -24,7 +24,7 @@ + set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/tools/cmake/Modules") + set (CMAKE_THREAD_PREFER_PTHREAD TRUE) - # Enable testing --enable_testing() -include (CTest) -+#enable_testing() -+#include (CTest) ++# include (CTest) + include (CheckLanguage) + include (CheckLibraryExists) + include (CheckSymbolExists) +@@ -33,13 +33,13 @@ + find_package (OpenSSL) + find_package (Threads) + find_package (PythonInterp REQUIRED) +-find_package (SWIG) ++# find_package (SWIG) + find_package (CyrusSASL) - # Pull in local cmake modules - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/tools/cmake/Modules/") -@@ -141,7 +142,7 @@ set (BINDINGS_DIR ${LIB_INSTALL_DIR}/proton/bindings) +-enable_testing () ++#enable_testing () + + # Set up runtime checks (valgrind, sanitizers etc.) +-include(tests/RuntimeCheck.cmake) ++# include(tests/RuntimeCheck.cmake) + + ## Variables used across components + +@@ -260,7 +260,7 @@ set (SYSINSTALL_BINDINGS OFF CACHE BOOL "If SYSINSTALL_BINDINGS is OFF then proton bindings will be installed underneath ${BINDINGS_DIR} and each user will need to modify their interpreter configuration to load the appropriate binding. If SYSINSTALL_BINDINGS is ON, then each language interpreter will be queried for the appropriate directory and proton bindings will be installed and available system wide with no additional per user configuration.") --set (BINDING_LANGS PERL PHP PYTHON RUBY) -+#set (BINDING_LANGS PERL PHP PYTHON RUBY) +-set (BINDING_LANGS PYTHON RUBY) ++# set (BINDING_LANGS PYTHON RUBY) foreach (LANG ${BINDING_LANGS}) set (SYSINSTALL_${LANG} OFF CACHE BOOL "Install ${LANG} bindings into interpreter specified location.") -@@ -156,10 +157,10 @@ set (PROTON_SHARE ${SHARE_INSTALL_DIR}/proton-${PN_VERSION}) - # End of variables used during install - - # Check for valgrind here so tests under proton-c/ and examples/ can use it. --find_program(VALGRIND_EXE valgrind DOC "Location of the valgrind program") -+#find_program(VALGRIND_EXE valgrind DOC "Location of the valgrind program") - mark_as_advanced (VALGRIND_EXE) - --option(ENABLE_VALGRIND "Use valgrind to detect run-time problems" ON) -+#option(ENABLE_VALGRIND "Use valgrind to detect run-time problems" ON) - if (ENABLE_VALGRIND) - if (NOT VALGRIND_EXE) - message(STATUS "Can't locate the valgrind command; no run-time error detection") -@@ -171,7 +172,7 @@ if (ENABLE_VALGRIND) - endif (ENABLE_VALGRIND) - - add_subdirectory(proton-c) --add_subdirectory(examples) -+#add_subdirectory(examples) - - install (FILES LICENSE README.md - DESTINATION ${PROTON_SHARE}) -diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt -index 304d899..f4877b4 100644 ---- a/examples/cpp/CMakeLists.txt -+++ b/examples/cpp/CMakeLists.txt -@@ -17,6 +17,7 @@ - # under the License. - # - -+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - find_package(ProtonCpp REQUIRED) - - include_directories(${ProtonCpp_INCLUDE_DIRS}) -diff --git a/proton-c/CMakeLists.txt b/proton-c/CMakeLists.txt -index 8edb661..dc7b99c 100644 ---- a/proton-c/CMakeLists.txt -+++ b/proton-c/CMakeLists.txt -@@ -22,24 +22,24 @@ include(CheckSymbolExists) - - include(soversion.cmake) - --add_custom_target(docs) --add_custom_target(doc DEPENDS docs) -+#add_custom_target(docs) -+#add_custom_target(doc DEPENDS docs) - - # Set the default SSL/TLS implementation --find_package(OpenSSL) -+#find_package(OpenSSL) - find_package(PythonInterp REQUIRED) --find_package(SWIG) -+#find_package(SWIG) - # FindSwig.cmake "forgets" make its outputs advanced like a good citizen - mark_as_advanced(SWIG_DIR SWIG_EXECUTABLE SWIG_VERSION) - - # See if Cyrus SASL is available --find_library(CYRUS_SASL_LIBRARY sasl2) --find_path(CYRUS_SASL_INCLUDE_DIR sasl/sasl.h PATH_SUFFIXES include) --find_package_handle_standard_args(CyrusSASL DEFAULT_MSG CYRUS_SASL_LIBRARY CYRUS_SASL_INCLUDE_DIR) -+#find_library(CYRUS_SASL_LIBRARY sasl2) -+#find_path(CYRUS_SASL_INCLUDE_DIR sasl/sasl.h PATH_SUFFIXES include) -+#find_package_handle_standard_args(CyrusSASL DEFAULT_MSG CYRUS_SASL_LIBRARY CYRUS_SASL_INCLUDE_DIR) - mark_as_advanced(CYRUS_SASL_LIBRARY CYRUS_SASL_INCLUDE_DIR) - - # Find saslpasswd2 executable to generate test config --find_program(SASLPASSWD_EXE saslpasswd2 DOC "Program used to make SASL user db for testing") -+#find_program(SASLPASSWD_EXE saslpasswd2 DOC "Program used to make SASL user db for testing") - mark_as_advanced(SASLPASSWD_EXE) - - if(WIN32 AND NOT CYGWIN) -@@ -315,8 +315,8 @@ pn_absolute_install_dir(EXEC_PREFIX "." ${CMAKE_INSTALL_PREFIX}) - pn_absolute_install_dir(LIBDIR ${LIB_INSTALL_DIR} ${CMAKE_INSTALL_PREFIX}) - pn_absolute_install_dir(INCLUDEDIR ${INCLUDE_INSTALL_DIR} ${CMAKE_INSTALL_PREFIX}) - --add_subdirectory(docs/api) --add_subdirectory(../tests/tools/apps/c ../tests/tools/apps/c) -+#add_subdirectory(docs/api) -+#add_subdirectory(../tests/tools/apps/c ../tests/tools/apps/c) - - # for full source distribution: - set (qpid-proton-platform-all -@@ -507,7 +507,7 @@ if (BUILD_WITH_CXX) - endif (BUILD_WITH_CXX) - - add_library ( -- qpid-proton-core SHARED -+ qpid-proton-core STATIC - ${qpid-proton-core} - ${qpid-proton-layers} - ${qpid-proton-platform} -@@ -527,7 +527,7 @@ set_target_properties ( - ) - - add_library( -- qpid-proton SHARED -+ qpid-proton STATIC - # Proton Core - ${qpid-proton-core} - ${qpid-proton-layers} -@@ -629,7 +629,7 @@ install (FILES - - # c tests: - --add_subdirectory(src/tests) -+#add_subdirectory(src/tests) - - if (CMAKE_SYSTEM_NAME STREQUAL Windows) - # No change needed for windows already use correct separator -@@ -712,7 +712,7 @@ if (BUILD_PYTHON) - - endif (BUILD_PYTHON) - --find_program(RUBY_EXE "ruby") -+#find_program(RUBY_EXE "ruby") - if (RUBY_EXE AND BUILD_RUBY) - set (rb_root "${pn_test_root}/ruby") - set (rb_src "${CMAKE_CURRENT_SOURCE_DIR}/bindings/ruby") -@@ -751,8 +751,8 @@ if (RUBY_EXE AND BUILD_RUBY) - else (DEFAULT_RUBY_TESTING) - message(STATUS "Skipping Ruby tests: missing dependencies") - endif (DEFAULT_RUBY_TESTING) --else (RUBY_EXE) -- message (STATUS "Cannot find ruby, skipping ruby tests") -+#else (RUBY_EXE) -+# message (STATUS "Cannot find ruby, skipping ruby tests") +@@ -315,7 +315,7 @@ endif() - mark_as_advanced (RUBY_EXE RSPEC_EXE) -diff --git a/proton-c/bindings/CMakeLists.txt b/proton-c/bindings/CMakeLists.txt -index 6b88384..d1a50a5 100644 ---- a/proton-c/bindings/CMakeLists.txt -+++ b/proton-c/bindings/CMakeLists.txt -@@ -19,14 +19,14 @@ - - # Add bindings that do not require swig here - the directory name must be the same as the binding name - # See below for swig bindings --set(BINDINGS javascript cpp go) -+set(BINDINGS cpp) - - # Prerequisites for javascript. - # - # It uses a C/C++ to JavaScript cross-compiler called emscripten (https://github.com/kripken/emscripten). Emscripten takes C/C++ - # and compiles it into a highly optimisable subset of JavaScript called asm.js (http://asmjs.org/) that can be - # aggressively optimised and run at near-native speed (usually between 1.5 to 10 times slower than native C/C++). --find_package(Emscripten) -+#find_package(Emscripten) - if (EMSCRIPTEN_FOUND) - set (DEFAULT_JAVASCRIPT ON) - endif (EMSCRIPTEN_FOUND) -@@ -37,7 +37,7 @@ if (CMAKE_CXX_COMPILER) - endif (CMAKE_CXX_COMPILER) - # Prerequisites for Go -find_program(GO_EXE go) -+#find_program(GO_EXE go) ++# find_program(GO_EXE go) mark_as_advanced(GO_EXE) if (GO_EXE) - if(WIN32) -diff --git a/proton-c/bindings/cpp/CMakeLists.txt b/proton-c/bindings/cpp/CMakeLists.txt -index 0cc4024..796fe29 100644 ---- a/proton-c/bindings/cpp/CMakeLists.txt -+++ b/proton-c/bindings/cpp/CMakeLists.txt -@@ -16,7 +16,7 @@ - # specific language governing permissions and limitations - # under the License. - # -- -+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") - include(cpp.cmake) # Compiler checks - - include_directories( -@@ -89,7 +89,7 @@ set_source_files_properties ( - COMPILE_FLAGS "${LTO}" - ) + set (DEFAULT_GO ON) +diff -ur a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt +--- a/cpp/CMakeLists.txt 2019-12-09 07:17:00.000000000 -0700 ++++ b/cpp/CMakeLists.txt 2020-01-08 16:20:18.855394195 -0700 +@@ -174,30 +174,30 @@ + set (CMAKE_DEBUG_POSTFIX "d") + endif () -add_library(qpid-proton-cpp SHARED ${qpid-proton-cpp-source}) -+add_library(qpid-proton-cpp STATIC ${qpid-proton-cpp-source}) ++# add_library(qpid-proton-cpp SHARED ${qpid-proton-cpp-source}) + if(BUILD_STATIC_LIBS) + add_library(qpid-proton-cpp-static STATIC ${qpid-proton-cpp-source}) + set(STATIC_LIBS qpid-proton-cpp-static) + endif(BUILD_STATIC_LIBS) - target_link_libraries (qpid-proton-cpp ${PLATFORM_LIBS} qpid-proton) +-target_link_libraries (qpid-proton-cpp LINK_PRIVATE ${PLATFORM_LIBS} qpid-proton-core qpid-proton-proactor ${CONNECT_CONFIG_LIBS}) ++# target_link_libraries (qpid-proton-cpp LINK_PRIVATE ${PLATFORM_LIBS} qpid-proton-core qpid-proton-proactor ${CONNECT_CONFIG_LIBS}) -@@ -120,8 +120,8 @@ endif (MSVC) +-set_target_properties ( +- qpid-proton-cpp +- PROPERTIES +- LINKER_LANGUAGE CXX +- VERSION "${PN_LIB_CPP_VERSION}" +- SOVERSION "${PN_LIB_CPP_MAJOR_VERSION}" +- LINK_FLAGS "${CATCH_UNDEFINED} ${LTO}" +- ) ++# set_target_properties ( ++# qpid-proton-cpp ++# PROPERTIES ++# LINKER_LANGUAGE CXX ++# VERSION "${PN_LIB_CPP_VERSION}" ++# SOVERSION "${PN_LIB_CPP_MAJOR_VERSION}" ++# LINK_FLAGS "${CATCH_UNDEFINED} ${LTO}" ++# ) + + ## Install + +-install(TARGETS qpid-proton-cpp ${STATIC_LIBS} +- EXPORT proton-cpp +- RUNTIME DESTINATION bin +- ARCHIVE DESTINATION ${LIB_INSTALL_DIR} +- LIBRARY DESTINATION ${LIB_INSTALL_DIR}) ++# install(TARGETS qpid-proton-cpp ${STATIC_LIBS} ++# EXPORT proton-cpp ++# RUNTIME DESTINATION bin ++# ARCHIVE DESTINATION ${LIB_INSTALL_DIR} ++# LIBRARY DESTINATION ${LIB_INSTALL_DIR}) + + # Install windows qpid-proton-cpp pdb files + if (MSVC) +@@ -209,12 +209,12 @@ install (DIRECTORY "include/proton" DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.hpp") + install (FILES "${CMAKE_CURRENT_BINARY_DIR}/config_presets.hpp" DESTINATION "${INCLUDE_INSTALL_DIR}/proton/internal") +-install (DIRECTORY "examples/" +- DESTINATION "${PROTON_SHARE}/examples/cpp" +- USE_SOURCE_PERMISSIONS +- PATTERN "ProtonCppConfig.cmake" EXCLUDE) ++# install (DIRECTORY "examples/" ++# DESTINATION "${PROTON_SHARE}/examples/cpp" ++# USE_SOURCE_PERMISSIONS ++# PATTERN "ProtonCppConfig.cmake" EXCLUDE) --add_subdirectory(docs) --add_subdirectory(${CMAKE_SOURCE_DIR}/tests/tools/apps/cpp ${CMAKE_BINARY_DIR}/tests/tools/apps/cpp) -+#add_subdirectory(docs) -+#add_subdirectory(${CMAKE_SOURCE_DIR}/tests/tools/apps/cpp ${CMAKE_BINARY_DIR}/tests/tools/apps/cpp) +-add_subdirectory(examples) ++# add_subdirectory(examples) + add_subdirectory(docs) # Pkg config file - configure_file( -@@ -171,12 +171,12 @@ macro(add_cpp_test test) - endif () - endmacro(add_cpp_test) +@@ -268,40 +268,40 @@ + set(test_env ${test_env} "PATH=$") + endif() +-macro(add_cpp_test test) +- add_executable (${test} src/${test}.cpp) +- target_link_libraries (${test} qpid-proton-cpp ${PLATFORM_LIBS}) +- add_test (NAME cpp-${test} +- COMMAND ${PN_ENV_SCRIPT} -- ${test_env} ${TEST_EXE_PREFIX_CMD} $ ${ARGN}) +-endmacro(add_cpp_test) +- -add_cpp_test(codec_test) -+#add_cpp_test(codec_test) - #add_cpp_test(engine_test) --add_cpp_test(thread_safe_test) +-add_cpp_test(connection_driver_test) -add_cpp_test(interop_test ${CMAKE_SOURCE_DIR}/tests) -add_cpp_test(message_test) +-add_cpp_test(map_test) -add_cpp_test(scalar_test) -add_cpp_test(value_test) -add_cpp_test(container_test) --add_cpp_test(url_test) -+#add_cpp_test(thread_safe_test) -+#add_cpp_test(interop_test ${CMAKE_SOURCE_DIR}/tests) -+#add_cpp_test(message_test) -+#add_cpp_test(scalar_test) -+#add_cpp_test(value_test) -+#add_cpp_test(container_test) -+#add_cpp_test(url_test) -diff --git a/proton-c/bindings/cpp/docs/CMakeLists.txt b/proton-c/bindings/cpp/docs/CMakeLists.txt -index d512d15..8576867 100644 ---- a/proton-c/bindings/cpp/docs/CMakeLists.txt -+++ b/proton-c/bindings/cpp/docs/CMakeLists.txt -@@ -17,7 +17,7 @@ - # under the License. - # +-add_cpp_test(reconnect_test) +-add_cpp_test(link_test) +-add_cpp_test(credit_test) +-if (ENABLE_JSONCPP) +- add_cpp_test(connect_config_test) +- target_link_libraries(connect_config_test qpid-proton-core) # For pn_sasl_enabled +- set_tests_properties(cpp-connect_config_test PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") +- # Test data and output directories for connect_config_test +- file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/testdata" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") +-endif() ++# macro(add_cpp_test test) ++# add_executable (${test} src/${test}.cpp) ++# target_link_libraries (${test} qpid-proton-cpp ${PLATFORM_LIBS}) ++# add_test (NAME cpp-${test} ++# COMMAND ${PN_ENV_SCRIPT} -- ${test_env} ${TEST_EXE_PREFIX_CMD} $ ${ARGN}) ++# endmacro(add_cpp_test) ++# ++# add_cpp_test(codec_test) ++# add_cpp_test(connection_driver_test) ++# add_cpp_test(interop_test ${CMAKE_SOURCE_DIR}/tests) ++# add_cpp_test(message_test) ++# add_cpp_test(map_test) ++# add_cpp_test(scalar_test) ++# add_cpp_test(value_test) ++# add_cpp_test(container_test) ++# add_cpp_test(reconnect_test) ++# add_cpp_test(link_test) ++# add_cpp_test(credit_test) ++# if (ENABLE_JSONCPP) ++# add_cpp_test(connect_config_test) ++# target_link_libraries(connect_config_test qpid-proton-core) # For pn_sasl_enabled ++# set_tests_properties(cpp-connect_config_test PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") ++# # Test data and output directories for connect_config_test ++# file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/testdata" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") ++# endif() --find_package(Doxygen) -+#find_package(Doxygen) + # TODO aconway 2018-10-31: Catch2 tests + # This is a simple example of a C++ test using the Catch2 framework. + # See c/tests/ for more interesting examples. + # Eventually all the C++ tests will migrate to Catch2. - if (DOXYGEN_FOUND) - configure_file ( -diff --git a/proton-c/docs/api/CMakeLists.txt b/proton-c/docs/api/CMakeLists.txt -index 7756e48..71ebb93 100644 ---- a/proton-c/docs/api/CMakeLists.txt -+++ b/proton-c/docs/api/CMakeLists.txt -@@ -17,7 +17,7 @@ - # under the License. - # +-include_directories(${CMAKE_SOURCE_DIR}/tests/include) +-add_executable(cpp-test src/cpp-test.cpp src/url_test.cpp) +-target_link_libraries(cpp-test qpid-proton-cpp ${PLATFORM_LIBS}) ++#include_directories(${CMAKE_SOURCE_DIR}/tests/include) ++#add_executable(cpp-test src/cpp-test.cpp src/url_test.cpp) ++#target_link_libraries(cpp-test qpid-proton-cpp ${PLATFORM_LIBS}) --find_package(Doxygen) -+#find_package(Doxygen) - if (DOXYGEN_FOUND) - configure_file (${CMAKE_CURRENT_SOURCE_DIR}/user.doxygen.in - ${CMAKE_CURRENT_BINARY_DIR}/user.doxygen) --- -2.7.4 - + macro(add_catch_test tag) + add_test ( diff --git a/src/Makefile.am b/src/Makefile.am index b44dd13c5..eb41a0031 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -65,13 +65,13 @@ LIBBITCOIN_WALLET=libbitcoin_wallet.a endif $(LIBSECP256K1): $(wildcard secp256k1/src/*) $(wildcard secp256k1/include/*) - $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) OPTFLAGS="-O2 -march=x86-64 -g " + $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) OPTFLAGS="-O2 -g " $(LIBUNIVALUE): $(wildcard univalue/lib/*) - $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) OPTFLAGS="-O2 -march=x86-64 -g " + $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) OPTFLAGS="-O2 -g " $(LIBCRYPTOCONDITIONS): $(wildcard cryptoconditions/src/*) $(wildcard cryptoconditions/include/*) - $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) OPTFLAGS="-O2 -march=x86-64 -g " + $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) OPTFLAGS="-O2 -g " # Make is not made aware of per-object dependencies to avoid limiting building parallelization # But to build the less dependent modules first, we manually select their order here: diff --git a/src/cc/Makefile_custom b/src/cc/Makefile_custom old mode 100755 new mode 100644 index 79219ec96..0c2401f31 --- a/src/cc/Makefile_custom +++ b/src/cc/Makefile_custom @@ -2,6 +2,7 @@ SHELL = /bin/sh CC = gcc CC_DARWIN = g++-8 CC_WIN = x86_64-w64-mingw32-gcc-posix +CC_ARM64 = aarch64-linux-gnu-g++ CFLAGS_DARWIN = -DBUILD_CUSTOMCC -std=c++11 -arch x86_64 -I../secp256k1/include -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -Wl,-undefined -Wl,dynamic_lookup -Wno-write-strings -shared -dynamiclib CFLAGS = -Wno-write-strings -DBUILD_CUSTOMCC -std=c++11 -I../secp256k1/include -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared CFLAGS_WIN = -Wno-write-strings -DBUILD_CUSTOMCC -std=c++11 -I../secp256k1/include -I../../depends/x86_64-w64-mingw32/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared @@ -28,6 +29,10 @@ else ifeq ($(HOST),x86_64-w64-mingw32) $(CC_WIN) $(CFLAGS_WIN) $(DEBUGFLAGS) -o $(TARGET_WIN) -c $(SOURCES) cp $(TARGET_WIN) ../libcc.dll #else ifeq ($(WIN_HOST),True) - todo: pass ENV var from build.sh if WIN host +else ifeq ($(HOST),aarch64-linux-gnu) + $(info LINUX ARM 64bit ) + $(CC_ARM64) $(CFLAGS) $(DEBUGFLAGS) -o $(TARGET) -c $(SOURCES) + cp $(TARGET) ../libcc.so else $(info LINUX) $(CC) $(CFLAGS) $(DEBUGFLAGS) -o $(TARGET) -c $(SOURCES) diff --git a/src/cc/makecustom b/src/cc/makecustom old mode 100755 new mode 100644 index 7f1c789c9..3516b4023 --- a/src/cc/makecustom +++ b/src/cc/makecustom @@ -1,5 +1,5 @@ #!/bin/sh -if make -f Makefile_custom "$@"; then +if HOST="$HOST" make -B -f Makefile_custom "$@"; then echo CUSTOMCC BUILD SUCCESSFUL else echo CUSTOMCC BUILD FAILED diff --git a/src/cryptoconditions/Makefile.am b/src/cryptoconditions/Makefile.am index 787b11ac6..615ac5783 100644 --- a/src/cryptoconditions/Makefile.am +++ b/src/cryptoconditions/Makefile.am @@ -15,7 +15,7 @@ AM_CFLAGS = -I$(top_srcdir)/src/asn -I$(top_srcdir)/include -I$(top_srcdir)/src/ LIBSECP256K1=src/include/secp256k1/libsecp256k1.la $(LIBSECP256K1): $(wildcard src/secp256k1/*) - $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) -march:x86-64 -g + $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F) -g CRYPTOCONDITIONS_CORE=libcryptoconditions_core.la diff --git a/src/cryptoconditions/src/include/secp256k1/Makefile.am b/src/cryptoconditions/src/include/secp256k1/Makefile.am index 52303e4e4..13c83fe18 100644 --- a/src/cryptoconditions/src/include/secp256k1/Makefile.am +++ b/src/cryptoconditions/src/include/secp256k1/Makefile.am @@ -71,7 +71,7 @@ endif endif libsecp256k1_la_SOURCES = src/secp256k1.c -libsecp256k1_la_CPPFLAGS = -DSECP256K1_BUILD -I$(top_srcdir)/include -I$(top_srcdir)/src $(SECP_INCLUDES) -march=x86-64 -g +libsecp256k1_la_CPPFLAGS = -DSECP256K1_BUILD -I$(top_srcdir)/include -I$(top_srcdir)/src $(SECP_INCLUDES) -g libsecp256k1_la_LIBADD = $(JNI_LIB) $(SECP_LIBS) $(COMMON_LIB) libsecp256k1_jni_la_SOURCES = src/java/org_bitcoin_NativeSecp256k1.c src/java/org_bitcoin_Secp256k1Context.c diff --git a/zcutil/build-cross-aarch64.sh b/zcutil/build-cross-aarch64.sh new file mode 100644 index 000000000..eea5af471 --- /dev/null +++ b/zcutil/build-cross-aarch64.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# Copyright (c) 2019-2020 radix42 +# Copyright (c) 2019-2020 The Hush developers +# Original aarch64 port by radix42. Thank you! + +set -eu -o pipefail + +cat <<'EOF' + ________________ +< Building Hush! > + ---------------- + \ ^__^ + \ (oo)\_______ + (__)\ )\/\ + ||----w | + || || +EOF + +if [ "x$*" = 'x--help' ] +then + cat ./zcutil/dragon.txt + cat < Date: Sun, 12 Jul 2020 12:55:58 +0200 Subject: [PATCH 115/255] make crossbuild script executable --- zcutil/build-cross-aarch64.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 zcutil/build-cross-aarch64.sh diff --git a/zcutil/build-cross-aarch64.sh b/zcutil/build-cross-aarch64.sh old mode 100644 new mode 100755 From c12ec78caf29a030a332cbfef428727f02ec45e2 Mon Sep 17 00:00:00 2001 From: miodragpop Date: Sun, 12 Jul 2020 13:35:31 +0200 Subject: [PATCH 116/255] executable permissions on makecustom script --- src/cc/makecustom | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 src/cc/makecustom diff --git a/src/cc/makecustom b/src/cc/makecustom old mode 100644 new mode 100755 From cbf0351e98b97de39881d5182156001cf890ce48 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 13 Jul 2020 14:03:37 -0400 Subject: [PATCH 117/255] Show shielded spends in getchaintxstats output --- src/rpc/blockchain.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 3bdce7eb2..6e2efbd57 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1904,6 +1904,7 @@ UniValue getchaintxstats(const UniValue& params, bool fHelp, const CPubKey& mypk " \"nullifiers\": xxxxx, (numeric) The total number of shielded nullifiers in the chain up to that point.\n" " \"shielded_txcount\": xxxxx, (numeric) The total number of shielded (containing a zaddr) transactions in the chain up to that point.\n" " \"shielded_outputs\": xxxxx, (numeric) The total number of shielded outputs in the chain up to that point.\n" + " \"shielded_spends\": xxxxx, (numeric) The total number of shielded spends in the chain up to that point.\n" " \"shielded_pool_size\": xxxxx, (numeric) The total number of unspent shielded outputs, i.e. the Shielded Pool or Anonymity Set (anonset).\n" " \"shielding_txcount\": xxxxx, (numeric) The total number of shielding (containing a zaddr output) transactions in the chain up to that point.\n" " \"deshielding_txcount\": xxxxx, (numeric) The total number of deshielding (containing a zaddr input) transactions in the chain up to that point.\n" @@ -2007,6 +2008,7 @@ UniValue getchaintxstats(const UniValue& params, bool fHelp, const CPubKey& mypk ret.pushKV("nullifiers", (int64_t)nullifierCount); ret.pushKV("shielded_pool_size", (int64_t)(pindex->nChainShieldedOutputs - pindex->nChainShieldedSpends)); ret.pushKV("shielded_outputs", (int64_t)pindex->nChainShieldedOutputs); + ret.pushKV("shielded_spends", (int64_t)pindex->nChainShieldedSpends); } if (blockcount > 0) { From 6017bdba7954ba03841b9a8aa51deafff4a71c45 Mon Sep 17 00:00:00 2001 From: miodragpop Date: Thu, 16 Jul 2020 19:24:30 +0200 Subject: [PATCH 118/255] cryptoconditions: ugly workaround to fix memory access issues on aarch64 --- src/cryptoconditions/src/asn/OCTET_STRING.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/cryptoconditions/src/asn/OCTET_STRING.c b/src/cryptoconditions/src/asn/OCTET_STRING.c index 5420dedec..a886ff8fa 100644 --- a/src/cryptoconditions/src/asn/OCTET_STRING.c +++ b/src/cryptoconditions/src/asn/OCTET_STRING.c @@ -1714,7 +1714,9 @@ OCTET_STRING_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only) { OCTET_STRING_t *st = (OCTET_STRING_t *)sptr; asn_OCTET_STRING_specifics_t *specs; asn_struct_ctx_t *ctx; +#if !defined(__aarch64__) struct _stack *stck; +#endif if(!td || !st) return; @@ -1731,6 +1733,15 @@ OCTET_STRING_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only) { st->buf = 0; } +/* Attention !!! + * this is quick & dirty workaround for memory corruption bug on aarch64-linux-gnu + * - downside: allows memory leakage + * - issue description: On Raspberry Pi 4 @ 64bit linux, daemon crashes with "free(): invalid pointer" error + * - probable cause: misaligned memory access to nested structs containing pointers + * - TODO: use the latest asn1c compiler on CryptoConditions.asn, maybe generate cpp instead of c code... investigation in progress + */ + +#if !defined(__aarch64__) /* * Remove decode-time stack. */ @@ -1747,6 +1758,7 @@ OCTET_STRING_free(asn_TYPE_descriptor_t *td, void *sptr, int contents_only) { if(!contents_only) { FREEMEM(st); } +#endif } /* From b1de0a7f86d4d658ec892dc3ec0a54b099d0bc94 Mon Sep 17 00:00:00 2001 From: miodragpop Date: Thu, 16 Jul 2020 23:35:43 +0200 Subject: [PATCH 119/255] proton lib removed --- configure.ac | 27 -- contrib/amqp/amqp_sub.py | 48 --- contrib/debian/copyright | 220 -------------- contrib/gitian-descriptors/gitian-linux.yml | 2 +- depends/Makefile | 3 +- depends/packages/packages.mk | 8 +- depends/packages/proton.mk | 24 -- depends/patches/proton/minimal-build.patch | 314 -------------------- doc/amqp.md | 123 -------- qa/pull-tester/rpc-tests.sh | 4 - qa/rpc-tests/proton_test.py | 117 -------- src/Makefile.am | 21 -- src/Makefile.gtest.include | 5 - src/Makefile.test.include | 4 - src/amqp/amqpabstractnotifier.cpp | 21 -- src/amqp/amqpabstractnotifier.h | 43 --- src/amqp/amqpconfig.h | 33 -- src/amqp/amqpnotificationinterface.cpp | 136 --------- src/amqp/amqpnotificationinterface.h | 36 --- src/amqp/amqppublishnotifier.cpp | 177 ----------- src/amqp/amqppublishnotifier.h | 56 ---- src/amqp/amqpsender.h | 115 ------- src/init.cpp | 39 --- zcutil/build-arm.sh | 2 +- zcutil/build-mac.sh | 2 +- zcutil/build.sh | 15 +- 26 files changed, 8 insertions(+), 1587 deletions(-) delete mode 100644 contrib/amqp/amqp_sub.py delete mode 100644 depends/packages/proton.mk delete mode 100644 depends/patches/proton/minimal-build.patch delete mode 100644 doc/amqp.md delete mode 100755 qa/rpc-tests/proton_test.py delete mode 100644 src/amqp/amqpabstractnotifier.cpp delete mode 100644 src/amqp/amqpabstractnotifier.h delete mode 100644 src/amqp/amqpconfig.h delete mode 100644 src/amqp/amqpnotificationinterface.cpp delete mode 100644 src/amqp/amqpnotificationinterface.h delete mode 100644 src/amqp/amqppublishnotifier.cpp delete mode 100644 src/amqp/amqppublishnotifier.h delete mode 100644 src/amqp/amqpsender.h diff --git a/configure.ac b/configure.ac index f0474aec0..ace3612da 100644 --- a/configure.ac +++ b/configure.ac @@ -96,12 +96,6 @@ AC_ARG_ENABLE([mining], [enable_mining=$enableval], [enable_mining=yes]) -AC_ARG_ENABLE([proton], - [AS_HELP_STRING([--disable-proton], - [disable Proton (AMQP messaging)])], - [use_proton=$enableval], - [use_proton=yes]) - AC_ARG_ENABLE(tests, AS_HELP_STRING([--enable-tests],[compile tests (default is yes)]), [use_tests=$enableval], @@ -605,23 +599,6 @@ if test x$enable_wallet != xno; then BITCOIN_FIND_BDB62 fi -dnl Check Qpid Proton headers and library exist -if test x$use_proton = xyes; then - AC_CHECK_HEADERS([proton/connection.hpp], - [], - [AC_MSG_WARN([Proton headers not found, disabling Proton support]) - use_proton=no]) - AC_CHECK_LIB([qpid-proton-cpp], [main], - [PROTON_LIBS="-lqpid-proton-cpp -lqpid-proton"], - [AC_MSG_WARN([Proton libraries not found, disabling Proton support]) - use_proton=no]) -fi -if test x$use_proton = xyes; then - AC_DEFINE(ENABLE_PROTON, 1, [Define to 1 to enable Proton functions]) -else - AC_DEFINE(ENABLE_PROTON, 0, [Define to 1 to enable Proton functions]) -fi - if test x$build_bitcoin_utils$build_bitcoind$use_tests = xnonono; then use_boost=no else @@ -849,8 +826,6 @@ fi AM_CONDITIONAL([ENABLE_ZMQ], [test "x$use_zmq" = "xyes"]) -AM_CONDITIONAL([ENABLE_PROTON], [test "x$use_proton" = "xyes"]) - AC_MSG_CHECKING([whether to build test_bitcoin]) if test x$use_tests = xyes; then AC_MSG_RESULT([yes]) @@ -923,7 +898,6 @@ AC_SUBST(ZMQ_LIBS) AC_SUBST(GMP_LIBS) AC_SUBST(GMPXX_LIBS) AC_SUBST(LIBZCASH_LIBS) -AC_SUBST(PROTON_LIBS) AC_CONFIG_FILES([Makefile src/Makefile doc/man/Makefile src/test/buildenv.py]) AC_CONFIG_FILES([qa/pull-tester/run-bitcoind-for-test.sh],[chmod +x qa/pull-tester/run-bitcoind-for-test.sh]) AC_CONFIG_FILES([qa/pull-tester/tests-config.sh],[chmod +x qa/pull-tester/tests-config.sh]) @@ -970,7 +944,6 @@ esac echo echo "Options used to compile and link:" echo " with wallet = $enable_wallet" -echo " with proton = $use_proton" echo " with zmq = $use_zmq" echo " with test = $use_tests" echo " debug enabled = $enable_debug" diff --git a/contrib/amqp/amqp_sub.py b/contrib/amqp/amqp_sub.py deleted file mode 100644 index bc51e8428..000000000 --- a/contrib/amqp/amqp_sub.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/env python2 -# Copyright (c) 2017 The Zcash developers -# Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. - -# Requirements: -# pip install python-qpid-proton - -import binascii -from proton.handlers import MessagingHandler -from proton.reactor import Container - -port = 5672 - -class Server(MessagingHandler): - def __init__(self, url): - super(Server, self).__init__() - self.url = url - self.senders = {} - - def on_start(self, event): - print "Listening on:", self.url - self.container = event.container - self.acceptor = event.container.listen(self.url) - - def on_message(self, event): - m = event.message - topic = m.subject - body = m.body - sequence = str( m.properties['x-opt-sequence-number'] ) - if topic == "hashablock": - print '- HASH BLOCK ('+sequence+') -' - print binascii.hexlify(body) - elif topic == "hashtx": - print '- HASH TX ('+sequence+') -' - print binascii.hexlify(body) - elif topic == "rawblock": - print '- RAW BLOCK HEADER ('+sequence+') -' - print binascii.hexlify(body[:80]) - elif topic == "rawtx": - print '- RAW TX ('+sequence+') -' - print binascii.hexlify(body) - -try: - Container(Server("127.0.0.1:%i" % port)).run() -except KeyboardInterrupt: - pass - diff --git a/contrib/debian/copyright b/contrib/debian/copyright index 9371b7022..2f51f4a4c 100644 --- a/contrib/debian/copyright +++ b/contrib/debian/copyright @@ -52,10 +52,6 @@ Files: depends/sources/google*.tar.gz Copyright: 2008 Google Inc. License: BSD-3clause-Google -Files: depends/sources/qpid-proton-*.tar.gz -Copyright: 2012-2017 The Apache Software Foundation -License: Apache-Qpid-Proton-with-BSD-Subcomponents - Files: src/secp256k1/build-aux/m4/ax_jni_include_dir.m4 Copyright: 2008 Don Anderson License: GNU-All-permissive-License @@ -1101,222 +1097,6 @@ Comment: You should have received a copy of the GNU General Public License along with this program. If not, see . -License: Apache-Qpid-Proton-with-BSD-Subcomponents - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - . - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - . - 1. Definitions. - . - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - . - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - . - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - . - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - . - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - . - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - . - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - . - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - . - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - . - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - . - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - . - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - . - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - . - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - . - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - . - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - . - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - . - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - . - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - . - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - . - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - . - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - . - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - . - END OF TERMS AND CONDITIONS - . - APPENDIX: How to apply the Apache License to your work. - . - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - . - Copyright [yyyy] [name of copyright owner] - . - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - . - http://www.apache.org/licenses/LICENSE-2.0 - . - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - . - . - PROTON SUBCOMPONENTS: - . - Proton includes freegetopt with a separate BSD license. Your use - of the source code for freegetopt is subject to the terms and - conditions of its license in examples/include/pncompat/internal/LICENSE. - . - The setup scripts for the python bindings include files derived by - PyZMQ and are licensed with a separate Modified BSD license. Use of - the source code in these setup files are subject to the terms and - conditions in the license: - proton-c/bindings/python/setuputils/PYZMQ_LICENSE.BSD. - License: GNU-All-permissive-License Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice diff --git a/contrib/gitian-descriptors/gitian-linux.yml b/contrib/gitian-descriptors/gitian-linux.yml index c619cf270..317bd8694 100644 --- a/contrib/gitian-descriptors/gitian-linux.yml +++ b/contrib/gitian-descriptors/gitian-linux.yml @@ -85,7 +85,7 @@ script: | BASEPREFIX=`pwd`/depends # Build dependencies for each host for i in $HOSTS; do - NO_PROTON="x" make ${MAKEOPTS} -C ${BASEPREFIX} HOST="${i}" + make ${MAKEOPTS} -C ${BASEPREFIX} HOST="${i}" done # Faketime for binaries diff --git a/depends/Makefile b/depends/Makefile index 9d53bd1be..82acde0ac 100644 --- a/depends/Makefile +++ b/depends/Makefile @@ -74,9 +74,8 @@ include builders/default.mk include packages/packages.mk wallet_packages_$(NO_WALLET) = $(wallet_packages) -proton_packages_$(NO_PROTON) = $(proton_packages) -packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(rust_packages) $(proton_packages_) $(wallet_packages_) +packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(rust_packages) $(wallet_packages_) native_packages += $($(host_arch)_$(host_os)_native_packages) $($(host_os)_native_packages) all_packages = $(packages) $(native_packages) diff --git a/depends/packages/packages.mk b/depends/packages/packages.mk index 8a56f73f3..9c76166af 100644 --- a/depends/packages/packages.mk +++ b/depends/packages/packages.mk @@ -1,10 +1,4 @@ -ifeq ($(build_os),darwin) - zcash_packages := libgmp libsodium utfcpp -else - proton_packages := proton - zcash_packages := libgmp libsodium utfcpp -endif - +zcash_packages := libgmp libsodium utfcpp rust_crates := \ crate_aes \ crate_aesni \ diff --git a/depends/packages/proton.mk b/depends/packages/proton.mk deleted file mode 100644 index d974fa5fa..000000000 --- a/depends/packages/proton.mk +++ /dev/null @@ -1,24 +0,0 @@ -package=proton -$(package)_version=0.30.0 -$(package)_download_path=https://archive.apache.org/dist/qpid/proton/$($(package)_version) -$(package)_file_name=qpid-proton-$($(package)_version).tar.gz -$(package)_sha256_hash=e37fd8fb13391c3996f927839969a8f66edf35612392d0611eeac6e39e48dd33 -$(package)_patches=minimal-build.patch - -define $(package)_preprocess_cmds - patch -p1 < $($(package)_patch_dir)/minimal-build.patch && \ - mkdir -p build/proton-c/src -endef - -define $(package)_config_cmds - cd build; cmake .. -DCMAKE_CXX_STANDARD=11 -DCMAKE_INSTALL_PREFIX=/ -DSYSINSTALL_BINDINGS=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_PYTHON=OFF -DBUILD_RUBY=OFF -DBUILD_GO=OFF -DBUILD_STATIC_LIBS=ON -DLIB_SUFFIX= -DENABLE_JSONCPP= -endef - -define $(package)_build_cmds - cd build; $(MAKE) VERBOSE=1 -endef - -define $(package)_stage_cmds - cd build; $(MAKE) VERBOSE=1 DESTDIR=$($(package)_staging_prefix_dir) install -endef - diff --git a/depends/patches/proton/minimal-build.patch b/depends/patches/proton/minimal-build.patch deleted file mode 100644 index dd138d2f6..000000000 --- a/depends/patches/proton/minimal-build.patch +++ /dev/null @@ -1,314 +0,0 @@ -diff -ur a/c/CMakeLists.txt b/c/CMakeLists.txt ---- a/c/CMakeLists.txt 2019-12-09 07:17:00.000000000 -0700 -+++ b/c/CMakeLists.txt 2020-01-08 16:15:26.837987469 -0700 -@@ -428,18 +428,18 @@ - # Can't use target_link_libraries() because cmake 2.8.12 doesn't allow object libraries as the first param - # otherwise for cmake 3.9 and on this would be: - # target_link_libraries (qpid-proton-core-objects ${SSL_LIB} ${SASL_LIB} ${TIME_LIB} ${PLATFORM_LIBS}) --target_compile_definitions(qpid-proton-core-objects PRIVATE $) --target_compile_options (qpid-proton-core-objects PRIVATE $) --target_include_directories(qpid-proton-core-objects PRIVATE $) -- --add_library (qpid-proton-core SHARED $) --target_link_libraries (qpid-proton-core ${SSL_LIB} ${SASL_LIB} ${TIME_LIB} ${PLATFORM_LIBS}) --set_target_properties (qpid-proton-core -- PROPERTIES -- VERSION "${PN_LIB_CORE_VERSION}" -- SOVERSION "${PN_LIB_CORE_MAJOR_VERSION}" -- LINK_FLAGS "${CATCH_UNDEFINED} ${LTO}" --) -+#target_compile_definitions(qpid-proton-core-objects PRIVATE $) -+#target_compile_options (qpid-proton-core-objects PRIVATE $) -+#target_include_directories(qpid-proton-core-objects PRIVATE $) -+ -+#add_library (qpid-proton-core SHARED $) -+#target_link_libraries (qpid-proton-core ${SSL_LIB} ${SASL_LIB} ${TIME_LIB} ${PLATFORM_LIBS}) -+#set_target_properties (qpid-proton-core -+# PROPERTIES -+# VERSION "${PN_LIB_CORE_VERSION}" -+# SOVERSION "${PN_LIB_CORE_MAJOR_VERSION}" -+# LINK_FLAGS "${CATCH_UNDEFINED} ${LTO}" -+#) - - if (BUILD_STATIC_LIBS) - add_library (qpid-proton-core-static STATIC ${qpid-proton-core-src}) -@@ -454,14 +454,14 @@ - ${qpid-proton-include-extra} - ) - --add_library (qpid-proton SHARED $ ${qpid-proton-noncore-src}) --target_link_libraries (qpid-proton LINK_PRIVATE ${SSL_LIB} ${SASL_LIB} ${TIME_LIB} ${PLATFORM_LIBS} ${PROACTOR_LIBS}) --set_target_properties (qpid-proton -- PROPERTIES -- VERSION "${PN_LIB_LEGACY_VERSION}" -- SOVERSION "${PN_LIB_LEGACY_MAJOR_VERSION}" -- LINK_FLAGS "${CATCH_UNDEFINED} ${LTO}" --) -+# add_library (qpid-proton SHARED $ ${qpid-proton-noncore-src}) -+# target_link_libraries (qpid-proton LINK_PRIVATE ${SSL_LIB} ${SASL_LIB} ${TIME_LIB} ${PLATFORM_LIBS} ${PROACTOR_LIBS}) -+# set_target_properties (qpid-proton -+# PROPERTIES -+# VERSION "${PN_LIB_LEGACY_VERSION}" -+# SOVERSION "${PN_LIB_LEGACY_MAJOR_VERSION}" -+# LINK_FLAGS "${CATCH_UNDEFINED} ${LTO}" -+# ) - - if (BUILD_STATIC_LIBS) - add_library(qpid-proton-static STATIC ${qpid-proton-core-src} ${qpid-proton-noncore-src}) -@@ -482,15 +482,15 @@ - - if (qpid-proton-proactor) - set(HAS_PROACTOR True) -- add_library (qpid-proton-proactor SHARED ${qpid-proton-proactor}) -- target_link_libraries (qpid-proton-proactor LINK_PUBLIC qpid-proton-core) -- target_link_libraries (qpid-proton-proactor LINK_PRIVATE ${PLATFORM_LIBS} ${PROACTOR_LIBS}) -- set_target_properties (qpid-proton-proactor -- PROPERTIES -- VERSION "${PN_LIB_PROACTOR_VERSION}" -- SOVERSION "${PN_LIB_PROACTOR_MAJOR_VERSION}" -- LINK_FLAGS "${CATCH_UNDEFINED} ${LTO}" -- ) -+ # add_library (qpid-proton-proactor SHARED ${qpid-proton-proactor}) -+ # target_link_libraries (qpid-proton-proactor LINK_PUBLIC qpid-proton-core) -+ # target_link_libraries (qpid-proton-proactor LINK_PRIVATE ${PLATFORM_LIBS} ${PROACTOR_LIBS}) -+ # set_target_properties (qpid-proton-proactor -+ # PROPERTIES -+ # VERSION "${PN_LIB_PROACTOR_VERSION}" -+ # SOVERSION "${PN_LIB_PROACTOR_MAJOR_VERSION}" -+ # LINK_FLAGS "${CATCH_UNDEFINED} ${LTO}" -+ # ) - if (BUILD_STATIC_LIBS) - add_library (qpid-proton-proactor-static STATIC ${qpid-proton-proactor}) - endif(BUILD_STATIC_LIBS) -@@ -500,11 +500,11 @@ - if (BUILD_STATIC_LIBS) - set(STATIC_LIBS qpid-proton-static qpid-proton-core-static) - endif() --install(TARGETS qpid-proton qpid-proton-core ${STATIC_LIBS} -- EXPORT proton -- RUNTIME DESTINATION bin -- ARCHIVE DESTINATION ${LIB_INSTALL_DIR} -- LIBRARY DESTINATION ${LIB_INSTALL_DIR}) -+# install(TARGETS qpid-proton qpid-proton-core ${STATIC_LIBS} -+# EXPORT proton -+# RUNTIME DESTINATION bin -+# ARCHIVE DESTINATION ${LIB_INSTALL_DIR} -+# LIBRARY DESTINATION ${LIB_INSTALL_DIR}) - - # Install windows pdb files - if (MSVC) -@@ -520,11 +520,11 @@ - if (BUILD_STATIC_LIBS) - set(STATIC_LIBS qpid-proton-proactor-static) - endif() -- install(TARGETS qpid-proton-proactor ${STATIC_LIBS} -- EXPORT proton -- RUNTIME DESTINATION bin -- ARCHIVE DESTINATION ${LIB_INSTALL_DIR} -- LIBRARY DESTINATION ${LIB_INSTALL_DIR}) -+ # install(TARGETS qpid-proton-proactor ${STATIC_LIBS} -+ # EXPORT proton -+ # RUNTIME DESTINATION bin -+ # ARCHIVE DESTINATION ${LIB_INSTALL_DIR} -+ # LIBRARY DESTINATION ${LIB_INSTALL_DIR}) - - # Install windows pdb files - if (MSVC) -@@ -576,10 +576,10 @@ - ${CMAKE_CURRENT_BINARY_DIR}/ProtonConfigVersion.cmake - DESTINATION ${LIB_INSTALL_DIR}/cmake/Proton) - --add_subdirectory(docs) --add_subdirectory(examples) --add_subdirectory(tests) --add_subdirectory(tools) -+# add_subdirectory(docs) -+# add_subdirectory(examples) -+# add_subdirectory(tests) -+# add_subdirectory(tools) - - install (DIRECTORY examples/ - DESTINATION "${PROTON_SHARE}/examples/c" -diff -ur a/CMakeLists.txt b/CMakeLists.txt ---- a/CMakeLists.txt 2019-12-09 07:17:00.000000000 -0700 -+++ b/CMakeLists.txt 2019-12-19 18:11:57.128248724 -0700 -@@ -24,7 +24,7 @@ - set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/tools/cmake/Modules") - set (CMAKE_THREAD_PREFER_PTHREAD TRUE) - --include (CTest) -+# include (CTest) - include (CheckLanguage) - include (CheckLibraryExists) - include (CheckSymbolExists) -@@ -33,13 +33,13 @@ - find_package (OpenSSL) - find_package (Threads) - find_package (PythonInterp REQUIRED) --find_package (SWIG) -+# find_package (SWIG) - find_package (CyrusSASL) - --enable_testing () -+#enable_testing () - - # Set up runtime checks (valgrind, sanitizers etc.) --include(tests/RuntimeCheck.cmake) -+# include(tests/RuntimeCheck.cmake) - - ## Variables used across components - -@@ -260,7 +260,7 @@ - - set (SYSINSTALL_BINDINGS OFF CACHE BOOL "If SYSINSTALL_BINDINGS is OFF then proton bindings will be installed underneath ${BINDINGS_DIR} and each user will need to modify their interpreter configuration to load the appropriate binding. If SYSINSTALL_BINDINGS is ON, then each language interpreter will be queried for the appropriate directory and proton bindings will be installed and available system wide with no additional per user configuration.") - --set (BINDING_LANGS PYTHON RUBY) -+# set (BINDING_LANGS PYTHON RUBY) - - foreach (LANG ${BINDING_LANGS}) - set (SYSINSTALL_${LANG} OFF CACHE BOOL "Install ${LANG} bindings into interpreter specified location.") -@@ -315,7 +315,7 @@ - endif() - - # Prerequisites for Go --find_program(GO_EXE go) -+# find_program(GO_EXE go) - mark_as_advanced(GO_EXE) - if (GO_EXE) - set (DEFAULT_GO ON) -diff -ur a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt ---- a/cpp/CMakeLists.txt 2019-12-09 07:17:00.000000000 -0700 -+++ b/cpp/CMakeLists.txt 2020-01-08 16:20:18.855394195 -0700 -@@ -174,30 +174,30 @@ - set (CMAKE_DEBUG_POSTFIX "d") - endif () - --add_library(qpid-proton-cpp SHARED ${qpid-proton-cpp-source}) -+# add_library(qpid-proton-cpp SHARED ${qpid-proton-cpp-source}) - if(BUILD_STATIC_LIBS) - add_library(qpid-proton-cpp-static STATIC ${qpid-proton-cpp-source}) - set(STATIC_LIBS qpid-proton-cpp-static) - endif(BUILD_STATIC_LIBS) - --target_link_libraries (qpid-proton-cpp LINK_PRIVATE ${PLATFORM_LIBS} qpid-proton-core qpid-proton-proactor ${CONNECT_CONFIG_LIBS}) -+# target_link_libraries (qpid-proton-cpp LINK_PRIVATE ${PLATFORM_LIBS} qpid-proton-core qpid-proton-proactor ${CONNECT_CONFIG_LIBS}) - --set_target_properties ( -- qpid-proton-cpp -- PROPERTIES -- LINKER_LANGUAGE CXX -- VERSION "${PN_LIB_CPP_VERSION}" -- SOVERSION "${PN_LIB_CPP_MAJOR_VERSION}" -- LINK_FLAGS "${CATCH_UNDEFINED} ${LTO}" -- ) -+# set_target_properties ( -+# qpid-proton-cpp -+# PROPERTIES -+# LINKER_LANGUAGE CXX -+# VERSION "${PN_LIB_CPP_VERSION}" -+# SOVERSION "${PN_LIB_CPP_MAJOR_VERSION}" -+# LINK_FLAGS "${CATCH_UNDEFINED} ${LTO}" -+# ) - - ## Install - --install(TARGETS qpid-proton-cpp ${STATIC_LIBS} -- EXPORT proton-cpp -- RUNTIME DESTINATION bin -- ARCHIVE DESTINATION ${LIB_INSTALL_DIR} -- LIBRARY DESTINATION ${LIB_INSTALL_DIR}) -+# install(TARGETS qpid-proton-cpp ${STATIC_LIBS} -+# EXPORT proton-cpp -+# RUNTIME DESTINATION bin -+# ARCHIVE DESTINATION ${LIB_INSTALL_DIR} -+# LIBRARY DESTINATION ${LIB_INSTALL_DIR}) - - # Install windows qpid-proton-cpp pdb files - if (MSVC) -@@ -209,12 +209,12 @@ - - install (DIRECTORY "include/proton" DESTINATION ${INCLUDE_INSTALL_DIR} FILES_MATCHING PATTERN "*.hpp") - install (FILES "${CMAKE_CURRENT_BINARY_DIR}/config_presets.hpp" DESTINATION "${INCLUDE_INSTALL_DIR}/proton/internal") --install (DIRECTORY "examples/" -- DESTINATION "${PROTON_SHARE}/examples/cpp" -- USE_SOURCE_PERMISSIONS -- PATTERN "ProtonCppConfig.cmake" EXCLUDE) -+# install (DIRECTORY "examples/" -+# DESTINATION "${PROTON_SHARE}/examples/cpp" -+# USE_SOURCE_PERMISSIONS -+# PATTERN "ProtonCppConfig.cmake" EXCLUDE) - --add_subdirectory(examples) -+# add_subdirectory(examples) - add_subdirectory(docs) - - # Pkg config file -@@ -268,40 +268,40 @@ - set(test_env ${test_env} "PATH=$") - endif() - --macro(add_cpp_test test) -- add_executable (${test} src/${test}.cpp) -- target_link_libraries (${test} qpid-proton-cpp ${PLATFORM_LIBS}) -- add_test (NAME cpp-${test} -- COMMAND ${PN_ENV_SCRIPT} -- ${test_env} ${TEST_EXE_PREFIX_CMD} $ ${ARGN}) --endmacro(add_cpp_test) -- --add_cpp_test(codec_test) --add_cpp_test(connection_driver_test) --add_cpp_test(interop_test ${CMAKE_SOURCE_DIR}/tests) --add_cpp_test(message_test) --add_cpp_test(map_test) --add_cpp_test(scalar_test) --add_cpp_test(value_test) --add_cpp_test(container_test) --add_cpp_test(reconnect_test) --add_cpp_test(link_test) --add_cpp_test(credit_test) --if (ENABLE_JSONCPP) -- add_cpp_test(connect_config_test) -- target_link_libraries(connect_config_test qpid-proton-core) # For pn_sasl_enabled -- set_tests_properties(cpp-connect_config_test PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") -- # Test data and output directories for connect_config_test -- file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/testdata" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") --endif() -+# macro(add_cpp_test test) -+# add_executable (${test} src/${test}.cpp) -+# target_link_libraries (${test} qpid-proton-cpp ${PLATFORM_LIBS}) -+# add_test (NAME cpp-${test} -+# COMMAND ${PN_ENV_SCRIPT} -- ${test_env} ${TEST_EXE_PREFIX_CMD} $ ${ARGN}) -+# endmacro(add_cpp_test) -+# -+# add_cpp_test(codec_test) -+# add_cpp_test(connection_driver_test) -+# add_cpp_test(interop_test ${CMAKE_SOURCE_DIR}/tests) -+# add_cpp_test(message_test) -+# add_cpp_test(map_test) -+# add_cpp_test(scalar_test) -+# add_cpp_test(value_test) -+# add_cpp_test(container_test) -+# add_cpp_test(reconnect_test) -+# add_cpp_test(link_test) -+# add_cpp_test(credit_test) -+# if (ENABLE_JSONCPP) -+# add_cpp_test(connect_config_test) -+# target_link_libraries(connect_config_test qpid-proton-core) # For pn_sasl_enabled -+# set_tests_properties(cpp-connect_config_test PROPERTIES WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") -+# # Test data and output directories for connect_config_test -+# file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/testdata" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") -+# endif() - - # TODO aconway 2018-10-31: Catch2 tests - # This is a simple example of a C++ test using the Catch2 framework. - # See c/tests/ for more interesting examples. - # Eventually all the C++ tests will migrate to Catch2. - --include_directories(${CMAKE_SOURCE_DIR}/tests/include) --add_executable(cpp-test src/cpp-test.cpp src/url_test.cpp) --target_link_libraries(cpp-test qpid-proton-cpp ${PLATFORM_LIBS}) -+#include_directories(${CMAKE_SOURCE_DIR}/tests/include) -+#add_executable(cpp-test src/cpp-test.cpp src/url_test.cpp) -+#target_link_libraries(cpp-test qpid-proton-cpp ${PLATFORM_LIBS}) - - macro(add_catch_test tag) - add_test ( diff --git a/doc/amqp.md b/doc/amqp.md deleted file mode 100644 index 431fa55b1..000000000 --- a/doc/amqp.md +++ /dev/null @@ -1,123 +0,0 @@ -# Block and Transaction Broadcasting With AMQP 1.0 (Experimental Feature) - -[AMQP](https://www.amqp.org/) is an enterprise-level message queuing -protocol for the reliable passing of real-time data and business -transactions between applications. AMQP supports both broker and -brokerless messaging. AMQP 1.0 is an open standard and has been -ratified as ISO/IEC 19464. - -The Hush daemon can be configured to act as a trusted "border -router", implementing the Hush P2P protocol and relay, making -consensus decisions, maintaining the local blockchain database, -broadcasting locally generated transactions into the network, and -providing a queryable RPC interface to interact on a polled basis for -requesting blockchain related data. However, there exists only a -limited service to notify external software of events like the arrival -of new blocks or transactions. - -The AMQP facility implements a notification interface through a set -of specific notifiers. Currently there are notifiers that publish -blocks and transactions. This read-only facility requires only the -connection of a corresponding AMQP subscriber port in receiving -software. - -Currently the facility is not authenticated nor is there any two-way -protocol involvement. Therefore, subscribers should validate the -received data since it may be out of date, incomplete or even invalid. - -Because AMQP is message oriented, subscribers receive transactions -and blocks all-at-once and do not need to implement any sort of -buffering or reassembly. - -## Prerequisites - -The AMQP feature in Hush requires [Qpid Proton](https://qpid.apache.org/proton/) -version 0.17 or newer, which you will need to install if you are not -using the depends system. Typically, it is packaged by distributions as -something like *libqpid-proton*. The C++ wrapper for AMQP *is* required. - -In order to run the example Python client scripts in contrib/ one must -also install *python-qpid-proton*, though this is not necessary for -daemon operation. - -## Enabling - -By default, the AMQP feature is automatically compiled in if the -necessary prerequisites are found. To disable, use --disable-proton -during the *configure* step of building zcashd: - - $ ./configure --disable-proton (other options) - -To actually enable operation, one must set the appropriate options on -the commandline or in the configuration file. - -## Usage - -AMQP support is currently an experimental feature, so you must pass -the option: - - -experimentalfeatures - -Currently, the following notifications are supported: - - -amqppubhashtx=address - -amqppubhashblock=address - -amqppubrawblock=address - -amqppubrawtx=address - -The address must be a valid AMQP address, where the same address can be -used in more than notification. Note that SSL and SASL addresses are -not currently supported. - -Launch zcashd like this: - - $ zcashd -amqppubhashtx=amqp://127.0.0.1:5672 - -Or this: - - $ zcashd -amqppubhashtx=amqp://127.0.0.1:5672 \ - -amqppubrawtx=amqp://127.0.0.1:5672 \ - -amqppubrawblock=amqp://127.0.0.1:5672 \ - -amqppubhashblock=amqp://127.0.0.1:5672 \ - -debug=amqp - -The debug category `amqp` enables AMQP-related logging. - -Each notification has a topic and body, where the header corresponds -to the notification type. For instance, for the notification `-amqpubhashtx` -the topic is `hashtx` (no null terminator) and the body is the hexadecimal -transaction hash (32 bytes). This transaction hash and the block hash -found in `hashblock` are in RPC byte order. - -These options can also be provided in zcash.conf. - -Please see `contrib/amqp/amqp_sub.py` for a working example of an -AMQP server listening for messages. - -## Remarks - -From the perspective of zcashd, the local end of an AMQP link is write-only. - -No information is broadcast that wasn't already received from the public -P2P network. - -No authentication or authorization is done on peers that zcashd connects -to; it is assumed that the AMQP link is exposed only to trusted entities, -using other means such as firewalling. - -TLS support may be added once OpenSSL has been removed from the Hush -project and alternative TLS implementations have been evaluated. - -SASL support may be added in a future update for secure communication. - -Note that when the block chain tip changes, a reorganisation may occur -and just the tip will be notified. It is up to the subscriber to -retrieve the chain from the last known block to the new tip. - -At present, zcashd does not try to resend a notification if there was -a problem confirming receipt. Support for delivery guarantees such as -*at-least-once* and *exactly-once* will be added in in a future update. - -Currently, zcashd appends an up-counting sequence number to each notification -which allows listeners to detect lost notifications. - diff --git a/qa/pull-tester/rpc-tests.sh b/qa/pull-tester/rpc-tests.sh index 35bf5a7e9..4af883ea3 100755 --- a/qa/pull-tester/rpc-tests.sh +++ b/qa/pull-tester/rpc-tests.sh @@ -96,10 +96,6 @@ if [ "x$ENABLE_ZMQ" = "x1" ]; then testScripts+=('zmq_test.py') fi -if [ "x$ENABLE_PROTON" = "x1" ]; then - testScripts+=('proton_test.py') -fi - extArg="-extended" passOn=${@#$extArg} diff --git a/qa/rpc-tests/proton_test.py b/qa/rpc-tests/proton_test.py deleted file mode 100755 index d9fb27bd3..000000000 --- a/qa/rpc-tests/proton_test.py +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/env python2 -# Copyright (c) 2017 The Zcash developers -# Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. - -# -# Test Proton interface (provides AMQP 1.0 messaging support). -# -# Requirements: -# Python library for Qpid Proton: -# https://pypi.python.org/pypi/python-qpid-proton -# To install: -# pip install python-qpid-proton -# - -from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal, bytes_to_hex_str, \ - start_nodes - -from proton.handlers import MessagingHandler -from proton.reactor import Container - -import threading - - -class Server(MessagingHandler): - - def __init__(self, url, limit): - super(Server, self).__init__() - self.url = url - self.counter = limit - self.blockhashes = [] - self.txids = [] - self.blockseq = -1 - self.txidseq = -1 - - def on_start(self, event): - print "Proton listening on:", self.url - self.container = event.container - self.acceptor = event.container.listen(self.url) - - def on_message(self, event): - m = event.message - hash = bytes_to_hex_str(m.body) - sequence = m.properties['x-opt-sequence-number'] - if m.subject == "hashtx": - self.txids.append(hash) - - # Test that sequence id is incrementing - assert(sequence == 1 + self.txidseq) - self.txidseq = sequence - elif m.subject == "hashblock": - self.blockhashes.append(hash) - - # Test that sequence id is incrementing - assert(sequence == 1 + self.blockseq) - self.blockseq = sequence - - self.counter = self.counter - 1 - if self.counter == 0: - self.container.stop() - - -class ProtonTest (BitcoinTestFramework): - - port = 25672 - numblocks = 10 # must be even, as two nodes generate equal number - assert(numblocks % 2 == 0) - - def setup_nodes(self): - - # Launch proton server in background thread - # It terminates after receiving numblocks * 2 messages (one for coinbase, one for block) - self.server = Server("127.0.0.1:%i" % self.port, self.numblocks * 2) - self.container = Container(self.server) - self.t1 = threading.Thread(target=self.container.run) - self.t1.start() - - return start_nodes(4, self.options.tmpdir, extra_args=[ - ['-experimentalfeatures', '-debug=amqp', '-amqppubhashtx=amqp://127.0.0.1:'+str(self.port), - '-amqppubhashblock=amqp://127.0.0.1:'+str(self.port)], - [], - [], - [] - ]) - - def run_test(self): - self.sync_all() - baseheight = self.nodes[0].getblockcount() # 200 blocks already mined - - # generate some blocks - self.nodes[0].generate(self.numblocks/2) - self.sync_all() - self.nodes[1].generate(self.numblocks/2) - self.sync_all() - - # wait for server to finish - self.t1.join() - - # sequence numbers have already been checked in the server's message handler - - # sanity check that we have the right number of block hashes and coinbase txids - assert_equal(len(self.server.blockhashes), self.numblocks) - assert_equal(len(self.server.txids), self.numblocks) - - # verify that each block has the correct coinbase txid - for i in xrange(0, self.numblocks): - height = baseheight + i + 1 - blockhash = self.nodes[0].getblockhash(height) - assert_equal(blockhash, self.server.blockhashes[i]) - resp = self.nodes[0].getblock(blockhash) - coinbase = resp["tx"][0] - assert_equal(coinbase, self.server.txids[i]) - - -if __name__ == '__main__': - ProtonTest().main() diff --git a/src/Makefile.am b/src/Makefile.am index eb41a0031..88e33df95 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -54,9 +54,6 @@ LIBZCASH=libzcash.a if ENABLE_ZMQ LIBBITCOIN_ZMQ=libbitcoin_zmq.a endif -if ENABLE_PROTON -LIBBITCOIN_PROTON=libbitcoin_proton.a -endif if BUILD_BITCOIN_LIBS LIBZCASH_CONSENSUS=libzcashconsensus.la endif @@ -89,9 +86,6 @@ endif if ENABLE_ZMQ EXTRA_LIBRARIES += $(LIBBITCOIN_ZMQ) endif -if ENABLE_PROTON -EXTRA_LIBRARIES += $(LIBBITCOIN_PROTON) -endif lib_LTLIBRARIES = $(LIBZCASH_CONSENSUS) @@ -331,15 +325,6 @@ libbitcoin_zmq_a_SOURCES = \ zmq/zmqpublishnotifier.cpp endif -if ENABLE_PROTON -libbitcoin_proton_a_CPPFLAGS = $(BITCOIN_INCLUDES) -libbitcoin_proton_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) -libbitcoin_proton_a_SOURCES = \ - amqp/amqpabstractnotifier.cpp \ - amqp/amqpnotificationinterface.cpp \ - amqp/amqppublishnotifier.cpp -endif - # wallet: komodod, but only linked when wallet enabled libbitcoin_wallet_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) libbitcoin_wallet_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) @@ -504,7 +489,6 @@ komodod_LDADD = \ $(LIBUNIVALUE) \ $(LIBBITCOIN_UTIL) \ $(LIBBITCOIN_ZMQ) \ - $(LIBBITCOIN_PROTON) \ $(LIBBITCOIN_CRYPTO) \ $(LIBZCASH) \ $(LIBLEVELDB) \ @@ -524,7 +508,6 @@ komodod_LDADD += \ $(EVENT_PTHREADS_LIBS) \ $(EVENT_LIBS) \ $(ZMQ_LIBS) \ - $(PROTON_LIBS) \ $(LIBBITCOIN_CRYPTO) \ $(LIBZCASH_LIBS) @@ -538,10 +521,6 @@ if TARGET_LINUX komodod_LDADD += libcc.so $(LIBSECP256K1) endif -if ENABLE_PROTON -komodod_LDADD += $(LIBBITCOIN_PROTON) $(PROTON_LIBS) -endif - # [+] Decker: use static linking for libstdc++.6.dylib, libgomp.1.dylib, libgcc_s.1.dylib if TARGET_DARWIN komodod_LDFLAGS += -static-libgcc diff --git a/src/Makefile.gtest.include b/src/Makefile.gtest.include index 1f1b511db..b259cbd4b 100644 --- a/src/Makefile.gtest.include +++ b/src/Makefile.gtest.include @@ -65,11 +65,6 @@ endif komodo_gtest_LDADD += $(LIBZCASH_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(LIBZCASH) $(LIBZCASH_LIBS) -if ENABLE_PROTON -komodo_gtest_LDADD += $(LIBBITCOIN_PROTON) $(PROTON_LIBS) -endif - - komodo_gtest_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static komodo_gtest_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static diff --git a/src/Makefile.test.include b/src/Makefile.test.include index 14324b02b..0e2433bfd 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -130,10 +130,6 @@ if ENABLE_ZMQ test_test_bitcoin_LDADD += $(ZMQ_LIBS) endif -if ENABLE_PROTON -test_test_bitcoin_LDADD += $(PROTON_LIBS) -endif - nodist_test_test_bitcoin_SOURCES = $(GENERATED_TEST_FILES) $(BITCOIN_TESTS): $(GENERATED_TEST_FILES) diff --git a/src/amqp/amqpabstractnotifier.cpp b/src/amqp/amqpabstractnotifier.cpp deleted file mode 100644 index 57686ef1d..000000000 --- a/src/amqp/amqpabstractnotifier.cpp +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include "amqpabstractnotifier.h" -#include "util.h" - - -AMQPAbstractNotifier::~AMQPAbstractNotifier() -{ -} - -bool AMQPAbstractNotifier::NotifyBlock(const CBlockIndex * /*CBlockIndex*/) -{ - return true; -} - -bool AMQPAbstractNotifier::NotifyTransaction(const CTransaction &/*transaction*/) -{ - return true; -} diff --git a/src/amqp/amqpabstractnotifier.h b/src/amqp/amqpabstractnotifier.h deleted file mode 100644 index c993a2b3e..000000000 --- a/src/amqp/amqpabstractnotifier.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef ZCASH_AMQP_AMQPABSTRACTNOTIFIER_H -#define ZCASH_AMQP_AMQPABSTRACTNOTIFIER_H - -#include "amqpconfig.h" - -class CBlockIndex; -class AMQPAbstractNotifier; - -typedef AMQPAbstractNotifier* (*AMQPNotifierFactory)(); - -class AMQPAbstractNotifier -{ -public: - AMQPAbstractNotifier() { } - virtual ~AMQPAbstractNotifier(); - - template - static AMQPAbstractNotifier* Create() - { - return new T(); - } - - std::string GetType() const { return type; } - void SetType(const std::string &t) { type = t; } - std::string GetAddress() const { return address; } - void SetAddress(const std::string &a) { address = a; } - - virtual bool Initialize() = 0; - virtual void Shutdown() = 0; - - virtual bool NotifyBlock(const CBlockIndex *pindex); - virtual bool NotifyTransaction(const CTransaction &transaction); - -protected: - std::string type; - std::string address; -}; - -#endif // ZCASH_AMQP_AMQPABSTRACTNOTIFIER_H diff --git a/src/amqp/amqpconfig.h b/src/amqp/amqpconfig.h deleted file mode 100644 index dcc5f7709..000000000 --- a/src/amqp/amqpconfig.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef ZCASH_AMQP_AMQPCONFIG_H -#define ZCASH_AMQP_AMQPCONFIG_H - -#if defined(HAVE_CONFIG_H) -#include "config/bitcoin-config.h" -#endif - -#include -#include - -#if ENABLE_PROTON -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#endif - -#include "primitives/block.h" -#include "primitives/transaction.h" - -#endif // ZCASH_AMQP_AMQPCONFIG_H diff --git a/src/amqp/amqpnotificationinterface.cpp b/src/amqp/amqpnotificationinterface.cpp deleted file mode 100644 index 66f5398ca..000000000 --- a/src/amqp/amqpnotificationinterface.cpp +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include "amqpnotificationinterface.h" -#include "amqppublishnotifier.h" - -#include "version.h" -#include "main.h" -#include "streams.h" -#include "util.h" - -// AMQP 1.0 Support -// -// The boost::signals2 signals and slot system is thread safe, so CValidationInterface listeners -// can be invoked from any thread. -// -// Currently signals are fired from main.cpp so the callbacks should be invoked on the same thread. -// It should be safe to share objects responsible for sending, as they should not be run concurrently -// across different threads. -// -// Developers should be mindful of where notifications are fired to avoid potential race conditions. -// For example, different signals targeting the same address could be fired from different threads -// in different parts of the system around the same time. -// -// Like the ZMQ notification interface, if a notifier fails to send a message, the notifier is shut down. -// - -AMQPNotificationInterface::AMQPNotificationInterface() -{ -} - -AMQPNotificationInterface::~AMQPNotificationInterface() -{ - Shutdown(); - - for (std::list::iterator i = notifiers.begin(); i != notifiers.end(); ++i) { - delete *i; - } -} - -AMQPNotificationInterface* AMQPNotificationInterface::CreateWithArguments(const std::map &args) -{ - AMQPNotificationInterface* notificationInterface = nullptr; - std::map factories; - std::list notifiers; - - factories["pubhashblock"] = AMQPAbstractNotifier::Create; - factories["pubhashtx"] = AMQPAbstractNotifier::Create; - factories["pubrawblock"] = AMQPAbstractNotifier::Create; - factories["pubrawtx"] = AMQPAbstractNotifier::Create; - - for (std::map::const_iterator i=factories.begin(); i!=factories.end(); ++i) { - std::map::const_iterator j = args.find("-amqp" + i->first); - if (j!=args.end()) { - AMQPNotifierFactory factory = i->second; - std::string address = j->second; - AMQPAbstractNotifier *notifier = factory(); - notifier->SetType(i->first); - notifier->SetAddress(address); - notifiers.push_back(notifier); - } - } - - if (!notifiers.empty()) { - notificationInterface = new AMQPNotificationInterface(); - notificationInterface->notifiers = notifiers; - - if (!notificationInterface->Initialize()) { - delete notificationInterface; - notificationInterface = nullptr; - } - } - - return notificationInterface; -} - -// Called at startup to conditionally set up -bool AMQPNotificationInterface::Initialize() -{ - LogPrint("amqp", "amqp: Initialize notification interface\n"); - - std::list::iterator i = notifiers.begin(); - for (; i != notifiers.end(); ++i) { - AMQPAbstractNotifier *notifier = *i; - if (notifier->Initialize()) { - LogPrint("amqp", "amqp: Notifier %s ready (address = %s)\n", notifier->GetType(), notifier->GetAddress()); - } else { - LogPrint("amqp", "amqp: Notifier %s failed (address = %s)\n", notifier->GetType(), notifier->GetAddress()); - break; - } - } - - if (i != notifiers.end()) { - return false; - } - - return true; -} - -// Called during shutdown sequence -void AMQPNotificationInterface::Shutdown() -{ - LogPrint("amqp", "amqp: Shutdown notification interface\n"); - - for (std::list::iterator i = notifiers.begin(); i != notifiers.end(); ++i) { - AMQPAbstractNotifier *notifier = *i; - notifier->Shutdown(); - } -} - -void AMQPNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindex) -{ - for (std::list::iterator i = notifiers.begin(); i != notifiers.end(); ) { - AMQPAbstractNotifier *notifier = *i; - if (notifier->NotifyBlock(pindex)) { - i++; - } else { - notifier->Shutdown(); - i = notifiers.erase(i); - } - } -} - -void AMQPNotificationInterface::SyncTransaction(const CTransaction &tx, const CBlock *pblock) -{ - for (std::list::iterator i = notifiers.begin(); i != notifiers.end(); ) { - AMQPAbstractNotifier *notifier = *i; - if (notifier->NotifyTransaction(tx)) { - i++; - } else { - notifier->Shutdown(); - i = notifiers.erase(i); - } - } -} diff --git a/src/amqp/amqpnotificationinterface.h b/src/amqp/amqpnotificationinterface.h deleted file mode 100644 index 0c07ce235..000000000 --- a/src/amqp/amqpnotificationinterface.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef ZCASH_AMQP_AMQPNOTIFICATIONINTERFACE_H -#define ZCASH_AMQP_AMQPNOTIFICATIONINTERFACE_H - -#include "validationinterface.h" -#include -#include - -class CBlockIndex; -class AMQPAbstractNotifier; - -class AMQPNotificationInterface : public CValidationInterface -{ -public: - virtual ~AMQPNotificationInterface(); - - static AMQPNotificationInterface* CreateWithArguments(const std::map &args); - -protected: - bool Initialize(); - void Shutdown(); - - // CValidationInterface - void SyncTransaction(const CTransaction &tx, const CBlock *pblock); - void UpdatedBlockTip(const CBlockIndex *pindex); - -private: - AMQPNotificationInterface(); - - std::list notifiers; -}; - -#endif // ZCASH_AMQP_AMQPNOTIFICATIONINTERFACE_H diff --git a/src/amqp/amqppublishnotifier.cpp b/src/amqp/amqppublishnotifier.cpp deleted file mode 100644 index 589eb151f..000000000 --- a/src/amqp/amqppublishnotifier.cpp +++ /dev/null @@ -1,177 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include "amqppublishnotifier.h" -#include "main.h" -#include "util.h" - -#include "amqpsender.h" - -#include -#include - -static std::multimap mapPublishNotifiers; - -static const char *MSG_HASHBLOCK = "hashblock"; -static const char *MSG_HASHTX = "hashtx"; -static const char *MSG_RAWBLOCK = "rawblock"; -static const char *MSG_RAWTX = "rawtx"; - -// Invoke this method from a new thread to run the proton container event loop. -void AMQPAbstractPublishNotifier::SpawnProtonContainer() -{ - try { - proton::default_container(*handler_).run(); - } - catch (const proton::error_condition &e) { - LogPrint("amqp", "amqp: container error: %s\n", e.what()); - } - catch (const std::runtime_error &e) { - LogPrint("amqp", "amqp: runtime error: %s\n", e.what()); - } - catch (const std::exception &e) { - LogPrint("amqp", "amqp: exception: %s\n", e.what()); - } - catch (...) { - LogPrint("amqp", "amqp: unknown error\n"); - } - handler_->terminate(); -} - -bool AMQPAbstractPublishNotifier::Initialize() -{ - std::multimap::iterator i = mapPublishNotifiers.find(address); - - if (i == mapPublishNotifiers.end()) { - try { - handler_ = std::make_shared(address); - thread_ = std::make_shared(&AMQPAbstractPublishNotifier::SpawnProtonContainer, this); - } - catch (std::exception &e) { - LogPrint("amqp", "amqp: initialization error: %s\n", e.what()); - return false; - } - mapPublishNotifiers.insert(std::make_pair(address, this)); - } else { - // copy the shared ptrs to the message handler and the thread where the proton container is running - handler_ = i->second->handler_; - thread_ = i->second->thread_; - mapPublishNotifiers.insert(std::make_pair(address, this)); - } - - return true; -} - - -void AMQPAbstractPublishNotifier::Shutdown() -{ - LogPrint("amqp", "amqp: Shutdown notifier %s at %s\n", GetType(), GetAddress()); - - int count = mapPublishNotifiers.count(address); - - // remove this notifier from the list of publishers using this address - typedef std::multimap::iterator iterator; - std::pair iterpair = mapPublishNotifiers.equal_range(address); - - for (iterator it = iterpair.first; it != iterpair.second; ++it) { - if (it->second == this) { - mapPublishNotifiers.erase(it); - break; - } - } - - // terminate the connection if this is the last publisher using this address - if (count == 1) { - handler_->terminate(); - if (thread_.get() != nullptr) { - if (thread_->joinable()) { - thread_->join(); - } - } - } -} - - -bool AMQPAbstractPublishNotifier::SendMessage(const char *command, const void* data, size_t size) -{ - try { - proton::binary content; - const char *p = (const char *)data; - content.assign(p, p + size); - - proton::message message(content); - message.subject(std::string(command)); - proton::message::property_map & props = message.properties(); - props.put("x-opt-sequence-number", sequence_); - handler_->publish(message); - - } catch (proton::error_condition &e) { - LogPrint("amqp", "amqp: error : %s\n", e.what()); - return false; - } - catch (const std::runtime_error &e) { - LogPrint("amqp", "amqp: runtime error: %s\n", e.what()); - return false; - } - catch (const std::exception &e) { - LogPrint("amqp", "amqp: exception: %s\n", e.what()); - return false; - } - catch (...) { - LogPrint("amqp", "amqp: unknown error\n"); - return false; - } - - sequence_++; - - return true; -} - -bool AMQPPublishHashBlockNotifier::NotifyBlock(const CBlockIndex *pindex) -{ - uint256 hash = pindex->GetBlockHash(); - LogPrint("amqp", "amqp: Publish hashblock %s\n", hash.GetHex()); - char data[32]; - for (unsigned int i = 0; i < 32; i++) - data[31 - i] = hash.begin()[i]; - return SendMessage(MSG_HASHBLOCK, data, 32); -} - -bool AMQPPublishHashTransactionNotifier::NotifyTransaction(const CTransaction &transaction) -{ - uint256 hash = transaction.GetHash(); - LogPrint("amqp", "amqp: Publish hashtx %s\n", hash.GetHex()); - char data[32]; - for (unsigned int i = 0; i < 32; i++) - data[31 - i] = hash.begin()[i]; - return SendMessage(MSG_HASHTX, data, 32); -} - -bool AMQPPublishRawBlockNotifier::NotifyBlock(const CBlockIndex *pindex) -{ - LogPrint("amqp", "amqp: Publish rawblock %s\n", pindex->GetBlockHash().GetHex()); - - CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - { - LOCK(cs_main); - CBlock block; - if(!ReadBlockFromDisk(block, pindex)) { - LogPrint("amqp", "amqp: Can't read block from disk"); - return false; - } - - ss << block; - } - - return SendMessage(MSG_RAWBLOCK, &(*ss.begin()), ss.size()); -} - -bool AMQPPublishRawTransactionNotifier::NotifyTransaction(const CTransaction &transaction) -{ - uint256 hash = transaction.GetHash(); - LogPrint("amqp", "amqp: Publish rawtx %s\n", hash.GetHex()); - CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); - ss << transaction; - return SendMessage(MSG_RAWTX, &(*ss.begin()), ss.size()); -} diff --git a/src/amqp/amqppublishnotifier.h b/src/amqp/amqppublishnotifier.h deleted file mode 100644 index 08b3aba08..000000000 --- a/src/amqp/amqppublishnotifier.h +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef ZCASH_AMQP_AMQPPUBLISHNOTIFIER_H -#define ZCASH_AMQP_AMQPPUBLISHNOTIFIER_H - -#include "amqpabstractnotifier.h" -#include "amqpconfig.h" -#include "amqpsender.h" - -#include -#include - -class CBlockIndex; - -class AMQPAbstractPublishNotifier : public AMQPAbstractNotifier -{ -private: - uint64_t sequence_; // memory only, per notifier instance: upcounting message sequence number - - std::shared_ptr thread_; // proton container thread, may be shared between notifiers - std::shared_ptr handler_; // proton container message handler, may be shared between notifiers - -public: - bool SendMessage(const char *command, const void* data, size_t size); - bool Initialize(); - void Shutdown(); - void SpawnProtonContainer(); -}; - -class AMQPPublishHashBlockNotifier : public AMQPAbstractPublishNotifier -{ -public: - bool NotifyBlock(const CBlockIndex *pindex); -}; - -class AMQPPublishHashTransactionNotifier : public AMQPAbstractPublishNotifier -{ -public: - bool NotifyTransaction(const CTransaction &transaction); -}; - -class AMQPPublishRawBlockNotifier : public AMQPAbstractPublishNotifier -{ -public: - bool NotifyBlock(const CBlockIndex *pindex); -}; - -class AMQPPublishRawTransactionNotifier : public AMQPAbstractPublishNotifier -{ -public: - bool NotifyTransaction(const CTransaction &transaction); -}; - -#endif // ZCASH_AMQP_AMQPPUBLISHNOTIFIER_H diff --git a/src/amqp/amqpsender.h b/src/amqp/amqpsender.h deleted file mode 100644 index 7fa85d89c..000000000 --- a/src/amqp/amqpsender.h +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (c) 2017 The Zcash developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef ZCASH_AMQP_AMQPSENDER_H -#define ZCASH_AMQP_AMQPSENDER_H - -#include "amqpconfig.h" - -#include -#include -#include -#include - -class AMQPSender : public proton::messaging_handler { - private: - std::deque messages_; - proton::url url_; - proton::connection conn_; - proton::sender sender_; - std::mutex lock_; - std::atomic terminated_ = {false}; - - public: - - AMQPSender(const std::string& url) : url_(url) {} - - // Callback to initialize the container when run() is invoked - void on_container_start(proton::container& c) override { - proton::duration t(10000); // milliseconds - proton::connection_options opts = proton::connection_options().idle_timeout(t); - conn_ = c.connect(url_, opts); - sender_ = conn_.open_sender(url_.path()); - } - - // Remote end signals when the local end can send (i.e. has credit) - void on_sendable(proton::sender &s) override { - dispatch(); - } - - // Publish message by adding to queue and trying to dispatch it - void publish(const proton::message &m) { - add_message(m); - dispatch(); - } - - // Add message to queue - void add_message(const proton::message &m) { - std::lock_guard guard(lock_); - messages_.push_back(m); - } - - // Send messages in queue - void dispatch() { - std::lock_guard guard(lock_); - - if (isTerminated()) { - throw std::runtime_error("amqp connection was terminated"); - } - - if (!conn_.active()) { - throw std::runtime_error("amqp connection is not active"); - } - - while (messages_.size() > 0) { - if (sender_.credit()) { - const proton::message& m = messages_.front(); - sender_.send(m); - messages_.pop_front(); - } else { - break; - } - } - } - - // Close connection to remote end. Container event-loop, by default, will auto-stop. - void terminate() { - std::lock_guard guard(lock_); - conn_.close(); - terminated_.store(true); - } - - bool isTerminated() const { - return terminated_.load(); - } - - void on_transport_error(proton::transport &t) override { - t.connection().close(); - throw t.error(); - } - - void on_connection_error(proton::connection &c) override { - c.close(); - throw c.error(); - } - - void on_session_error(proton::session &s) override { - s.connection().close(); - throw s.error(); - } - - void on_receiver_error(proton::receiver &r) override { - r.connection().close(); - throw r.error(); - } - - void on_sender_error(proton::sender &s) override { - s.connection().close(); - throw s.error(); - } - -}; - - -#endif //ZCASH_AMQP_AMQPSENDER_H diff --git a/src/init.cpp b/src/init.cpp index c43c5b0b4..d52888503 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -84,10 +84,6 @@ #include "zmq/zmqnotificationinterface.h" #endif -#if ENABLE_PROTON -#include "amqp/amqpnotificationinterface.h" -#endif - #include "librustzcash.h" using namespace std; @@ -112,10 +108,6 @@ bool fFeeEstimatesInitialized = false; static CZMQNotificationInterface* pzmqNotificationInterface = NULL; #endif -#if ENABLE_PROTON -static AMQPNotificationInterface* pAMQPNotificationInterface = NULL; -#endif - #ifdef WIN32 // Win32 LevelDB doesn't use file descriptors, and the ones used for // accessing block files don't count towards the fd_set size limit @@ -285,14 +277,6 @@ void Shutdown() } #endif -#if ENABLE_PROTON - if (pAMQPNotificationInterface) { - UnregisterValidationInterface(pAMQPNotificationInterface); - delete pAMQPNotificationInterface; - pAMQPNotificationInterface = NULL; - } -#endif - #ifndef WIN32 try { boost::filesystem::remove(GetPidFile()); @@ -486,14 +470,6 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-zmqpubrawtx=
", _("Enable publish raw transaction in
")); #endif -#if ENABLE_PROTON - strUsage += HelpMessageGroup(_("AMQP 1.0 notification options:")); - strUsage += HelpMessageOpt("-amqppubhashblock=
", _("Enable publish hash block in
")); - strUsage += HelpMessageOpt("-amqppubhashtx=
", _("Enable publish hash transaction in
")); - strUsage += HelpMessageOpt("-amqppubrawblock=
", _("Enable publish raw block in
")); - strUsage += HelpMessageOpt("-amqppubrawtx=
", _("Enable publish raw transaction in
")); -#endif - strUsage += HelpMessageGroup(_("Debugging/Testing options:")); if (showDebug) { @@ -1624,21 +1600,6 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) } #endif -#if ENABLE_PROTON - pAMQPNotificationInterface = AMQPNotificationInterface::CreateWithArguments(mapArgs); - - if (pAMQPNotificationInterface) { - - // AMQP support is currently an experimental feature, so fail if user configured AMQP notifications - // without enabling experimental features. - if (!fExperimentalMode) { - return InitError(_("AMQP support requires -experimentalfeatures.")); - } - - RegisterValidationInterface(pAMQPNotificationInterface); - } -#endif - if ( KOMODO_NSPV_SUPERLITE ) { std::vector vImportFiles; diff --git a/zcutil/build-arm.sh b/zcutil/build-arm.sh index 2131fa7cb..838607c7e 100644 --- a/zcutil/build-arm.sh +++ b/zcutil/build-arm.sh @@ -51,7 +51,7 @@ PREFIX="$(pwd)/depends/aarch64-unknown-linux-gnu/" HOST=aarch64-unknown-linux-gnu BUILD=aarch64-unknown-linux-gnu make "$@" -C ./depends/ V=1 NO_QT=1 ./autogen.sh -CONFIG_SITE="$(pwd)/depends/aarch64-unknown-linux-gnu/share/config.site" ./configure --prefix="${PREFIX}" --host=aarch64-unknown-linux-gnu --build=aarch64-unknown-linux-gnu --with-gui=no --enable-rust=no --disable-proton "$HARDENING_ARG" "$LCOV_ARG" CXXFLAGS='-fwrapv -fno-strict-aliasing -g' +CONFIG_SITE="$(pwd)/depends/aarch64-unknown-linux-gnu/share/config.site" ./configure --prefix="${PREFIX}" --host=aarch64-unknown-linux-gnu --build=aarch64-unknown-linux-gnu --with-gui=no --enable-rust=no "$HARDENING_ARG" "$LCOV_ARG" CXXFLAGS='-fwrapv -fno-strict-aliasing -g' #BUILD CCLIB diff --git a/zcutil/build-mac.sh b/zcutil/build-mac.sh index 096ca96e4..12e426e71 100755 --- a/zcutil/build-mac.sh +++ b/zcutil/build-mac.sh @@ -43,7 +43,7 @@ fi TRIPLET=`./depends/config.guess` PREFIX="$(pwd)/depends/$TRIPLET" -make "$@" -C ./depends/ V=1 NO_QT=1 NO_PROTON=1 +make "$@" -C ./depends/ V=1 NO_QT=1 #BUILD CCLIB diff --git a/zcutil/build.sh b/zcutil/build.sh index 76980476b..6b90c0e01 100755 --- a/zcutil/build.sh +++ b/zcutil/build.sh @@ -58,12 +58,11 @@ Welcome To The Hush Build System, Here Be Dragons! Usage: $0 --help Show this help message and exit. -$0 [ --enable-lcov || --disable-tests ] [ --disable-mining ] [ --enable-proton ] [ --disable-libs ] [ MAKEARGS... ] +$0 [ --enable-lcov || --disable-tests ] [ --disable-mining ] [ --disable-libs ] [ MAKEARGS... ] Build Hush and most of its transitive dependencies from source. MAKEARGS are applied to both dependencies and Hush itself. If --enable-lcov is passed, Hush is configured to add coverage instrumentation, thus enabling "make cov" to work. If --disable-tests is passed instead, the Hush tests are not built. If --disable-mining is passed, Hush is configured to not build any mining code. It must be passed after the test arguments, if present. - If --enable-proton is passed, Hush is configured to build the Apache Qpid Proton library required for AMQP support. This library is not built by default. It must be passed after the test/mining arguments, if present. EOF exit 0 @@ -94,25 +93,17 @@ then shift fi -# If --enable-proton is the next argument, enable building Proton code: -PROTON_ARG='--enable-proton=no' -if [ "x${1:-}" = 'x--enable-proton' ] -then - PROTON_ARG='' - shift -fi - # Just show the useful info eval "$MAKE" --version | head -n2 as --version | head -n1 as --version | tail -n1 ld -v -HOST="$HOST" BUILD="$BUILD" NO_PROTON="$PROTON_ARG" "$MAKE" "$@" -C ./depends/ V=1 +HOST="$HOST" BUILD="$BUILD" "$MAKE" "$@" -C ./depends/ V=1 ./autogen.sh -CONFIG_SITE="$PWD/depends/$HOST/share/config.site" ./configure "$HARDENING_ARG" "$LCOV_ARG" "$TEST_ARG" "$MINING_ARG" "$PROTON_ARG" $CONFIGURE_FLAGS CXXFLAGS='-g' +CONFIG_SITE="$PWD/depends/$HOST/share/config.site" ./configure "$HARDENING_ARG" "$LCOV_ARG" "$TEST_ARG" "$MINING_ARG" $CONFIGURE_FLAGS CXXFLAGS='-g' #BUILD CCLIB From c0eb0631e28c980534a476f6c981eb9303194748 Mon Sep 17 00:00:00 2001 From: miodragpop Date: Fri, 17 Jul 2020 01:58:23 +0200 Subject: [PATCH 120/255] rust reverted to version 1.32.0 --- depends/packages/rust.mk | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/depends/packages/rust.mk b/depends/packages/rust.mk index 2546a733e..6fbdda037 100644 --- a/depends/packages/rust.mk +++ b/depends/packages/rust.mk @@ -1,12 +1,12 @@ package=rust -$(package)_version=1.42.0 +$(package)_version=1.32.0 $(package)_download_path=https://static.rust-lang.org/dist $(package)_file_name_linux=rust-$($(package)_version)-x86_64-unknown-linux-gnu.tar.gz -$(package)_sha256_hash_linux=7d1e07ad9c8a33d8d039def7c0a131c5917aa3ea0af3d0cc399c6faf7b789052 +$(package)_sha256_hash_linux=e024698320d76b74daf0e6e71be3681a1e7923122e3ebd03673fcac3ecc23810 $(package)_file_name_darwin=rust-$($(package)_version)-x86_64-apple-darwin.tar.gz -$(package)_sha256_hash_darwin=db1055c46e0d54b99da05e88c71fea21b3897e74a4f5ff9390e934f3f050c0a8 -$(package)_file_name_freebsd=rust-$($(package)_version)-x86_64-unknown-freebsd.tar.gz -$(package)_sha256_hash_freebsd=230bcf17e4383fba85d3c87fe25d17737459fe561a5f4668fe70dcac2da4e17c +$(package)_sha256_hash_darwin=f0dfba507192f9b5c330b5984ba71d57d434475f3d62bd44a39201e36fa76304 +$(package)_file_name_mingw32=rust-$($(package)_version)-x86_64-pc-windows-gnu.tar.gz +$(package)_sha256_hash_mingw32=358e1435347c67dbf33aa9cad6fe501a833d6633ed5d5aa1863d5dffa0349be9 # Mapping from GCC canonical hosts to Rust targets # If a mapping is not present, we assume they are identical, unless $host_os is @@ -14,9 +14,9 @@ $(package)_sha256_hash_freebsd=230bcf17e4383fba85d3c87fe25d17737459fe561a5f4668f $(package)_rust_target_x86_64-w64-mingw32=x86_64-pc-windows-gnu # Mapping from Rust targets to SHA-256 hashes -$(package)_rust_std_sha256_hash_aarch64-unknown-linux-gnu=1343f51fc87049327233cee8941629c3d7dfdc425d359385f93665de3d46711b -$(package)_rust_std_sha256_hash_x86_64-apple-darwin=1d61e9ed5d29e1bb4c18e13d551c6d856c73fb8b410053245dc6e0d3b3a0e92c -$(package)_rust_std_sha256_hash_x86_64-pc-windows-gnu=8a8389f3860df6f42fbf8b76a62ddc7b9b6fe6d0fb526dcfc42faab1005bfb6d +$(package)_rust_std_sha256_hash_aarch64-unknown-linux-gnu=346efe3aef2aff7b71a611bf7661bcec5f9bc4025a599c2866ec5fd330247cb9 +$(package)_rust_std_sha256_hash_x86_64-apple-darwin=b736d035a97f830585360e54e3f8877b68c942211cf0a75e805f34bfb36103a6 +$(package)_rust_std_sha256_hash_x86_64-pc-windows-gnu=cad5f1454d591c13eeb3657f1c9dbfeb30e648f59680bd0765b94c63e7afc49e define rust_target $(if $($(1)_rust_target_$(2)),$($(1)_rust_target_$(2)),$(if $(findstring darwin,$(3)),x86_64-apple-darwin,$(2))) From 534efcb65d509dd9b9146a7f7402e41b52bdadb5 Mon Sep 17 00:00:00 2001 From: miodragpop Date: Fri, 17 Jul 2020 02:28:27 +0200 Subject: [PATCH 121/255] malloc_trim is glibc specific --- src/wallet/wallet.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index ae845cb21..3c7040b45 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2439,11 +2439,10 @@ void CWallet::DeleteTransactions(std::vector &removeTxs) { return; } } -#if defined(__unix__) || defined(_WIN64) - // Miodrag: release memory back to the OS +#if defined(__GLIBC__) malloc_trim(0); #else - //TODO: This doesn't work on Mac + // On Mac and Win memory isn't kept back upon vector or list member erase, different garbage collector strategy. No need to force trimming. #endif } From fc409581f30d5ef446e6f32bba1b7bdce5b13cf5 Mon Sep 17 00:00:00 2001 From: miodragpop Date: Fri, 17 Jul 2020 02:35:25 +0200 Subject: [PATCH 122/255] updated .gitignore with cc dynamic libs built for Win --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 408d59085..ae3cff264 100644 --- a/.gitignore +++ b/.gitignore @@ -156,7 +156,9 @@ src/Makefile.in doc/man/Makefile.in Makefile.in src/libcc.so +src/libcc.dll src/cc/customcc.so +src/cc/customcc.dll src/HUSH3_7776 REGTEST_7776 src/cc/librogue.so From 29a06462cb46bb1dd43d66cc826bb84fb796f4b7 Mon Sep 17 00:00:00 2001 From: miodragpop Date: Fri, 17 Jul 2020 02:44:29 +0200 Subject: [PATCH 123/255] more associative naming convention --- src/cc/Makefile_custom | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/Makefile_custom b/src/cc/Makefile_custom index 0c2401f31..3989eefa3 100644 --- a/src/cc/Makefile_custom +++ b/src/cc/Makefile_custom @@ -2,7 +2,7 @@ SHELL = /bin/sh CC = gcc CC_DARWIN = g++-8 CC_WIN = x86_64-w64-mingw32-gcc-posix -CC_ARM64 = aarch64-linux-gnu-g++ +CC_AARCH64 = aarch64-linux-gnu-g++ CFLAGS_DARWIN = -DBUILD_CUSTOMCC -std=c++11 -arch x86_64 -I../secp256k1/include -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -Wl,-undefined -Wl,dynamic_lookup -Wno-write-strings -shared -dynamiclib CFLAGS = -Wno-write-strings -DBUILD_CUSTOMCC -std=c++11 -I../secp256k1/include -I../../depends/$(shell echo `../..//depends/config.guess`/include) -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared CFLAGS_WIN = -Wno-write-strings -DBUILD_CUSTOMCC -std=c++11 -I../secp256k1/include -I../../depends/x86_64-w64-mingw32/include -I../univalue/include -I../cryptoconditions/include -I../cryptoconditions/src -I../cryptoconditions/src/asn -I.. -I. -fPIC -shared @@ -31,7 +31,7 @@ else ifeq ($(HOST),x86_64-w64-mingw32) #else ifeq ($(WIN_HOST),True) - todo: pass ENV var from build.sh if WIN host else ifeq ($(HOST),aarch64-linux-gnu) $(info LINUX ARM 64bit ) - $(CC_ARM64) $(CFLAGS) $(DEBUGFLAGS) -o $(TARGET) -c $(SOURCES) + $(CC_AARCH64) $(CFLAGS) $(DEBUGFLAGS) -o $(TARGET) -c $(SOURCES) cp $(TARGET) ../libcc.so else $(info LINUX) From 221335602850703d2aaa23f06141097d4141f211 Mon Sep 17 00:00:00 2001 From: miodragpop Date: Fri, 17 Jul 2020 02:55:00 +0200 Subject: [PATCH 124/255] whitespaces: changes undoed --- configure.ac | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/configure.ac b/configure.ac index ace3612da..4d1c91acd 100644 --- a/configure.ac +++ b/configure.ac @@ -328,11 +328,11 @@ case $host in dnl AC_CHECK_PROG([BREW],brew, brew) dnl if test x$BREW = xbrew; then - dnl These Homebrew packages may be keg-only, meaning that they won't be found - dnl in expected paths because they may conflict with system files. Ask - dnl Homebrew where each one is located, then adjust paths accordingly. - dnl It's safe to add these paths even if the functionality is disabled by - dnl the user (--without-wallet for example). + dnl These Homebrew packages may be keg-only, meaning that they won't be found + dnl in expected paths because they may conflict with system files. Ask + dnl Homebrew where each one is located, then adjust paths accordingly. + dnl It's safe to add these paths even if the functionality is disabled by + dnl the user (--without-wallet for example). dnl openssl_prefix=`$BREW --prefix openssl 2>/dev/null` dnl bdb_prefix=`$BREW --prefix berkeley-db4 2>/dev/null` @@ -948,10 +948,10 @@ echo " with zmq = $use_zmq" echo " with test = $use_tests" echo " debug enabled = $enable_debug" echo " werror = $enable_werror" -echo +echo echo " target os = $TARGET_OS" echo " build os = $BUILD_OS" -echo +echo echo " CC = $CC" echo " CFLAGS = $CFLAGS" echo " CPPFLAGS = $CPPFLAGS" @@ -959,4 +959,4 @@ echo " CXX = $CXX" echo " CXXFLAGS = $CXXFLAGS" echo " LDFLAGS = $LDFLAGS" echo " ARFLAGS = $ARFLAGS" -echo +echo From 57052a0e9f1dd4f08f6a9218da2d7975135a9602 Mon Sep 17 00:00:00 2001 From: miodragpop Date: Fri, 17 Jul 2020 02:58:33 +0200 Subject: [PATCH 125/255] more typos fix --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 4d1c91acd..b14a6e156 100644 --- a/configure.ac +++ b/configure.ac @@ -686,7 +686,7 @@ if test x$use_pkgconfig = xyes; then ) else # BUG: Fix this: - echo 'BUG: configure does not yet check for the following dependencies if pkg-config is not on the system: libcrypto++, libgmp' + echo 'BUG: configure does not yet check for the following dependencies if pkg-config is not on the system: libcrypto++, gmp' AC_CHECK_HEADER([openssl/crypto.h],,AC_MSG_ERROR(libcrypto headers missing)) AC_CHECK_LIB([crypto], [main],CRYPTO_LIBS=-lcrypto, AC_MSG_ERROR(libcrypto missing)) @@ -951,7 +951,7 @@ echo " werror = $enable_werror" echo echo " target os = $TARGET_OS" echo " build os = $BUILD_OS" -echo +echo echo " CC = $CC" echo " CFLAGS = $CFLAGS" echo " CPPFLAGS = $CPPFLAGS" From 2112a1ae04878d0917fe4122a2bda78f8662fab4 Mon Sep 17 00:00:00 2001 From: miodragpop Date: Fri, 17 Jul 2020 03:01:40 +0200 Subject: [PATCH 126/255] ... and this one --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index b14a6e156..4ff3855b8 100644 --- a/configure.ac +++ b/configure.ac @@ -941,7 +941,7 @@ case $host in ;; esac -echo +echo echo "Options used to compile and link:" echo " with wallet = $enable_wallet" echo " with zmq = $use_zmq" From f7ec886a3e839b80aa18cb8c328909b43b799ae3 Mon Sep 17 00:00:00 2001 From: miodragpop Date: Fri, 17 Jul 2020 03:27:53 +0200 Subject: [PATCH 127/255] build-cross-aarch64.sh script removed for aarch64 cross-build use `HOST=aarch64-linux-gnu zcutil/build.sh` followed by optional parameters --- zcutil/build-cross-aarch64.sh | 64 ----------------------------------- 1 file changed, 64 deletions(-) delete mode 100755 zcutil/build-cross-aarch64.sh diff --git a/zcutil/build-cross-aarch64.sh b/zcutil/build-cross-aarch64.sh deleted file mode 100755 index eea5af471..000000000 --- a/zcutil/build-cross-aarch64.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/bash -# Copyright (c) 2019-2020 radix42 -# Copyright (c) 2019-2020 The Hush developers -# Original aarch64 port by radix42. Thank you! - -set -eu -o pipefail - -cat <<'EOF' - ________________ -< Building Hush! > - ---------------- - \ ^__^ - \ (oo)\_______ - (__)\ )\/\ - ||----w | - || || -EOF - -if [ "x$*" = 'x--help' ] -then - cat ./zcutil/dragon.txt - cat < Date: Fri, 17 Jul 2020 01:24:50 -0400 Subject: [PATCH 128/255] Catch errors early and exit, such as when best chain is still activating --- contrib/checkpoints.pl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/contrib/checkpoints.pl b/contrib/checkpoints.pl index 99a84f2c2..93ea1041c 100755 --- a/contrib/checkpoints.pl +++ b/contrib/checkpoints.pl @@ -1,5 +1,5 @@ #!/usr/bin/perl -# Copyright 2019 The Hush developers +# Copyright 2019-2020 The Hush developers # Released under the GPLv3 use warnings; use strict; @@ -12,6 +12,10 @@ my $gethash = "$hush getblockhash"; my $stride = shift || 1000; my $count = 0; my $blocks = qx{$hush getblockcount}; +if($?) { + print "ERROR, exiting...\n"; + exit 1; +} my $prev = $blocks - $perday; my $last = 0; my $now = time(); From b094db7113f5567d1c6fadce39134b4f4f4b1ab4 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 17 Jul 2020 15:35:28 -0400 Subject: [PATCH 129/255] More debugspam for -zdebug; Fix bug where shielded spends where not tracked correctly --- src/main.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 0dc0cf87e..ac9be64b3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4734,7 +4734,7 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl CAmount sproutValue = 0; CAmount saplingValue = 0; bool isShieldedTx = false; - unsigned int nShieldedSpends=0,nShieldedSpendsInBlock=0,nShieldedOutputs=0,nPayments=0, nShieldedOutputsInBlock=0; + unsigned int nShieldedSpends=0,nShieldedSpendsInBlock=0,nShieldedOutputs=0,nPayments=0,nShieldedOutputsInBlock=0; unsigned int nShieldedTx=0,nFullyShieldedTx=0,nDeshieldingTx=0,nShieldingTx=0; unsigned int nShieldedPayments=0,nFullyShieldedPayments=0,nShieldingPayments=0,nDeshieldingPayments=0; unsigned int nNotarizations=0; @@ -4825,6 +4825,9 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl // To calculate the anonset we must track the sum of spends and zouts in every tx, in every block. -- Duke nShieldedOutputsInBlock += nShieldedOutputs; nShieldedSpendsInBlock += nShieldedSpends; + if (fZdebug) { + fprintf(stderr,"%s: tx=%s has zspends=%d zouts=%d\n", __FUNCTION__, tx.GetHash().ToString().c_str(), nShieldedSpendsInBlock, nShieldedOutputsInBlock ); + } } pindexNew->nSproutValue = sproutValue; @@ -4864,12 +4867,15 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl queue.pop_front(); pindex->nChainTx = (pindex->pprev ? pindex->pprev->nChainTx : 0) + pindex->nTx; + // Update -zindex stats if (fZindex) { - if (fZdebug) - fprintf(stderr,"%s: setting blockchain zstats with zouts=%d\n", __FUNCTION__, nShieldedOutputsInBlock ); + if (fZdebug) { + fprintf(stderr,"%s: setting blockchain zstats with zspends=%d, zouts=%d\n", __FUNCTION__, nShieldedSpendsInBlock, nShieldedOutputsInBlock ); + } pindex->nChainNotarizations = (pindex->pprev ? pindex->pprev->nChainNotarizations : 0) + pindex->nNotarizations; pindex->nChainShieldedTx = (pindex->pprev ? pindex->pprev->nChainShieldedTx : 0) + pindex->nShieldedTx; pindex->nChainShieldedOutputs = (pindex->pprev ? pindex->pprev->nChainShieldedOutputs : 0) + pindex->nShieldedOutputs; + pindex->nChainShieldedSpends = (pindex->pprev ? pindex->pprev->nChainShieldedSpends : 0) + pindex->nShieldedSpends; pindex->nChainFullyShieldedTx = (pindex->pprev ? pindex->pprev->nChainFullyShieldedTx : 0) + pindex->nFullyShieldedTx; pindex->nChainShieldingTx = (pindex->pprev ? pindex->pprev->nChainShieldingTx : 0) + pindex->nShieldingTx; pindex->nChainDeshieldingTx = (pindex->pprev ? pindex->pprev->nChainDeshieldingTx : 0) + pindex->nDeshieldingTx; From 33358740f4110cf9382eb33a4dfdc83361a91241 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miodrag=20Popovi=C4=87?= Date: Tue, 21 Jul 2020 10:26:42 +0200 Subject: [PATCH 130/255] malloc.h conditional inclusion malloc.h header is also glibc specific --- src/wallet/wallet.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 3c7040b45..3a0bc389c 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -49,7 +49,9 @@ #include #include +#if defined(__GLIBC__) #include +#endif using namespace std; using namespace libzcash; From 5a1109ccf409e62a6044e39adf1fc55246fc0e17 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Thu, 23 Jul 2020 08:04:25 -0400 Subject: [PATCH 131/255] Allow z2z fork height to be specified on CLI for testing --- src/main.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index ac9be64b3..54643992f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3232,6 +3232,7 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex // If disconnecting a block brings us back before our blocktime halving height, go back // to our original blocktime so our DAA has the correct target for that height int nHeight = pindex->pprev->GetHeight(); + nFirstHalvingHeight = GetArg("-z2zheight",340000); if (ishush3 && (ASSETCHAINS_BLOCKTIME != 150) && (nHeight < nFirstHalvingHeight)) { LogPrintf("%s: Setting blocktime to 150s at height %d!\n",__func__,nHeight); ASSETCHAINS_BLOCKTIME = 150; @@ -3378,6 +3379,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin // At startup, HUSH3 doesn't know a block height yet and so we must wait until // connecting a block to set our private/blocktime flags, which are height-dependent + nFirstHalvingHeight = GetArg("-z2zheight",340000); if(!ASSETCHAINS_PRIVATE && ishush3) { unsigned int nHeight = pindex->GetHeight(); if(nHeight >= nFirstHalvingHeight) { @@ -3987,6 +3989,7 @@ void static UpdateTip(CBlockIndex *pindexNew) { progress = (longestchain > 0 ) ? (double) chainActive.Height() / longestchain : 1.0; } + nFirstHalvingHeight = GetArg("-z2zheight",340000); if(ishush3) { if (ASSETCHAINS_BLOCKTIME != 75 && (chainActive.Height() >= nFirstHalvingHeight)) { LogPrintf("%s: Blocktime halving to 75s at height %d!\n",__func__,chainActive.Height()); From ee09f123c61cb48b286499c4a11aaef3a194bf67 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Thu, 23 Jul 2020 10:27:07 -0400 Subject: [PATCH 132/255] Bump version to a 3.5 pre-release --- src/clientversion.cpp | 2 ++ src/clientversion.h | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/clientversion.cpp b/src/clientversion.cpp index 084bbd5ce..b490e9f9e 100644 --- a/src/clientversion.cpp +++ b/src/clientversion.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -64,6 +65,7 @@ const std::string CLIENT_NAME = GetArg("-clientname", "MagicBean"); #include "build.h" #endif +//TODO: clean up this stuff //! git will put "#define GIT_ARCHIVE 1" on the next line inside archives. #define GIT_ARCHIVE 1 #ifdef GIT_ARCHIVE diff --git a/src/clientversion.h b/src/clientversion.h index c62e6d3e0..fea7d0b05 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -33,9 +33,9 @@ //! These need to be macros, as clientversion.cpp's and bitcoin*-res.rc's voodoo requires it // Must be kept in sync with configure.ac ! #define CLIENT_VERSION_MAJOR 3 -#define CLIENT_VERSION_MINOR 4 +#define CLIENT_VERSION_MINOR 5 #define CLIENT_VERSION_REVISION 0 -#define CLIENT_VERSION_BUILD 50 +#define CLIENT_VERSION_BUILD 5 //! Set to true for release, false for prerelease or test build #define CLIENT_VERSION_IS_RELEASE true From 7e0c41977f2aa2818a49d3ae293089652623194d Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Thu, 23 Jul 2020 22:53:12 -0400 Subject: [PATCH 133/255] Revert "Use dynamically generated zaddrs in sietch, which are not stored in wallet.dat" This reverts commit 89532c4d7b645e3c4b488ad7e1dc8df9a04e8170. --- src/sietch.h | 225 +++++++++++++++++++++++++++++++++++++-- src/wallet/rpcwallet.cpp | 15 +-- 2 files changed, 223 insertions(+), 17 deletions(-) diff --git a/src/sietch.h b/src/sietch.h index 3a83b529f..64a4fe0ce 100644 --- a/src/sietch.h +++ b/src/sietch.h @@ -16,17 +16,222 @@ #ifndef SIETCH_H #define SIETCH_H -string newSietchZaddr() { - bool addToWallet = false; - auto zaddr = EncodePaymentAddress(pwalletMain->GenerateNewSaplingZKey(addToWallet)); - return zaddr; -} +// The network essentially DoS's these addresses and reduces their privacy slightly +// by making them public, but in return, the rest of the shielded pool benefits +// and so it's a large benefit for a small cost. +string randomSietchZaddr() { + std::vector SietchShieldedPool1 = { + "zs1qqj4aw35ku9yn72g3tha588mxk66mhl5smnn99as40887xvdg49d4yqf43hhqnj9rpsq7qaqqhx", + "zs1qywzq2cutvg6rkynjljtssz246easagumg3hlwjluz4g7qttg9kqrld7s43ewutpph56jmn2zu6", + "zs1qx7swmw28dj992f6zs0aqucds9kag88mnca5u73dddeqek4m97pg7h9qsaxxwwkgqxht6zujaxc", + "zs1q82pkqu58uemrm2749x6g2ta5shnsra9p5jgk0qqzxd3e08ke6vyeezz7lhldj32jxtsuemskk7", + "zs1qvah5w05qq4yhrsqrt73ckgntkmwdv9mntxep8clnxqfph8xggqad96a5nvwg4evfr9pc5ruvc8", + "zs1qwrkjcmnrwrqqkz3dyfjvdvdppe0ndnm8fhhpsz8stje4qcfc54jtuygz2jfwc3aag69wsjcm8h", + "zs1q5pd7h4x7dtnpa4ace7tytye5sd0j4043t4f3jdntyxvg9ex258nu6pw9tthn6t5gmjq5gv0lhc", + "zs1q6vjrpsuf468an545q7fh9cx0xlkwh75a7qjpemjh3ymuqqzxz5ts2n2dcth3yfnlv6vqpjyglr", + "zs1qmsvwtxkwlh3tkh0lqtwqv2mxy94jt778f7j74a8067nejkt4j3m2rkmypccju7cfuw7xyg0gg8", + "zs1qu3jxrw5qwuvl7zfvnsdvywr4a9cn4h00me65te29platx5agek072f5rvxgt8kdt630qs4tgtr", + "zs1qamxwddwrl5xn56alffruk69p304cqf7uf5nhqpwfc374l9ph00m78xv2kzwymyz0fhxcku7v5k", + "zs1q7gv479e6q7d8fxc35v5s27em66mmm5gz50excudf95rzjgnwdy5pnwdfytvm7gt8kt6wpkfphq", + "zs1pqvxd9a2zcsh2v8gaswh3jp2qkzz5umrucl5k4gx0rkvmq68krpx3jesavxftd8t0z56v8whllj", + "zs1ppn2mdznaa2pd9mavfnxrcjtv0c9un8pg6jaa9ww4wy6wdfs8xxwquqk5umtcjwm6vr4zrqy5x7", + "zs1pz9c9ydyrm7e876cvae9ha45ww77ru5fhys2yz33kjy8ej9230wjy8yupfxkynwqr6nfupgmf94", + "zs1p83g95avpsgr847eu3rm3xcmgurt9hc77wtndnmpypa046n529aqdc9ptz04ugsuhvum2ztzwe3", + "zs1p83jle2p8awu4peevq389y5kyrs5tqxxyrk32zy0t98d4cfepmme0myxp68nrq60xwzc5teulvg", + "zs1pg5ggzwx4yaa7g83yuhay8kzh78nahxfe7cgavn88f7rxlnuckhl2vznv0f33yuqhhs3sh62vl6", + "zs1p2nrefmqfhnwrxqfsz4ruvu8wl7742j5rv2fmwlpmpudwqpdn2yrha9rwsu5gc0fdv2j73tfk6a", + "zs1pw29hkrvszxpe2e4tjpj5h9pszjhql2p4tzcj2c5lf67m7d8jtgc22vehftxdnqze33mgtjc25k", + "zs1p0ggg024alu2l5x8df8ucu4lz8r453su56w2mmshru49uh9a0p6ufy3qfj8a9n7xeu8dxxjrk4p", + "zs1psaydszvszu4mar7ef9gk8atmwpnfjjsh8plajn6ttlgdk44jfud5zv8l3uyq73qk3eskec96ut", + "zs1pjf3kczvrwduuy4x99t03wfrgwstueyw0ypvwa44fz2tukux8kqqqs48uag4y39ed4rux8etvv0", + "zs1pnwzzh4mhehkvf4ys9x70q6meq9mgqj6mgl9ddzwvf8excswrj54lfgu4m9slmc90s37q8e63du", + "zs1pnndevupuakjcqyqzu4sfcgdmdzrhutp8ygxwsl5wvq5hgu20u55auu8p08wphvz9mu3k8ynyr5", + "zs1pmy6tvt9p3xxp5edt70mkwfqk0ljgaranzdnluh5ln36g9g3v2udquleuz5974q2mamywmrxl7j", + "zs1pau6lddk3uapms7v7rsmxvxeekqh52z795kzy9z3dv9qvzq3jwh4pr2adg5cf8fw2e3mzqmgstq", + "zs1zpy6wuvy3jlrfmj0363tx6cuume6j0mqfakk7ydw4f6zvn4s7plewk0gtm7r34pjtppvkp8rzl0", + "zs1zpvkccety206ww6c344ehughuyklc3v02q07j4p72pqewxl0n50zugtje6lclj3m292t6vs56fl", + "zs1zzucdg9kalcjnnknt98gpg42qm9aqpkc6qf5ewgr29udu55r0zt862z3zt23sd4mj9t47k7k6w4", + "zs1z9agq4vq7eswwynhmzdsy58nxq3azhn66y853yw9kvercmve8vv6d5pawpwwpwpuyedmzpcqk8q", + "zs1zvddl2e0pve5kl0hu7fcum30lyhx4pdq64jztq2vp09lqtu5gclfg4fe9fqvnm8k2d5svydg7s4", + "zs1zvsmkn6a4celtcg8ece6exnkvnr2u06ej8kjt6mrpm0983e86dr9al6gd5g73k24j0a0zkpjs3w", + "zs1zv33kglx4n5572dg2pez2k3m7tgtz08a70ndpfj6x204pphlm0pzcppetsnjlat3qflswqfmu83", + "zs1zsz5c9xua7arkvd60vsl559d4dvnjz8ejq4rlmmm9cnz942fdmjmvsgrdl7d5ddxh4y9258jk2l", + "zs1z5n6qvch0wfymumxjflezekxa2j5t978eqzh9ldxsl39h2jjrlzdv9rf00wdrvg0t6afq7mq0us", + "zs1z4ymm3gt22f3pcj9p9l2yg00e2m39kfexgaz99s9y4nsuxhlk6u0sl9lsx9awzywumxyuxv9vuw", + "zs1zkjnhz96xepc97rfyven23epymd5s558yqhp488gcxcj794z6p37h5ej5m5waqxfupmc538mej3", + "zs1zcqdekyq656yj2y86lh08u8zpetfanj5u4rhfpcphne9xw7esce8asux2rdr4yjxzds56fuda5r", + "zs1zceru3jt9m3jqzacnffetvrg8zch6le0zactl7ssfky2vwy7pcffkg3pmauqqpkv5v7nv3uzc5a", + "zs1zellp4tdmxdsd6hmg2c4qlx96m39c0cjlqupw085z87lvzcnx2r0gs7plc0wp4m4upk3zcs35e8", + "zs1zm2pcg2d3hnyxufn8cyshjn742gmffwaqdc0nt5uf9gsytdjywsqaasfdxf4sysfu0sgxjwjp0g", + "zs1za9nk7fpgnfetjulq6t8jgfyks06xg4q8rfwpgsfrkn49k34nc7xhm27dnjuzztgnwkww28ztyw", + "zs1zaaz6j6z7z748mck4v55s3fd4htl4f478kulnwr84m8vn4m0r227juddyq0ncu3cyvc765z9gm4", + "zs1zlz59lgwc8pqq33508v5ygk9e58f7fs4rpj3achhwnkcyn2dku44yfjghdf5l2v50nu2gjzgl2l", + "zs1zlgenma0yuqxmqgns2avpnauclxgfvgd6rf0jt09fmfyaflwlhsscem9ypmrvewl9l356dn3jtr", + "zs1rzu2yg2328l2wlfstu27dl024ucqsjx6g635yxmyhs0wr3lduutkc3peuhqe83uueh5n5q624rd", + "zs1rr9jpeemn9ek30x4h65rx0ddul7xet6cc8atwrjftmq9sdrvj9f5zdc9xg7amtc6dv5fxjyhu54", + "zs1rrgccr0yvfn5fdek39x09y2ylyf42xkydcwzq67wdrzyjj2mv874easa4h4tymz5gj852aqpffk", + "zs1rynh7vl05weafzwkp0p5eafuzzqph04prgg74emqq0sx6xudtrs2380v3ycxgp5lzudw6tmc2zd", + "zs1rxqz0a59zx3yduncc3azyzexwu8xl6cc0zu83hfd28mksrgahhvx8604uhf0u5mna9m4znnj4gr", + "zs1rxr2xff2vcv0y9s6ux6c6t9y7r3zvcvrqmwkvsnxj39t0qv7qwyhncnykhzcqg0ggpu423ykzxe", + "zs1r8chvye5uzlskv8jvt6j8nxnyz4lshy3u46yjhc8w9ekhjhneg402knft3t943t5nrhs6d0d5um", + "zs1rgu6mz58xrqxpyl5xw7ss2szz29cg98s8xl25hu7fy4lcxw58zr93a8rgyha52vwxx7hxj2emkw", + "zs1rveutz8ftruljrlctum42kakjqk4cm8dm2807nqm974dz0rptlxcs999ttsvwp65vc9e59vv9fe", + "zs1rwfqhlezm5ln7kq8wp8hkl08ddn74ryr8cs4cu8qc23spdx79xgfqj4lju4u2yqdrkxkwfvk3ed", + "zs1rwklllsk9jwhhf0fedvlzsqfqdkwer05zh8c8hwypl4tls2hdal54lexhca7kghhum5hycurvfe", + "zs1r0ulehrcg9xz0lfdcukjm3qlvqy74t0u8raqf4zn88vdsta8mzp8t8p9ul8jragssvs9qaqpw2e", + "zs1r3t0cve050wufwl8r2tly05vn7w79v53fe6dagjtt2ese0qm6vgjp3rrsfu4n0am840sq5thn72", + "zs1rnd8zwan2xlrnfwylm9khkeutnzg2v9vjdnyellyuzkwmed94uvd2dq8ceumxwspz037zp2ctqa", + "zs1r4tphfnf3zy34dqyjuld2kgtyg88hrxpv756pkkkmrfdeun0cqzpepac4ma9qrjrvdqxg2z5fuv", + "zs1rcpywy0v4sfej85wdaslfwsp4pe9sa87xgzv24ywhps2l4c9jlrqttv0wl9zkc5e7rsekf42wvp", + "zs1r66et0z9xw3qqhzyc2aht294y7yqyz8wx2l2t63unca4k4zh4v9t44kpmg52z9va5968y45fdkx", + "zs1rat3szdulwxwmx7y4rdphvlpjj5phadvz0fsvj7mtg9ggzwd22sn30hzsh27h7t6cvca6a8wu2n", + "zs1rau4jcth66jsg098ucclp9tfa5qe6jmtmfkcluaqnyj3uatkt9dsrgx44xtmxr3e9xuxv6sy208", + "zs1ypf2v2yu4p4mnlmw0wd3mpztpjlhl39jnn6hkvf77ell0h5u6yg2pgeusvku5y5sykyy6kk6yyh", + "zs1yzkt8catgk6slwj7azu79tvwv6tkd6agcykvvht4rxlevtsh99u036jf5503pju3h05w7x02cm8", + "zs1yrty5fmnyaartpcyjnpal0w44g4mt2ey5tyzcmgq4g6qtsfjmxae7fvy2zsw7t0zvseuwcfwt2e", + "zs1y9p5gazcx04kke96xudep0edzkqr06gdjnr5vm99a6qxzatqz5katput4q9nx95e8965sg7d3pl", + "zs1y9vpfgkxwh3xm3j9d38zkeqql2lh8w3ucgerkww2asdv89p87emdavkzurnqpkrmu7e3xv5myue", + "zs1yfa9gwmn0xe4myrg0rf8kmu36243u8773ukeev0set2yv0z9vpxm6ratee52e9zmpvvx7w2xy28", + "zs1ytpjrujfsgs69smqerxeaf8m38jwxc4ejgxxe4pzc5qu4auqrgy8tf7zxc402pxf9uku646kc0q", + "zs1ytvtdwmcn8tnka6w6wa8n3ghnkf7gp2qaudd4233y6m509ntm59rr0n8eudhre0md7m0zedpcsq", + "zs1yjmeu09mzrt8rgehv2gcfhxx6ddqz7ww87ssfapndvc94hxfrfsdkkgm8f8nr36xm8p7q462qy2", + "zs1ynqghdu0r0c20csp3ygrxdw9hk2l89j3g59q8zhht9jyxycpcc9ccvhyyn2f9j0ehp4pk5wkhqs", + "zs1y5ny4jpjm05vp5awjd6muaqqypdv0y9tr6pz0m5t82cwtrearxwf7km4aznydpcjeuzxqvk0z9m", + "zs1yh2vd5usfsyv4pscjrxg9wdy3gnnyuh8vky27ln3u9jspadmpqsjmyvxmvfyyq3nv4deudvygxa", + "zs1yclvhy57hngs7d233e4x8ywfreswslz2gvn0f8epcs0wrzuqqau3hkrvf7ru6jhh0zmsyn5jkj6", + "zs1yunkgwzf0m5suz380j7xqge6rd9e6acjc5wp22z0jhalqdpspdjey7jfjvgrckgsk9ydc9yrnq3", + "zs19p94fnry6p88ms3yh60nl4kxlxmu7uxv9aafmf5pc4nyd64vslaqgmj30nxe3l5j7cxu5kqeqpm", + "zs19x2df6qmd4c9whrgj6m4mssz22x9qj9x8lmcnexnhw32pey24xy9sws5ts2q7guunm7mx9wmllj", + "zs198a984na6qt2z3uyhdkmj7sfevt794dl3mum3782kddjy4uawr2teznpuxvnzc4dvs3c6zyqxey", + "zs192ld62azpypesveqsat6m63sqaw95ejlqfcjsal5t0fea9zjzqnurmpnl6074zdms0amw83rw0x", + "zs19vsx09xmzlj9vr3s3vu8z4237gpcgrl7qs0vapzzawgnu7gxngeaxlgwqf0ppu0f7us9cfe3cqz", + "zs19wfwd8zufu27zugan77wf2g790egdw7vkulf6f375ylq0arnv2nv94l84nl8lp3tpccv763wetn", + "zs19wcqtqqjj0mnrn90ntcmyq5x8qr2wsaslqwt0fysz4xh2mmjy0z9jjh4sj86sjrgen0axx04zt4", + "zs19jypvpjpvhv5et5wq2ny09skt72hxz9adfgk2ev7nza5jyxr6gss5qelygnxn0szmjqyke2h8a7", + "zs195kll03d43her83a65y7z0zsetynlnft4pjxdspegvun0m7cwtx0vsxfm89mv50vxr90qhvcqpz", + "zs195e2g52jpyly7t9vjpfcegt87g7lpa4rm74nxn0zvmtzjhvg7f5gjnskc5ax5skvwprcshenyqs", + "zs194e84mfxc4vn4ssce7hkvgrcm3c8j7vehcetkdf78rele2lwkx9tzcfnrwhykdqa2nmwx5qcr0j", + "zs19cxqspj63ksk6uwtynj0la72zuvh8rxfh0e0pr2y5vuuvw35sm78juzh5gxcuqa8jggv703rplf", + "zs19e04k24qrca0sx5z47dxmtx0swcx2ywxqjt5594gu95rjaeyxrpa2vyylvzxpau5spt2v529me6", + "zs19707gmdvc4hfwg4lgvxg55695gltx3jwye8l2gjekrx4zqz7yr6grq8s8hpfqwggrywx509ln5y", + "zs1xrw8nwla7yrz8l3d7y3rxlhamel2ly4kdmxlc6w4cztxhd6l8wufqv2pcsvtl3d7s6awvjatyx9", + "zs1xymrgyhle6dcvjk5f62k4xygr0vrr2wckqy7sp6wc6cttn29hra77dzhwxst7z9rxqxkz08jd7g", + "zs1x9c8tetxgauxh474hlhnlscuhgzww8vnvxfwm0p8589x73t5yl2fph8q8r8qpl8sh0wfwx0vg62", + "zs1xxcpzsfpyekhvvum3erxjpt34pw3h70ma8vxwecg85tze380f4srlg8zlgxty8yqhutt234nk9q", + "zs1xx6pd3vtj78tg0zpwtc0jjkdxlfy48vegzd6cng4m9w0gtcya8ck7pqgf4l5sxf9ml5zvzru5xg", + "zs1x8qre6x5d8e3tt2m4l9q2tujw8ajun70qelp8tfynyw390rm6vhjtmpf58dmx4hccef9xe50az0", + "zs1x88vjduckqarz2j8tp2me08ya4dgd6pw7j4j98j5jynrze3xy2jjptzye7eftjxd6dn4sj03v7m", + }; -SendManyRecipient newSietchRecipient(string zaddr) { - int nAmount = 0; - string memo = "f600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - - return SendManyRecipient( zaddr, nAmount, memo ); + std::vector SietchShieldedPool2 = { + "zs1ehrs7hetemzsmfz9xwt8xetxag33j3xzj8mhdgywdnvkk4dmtvw6eqys6gm3vr679y865jz7rth", + "zs1ehyr6w0c4mwp0wlp6w5letgm3rjk32rxa9kkkur86e5x8lutr9mwzey0hsesnz0yaarmxra7w2z", + "zs1ec793pjf3anee0qq9ex5u2qygjzk9llmwfygev563l89quc3u8wxvtz9kctlmv2dtjgqwn7krcg", + "zs1eclpgnqy7qll0l5z0gy7m4ew86yjvp397yxyau9y2y43x5mqfdw2sll95l83ux6h8mppzsx3xnp", + "zs1eexedkctuzhjysl00m0j3ekknd32635yd8rejx9ykjp6zz77fyzf5388env642ja2qlg6mrwgsc", + "zs1e77uz8yaj998arp56d0fm4p827wchlf2w09hve6rgkmavhzeyhke8qsk3l7s5k6yh2jwjheqpup", + "zs1elj4qvy42jpts2cu22tcwt0kmwzafpmrjgztwf2xcqaycrlr4rpfxfpswx63e6agvhz96gps9yf", + "zs16q0fzcvf25fh70ysn38v7qkpfspakmelnljgnyrpu7rvllyew57n5cpqjqe0wmy5j57au47j6x8", + "zs16pnkw3mucdef34jjk6q28zd7ghhatdcqn598vs3g70qev234uc5uw6xxxjnzef3pt2t567qev8v", + "zs16rmnl4hd6c226u3v6eekk68y59u0x7v37n8pmytt9xw6drugjml7ryhd243nf3l2pvafw42rnxc", + "zs16ruwvwmetmnnns0rxwtx2kss23da2pccares0tehzw3v3nxd483qn49c9apdfua0hpm8xdecdt4", + "zs16ymafsjd7fp9zdl9vtyvfedecvn7q2vcs7emeglwy7hpuphve97d3j87v2evqs0xm3jrx44nwfe", + "zs1697ggm9zqp4rh0fv4r9hnh9uy6gg4hk7r2lm33tp2we4ry5azpxq6nwuzscha0g2nx03x4sstq8", + "zs168t8u6at9k6kt748dv749dxahnk8rv8yn32z8gcgvc9rkhkewscgu8r8vuzv0zecnq26w9p7x0c", + "zs16gnyx6f8vql24cepamfquhr3jjt7wgmzjcvwtct4lwy9p2studln6ut9kjzf6empwqjtxqmddqy", + "zs1622ra8snywvxufsunk97pccr7k0j32p960evl9yqjadhju22m4sk48md84q5u238gej8xnm4xm5", + "zs162stv8m0udzy4c6ff5kqva2g7pqth2rrdn7rjjgw29dcx7lj3vs4dnj8fz0gczsat3u3q5axgva", + "zs16t78376h9ledgt50k2dmwssuhyy4hn94wfgd8vzegvqy9k9kauuvpe8xz0f3va65l8ufqhgv4gv", + "zs16vxrghgv7mth6k9unzdude9cyt9vl76ms5hm9ce4py92rk69j4p9u570974nh8kqh8e2stqknj5", + "zs1654eafn589g2ujzcasa8caz8exag742tra2dd6mjkp22axh27hda6sy9exh3wkp4c6f5vztafr0", + "zs164u3ntsnn7s3zrp6c5gsqfrwr0ywhspynvunq3fhvr9crwz5eme706j5awwvuatqwh7m2qqkqm9", + "zs16cpqwm4yml5x8j5r3q5j0xljam68pf56xt40hylzn69w45venwdvd4h8drys5t380mspkvt7h8r", + "zs16c6m9aqs0q9kadm4nk6hugmqw6p0lf2h6v5d9ccwszssyecq35sm6284c3uqx2u40da4s2mr2ap", + "zs16u7rc066566j9ux73dcq0m7cq4qdmtd3gefrnhhrpjww3z00j4za7m5mcutmj6qcezkzys87mpp", + "zs1673rm5d5z9sh2k9uc2cvgwk2e44z0sekx6ezt9n4fvgnky5yxa2tc306dw7n2dg5vwfn7ppwr5s", + "zs167nvq5ahvu4s26447rem9j37qglgtle4fghsgpksumkz34g2q9x783pak5jgdhhzylmgs9wemg8", + "zs16lluayez28xevxg0rawxxcd7yx5t7qaraet256sxe8ac69lj7n7ppncsx3m2tddxlzptzyxv0qr", + "zs1mydlmczamey4ydc79n8gj5wtgs79zge4nwhcg8g640r6fvwu6wpt70970p7ptkcrzg6r6frqh0u", + "zs1my6tgqmy3kgdlqncyd5dv9s727x9hcrmj8h06e5whn4hkn5t2x46j84276yd8pw0p6ysx53u38u", + "zs1mte528eue8smvjwpe9cs8qz3wud9735rnk7vrtefu9lhyvh5pyeyenpaq5fa08jpwrl4x7sz069", + "zs1mvmu20syf3u5yzd6hpdd29xfej8237x2k0pcmf7pvra46qem5g0jralrmdcvncgf5j0y5varzr2", + "zs1mw86y6g2c8972a2ndw57648p9qcx2jppxr9g5k24df8hl3rgfzfsfe2xyesemdfmasutk88duht", + "zs1mwca7dqjq0r2mzmn4qarw8acmt4rjk26lyyar35sssqe2fky2nmv3kmf0lfxs2a9htugsadg027", + "zs1m0rpcrkfagzpex9mlw2htyrwpxe48v47pj8zg96l9wm5k8xkj3kev3xca6wumv5avkgsjtygush", + "zs1mjgyju3jnyxjhekv72y448edq3j2cvtk5s4wrej790zzpv3uc20dvewt7nhjdqryuecmykfm0je", + "zs1mjlfwyma3fv45yg50j73wcswnap2s4lsh5c9km6lcem73wky9lej7vy8wrlkr75sy6z2g0agtmw", + "zs1mkh9s9gdfxx4dkug47dqnc98g76dhm09zty779pm6gqc5aye4gvxvduqm5j56nq4lncx5ygqu90", + "zs1mm7tesf30r56l8xmnxjyxvgmnsny2zntsxahllrd930q8ycahz8npdxt7lqwu3k8ljs9sw7uzs8", + "zs1mu34v9wtyhtlr22phfxkp670wt0gj4z8czumx0m4u05elg7kjzu0dzveq5jn28xg5a2wqr6cywd", + "zs1ma3xy4fj0vm0w37a4kur3ghe72f8nstmqmmvh0u48kurtlwg50rqqlw39j6ng8lrxgam2dh0zyr", + "zs1m7yauj7694wjz92m5sxds8udp43z6kclarqwzc22wn2q6svkkk4lpzx53kwctwfn6jqcu4yww5u", + "zs1m77qqksfvuqmjmwdm22xr2u99z3uz4glenk02md4tq5z066gc7jkdayhf2txspqggv29quacpy4", + "zs1uq88d69zrnksytnquejpksdvdlp9e5y3xec3eyf0rrya8zap623zpwjs5mfzadrp7twawkpennl", + "zs1uq0zzag2cmekwn9a35vkf2q45sary5v8nt2adukhej9ydq3qpegskg5naysl3wvvxtzuyv5lu8w", + "zs1uqs3n3j8kfgurz8tj0ea5g2ny200c69rwwpq50kkup8sxntdne6h9uhx3wc2y5jjkcggvpvcl4g", + "zs1uqmnl793xh4cskxjherwlpt7xfnt6fy2sp2l3n58hpmd4msj2g3fjsks02069tqgzzvn77mpfg7", + "zs1uz73f8arfahrvgtxcjwya33ql5w8mwkmyrvxvjrjx5rla07hv3ax49hkeqg3aqynxx39z4y4vtt", + "zs1urzuwedq4qgnqjsjwjeauzyyjwxvs27mau6zmpretn37my92h3jqc0waad4r8s7zeeczq6jfas6", + "zs1urfls60sjxpnla4hhe736qu54w7047akw2p9cksx054y8e8gdyknkhwv6spwzgstf7z2wrsdapw", + "zs1u9jum0rl3959ay3qqxskkak5emv0fpceuhuhcj9rnkzfy6gpe2uv6ny29c399nrc68fx6fffg6c", + "zs1u8fdxg8lu08p6s5z9qe6jf6fkvd74a99yg3n5exlm6wm8paypygy82ue2smf0qqlhdhjzy2jxq4", + "zs1u8u44rlv4ay27248807fqwyf6lw2w76v8evn26nvwv887caqlenjgsw0nqlajzw9equn7phhs95", + "zs1u4jhx25fghqzn2az7he7lrv7xj23xd8spcl660g9kzqa3wyykm5gucuu5wwxvum6l6spq4u4e5s", + "zs1uh85d43vr4wwqnq6e7akxtlwkzx2y8cmdm3wrxzj6m42pzj3xs2heqey79hgxrhwhapwu8tt73g", + "zs1uhwgwkg2y3xex7e34dvnx97d0jdnhmchevcvg54tg4dg00ay9sjucr82py4jqx0kkf7cz5dytad", + "zs1uhkhsv3c3m5r8z7unmceg4zln6edwfr25wjauv5u8fxdqhdflj7vuc2xnkm9028y802w2pyf07g", + "zs1uhuwuzu89j05p9y48nseklu7gfhw4mrwv68f9s66csafrkpsmpsh23zzgxm24nspmsgrvtpttzg", + "zs1ucetuz8ysvz42uvuwndjfnphrtsfgekgef228meuhfrqtm97gql87rsvhxmxplw2xmj27p9jemj", + "zs1ucm95fgyy72rf6x5rwl5m5pldt38lulzqf9ueepel4gvd4cqjhk8xrf4kvl2lnn5ge9fwyfrfva", + "zs1um3pu2u0eu0zpx4czj9dufvxnud2zd0x5lygepp6maz96j572r6mh8gpmlm3w6jhmxxz2sepdfh", + "zs1ulkw8j488xuhhlewedj9dr7atm5jatmlwsxz83lquhz42ln78utqmtqsmhagcquq6uqszk23g9d", + "zs1az03j8f46n2600z47xnf5y28j34rpxljh3j6w5p3xgsmqt2fuklmhyd383aljxf4mx4pcfv0xm8", + "zs1ayal4wq4crwj70u6hae82h6r4jpk7ptycfhs9v5y83lxc7u4gadegu2r5ggsgt95n0rjk284fzj", + "zs1a984wux9sr2594lr24yal43zq6pstczyevj7yr8pn403643zuge88ekrc0cj8n2fk6z6xrxjpsz", + "zs1a95ptq9d6nauwtvgdj2lnct9y6g4cmm258jzyuqhsk4m3gqmaz62t4klqe42eu83n27jcpgz0ed", + "zs1a8xdhdzpjqx0alrjg43enszjnf6nn6nhf6c3xd77ecrvp4kfarvux4u4lcttv3rgyhmgzxukw2q", + "zs1afqnaljmvzunvjhr3m8yf2g4r0pe66kkxkm6ldjhylyjfsclk3nf88u29pskdqx76szdz48tt3m", + "zs1avx0j6mrcqrhp9903xrysptm6gefcyv6uqltta92hsgjpp2f8h8rz8suwxgjkp2f8366y6n6dj8", + "zs1a036amk3q8azryytah2zpdhyazeruq2q7zq2c06l0845kl0v2rmg0h8cdjvta4alxj0my4kcfad", + "zs1ahy2sja2ala03wrc79xx2ks3ujxxnsm44uh6yucmy5p5l0xcfa3g90cdgs4l9rhy975zvd4uzts", + "zs1aeyqta7xs8edzq2c0z6e9v3vjep55e4lg9fp9ls6d55x2mel6snxud6kqcaz8nl7zgrxxj96d6a", + "zs1aap3thj9xna07vlg3yz389c34v9mgd06g234d3htyq667286phjsf98nndm8frts7frmcyjfa90", + "zs17qdqrdgwcafkpgchc4rvk22e4u86alhnmzne5xzantpecwrxf3c6jxqk7xgzanzjj4kmxd2tuwg", + "zs17z3fmn6e84ypzpzn0p0j9nddptrj2nwhk9lhaw952j0lzxslrp24cj0ltuem9g5dustakcq4dsp", + "zs17zut2398dst3hnmnslnk0jv9w4q9yn8akelymvs8ewurdytxushp92nyqv30quqhy0yju7rn7lw", + "zs17r4fuv9ldl3kzwk5stv59exusc7jlsmtcz4t2uzjnrgrr6aj6tvnp04wc9jq2n3eh6fsyqe2ru5", + "zs17rajftxlkcywcenl0cn3fqw4lh2un5lpfegjdz06j3vl9gjmay2d5pk7uequ02vw6tmtzz6jrst", + "zs179rvu8endcr48sft7zg4w6uvxwu4ps94r06uwk7e606yffkgtx7epaamlfdqnc6xa4l9scqcv4v", + "zs178dr2z7zgqrsg5ul3sxx05qky2kemfequf08dxr332n9f5fq9cj98jttssz97lzmf2k22xpn54m", + "zs172zz77ds82urqmsa9pgyz65k04euw7uuk58k4ardcxectjc4t4yjekxm8xxmgd7gqs8k6jupypk", + "zs172eamykp6sl4vx4tsgmg2t0p482hnn3gg4my9y4frd4tl5zgsyrsvjvlxc9zjtqpve6e6djdc4x", + "zs17v4xqdu83fkvrjxrpnjksuanj0pung2kqn9ys533nnm8kq8ad8xv9kd48e4utrz947pejg55p46", + "zs17dgakqvwzgh4dgfe70cjulju698cs50zvchsze2e3zvdp68wytqdcvj4suh4vq2acdg7wuvs7ar", + "zs17snaqr6vukwp4apsdf44h6w3flgphzrnpmdjly662tgqtvkgs72lpz7m7tnkksdmt5uzjgmpg2e", + "zs173ad7l6u8dr90e2t5jkrnw0gc9u2mppv9vjeh8l6q2jdvgnq6tq4anxxltwuxm3wssfzgg6hfcy", + "zs17nez6jn8tnse243f5uf72d8y000ynmjnm6vsrpzpd2fj75wq4u4lu7xc8fmtn2e5v0r7uknphs3", + "zs174c6x8u2yagjnsq2kswnd6fh8u2f3g5dkrk7r7ja5n30zwjm4ke3x84syt9qklqyk0m7vekcx9f", + "zs174mlfm6snsmgj4usez3e6xtd5nkwwl24vgg96srpnv7ulz4de6n4lx6cmxaqszqnk7p9y6wcl8q", + "zs17h5lnrnpprdtkjwq09ax94qetryf65qm5jqv0gpyeesw4wujytks9qljvlry863flf242arvx8f", + "zs1lp07e40usxenrznuuf2nzn5v7tx9pzp9r6eaw6upnm4t9cer8l5fckzm7jr58j5l77tzjrprv8v", + "zs1ly5u5sqeeax9g3uafva7fl35r3wv0nm2aka9m940graqjh0zlw7rrcgay0a7f29j3ar4wrj4uzu", + "zs1lgqckcp2uqx5c6gdm5zklzrxz8ygva9kxtxc4u4dlzpg68m9prga5q3ur3uqutkcy4ztuhclrxw", + "zs1lgz7ychnnhe58hk2e379zhqdxynp30e6fdh6xjxx8u9ga9rmwzdrdvqcq5kps2uetyf6gzeqdn2", + "zs1l2ghymesqwrfw89pqnw08u346es6wn86r77a55n7d7xky2rc58jfhn7man9kjjesnegec3frxeh", + "zs1ls3lyaqhm39zgz3528ereaa48vzsw4cw99k536524a6ruxmdqyvqnv4pl477q7rwptrzx8dhhzu", + "zs1lsnr42d2ez0w55pxws4qn70f68vxllv92wppu24n75y7a0wrmkw6qgup0md5jhjmkwhzu742zx4", + "zs1ljzwlum9nme83hhvkjkxl323u0ezm4sgnk84nzkyu5acum0kxf0s6g06gy78w0hl66f5263g7ha", + "zs1l5kfev0dpl8swjlyvyms5t9yhhnvg0590jfgpxw7zxx6eh29vd7453q9d0ne75x7gsm42j65l3v", + "zs1lhpxmvxmfpdfa5myd35wf24pmacrgdhrcpxydrcwz3qvmfvpt9x78nf2ne3kkqh40m0nvhhd3uj", + "zs1lhkhftvpkvcuyhwgcz4gq9y9l3ly5esglk2g0sgdctrz2cd63lgss2gtn8eedsvtuh8f6shpwww", + }; + //TODO: Assumes pools of 100 + int randIndex = GetRandInt(100); // random int between 0 and 99 + if(randIndex % 2) { + return SietchShieldedPool1[randIndex]; + } else { + return SietchShieldedPool2[randIndex]; + } } #endif diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 3425de1a8..aa9f1f857 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4749,29 +4749,30 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) // OK, we identify this xtn as needing privacy zdust, we must decide how much, non-deterministically int nAmount = 0; int decider = 1 + GetRandInt(100); // random int between 1 and 100 + string memo = "f600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; string zdust1, zdust2; - // Which zaddr we send to is dynamically generated - zdust1 = newSietchZaddr(); + // Which zaddr we send to is non-deterministically chosen from two zpools... + zdust1 = randomSietchZaddr(); // And their ordering when given to internals is also non-deterministic, which // helps breaks assumptions blockchain analysts may use from z_sendmany internals if (decider % 2) { - zaddrRecipients.insert(std::begin(zaddrRecipients), newSietchRecipient(zdust1) ); + zaddrRecipients.insert(std::begin(zaddrRecipients), SendManyRecipient(zdust1, nAmount, memo) ); } else { - zaddrRecipients.push_back( newSietchRecipient(zdust1) ); + zaddrRecipients.push_back( SendManyRecipient(zdust1, nAmount, memo) ); } if(fZdebug) fprintf(stderr,"%s: adding %s as zdust receiver\n", __FUNCTION__, zdust1.c_str()); //50% chance of adding another zout if (decider % 2) { - zdust2 = newSietchZaddr(); + zdust2 = randomSietchZaddr(); if(decider % 4 == 3) { - zaddrRecipients.push_back( newSietchRecipient(zdust2) ); + zaddrRecipients.push_back( SendManyRecipient(zdust2, nAmount, memo) ); } else { - zaddrRecipients.insert(std::begin(zaddrRecipients), newSietchRecipient(zdust2) ); + zaddrRecipients.insert(std::begin(zaddrRecipients), SendManyRecipient(zdust2, nAmount, memo) ); } if(fZdebug) fprintf(stderr,"%s: adding %s as zdust receiver\n", __FUNCTION__, zdust2.c_str()); From 31983a9655a694036978eaef9a7f63fde2e2bc60 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 25 Jul 2020 01:41:48 -0400 Subject: [PATCH 134/255] Correctly choose between dynamic or random sietch zdust addresses --- src/sietch.h | 20 ++++++++++++++++++++ src/wallet/rpcwallet.cpp | 28 ++++++++++++++++------------ 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/sietch.h b/src/sietch.h index 64a4fe0ce..630c3ce72 100644 --- a/src/sietch.h +++ b/src/sietch.h @@ -16,6 +16,26 @@ #ifndef SIETCH_H #define SIETCH_H +string newSietchZaddr() { + bool addToWallet = false; + auto zaddr = EncodePaymentAddress(pwalletMain->GenerateNewSaplingZKey(addToWallet)); + return zaddr; +} + +SendManyRecipient newSietchRecipient(string zaddr) { + int nAmount = 0; + // Sietch zouts have random data in their memos so they are indistinguishable from + // encrypted data being stored in the memo field + char hex[] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; + // memo field is 512 bytes or 1024 hex chars + char str[1024]; + for(int i=0;i<1024;i++) { + str[i] = hex[GetRandInt(16)]; + } + return SendManyRecipient( zaddr, nAmount, string(str) ); +} + + // The network essentially DoS's these addresses and reduces their privacy slightly // by making them public, but in return, the rest of the shielded pool benefits // and so it's a large benefit for a small cost. diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index aa9f1f857..350215b69 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -72,6 +72,7 @@ using namespace libzcash; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern std::string ASSETCHAINS_OVERRIDE_PUBKEY; const std::string ADDR_TYPE_SAPLING = "sapling"; +const std::string ADDR_TYPE_DONOTREMEMBER = "donotremember"; extern UniValue TxJoinSplitToJSON(const CTransaction& tx); extern int32_t KOMODO_INSYNC; uint32_t komodo_segid32(char *coinaddr); @@ -81,6 +82,9 @@ CBlockIndex *komodo_getblockindex(uint256 hash); extern string randomSietchZaddr(); extern CAmount fConsolidationTxFee; extern bool fZindex; +extern string randomSietchZaddr(); +extern SendManyRecipient newSietchRecipient(string zaddr); +extern string newSietchZaddr(); int64_t nWalletUnlockTime; static CCriticalSection cs_nWalletUnlockTime; @@ -4735,44 +4739,44 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) // SIETCH: Sprinkle our cave with some magic privacy zdust // End goal is to have this be as large as possible without slowing xtns down too much // A value of 7 will provide much stronger linkability privacy versus pre-Sietch operations - unsigned int DEFAULT_MIN_ZOUTS=7; unsigned int MAX_ZOUTS=25; unsigned int MIN_ZOUTS=GetArg("--sietch-min-zouts", DEFAULT_MIN_ZOUTS); - if((MIN_ZOUTS<2) || (MIN_ZOUTS>MAX_ZOUTS)) { - fprintf(stderr,"%s: Sietch min zouts must be >=2 and <= 25, setting to default value of %d\n", __FUNCTION__, DEFAULT_MIN_ZOUTS ); + if((MIN_ZOUTS<3) || (MIN_ZOUTS>MAX_ZOUTS)) { + fprintf(stderr,"%s: Sietch min zouts must be >=3 and <= 25, setting to default value of %d\n", __FUNCTION__, DEFAULT_MIN_ZOUTS ); MIN_ZOUTS=DEFAULT_MIN_ZOUTS; } + int nAmount = 0; + // Dynamic Sietch zaddrs default to OFF + bool fSietchDynamic = GetArg("--sietch-dynamic",0); while (zaddrRecipients.size() < MIN_ZOUTS) { // OK, we identify this xtn as needing privacy zdust, we must decide how much, non-deterministically - int nAmount = 0; int decider = 1 + GetRandInt(100); // random int between 1 and 100 - string memo = "f600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - string zdust1, zdust2; // Which zaddr we send to is non-deterministically chosen from two zpools... - zdust1 = randomSietchZaddr(); + zdust1 = fSietchDynamic ? newSietchZaddr() : randomSietchZaddr(); // And their ordering when given to internals is also non-deterministic, which // helps breaks assumptions blockchain analysts may use from z_sendmany internals if (decider % 2) { - zaddrRecipients.insert(std::begin(zaddrRecipients), SendManyRecipient(zdust1, nAmount, memo) ); + zaddrRecipients.insert(std::begin(zaddrRecipients), newSietchRecipient(zdust1) ); } else { - zaddrRecipients.push_back( SendManyRecipient(zdust1, nAmount, memo) ); + zaddrRecipients.push_back( newSietchRecipient(zdust1) ); } if(fZdebug) fprintf(stderr,"%s: adding %s as zdust receiver\n", __FUNCTION__, zdust1.c_str()); //50% chance of adding another zout if (decider % 2) { - zdust2 = randomSietchZaddr(); + zdust2 = fSietchDynamic ? newSietchZaddr() : randomSietchZaddr(); + // 50% chance of adding it to the front or back since all odd numbers are 1 or 3 mod 4 if(decider % 4 == 3) { - zaddrRecipients.push_back( SendManyRecipient(zdust2, nAmount, memo) ); + zaddrRecipients.push_back( newSietchRecipient(zdust2) ); } else { - zaddrRecipients.insert(std::begin(zaddrRecipients), SendManyRecipient(zdust2, nAmount, memo) ); + zaddrRecipients.insert(std::begin(zaddrRecipients), newSietchRecipient(zdust2) ); } if(fZdebug) fprintf(stderr,"%s: adding %s as zdust receiver\n", __FUNCTION__, zdust2.c_str()); From 6e40e2f1e2c3f2abd7414687b3082ed0f5faa588 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 26 Jul 2020 08:29:25 -0400 Subject: [PATCH 135/255] NULL terminator considered important --- src/sietch.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/sietch.h b/src/sietch.h index 630c3ce72..65908e2c9 100644 --- a/src/sietch.h +++ b/src/sietch.h @@ -32,6 +32,7 @@ SendManyRecipient newSietchRecipient(string zaddr) { for(int i=0;i<1024;i++) { str[i] = hex[GetRandInt(16)]; } + str[1024] = 0; return SendManyRecipient( zaddr, nAmount, string(str) ); } From fd456ec14653cbbe4c1d1bcb9a3bbfa5459a6c20 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 26 Jul 2020 08:47:59 -0400 Subject: [PATCH 136/255] Bump version to 3.5.0 and update unix man pages --- configure.ac | 4 ++-- doc/man/hush-cli.1 | 8 ++++---- doc/man/hush-tx.1 | 8 ++++---- doc/man/hushd.1 | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/configure.ac b/configure.ac index 4ff3855b8..eb515e59d 100644 --- a/configure.ac +++ b/configure.ac @@ -1,9 +1,9 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N) AC_PREREQ([2.60]) define(_CLIENT_VERSION_MAJOR, 3) -define(_CLIENT_VERSION_MINOR, 4) +define(_CLIENT_VERSION_MINOR, 5) define(_CLIENT_VERSION_REVISION, 0) -define(_CLIENT_VERSION_BUILD, 50) +define(_CLIENT_VERSION_BUILD, 5) define(_ZC_BUILD_VAL, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, m4_incr(_CLIENT_VERSION_BUILD), m4_eval(_CLIENT_VERSION_BUILD < 50), 1, m4_eval(_CLIENT_VERSION_BUILD - 24), m4_eval(_CLIENT_VERSION_BUILD == 50), 1, , m4_eval(_CLIENT_VERSION_BUILD - 50))) define(_CLIENT_VERSION_SUFFIX, m4_if(m4_eval(_CLIENT_VERSION_BUILD < 25), 1, _CLIENT_VERSION_REVISION-beta$1, m4_eval(_CLIENT_VERSION_BUILD < 50), 1, _CLIENT_VERSION_REVISION-rc$1, m4_eval(_CLIENT_VERSION_BUILD == 50), 1, _CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION-$1))) define(_CLIENT_VERSION_IS_RELEASE, true) diff --git a/doc/man/hush-cli.1 b/doc/man/hush-cli.1 index 5d87d8205..3e1ca3616 100644 --- a/doc/man/hush-cli.1 +++ b/doc/man/hush-cli.1 @@ -1,9 +1,9 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.10. -.TH HUSH-CLI "1" "June 2020" "hush-cli v3.4.0" "User Commands" +.TH HUSH-CLI "1" "July 2020" "hush-cli v3.5.0" "User Commands" .SH NAME -hush-cli \- manual page for hush-cli v3.4.0 +hush-cli \- manual page for hush-cli v3.5.0 .SH DESCRIPTION -Komodo RPC client version v3.4.0\-2fbcca416\-dirty +Komodo RPC client version v3.5.0\-beta6\-a59803c32\-dirty .PP In order to ensure you are adequately protecting your privacy when using Hush, please see . @@ -71,7 +71,7 @@ Timeout in seconds during HTTP requests, or 0 for no timeout. (default: Read extra arguments from standard input, one per line until EOF/Ctrl\-D (recommended for sensitive information such as passphrases) .SH COPYRIGHT -Hush Daemon version v3.4.0-2fbcca416-dirty +Hush Daemon version v3.5.0-beta6-a59803c32-dirty In order to ensure you are adequately protecting your privacy when using Hush, please see . diff --git a/doc/man/hush-tx.1 b/doc/man/hush-tx.1 index a6d3be7ef..fa3162fda 100644 --- a/doc/man/hush-tx.1 +++ b/doc/man/hush-tx.1 @@ -1,9 +1,9 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.10. -.TH HUSH-TX "1" "June 2020" "hush-tx v3.4.0" "User Commands" +.TH HUSH-TX "1" "July 2020" "hush-tx v3.5.0" "User Commands" .SH NAME -hush-tx \- manual page for hush-tx v3.4.0 +hush-tx \- manual page for hush-tx v3.5.0 .SH DESCRIPTION -Hush komodo\-tx utility version v3.4.0\-2fbcca416\-dirty +Hush komodo\-tx utility version v3.5.0\-beta6\-a59803c32\-dirty .SS "Usage:" .TP komodo\-tx [options] [commands] @@ -84,7 +84,7 @@ set=NAME:JSON\-STRING .IP Set register NAME to given JSON\-STRING .SH COPYRIGHT -Hush Daemon version v3.4.0-2fbcca416-dirty +Hush Daemon version v3.5.0-beta6-a59803c32-dirty In order to ensure you are adequately protecting your privacy when using Hush, please see . diff --git a/doc/man/hushd.1 b/doc/man/hushd.1 index 6e57386b7..370986f0f 100644 --- a/doc/man/hushd.1 +++ b/doc/man/hushd.1 @@ -1,10 +1,10 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.10. -.TH HUSHD "1" "June 2020" "hushd v3.4.0" "User Commands" +.TH HUSHD "1" "July 2020" "hushd v3.5.0" "User Commands" .SH NAME -hushd \- manual page for hushd v3.4.0 +hushd \- manual page for hushd v3.5.0 .SH DESCRIPTION Found binary: ./komodod -Hush Daemon version v3.4.0\-2fbcca416\-dirty +Hush Daemon version v3.5.0\-beta6\-a59803c32\-dirty .PP In order to ensure you are adequately protecting your privacy when using Hush, please see . @@ -541,7 +541,7 @@ output (default: 1 if running in a console, 0 otherwise) Number of seconds between metrics refreshes (default: 1 if running in a console, 600 otherwise) .PP -Komodo Asset Chain options: +Hush Smart Chain options: .HP \fB\-ac_algo\fR .IP @@ -639,7 +639,7 @@ Starting supply, default is 0 .IP Enforce transaction\-rate limit, default 0 .SH COPYRIGHT -Hush Daemon version v3.4.0-2fbcca416-dirty +Hush Daemon version v3.5.0-beta6-a59803c32-dirty In order to ensure you are adequately protecting your privacy when using Hush, please see . From 79a4a48c382b12689434e3d52c3dd4a6e81bf6fc Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 26 Jul 2020 14:58:49 -0400 Subject: [PATCH 137/255] Fix zaddr logging --- src/wallet/asyncrpcoperation_sendmany.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index 1b709b142..edcee1b76 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -473,14 +473,13 @@ bool AsyncRPCOperation_sendmany::main_impl() { // Add Sapling outputs for (auto r : z_outputs_) { auto address = std::get<0>(r); - auto value = std::get<1>(r); + auto value = std::get<1>(r); auto hexMemo = std::get<2>(r); - - auto addr = DecodePaymentAddress(address); + auto addr = DecodePaymentAddress(address); assert(boost::get(&addr) != nullptr); auto to = boost::get(addr); if(fZdebug) - LogPrintf("%s: Adding Sapling output to address %s\n", __FUNCTION__, to.GetHash().ToString().c_str()); + LogPrintf("%s: Adding Sapling output to address %s\n", __FUNCTION__, address.c_str()); auto memo = get_memo_from_hex_string(hexMemo); From b4e7f458266a0d870e072da7d6390308264ab622 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 28 Jul 2020 00:44:57 -0400 Subject: [PATCH 138/255] Remove dead code --- src/wallet/asyncrpcoperation_sendmany.cpp | 17 ----------------- src/wallet/asyncrpcoperation_shieldcoinbase.cpp | 17 ----------------- 2 files changed, 34 deletions(-) diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index edcee1b76..1b6a9c669 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -62,23 +62,6 @@ bool hush_hardfork_active(uint32_t time); extern UniValue signrawtransaction(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue sendrawtransaction(const UniValue& params, bool fHelp, const CPubKey& mypk); -int find_output(UniValue obj, int n) { - UniValue outputMapValue = find_value(obj, "outputmap"); - if (!outputMapValue.isArray()) { - throw JSONRPCError(RPC_WALLET_ERROR, "Missing outputmap for JoinSplit operation"); - } - - UniValue outputMap = outputMapValue.get_array(); - assert(outputMap.size() == ZC_NUM_JS_OUTPUTS); - for (size_t i = 0; i < outputMap.size(); i++) { - if (outputMap[i].get_int() == n) { - return i; - } - } - - throw std::logic_error("n is not present in outputmap"); -} - AsyncRPCOperation_sendmany::AsyncRPCOperation_sendmany( boost::optional builder, CMutableTransaction contextualTx, diff --git a/src/wallet/asyncrpcoperation_shieldcoinbase.cpp b/src/wallet/asyncrpcoperation_shieldcoinbase.cpp index de56ba3bc..78b89712e 100644 --- a/src/wallet/asyncrpcoperation_shieldcoinbase.cpp +++ b/src/wallet/asyncrpcoperation_shieldcoinbase.cpp @@ -51,23 +51,6 @@ using namespace libzcash; extern uint64_t ASSETCHAINS_TIMELOCKGTE; -static int find_output(UniValue obj, int n) { - UniValue outputMapValue = find_value(obj, "outputmap"); - if (!outputMapValue.isArray()) { - throw JSONRPCError(RPC_WALLET_ERROR, "Missing outputmap for JoinSplit operation"); - } - - UniValue outputMap = outputMapValue.get_array(); - assert(outputMap.size() == ZC_NUM_JS_OUTPUTS); - for (size_t i = 0; i < outputMap.size(); i++) { - if (outputMap[i].get_int() == n) { - return i; - } - } - - throw std::logic_error("n is not present in outputmap"); -} - AsyncRPCOperation_shieldcoinbase::AsyncRPCOperation_shieldcoinbase( TransactionBuilder builder, CMutableTransaction contextualTx, From 10c5809877e2db54f162c1f39165f1d9ae598fe9 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 28 Jul 2020 11:00:20 -0400 Subject: [PATCH 139/255] More z_sendmany debugging when -zdebug enabled --- src/wallet/asyncrpcoperation_sendmany.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index 1b6a9c669..46a556080 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -538,6 +538,8 @@ void AsyncRPCOperation_sendmany::sign_send_raw_transaction(UniValue obj) throw JSONRPCError(RPC_WALLET_ERROR, "Missing hex data for raw transaction"); } std::string rawtxn = rawtxnValue.get_str(); + if(fZdebug) + LogPrintf("%s: Signing raw txid=%s\n", __FUNCTION__, rawtxn.c_str()); UniValue params = UniValue(UniValue::VARR); params.push_back(rawtxn); @@ -549,12 +551,16 @@ void AsyncRPCOperation_sendmany::sign_send_raw_transaction(UniValue obj) // TODO: #1366 Maybe get "errors" and print array vErrors into a string throw JSONRPCError(RPC_WALLET_ENCRYPTION_FAILED, "Failed to sign transaction"); } + if(fZdebug) + LogPrintf("%s: Signed raw txid correctly %s\n", __FUNCTION__); UniValue hexValue = find_value(signResultObject, "hex"); if (hexValue.isNull()) { throw JSONRPCError(RPC_WALLET_ERROR, "Missing hex data for signed transaction"); } std::string signedtxn = hexValue.get_str(); + if(fZdebug) + LogPrintf("%s: Found hex data\n", __FUNCTION__, rawtxn.c_str()); // Send the signed transaction if (!testmode) { @@ -567,6 +573,8 @@ void AsyncRPCOperation_sendmany::sign_send_raw_transaction(UniValue obj) } std::string txid = sendResultValue.get_str(); + if(fZdebug) + LogPrintf("%s: sendrawtransction on txid=%s completed\n", __FUNCTION__, txid.c_str()); UniValue o(UniValue::VOBJ); o.push_back(Pair("txid", txid)); @@ -596,7 +604,8 @@ bool AsyncRPCOperation_sendmany::find_utxos(bool fAcceptCoinbase=false) { std::set destinations; destinations.insert(fromtaddr_); - //printf("Looking for %s\n", boost::apply_visitor(AddressVisitorString(), fromtaddr_).c_str()); + if(fZdebug) + LogPrintf("%s: Looking for %s\n", boost::apply_visitor(AddressVisitorString(), fromtaddr_).c_str()); vector vecOutputs; @@ -660,6 +669,9 @@ bool AsyncRPCOperation_sendmany::find_utxos(bool fAcceptCoinbase=false) { bool AsyncRPCOperation_sendmany::find_unspent_notes() { + if(fZdebug) + LogPrintf("%s: For address %s depth=%d\n", __FUNCTION__, fromaddress_.c_str(), mindepth_); + std::vector saplingEntries; { LOCK2(cs_main, pwalletMain->cs_wallet); From c14e7102bfd38733945004fca05165c83fd46809 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 28 Jul 2020 11:11:21 -0400 Subject: [PATCH 140/255] Reduce noise --- src/wallet/wallet.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index e10065de4..2212f8f1f 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -869,14 +869,10 @@ int64_t CWallet::NullifierCount() { LOCK(cs_wallet); if(fZdebug) { - // this is our *local* nullifier count - fprintf(stderr,"%s:mapTxSaplingNullifers.size=%d\n",__FUNCTION__,(int)mapTxSaplingNullifiers.size() ); - // here be dragons - fprintf(stderr,"%s:mempool.getNullifiers.size=%d\n",__FUNCTION__,(int)mempool.getNullifiers().size() ); - // this is the global nullifier count - fprintf(stderr,"%s:cacheSaplingNullifiers.size=%d\n",__FUNCTION__,(int)pcoinsTip->getNullifiers().size() ); + //fprintf(stderr,"%s:mapTxSaplingNullifers.size=%d\n",__FUNCTION__,(int)mapTxSaplingNullifiers.size() ); + //fprintf(stderr,"%s:mempool.getNullifiers.size=%d\n",__FUNCTION__,(int)mempool.getNullifiers().size() ); + //fprintf(stderr,"%s:cacheSaplingNullifiers.size=%d\n",__FUNCTION__,(int)pcoinsTip->getNullifiers().size() ); } - // TODO: expose local nullifier stats, for now global only return pcoinsTip->getNullifiers().size(); } From bfbe4e955379cdd00ea20a2aec222528710580de Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 28 Jul 2020 11:38:16 -0400 Subject: [PATCH 141/255] Tweak some logging --- src/main.cpp | 2 +- src/wallet/wallet.cpp | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 54643992f..d58edff19 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4873,7 +4873,7 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl // Update -zindex stats if (fZindex) { if (fZdebug) { - fprintf(stderr,"%s: setting blockchain zstats with zspends=%d, zouts=%d\n", __FUNCTION__, nShieldedSpendsInBlock, nShieldedOutputsInBlock ); + //fprintf(stderr,"%s: setting blockchain zstats with zspends=%d, zouts=%d\n", __FUNCTION__, nShieldedSpendsInBlock, nShieldedOutputsInBlock ); } pindex->nChainNotarizations = (pindex->pprev ? pindex->pprev->nChainNotarizations : 0) + pindex->nNotarizations; pindex->nChainShieldedTx = (pindex->pprev ? pindex->pprev->nChainShieldedTx : 0) + pindex->nShieldedTx; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 2212f8f1f..f519b5a46 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1648,12 +1648,14 @@ std::pair CWallet::FindMySap { LOCK(cs_SpendingKeyStore); uint256 hash = tx.GetHash(); + uint32_t nZouts = tx.vShieldedOutput.size(); + LogPrintf("%s: zouts=%d in tx=%s\n",__func__,nZouts, hash.ToString().c_str()); mapSaplingNoteData_t noteData; SaplingIncomingViewingKeyMap viewingKeysToAdd; // Protocol Spec: 4.19 Block Chain Scanning (Sapling) - for (uint32_t i = 0; i < tx.vShieldedOutput.size(); ++i) { + for (uint32_t i = 0; i < nZouts; ++i) { const OutputDescription output = tx.vShieldedOutput[i]; bool found = false; for (auto it = mapSaplingFullViewingKeys.begin(); it != mapSaplingFullViewingKeys.end(); ++it) { @@ -2407,7 +2409,7 @@ for (map, CWalletTx*>::iterator it = mapSorted.begin(); it != CWalletDB walletdb(strWalletFile, "r+", false); for (map::iterator it = mapUpdatedTxs.begin(); it != mapUpdatedTxs.end(); ++it) { CWalletTx* pwtx = it->second; - LogPrint("deletetx","Reorder Tx - Updating Positon to %i for Tx %s\n ", pwtx->nOrderPos, pwtx->GetHash().ToString()); + LogPrintf("%s: Updating Positon to %i for Tx %s\n ", __func__, pwtx->nOrderPos, pwtx->GetHash().ToString()); pwtx->WriteToDisk(&walletdb); mapWallet[pwtx->GetHash()].nOrderPos = pwtx->nOrderPos; } @@ -2415,7 +2417,7 @@ for (map, CWalletTx*>::iterator it = mapSorted.begin(); it != //Update Next Wallet Tx Positon nOrderPosNext = previousPosition++; CWalletDB(strWalletFile).WriteOrderPosNext(nOrderPosNext); - LogPrint("deletetx","Reorder Tx - Total Transactions Reordered %i, Next Position %i\n ", mapUpdatedTxs.size(), nOrderPosNext); + LogPrint("%s: Total Transactions Reordered %i, Next Position %i\n ", __func__, mapUpdatedTxs.size(), nOrderPosNext); } @@ -2430,9 +2432,9 @@ void CWallet::DeleteTransactions(std::vector &removeTxs) { for (int i = 0; i< removeTxs.size(); i++) { if (mapWallet.erase(removeTxs[i])) { walletdb.EraseTx(removeTxs[i]); - LogPrint("deletetx","Delete Tx - Deleting tx %s, %i.\n", removeTxs[i].ToString(),i); + LogPrintf("%s: Deleting tx %s, %i.\n", __func__, removeTxs[i].ToString(),i); } else { - LogPrint("deletetx","Delete Tx - Deleting tx %failed.\n", removeTxs[i].ToString()); + LogPrintf("%s: Deleting tx %failed.\n", __func__, removeTxs[i].ToString()); return; } } From eae956cde9e5e537d4755ad4cbb9369a72c2c3db Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Thu, 30 Jul 2020 09:01:29 -0700 Subject: [PATCH 142/255] Update docs --- src/rpc/mining.cpp | 6 +++--- src/rpc/rawtransaction.cpp | 4 ++-- src/wallet/rpcwallet.cpp | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 5262b1b1f..ab64e8d49 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers -// Copyright (c) 2019 The Hush developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -1021,8 +1021,8 @@ UniValue getblocksubsidy(const UniValue& params, bool fHelp, const CPubKey& mypk "1. height (numeric, optional) The block height. If not provided, defaults to the current height of the chain.\n" "\nResult:\n" "{\n" - " \"miner\" : x.xxx (numeric) The mining reward amount in KMD.\n" - " \"ac_pubkey\" : x.xxx (numeric) The mining reward amount in KMD.\n" + " \"miner\" : x.xxx (numeric) The mining reward amount in HUSH.\n" + " \"ac_pubkey\" : x.xxx (numeric) The mining reward amount in HUSH.\n" "}\n" "\nExamples:\n" + HelpExampleCli("getblocksubsidy", "1000") diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 71b28c642..2ed95a4df 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -480,8 +480,8 @@ UniValue getrawtransaction(const UniValue& params, bool fHelp, const CPubKey& my " ],\n" " \"vjoinsplit\" : [ (array of json objects, only for version >= 2)\n" " {\n" - " \"vpub_old\" : x.xxx, (numeric) public input value in KMD\n" - " \"vpub_new\" : x.xxx, (numeric) public output value in KMD\n" + " \"vpub_old\" : x.xxx, (numeric) public input value\n" + " \"vpub_new\" : x.xxx, (numeric) public output value\n" " \"anchor\" : \"hex\", (string) the anchor\n" " \"nullifiers\" : [ (json array of string)\n" " \"hex\" (string) input note nullifier\n" diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 350215b69..a2fa34b3b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4177,7 +4177,7 @@ UniValue z_getbalance(const UniValue& params, bool fHelp, const CPubKey& mypk) "1. \"address\" (string) The selected address. It may be a transparent or private address.\n" "2. minconf (numeric, optional, default=1) Only include transactions confirmed at least this many times.\n" "\nResult:\n" - "amount (numeric) The total amount in KMD received for this address.\n" + "amount (numeric) The total amount received for this address.\n" "\nExamples:\n" "\nThe total amount received by address \"myaddress\"\n" + HelpExampleCli("z_getbalance", "\"myaddress\"") + @@ -4622,7 +4622,7 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) "2. \"amounts\" (array, required) An array of json objects representing the amounts to send.\n" " [{\n" " \"address\":address (string, required) The address is a taddr or zaddr\n" - " \"amount\":amount (numeric, required) The numeric amount in KMD is the value\n" + " \"amount\":amount (numeric, required) The amount to send this address\n" " \"memo\":memo (string, optional) If the address is a zaddr, raw data represented in hexadecimal string format\n" " }, ... ]\n" "3. minconf (numeric, optional, default=1) Only use funds confirmed at least this many times.\n" From 19b6feecba6dbd27e53c570e5dd2d8e092ee9f13 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 31 Jul 2020 08:17:19 -0400 Subject: [PATCH 143/255] Fix docs of decoderawtransaction --- src/rpc/rawtransaction.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 2ed95a4df..23327faf2 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -935,8 +935,8 @@ UniValue decoderawtransaction(const UniValue& params, bool fHelp, const CPubKey& " ],\n" " \"vjoinsplit\" : [ (array of json objects, only for version >= 2)\n" " {\n" - " \"vpub_old\" : x.xxx, (numeric) public input value in KMD\n" - " \"vpub_new\" : x.xxx, (numeric) public output value in KMD\n" + " \"vpub_old\" : x.xxx, (numeric) public input value in HUSH\n" + " \"vpub_new\" : x.xxx, (numeric) public output value in HUSH\n" " \"anchor\" : \"hex\", (string) the anchor\n" " \"nullifiers\" : [ (json array of string)\n" " \"hex\" (string) input note nullifier\n" From 9459536b52a0465cd1b83f941890cc1f8195d022 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 31 Jul 2020 08:33:36 -0400 Subject: [PATCH 144/255] copyrights --- src/checkpoints.cpp | 1 + src/checkpoints.h | 1 + src/checkqueue.h | 1 + 3 files changed, 3 insertions(+) diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index 026475f88..73a514262 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/checkpoints.h b/src/checkpoints.h index 1b21755f0..6e2f62c5d 100644 --- a/src/checkpoints.h +++ b/src/checkpoints.h @@ -1,4 +1,5 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/checkqueue.h b/src/checkqueue.h index fc3cdb610..f81bb49c7 100644 --- a/src/checkqueue.h +++ b/src/checkqueue.h @@ -1,4 +1,5 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. From eab78f6b442bbca47d742d3c284cb2cfbb52fb59 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 31 Jul 2020 08:33:55 -0400 Subject: [PATCH 145/255] We probably don't need to version control our core files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ae3cff264..03f81cc82 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.deb src/bitcoin src/test/test_bitcoin +src/core *zcashTest.pk *zcashTest.vk From 63652a543dc4dd4378e28f6dd92f62c0013438b8 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 31 Jul 2020 08:34:08 -0400 Subject: [PATCH 146/255] Increase default stride to 5000 blocks --- contrib/checkpoints.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/checkpoints.pl b/contrib/checkpoints.pl index 93ea1041c..8d14b1619 100755 --- a/contrib/checkpoints.pl +++ b/contrib/checkpoints.pl @@ -9,7 +9,7 @@ use strict; my $perday = 576; my $hush = "./src/hush-cli"; my $gethash = "$hush getblockhash"; -my $stride = shift || 1000; +my $stride = shift || 5000; my $count = 0; my $blocks = qx{$hush getblockcount}; if($?) { From 6b531f4ecbb51b8523eb516c65a339b81aae246d Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 31 Jul 2020 08:51:35 -0400 Subject: [PATCH 147/255] Update checkpoints --- src/chainparams.cpp | 161 +++++++++++--------------------------------- 1 file changed, 40 insertions(+), 121 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index f14e2d9ef..b62f79b5d 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -597,145 +597,64 @@ void *chainparams_commandline() { boost::assign::map_list_of (0, pCurrentParams->consensus.hashGenesisBlock) - (1000, uint256S("0x0000001893130f005d2e90fcdf40057ae06390bd0490740aae2843e62aeb7bc2")) - (2000, uint256S("0x00000003003e6c8fa176ef293d1322514778343601fa21dfdb0c9aacef189576")) - (3000, uint256S("0x00000005c1419d252bc59d77c06e07aad61702c8b3e76d2070577a18159ab59d")) - (4000, uint256S("0x00000008bc4094ea475a871302361ffdc6bfd63ded049d172c8dad01ed67fd3c")) - (5000, uint256S("0x000000018f8543066baa9c5f83e981749da4cb625fad02c187b4a9c4693ebd60")) - (6000, uint256S("0x0000000567191591911b33b852e4b87de119df2c773bc800b5a3655be18eb98e")) - (7000, uint256S("0x000000082e7b000480d0317d9115f0d0737e78fa2381a2d6456f598bf83fe2f0")) - (8000, uint256S("0x0000000415226fff123cd868e255a23d72e204d61bb405fb9dde0810e7721ebf")) - (9000, uint256S("0x00000000bd26f7b8d6d80230aad06c0cd590758176b8558da7dfc14161a23ab7")) + // Generated at 1596199654 via hush3 contrib/checkpoints.pl by Duke Leto + (5000, uint256S("0x000000018f8543066baa9c5f83e981749da4cb625fad02c187b4a9c4693ebd60")) (10000, uint256S("0x00000002d177d1cbfeaf7c27a2a32766ea9063d222cbcc7623dc08355b07a3ad")) - (11000, uint256S("0x0000000284bcffa3bef4097178a94b6b9a788261981253cb8cd6db6b47634732")) - (12000, uint256S("0x000000006cf15fdb94253a9389d95ef607c3484c635fe0c8a1f1ec1e5a1c6865")) - (13000, uint256S("0x00000001cdc66e08f7f13c775aa1220a801a33df90edba7bbcffac8d06181207")) - (14000, uint256S("0x0000000443e432c7dbf0707a12c5671dd1ca606f962368a847bbcff2f5fc2135")) (15000, uint256S("0x000000008dbfbd5d5e27d819bf2989c5658c3494608bfa1320ad0b090660cd44")) - (16000, uint256S("0x00000003c6a59e5b10e1a1c6bef08dee4d33d1841156bf97e26c3e4df789b128")) - (17000, uint256S("0x00000001debe3734ef4b6aacedde4a6b04cd1c60d4cf37b9f4689f2225ff7c24")) - (18000, uint256S("0x00000002e37eccfa7bacd9c201468c754cbef50be9411e3f907891755eef4c6d")) - (19000, uint256S("0x000000044636331c0277abb5592529cae1303d2bd43981a8382b4cc152a8d024")) (20000, uint256S("0x00000000a7840e1fccedb13672804e94fcaa87c0360ee4f7353a6b93e5a59da8")) - (21000, uint256S("0x00000003a89b17d0cd489045ad62531c4211ee17c3609ed3e4291a067636d526")) - (22000, uint256S("0x0000000352a7a25b3fe5f1a32a2c42260d32345487b92b6e520eecec0ee6aca4")) - (23000, uint256S("0x00000002c1fdc5cc1211b7adff3b7e755059638fd98bd9da1cdd86bd9a0af1fd")) - (24000, uint256S("0x0000000603a6190bbfdcdc5da9645d069aebd7a0b29607077470089c7b4a1188")) (25000, uint256S("0x0000000519d6ab6ca9c705ebafa9946bce34934709621bc22227567e90608667")) - (26000, uint256S("0x0000000146e7314e2ebb2bfc10b9fe0fdd744734910a3971bbc4e970fe2c4cb9")) - (27000, uint256S("0x000000047060e4173b4edd6374c3580580981dea20d0b49ea15c9fdfa97ba104")) - (28000, uint256S("0x000000065eea521cccf6b1f99e1a77683717d02ddaed654a4c85d717e1e8c957")) - (29000, uint256S("0x00000001ecdbcd195e04f792721262dc79bb070e73b6606b389825b5ae8e4791")) (30000, uint256S("0x0000000240de901e9e70d2db5badf62886ab0e8c442107d571bc04b3bdd43052")) - (31000, uint256S("0x00000002d39f4f3504660e13e956c12aa3411a0ba392b3797d95f15e8fbd1958")) - (32000, uint256S("0x0000000130cd781ed559d553f35a6bc99ed252aadd92b2a461bd332ca2d69a96")) - (33000, uint256S("0x000000035ad950b0e78bbaf19f7a97865f29edd600e7aee4a3fce2e42db29d38")) - (34000, uint256S("0x00000004f33b5ff97c128bfbef656aa10341e2606f54e198d5280016d2578eca")) (35000, uint256S("0x00000000ad1ef91eb70011a94646c148f1b8949b464a0de82adf1ba1ce6175a5")) - (36000, uint256S("0x00000003b1450e1cf9f4e5f53534777b24039fcde81ec7ac1c2ea754a26fcd78")) - (37000, uint256S("0x0000000337c4407954be01dcaf75a660e4b5b69e9e923bd62e74b0e44f01d9df")) - (38000, uint256S("0x00000002b5d6f83f8d2ef7d88c3cdff1e444882819a70a7c7281d1d92f81bc9a")) - (39000, uint256S("0x00000001a1eb6a530b065c873f65219de3282c4f386ba68bc2a0b88dc2b4c5cd")) (40000, uint256S("0x000000013b65e22d0bb6a9103dc71da5a1b7fa2acbc1c7d7a4d8f7730c37d4ab")) - (41000, uint256S("0x000000027dbc2315769690cf93c79c54e0591c808d83decb66302492f0f79f1c")) - (42000, uint256S("0x00000000ca09a12162a92b9ecbf6bf00a2bb822a77dd142df26d81db95c21bed")) - (43000, uint256S("0x000000050c4c80b9e53b960a638bd231c193a383f0df162c720e4594ba427a4b")) - (44000, uint256S("0x00000000f42d6c43703dbb47847298cedcbef8a27018baed8f4a217e7d5d823c")) (45000, uint256S("0x00000004da449923c218bd3e69745ebafca41c32e0c81ab6b485ae6c4c80df18")) - (46000, uint256S("0x00000006e4bdf2707158e266d2d54294b20063c0f1723abed97fafe7ecf4b2de")) - (47000, uint256S("0x0000000015d099357b0c8cbc24d8e2bd18e5e47eabe6ff89c09c9837bb071cd8")) - (48000, uint256S("0x00000009c9ddaffefc5d5c78a6f89b872fdd732c16a5311debed6b92255f340b")) - (49000, uint256S("0x00000008447d907ddc1d87df0ea235636baaaf34bc1000620e8173f1d8f7758c")) (50000, uint256S("0x000000027470e84cd195242f199b90fde40b70f80fac7a7080b1517c95cf56c6")) - (51000, uint256S("0x000000015190913dec8a508bc219b0a0a1587b50acb23b48343010015cb5ec69")) - (52000, uint256S("0x000000071608ad395dc31dc3011d5cad7f7a7296e34490a1e9e2dcf060bcc649")) - (53000, uint256S("0x0000000608fa8a454c3c0e5e06bf091c4cfa131e7b91eb6622087cfc3fa4c149")) - (54000, uint256S("0x0000000455eac130c205512cc0bffaa3ecb2d393cbf0d9e943c3d5911ea06a4b")) (55000, uint256S("0x00000000a20b276ed95b261a51681fb2d0d58e528cc8cd2e5fb7fdeb732b1861")) - (56000, uint256S("0x000000016057dfbf2fc59650b63b7c2dc2379af75cf00c0ee3f3835e992ec11e")) - (57000, uint256S("0x00000003a1eff8b5160655111ff1c0f1426b2b879c1f6fd761332b82c8640c67")) - (58000, uint256S("0x00000001b0ac789061a277b553de1aae373533f5b6b1330326744ac7087c87c9")) - (59000, uint256S("0x0000000a0dee07bdf593a68e5463cb5553f9bce3367a39d88f07ea43709eba87")) (60000, uint256S("0x000000060382850eadef184b67f38c0b2de27157296f3d9d8e2b7b70b1f76127")) - (61000, uint256S("0x0000000492a93fd6c9eb080f3398517b39c8eaf835440d2571e515f76a931bf2")) - (62000, uint256S("0x00000005ee0b8f7fcae8e6b17b12ab66f17cf34697182afc29d863d9844a84a9")) - (63000, uint256S("0x000000045842b1c05c7e9a1a887e9a6ecdcaea2f4e03b9476031ed609ace91d2")) - (64000, uint256S("0x00000004259921159c0714b90b1950fbae7eee2a14687dcfc57ab22b39c8123c")) (65000, uint256S("0x0000000618eb1c909301585f6b8f17ee6d09da97c580fe70d59babcd7864b556")) - (66000, uint256S("0x000000049c85139efb1694525b5cf864a6021e49a412aaea9ff2b2b6ee04e1ca")) - (67000, uint256S("0x0000000141358b3ae2c4ab2a384f963f4fdc925060c42de5578aec82c1de3189")) - (68000, uint256S("0x0000000405b0273ba96d1e83e27e50ecf5f123c2e3e05b56524cc2cd79ea18e7")) - (69000, uint256S("0x0000000764c8a434a1583b2578155a18720bbad67cc2c06e2fb013e872b1b10e")) (70000, uint256S("0x00000006d11cf168399c719b2bb036eadd09e740c98764d82adf75f5a800e90d")) - (71000, uint256S("0x00000002339c3cf62fc4716899a0e341969d85146dcb98854607332f81e5f258")) - (72000, uint256S("0x000000055e39f9cd963bac08c9c10ab982491d50b66486099675b015016dad7a")) - (73000, uint256S("0x0000000766261dbd9e48a0d544d012f57ab7890a761d893851b63e0e5b5e47dc")) - (74000, uint256S("0x000000058bd8080674ffb086704fbfde45e91172d0784416ed5356d20bd60fd7")) (75000, uint256S("0x00000007abb9cb521244c988f0ace53bf230bdf9c9db75d0102472a721c6b038")) - (76000, uint256S("0x000000071789d7ecf5e8c7e1a982e119d0b9d6748cb01426a5b8fff77a54f76b")) - (77000, uint256S("0x00000007364be847b08481f87bbe4db69a79f5c4388e3c898ea140011a121ca7")) - (78000, uint256S("0x000000031b7afd1aa244d78056606bf718cb96cb1fe1656070d37ed9d4031ebf")) - (79000, uint256S("0x00000003125d8e62fa215c1797229d271db705299f43e1db85edb7ac68349127")) (80000, uint256S("0x000000031c23c3a1828b3a432ab27c6b34a93741f5711507abeb34a822ba5311")) - (81000, uint256S("0x0000000212aab2361322e29a1037b82624fc2acdb61dd457ae25e4dffca14b42")) - (82000, uint256S("0x00000003140442a0d3b5ba57d2e51ed4a2ec39fb6ee8c9e2d70d530f46843f57")) - (83000, uint256S("0x0000000404e963d87db2ccd709377d5fd8b28c67c51ffcace62290844b895ba0")) - (84000, uint256S("0x00000003076c29391d9a5910e287d5319f4bf29f92eb309a8dd72cbf98847102")) (85000, uint256S("0x00000006fc5823857bdd44f89f4a97838a9f735c7bdf81bd89f50110dc16fbab")) - (86000, uint256S("0x00000002247705c4f02ab4a672686dadba9de55fcf71433388a4250af6d1154d")) - (87000, uint256S("0x00000000302718129c873c0ba6e571512ab5c4216e0d978ed3ef1d4dccddbb26")) - (88000, uint256S("0x00000002129732e7d8d99d78eef4ed3318cdbd73883d88e7c2b9534d11284486")) - (89000, uint256S("0x00000001513759a2e2b6e6c30ee8db631957511adcefa518ad31e0b1ec4e789d")) (90000, uint256S("0x00000003e62dcb81fe33178e2dc45c70ca04733542179ac5d93bceb7c456f365")) - (91000, uint256S("0x00000000674963dd8d6d7dab67d1df8c6e9455cef55014aa15082722f9d7f115")) - (92000, uint256S("0x00000004f4e1151df0905baf82bd29ece0fc7db8d96a2ae6c0efad0e0e68e55e")) - (93000, uint256S("0x00000002876b9eb7b41e025d55d7dd740b5dc811eae0909169081e705c61b6b5")) - (94000, uint256S("0x00000001efdcd19bf060a424cd0cef2d04f0d206fae21a72a57b4cc8d1019421")) (95000, uint256S("0x00000002a22cae35b32e31ffbe55d2d56ef04f010aebd19f1536b7582c1ea4d9")) - (96000, uint256S("0x0000000433d2385e8260c26dabec1c5f7376ed63b478c5d94bc15ee521a86ee3")) - (97000, uint256S("0x00000003112c73fd4cf10604e1a44b7acd698e196cbe16e63abdcd34008f4b36")) - (98000, uint256S("0x0000000179fb7ea8e68c54de5d09e531b5cbbfe7f5d128f3f93f55576673ddc7")) - (99000, uint256S("0x00000002e8e3a9f26154b941837d42ad62ea153d75be61a13c04e2249a781243")) - (100000, uint256S("0x00000001bc1c40d120bf2df1654f3fb5e4d28d4ff292d05667cf5610042c794a")) - (101000, uint256S("0x00000003a52ec72d58bdb88096334a29eddb17fd454a7c15aba815358f3b4285")) - (102000, uint256S("0x00000002a602644eb8765aab158112307f25bc6e8f82c1220be08642be6d12ca")) - (103000, uint256S("0x000000044a6a0aca758af879fee5bbbfc4ac75287f63cc91ad26bc921d3c44ac")) - (104000, uint256S("0x000000013fe4abb66862573821938d8e203da577e8c15055249a5fc4d6ca28f6")) - (105000, uint256S("0x0000000175182a7f9c46aaae8723a664168af4be37c5d73e8f773df6b67a458b")) - (106000, uint256S("0x000000005426bdc52efa996e5bd44f0d5f075fdd865063a1c5c341f4b37aa8d7")) - (107000, uint256S("0x000000026ce5ee0c6f81786838f502ab3ac4b52371716b3956bb58f91fe2a79e")) - (108000, uint256S("0x000000042a0f660df6ef24e237b4010749b7cc7ba402fe7f6af98643df62cb0b")) - (109000, uint256S("0x000000020debe96d90bc1d317036404c4518309e93c45303f86bdef7fac213df")) - (110000, uint256S("0x000000030ba3cdbb85d5028379dfe50fbf28c04f8add3300814c2f649ec53594")) - (111000, uint256S("0x000000030d9aa7e30990157616d54e5c32a26a0fbb5db1a7fde7e192bb2bd992")) - (112000, uint256S("0x00000003885472c246e7f5cc5c9982ce0d1ed292ff0b09451c272f201ff1bd3a")) - (113000, uint256S("0x000000027d6d7f782a510fa9b2a41f8f1a713fa4ff12906e453ba59af911cbfc")) - (114000, uint256S("0x000000046020cd15a3803db747ec6811bee5703c9b67b54185d8fae23f7617cf")) - (115000, uint256S("0x000000019fd1a317c649c83c6b2a3f6bca7e82fac2fc89ce69de4b6d5715050b")) - (116000, uint256S("0x00000002cad5e312f8553c3ca053f3588d53561722ce3bf20d55eb4654707668")) - (117000, uint256S("0x0000000339f55a289fabf4881ab5d89739779bc0e1ab5650830b4fec8870d183")) - (118000, uint256S("0x000000027bc70600ad7355ee66e6ca0b9d2fd24b7778014bb464a7bbc37627de")) - (119000, uint256S("0x00000001ddca829e3480f45ec3f7291fe9d611dd4600c047516729052a881058")) - (120000, uint256S("0x0000000217decb42c4ea26cbee700e728a558ae648393b8014f035566ef2a456")) - (121000, uint256S("0x00000000f2798338531f5a39201960a80ec28203cdd5dcd27718f6a7fd6723bf")) - (122000, uint256S("0x00000001204dfcde9f95ef04a25f54553329a48fe34078e213d93199dfe0c26b")) - (123000, uint256S("0x0000000220091729c30ec5a296a5218e0500bff2dfe10a5d9e5ceca2ea39482b")) - (124000, uint256S("0x00000002415360bf949d8e96362ce7b0aada6adbcfb73aba536fa7a329fec49f")) - (125000, uint256S("0x000000002aeab45f5e399d027976c49f4c7732ddbb78d7dc729fb226346ea3f1")) - (126000, uint256S("0x0000000067f239b6b78180145dc4ccbda1c71d506201f807912ddc170683808d")) - (127000, uint256S("0x00000001962a64e4e5a9e9c6cc286e2bcf155734c24f2c9481128e37ac6d9712")) - (128000, uint256S("0x000000011dfac6f7447ae6de5002dd3bf5ddc94faadb706f45e0b4724257dfe5")) - (129000, uint256S("0x0000000014f4aa454784a182645fa425834f8f9464abea319ea0afe5d3ccd91a")) - (130000, uint256S("0x000000001c4a5aa11e6c142931463fcf7a9f5b9fb41061d26c18ff1860431881")) - (131000, uint256S("0x000000003c44e490a60f7aa1941835277230706cfbf58dc8113610cc9c3582eb")) - (132000, uint256S("0x0000000041bef6adaff29263986224bd5a2999e2aec38aa07b52fa67eed1402f")) - (133000, uint256S("0x0000000162eb0ea1633481197a8ddc3743ff32ce2e8ecc249f9a8e9912459e05")) - (134000, uint256S("0x00000002a34611317b4b1d8bc8640282ffb7d7c86fc858af7e0abb0bca6b720d")) - (135000, uint256S("0x000000025f9502fc7474d62a0a23417cc5b77f3a049260e65b5b810d71074743")) - (136000, uint256S("0x00000000af2a19997fde28b70235070f627f3b5900a9ee13c927529a11110bc6")), - (int64_t) 1575741799, // time of last checkpointed block - (int64_t) 274689, // total txs - (double) 1065 // txs in the last day before block 136590 + (100000, uint256S("0x00000001bc1c40d120bf2df1654f3fb5e4d28d4ff292d05667cf5610042c794a")) + (105000, uint256S("0x0000000175182a7f9c46aaae8723a664168af4be37c5d73e8f773df6b67a458b")) + (110000, uint256S("0x000000030ba3cdbb85d5028379dfe50fbf28c04f8add3300814c2f649ec53594")) + (115000, uint256S("0x000000019fd1a317c649c83c6b2a3f6bca7e82fac2fc89ce69de4b6d5715050b")) + (120000, uint256S("0x0000000217decb42c4ea26cbee700e728a558ae648393b8014f035566ef2a456")) + (125000, uint256S("0x000000002aeab45f5e399d027976c49f4c7732ddbb78d7dc729fb226346ea3f1")) + (130000, uint256S("0x000000001c4a5aa11e6c142931463fcf7a9f5b9fb41061d26c18ff1860431881")) + (135000, uint256S("0x000000025f9502fc7474d62a0a23417cc5b77f3a049260e65b5b810d71074743")) + (140000, uint256S("0x00000000ea91b31e677db9f506e9de4ce03b609275212072759aada24b4654bf")) + (145000, uint256S("0x000000003f623cfbe83830077ce9d79f692cb1cd39f027d2bbfba0861dc050d7")) + (150000, uint256S("0x00000001850c65319eb4048f175e9540091dad9e4a7f8aeb5c989137e15a8524")) + (155000, uint256S("0x00000003c30e0e03841c63a47e934c0ba7f42578c6065ca03436dca8c99918da")) + (160000, uint256S("0x0000000553274de0e5f07bf3a63bdb6ab71158a3506829fd6f7df2cd51d5b2a3")) + (165000, uint256S("0x00000002c72ab9752b4f605b303f5c006600eb8e62baab7016af2e0454894c9b")) + (170000, uint256S("0x0000000191d6e3c5473215ab1e28a8fa8db6172eb4ec6fed371d4bd71224adb0")) + (175000, uint256S("0x00000000ac73f67cdc92b225e0895054ba4349d68ddca707ba536d9946f14a2b")) + (180000, uint256S("0x00000003119d28eed1fd0c2e2a33510b2b740c1227a9e0e59157228f8e9e1666")) + (185000, uint256S("0x000000032f71875bf21794a8aa44720e10bef77c12af1aec30951999a4d190d7")) + (190000, uint256S("0x000000002beb4cc8e79a3aed7b1b8329b31a55a3e1556b0933953450a0c185b9")) + (195000, uint256S("0x00000001f2fec10089b395c2df2edbfd15e67077ea48706a43bedaf5eae0e5ca")) + (200000, uint256S("0x00000003d57cdb7fba2f3b641d288737945de2434adeb0b3b3f2ef35a66e45ab")) + (205000, uint256S("0x000000011c8311c289958290444111ffc33261773cc171bfe9a492f59dd2be01")) + (210000, uint256S("0x000000006e43c9650b62ae15d05ada7d12be75df37a8b600b636268b144e2aab")) + (215000, uint256S("0x0000000385861debdf375a584fc33c6da0a13b9ae41cb904483903f29b8f423c")) + (220000, uint256S("0x00000000dd40d7372e60da03205bfc9bd796cc467737e093a58ab08b688014a4")) + (225000, uint256S("0x0000000216ec6bc7a702846ac429ff9e9b1dc14c0528689e810f663a05045f24")) + (230000, uint256S("0x000000015b0545acc87aa652a8d8d5aac1ecfc5e15d9e3a9e4171d472fdfa9b4")) + (235000, uint256S("0x00000000b841e412b8828fe64693bec0a6922d048f8ae061ba547fcad93f7e8f")) + (240000, uint256S("0x000000013e22209c4587e7fce090b7219f2d96640172697d276b606cf53ce07b")) + (245000, uint256S("0x00000002c0b1deff663826669c4a5bbfcba9cf7029598a35bb999afb27cce854")) + (250000, uint256S("0x00000003cba3713646dc533b75fba6f6fe02779e4fb934cda4fe2109c9403268")) + (255000, uint256S("0x00000000b76f444f3f5258a2d20d2639c0bffebb6ee0217caa56fcd0404337d5")) + (260000, uint256S("0x00000001f2dc5f292d9ee232d463faf1bc59362b9b3432f5bd1f72ffc76716f8")) + (265000, uint256S("0x00000003c2dc488c16fc1d73b288065e89bfb9e38dd08cc543867b0b7aa26047")) + (270000, uint256S("0x000000026cc545eed18b508c3368cd20256c012bfa10f5f115b21ad0101c02cb")) + (int64_t) 1596129098, // time of last checkpointed block + (int64_t) 527001, // total txs + (double) 891, // txs in the last day before block 270407 }; } else { checkpointData = //(Checkpoints::CCheckpointData) From 1d2401530032c5fd00665072243ac430107e0ba5 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 31 Jul 2020 09:24:47 -0400 Subject: [PATCH 148/255] Update checkpoints --- src/chainparams.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index b62f79b5d..3714e0857 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -593,11 +593,11 @@ void *chainparams_commandline() pCurrentParams->consensus.vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight = ASSETCHAINS_OVERWINTER; // Generated at 1575831755 via hush3 contrib/checkpoints.pl by Duke Leto if (strcmp(ASSETCHAINS_SYMBOL,"HUSH3") == 0) { + // Generated at 1596199654 via hush3 contrib/checkpoints.pl by Duke Leto checkpointData = //(Checkpoints::CCheckpointData) { boost::assign::map_list_of (0, pCurrentParams->consensus.hashGenesisBlock) - // Generated at 1596199654 via hush3 contrib/checkpoints.pl by Duke Leto (5000, uint256S("0x000000018f8543066baa9c5f83e981749da4cb625fad02c187b4a9c4693ebd60")) (10000, uint256S("0x00000002d177d1cbfeaf7c27a2a32766ea9063d222cbcc7623dc08355b07a3ad")) (15000, uint256S("0x000000008dbfbd5d5e27d819bf2989c5658c3494608bfa1320ad0b090660cd44")) @@ -651,14 +651,14 @@ void *chainparams_commandline() (255000, uint256S("0x00000000b76f444f3f5258a2d20d2639c0bffebb6ee0217caa56fcd0404337d5")) (260000, uint256S("0x00000001f2dc5f292d9ee232d463faf1bc59362b9b3432f5bd1f72ffc76716f8")) (265000, uint256S("0x00000003c2dc488c16fc1d73b288065e89bfb9e38dd08cc543867b0b7aa26047")) - (270000, uint256S("0x000000026cc545eed18b508c3368cd20256c012bfa10f5f115b21ad0101c02cb")) + (270000, uint256S("0x000000026cc545eed18b508c3368cd20256c012bfa10f5f115b21ad0101c02cb")), (int64_t) 1596129098, // time of last checkpointed block (int64_t) 527001, // total txs - (double) 891, // txs in the last day before block 270407 + (double) 891 // txs in the last day before block 270407 }; } else { checkpointData = //(Checkpoints::CCheckpointData) - { + { boost::assign::map_list_of (0, pCurrentParams->consensus.hashGenesisBlock), (int64_t)1231006505, @@ -669,6 +669,7 @@ void *chainparams_commandline() } pCurrentParams->SetCheckpointData(checkpointData); + fprintf(stderr,"%s: Set checkpoint data\n", __func__); ASSETCHAIN_INIT = 1; return(0); From 40d6716993e7695f52d1f6b61c8fe00fde7422ca Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 1 Aug 2020 09:12:14 -0400 Subject: [PATCH 149/255] Update Hush emission schedule code based on going to 75s blocks @ Block 340K --- src/komodo_bitcoind.h | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 930d7ddf8..e58056a40 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1254,32 +1254,51 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); if (ishush3) { - int32_t starting_commission = 125000000, HALVING1 = 340000, INTERVAL = 840000, TRANSITION = 129, BR_END = 5422111; + // TODO: Calculate new BR_END based on 75s block time!!! 2X old BR_END is a rough estimate, not exact! + int32_t starting_commission = 125000000, HALVING1 = GetArg("-z2zheight",340000), INTERVAL = 840000, TRANSITION = 129, BR_END = 2*5422111; // HUSH supply curve cannot be exactly represented via KMD AC CLI args, so we do it ourselves. // You specify the BR, and the FR % gets added so 10% of 12.5 is 1.25 // but to tell the AC params, I need to say "11% of 11.25" is 1.25 // 11% ie. 1/9th cannot be exactly represented and so the FR has tiny amounts of error unless done manually + + + if( height > HALVING1) { + // Block time going from 150s to 75s (half) means the interval between halvings + // must be twice as often, i.e. 840000*2=1680000 + // With 150s blocks, we have 210,000 blocks per year + // With 75s blocks, we have 420,000 blocks per year + INTERVAL = 1680000; + } + // Transition period of 128 blocks has BR=FR=0 if (height < TRANSITION) { commission = 0; - } else if (height < HALVING1) { + } else if (height < HALVING1) { // before 1st Halving @ Block 340000 (Nov 2020) commission = starting_commission; - } else if (height < HALVING1+1*INTERVAL) { + } else if (height < HALVING1+1*INTERVAL) { // before 2nd Halving @ Block 2020000 commission = starting_commission / 2; - } else if (height < HALVING1+2*INTERVAL) { + } else if (height < HALVING1+2*INTERVAL) { // before 3rd Halving @ Block 3700000 commission = starting_commission / 4; - } else if (height < HALVING1+3*INTERVAL) { + } else if (height < HALVING1+3*INTERVAL) { // before 4th Halving @ Block 5380000 commission = starting_commission / 8; - } else if (height < HALVING1+4*INTERVAL) { + } else if (height < HALVING1+4*INTERVAL) { // before 5th Halving @ Block 7060000 commission = starting_commission / 16; - } else if (height < HALVING1+5*INTERVAL) { + } else if (height < HALVING1+5*INTERVAL) { // before 6th Halving @ Block 8740000 commission = starting_commission / 32; - } else if (height < HALVING1+6*INTERVAL) { // Block 5380000 - // Block reward will go to zero between 7th+8th halvings, ac_end may need adjusting + } else if (height < HALVING1+6*INTERVAL) { // before 7th Halving @ Block 10420000 commission = starting_commission / 64; - } else if (height < HALVING1+7*INTERVAL) { - // Block reward will be zero before this is ever reached - commission = starting_commission / 128; // Block 6220000 + } else if (height < HALVING1+7*INTERVAL) { // before 8th Halving @ Block 12100000 + // Block reward will go to zero between 7th+8th halvings, ac_end may need adjusting + commission = starting_commission / 128; + } else if (height < HALVING1+8*INTERVAL) { // before 9th Halving @ Block 13780000 + // BR should be zero before this halving happens + commission = starting_commission / 256; + } + // Explicitly set the last block reward + // BR_END is the block with the last non-zero block reward, which overrides + // the -ac_end param on HUSH3 + if(height > BR_END) { + commission = 0; } } From 8558fa1c8d01f8dfd7b15cf377909e543efcd738 Mon Sep 17 00:00:00 2001 From: jahway603 Date: Tue, 11 Aug 2020 23:44:28 -0400 Subject: [PATCH 150/255] Added stdexcept to src/crypto/equihash.h to enable compiling hush3 in Arch Linux with gcc 10 --- src/crypto/equihash.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/crypto/equihash.h b/src/crypto/equihash.h index 57c434dae..533e0d512 100644 --- a/src/crypto/equihash.h +++ b/src/crypto/equihash.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include From 9deb58fa4ea4dca1e959612aca313aa038d08e20 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 16 Aug 2020 23:18:15 -0400 Subject: [PATCH 151/255] Start to tweak hush_supply and save old script to compare results --- contrib/hush_supply | 2 +- contrib/hush_supply_old | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100755 contrib/hush_supply_old diff --git a/contrib/hush_supply b/contrib/hush_supply index 92e917055..674424073 100755 --- a/contrib/hush_supply +++ b/contrib/hush_supply @@ -1,5 +1,5 @@ #!/usr/bin/env perl -# Copyright 2019 The Hush developers +# Copyright 2019-2020 The Hush developers # Released under the GPLv3 use warnings; use strict; diff --git a/contrib/hush_supply_old b/contrib/hush_supply_old new file mode 100755 index 000000000..674424073 --- /dev/null +++ b/contrib/hush_supply_old @@ -0,0 +1,33 @@ +#!/usr/bin/env perl +# Copyright 2019-2020 The Hush developers +# Released under the GPLv3 +use warnings; +use strict; + +my $supply = 0.0; +my $block = 0; +my $satoshis = 100_000_000; +my $amount = int(12.5*$satoshis); +my $halvings = 0; + +# Usage: ./hush_supply &> supply.csv + +# Use this to calculate when supply hits a certain value +#while ($supply <= 21_000_000*$satoshis) { +# Use this to calculate when block rewards end +while ($halvings <= 64 && $amount >= 1) { + $block++; + if ($block < 5) { + $amount = 40_000 * $satoshis; + } else { + # Halving every 840000 blocks + if ($block % 840_000 == 0) { + $amount /= 2; + $halvings++; + } + $amount = int(12.5*$satoshis) / (2**$halvings); + } + $supply += $amount; + # block, current supply, block reward amount, number of halvings + printf "%s,%s,%s,%s\n", $block,$supply / $satoshis, $amount / $satoshis, $halvings; +} From 6745ea5a48e6e443375f2b98b8b4f468b04d235a Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 17 Aug 2020 00:17:09 -0400 Subject: [PATCH 152/255] WIP script to simulate Hush total supply for every block in the future until it goes to zero --- contrib/hush_supply | 43 ++++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/contrib/hush_supply b/contrib/hush_supply index 674424073..99659f219 100755 --- a/contrib/hush_supply +++ b/contrib/hush_supply @@ -4,30 +4,43 @@ use warnings; use strict; +# Simulate the total supply on Hush v3 mainnet + my $supply = 0.0; my $block = 0; my $satoshis = 100_000_000; -my $amount = int(12.5*$satoshis); +my $reward0 = int(12.5*$satoshis); my $halvings = 0; +my $initial = 6178674 * $satoshis; +my $interval = 1_640_000; # 4 years of 75s blocks +my $height = shift || -1; -# Usage: ./hush_supply &> supply.csv +# Usage: ./hush_supply &> supply.csv +# ./hush_supply HEIGHT &> supply.csv # stop at HEIGHT -# Use this to calculate when supply hits a certain value -#while ($supply <= 21_000_000*$satoshis) { -# Use this to calculate when block rewards end -while ($halvings <= 64 && $amount >= 1) { +my $reward = $reward0; +# We know BR will go to zero between 7 and 8th halvings +while ($halvings <= 10) { $block++; - if ($block < 5) { - $amount = 40_000 * $satoshis; + # blocks 2-127 of Hush v3 had BR=0 + if ($block == 1) { + $reward = $initial; # airdropped funds from Hush v2 mainnet + } elsif ($block > 1 && $block < 128) { + $reward = 0; # blocks 2-127 have BR=0 } else { - # Halving every 840000 blocks - if ($block % 840_000 == 0) { - $amount /= 2; - $halvings++; + if ($block < 340_000) { + $reward = $reward0; + } else { + # Past the first halving + $block -= 340_000; + $halvings = 1 + ($block % $interval); + $reward <<= $halvings; } - $amount = int(12.5*$satoshis) / (2**$halvings); } - $supply += $amount; + $supply += $reward; # block, current supply, block reward amount, number of halvings - printf "%s,%s,%s,%s\n", $block,$supply / $satoshis, $amount / $satoshis, $halvings; + # all amounts are in satoshis + printf "%s,%s,%s,%s\n",$block, $supply, $reward, $halvings; + #exit(0) if ($block > 200); + exit(0) if $block == $height; } From 5315ded7861d218072991a5bfc33d7492fd0a052 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Fri, 4 Sep 2020 19:31:05 -0700 Subject: [PATCH 153/255] Support wallet.dat outside of datadir Ported from https://github.com/zcash/zcash/commit/6a7cfdea54a9469ac1234e32db9d2fed0bb146af which did not apply cleanly. --- qa/rpc-tests/feature_walletfile.py | 51 ++++++++++++++++++++++++++++++ src/wallet/wallet.cpp | 17 ++++++++++ 2 files changed, 68 insertions(+) create mode 100755 qa/rpc-tests/feature_walletfile.py diff --git a/qa/rpc-tests/feature_walletfile.py b/qa/rpc-tests/feature_walletfile.py new file mode 100755 index 000000000..f38403574 --- /dev/null +++ b/qa/rpc-tests/feature_walletfile.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python3 +# Copyright (c) 2017 The Bitcoin Core developers +# Copyright (c) 2019-2020 The Hush developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or https://www.opensource.org/licenses/mit-license.php +"""Test wallet file location.""" + +import os + +from test_framework.util import start_node, stop_node, assert_start_raises_init_error + +from test_framework.test_framework import BitcoinTestFramework + +class WalletFileTest(BitcoinTestFramework): + def set_test_params(self): + self.num_nodes = 1 + self.setup_clean_chain = True + + def run_test(self): + # test default wallet location + assert os.path.isfile(os.path.join(self.options.tmpdir, "node0", "regtest", "wallet.dat")) + + # test alternative wallet file name in datadir + stop_node(self.nodes[0], 0) + self.nodes[0] = start_node(0, self.options.tmpdir, ["-wallet=altwallet.dat"]) + assert os.path.isfile(os.path.join(self.options.tmpdir, "node0", "regtest", "altwallet.dat")) + + # test wallet file outside datadir + tempname = os.path.join(self.options.tmpdir, "outsidewallet.dat") + stop_node(self.nodes[0], 0) + self.nodes[0] = start_node(0, self.options.tmpdir, ["-wallet=%s" % tempname]) + assert os.path.isfile(tempname) + + # test the case where absolute path does not exist + assert not os.path.isdir("/this_directory_must_not_exist") + invalidpath = os.path.join("/this_directory_must_not_exist/", "foo.dat") + stop_node(self.nodes[0], 0) + assert_start_raises_init_error(0, "-wallet=%s" % invalidpath, + "Error: Absolute path %s does not exist") + + # relative path does not exist + invalidpath = os.path.join("wallet", "foo.dat") + assert_start_raises_init_error(0, "-wallet=%s" % invalidpath, + "Error: Relative path %s does not exist") + + # create dir and retry + os.mkdir(os.path.join(self.options.tmpdir, "node0", "regtest", "wallet")) + self.nodes[0] = start_node(0, self.options.tmpdir, ["-wallet=%s" % invalidpath]) + +if __name__ == '__main__': + WalletFileTest().main() diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index f519b5a46..1347ef974 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -668,6 +668,23 @@ void CWallet::Flush(bool shutdown) bool CWallet::Verify(const string& walletFile, string& warningString, string& errorString) { + LogPrintf("Using wallet %s\n", walletFile); + uiInterface.InitMessage(_("Verifying wallet...")); + + if (walletFile != boost::filesystem::basename(walletFile) + boost::filesystem::extension(walletFile)) { + boost::filesystem::path path(walletFile); + if (path.is_absolute()) { + if (!boost::filesystem::exists(path.parent_path())) { + return UIError(strprintf(_("Absolute path %s does not exist!"), walletFile)); + } + } else { + boost::filesystem::path full_path = GetDataDir() / path; + if (!boost::filesystem::exists(full_path.parent_path())) { + return UIError(strprintf(_("Relative path %s does not exist!"), walletFile)); + } + } + } + if (!bitdb.Open(GetDataDir())) { // try moving the database env out of the way From ad3e5db501c7d99748f8cee0a537ec8e1ea2be9f Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Fri, 4 Sep 2020 19:40:29 -0700 Subject: [PATCH 154/255] Update help regarding new -wallet option for relative paths --- src/init.cpp | 2 +- src/wallet/wallet.cpp | 1 + src/wallet/wallet.h | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/init.cpp b/src/init.cpp index d52888503..cd25e63fd 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -454,7 +454,7 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-maxtxfee=", strprintf(_("Maximum total fees (in %s) to use in a single wallet transaction; setting this too low may abort large transactions (default: %s)"), CURRENCY_UNIT, FormatMoney(maxTxFee))); strUsage += HelpMessageOpt("-upgradewallet", _("Upgrade wallet to latest format") + " " + _("on startup")); - strUsage += HelpMessageOpt("-wallet=", _("Specify wallet file (within data directory)") + " " + strprintf(_("(default: %s)"), "wallet.dat")); + strUsage += HelpMessageOpt("-wallet=", _("Specify wallet file absolute path or a path relative to the data directory") + " " + strprintf(_("(default: %s)"), DEFAULT_WALLET_DAT)); strUsage += HelpMessageOpt("-walletbroadcast", _("Make the wallet broadcast transactions") + " " + strprintf(_("(default: %u)"), true)); strUsage += HelpMessageOpt("-walletnotify=", _("Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)")); strUsage += HelpMessageOpt("-whitelistaddress=", _("Enable the wallet filter for notary nodes and add one Raddress to the whitelist of the wallet filter. If -whitelistaddress= is used, then the wallet filter is automatically activated. Several Raddresses can be defined using several -whitelistaddress= (similar to -addnode). The wallet filter will filter the utxo to only ones coming from my own Raddress (derived from pubkey) and each Raddress defined using -whitelistaddress= this option is mostly for Notary Nodes).")); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 1347ef974..9d2528073 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -59,6 +59,7 @@ using namespace libzcash; /** * Settings */ +const char * DEFAULT_WALLET_DAT = "wallet.dat"; CFeeRate payTxFee(DEFAULT_TRANSACTION_FEE); CAmount maxTxFee = DEFAULT_TRANSACTION_MAXFEE; unsigned int nTxConfirmTarget = DEFAULT_TX_CONFIRM_TARGET; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index dd6100f97..475214919 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -100,6 +100,8 @@ static const unsigned int DEFAULT_TX_RETENTION_LASTTX = 200; //Amount of transactions to delete per run while syncing static const int MAX_DELETE_TX_SIZE = 50000; +extern const char * DEFAULT_WALLET_DAT; + class CBlockIndex; class CCoinControl; class COutput; From b3ff90ed6fbb92ae46bbbad81eb964e352802b96 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Fri, 4 Sep 2020 22:29:28 -0700 Subject: [PATCH 155/255] Add constant time AES routines --- src/crypto/ctaes/COPYING | 21 ++ src/crypto/ctaes/README.md | 41 +++ src/crypto/ctaes/bench.c | 170 ++++++++++++ src/crypto/ctaes/ctaes.c | 556 +++++++++++++++++++++++++++++++++++++ src/crypto/ctaes/ctaes.h | 41 +++ src/crypto/ctaes/test.c | 110 ++++++++ 6 files changed, 939 insertions(+) create mode 100644 src/crypto/ctaes/COPYING create mode 100644 src/crypto/ctaes/README.md create mode 100644 src/crypto/ctaes/bench.c create mode 100644 src/crypto/ctaes/ctaes.c create mode 100644 src/crypto/ctaes/ctaes.h create mode 100644 src/crypto/ctaes/test.c diff --git a/src/crypto/ctaes/COPYING b/src/crypto/ctaes/COPYING new file mode 100644 index 000000000..415b202a2 --- /dev/null +++ b/src/crypto/ctaes/COPYING @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Pieter Wuille + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/src/crypto/ctaes/README.md b/src/crypto/ctaes/README.md new file mode 100644 index 000000000..0e7fe1775 --- /dev/null +++ b/src/crypto/ctaes/README.md @@ -0,0 +1,41 @@ +ctaes +===== + +Simple C module for constant-time AES encryption and decryption. + +Features: +* Simple, pure C code without any dependencies. +* No tables or data-dependent branches whatsoever, but using bit sliced approach from https://eprint.iacr.org/2009/129.pdf. +* Very small object code: slightly over 4k of executable code when compiled with -Os. +* Slower than implementations based on precomputed tables or specialized instructions, but can do ~15 MB/s on modern CPUs. + +Performance +----------- + +Compiled with GCC 5.3.1 with -O3, on an Intel(R) Core(TM) i7-4800MQ CPU, numbers in CPU cycles: + +| Algorithm | Key schedule | Encryption per byte | Decryption per byte | +| --------- | ------------:| -------------------:| -------------------:| +| AES-128 | 2.8k | 154 | 161 | +| AES-192 | 3.1k | 169 | 181 | +| AES-256 | 4.0k | 191 | 203 | + +Build steps +----------- + +Object code: + + $ gcc -O3 ctaes.c -c -o ctaes.o + +Tests: + + $ gcc -O3 ctaes.c test.c -o test + +Benchmark: + + $ gcc -O3 ctaes.c bench.c -o bench + +Review +------ + +Results of a formal review of the code can be found in http://bitcoin.sipa.be/ctaes/review.zip diff --git a/src/crypto/ctaes/bench.c b/src/crypto/ctaes/bench.c new file mode 100644 index 000000000..a86df496c --- /dev/null +++ b/src/crypto/ctaes/bench.c @@ -0,0 +1,170 @@ +#include +#include +#include "sys/time.h" + +#include "ctaes.h" + +static double gettimedouble(void) { + struct timeval tv; + gettimeofday(&tv, NULL); + return tv.tv_usec * 0.000001 + tv.tv_sec; +} + +static void print_number(double x) { + double y = x; + int c = 0; + if (y < 0.0) { + y = -y; + } + while (y < 100.0) { + y *= 10.0; + c++; + } + printf("%.*f", c, x); +} + +static void run_benchmark(char *name, void (*benchmark)(void*), void (*setup)(void*), void (*teardown)(void*), void* data, int count, int iter) { + int i; + double min = HUGE_VAL; + double sum = 0.0; + double max = 0.0; + for (i = 0; i < count; i++) { + double begin, total; + if (setup != NULL) { + setup(data); + } + begin = gettimedouble(); + benchmark(data); + total = gettimedouble() - begin; + if (teardown != NULL) { + teardown(data); + } + if (total < min) { + min = total; + } + if (total > max) { + max = total; + } + sum += total; + } + printf("%s: min ", name); + print_number(min * 1000000000.0 / iter); + printf("ns / avg "); + print_number((sum / count) * 1000000000.0 / iter); + printf("ns / max "); + print_number(max * 1000000000.0 / iter); + printf("ns\n"); +} + +static void bench_AES128_init(void* data) { + AES128_ctx* ctx = (AES128_ctx*)data; + int i; + for (i = 0; i < 50000; i++) { + AES128_init(ctx, (unsigned char*)ctx); + } +} + +static void bench_AES128_encrypt_setup(void* data) { + AES128_ctx* ctx = (AES128_ctx*)data; + static const unsigned char key[16] = {0}; + AES128_init(ctx, key); +} + +static void bench_AES128_encrypt(void* data) { + const AES128_ctx* ctx = (const AES128_ctx*)data; + unsigned char scratch[16] = {0}; + int i; + for (i = 0; i < 4000000 / 16; i++) { + AES128_encrypt(ctx, 1, scratch, scratch); + } +} + +static void bench_AES128_decrypt(void* data) { + const AES128_ctx* ctx = (const AES128_ctx*)data; + unsigned char scratch[16] = {0}; + int i; + for (i = 0; i < 4000000 / 16; i++) { + AES128_decrypt(ctx, 1, scratch, scratch); + } +} + +static void bench_AES192_init(void* data) { + AES192_ctx* ctx = (AES192_ctx*)data; + int i; + for (i = 0; i < 50000; i++) { + AES192_init(ctx, (unsigned char*)ctx); + } +} + +static void bench_AES192_encrypt_setup(void* data) { + AES192_ctx* ctx = (AES192_ctx*)data; + static const unsigned char key[16] = {0}; + AES192_init(ctx, key); +} + +static void bench_AES192_encrypt(void* data) { + const AES192_ctx* ctx = (const AES192_ctx*)data; + unsigned char scratch[16] = {0}; + int i; + for (i = 0; i < 4000000 / 16; i++) { + AES192_encrypt(ctx, 1, scratch, scratch); + } +} + +static void bench_AES192_decrypt(void* data) { + const AES192_ctx* ctx = (const AES192_ctx*)data; + unsigned char scratch[16] = {0}; + int i; + for (i = 0; i < 4000000 / 16; i++) { + AES192_decrypt(ctx, 1, scratch, scratch); + } +} + +static void bench_AES256_init(void* data) { + AES256_ctx* ctx = (AES256_ctx*)data; + int i; + for (i = 0; i < 50000; i++) { + AES256_init(ctx, (unsigned char*)ctx); + } +} + + +static void bench_AES256_encrypt_setup(void* data) { + AES256_ctx* ctx = (AES256_ctx*)data; + static const unsigned char key[16] = {0}; + AES256_init(ctx, key); +} + +static void bench_AES256_encrypt(void* data) { + const AES256_ctx* ctx = (const AES256_ctx*)data; + unsigned char scratch[16] = {0}; + int i; + for (i = 0; i < 4000000 / 16; i++) { + AES256_encrypt(ctx, 1, scratch, scratch); + } +} + +static void bench_AES256_decrypt(void* data) { + const AES256_ctx* ctx = (const AES256_ctx*)data; + unsigned char scratch[16] = {0}; + int i; + for (i = 0; i < 4000000 / 16; i++) { + AES256_decrypt(ctx, 1, scratch, scratch); + } +} + +int main(void) { + AES128_ctx ctx128; + AES192_ctx ctx192; + AES256_ctx ctx256; + run_benchmark("aes128_init", bench_AES128_init, NULL, NULL, &ctx128, 20, 50000); + run_benchmark("aes128_encrypt_byte", bench_AES128_encrypt, bench_AES128_encrypt_setup, NULL, &ctx128, 20, 4000000); + run_benchmark("aes128_decrypt_byte", bench_AES128_decrypt, bench_AES128_encrypt_setup, NULL, &ctx128, 20, 4000000); + run_benchmark("aes192_init", bench_AES192_init, NULL, NULL, &ctx192, 20, 50000); + run_benchmark("aes192_encrypt_byte", bench_AES192_encrypt, bench_AES192_encrypt_setup, NULL, &ctx192, 20, 4000000); + run_benchmark("aes192_decrypt_byte", bench_AES192_decrypt, bench_AES192_encrypt_setup, NULL, &ctx192, 20, 4000000); + run_benchmark("aes256_init", bench_AES256_init, NULL, NULL, &ctx256, 20, 50000); + run_benchmark("aes256_encrypt_byte", bench_AES256_encrypt, bench_AES256_encrypt_setup, NULL, &ctx256, 20, 4000000); + run_benchmark("aes256_decrypt_byte", bench_AES256_decrypt, bench_AES256_encrypt_setup, NULL, &ctx256, 20, 4000000); + return 0; +} diff --git a/src/crypto/ctaes/ctaes.c b/src/crypto/ctaes/ctaes.c new file mode 100644 index 000000000..55962bf25 --- /dev/null +++ b/src/crypto/ctaes/ctaes.c @@ -0,0 +1,556 @@ + /********************************************************************* + * Copyright (c) 2016 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +/* Constant time, unoptimized, concise, plain C, AES implementation + * Based On: + * Emilia Kasper and Peter Schwabe, Faster and Timing-Attack Resistant AES-GCM + * http://www.iacr.org/archive/ches2009/57470001/57470001.pdf + * But using 8 16-bit integers representing a single AES state rather than 8 128-bit + * integers representing 8 AES states. + */ + +#include "ctaes.h" + +/* Slice variable slice_i contains the i'th bit of the 16 state variables in this order: + * 0 1 2 3 + * 4 5 6 7 + * 8 9 10 11 + * 12 13 14 15 + */ + +/** Convert a byte to sliced form, storing it corresponding to given row and column in s */ +static void LoadByte(AES_state* s, unsigned char byte, int r, int c) { + int i; + for (i = 0; i < 8; i++) { + s->slice[i] |= (byte & 1) << (r * 4 + c); + byte >>= 1; + } +} + +/** Load 16 bytes of data into 8 sliced integers */ +static void LoadBytes(AES_state *s, const unsigned char* data16) { + int c; + for (c = 0; c < 4; c++) { + int r; + for (r = 0; r < 4; r++) { + LoadByte(s, *(data16++), r, c); + } + } +} + +/** Convert 8 sliced integers into 16 bytes of data */ +static void SaveBytes(unsigned char* data16, const AES_state *s) { + int c; + for (c = 0; c < 4; c++) { + int r; + for (r = 0; r < 4; r++) { + int b; + uint8_t v = 0; + for (b = 0; b < 8; b++) { + v |= ((s->slice[b] >> (r * 4 + c)) & 1) << b; + } + *(data16++) = v; + } + } +} + +/* S-box implementation based on the gate logic from: + * Joan Boyar and Rene Peralta, A depth-16 circuit for the AES S-box. + * https://eprint.iacr.org/2011/332.pdf +*/ +static void SubBytes(AES_state *s, int inv) { + /* Load the bit slices */ + uint16_t U0 = s->slice[7], U1 = s->slice[6], U2 = s->slice[5], U3 = s->slice[4]; + uint16_t U4 = s->slice[3], U5 = s->slice[2], U6 = s->slice[1], U7 = s->slice[0]; + + uint16_t T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16; + uint16_t T17, T18, T19, T20, T21, T22, T23, T24, T25, T26, T27, D; + uint16_t M1, M6, M11, M13, M15, M20, M21, M22, M23, M25, M37, M38, M39, M40; + uint16_t M41, M42, M43, M44, M45, M46, M47, M48, M49, M50, M51, M52, M53, M54; + uint16_t M55, M56, M57, M58, M59, M60, M61, M62, M63; + + if (inv) { + uint16_t R5, R13, R17, R18, R19; + /* Undo linear postprocessing */ + T23 = U0 ^ U3; + T22 = ~(U1 ^ U3); + T2 = ~(U0 ^ U1); + T1 = U3 ^ U4; + T24 = ~(U4 ^ U7); + R5 = U6 ^ U7; + T8 = ~(U1 ^ T23); + T19 = T22 ^ R5; + T9 = ~(U7 ^ T1); + T10 = T2 ^ T24; + T13 = T2 ^ R5; + T3 = T1 ^ R5; + T25 = ~(U2 ^ T1); + R13 = U1 ^ U6; + T17 = ~(U2 ^ T19); + T20 = T24 ^ R13; + T4 = U4 ^ T8; + R17 = ~(U2 ^ U5); + R18 = ~(U5 ^ U6); + R19 = ~(U2 ^ U4); + D = U0 ^ R17; + T6 = T22 ^ R17; + T16 = R13 ^ R19; + T27 = T1 ^ R18; + T15 = T10 ^ T27; + T14 = T10 ^ R18; + T26 = T3 ^ T16; + } else { + /* Linear preprocessing. */ + T1 = U0 ^ U3; + T2 = U0 ^ U5; + T3 = U0 ^ U6; + T4 = U3 ^ U5; + T5 = U4 ^ U6; + T6 = T1 ^ T5; + T7 = U1 ^ U2; + T8 = U7 ^ T6; + T9 = U7 ^ T7; + T10 = T6 ^ T7; + T11 = U1 ^ U5; + T12 = U2 ^ U5; + T13 = T3 ^ T4; + T14 = T6 ^ T11; + T15 = T5 ^ T11; + T16 = T5 ^ T12; + T17 = T9 ^ T16; + T18 = U3 ^ U7; + T19 = T7 ^ T18; + T20 = T1 ^ T19; + T21 = U6 ^ U7; + T22 = T7 ^ T21; + T23 = T2 ^ T22; + T24 = T2 ^ T10; + T25 = T20 ^ T17; + T26 = T3 ^ T16; + T27 = T1 ^ T12; + D = U7; + } + + /* Non-linear transformation (shared between the forward and backward case) */ + M1 = T13 & T6; + M6 = T3 & T16; + M11 = T1 & T15; + M13 = (T4 & T27) ^ M11; + M15 = (T2 & T10) ^ M11; + M20 = T14 ^ M1 ^ (T23 & T8) ^ M13; + M21 = (T19 & D) ^ M1 ^ T24 ^ M15; + M22 = T26 ^ M6 ^ (T22 & T9) ^ M13; + M23 = (T20 & T17) ^ M6 ^ M15 ^ T25; + M25 = M22 & M20; + M37 = M21 ^ ((M20 ^ M21) & (M23 ^ M25)); + M38 = M20 ^ M25 ^ (M21 | (M20 & M23)); + M39 = M23 ^ ((M22 ^ M23) & (M21 ^ M25)); + M40 = M22 ^ M25 ^ (M23 | (M21 & M22)); + M41 = M38 ^ M40; + M42 = M37 ^ M39; + M43 = M37 ^ M38; + M44 = M39 ^ M40; + M45 = M42 ^ M41; + M46 = M44 & T6; + M47 = M40 & T8; + M48 = M39 & D; + M49 = M43 & T16; + M50 = M38 & T9; + M51 = M37 & T17; + M52 = M42 & T15; + M53 = M45 & T27; + M54 = M41 & T10; + M55 = M44 & T13; + M56 = M40 & T23; + M57 = M39 & T19; + M58 = M43 & T3; + M59 = M38 & T22; + M60 = M37 & T20; + M61 = M42 & T1; + M62 = M45 & T4; + M63 = M41 & T2; + + if (inv){ + /* Undo linear preprocessing */ + uint16_t P0 = M52 ^ M61; + uint16_t P1 = M58 ^ M59; + uint16_t P2 = M54 ^ M62; + uint16_t P3 = M47 ^ M50; + uint16_t P4 = M48 ^ M56; + uint16_t P5 = M46 ^ M51; + uint16_t P6 = M49 ^ M60; + uint16_t P7 = P0 ^ P1; + uint16_t P8 = M50 ^ M53; + uint16_t P9 = M55 ^ M63; + uint16_t P10 = M57 ^ P4; + uint16_t P11 = P0 ^ P3; + uint16_t P12 = M46 ^ M48; + uint16_t P13 = M49 ^ M51; + uint16_t P14 = M49 ^ M62; + uint16_t P15 = M54 ^ M59; + uint16_t P16 = M57 ^ M61; + uint16_t P17 = M58 ^ P2; + uint16_t P18 = M63 ^ P5; + uint16_t P19 = P2 ^ P3; + uint16_t P20 = P4 ^ P6; + uint16_t P22 = P2 ^ P7; + uint16_t P23 = P7 ^ P8; + uint16_t P24 = P5 ^ P7; + uint16_t P25 = P6 ^ P10; + uint16_t P26 = P9 ^ P11; + uint16_t P27 = P10 ^ P18; + uint16_t P28 = P11 ^ P25; + uint16_t P29 = P15 ^ P20; + s->slice[7] = P13 ^ P22; + s->slice[6] = P26 ^ P29; + s->slice[5] = P17 ^ P28; + s->slice[4] = P12 ^ P22; + s->slice[3] = P23 ^ P27; + s->slice[2] = P19 ^ P24; + s->slice[1] = P14 ^ P23; + s->slice[0] = P9 ^ P16; + } else { + /* Linear postprocessing */ + uint16_t L0 = M61 ^ M62; + uint16_t L1 = M50 ^ M56; + uint16_t L2 = M46 ^ M48; + uint16_t L3 = M47 ^ M55; + uint16_t L4 = M54 ^ M58; + uint16_t L5 = M49 ^ M61; + uint16_t L6 = M62 ^ L5; + uint16_t L7 = M46 ^ L3; + uint16_t L8 = M51 ^ M59; + uint16_t L9 = M52 ^ M53; + uint16_t L10 = M53 ^ L4; + uint16_t L11 = M60 ^ L2; + uint16_t L12 = M48 ^ M51; + uint16_t L13 = M50 ^ L0; + uint16_t L14 = M52 ^ M61; + uint16_t L15 = M55 ^ L1; + uint16_t L16 = M56 ^ L0; + uint16_t L17 = M57 ^ L1; + uint16_t L18 = M58 ^ L8; + uint16_t L19 = M63 ^ L4; + uint16_t L20 = L0 ^ L1; + uint16_t L21 = L1 ^ L7; + uint16_t L22 = L3 ^ L12; + uint16_t L23 = L18 ^ L2; + uint16_t L24 = L15 ^ L9; + uint16_t L25 = L6 ^ L10; + uint16_t L26 = L7 ^ L9; + uint16_t L27 = L8 ^ L10; + uint16_t L28 = L11 ^ L14; + uint16_t L29 = L11 ^ L17; + s->slice[7] = L6 ^ L24; + s->slice[6] = ~(L16 ^ L26); + s->slice[5] = ~(L19 ^ L28); + s->slice[4] = L6 ^ L21; + s->slice[3] = L20 ^ L22; + s->slice[2] = L25 ^ L29; + s->slice[1] = ~(L13 ^ L27); + s->slice[0] = ~(L6 ^ L23); + } +} + +#define BIT_RANGE(from,to) (((1 << ((to) - (from))) - 1) << (from)) + +#define BIT_RANGE_LEFT(x,from,to,shift) (((x) & BIT_RANGE((from), (to))) << (shift)) +#define BIT_RANGE_RIGHT(x,from,to,shift) (((x) & BIT_RANGE((from), (to))) >> (shift)) + +static void ShiftRows(AES_state* s) { + int i; + for (i = 0; i < 8; i++) { + uint16_t v = s->slice[i]; + s->slice[i] = + (v & BIT_RANGE(0, 4)) | + BIT_RANGE_LEFT(v, 4, 5, 3) | BIT_RANGE_RIGHT(v, 5, 8, 1) | + BIT_RANGE_LEFT(v, 8, 10, 2) | BIT_RANGE_RIGHT(v, 10, 12, 2) | + BIT_RANGE_LEFT(v, 12, 15, 1) | BIT_RANGE_RIGHT(v, 15, 16, 3); + } +} + +static void InvShiftRows(AES_state* s) { + int i; + for (i = 0; i < 8; i++) { + uint16_t v = s->slice[i]; + s->slice[i] = + (v & BIT_RANGE(0, 4)) | + BIT_RANGE_LEFT(v, 4, 7, 1) | BIT_RANGE_RIGHT(v, 7, 8, 3) | + BIT_RANGE_LEFT(v, 8, 10, 2) | BIT_RANGE_RIGHT(v, 10, 12, 2) | + BIT_RANGE_LEFT(v, 12, 13, 3) | BIT_RANGE_RIGHT(v, 13, 16, 1); + } +} + +#define ROT(x,b) (((x) >> ((b) * 4)) | ((x) << ((4-(b)) * 4))) + +static void MixColumns(AES_state* s, int inv) { + /* The MixColumns transform treats the bytes of the columns of the state as + * coefficients of a 3rd degree polynomial over GF(2^8) and multiplies them + * by the fixed polynomial a(x) = {03}x^3 + {01}x^2 + {01}x + {02}, modulo + * x^4 + {01}. + * + * In the inverse transform, we multiply by the inverse of a(x), + * a^-1(x) = {0b}x^3 + {0d}x^2 + {09}x + {0e}. This is equal to + * a(x) * ({04}x^2 + {05}), so we can reuse the forward transform's code + * (found in OpenSSL's bsaes-x86_64.pl, attributed to Jussi Kivilinna) + * + * In the bitsliced representation, a multiplication of every column by x + * mod x^4 + 1 is simply a right rotation. + */ + + /* Shared for both directions is a multiplication by a(x), which can be + * rewritten as (x^3 + x^2 + x) + {02}*(x^3 + {01}). + * + * First compute s into the s? variables, (x^3 + {01}) * s into the s?_01 + * variables and (x^3 + x^2 + x)*s into the s?_123 variables. + */ + uint16_t s0 = s->slice[0], s1 = s->slice[1], s2 = s->slice[2], s3 = s->slice[3]; + uint16_t s4 = s->slice[4], s5 = s->slice[5], s6 = s->slice[6], s7 = s->slice[7]; + uint16_t s0_01 = s0 ^ ROT(s0, 1), s0_123 = ROT(s0_01, 1) ^ ROT(s0, 3); + uint16_t s1_01 = s1 ^ ROT(s1, 1), s1_123 = ROT(s1_01, 1) ^ ROT(s1, 3); + uint16_t s2_01 = s2 ^ ROT(s2, 1), s2_123 = ROT(s2_01, 1) ^ ROT(s2, 3); + uint16_t s3_01 = s3 ^ ROT(s3, 1), s3_123 = ROT(s3_01, 1) ^ ROT(s3, 3); + uint16_t s4_01 = s4 ^ ROT(s4, 1), s4_123 = ROT(s4_01, 1) ^ ROT(s4, 3); + uint16_t s5_01 = s5 ^ ROT(s5, 1), s5_123 = ROT(s5_01, 1) ^ ROT(s5, 3); + uint16_t s6_01 = s6 ^ ROT(s6, 1), s6_123 = ROT(s6_01, 1) ^ ROT(s6, 3); + uint16_t s7_01 = s7 ^ ROT(s7, 1), s7_123 = ROT(s7_01, 1) ^ ROT(s7, 3); + /* Now compute s = s?_123 + {02} * s?_01. */ + s->slice[0] = s7_01 ^ s0_123; + s->slice[1] = s7_01 ^ s0_01 ^ s1_123; + s->slice[2] = s1_01 ^ s2_123; + s->slice[3] = s7_01 ^ s2_01 ^ s3_123; + s->slice[4] = s7_01 ^ s3_01 ^ s4_123; + s->slice[5] = s4_01 ^ s5_123; + s->slice[6] = s5_01 ^ s6_123; + s->slice[7] = s6_01 ^ s7_123; + if (inv) { + /* In the reverse direction, we further need to multiply by + * {04}x^2 + {05}, which can be written as {04} * (x^2 + {01}) + {01}. + * + * First compute (x^2 + {01}) * s into the t?_02 variables: */ + uint16_t t0_02 = s->slice[0] ^ ROT(s->slice[0], 2); + uint16_t t1_02 = s->slice[1] ^ ROT(s->slice[1], 2); + uint16_t t2_02 = s->slice[2] ^ ROT(s->slice[2], 2); + uint16_t t3_02 = s->slice[3] ^ ROT(s->slice[3], 2); + uint16_t t4_02 = s->slice[4] ^ ROT(s->slice[4], 2); + uint16_t t5_02 = s->slice[5] ^ ROT(s->slice[5], 2); + uint16_t t6_02 = s->slice[6] ^ ROT(s->slice[6], 2); + uint16_t t7_02 = s->slice[7] ^ ROT(s->slice[7], 2); + /* And then update s += {04} * t?_02 */ + s->slice[0] ^= t6_02; + s->slice[1] ^= t6_02 ^ t7_02; + s->slice[2] ^= t0_02 ^ t7_02; + s->slice[3] ^= t1_02 ^ t6_02; + s->slice[4] ^= t2_02 ^ t6_02 ^ t7_02; + s->slice[5] ^= t3_02 ^ t7_02; + s->slice[6] ^= t4_02; + s->slice[7] ^= t5_02; + } +} + +static void AddRoundKey(AES_state* s, const AES_state* round) { + int b; + for (b = 0; b < 8; b++) { + s->slice[b] ^= round->slice[b]; + } +} + +/** column_0(s) = column_c(a) */ +static void GetOneColumn(AES_state* s, const AES_state* a, int c) { + int b; + for (b = 0; b < 8; b++) { + s->slice[b] = (a->slice[b] >> c) & 0x1111; + } +} + +/** column_c1(r) |= (column_0(s) ^= column_c2(a)) */ +static void KeySetupColumnMix(AES_state* s, AES_state* r, const AES_state* a, int c1, int c2) { + int b; + for (b = 0; b < 8; b++) { + r->slice[b] |= ((s->slice[b] ^= ((a->slice[b] >> c2) & 0x1111)) & 0x1111) << c1; + } +} + +/** Rotate the rows in s one position upwards, and xor in r */ +static void KeySetupTransform(AES_state* s, const AES_state* r) { + int b; + for (b = 0; b < 8; b++) { + s->slice[b] = ((s->slice[b] >> 4) | (s->slice[b] << 12)) ^ r->slice[b]; + } +} + +/* Multiply the cells in s by x, as polynomials over GF(2) mod x^8 + x^4 + x^3 + x + 1 */ +static void MultX(AES_state* s) { + uint16_t top = s->slice[7]; + s->slice[7] = s->slice[6]; + s->slice[6] = s->slice[5]; + s->slice[5] = s->slice[4]; + s->slice[4] = s->slice[3] ^ top; + s->slice[3] = s->slice[2] ^ top; + s->slice[2] = s->slice[1]; + s->slice[1] = s->slice[0] ^ top; + s->slice[0] = top; +} + +/** Expand the cipher key into the key schedule. + * + * state must be a pointer to an array of size nrounds + 1. + * key must be a pointer to 4 * nkeywords bytes. + * + * AES128 uses nkeywords = 4, nrounds = 10 + * AES192 uses nkeywords = 6, nrounds = 12 + * AES256 uses nkeywords = 8, nrounds = 14 + */ +static void AES_setup(AES_state* rounds, const uint8_t* key, int nkeywords, int nrounds) +{ + int i; + + /* The one-byte round constant */ + AES_state rcon = {{1,0,0,0,0,0,0,0}}; + /* The number of the word being generated, modulo nkeywords */ + int pos = 0; + /* The column representing the word currently being processed */ + AES_state column; + + for (i = 0; i < nrounds + 1; i++) { + int b; + for (b = 0; b < 8; b++) { + rounds[i].slice[b] = 0; + } + } + + /* The first nkeywords round columns are just taken from the key directly. */ + for (i = 0; i < nkeywords; i++) { + int r; + for (r = 0; r < 4; r++) { + LoadByte(&rounds[i >> 2], *(key++), r, i & 3); + } + } + + GetOneColumn(&column, &rounds[(nkeywords - 1) >> 2], (nkeywords - 1) & 3); + + for (i = nkeywords; i < 4 * (nrounds + 1); i++) { + /* Transform column */ + if (pos == 0) { + SubBytes(&column, 0); + KeySetupTransform(&column, &rcon); + MultX(&rcon); + } else if (nkeywords > 6 && pos == 4) { + SubBytes(&column, 0); + } + if (++pos == nkeywords) pos = 0; + KeySetupColumnMix(&column, &rounds[i >> 2], &rounds[(i - nkeywords) >> 2], i & 3, (i - nkeywords) & 3); + } +} + +static void AES_encrypt(const AES_state* rounds, int nrounds, unsigned char* cipher16, const unsigned char* plain16) { + AES_state s = {{0}}; + int round; + + LoadBytes(&s, plain16); + AddRoundKey(&s, rounds++); + + for (round = 1; round < nrounds; round++) { + SubBytes(&s, 0); + ShiftRows(&s); + MixColumns(&s, 0); + AddRoundKey(&s, rounds++); + } + + SubBytes(&s, 0); + ShiftRows(&s); + AddRoundKey(&s, rounds); + + SaveBytes(cipher16, &s); +} + +static void AES_decrypt(const AES_state* rounds, int nrounds, unsigned char* plain16, const unsigned char* cipher16) { + /* Most AES decryption implementations use the alternate scheme + * (the Equivalent Inverse Cipher), which allows for more code reuse between + * the encryption and decryption code, but requires separate setup for both. + */ + AES_state s = {{0}}; + int round; + + rounds += nrounds; + + LoadBytes(&s, cipher16); + AddRoundKey(&s, rounds--); + + for (round = 1; round < nrounds; round++) { + InvShiftRows(&s); + SubBytes(&s, 1); + AddRoundKey(&s, rounds--); + MixColumns(&s, 1); + } + + InvShiftRows(&s); + SubBytes(&s, 1); + AddRoundKey(&s, rounds); + + SaveBytes(plain16, &s); +} + +void AES128_init(AES128_ctx* ctx, const unsigned char* key16) { + AES_setup(ctx->rk, key16, 4, 10); +} + +void AES128_encrypt(const AES128_ctx* ctx, size_t blocks, unsigned char* cipher16, const unsigned char* plain16) { + while (blocks--) { + AES_encrypt(ctx->rk, 10, cipher16, plain16); + cipher16 += 16; + plain16 += 16; + } +} + +void AES128_decrypt(const AES128_ctx* ctx, size_t blocks, unsigned char* plain16, const unsigned char* cipher16) { + while (blocks--) { + AES_decrypt(ctx->rk, 10, plain16, cipher16); + cipher16 += 16; + plain16 += 16; + } +} + +void AES192_init(AES192_ctx* ctx, const unsigned char* key24) { + AES_setup(ctx->rk, key24, 6, 12); +} + +void AES192_encrypt(const AES192_ctx* ctx, size_t blocks, unsigned char* cipher16, const unsigned char* plain16) { + while (blocks--) { + AES_encrypt(ctx->rk, 12, cipher16, plain16); + cipher16 += 16; + plain16 += 16; + } + +} + +void AES192_decrypt(const AES192_ctx* ctx, size_t blocks, unsigned char* plain16, const unsigned char* cipher16) { + while (blocks--) { + AES_decrypt(ctx->rk, 12, plain16, cipher16); + cipher16 += 16; + plain16 += 16; + } +} + +void AES256_init(AES256_ctx* ctx, const unsigned char* key32) { + AES_setup(ctx->rk, key32, 8, 14); +} + +void AES256_encrypt(const AES256_ctx* ctx, size_t blocks, unsigned char* cipher16, const unsigned char* plain16) { + while (blocks--) { + AES_encrypt(ctx->rk, 14, cipher16, plain16); + cipher16 += 16; + plain16 += 16; + } +} + +void AES256_decrypt(const AES256_ctx* ctx, size_t blocks, unsigned char* plain16, const unsigned char* cipher16) { + while (blocks--) { + AES_decrypt(ctx->rk, 14, plain16, cipher16); + cipher16 += 16; + plain16 += 16; + } +} diff --git a/src/crypto/ctaes/ctaes.h b/src/crypto/ctaes/ctaes.h new file mode 100644 index 000000000..2f0af0421 --- /dev/null +++ b/src/crypto/ctaes/ctaes.h @@ -0,0 +1,41 @@ + /********************************************************************* + * Copyright (c) 2016 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#ifndef _CTAES_H_ +#define _CTAES_H_ 1 + +#include +#include + +typedef struct { + uint16_t slice[8]; +} AES_state; + +typedef struct { + AES_state rk[11]; +} AES128_ctx; + +typedef struct { + AES_state rk[13]; +} AES192_ctx; + +typedef struct { + AES_state rk[15]; +} AES256_ctx; + +void AES128_init(AES128_ctx* ctx, const unsigned char* key16); +void AES128_encrypt(const AES128_ctx* ctx, size_t blocks, unsigned char* cipher16, const unsigned char* plain16); +void AES128_decrypt(const AES128_ctx* ctx, size_t blocks, unsigned char* plain16, const unsigned char* cipher16); + +void AES192_init(AES192_ctx* ctx, const unsigned char* key24); +void AES192_encrypt(const AES192_ctx* ctx, size_t blocks, unsigned char* cipher16, const unsigned char* plain16); +void AES192_decrypt(const AES192_ctx* ctx, size_t blocks, unsigned char* plain16, const unsigned char* cipher16); + +void AES256_init(AES256_ctx* ctx, const unsigned char* key32); +void AES256_encrypt(const AES256_ctx* ctx, size_t blocks, unsigned char* cipher16, const unsigned char* plain16); +void AES256_decrypt(const AES256_ctx* ctx, size_t blocks, unsigned char* plain16, const unsigned char* cipher16); + +#endif diff --git a/src/crypto/ctaes/test.c b/src/crypto/ctaes/test.c new file mode 100644 index 000000000..21439a16f --- /dev/null +++ b/src/crypto/ctaes/test.c @@ -0,0 +1,110 @@ + /********************************************************************* + * Copyright (c) 2016 Pieter Wuille * + * Distributed under the MIT software license, see the accompanying * + * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + **********************************************************************/ + +#include "ctaes.h" + +#include +#include +#include + +typedef struct { + int keysize; + const char* key; + const char* plain; + const char* cipher; +} ctaes_test; + +static const ctaes_test ctaes_tests[] = { + /* AES test vectors from FIPS 197. */ + {128, "000102030405060708090a0b0c0d0e0f", "00112233445566778899aabbccddeeff", "69c4e0d86a7b0430d8cdb78070b4c55a"}, + {192, "000102030405060708090a0b0c0d0e0f1011121314151617", "00112233445566778899aabbccddeeff", "dda97ca4864cdfe06eaf70a0ec0d7191"}, + {256, "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f", "00112233445566778899aabbccddeeff", "8ea2b7ca516745bfeafc49904b496089"}, + + /* AES-ECB test vectors from NIST sp800-38a. */ + {128, "2b7e151628aed2a6abf7158809cf4f3c", "6bc1bee22e409f96e93d7e117393172a", "3ad77bb40d7a3660a89ecaf32466ef97"}, + {128, "2b7e151628aed2a6abf7158809cf4f3c", "ae2d8a571e03ac9c9eb76fac45af8e51", "f5d3d58503b9699de785895a96fdbaaf"}, + {128, "2b7e151628aed2a6abf7158809cf4f3c", "30c81c46a35ce411e5fbc1191a0a52ef", "43b1cd7f598ece23881b00e3ed030688"}, + {128, "2b7e151628aed2a6abf7158809cf4f3c", "f69f2445df4f9b17ad2b417be66c3710", "7b0c785e27e8ad3f8223207104725dd4"}, + {192, "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b", "6bc1bee22e409f96e93d7e117393172a", "bd334f1d6e45f25ff712a214571fa5cc"}, + {192, "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b", "ae2d8a571e03ac9c9eb76fac45af8e51", "974104846d0ad3ad7734ecb3ecee4eef"}, + {192, "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b", "30c81c46a35ce411e5fbc1191a0a52ef", "ef7afd2270e2e60adce0ba2face6444e"}, + {192, "8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b", "f69f2445df4f9b17ad2b417be66c3710", "9a4b41ba738d6c72fb16691603c18e0e"}, + {256, "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4", "6bc1bee22e409f96e93d7e117393172a", "f3eed1bdb5d2a03c064b5a7e3db181f8"}, + {256, "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4", "ae2d8a571e03ac9c9eb76fac45af8e51", "591ccb10d410ed26dc5ba74a31362870"}, + {256, "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4", "30c81c46a35ce411e5fbc1191a0a52ef", "b6ed21b99ca6f4f9f153e7b1beafed1d"}, + {256, "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4", "f69f2445df4f9b17ad2b417be66c3710", "23304b7a39f9f3ff067d8d8f9e24ecc7"} +}; + +static void from_hex(unsigned char* data, int len, const char* hex) { + int p; + for (p = 0; p < len; p++) { + int v = 0; + int n; + for (n = 0; n < 2; n++) { + assert((*hex >= '0' && *hex <= '9') || (*hex >= 'a' && *hex <= 'f')); + if (*hex >= '0' && *hex <= '9') { + v |= (*hex - '0') << (4 * (1 - n)); + } else { + v |= (*hex - 'a' + 10) << (4 * (1 - n)); + } + hex++; + } + *(data++) = v; + } + assert(*hex == 0); +} + +int main(void) { + int i; + int fail = 0; + for (i = 0; i < sizeof(ctaes_tests) / sizeof(ctaes_tests[0]); i++) { + unsigned char key[32], plain[16], cipher[16], ciphered[16], deciphered[16]; + const ctaes_test* test = &ctaes_tests[i]; + assert(test->keysize == 128 || test->keysize == 192 || test->keysize == 256); + from_hex(plain, 16, test->plain); + from_hex(cipher, 16, test->cipher); + switch (test->keysize) { + case 128: { + AES128_ctx ctx; + from_hex(key, 16, test->key); + AES128_init(&ctx, key); + AES128_encrypt(&ctx, 1, ciphered, plain); + AES128_decrypt(&ctx, 1, deciphered, cipher); + break; + } + case 192: { + AES192_ctx ctx; + from_hex(key, 24, test->key); + AES192_init(&ctx, key); + AES192_encrypt(&ctx, 1, ciphered, plain); + AES192_decrypt(&ctx, 1, deciphered, cipher); + break; + } + case 256: { + AES256_ctx ctx; + from_hex(key, 32, test->key); + AES256_init(&ctx, key); + AES256_encrypt(&ctx, 1, ciphered, plain); + AES256_decrypt(&ctx, 1, deciphered, cipher); + break; + } + } + if (memcmp(cipher, ciphered, 16)) { + fprintf(stderr, "E(key=\"%s\", plain=\"%s\") != \"%s\"\n", test->key, test->plain, test->cipher); + fail++; + } + if (memcmp(plain, deciphered, 16)) { + fprintf(stderr, "D(key=\"%s\", cipher=\"%s\") != \"%s\"\n", test->key, test->cipher, test->plain); + fail++; + } + } + if (fail == 0) { + fprintf(stderr, "All tests successful\n"); + } else { + fprintf(stderr, "%i tests failed\n", fail); + } + return (fail != 0); +} From 820a48bb73610f9ae0ad195491fb24deab7048c8 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Fri, 4 Sep 2020 22:50:23 -0700 Subject: [PATCH 156/255] Add trezor bip39 code --- src/crypto/bip39/README.md | 3 + src/crypto/bip39/bip39.c | 281 +++++++ src/crypto/bip39/bip39.h | 52 ++ src/crypto/bip39/bip39_english.h | 367 +++++++++ src/crypto/bip39/hmac.c | 176 ++++ src/crypto/bip39/hmac.h | 60 ++ src/crypto/bip39/hmac_drbg.c | 130 +++ src/crypto/bip39/hmac_drbg.h | 43 + src/crypto/bip39/memzero.h | 8 + src/crypto/bip39/options.h | 99 +++ src/crypto/bip39/pbkdf2.c | 179 +++++ src/crypto/bip39/pbkdf2.h | 66 ++ src/crypto/bip39/rand.c | 81 ++ src/crypto/bip39/rand.h | 37 + src/crypto/bip39/sha2.c | 1283 ++++++++++++++++++++++++++++++ src/crypto/bip39/sha2.h | 116 +++ src/crypto/bip39/sha3.c | 397 +++++++++ src/crypto/bip39/sha3.h | 89 +++ 18 files changed, 3467 insertions(+) create mode 100644 src/crypto/bip39/README.md create mode 100644 src/crypto/bip39/bip39.c create mode 100644 src/crypto/bip39/bip39.h create mode 100644 src/crypto/bip39/bip39_english.h create mode 100644 src/crypto/bip39/hmac.c create mode 100644 src/crypto/bip39/hmac.h create mode 100644 src/crypto/bip39/hmac_drbg.c create mode 100644 src/crypto/bip39/hmac_drbg.h create mode 100644 src/crypto/bip39/memzero.h create mode 100644 src/crypto/bip39/options.h create mode 100644 src/crypto/bip39/pbkdf2.c create mode 100644 src/crypto/bip39/pbkdf2.h create mode 100644 src/crypto/bip39/rand.c create mode 100644 src/crypto/bip39/rand.h create mode 100644 src/crypto/bip39/sha2.c create mode 100644 src/crypto/bip39/sha2.h create mode 100644 src/crypto/bip39/sha3.c create mode 100644 src/crypto/bip39/sha3.h diff --git a/src/crypto/bip39/README.md b/src/crypto/bip39/README.md new file mode 100644 index 000000000..b8e03fc93 --- /dev/null +++ b/src/crypto/bip39/README.md @@ -0,0 +1,3 @@ +# trezor-firmware bip39 + +Imported from https://github.com/trezor/trezor-firmware/commit/047fcffde1f8530d3aee279b731e5e5f5901590a diff --git a/src/crypto/bip39/bip39.c b/src/crypto/bip39/bip39.c new file mode 100644 index 000000000..33455f6c5 --- /dev/null +++ b/src/crypto/bip39/bip39.c @@ -0,0 +1,281 @@ +/** + * Copyright (c) 2013-2014 Tomas Dzetkulic + * Copyright (c) 2013-2014 Pavol Rusnak + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include + +#include "bip39.h" +#include "bip39_english.h" +#include "hmac.h" +#include "memzero.h" +#include "options.h" +#include "pbkdf2.h" +#include "rand.h" +#include "sha2.h" + +#if USE_BIP39_CACHE + +static int bip39_cache_index = 0; + +static CONFIDENTIAL struct { + bool set; + char mnemonic[256]; + char passphrase[64]; + uint8_t seed[512 / 8]; +} bip39_cache[BIP39_CACHE_SIZE]; + +#endif + +const char *mnemonic_generate(int strength) { + if (strength % 32 || strength < 128 || strength > 256) { + return 0; + } + uint8_t data[32] = {0}; + random_buffer(data, 32); + const char *r = mnemonic_from_data(data, strength / 8); + memzero(data, sizeof(data)); + return r; +} + +static CONFIDENTIAL char mnemo[24 * 10]; + +const char *mnemonic_from_data(const uint8_t *data, int len) { + if (len % 4 || len < 16 || len > 32) { + return 0; + } + + uint8_t bits[32 + 1] = {0}; + + sha256_Raw(data, len, bits); + // checksum + bits[len] = bits[0]; + // data + memcpy(bits, data, len); + + int mlen = len * 3 / 4; + + int i = 0, j = 0, idx = 0; + char *p = mnemo; + for (i = 0; i < mlen; i++) { + idx = 0; + for (j = 0; j < 11; j++) { + idx <<= 1; + idx += (bits[(i * 11 + j) / 8] & (1 << (7 - ((i * 11 + j) % 8)))) > 0; + } + strcpy(p, wordlist[idx]); + p += strlen(wordlist[idx]); + *p = (i < mlen - 1) ? ' ' : 0; + p++; + } + memzero(bits, sizeof(bits)); + + return mnemo; +} + +void mnemonic_clear(void) { memzero(mnemo, sizeof(mnemo)); } + +int mnemonic_to_entropy(const char *mnemonic, uint8_t *entropy) { + if (!mnemonic) { + return 0; + } + + uint32_t i = 0, n = 0; + + while (mnemonic[i]) { + if (mnemonic[i] == ' ') { + n++; + } + i++; + } + n++; + + // check number of words + if (n != 12 && n != 18 && n != 24) { + return 0; + } + + char current_word[10] = {0}; + uint32_t j = 0, k = 0, ki = 0, bi = 0; + uint8_t bits[32 + 1] = {0}; + + memzero(bits, sizeof(bits)); + i = 0; + while (mnemonic[i]) { + j = 0; + while (mnemonic[i] != ' ' && mnemonic[i] != 0) { + if (j >= sizeof(current_word) - 1) { + return 0; + } + current_word[j] = mnemonic[i]; + i++; + j++; + } + current_word[j] = 0; + if (mnemonic[i] != 0) { + i++; + } + k = 0; + for (;;) { + if (!wordlist[k]) { // word not found + return 0; + } + if (strcmp(current_word, wordlist[k]) == 0) { // word found on index k + for (ki = 0; ki < 11; ki++) { + if (k & (1 << (10 - ki))) { + bits[bi / 8] |= 1 << (7 - (bi % 8)); + } + bi++; + } + break; + } + k++; + } + } + if (bi != n * 11) { + return 0; + } + memcpy(entropy, bits, sizeof(bits)); + return n * 11; +} + +int mnemonic_check(const char *mnemonic) { + uint8_t bits[32 + 1] = {0}; + int seed_len = mnemonic_to_entropy(mnemonic, bits); + if (seed_len != (12 * 11) && seed_len != (18 * 11) && seed_len != (24 * 11)) { + return 0; + } + int words = seed_len / 11; + + uint8_t checksum = bits[words * 4 / 3]; + sha256_Raw(bits, words * 4 / 3, bits); + if (words == 12) { + return (bits[0] & 0xF0) == (checksum & 0xF0); // compare first 4 bits + } else if (words == 18) { + return (bits[0] & 0xFC) == (checksum & 0xFC); // compare first 6 bits + } else if (words == 24) { + return bits[0] == checksum; // compare 8 bits + } + return 0; +} + +// passphrase must be at most 256 characters otherwise it would be truncated +void mnemonic_to_seed(const char *mnemonic, const char *passphrase, + uint8_t seed[512 / 8], + void (*progress_callback)(uint32_t current, + uint32_t total)) { + int mnemoniclen = strlen(mnemonic); + int passphraselen = strnlen(passphrase, 256); +#if USE_BIP39_CACHE + // check cache + if (mnemoniclen < 256 && passphraselen < 64) { + for (int i = 0; i < BIP39_CACHE_SIZE; i++) { + if (!bip39_cache[i].set) continue; + if (strcmp(bip39_cache[i].mnemonic, mnemonic) != 0) continue; + if (strcmp(bip39_cache[i].passphrase, passphrase) != 0) continue; + // found the correct entry + memcpy(seed, bip39_cache[i].seed, 512 / 8); + return; + } + } +#endif + uint8_t salt[8 + 256] = {0}; + memcpy(salt, "mnemonic", 8); + memcpy(salt + 8, passphrase, passphraselen); + static CONFIDENTIAL PBKDF2_HMAC_SHA512_CTX pctx; + pbkdf2_hmac_sha512_Init(&pctx, (const uint8_t *)mnemonic, mnemoniclen, salt, + passphraselen + 8, 1); + if (progress_callback) { + progress_callback(0, BIP39_PBKDF2_ROUNDS); + } + for (int i = 0; i < 16; i++) { + pbkdf2_hmac_sha512_Update(&pctx, BIP39_PBKDF2_ROUNDS / 16); + if (progress_callback) { + progress_callback((i + 1) * BIP39_PBKDF2_ROUNDS / 16, + BIP39_PBKDF2_ROUNDS); + } + } + pbkdf2_hmac_sha512_Final(&pctx, seed); + memzero(salt, sizeof(salt)); +#if USE_BIP39_CACHE + // store to cache + if (mnemoniclen < 256 && passphraselen < 64) { + bip39_cache[bip39_cache_index].set = true; + strcpy(bip39_cache[bip39_cache_index].mnemonic, mnemonic); + strcpy(bip39_cache[bip39_cache_index].passphrase, passphrase); + memcpy(bip39_cache[bip39_cache_index].seed, seed, 512 / 8); + bip39_cache_index = (bip39_cache_index + 1) % BIP39_CACHE_SIZE; + } +#endif +} + +// binary search for finding the word in the wordlist +int mnemonic_find_word(const char *word) { + int lo = 0, hi = BIP39_WORDS - 1; + while (lo <= hi) { + int mid = lo + (hi - lo) / 2; + int cmp = strcmp(word, wordlist[mid]); + if (cmp == 0) { + return mid; + } + if (cmp > 0) { + lo = mid + 1; + } else { + hi = mid - 1; + } + } + return -1; +} + +const char *mnemonic_complete_word(const char *prefix, int len) { + // we need to perform linear search, + // because we want to return the first match + for (const char *const *w = wordlist; *w != 0; w++) { + if (strncmp(*w, prefix, len) == 0) { + return *w; + } + } + return NULL; +} + +const char *mnemonic_get_word(int index) { + if (index >= 0 && index < BIP39_WORDS) { + return wordlist[index]; + } else { + return NULL; + } +} + +uint32_t mnemonic_word_completion_mask(const char *prefix, int len) { + if (len <= 0) { + return 0x3ffffff; // all letters (bits 1-26 set) + } + uint32_t res = 0; + for (const char *const *w = wordlist; *w != 0; w++) { + const char *word = *w; + if (strncmp(word, prefix, len) == 0 && word[len] >= 'a' && + word[len] <= 'z') { + res |= 1 << (word[len] - 'a'); + } + } + return res; +} diff --git a/src/crypto/bip39/bip39.h b/src/crypto/bip39/bip39.h new file mode 100644 index 000000000..07fb21bb2 --- /dev/null +++ b/src/crypto/bip39/bip39.h @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2013-2014 Tomas Dzetkulic + * Copyright (c) 2013-2014 Pavol Rusnak + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __BIP39_H__ +#define __BIP39_H__ + +#include +#include + +#define BIP39_WORDS 2048 +#define BIP39_PBKDF2_ROUNDS 2048 + +const char *mnemonic_generate(int strength); // strength in bits +const char *mnemonic_from_data(const uint8_t *data, int len); +void mnemonic_clear(void); + +int mnemonic_check(const char *mnemonic); + +int mnemonic_to_entropy(const char *mnemonic, uint8_t *entropy); + +// passphrase must be at most 256 characters otherwise it would be truncated +void mnemonic_to_seed(const char *mnemonic, const char *passphrase, + uint8_t seed[512 / 8], + void (*progress_callback)(uint32_t current, + uint32_t total)); + +int mnemonic_find_word(const char *word); +const char *mnemonic_complete_word(const char *prefix, int len); +const char *mnemonic_get_word(int index); +uint32_t mnemonic_word_completion_mask(const char *prefix, int len); + +#endif diff --git a/src/crypto/bip39/bip39_english.h b/src/crypto/bip39/bip39_english.h new file mode 100644 index 000000000..c57fca365 --- /dev/null +++ b/src/crypto/bip39/bip39_english.h @@ -0,0 +1,367 @@ +/** + * Copyright (c) 2013-2014 Tomas Dzetkulic + * Copyright (c) 2013-2014 Pavol Rusnak + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +static const char* const wordlist[] = { + "abandon", "ability", "able", "about", "above", "absent", + "absorb", "abstract", "absurd", "abuse", "access", "accident", + "account", "accuse", "achieve", "acid", "acoustic", "acquire", + "across", "act", "action", "actor", "actress", "actual", + "adapt", "add", "addict", "address", "adjust", "admit", + "adult", "advance", "advice", "aerobic", "affair", "afford", + "afraid", "again", "age", "agent", "agree", "ahead", + "aim", "air", "airport", "aisle", "alarm", "album", + "alcohol", "alert", "alien", "all", "alley", "allow", + "almost", "alone", "alpha", "already", "also", "alter", + "always", "amateur", "amazing", "among", "amount", "amused", + "analyst", "anchor", "ancient", "anger", "angle", "angry", + "animal", "ankle", "announce", "annual", "another", "answer", + "antenna", "antique", "anxiety", "any", "apart", "apology", + "appear", "apple", "approve", "april", "arch", "arctic", + "area", "arena", "argue", "arm", "armed", "armor", + "army", "around", "arrange", "arrest", "arrive", "arrow", + "art", "artefact", "artist", "artwork", "ask", "aspect", + "assault", "asset", "assist", "assume", "asthma", "athlete", + "atom", "attack", "attend", "attitude", "attract", "auction", + "audit", "august", "aunt", "author", "auto", "autumn", + "average", "avocado", "avoid", "awake", "aware", "away", + "awesome", "awful", "awkward", "axis", "baby", "bachelor", + "bacon", "badge", "bag", "balance", "balcony", "ball", + "bamboo", "banana", "banner", "bar", "barely", "bargain", + "barrel", "base", "basic", "basket", "battle", "beach", + "bean", "beauty", "because", "become", "beef", "before", + "begin", "behave", "behind", "believe", "below", "belt", + "bench", "benefit", "best", "betray", "better", "between", + "beyond", "bicycle", "bid", "bike", "bind", "biology", + "bird", "birth", "bitter", "black", "blade", "blame", + "blanket", "blast", "bleak", "bless", "blind", "blood", + "blossom", "blouse", "blue", "blur", "blush", "board", + "boat", "body", "boil", "bomb", "bone", "bonus", + "book", "boost", "border", "boring", "borrow", "boss", + "bottom", "bounce", "box", "boy", "bracket", "brain", + "brand", "brass", "brave", "bread", "breeze", "brick", + "bridge", "brief", "bright", "bring", "brisk", "broccoli", + "broken", "bronze", "broom", "brother", "brown", "brush", + "bubble", "buddy", "budget", "buffalo", "build", "bulb", + "bulk", "bullet", "bundle", "bunker", "burden", "burger", + "burst", "bus", "business", "busy", "butter", "buyer", + "buzz", "cabbage", "cabin", "cable", "cactus", "cage", + "cake", "call", "calm", "camera", "camp", "can", + "canal", "cancel", "candy", "cannon", "canoe", "canvas", + "canyon", "capable", "capital", "captain", "car", "carbon", + "card", "cargo", "carpet", "carry", "cart", "case", + "cash", "casino", "castle", "casual", "cat", "catalog", + "catch", "category", "cattle", "caught", "cause", "caution", + "cave", "ceiling", "celery", "cement", "census", "century", + "cereal", "certain", "chair", "chalk", "champion", "change", + "chaos", "chapter", "charge", "chase", "chat", "cheap", + "check", "cheese", "chef", "cherry", "chest", "chicken", + "chief", "child", "chimney", "choice", "choose", "chronic", + "chuckle", "chunk", "churn", "cigar", "cinnamon", "circle", + "citizen", "city", "civil", "claim", "clap", "clarify", + "claw", "clay", "clean", "clerk", "clever", "click", + "client", "cliff", "climb", "clinic", "clip", "clock", + "clog", "close", "cloth", "cloud", "clown", "club", + "clump", "cluster", "clutch", "coach", "coast", "coconut", + "code", "coffee", "coil", "coin", "collect", "color", + "column", "combine", "come", "comfort", "comic", "common", + "company", "concert", "conduct", "confirm", "congress", "connect", + "consider", "control", "convince", "cook", "cool", "copper", + "copy", "coral", "core", "corn", "correct", "cost", + "cotton", "couch", "country", "couple", "course", "cousin", + "cover", "coyote", "crack", "cradle", "craft", "cram", + "crane", "crash", "crater", "crawl", "crazy", "cream", + "credit", "creek", "crew", "cricket", "crime", "crisp", + "critic", "crop", "cross", "crouch", "crowd", "crucial", + "cruel", "cruise", "crumble", "crunch", "crush", "cry", + "crystal", "cube", "culture", "cup", "cupboard", "curious", + "current", "curtain", "curve", "cushion", "custom", "cute", + "cycle", "dad", "damage", "damp", "dance", "danger", + "daring", "dash", "daughter", "dawn", "day", "deal", + "debate", "debris", "decade", "december", "decide", "decline", + "decorate", "decrease", "deer", "defense", "define", "defy", + "degree", "delay", "deliver", "demand", "demise", "denial", + "dentist", "deny", "depart", "depend", "deposit", "depth", + "deputy", "derive", "describe", "desert", "design", "desk", + "despair", "destroy", "detail", "detect", "develop", "device", + "devote", "diagram", "dial", "diamond", "diary", "dice", + "diesel", "diet", "differ", "digital", "dignity", "dilemma", + "dinner", "dinosaur", "direct", "dirt", "disagree", "discover", + "disease", "dish", "dismiss", "disorder", "display", "distance", + "divert", "divide", "divorce", "dizzy", "doctor", "document", + "dog", "doll", "dolphin", "domain", "donate", "donkey", + "donor", "door", "dose", "double", "dove", "draft", + "dragon", "drama", "drastic", "draw", "dream", "dress", + "drift", "drill", "drink", "drip", "drive", "drop", + "drum", "dry", "duck", "dumb", "dune", "during", + "dust", "dutch", "duty", "dwarf", "dynamic", "eager", + "eagle", "early", "earn", "earth", "easily", "east", + "easy", "echo", "ecology", "economy", "edge", "edit", + "educate", "effort", "egg", "eight", "either", "elbow", + "elder", "electric", "elegant", "element", "elephant", "elevator", + "elite", "else", "embark", "embody", "embrace", "emerge", + "emotion", "employ", "empower", "empty", "enable", "enact", + "end", "endless", "endorse", "enemy", "energy", "enforce", + "engage", "engine", "enhance", "enjoy", "enlist", "enough", + "enrich", "enroll", "ensure", "enter", "entire", "entry", + "envelope", "episode", "equal", "equip", "era", "erase", + "erode", "erosion", "error", "erupt", "escape", "essay", + "essence", "estate", "eternal", "ethics", "evidence", "evil", + "evoke", "evolve", "exact", "example", "excess", "exchange", + "excite", "exclude", "excuse", "execute", "exercise", "exhaust", + "exhibit", "exile", "exist", "exit", "exotic", "expand", + "expect", "expire", "explain", "expose", "express", "extend", + "extra", "eye", "eyebrow", "fabric", "face", "faculty", + "fade", "faint", "faith", "fall", "false", "fame", + "family", "famous", "fan", "fancy", "fantasy", "farm", + "fashion", "fat", "fatal", "father", "fatigue", "fault", + "favorite", "feature", "february", "federal", "fee", "feed", + "feel", "female", "fence", "festival", "fetch", "fever", + "few", "fiber", "fiction", "field", "figure", "file", + "film", "filter", "final", "find", "fine", "finger", + "finish", "fire", "firm", "first", "fiscal", "fish", + "fit", "fitness", "fix", "flag", "flame", "flash", + "flat", "flavor", "flee", "flight", "flip", "float", + "flock", "floor", "flower", "fluid", "flush", "fly", + "foam", "focus", "fog", "foil", "fold", "follow", + "food", "foot", "force", "forest", "forget", "fork", + "fortune", "forum", "forward", "fossil", "foster", "found", + "fox", "fragile", "frame", "frequent", "fresh", "friend", + "fringe", "frog", "front", "frost", "frown", "frozen", + "fruit", "fuel", "fun", "funny", "furnace", "fury", + "future", "gadget", "gain", "galaxy", "gallery", "game", + "gap", "garage", "garbage", "garden", "garlic", "garment", + "gas", "gasp", "gate", "gather", "gauge", "gaze", + "general", "genius", "genre", "gentle", "genuine", "gesture", + "ghost", "giant", "gift", "giggle", "ginger", "giraffe", + "girl", "give", "glad", "glance", "glare", "glass", + "glide", "glimpse", "globe", "gloom", "glory", "glove", + "glow", "glue", "goat", "goddess", "gold", "good", + "goose", "gorilla", "gospel", "gossip", "govern", "gown", + "grab", "grace", "grain", "grant", "grape", "grass", + "gravity", "great", "green", "grid", "grief", "grit", + "grocery", "group", "grow", "grunt", "guard", "guess", + "guide", "guilt", "guitar", "gun", "gym", "habit", + "hair", "half", "hammer", "hamster", "hand", "happy", + "harbor", "hard", "harsh", "harvest", "hat", "have", + "hawk", "hazard", "head", "health", "heart", "heavy", + "hedgehog", "height", "hello", "helmet", "help", "hen", + "hero", "hidden", "high", "hill", "hint", "hip", + "hire", "history", "hobby", "hockey", "hold", "hole", + "holiday", "hollow", "home", "honey", "hood", "hope", + "horn", "horror", "horse", "hospital", "host", "hotel", + "hour", "hover", "hub", "huge", "human", "humble", + "humor", "hundred", "hungry", "hunt", "hurdle", "hurry", + "hurt", "husband", "hybrid", "ice", "icon", "idea", + "identify", "idle", "ignore", "ill", "illegal", "illness", + "image", "imitate", "immense", "immune", "impact", "impose", + "improve", "impulse", "inch", "include", "income", "increase", + "index", "indicate", "indoor", "industry", "infant", "inflict", + "inform", "inhale", "inherit", "initial", "inject", "injury", + "inmate", "inner", "innocent", "input", "inquiry", "insane", + "insect", "inside", "inspire", "install", "intact", "interest", + "into", "invest", "invite", "involve", "iron", "island", + "isolate", "issue", "item", "ivory", "jacket", "jaguar", + "jar", "jazz", "jealous", "jeans", "jelly", "jewel", + "job", "join", "joke", "journey", "joy", "judge", + "juice", "jump", "jungle", "junior", "junk", "just", + "kangaroo", "keen", "keep", "ketchup", "key", "kick", + "kid", "kidney", "kind", "kingdom", "kiss", "kit", + "kitchen", "kite", "kitten", "kiwi", "knee", "knife", + "knock", "know", "lab", "label", "labor", "ladder", + "lady", "lake", "lamp", "language", "laptop", "large", + "later", "latin", "laugh", "laundry", "lava", "law", + "lawn", "lawsuit", "layer", "lazy", "leader", "leaf", + "learn", "leave", "lecture", "left", "leg", "legal", + "legend", "leisure", "lemon", "lend", "length", "lens", + "leopard", "lesson", "letter", "level", "liar", "liberty", + "library", "license", "life", "lift", "light", "like", + "limb", "limit", "link", "lion", "liquid", "list", + "little", "live", "lizard", "load", "loan", "lobster", + "local", "lock", "logic", "lonely", "long", "loop", + "lottery", "loud", "lounge", "love", "loyal", "lucky", + "luggage", "lumber", "lunar", "lunch", "luxury", "lyrics", + "machine", "mad", "magic", "magnet", "maid", "mail", + "main", "major", "make", "mammal", "man", "manage", + "mandate", "mango", "mansion", "manual", "maple", "marble", + "march", "margin", "marine", "market", "marriage", "mask", + "mass", "master", "match", "material", "math", "matrix", + "matter", "maximum", "maze", "meadow", "mean", "measure", + "meat", "mechanic", "medal", "media", "melody", "melt", + "member", "memory", "mention", "menu", "mercy", "merge", + "merit", "merry", "mesh", "message", "metal", "method", + "middle", "midnight", "milk", "million", "mimic", "mind", + "minimum", "minor", "minute", "miracle", "mirror", "misery", + "miss", "mistake", "mix", "mixed", "mixture", "mobile", + "model", "modify", "mom", "moment", "monitor", "monkey", + "monster", "month", "moon", "moral", "more", "morning", + "mosquito", "mother", "motion", "motor", "mountain", "mouse", + "move", "movie", "much", "muffin", "mule", "multiply", + "muscle", "museum", "mushroom", "music", "must", "mutual", + "myself", "mystery", "myth", "naive", "name", "napkin", + "narrow", "nasty", "nation", "nature", "near", "neck", + "need", "negative", "neglect", "neither", "nephew", "nerve", + "nest", "net", "network", "neutral", "never", "news", + "next", "nice", "night", "noble", "noise", "nominee", + "noodle", "normal", "north", "nose", "notable", "note", + "nothing", "notice", "novel", "now", "nuclear", "number", + "nurse", "nut", "oak", "obey", "object", "oblige", + "obscure", "observe", "obtain", "obvious", "occur", "ocean", + "october", "odor", "off", "offer", "office", "often", + "oil", "okay", "old", "olive", "olympic", "omit", + "once", "one", "onion", "online", "only", "open", + "opera", "opinion", "oppose", "option", "orange", "orbit", + "orchard", "order", "ordinary", "organ", "orient", "original", + "orphan", "ostrich", "other", "outdoor", "outer", "output", + "outside", "oval", "oven", "over", "own", "owner", + "oxygen", "oyster", "ozone", "pact", "paddle", "page", + "pair", "palace", "palm", "panda", "panel", "panic", + "panther", "paper", "parade", "parent", "park", "parrot", + "party", "pass", "patch", "path", "patient", "patrol", + "pattern", "pause", "pave", "payment", "peace", "peanut", + "pear", "peasant", "pelican", "pen", "penalty", "pencil", + "people", "pepper", "perfect", "permit", "person", "pet", + "phone", "photo", "phrase", "physical", "piano", "picnic", + "picture", "piece", "pig", "pigeon", "pill", "pilot", + "pink", "pioneer", "pipe", "pistol", "pitch", "pizza", + "place", "planet", "plastic", "plate", "play", "please", + "pledge", "pluck", "plug", "plunge", "poem", "poet", + "point", "polar", "pole", "police", "pond", "pony", + "pool", "popular", "portion", "position", "possible", "post", + "potato", "pottery", "poverty", "powder", "power", "practice", + "praise", "predict", "prefer", "prepare", "present", "pretty", + "prevent", "price", "pride", "primary", "print", "priority", + "prison", "private", "prize", "problem", "process", "produce", + "profit", "program", "project", "promote", "proof", "property", + "prosper", "protect", "proud", "provide", "public", "pudding", + "pull", "pulp", "pulse", "pumpkin", "punch", "pupil", + "puppy", "purchase", "purity", "purpose", "purse", "push", + "put", "puzzle", "pyramid", "quality", "quantum", "quarter", + "question", "quick", "quit", "quiz", "quote", "rabbit", + "raccoon", "race", "rack", "radar", "radio", "rail", + "rain", "raise", "rally", "ramp", "ranch", "random", + "range", "rapid", "rare", "rate", "rather", "raven", + "raw", "razor", "ready", "real", "reason", "rebel", + "rebuild", "recall", "receive", "recipe", "record", "recycle", + "reduce", "reflect", "reform", "refuse", "region", "regret", + "regular", "reject", "relax", "release", "relief", "rely", + "remain", "remember", "remind", "remove", "render", "renew", + "rent", "reopen", "repair", "repeat", "replace", "report", + "require", "rescue", "resemble", "resist", "resource", "response", + "result", "retire", "retreat", "return", "reunion", "reveal", + "review", "reward", "rhythm", "rib", "ribbon", "rice", + "rich", "ride", "ridge", "rifle", "right", "rigid", + "ring", "riot", "ripple", "risk", "ritual", "rival", + "river", "road", "roast", "robot", "robust", "rocket", + "romance", "roof", "rookie", "room", "rose", "rotate", + "rough", "round", "route", "royal", "rubber", "rude", + "rug", "rule", "run", "runway", "rural", "sad", + "saddle", "sadness", "safe", "sail", "salad", "salmon", + "salon", "salt", "salute", "same", "sample", "sand", + "satisfy", "satoshi", "sauce", "sausage", "save", "say", + "scale", "scan", "scare", "scatter", "scene", "scheme", + "school", "science", "scissors", "scorpion", "scout", "scrap", + "screen", "script", "scrub", "sea", "search", "season", + "seat", "second", "secret", "section", "security", "seed", + "seek", "segment", "select", "sell", "seminar", "senior", + "sense", "sentence", "series", "service", "session", "settle", + "setup", "seven", "shadow", "shaft", "shallow", "share", + "shed", "shell", "sheriff", "shield", "shift", "shine", + "ship", "shiver", "shock", "shoe", "shoot", "shop", + "short", "shoulder", "shove", "shrimp", "shrug", "shuffle", + "shy", "sibling", "sick", "side", "siege", "sight", + "sign", "silent", "silk", "silly", "silver", "similar", + "simple", "since", "sing", "siren", "sister", "situate", + "six", "size", "skate", "sketch", "ski", "skill", + "skin", "skirt", "skull", "slab", "slam", "sleep", + "slender", "slice", "slide", "slight", "slim", "slogan", + "slot", "slow", "slush", "small", "smart", "smile", + "smoke", "smooth", "snack", "snake", "snap", "sniff", + "snow", "soap", "soccer", "social", "sock", "soda", + "soft", "solar", "soldier", "solid", "solution", "solve", + "someone", "song", "soon", "sorry", "sort", "soul", + "sound", "soup", "source", "south", "space", "spare", + "spatial", "spawn", "speak", "special", "speed", "spell", + "spend", "sphere", "spice", "spider", "spike", "spin", + "spirit", "split", "spoil", "sponsor", "spoon", "sport", + "spot", "spray", "spread", "spring", "spy", "square", + "squeeze", "squirrel", "stable", "stadium", "staff", "stage", + "stairs", "stamp", "stand", "start", "state", "stay", + "steak", "steel", "stem", "step", "stereo", "stick", + "still", "sting", "stock", "stomach", "stone", "stool", + "story", "stove", "strategy", "street", "strike", "strong", + "struggle", "student", "stuff", "stumble", "style", "subject", + "submit", "subway", "success", "such", "sudden", "suffer", + "sugar", "suggest", "suit", "summer", "sun", "sunny", + "sunset", "super", "supply", "supreme", "sure", "surface", + "surge", "surprise", "surround", "survey", "suspect", "sustain", + "swallow", "swamp", "swap", "swarm", "swear", "sweet", + "swift", "swim", "swing", "switch", "sword", "symbol", + "symptom", "syrup", "system", "table", "tackle", "tag", + "tail", "talent", "talk", "tank", "tape", "target", + "task", "taste", "tattoo", "taxi", "teach", "team", + "tell", "ten", "tenant", "tennis", "tent", "term", + "test", "text", "thank", "that", "theme", "then", + "theory", "there", "they", "thing", "this", "thought", + "three", "thrive", "throw", "thumb", "thunder", "ticket", + "tide", "tiger", "tilt", "timber", "time", "tiny", + "tip", "tired", "tissue", "title", "toast", "tobacco", + "today", "toddler", "toe", "together", "toilet", "token", + "tomato", "tomorrow", "tone", "tongue", "tonight", "tool", + "tooth", "top", "topic", "topple", "torch", "tornado", + "tortoise", "toss", "total", "tourist", "toward", "tower", + "town", "toy", "track", "trade", "traffic", "tragic", + "train", "transfer", "trap", "trash", "travel", "tray", + "treat", "tree", "trend", "trial", "tribe", "trick", + "trigger", "trim", "trip", "trophy", "trouble", "truck", + "true", "truly", "trumpet", "trust", "truth", "try", + "tube", "tuition", "tumble", "tuna", "tunnel", "turkey", + "turn", "turtle", "twelve", "twenty", "twice", "twin", + "twist", "two", "type", "typical", "ugly", "umbrella", + "unable", "unaware", "uncle", "uncover", "under", "undo", + "unfair", "unfold", "unhappy", "uniform", "unique", "unit", + "universe", "unknown", "unlock", "until", "unusual", "unveil", + "update", "upgrade", "uphold", "upon", "upper", "upset", + "urban", "urge", "usage", "use", "used", "useful", + "useless", "usual", "utility", "vacant", "vacuum", "vague", + "valid", "valley", "valve", "van", "vanish", "vapor", + "various", "vast", "vault", "vehicle", "velvet", "vendor", + "venture", "venue", "verb", "verify", "version", "very", + "vessel", "veteran", "viable", "vibrant", "vicious", "victory", + "video", "view", "village", "vintage", "violin", "virtual", + "virus", "visa", "visit", "visual", "vital", "vivid", + "vocal", "voice", "void", "volcano", "volume", "vote", + "voyage", "wage", "wagon", "wait", "walk", "wall", + "walnut", "want", "warfare", "warm", "warrior", "wash", + "wasp", "waste", "water", "wave", "way", "wealth", + "weapon", "wear", "weasel", "weather", "web", "wedding", + "weekend", "weird", "welcome", "west", "wet", "whale", + "what", "wheat", "wheel", "when", "where", "whip", + "whisper", "wide", "width", "wife", "wild", "will", + "win", "window", "wine", "wing", "wink", "winner", + "winter", "wire", "wisdom", "wise", "wish", "witness", + "wolf", "woman", "wonder", "wood", "wool", "word", + "work", "world", "worry", "worth", "wrap", "wreck", + "wrestle", "wrist", "write", "wrong", "yard", "year", + "yellow", "you", "young", "youth", "zebra", "zero", + "zone", "zoo", 0, +}; diff --git a/src/crypto/bip39/hmac.c b/src/crypto/bip39/hmac.c new file mode 100644 index 000000000..654f2d6e8 --- /dev/null +++ b/src/crypto/bip39/hmac.c @@ -0,0 +1,176 @@ +/** + * Copyright (c) 2013-2014 Tomas Dzetkulic + * Copyright (c) 2013-2014 Pavol Rusnak + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include + +#include "hmac.h" +#include "memzero.h" +#include "options.h" + +void hmac_sha256_Init(HMAC_SHA256_CTX *hctx, const uint8_t *key, + const uint32_t keylen) { + static CONFIDENTIAL uint8_t i_key_pad[SHA256_BLOCK_LENGTH]; + memzero(i_key_pad, SHA256_BLOCK_LENGTH); + if (keylen > SHA256_BLOCK_LENGTH) { + sha256_Raw(key, keylen, i_key_pad); + } else { + memcpy(i_key_pad, key, keylen); + } + for (int i = 0; i < SHA256_BLOCK_LENGTH; i++) { + hctx->o_key_pad[i] = i_key_pad[i] ^ 0x5c; + i_key_pad[i] ^= 0x36; + } + sha256_Init(&(hctx->ctx)); + sha256_Update(&(hctx->ctx), i_key_pad, SHA256_BLOCK_LENGTH); + memzero(i_key_pad, sizeof(i_key_pad)); +} + +void hmac_sha256_Update(HMAC_SHA256_CTX *hctx, const uint8_t *msg, + const uint32_t msglen) { + sha256_Update(&(hctx->ctx), msg, msglen); +} + +void hmac_sha256_Final(HMAC_SHA256_CTX *hctx, uint8_t *hmac) { + sha256_Final(&(hctx->ctx), hmac); + sha256_Init(&(hctx->ctx)); + sha256_Update(&(hctx->ctx), hctx->o_key_pad, SHA256_BLOCK_LENGTH); + sha256_Update(&(hctx->ctx), hmac, SHA256_DIGEST_LENGTH); + sha256_Final(&(hctx->ctx), hmac); + memzero(hctx, sizeof(HMAC_SHA256_CTX)); +} + +void hmac_sha256(const uint8_t *key, const uint32_t keylen, const uint8_t *msg, + const uint32_t msglen, uint8_t *hmac) { + static CONFIDENTIAL HMAC_SHA256_CTX hctx; + hmac_sha256_Init(&hctx, key, keylen); + hmac_sha256_Update(&hctx, msg, msglen); + hmac_sha256_Final(&hctx, hmac); +} + +void hmac_sha256_prepare(const uint8_t *key, const uint32_t keylen, + uint32_t *opad_digest, uint32_t *ipad_digest) { + static CONFIDENTIAL uint32_t key_pad[SHA256_BLOCK_LENGTH / sizeof(uint32_t)]; + + memzero(key_pad, sizeof(key_pad)); + if (keylen > SHA256_BLOCK_LENGTH) { + static CONFIDENTIAL SHA256_CTX context; + sha256_Init(&context); + sha256_Update(&context, key, keylen); + sha256_Final(&context, (uint8_t *)key_pad); + } else { + memcpy(key_pad, key, keylen); + } + + /* compute o_key_pad and its digest */ + for (int i = 0; i < SHA256_BLOCK_LENGTH / (int)sizeof(uint32_t); i++) { + uint32_t data = 0; +#if BYTE_ORDER == LITTLE_ENDIAN + REVERSE32(key_pad[i], data); +#else + data = key_pad[i]; +#endif + key_pad[i] = data ^ 0x5c5c5c5c; + } + sha256_Transform(sha256_initial_hash_value, key_pad, opad_digest); + + /* convert o_key_pad to i_key_pad and compute its digest */ + for (int i = 0; i < SHA256_BLOCK_LENGTH / (int)sizeof(uint32_t); i++) { + key_pad[i] = key_pad[i] ^ 0x5c5c5c5c ^ 0x36363636; + } + sha256_Transform(sha256_initial_hash_value, key_pad, ipad_digest); + memzero(key_pad, sizeof(key_pad)); +} + +void hmac_sha512_Init(HMAC_SHA512_CTX *hctx, const uint8_t *key, + const uint32_t keylen) { + static CONFIDENTIAL uint8_t i_key_pad[SHA512_BLOCK_LENGTH]; + memzero(i_key_pad, SHA512_BLOCK_LENGTH); + if (keylen > SHA512_BLOCK_LENGTH) { + sha512_Raw(key, keylen, i_key_pad); + } else { + memcpy(i_key_pad, key, keylen); + } + for (int i = 0; i < SHA512_BLOCK_LENGTH; i++) { + hctx->o_key_pad[i] = i_key_pad[i] ^ 0x5c; + i_key_pad[i] ^= 0x36; + } + sha512_Init(&(hctx->ctx)); + sha512_Update(&(hctx->ctx), i_key_pad, SHA512_BLOCK_LENGTH); + memzero(i_key_pad, sizeof(i_key_pad)); +} + +void hmac_sha512_Update(HMAC_SHA512_CTX *hctx, const uint8_t *msg, + const uint32_t msglen) { + sha512_Update(&(hctx->ctx), msg, msglen); +} + +void hmac_sha512_Final(HMAC_SHA512_CTX *hctx, uint8_t *hmac) { + sha512_Final(&(hctx->ctx), hmac); + sha512_Init(&(hctx->ctx)); + sha512_Update(&(hctx->ctx), hctx->o_key_pad, SHA512_BLOCK_LENGTH); + sha512_Update(&(hctx->ctx), hmac, SHA512_DIGEST_LENGTH); + sha512_Final(&(hctx->ctx), hmac); + memzero(hctx, sizeof(HMAC_SHA512_CTX)); +} + +void hmac_sha512(const uint8_t *key, const uint32_t keylen, const uint8_t *msg, + const uint32_t msglen, uint8_t *hmac) { + HMAC_SHA512_CTX hctx = {0}; + hmac_sha512_Init(&hctx, key, keylen); + hmac_sha512_Update(&hctx, msg, msglen); + hmac_sha512_Final(&hctx, hmac); +} + +void hmac_sha512_prepare(const uint8_t *key, const uint32_t keylen, + uint64_t *opad_digest, uint64_t *ipad_digest) { + static CONFIDENTIAL uint64_t key_pad[SHA512_BLOCK_LENGTH / sizeof(uint64_t)]; + + memzero(key_pad, sizeof(key_pad)); + if (keylen > SHA512_BLOCK_LENGTH) { + static CONFIDENTIAL SHA512_CTX context; + sha512_Init(&context); + sha512_Update(&context, key, keylen); + sha512_Final(&context, (uint8_t *)key_pad); + } else { + memcpy(key_pad, key, keylen); + } + + /* compute o_key_pad and its digest */ + for (int i = 0; i < SHA512_BLOCK_LENGTH / (int)sizeof(uint64_t); i++) { + uint64_t data = 0; +#if BYTE_ORDER == LITTLE_ENDIAN + REVERSE64(key_pad[i], data); +#else + data = key_pad[i]; +#endif + key_pad[i] = data ^ 0x5c5c5c5c5c5c5c5c; + } + sha512_Transform(sha512_initial_hash_value, key_pad, opad_digest); + + /* convert o_key_pad to i_key_pad and compute its digest */ + for (int i = 0; i < SHA512_BLOCK_LENGTH / (int)sizeof(uint64_t); i++) { + key_pad[i] = key_pad[i] ^ 0x5c5c5c5c5c5c5c5c ^ 0x3636363636363636; + } + sha512_Transform(sha512_initial_hash_value, key_pad, ipad_digest); + memzero(key_pad, sizeof(key_pad)); +} diff --git a/src/crypto/bip39/hmac.h b/src/crypto/bip39/hmac.h new file mode 100644 index 000000000..3921a171e --- /dev/null +++ b/src/crypto/bip39/hmac.h @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2013-2014 Tomas Dzetkulic + * Copyright (c) 2013-2014 Pavol Rusnak + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT HMAC_SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __HMAC_H__ +#define __HMAC_H__ + +#include +#include "sha2.h" + +typedef struct _HMAC_SHA256_CTX { + uint8_t o_key_pad[SHA256_BLOCK_LENGTH]; + SHA256_CTX ctx; +} HMAC_SHA256_CTX; + +typedef struct _HMAC_SHA512_CTX { + uint8_t o_key_pad[SHA512_BLOCK_LENGTH]; + SHA512_CTX ctx; +} HMAC_SHA512_CTX; + +void hmac_sha256_Init(HMAC_SHA256_CTX *hctx, const uint8_t *key, + const uint32_t keylen); +void hmac_sha256_Update(HMAC_SHA256_CTX *hctx, const uint8_t *msg, + const uint32_t msglen); +void hmac_sha256_Final(HMAC_SHA256_CTX *hctx, uint8_t *hmac); +void hmac_sha256(const uint8_t *key, const uint32_t keylen, const uint8_t *msg, + const uint32_t msglen, uint8_t *hmac); +void hmac_sha256_prepare(const uint8_t *key, const uint32_t keylen, + uint32_t *opad_digest, uint32_t *ipad_digest); + +void hmac_sha512_Init(HMAC_SHA512_CTX *hctx, const uint8_t *key, + const uint32_t keylen); +void hmac_sha512_Update(HMAC_SHA512_CTX *hctx, const uint8_t *msg, + const uint32_t msglen); +void hmac_sha512_Final(HMAC_SHA512_CTX *hctx, uint8_t *hmac); +void hmac_sha512(const uint8_t *key, const uint32_t keylen, const uint8_t *msg, + const uint32_t msglen, uint8_t *hmac); +void hmac_sha512_prepare(const uint8_t *key, const uint32_t keylen, + uint64_t *opad_digest, uint64_t *ipad_digest); + +#endif diff --git a/src/crypto/bip39/hmac_drbg.c b/src/crypto/bip39/hmac_drbg.c new file mode 100644 index 000000000..1ed1401b8 --- /dev/null +++ b/src/crypto/bip39/hmac_drbg.c @@ -0,0 +1,130 @@ +/** + * Copyright (c) 2019 Andrew R. Kozlik + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "hmac_drbg.h" +#include +#include "memzero.h" +#include "sha2.h" + +static void update_k(HMAC_DRBG_CTX *ctx, uint8_t domain, const uint8_t *data1, + size_t len1, const uint8_t *data2, size_t len2) { + // Computes K = HMAC(K, V || domain || data1 || data 2). + + // First hash operation of HMAC. + uint32_t h[SHA256_BLOCK_LENGTH / sizeof(uint32_t)] = {0}; + if (len1 + len2 == 0) { + ctx->v[8] = 0x00800000; + ctx->v[15] = (SHA256_BLOCK_LENGTH + SHA256_DIGEST_LENGTH + 1) * 8; + sha256_Transform(ctx->idig, ctx->v, h); + ctx->v[8] = 0x80000000; + ctx->v[15] = (SHA256_BLOCK_LENGTH + SHA256_DIGEST_LENGTH) * 8; + } else { + SHA256_CTX sha_ctx = {0}; + memcpy(sha_ctx.state, ctx->idig, SHA256_DIGEST_LENGTH); + for (size_t i = 0; i < SHA256_DIGEST_LENGTH / sizeof(uint32_t); i++) { +#if BYTE_ORDER == LITTLE_ENDIAN + REVERSE32(ctx->v[i], sha_ctx.buffer[i]); +#else + sha_ctx.buffer[i] = ctx->v[i]; +#endif + } + ((uint8_t *)sha_ctx.buffer)[SHA256_DIGEST_LENGTH] = domain; + sha_ctx.bitcount = (SHA256_BLOCK_LENGTH + SHA256_DIGEST_LENGTH + 1) * 8; + sha256_Update(&sha_ctx, data1, len1); + sha256_Update(&sha_ctx, data2, len2); + sha256_Final(&sha_ctx, (uint8_t *)h); +#if BYTE_ORDER == LITTLE_ENDIAN + for (size_t i = 0; i < SHA256_DIGEST_LENGTH / sizeof(uint32_t); i++) + REVERSE32(h[i], h[i]); +#endif + } + + // Second hash operation of HMAC. + h[8] = 0x80000000; + h[15] = (SHA256_BLOCK_LENGTH + SHA256_DIGEST_LENGTH) * 8; + sha256_Transform(ctx->odig, h, h); + + // Precompute the inner digest and outer digest of K. + h[8] = 0; + h[15] = 0; + for (size_t i = 0; i < SHA256_BLOCK_LENGTH / sizeof(uint32_t); i++) { + h[i] ^= 0x36363636; + } + sha256_Transform(sha256_initial_hash_value, h, ctx->idig); + + for (size_t i = 0; i < SHA256_BLOCK_LENGTH / sizeof(uint32_t); i++) { + h[i] = h[i] ^ 0x36363636 ^ 0x5c5c5c5c; + } + sha256_Transform(sha256_initial_hash_value, h, ctx->odig); + memzero(h, sizeof(h)); +} + +static void update_v(HMAC_DRBG_CTX *ctx) { + sha256_Transform(ctx->idig, ctx->v, ctx->v); + sha256_Transform(ctx->odig, ctx->v, ctx->v); +} + +void hmac_drbg_init(HMAC_DRBG_CTX *ctx, const uint8_t *entropy, + size_t entropy_len, const uint8_t *nonce, + size_t nonce_len) { + uint32_t h[SHA256_BLOCK_LENGTH / sizeof(uint32_t)] = {0}; + + // Precompute the inner digest and outer digest of K = 0x00 ... 0x00. + memset(h, 0x36, sizeof(h)); + sha256_Transform(sha256_initial_hash_value, h, ctx->idig); + memset(h, 0x5c, sizeof(h)); + sha256_Transform(sha256_initial_hash_value, h, ctx->odig); + + // Let V = 0x01 ... 0x01. + memset(ctx->v, 1, SHA256_DIGEST_LENGTH); + for (size_t i = 9; i < 15; i++) ctx->v[i] = 0; + ctx->v[8] = 0x80000000; + ctx->v[15] = (SHA256_BLOCK_LENGTH + SHA256_DIGEST_LENGTH) * 8; + + hmac_drbg_reseed(ctx, entropy, entropy_len, nonce, nonce_len); + + memzero(h, sizeof(h)); +} + +void hmac_drbg_reseed(HMAC_DRBG_CTX *ctx, const uint8_t *entropy, size_t len, + const uint8_t *addin, size_t addin_len) { + update_k(ctx, 0, entropy, len, addin, addin_len); + update_v(ctx); + if (len == 0) return; + update_k(ctx, 1, entropy, len, addin, addin_len); + update_v(ctx); +} + +void hmac_drbg_generate(HMAC_DRBG_CTX *ctx, uint8_t *buf, size_t len) { + size_t i = 0; + while (i < len) { + update_v(ctx); + for (size_t j = 0; j < 8 && i < len; j++) { + uint32_t r = ctx->v[j]; + for (int k = 24; k >= 0 && i < len; k -= 8) { + buf[i++] = (r >> k) & 0xFF; + } + } + } + update_k(ctx, 0, NULL, 0, NULL, 0); + update_v(ctx); +} diff --git a/src/crypto/bip39/hmac_drbg.h b/src/crypto/bip39/hmac_drbg.h new file mode 100644 index 000000000..4b969dedb --- /dev/null +++ b/src/crypto/bip39/hmac_drbg.h @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2019 Andrew R. Kozlik + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __HMAC_DRBG_H__ +#define __HMAC_DRBG_H__ + +#include +#include + +// HMAC based Deterministic Random Bit Generator with SHA-256 + +typedef struct _HMAC_DRBG_CTX { + uint32_t odig[SHA256_DIGEST_LENGTH / sizeof(uint32_t)]; + uint32_t idig[SHA256_DIGEST_LENGTH / sizeof(uint32_t)]; + uint32_t v[SHA256_BLOCK_LENGTH / sizeof(uint32_t)]; +} HMAC_DRBG_CTX; + +void hmac_drbg_init(HMAC_DRBG_CTX *ctx, const uint8_t *buf, size_t len, + const uint8_t *nonce, size_t nonce_len); +void hmac_drbg_reseed(HMAC_DRBG_CTX *ctx, const uint8_t *buf, size_t len, + const uint8_t *addin, size_t addin_len); +void hmac_drbg_generate(HMAC_DRBG_CTX *ctx, uint8_t *buf, size_t len); + +#endif diff --git a/src/crypto/bip39/memzero.h b/src/crypto/bip39/memzero.h new file mode 100644 index 000000000..0a959fbc2 --- /dev/null +++ b/src/crypto/bip39/memzero.h @@ -0,0 +1,8 @@ +#ifndef __MEMZERO_H__ +#define __MEMZERO_H__ + +#include + +void memzero(void* const pnt, const size_t len); + +#endif diff --git a/src/crypto/bip39/options.h b/src/crypto/bip39/options.h new file mode 100644 index 000000000..d3a9c2edf --- /dev/null +++ b/src/crypto/bip39/options.h @@ -0,0 +1,99 @@ +/** + * Copyright (c) 2013-2014 Pavol Rusnak + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __OPTIONS_H__ +#define __OPTIONS_H__ + +// use precomputed Curve Points (some scalar multiples of curve base point G) +#ifndef USE_PRECOMPUTED_CP +#define USE_PRECOMPUTED_CP 1 +#endif + +// use fast inverse method +#ifndef USE_INVERSE_FAST +#define USE_INVERSE_FAST 1 +#endif + +// support for printing bignum256 structures via printf +#ifndef USE_BN_PRINT +#define USE_BN_PRINT 0 +#endif + +// use deterministic signatures +#ifndef USE_RFC6979 +#define USE_RFC6979 1 +#endif + +// implement BIP32 caching +#ifndef USE_BIP32_CACHE +#define USE_BIP32_CACHE 1 +#define BIP32_CACHE_SIZE 10 +#define BIP32_CACHE_MAXDEPTH 8 +#endif + +// support constructing BIP32 nodes from ed25519 and curve25519 curves. +#ifndef USE_BIP32_25519_CURVES +#define USE_BIP32_25519_CURVES 1 +#endif + +// implement BIP39 caching +#ifndef USE_BIP39_CACHE +#define USE_BIP39_CACHE 1 +#define BIP39_CACHE_SIZE 4 +#endif + +// support Ethereum operations +#ifndef USE_ETHEREUM +#define USE_ETHEREUM 0 +#endif + +// support Graphene operations (STEEM, BitShares) +#ifndef USE_GRAPHENE +#define USE_GRAPHENE 0 +#endif + +// support NEM operations +#ifndef USE_NEM +#define USE_NEM 0 +#endif + +// support MONERO operations +#ifndef USE_MONERO +#define USE_MONERO 0 +#endif + +// support CARDANO operations +#ifndef USE_CARDANO +#define USE_CARDANO 0 +#endif + +// support Keccak hashing +#ifndef USE_KECCAK +#define USE_KECCAK 1 +#endif + +// add way how to mark confidential data +#ifndef CONFIDENTIAL +#define CONFIDENTIAL +#endif + +#endif diff --git a/src/crypto/bip39/pbkdf2.c b/src/crypto/bip39/pbkdf2.c new file mode 100644 index 000000000..d9e142297 --- /dev/null +++ b/src/crypto/bip39/pbkdf2.c @@ -0,0 +1,179 @@ +/** + * Copyright (c) 2013-2014 Tomas Dzetkulic + * Copyright (c) 2013-2014 Pavol Rusnak + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "pbkdf2.h" +#include +#include "hmac.h" +#include "memzero.h" +#include "sha2.h" + +void pbkdf2_hmac_sha256_Init(PBKDF2_HMAC_SHA256_CTX *pctx, const uint8_t *pass, + int passlen, const uint8_t *salt, int saltlen, + uint32_t blocknr) { + SHA256_CTX ctx = {0}; +#if BYTE_ORDER == LITTLE_ENDIAN + REVERSE32(blocknr, blocknr); +#endif + + hmac_sha256_prepare(pass, passlen, pctx->odig, pctx->idig); + memzero(pctx->g, sizeof(pctx->g)); + pctx->g[8] = 0x80000000; + pctx->g[15] = (SHA256_BLOCK_LENGTH + SHA256_DIGEST_LENGTH) * 8; + + memcpy(ctx.state, pctx->idig, sizeof(pctx->idig)); + ctx.bitcount = SHA256_BLOCK_LENGTH * 8; + sha256_Update(&ctx, salt, saltlen); + sha256_Update(&ctx, (uint8_t *)&blocknr, sizeof(blocknr)); + sha256_Final(&ctx, (uint8_t *)pctx->g); +#if BYTE_ORDER == LITTLE_ENDIAN + for (uint32_t k = 0; k < SHA256_DIGEST_LENGTH / sizeof(uint32_t); k++) { + REVERSE32(pctx->g[k], pctx->g[k]); + } +#endif + sha256_Transform(pctx->odig, pctx->g, pctx->g); + memcpy(pctx->f, pctx->g, SHA256_DIGEST_LENGTH); + pctx->first = 1; +} + +void pbkdf2_hmac_sha256_Update(PBKDF2_HMAC_SHA256_CTX *pctx, + uint32_t iterations) { + for (uint32_t i = pctx->first; i < iterations; i++) { + sha256_Transform(pctx->idig, pctx->g, pctx->g); + sha256_Transform(pctx->odig, pctx->g, pctx->g); + for (uint32_t j = 0; j < SHA256_DIGEST_LENGTH / sizeof(uint32_t); j++) { + pctx->f[j] ^= pctx->g[j]; + } + } + pctx->first = 0; +} + +void pbkdf2_hmac_sha256_Final(PBKDF2_HMAC_SHA256_CTX *pctx, uint8_t *key) { +#if BYTE_ORDER == LITTLE_ENDIAN + for (uint32_t k = 0; k < SHA256_DIGEST_LENGTH / sizeof(uint32_t); k++) { + REVERSE32(pctx->f[k], pctx->f[k]); + } +#endif + memcpy(key, pctx->f, SHA256_DIGEST_LENGTH); + memzero(pctx, sizeof(PBKDF2_HMAC_SHA256_CTX)); +} + +void pbkdf2_hmac_sha256(const uint8_t *pass, int passlen, const uint8_t *salt, + int saltlen, uint32_t iterations, uint8_t *key, + int keylen) { + uint32_t last_block_size = keylen % SHA256_DIGEST_LENGTH; + uint32_t blocks_count = keylen / SHA256_DIGEST_LENGTH; + if (last_block_size) { + blocks_count++; + } else { + last_block_size = SHA256_DIGEST_LENGTH; + } + for (uint32_t blocknr = 1; blocknr <= blocks_count; blocknr++) { + PBKDF2_HMAC_SHA256_CTX pctx = {0}; + pbkdf2_hmac_sha256_Init(&pctx, pass, passlen, salt, saltlen, blocknr); + pbkdf2_hmac_sha256_Update(&pctx, iterations); + uint8_t digest[SHA256_DIGEST_LENGTH] = {0}; + pbkdf2_hmac_sha256_Final(&pctx, digest); + uint32_t key_offset = (blocknr - 1) * SHA256_DIGEST_LENGTH; + if (blocknr < blocks_count) { + memcpy(key + key_offset, digest, SHA256_DIGEST_LENGTH); + } else { + memcpy(key + key_offset, digest, last_block_size); + } + } +} + +void pbkdf2_hmac_sha512_Init(PBKDF2_HMAC_SHA512_CTX *pctx, const uint8_t *pass, + int passlen, const uint8_t *salt, int saltlen, + uint32_t blocknr) { + SHA512_CTX ctx = {0}; +#if BYTE_ORDER == LITTLE_ENDIAN + REVERSE32(blocknr, blocknr); +#endif + + hmac_sha512_prepare(pass, passlen, pctx->odig, pctx->idig); + memzero(pctx->g, sizeof(pctx->g)); + pctx->g[8] = 0x8000000000000000; + pctx->g[15] = (SHA512_BLOCK_LENGTH + SHA512_DIGEST_LENGTH) * 8; + + memcpy(ctx.state, pctx->idig, sizeof(pctx->idig)); + ctx.bitcount[0] = SHA512_BLOCK_LENGTH * 8; + ctx.bitcount[1] = 0; + sha512_Update(&ctx, salt, saltlen); + sha512_Update(&ctx, (uint8_t *)&blocknr, sizeof(blocknr)); + sha512_Final(&ctx, (uint8_t *)pctx->g); +#if BYTE_ORDER == LITTLE_ENDIAN + for (uint32_t k = 0; k < SHA512_DIGEST_LENGTH / sizeof(uint64_t); k++) { + REVERSE64(pctx->g[k], pctx->g[k]); + } +#endif + sha512_Transform(pctx->odig, pctx->g, pctx->g); + memcpy(pctx->f, pctx->g, SHA512_DIGEST_LENGTH); + pctx->first = 1; +} + +void pbkdf2_hmac_sha512_Update(PBKDF2_HMAC_SHA512_CTX *pctx, + uint32_t iterations) { + for (uint32_t i = pctx->first; i < iterations; i++) { + sha512_Transform(pctx->idig, pctx->g, pctx->g); + sha512_Transform(pctx->odig, pctx->g, pctx->g); + for (uint32_t j = 0; j < SHA512_DIGEST_LENGTH / sizeof(uint64_t); j++) { + pctx->f[j] ^= pctx->g[j]; + } + } + pctx->first = 0; +} + +void pbkdf2_hmac_sha512_Final(PBKDF2_HMAC_SHA512_CTX *pctx, uint8_t *key) { +#if BYTE_ORDER == LITTLE_ENDIAN + for (uint32_t k = 0; k < SHA512_DIGEST_LENGTH / sizeof(uint64_t); k++) { + REVERSE64(pctx->f[k], pctx->f[k]); + } +#endif + memcpy(key, pctx->f, SHA512_DIGEST_LENGTH); + memzero(pctx, sizeof(PBKDF2_HMAC_SHA512_CTX)); +} + +void pbkdf2_hmac_sha512(const uint8_t *pass, int passlen, const uint8_t *salt, + int saltlen, uint32_t iterations, uint8_t *key, + int keylen) { + uint32_t last_block_size = keylen % SHA512_DIGEST_LENGTH; + uint32_t blocks_count = keylen / SHA512_DIGEST_LENGTH; + if (last_block_size) { + blocks_count++; + } else { + last_block_size = SHA512_DIGEST_LENGTH; + } + for (uint32_t blocknr = 1; blocknr <= blocks_count; blocknr++) { + PBKDF2_HMAC_SHA512_CTX pctx = {0}; + pbkdf2_hmac_sha512_Init(&pctx, pass, passlen, salt, saltlen, blocknr); + pbkdf2_hmac_sha512_Update(&pctx, iterations); + uint8_t digest[SHA512_DIGEST_LENGTH] = {0}; + pbkdf2_hmac_sha512_Final(&pctx, digest); + uint32_t key_offset = (blocknr - 1) * SHA512_DIGEST_LENGTH; + if (blocknr < blocks_count) { + memcpy(key + key_offset, digest, SHA512_DIGEST_LENGTH); + } else { + memcpy(key + key_offset, digest, last_block_size); + } + } +} diff --git a/src/crypto/bip39/pbkdf2.h b/src/crypto/bip39/pbkdf2.h new file mode 100644 index 000000000..c2e3f04a6 --- /dev/null +++ b/src/crypto/bip39/pbkdf2.h @@ -0,0 +1,66 @@ +/** + * Copyright (c) 2013-2014 Tomas Dzetkulic + * Copyright (c) 2013-2014 Pavol Rusnak + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __PBKDF2_H__ +#define __PBKDF2_H__ + +#include +#include "sha2.h" + +typedef struct _PBKDF2_HMAC_SHA256_CTX { + uint32_t odig[SHA256_DIGEST_LENGTH / sizeof(uint32_t)]; + uint32_t idig[SHA256_DIGEST_LENGTH / sizeof(uint32_t)]; + uint32_t f[SHA256_DIGEST_LENGTH / sizeof(uint32_t)]; + uint32_t g[SHA256_BLOCK_LENGTH / sizeof(uint32_t)]; + char first; +} PBKDF2_HMAC_SHA256_CTX; + +typedef struct _PBKDF2_HMAC_SHA512_CTX { + uint64_t odig[SHA512_DIGEST_LENGTH / sizeof(uint64_t)]; + uint64_t idig[SHA512_DIGEST_LENGTH / sizeof(uint64_t)]; + uint64_t f[SHA512_DIGEST_LENGTH / sizeof(uint64_t)]; + uint64_t g[SHA512_BLOCK_LENGTH / sizeof(uint64_t)]; + char first; +} PBKDF2_HMAC_SHA512_CTX; + +void pbkdf2_hmac_sha256_Init(PBKDF2_HMAC_SHA256_CTX *pctx, const uint8_t *pass, + int passlen, const uint8_t *salt, int saltlen, + uint32_t blocknr); +void pbkdf2_hmac_sha256_Update(PBKDF2_HMAC_SHA256_CTX *pctx, + uint32_t iterations); +void pbkdf2_hmac_sha256_Final(PBKDF2_HMAC_SHA256_CTX *pctx, uint8_t *key); +void pbkdf2_hmac_sha256(const uint8_t *pass, int passlen, const uint8_t *salt, + int saltlen, uint32_t iterations, uint8_t *key, + int keylen); + +void pbkdf2_hmac_sha512_Init(PBKDF2_HMAC_SHA512_CTX *pctx, const uint8_t *pass, + int passlen, const uint8_t *salt, int saltlen, + uint32_t blocknr); +void pbkdf2_hmac_sha512_Update(PBKDF2_HMAC_SHA512_CTX *pctx, + uint32_t iterations); +void pbkdf2_hmac_sha512_Final(PBKDF2_HMAC_SHA512_CTX *pctx, uint8_t *key); +void pbkdf2_hmac_sha512(const uint8_t *pass, int passlen, const uint8_t *salt, + int saltlen, uint32_t iterations, uint8_t *key, + int keylen); + +#endif diff --git a/src/crypto/bip39/rand.c b/src/crypto/bip39/rand.c new file mode 100644 index 000000000..ea95d143b --- /dev/null +++ b/src/crypto/bip39/rand.c @@ -0,0 +1,81 @@ +/** + * Copyright (c) 2013-2014 Tomas Dzetkulic + * Copyright (c) 2013-2014 Pavol Rusnak + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "rand.h" + +#ifndef RAND_PLATFORM_INDEPENDENT + +#pragma message( \ + "NOT SUITABLE FOR PRODUCTION USE! Replace random32() function with your own secure code.") + +// The following code is not supposed to be used in a production environment. +// It's included only to make the library testable. +// The message above tries to prevent any accidental use outside of the test +// environment. +// +// You are supposed to replace the random8() and random32() function with your +// own secure code. There is also a possibility to replace the random_buffer() +// function as it is defined as a weak symbol. + +static uint32_t seed = 0; + +void random_reseed(const uint32_t value) { seed = value; } + +uint32_t random32(void) { + // Linear congruential generator from Numerical Recipes + // https://en.wikipedia.org/wiki/Linear_congruential_generator + seed = 1664525 * seed + 1013904223; + return seed; +} + +#endif /* RAND_PLATFORM_INDEPENDENT */ + +// +// The following code is platform independent +// + +void __attribute__((weak)) random_buffer(uint8_t *buf, size_t len) { + uint32_t r = 0; + for (size_t i = 0; i < len; i++) { + if (i % 4 == 0) { + r = random32(); + } + buf[i] = (r >> ((i % 4) * 8)) & 0xFF; + } +} + +uint32_t random_uniform(uint32_t n) { + uint32_t x = 0, max = 0xFFFFFFFF - (0xFFFFFFFF % n); + while ((x = random32()) >= max) + ; + return x / (max / n); +} + +void random_permute(char *str, size_t len) { + for (int i = len - 1; i >= 1; i--) { + int j = random_uniform(i + 1); + char t = str[j]; + str[j] = str[i]; + str[i] = t; + } +} diff --git a/src/crypto/bip39/rand.h b/src/crypto/bip39/rand.h new file mode 100644 index 000000000..49d9cfaf2 --- /dev/null +++ b/src/crypto/bip39/rand.h @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2013-2014 Tomas Dzetkulic + * Copyright (c) 2013-2014 Pavol Rusnak + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __RAND_H__ +#define __RAND_H__ + +#include +#include + +void random_reseed(const uint32_t value); +uint32_t random32(void); +void random_buffer(uint8_t *buf, size_t len); + +uint32_t random_uniform(uint32_t n); +void random_permute(char *buf, size_t len); + +#endif diff --git a/src/crypto/bip39/sha2.c b/src/crypto/bip39/sha2.c new file mode 100644 index 000000000..b37e5cb41 --- /dev/null +++ b/src/crypto/bip39/sha2.c @@ -0,0 +1,1283 @@ +/** + * Copyright (c) 2000-2001 Aaron D. Gifford + * Copyright (c) 2013-2014 Pavol Rusnak + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include "sha2.h" +#include "memzero.h" + +/* + * ASSERT NOTE: + * Some sanity checking code is included using assert(). On my FreeBSD + * system, this additional code can be removed by compiling with NDEBUG + * defined. Check your own systems manpage on assert() to see how to + * compile WITHOUT the sanity checking code on your system. + * + * UNROLLED TRANSFORM LOOP NOTE: + * You can define SHA2_UNROLL_TRANSFORM to use the unrolled transform + * loop version for the hash transform rounds (defined using macros + * later in this file). Either define on the command line, for example: + * + * cc -DSHA2_UNROLL_TRANSFORM -o sha2 sha2.c sha2prog.c + * + * or define below: + * + * #define SHA2_UNROLL_TRANSFORM + * + */ + + +/*** SHA-256/384/512 Machine Architecture Definitions *****************/ +/* + * BYTE_ORDER NOTE: + * + * Please make sure that your system defines BYTE_ORDER. If your + * architecture is little-endian, make sure it also defines + * LITTLE_ENDIAN and that the two (BYTE_ORDER and LITTLE_ENDIAN) are + * equivilent. + * + * If your system does not define the above, then you can do so by + * hand like this: + * + * #define LITTLE_ENDIAN 1234 + * #define BIG_ENDIAN 4321 + * + * And for little-endian machines, add: + * + * #define BYTE_ORDER LITTLE_ENDIAN + * + * Or for big-endian machines: + * + * #define BYTE_ORDER BIG_ENDIAN + * + * The FreeBSD machine this was written on defines BYTE_ORDER + * appropriately by including (which in turn includes + * where the appropriate definitions are actually + * made). + */ + +#if !defined(BYTE_ORDER) || (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN) +#error Define BYTE_ORDER to be equal to either LITTLE_ENDIAN or BIG_ENDIAN +#endif + +typedef uint8_t sha2_byte; /* Exactly 1 byte */ +typedef uint32_t sha2_word32; /* Exactly 4 bytes */ +typedef uint64_t sha2_word64; /* Exactly 8 bytes */ + +/*** SHA-256/384/512 Various Length Definitions ***********************/ +/* NOTE: Most of these are in sha2.h */ +#define SHA1_SHORT_BLOCK_LENGTH (SHA1_BLOCK_LENGTH - 8) +#define SHA256_SHORT_BLOCK_LENGTH (SHA256_BLOCK_LENGTH - 8) +#define SHA512_SHORT_BLOCK_LENGTH (SHA512_BLOCK_LENGTH - 16) + +/* + * Macro for incrementally adding the unsigned 64-bit integer n to the + * unsigned 128-bit integer (represented using a two-element array of + * 64-bit words): + */ +#define ADDINC128(w,n) { \ + (w)[0] += (sha2_word64)(n); \ + if ((w)[0] < (n)) { \ + (w)[1]++; \ + } \ +} + +#define MEMCPY_BCOPY(d,s,l) memcpy((d), (s), (l)) + +/*** THE SIX LOGICAL FUNCTIONS ****************************************/ +/* + * Bit shifting and rotation (used by the six SHA-XYZ logical functions: + * + * NOTE: In the original SHA-256/384/512 document, the shift-right + * function was named R and the rotate-right function was called S. + * (See: http://csrc.nist.gov/cryptval/shs/sha256-384-512.pdf on the + * web.) + * + * The newer NIST FIPS 180-2 document uses a much clearer naming + * scheme, SHR for shift-right, ROTR for rotate-right, and ROTL for + * rotate-left. (See: + * http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf + * on the web.) + * + * WARNING: These macros must be used cautiously, since they reference + * supplied parameters sometimes more than once, and thus could have + * unexpected side-effects if used without taking this into account. + */ + +/* Shift-right (used in SHA-256, SHA-384, and SHA-512): */ +#define SHR(b,x) ((x) >> (b)) +/* 32-bit Rotate-right (used in SHA-256): */ +#define ROTR32(b,x) (((x) >> (b)) | ((x) << (32 - (b)))) +/* 64-bit Rotate-right (used in SHA-384 and SHA-512): */ +#define ROTR64(b,x) (((x) >> (b)) | ((x) << (64 - (b)))) +/* 32-bit Rotate-left (used in SHA-1): */ +#define ROTL32(b,x) (((x) << (b)) | ((x) >> (32 - (b)))) + +/* Two of six logical functions used in SHA-1, SHA-256, SHA-384, and SHA-512: */ +#define Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z))) +#define Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z))) + +/* Function used in SHA-1: */ +#define Parity(x,y,z) ((x) ^ (y) ^ (z)) + +/* Four of six logical functions used in SHA-256: */ +#define Sigma0_256(x) (ROTR32(2, (x)) ^ ROTR32(13, (x)) ^ ROTR32(22, (x))) +#define Sigma1_256(x) (ROTR32(6, (x)) ^ ROTR32(11, (x)) ^ ROTR32(25, (x))) +#define sigma0_256(x) (ROTR32(7, (x)) ^ ROTR32(18, (x)) ^ SHR(3 , (x))) +#define sigma1_256(x) (ROTR32(17, (x)) ^ ROTR32(19, (x)) ^ SHR(10, (x))) + +/* Four of six logical functions used in SHA-384 and SHA-512: */ +#define Sigma0_512(x) (ROTR64(28, (x)) ^ ROTR64(34, (x)) ^ ROTR64(39, (x))) +#define Sigma1_512(x) (ROTR64(14, (x)) ^ ROTR64(18, (x)) ^ ROTR64(41, (x))) +#define sigma0_512(x) (ROTR64( 1, (x)) ^ ROTR64( 8, (x)) ^ SHR( 7, (x))) +#define sigma1_512(x) (ROTR64(19, (x)) ^ ROTR64(61, (x)) ^ SHR( 6, (x))) + +/*** INTERNAL FUNCTION PROTOTYPES *************************************/ +/* NOTE: These should not be accessed directly from outside this + * library -- they are intended for private internal visibility/use + * only. + */ +static void sha512_Last(SHA512_CTX*); + + +/*** SHA-XYZ INITIAL HASH VALUES AND CONSTANTS ************************/ + +/* Hash constant words K for SHA-1: */ +#define K1_0_TO_19 0x5a827999UL +#define K1_20_TO_39 0x6ed9eba1UL +#define K1_40_TO_59 0x8f1bbcdcUL +#define K1_60_TO_79 0xca62c1d6UL + +/* Initial hash value H for SHA-1: */ +const sha2_word32 sha1_initial_hash_value[SHA1_DIGEST_LENGTH / sizeof(sha2_word32)] = { + 0x67452301UL, + 0xefcdab89UL, + 0x98badcfeUL, + 0x10325476UL, + 0xc3d2e1f0UL +}; + +/* Hash constant words K for SHA-256: */ +static const sha2_word32 K256[64] = { + 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, + 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, + 0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL, + 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0xc19bf174UL, + 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL, + 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL, + 0x983e5152UL, 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL, + 0xc6e00bf3UL, 0xd5a79147UL, 0x06ca6351UL, 0x14292967UL, + 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 0x53380d13UL, + 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL, + 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL, + 0xd192e819UL, 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL, + 0x19a4c116UL, 0x1e376c08UL, 0x2748774cUL, 0x34b0bcb5UL, + 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 0x682e6ff3UL, + 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL, + 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL +}; + +/* Initial hash value H for SHA-256: */ +const sha2_word32 sha256_initial_hash_value[8] = { + 0x6a09e667UL, + 0xbb67ae85UL, + 0x3c6ef372UL, + 0xa54ff53aUL, + 0x510e527fUL, + 0x9b05688cUL, + 0x1f83d9abUL, + 0x5be0cd19UL +}; + +/* Hash constant words K for SHA-384 and SHA-512: */ +static const sha2_word64 K512[80] = { + 0x428a2f98d728ae22ULL, 0x7137449123ef65cdULL, + 0xb5c0fbcfec4d3b2fULL, 0xe9b5dba58189dbbcULL, + 0x3956c25bf348b538ULL, 0x59f111f1b605d019ULL, + 0x923f82a4af194f9bULL, 0xab1c5ed5da6d8118ULL, + 0xd807aa98a3030242ULL, 0x12835b0145706fbeULL, + 0x243185be4ee4b28cULL, 0x550c7dc3d5ffb4e2ULL, + 0x72be5d74f27b896fULL, 0x80deb1fe3b1696b1ULL, + 0x9bdc06a725c71235ULL, 0xc19bf174cf692694ULL, + 0xe49b69c19ef14ad2ULL, 0xefbe4786384f25e3ULL, + 0x0fc19dc68b8cd5b5ULL, 0x240ca1cc77ac9c65ULL, + 0x2de92c6f592b0275ULL, 0x4a7484aa6ea6e483ULL, + 0x5cb0a9dcbd41fbd4ULL, 0x76f988da831153b5ULL, + 0x983e5152ee66dfabULL, 0xa831c66d2db43210ULL, + 0xb00327c898fb213fULL, 0xbf597fc7beef0ee4ULL, + 0xc6e00bf33da88fc2ULL, 0xd5a79147930aa725ULL, + 0x06ca6351e003826fULL, 0x142929670a0e6e70ULL, + 0x27b70a8546d22ffcULL, 0x2e1b21385c26c926ULL, + 0x4d2c6dfc5ac42aedULL, 0x53380d139d95b3dfULL, + 0x650a73548baf63deULL, 0x766a0abb3c77b2a8ULL, + 0x81c2c92e47edaee6ULL, 0x92722c851482353bULL, + 0xa2bfe8a14cf10364ULL, 0xa81a664bbc423001ULL, + 0xc24b8b70d0f89791ULL, 0xc76c51a30654be30ULL, + 0xd192e819d6ef5218ULL, 0xd69906245565a910ULL, + 0xf40e35855771202aULL, 0x106aa07032bbd1b8ULL, + 0x19a4c116b8d2d0c8ULL, 0x1e376c085141ab53ULL, + 0x2748774cdf8eeb99ULL, 0x34b0bcb5e19b48a8ULL, + 0x391c0cb3c5c95a63ULL, 0x4ed8aa4ae3418acbULL, + 0x5b9cca4f7763e373ULL, 0x682e6ff3d6b2b8a3ULL, + 0x748f82ee5defb2fcULL, 0x78a5636f43172f60ULL, + 0x84c87814a1f0ab72ULL, 0x8cc702081a6439ecULL, + 0x90befffa23631e28ULL, 0xa4506cebde82bde9ULL, + 0xbef9a3f7b2c67915ULL, 0xc67178f2e372532bULL, + 0xca273eceea26619cULL, 0xd186b8c721c0c207ULL, + 0xeada7dd6cde0eb1eULL, 0xf57d4f7fee6ed178ULL, + 0x06f067aa72176fbaULL, 0x0a637dc5a2c898a6ULL, + 0x113f9804bef90daeULL, 0x1b710b35131c471bULL, + 0x28db77f523047d84ULL, 0x32caab7b40c72493ULL, + 0x3c9ebe0a15c9bebcULL, 0x431d67c49c100d4cULL, + 0x4cc5d4becb3e42b6ULL, 0x597f299cfc657e2aULL, + 0x5fcb6fab3ad6faecULL, 0x6c44198c4a475817ULL +}; + +/* Initial hash value H for SHA-512 */ +const sha2_word64 sha512_initial_hash_value[8] = { + 0x6a09e667f3bcc908ULL, + 0xbb67ae8584caa73bULL, + 0x3c6ef372fe94f82bULL, + 0xa54ff53a5f1d36f1ULL, + 0x510e527fade682d1ULL, + 0x9b05688c2b3e6c1fULL, + 0x1f83d9abfb41bd6bULL, + 0x5be0cd19137e2179ULL +}; + +/* + * Constant used by SHA256/384/512_End() functions for converting the + * digest to a readable hexadecimal character string: + */ +static const char *sha2_hex_digits = "0123456789abcdef"; + + +/*** SHA-1: ***********************************************************/ +void sha1_Init(SHA1_CTX* context) { + MEMCPY_BCOPY(context->state, sha1_initial_hash_value, SHA1_DIGEST_LENGTH); + memzero(context->buffer, SHA1_BLOCK_LENGTH); + context->bitcount = 0; +} + +#ifdef SHA2_UNROLL_TRANSFORM + +/* Unrolled SHA-1 round macros: */ + +#define ROUND1_0_TO_15(a,b,c,d,e) \ + (e) = ROTL32(5, (a)) + Ch((b), (c), (d)) + (e) + \ + K1_0_TO_19 + ( W1[j] = *data++ ); \ + (b) = ROTL32(30, (b)); \ + j++; + +#define ROUND1_16_TO_19(a,b,c,d,e) \ + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; \ + (e) = ROTL32(5, a) + Ch(b,c,d) + e + K1_0_TO_19 + ( W1[j&0x0f] = ROTL32(1, T1) ); \ + (b) = ROTL32(30, b); \ + j++; + +#define ROUND1_20_TO_39(a,b,c,d,e) \ + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; \ + (e) = ROTL32(5, a) + Parity(b,c,d) + e + K1_20_TO_39 + ( W1[j&0x0f] = ROTL32(1, T1) ); \ + (b) = ROTL32(30, b); \ + j++; + +#define ROUND1_40_TO_59(a,b,c,d,e) \ + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; \ + (e) = ROTL32(5, a) + Maj(b,c,d) + e + K1_40_TO_59 + ( W1[j&0x0f] = ROTL32(1, T1) ); \ + (b) = ROTL32(30, b); \ + j++; + +#define ROUND1_60_TO_79(a,b,c,d,e) \ + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; \ + (e) = ROTL32(5, a) + Parity(b,c,d) + e + K1_60_TO_79 + ( W1[j&0x0f] = ROTL32(1, T1) ); \ + (b) = ROTL32(30, b); \ + j++; + +void sha1_Transform(const sha2_word32* state_in, const sha2_word32* data, sha2_word32* state_out) { + sha2_word32 a = 0, b = 0, c = 0, d = 0, e = 0; + sha2_word32 T1 = 0; + sha2_word32 W1[16] = {0}; + int j = 0; + + /* Initialize registers with the prev. intermediate value */ + a = state_in[0]; + b = state_in[1]; + c = state_in[2]; + d = state_in[3]; + e = state_in[4]; + + j = 0; + + /* Rounds 0 to 15 unrolled: */ + ROUND1_0_TO_15(a,b,c,d,e); + ROUND1_0_TO_15(e,a,b,c,d); + ROUND1_0_TO_15(d,e,a,b,c); + ROUND1_0_TO_15(c,d,e,a,b); + ROUND1_0_TO_15(b,c,d,e,a); + ROUND1_0_TO_15(a,b,c,d,e); + ROUND1_0_TO_15(e,a,b,c,d); + ROUND1_0_TO_15(d,e,a,b,c); + ROUND1_0_TO_15(c,d,e,a,b); + ROUND1_0_TO_15(b,c,d,e,a); + ROUND1_0_TO_15(a,b,c,d,e); + ROUND1_0_TO_15(e,a,b,c,d); + ROUND1_0_TO_15(d,e,a,b,c); + ROUND1_0_TO_15(c,d,e,a,b); + ROUND1_0_TO_15(b,c,d,e,a); + ROUND1_0_TO_15(a,b,c,d,e); + + /* Rounds 16 to 19 unrolled: */ + ROUND1_16_TO_19(e,a,b,c,d); + ROUND1_16_TO_19(d,e,a,b,c); + ROUND1_16_TO_19(c,d,e,a,b); + ROUND1_16_TO_19(b,c,d,e,a); + + /* Rounds 20 to 39 unrolled: */ + ROUND1_20_TO_39(a,b,c,d,e); + ROUND1_20_TO_39(e,a,b,c,d); + ROUND1_20_TO_39(d,e,a,b,c); + ROUND1_20_TO_39(c,d,e,a,b); + ROUND1_20_TO_39(b,c,d,e,a); + ROUND1_20_TO_39(a,b,c,d,e); + ROUND1_20_TO_39(e,a,b,c,d); + ROUND1_20_TO_39(d,e,a,b,c); + ROUND1_20_TO_39(c,d,e,a,b); + ROUND1_20_TO_39(b,c,d,e,a); + ROUND1_20_TO_39(a,b,c,d,e); + ROUND1_20_TO_39(e,a,b,c,d); + ROUND1_20_TO_39(d,e,a,b,c); + ROUND1_20_TO_39(c,d,e,a,b); + ROUND1_20_TO_39(b,c,d,e,a); + ROUND1_20_TO_39(a,b,c,d,e); + ROUND1_20_TO_39(e,a,b,c,d); + ROUND1_20_TO_39(d,e,a,b,c); + ROUND1_20_TO_39(c,d,e,a,b); + ROUND1_20_TO_39(b,c,d,e,a); + + /* Rounds 40 to 59 unrolled: */ + ROUND1_40_TO_59(a,b,c,d,e); + ROUND1_40_TO_59(e,a,b,c,d); + ROUND1_40_TO_59(d,e,a,b,c); + ROUND1_40_TO_59(c,d,e,a,b); + ROUND1_40_TO_59(b,c,d,e,a); + ROUND1_40_TO_59(a,b,c,d,e); + ROUND1_40_TO_59(e,a,b,c,d); + ROUND1_40_TO_59(d,e,a,b,c); + ROUND1_40_TO_59(c,d,e,a,b); + ROUND1_40_TO_59(b,c,d,e,a); + ROUND1_40_TO_59(a,b,c,d,e); + ROUND1_40_TO_59(e,a,b,c,d); + ROUND1_40_TO_59(d,e,a,b,c); + ROUND1_40_TO_59(c,d,e,a,b); + ROUND1_40_TO_59(b,c,d,e,a); + ROUND1_40_TO_59(a,b,c,d,e); + ROUND1_40_TO_59(e,a,b,c,d); + ROUND1_40_TO_59(d,e,a,b,c); + ROUND1_40_TO_59(c,d,e,a,b); + ROUND1_40_TO_59(b,c,d,e,a); + + /* Rounds 60 to 79 unrolled: */ + ROUND1_60_TO_79(a,b,c,d,e); + ROUND1_60_TO_79(e,a,b,c,d); + ROUND1_60_TO_79(d,e,a,b,c); + ROUND1_60_TO_79(c,d,e,a,b); + ROUND1_60_TO_79(b,c,d,e,a); + ROUND1_60_TO_79(a,b,c,d,e); + ROUND1_60_TO_79(e,a,b,c,d); + ROUND1_60_TO_79(d,e,a,b,c); + ROUND1_60_TO_79(c,d,e,a,b); + ROUND1_60_TO_79(b,c,d,e,a); + ROUND1_60_TO_79(a,b,c,d,e); + ROUND1_60_TO_79(e,a,b,c,d); + ROUND1_60_TO_79(d,e,a,b,c); + ROUND1_60_TO_79(c,d,e,a,b); + ROUND1_60_TO_79(b,c,d,e,a); + ROUND1_60_TO_79(a,b,c,d,e); + ROUND1_60_TO_79(e,a,b,c,d); + ROUND1_60_TO_79(d,e,a,b,c); + ROUND1_60_TO_79(c,d,e,a,b); + ROUND1_60_TO_79(b,c,d,e,a); + + /* Compute the current intermediate hash value */ + state_out[0] = state_in[0] + a; + state_out[1] = state_in[1] + b; + state_out[2] = state_in[2] + c; + state_out[3] = state_in[3] + d; + state_out[4] = state_in[4] + e; + + /* Clean up */ + a = b = c = d = e = T1 = 0; +} + +#else /* SHA2_UNROLL_TRANSFORM */ + +void sha1_Transform(const sha2_word32* state_in, const sha2_word32* data, sha2_word32* state_out) { + sha2_word32 a = 0, b = 0, c = 0, d = 0, e = 0; + sha2_word32 T1 = 0; + sha2_word32 W1[16] = {0}; + int j = 0; + + /* Initialize registers with the prev. intermediate value */ + a = state_in[0]; + b = state_in[1]; + c = state_in[2]; + d = state_in[3]; + e = state_in[4]; + j = 0; + do { + T1 = ROTL32(5, a) + Ch(b, c, d) + e + K1_0_TO_19 + (W1[j] = *data++); + e = d; + d = c; + c = ROTL32(30, b); + b = a; + a = T1; + j++; + } while (j < 16); + + do { + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; + T1 = ROTL32(5, a) + Ch(b,c,d) + e + K1_0_TO_19 + (W1[j&0x0f] = ROTL32(1, T1)); + e = d; + d = c; + c = ROTL32(30, b); + b = a; + a = T1; + j++; + } while (j < 20); + + do { + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; + T1 = ROTL32(5, a) + Parity(b,c,d) + e + K1_20_TO_39 + (W1[j&0x0f] = ROTL32(1, T1)); + e = d; + d = c; + c = ROTL32(30, b); + b = a; + a = T1; + j++; + } while (j < 40); + + do { + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; + T1 = ROTL32(5, a) + Maj(b,c,d) + e + K1_40_TO_59 + (W1[j&0x0f] = ROTL32(1, T1)); + e = d; + d = c; + c = ROTL32(30, b); + b = a; + a = T1; + j++; + } while (j < 60); + + do { + T1 = W1[(j+13)&0x0f] ^ W1[(j+8)&0x0f] ^ W1[(j+2)&0x0f] ^ W1[j&0x0f]; + T1 = ROTL32(5, a) + Parity(b,c,d) + e + K1_60_TO_79 + (W1[j&0x0f] = ROTL32(1, T1)); + e = d; + d = c; + c = ROTL32(30, b); + b = a; + a = T1; + j++; + } while (j < 80); + + + /* Compute the current intermediate hash value */ + state_out[0] = state_in[0] + a; + state_out[1] = state_in[1] + b; + state_out[2] = state_in[2] + c; + state_out[3] = state_in[3] + d; + state_out[4] = state_in[4] + e; + + /* Clean up */ + a = b = c = d = e = T1 = 0; +} + +#endif /* SHA2_UNROLL_TRANSFORM */ + +void sha1_Update(SHA1_CTX* context, const sha2_byte *data, size_t len) { + unsigned int freespace = 0, usedspace = 0; + + if (len == 0) { + /* Calling with no data is valid - we do nothing */ + return; + } + + usedspace = (context->bitcount >> 3) % SHA1_BLOCK_LENGTH; + if (usedspace > 0) { + /* Calculate how much free space is available in the buffer */ + freespace = SHA1_BLOCK_LENGTH - usedspace; + + if (len >= freespace) { + /* Fill the buffer completely and process it */ + MEMCPY_BCOPY(((uint8_t*)context->buffer) + usedspace, data, freespace); + context->bitcount += freespace << 3; + len -= freespace; + data += freespace; +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert TO host byte order */ + for (int j = 0; j < 16; j++) { + REVERSE32(context->buffer[j],context->buffer[j]); + } +#endif + sha1_Transform(context->state, context->buffer, context->state); + } else { + /* The buffer is not yet full */ + MEMCPY_BCOPY(((uint8_t*)context->buffer) + usedspace, data, len); + context->bitcount += len << 3; + /* Clean up: */ + usedspace = freespace = 0; + return; + } + } + while (len >= SHA1_BLOCK_LENGTH) { + /* Process as many complete blocks as we can */ + MEMCPY_BCOPY(context->buffer, data, SHA1_BLOCK_LENGTH); +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert TO host byte order */ + for (int j = 0; j < 16; j++) { + REVERSE32(context->buffer[j],context->buffer[j]); + } +#endif + sha1_Transform(context->state, context->buffer, context->state); + context->bitcount += SHA1_BLOCK_LENGTH << 3; + len -= SHA1_BLOCK_LENGTH; + data += SHA1_BLOCK_LENGTH; + } + if (len > 0) { + /* There's left-overs, so save 'em */ + MEMCPY_BCOPY(context->buffer, data, len); + context->bitcount += len << 3; + } + /* Clean up: */ + usedspace = freespace = 0; +} + +void sha1_Final(SHA1_CTX* context, sha2_byte digest[]) { + unsigned int usedspace = 0; + + /* If no digest buffer is passed, we don't bother doing this: */ + if (digest != (sha2_byte*)0) { + usedspace = (context->bitcount >> 3) % SHA1_BLOCK_LENGTH; + /* Begin padding with a 1 bit: */ + ((uint8_t*)context->buffer)[usedspace++] = 0x80; + + if (usedspace > SHA1_SHORT_BLOCK_LENGTH) { + memzero(((uint8_t*)context->buffer) + usedspace, SHA1_BLOCK_LENGTH - usedspace); + +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert TO host byte order */ + for (int j = 0; j < 16; j++) { + REVERSE32(context->buffer[j],context->buffer[j]); + } +#endif + /* Do second-to-last transform: */ + sha1_Transform(context->state, context->buffer, context->state); + + /* And prepare the last transform: */ + usedspace = 0; + } + /* Set-up for the last transform: */ + memzero(((uint8_t*)context->buffer) + usedspace, SHA1_SHORT_BLOCK_LENGTH - usedspace); + +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert TO host byte order */ + for (int j = 0; j < 14; j++) { + REVERSE32(context->buffer[j],context->buffer[j]); + } +#endif + /* Set the bit count: */ + context->buffer[14] = context->bitcount >> 32; + context->buffer[15] = context->bitcount & 0xffffffff; + + /* Final transform: */ + sha1_Transform(context->state, context->buffer, context->state); + +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert FROM host byte order */ + for (int j = 0; j < 5; j++) { + REVERSE32(context->state[j],context->state[j]); + } +#endif + MEMCPY_BCOPY(digest, context->state, SHA1_DIGEST_LENGTH); + } + + /* Clean up state data: */ + memzero(context, sizeof(SHA1_CTX)); + usedspace = 0; +} + +char *sha1_End(SHA1_CTX* context, char buffer[]) { + sha2_byte digest[SHA1_DIGEST_LENGTH] = {0}, *d = digest; + int i = 0; + + if (buffer != (char*)0) { + sha1_Final(context, digest); + + for (i = 0; i < SHA1_DIGEST_LENGTH; i++) { + *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4]; + *buffer++ = sha2_hex_digits[*d & 0x0f]; + d++; + } + *buffer = (char)0; + } else { + memzero(context, sizeof(SHA1_CTX)); + } + memzero(digest, SHA1_DIGEST_LENGTH); + return buffer; +} + +void sha1_Raw(const sha2_byte* data, size_t len, uint8_t digest[SHA1_DIGEST_LENGTH]) { + SHA1_CTX context = {0}; + sha1_Init(&context); + sha1_Update(&context, data, len); + sha1_Final(&context, digest); +} + +char* sha1_Data(const sha2_byte* data, size_t len, char digest[SHA1_DIGEST_STRING_LENGTH]) { + SHA1_CTX context = {0}; + + sha1_Init(&context); + sha1_Update(&context, data, len); + return sha1_End(&context, digest); +} + +/*** SHA-256: *********************************************************/ +void sha256_Init(SHA256_CTX* context) { + if (context == (SHA256_CTX*)0) { + return; + } + MEMCPY_BCOPY(context->state, sha256_initial_hash_value, SHA256_DIGEST_LENGTH); + memzero(context->buffer, SHA256_BLOCK_LENGTH); + context->bitcount = 0; +} + +#ifdef SHA2_UNROLL_TRANSFORM + +/* Unrolled SHA-256 round macros: */ + +#define ROUND256_0_TO_15(a,b,c,d,e,f,g,h) \ + T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + \ + K256[j] + (W256[j] = *data++); \ + (d) += T1; \ + (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \ + j++ + +#define ROUND256(a,b,c,d,e,f,g,h) \ + s0 = W256[(j+1)&0x0f]; \ + s0 = sigma0_256(s0); \ + s1 = W256[(j+14)&0x0f]; \ + s1 = sigma1_256(s1); \ + T1 = (h) + Sigma1_256(e) + Ch((e), (f), (g)) + K256[j] + \ + (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0); \ + (d) += T1; \ + (h) = T1 + Sigma0_256(a) + Maj((a), (b), (c)); \ + j++ + +void sha256_Transform(const sha2_word32* state_in, const sha2_word32* data, sha2_word32* state_out) { + sha2_word32 a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, s0 = 0, s1 = 0; + sha2_word32 T1 = 0; + sha2_word32 W256[16] = {0}; + int j = 0; + + /* Initialize registers with the prev. intermediate value */ + a = state_in[0]; + b = state_in[1]; + c = state_in[2]; + d = state_in[3]; + e = state_in[4]; + f = state_in[5]; + g = state_in[6]; + h = state_in[7]; + + j = 0; + do { + /* Rounds 0 to 15 (unrolled): */ + ROUND256_0_TO_15(a,b,c,d,e,f,g,h); + ROUND256_0_TO_15(h,a,b,c,d,e,f,g); + ROUND256_0_TO_15(g,h,a,b,c,d,e,f); + ROUND256_0_TO_15(f,g,h,a,b,c,d,e); + ROUND256_0_TO_15(e,f,g,h,a,b,c,d); + ROUND256_0_TO_15(d,e,f,g,h,a,b,c); + ROUND256_0_TO_15(c,d,e,f,g,h,a,b); + ROUND256_0_TO_15(b,c,d,e,f,g,h,a); + } while (j < 16); + + /* Now for the remaining rounds to 64: */ + do { + ROUND256(a,b,c,d,e,f,g,h); + ROUND256(h,a,b,c,d,e,f,g); + ROUND256(g,h,a,b,c,d,e,f); + ROUND256(f,g,h,a,b,c,d,e); + ROUND256(e,f,g,h,a,b,c,d); + ROUND256(d,e,f,g,h,a,b,c); + ROUND256(c,d,e,f,g,h,a,b); + ROUND256(b,c,d,e,f,g,h,a); + } while (j < 64); + + /* Compute the current intermediate hash value */ + state_out[0] = state_in[0] + a; + state_out[1] = state_in[1] + b; + state_out[2] = state_in[2] + c; + state_out[3] = state_in[3] + d; + state_out[4] = state_in[4] + e; + state_out[5] = state_in[5] + f; + state_out[6] = state_in[6] + g; + state_out[7] = state_in[7] + h; + + /* Clean up */ + a = b = c = d = e = f = g = h = T1 = 0; +} + +#else /* SHA2_UNROLL_TRANSFORM */ + +void sha256_Transform(const sha2_word32* state_in, const sha2_word32* data, sha2_word32* state_out) { + sha2_word32 a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, s0 = 0, s1 = 0; + sha2_word32 T1 = 0, T2 = 0 , W256[16] = {0}; + int j = 0; + + /* Initialize registers with the prev. intermediate value */ + a = state_in[0]; + b = state_in[1]; + c = state_in[2]; + d = state_in[3]; + e = state_in[4]; + f = state_in[5]; + g = state_in[6]; + h = state_in[7]; + + j = 0; + do { + /* Apply the SHA-256 compression function to update a..h with copy */ + T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + (W256[j] = *data++); + T2 = Sigma0_256(a) + Maj(a, b, c); + h = g; + g = f; + f = e; + e = d + T1; + d = c; + c = b; + b = a; + a = T1 + T2; + + j++; + } while (j < 16); + + do { + /* Part of the message block expansion: */ + s0 = W256[(j+1)&0x0f]; + s0 = sigma0_256(s0); + s1 = W256[(j+14)&0x0f]; + s1 = sigma1_256(s1); + + /* Apply the SHA-256 compression function to update a..h */ + T1 = h + Sigma1_256(e) + Ch(e, f, g) + K256[j] + + (W256[j&0x0f] += s1 + W256[(j+9)&0x0f] + s0); + T2 = Sigma0_256(a) + Maj(a, b, c); + h = g; + g = f; + f = e; + e = d + T1; + d = c; + c = b; + b = a; + a = T1 + T2; + + j++; + } while (j < 64); + + /* Compute the current intermediate hash value */ + state_out[0] = state_in[0] + a; + state_out[1] = state_in[1] + b; + state_out[2] = state_in[2] + c; + state_out[3] = state_in[3] + d; + state_out[4] = state_in[4] + e; + state_out[5] = state_in[5] + f; + state_out[6] = state_in[6] + g; + state_out[7] = state_in[7] + h; + + /* Clean up */ + a = b = c = d = e = f = g = h = T1 = T2 = 0; +} + +#endif /* SHA2_UNROLL_TRANSFORM */ + +void sha256_Update(SHA256_CTX* context, const sha2_byte *data, size_t len) { + unsigned int freespace = 0, usedspace = 0; + + if (len == 0) { + /* Calling with no data is valid - we do nothing */ + return; + } + + usedspace = (context->bitcount >> 3) % SHA256_BLOCK_LENGTH; + if (usedspace > 0) { + /* Calculate how much free space is available in the buffer */ + freespace = SHA256_BLOCK_LENGTH - usedspace; + + if (len >= freespace) { + /* Fill the buffer completely and process it */ + MEMCPY_BCOPY(((uint8_t*)context->buffer) + usedspace, data, freespace); + context->bitcount += freespace << 3; + len -= freespace; + data += freespace; +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert TO host byte order */ + for (int j = 0; j < 16; j++) { + REVERSE32(context->buffer[j],context->buffer[j]); + } +#endif + sha256_Transform(context->state, context->buffer, context->state); + } else { + /* The buffer is not yet full */ + MEMCPY_BCOPY(((uint8_t*)context->buffer) + usedspace, data, len); + context->bitcount += len << 3; + /* Clean up: */ + usedspace = freespace = 0; + return; + } + } + while (len >= SHA256_BLOCK_LENGTH) { + /* Process as many complete blocks as we can */ + MEMCPY_BCOPY(context->buffer, data, SHA256_BLOCK_LENGTH); +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert TO host byte order */ + for (int j = 0; j < 16; j++) { + REVERSE32(context->buffer[j],context->buffer[j]); + } +#endif + sha256_Transform(context->state, context->buffer, context->state); + context->bitcount += SHA256_BLOCK_LENGTH << 3; + len -= SHA256_BLOCK_LENGTH; + data += SHA256_BLOCK_LENGTH; + } + if (len > 0) { + /* There's left-overs, so save 'em */ + MEMCPY_BCOPY(context->buffer, data, len); + context->bitcount += len << 3; + } + /* Clean up: */ + usedspace = freespace = 0; +} + +void sha256_Final(SHA256_CTX* context, sha2_byte digest[]) { + unsigned int usedspace = 0; + + /* If no digest buffer is passed, we don't bother doing this: */ + if (digest != (sha2_byte*)0) { + usedspace = (context->bitcount >> 3) % SHA256_BLOCK_LENGTH; + /* Begin padding with a 1 bit: */ + ((uint8_t*)context->buffer)[usedspace++] = 0x80; + + if (usedspace > SHA256_SHORT_BLOCK_LENGTH) { + memzero(((uint8_t*)context->buffer) + usedspace, SHA256_BLOCK_LENGTH - usedspace); + +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert TO host byte order */ + for (int j = 0; j < 16; j++) { + REVERSE32(context->buffer[j],context->buffer[j]); + } +#endif + /* Do second-to-last transform: */ + sha256_Transform(context->state, context->buffer, context->state); + + /* And prepare the last transform: */ + usedspace = 0; + } + /* Set-up for the last transform: */ + memzero(((uint8_t*)context->buffer) + usedspace, SHA256_SHORT_BLOCK_LENGTH - usedspace); + +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert TO host byte order */ + for (int j = 0; j < 14; j++) { + REVERSE32(context->buffer[j],context->buffer[j]); + } +#endif + /* Set the bit count: */ + context->buffer[14] = context->bitcount >> 32; + context->buffer[15] = context->bitcount & 0xffffffff; + + /* Final transform: */ + sha256_Transform(context->state, context->buffer, context->state); + +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert FROM host byte order */ + for (int j = 0; j < 8; j++) { + REVERSE32(context->state[j],context->state[j]); + } +#endif + MEMCPY_BCOPY(digest, context->state, SHA256_DIGEST_LENGTH); + } + + /* Clean up state data: */ + memzero(context, sizeof(SHA256_CTX)); + usedspace = 0; +} + +char *sha256_End(SHA256_CTX* context, char buffer[]) { + sha2_byte digest[SHA256_DIGEST_LENGTH] = {0}, *d = digest; + int i = 0; + + if (buffer != (char*)0) { + sha256_Final(context, digest); + + for (i = 0; i < SHA256_DIGEST_LENGTH; i++) { + *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4]; + *buffer++ = sha2_hex_digits[*d & 0x0f]; + d++; + } + *buffer = (char)0; + } else { + memzero(context, sizeof(SHA256_CTX)); + } + memzero(digest, SHA256_DIGEST_LENGTH); + return buffer; +} + +void sha256_Raw(const sha2_byte* data, size_t len, uint8_t digest[SHA256_DIGEST_LENGTH]) { + SHA256_CTX context = {0}; + sha256_Init(&context); + sha256_Update(&context, data, len); + sha256_Final(&context, digest); +} + +char* sha256_Data(const sha2_byte* data, size_t len, char digest[SHA256_DIGEST_STRING_LENGTH]) { + SHA256_CTX context = {0}; + + sha256_Init(&context); + sha256_Update(&context, data, len); + return sha256_End(&context, digest); +} + + +/*** SHA-512: *********************************************************/ +void sha512_Init(SHA512_CTX* context) { + if (context == (SHA512_CTX*)0) { + return; + } + MEMCPY_BCOPY(context->state, sha512_initial_hash_value, SHA512_DIGEST_LENGTH); + memzero(context->buffer, SHA512_BLOCK_LENGTH); + context->bitcount[0] = context->bitcount[1] = 0; +} + +#ifdef SHA2_UNROLL_TRANSFORM + +/* Unrolled SHA-512 round macros: */ +#define ROUND512_0_TO_15(a,b,c,d,e,f,g,h) \ + T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + \ + K512[j] + (W512[j] = *data++); \ + (d) += T1; \ + (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \ + j++ + +#define ROUND512(a,b,c,d,e,f,g,h) \ + s0 = W512[(j+1)&0x0f]; \ + s0 = sigma0_512(s0); \ + s1 = W512[(j+14)&0x0f]; \ + s1 = sigma1_512(s1); \ + T1 = (h) + Sigma1_512(e) + Ch((e), (f), (g)) + K512[j] + \ + (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0); \ + (d) += T1; \ + (h) = T1 + Sigma0_512(a) + Maj((a), (b), (c)); \ + j++ + +void sha512_Transform(const sha2_word64* state_in, const sha2_word64* data, sha2_word64* state_out) { + sha2_word64 a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, s0 = 0, s1 = 0; + sha2_word64 T1 = 0, W512[16] = {0}; + int j = 0; + + /* Initialize registers with the prev. intermediate value */ + a = state_in[0]; + b = state_in[1]; + c = state_in[2]; + d = state_in[3]; + e = state_in[4]; + f = state_in[5]; + g = state_in[6]; + h = state_in[7]; + + j = 0; + do { + ROUND512_0_TO_15(a,b,c,d,e,f,g,h); + ROUND512_0_TO_15(h,a,b,c,d,e,f,g); + ROUND512_0_TO_15(g,h,a,b,c,d,e,f); + ROUND512_0_TO_15(f,g,h,a,b,c,d,e); + ROUND512_0_TO_15(e,f,g,h,a,b,c,d); + ROUND512_0_TO_15(d,e,f,g,h,a,b,c); + ROUND512_0_TO_15(c,d,e,f,g,h,a,b); + ROUND512_0_TO_15(b,c,d,e,f,g,h,a); + } while (j < 16); + + /* Now for the remaining rounds up to 79: */ + do { + ROUND512(a,b,c,d,e,f,g,h); + ROUND512(h,a,b,c,d,e,f,g); + ROUND512(g,h,a,b,c,d,e,f); + ROUND512(f,g,h,a,b,c,d,e); + ROUND512(e,f,g,h,a,b,c,d); + ROUND512(d,e,f,g,h,a,b,c); + ROUND512(c,d,e,f,g,h,a,b); + ROUND512(b,c,d,e,f,g,h,a); + } while (j < 80); + + /* Compute the current intermediate hash value */ + state_out[0] = state_in[0] + a; + state_out[1] = state_in[1] + b; + state_out[2] = state_in[2] + c; + state_out[3] = state_in[3] + d; + state_out[4] = state_in[4] + e; + state_out[5] = state_in[5] + f; + state_out[6] = state_in[6] + g; + state_out[7] = state_in[7] + h; + + /* Clean up */ + a = b = c = d = e = f = g = h = T1 = 0; +} + +#else /* SHA2_UNROLL_TRANSFORM */ + +void sha512_Transform(const sha2_word64* state_in, const sha2_word64* data, sha2_word64* state_out) { + sha2_word64 a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, s0 = 0, s1 = 0; + sha2_word64 T1 = 0, T2 = 0, W512[16] = {0}; + int j = 0; + + /* Initialize registers with the prev. intermediate value */ + a = state_in[0]; + b = state_in[1]; + c = state_in[2]; + d = state_in[3]; + e = state_in[4]; + f = state_in[5]; + g = state_in[6]; + h = state_in[7]; + + j = 0; + do { + /* Apply the SHA-512 compression function to update a..h with copy */ + T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + (W512[j] = *data++); + T2 = Sigma0_512(a) + Maj(a, b, c); + h = g; + g = f; + f = e; + e = d + T1; + d = c; + c = b; + b = a; + a = T1 + T2; + + j++; + } while (j < 16); + + do { + /* Part of the message block expansion: */ + s0 = W512[(j+1)&0x0f]; + s0 = sigma0_512(s0); + s1 = W512[(j+14)&0x0f]; + s1 = sigma1_512(s1); + + /* Apply the SHA-512 compression function to update a..h */ + T1 = h + Sigma1_512(e) + Ch(e, f, g) + K512[j] + + (W512[j&0x0f] += s1 + W512[(j+9)&0x0f] + s0); + T2 = Sigma0_512(a) + Maj(a, b, c); + h = g; + g = f; + f = e; + e = d + T1; + d = c; + c = b; + b = a; + a = T1 + T2; + + j++; + } while (j < 80); + + /* Compute the current intermediate hash value */ + state_out[0] = state_in[0] + a; + state_out[1] = state_in[1] + b; + state_out[2] = state_in[2] + c; + state_out[3] = state_in[3] + d; + state_out[4] = state_in[4] + e; + state_out[5] = state_in[5] + f; + state_out[6] = state_in[6] + g; + state_out[7] = state_in[7] + h; + + /* Clean up */ + a = b = c = d = e = f = g = h = T1 = T2 = 0; +} + +#endif /* SHA2_UNROLL_TRANSFORM */ + +void sha512_Update(SHA512_CTX* context, const sha2_byte *data, size_t len) { + unsigned int freespace = 0, usedspace = 0; + + if (len == 0) { + /* Calling with no data is valid - we do nothing */ + return; + } + + usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH; + if (usedspace > 0) { + /* Calculate how much free space is available in the buffer */ + freespace = SHA512_BLOCK_LENGTH - usedspace; + + if (len >= freespace) { + /* Fill the buffer completely and process it */ + MEMCPY_BCOPY(((uint8_t*)context->buffer) + usedspace, data, freespace); + ADDINC128(context->bitcount, freespace << 3); + len -= freespace; + data += freespace; +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert TO host byte order */ + for (int j = 0; j < 16; j++) { + REVERSE64(context->buffer[j],context->buffer[j]); + } +#endif + sha512_Transform(context->state, context->buffer, context->state); + } else { + /* The buffer is not yet full */ + MEMCPY_BCOPY(((uint8_t*)context->buffer) + usedspace, data, len); + ADDINC128(context->bitcount, len << 3); + /* Clean up: */ + usedspace = freespace = 0; + return; + } + } + while (len >= SHA512_BLOCK_LENGTH) { + /* Process as many complete blocks as we can */ + MEMCPY_BCOPY(context->buffer, data, SHA512_BLOCK_LENGTH); +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert TO host byte order */ + for (int j = 0; j < 16; j++) { + REVERSE64(context->buffer[j],context->buffer[j]); + } +#endif + sha512_Transform(context->state, context->buffer, context->state); + ADDINC128(context->bitcount, SHA512_BLOCK_LENGTH << 3); + len -= SHA512_BLOCK_LENGTH; + data += SHA512_BLOCK_LENGTH; + } + if (len > 0) { + /* There's left-overs, so save 'em */ + MEMCPY_BCOPY(context->buffer, data, len); + ADDINC128(context->bitcount, len << 3); + } + /* Clean up: */ + usedspace = freespace = 0; +} + +static void sha512_Last(SHA512_CTX* context) { + unsigned int usedspace = 0; + + usedspace = (context->bitcount[0] >> 3) % SHA512_BLOCK_LENGTH; + /* Begin padding with a 1 bit: */ + ((uint8_t*)context->buffer)[usedspace++] = 0x80; + + if (usedspace > SHA512_SHORT_BLOCK_LENGTH) { + memzero(((uint8_t*)context->buffer) + usedspace, SHA512_BLOCK_LENGTH - usedspace); + +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert TO host byte order */ + for (int j = 0; j < 16; j++) { + REVERSE64(context->buffer[j],context->buffer[j]); + } +#endif + /* Do second-to-last transform: */ + sha512_Transform(context->state, context->buffer, context->state); + + /* And prepare the last transform: */ + usedspace = 0; + } + /* Set-up for the last transform: */ + memzero(((uint8_t*)context->buffer) + usedspace, SHA512_SHORT_BLOCK_LENGTH - usedspace); + +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert TO host byte order */ + for (int j = 0; j < 14; j++) { + REVERSE64(context->buffer[j],context->buffer[j]); + } +#endif + /* Store the length of input data (in bits): */ + context->buffer[14] = context->bitcount[1]; + context->buffer[15] = context->bitcount[0]; + + /* Final transform: */ + sha512_Transform(context->state, context->buffer, context->state); +} + +void sha512_Final(SHA512_CTX* context, sha2_byte digest[]) { + /* If no digest buffer is passed, we don't bother doing this: */ + if (digest != (sha2_byte*)0) { + sha512_Last(context); + + /* Save the hash data for output: */ +#if BYTE_ORDER == LITTLE_ENDIAN + /* Convert FROM host byte order */ + for (int j = 0; j < 8; j++) { + REVERSE64(context->state[j],context->state[j]); + } +#endif + MEMCPY_BCOPY(digest, context->state, SHA512_DIGEST_LENGTH); + } + + /* Zero out state data */ + memzero(context, sizeof(SHA512_CTX)); +} + +char *sha512_End(SHA512_CTX* context, char buffer[]) { + sha2_byte digest[SHA512_DIGEST_LENGTH] = {0}, *d = digest; + int i = 0; + + if (buffer != (char*)0) { + sha512_Final(context, digest); + + for (i = 0; i < SHA512_DIGEST_LENGTH; i++) { + *buffer++ = sha2_hex_digits[(*d & 0xf0) >> 4]; + *buffer++ = sha2_hex_digits[*d & 0x0f]; + d++; + } + *buffer = (char)0; + } else { + memzero(context, sizeof(SHA512_CTX)); + } + memzero(digest, SHA512_DIGEST_LENGTH); + return buffer; +} + +void sha512_Raw(const sha2_byte* data, size_t len, uint8_t digest[SHA512_DIGEST_LENGTH]) { + SHA512_CTX context = {0}; + sha512_Init(&context); + sha512_Update(&context, data, len); + sha512_Final(&context, digest); +} + +char* sha512_Data(const sha2_byte* data, size_t len, char digest[SHA512_DIGEST_STRING_LENGTH]) { + SHA512_CTX context = {0}; + + sha512_Init(&context); + sha512_Update(&context, data, len); + return sha512_End(&context, digest); +} diff --git a/src/crypto/bip39/sha2.h b/src/crypto/bip39/sha2.h new file mode 100644 index 000000000..7f519c50b --- /dev/null +++ b/src/crypto/bip39/sha2.h @@ -0,0 +1,116 @@ +/** + * Copyright (c) 2000-2001 Aaron D. Gifford + * Copyright (c) 2013-2014 Pavol Rusnak + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright holder nor the names of contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef __SHA2_H__ +#define __SHA2_H__ + +#include +#include + +#define SHA1_BLOCK_LENGTH 64 +#define SHA1_DIGEST_LENGTH 20 +#define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1) +#define SHA256_BLOCK_LENGTH 64 +#define SHA256_DIGEST_LENGTH 32 +#define SHA256_DIGEST_STRING_LENGTH (SHA256_DIGEST_LENGTH * 2 + 1) +#define SHA512_BLOCK_LENGTH 128 +#define SHA512_DIGEST_LENGTH 64 +#define SHA512_DIGEST_STRING_LENGTH (SHA512_DIGEST_LENGTH * 2 + 1) + +typedef struct _SHA1_CTX { + uint32_t state[5]; + uint64_t bitcount; + uint32_t buffer[SHA1_BLOCK_LENGTH/sizeof(uint32_t)]; +} SHA1_CTX; +typedef struct _SHA256_CTX { + uint32_t state[8]; + uint64_t bitcount; + uint32_t buffer[SHA256_BLOCK_LENGTH/sizeof(uint32_t)]; +} SHA256_CTX; +typedef struct _SHA512_CTX { + uint64_t state[8]; + uint64_t bitcount[2]; + uint64_t buffer[SHA512_BLOCK_LENGTH/sizeof(uint64_t)]; +} SHA512_CTX; + +/*** ENDIAN REVERSAL MACROS *******************************************/ +#ifndef LITTLE_ENDIAN +#define LITTLE_ENDIAN 1234 +#define BIG_ENDIAN 4321 +#endif + +#ifndef BYTE_ORDER +#define BYTE_ORDER LITTLE_ENDIAN +#endif + +#if BYTE_ORDER == LITTLE_ENDIAN +#define REVERSE32(w,x) { \ + uint32_t tmp = (w); \ + tmp = (tmp >> 16) | (tmp << 16); \ + (x) = ((tmp & 0xff00ff00UL) >> 8) | ((tmp & 0x00ff00ffUL) << 8); \ +} +#define REVERSE64(w,x) { \ + uint64_t tmp = (w); \ + tmp = (tmp >> 32) | (tmp << 32); \ + tmp = ((tmp & 0xff00ff00ff00ff00ULL) >> 8) | \ + ((tmp & 0x00ff00ff00ff00ffULL) << 8); \ + (x) = ((tmp & 0xffff0000ffff0000ULL) >> 16) | \ + ((tmp & 0x0000ffff0000ffffULL) << 16); \ +} +#endif /* BYTE_ORDER == LITTLE_ENDIAN */ + +extern const uint32_t sha256_initial_hash_value[8]; +extern const uint64_t sha512_initial_hash_value[8]; + +void sha1_Transform(const uint32_t* state_in, const uint32_t* data, uint32_t* state_out); +void sha1_Init(SHA1_CTX *); +void sha1_Update(SHA1_CTX*, const uint8_t*, size_t); +void sha1_Final(SHA1_CTX*, uint8_t[SHA1_DIGEST_LENGTH]); +char* sha1_End(SHA1_CTX*, char[SHA1_DIGEST_STRING_LENGTH]); +void sha1_Raw(const uint8_t*, size_t, uint8_t[SHA1_DIGEST_LENGTH]); +char* sha1_Data(const uint8_t*, size_t, char[SHA1_DIGEST_STRING_LENGTH]); + +void sha256_Transform(const uint32_t* state_in, const uint32_t* data, uint32_t* state_out); +void sha256_Init(SHA256_CTX *); +void sha256_Update(SHA256_CTX*, const uint8_t*, size_t); +void sha256_Final(SHA256_CTX*, uint8_t[SHA256_DIGEST_LENGTH]); +char* sha256_End(SHA256_CTX*, char[SHA256_DIGEST_STRING_LENGTH]); +void sha256_Raw(const uint8_t*, size_t, uint8_t[SHA256_DIGEST_LENGTH]); +char* sha256_Data(const uint8_t*, size_t, char[SHA256_DIGEST_STRING_LENGTH]); + +void sha512_Transform(const uint64_t* state_in, const uint64_t* data, uint64_t* state_out); +void sha512_Init(SHA512_CTX*); +void sha512_Update(SHA512_CTX*, const uint8_t*, size_t); +void sha512_Final(SHA512_CTX*, uint8_t[SHA512_DIGEST_LENGTH]); +char* sha512_End(SHA512_CTX*, char[SHA512_DIGEST_STRING_LENGTH]); +void sha512_Raw(const uint8_t*, size_t, uint8_t[SHA512_DIGEST_LENGTH]); +char* sha512_Data(const uint8_t*, size_t, char[SHA512_DIGEST_STRING_LENGTH]); + +#endif diff --git a/src/crypto/bip39/sha3.c b/src/crypto/bip39/sha3.c new file mode 100644 index 000000000..80ac28ff6 --- /dev/null +++ b/src/crypto/bip39/sha3.c @@ -0,0 +1,397 @@ +/* sha3.c - an implementation of Secure Hash Algorithm 3 (Keccak). + * based on the + * The Keccak SHA-3 submission. Submission to NIST (Round 3), 2011 + * by Guido Bertoni, Joan Daemen, Michaël Peeters and Gilles Van Assche + * + * Copyright: 2013 Aleksey Kravchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. Use this program at your own risk! + */ + +#include +#include + +#include "sha3.h" +#include "memzero.h" + +#define I64(x) x##LL +#define ROTL64(qword, n) ((qword) << (n) ^ ((qword) >> (64 - (n)))) +#define le2me_64(x) (x) +#define IS_ALIGNED_64(p) (0 == (7 & ((const char*)(p) - (const char*)0))) +# define me64_to_le_str(to, from, length) memcpy((to), (from), (length)) + +/* constants */ +#define NumberOfRounds 24 + +/* SHA3 (Keccak) constants for 24 rounds */ +static uint64_t keccak_round_constants[NumberOfRounds] = { + I64(0x0000000000000001), I64(0x0000000000008082), I64(0x800000000000808A), I64(0x8000000080008000), + I64(0x000000000000808B), I64(0x0000000080000001), I64(0x8000000080008081), I64(0x8000000000008009), + I64(0x000000000000008A), I64(0x0000000000000088), I64(0x0000000080008009), I64(0x000000008000000A), + I64(0x000000008000808B), I64(0x800000000000008B), I64(0x8000000000008089), I64(0x8000000000008003), + I64(0x8000000000008002), I64(0x8000000000000080), I64(0x000000000000800A), I64(0x800000008000000A), + I64(0x8000000080008081), I64(0x8000000000008080), I64(0x0000000080000001), I64(0x8000000080008008) +}; + +/* Initializing a sha3 context for given number of output bits */ +static void keccak_Init(SHA3_CTX *ctx, unsigned bits) +{ + /* NB: The Keccak capacity parameter = bits * 2 */ + unsigned rate = 1600 - bits * 2; + + memzero(ctx, sizeof(SHA3_CTX)); + ctx->block_size = rate / 8; + assert(rate <= 1600 && (rate % 64) == 0); +} + +/** + * Initialize context before calculating hash. + * + * @param ctx context to initialize + */ +void sha3_224_Init(SHA3_CTX *ctx) +{ + keccak_Init(ctx, 224); +} + +/** + * Initialize context before calculating hash. + * + * @param ctx context to initialize + */ +void sha3_256_Init(SHA3_CTX *ctx) +{ + keccak_Init(ctx, 256); +} + +/** + * Initialize context before calculating hash. + * + * @param ctx context to initialize + */ +void sha3_384_Init(SHA3_CTX *ctx) +{ + keccak_Init(ctx, 384); +} + +/** + * Initialize context before calculating hash. + * + * @param ctx context to initialize + */ +void sha3_512_Init(SHA3_CTX *ctx) +{ + keccak_Init(ctx, 512); +} + +/* Keccak theta() transformation */ +static void keccak_theta(uint64_t *A) +{ + unsigned int x = 0; + uint64_t C[5] = {0}, D[5] = {0}; + + for (x = 0; x < 5; x++) { + C[x] = A[x] ^ A[x + 5] ^ A[x + 10] ^ A[x + 15] ^ A[x + 20]; + } + D[0] = ROTL64(C[1], 1) ^ C[4]; + D[1] = ROTL64(C[2], 1) ^ C[0]; + D[2] = ROTL64(C[3], 1) ^ C[1]; + D[3] = ROTL64(C[4], 1) ^ C[2]; + D[4] = ROTL64(C[0], 1) ^ C[3]; + + for (x = 0; x < 5; x++) { + A[x] ^= D[x]; + A[x + 5] ^= D[x]; + A[x + 10] ^= D[x]; + A[x + 15] ^= D[x]; + A[x + 20] ^= D[x]; + } +} + +/* Keccak pi() transformation */ +static void keccak_pi(uint64_t *A) +{ + uint64_t A1 = 0; + A1 = A[1]; + A[ 1] = A[ 6]; + A[ 6] = A[ 9]; + A[ 9] = A[22]; + A[22] = A[14]; + A[14] = A[20]; + A[20] = A[ 2]; + A[ 2] = A[12]; + A[12] = A[13]; + A[13] = A[19]; + A[19] = A[23]; + A[23] = A[15]; + A[15] = A[ 4]; + A[ 4] = A[24]; + A[24] = A[21]; + A[21] = A[ 8]; + A[ 8] = A[16]; + A[16] = A[ 5]; + A[ 5] = A[ 3]; + A[ 3] = A[18]; + A[18] = A[17]; + A[17] = A[11]; + A[11] = A[ 7]; + A[ 7] = A[10]; + A[10] = A1; + /* note: A[ 0] is left as is */ +} + +/* Keccak chi() transformation */ +static void keccak_chi(uint64_t *A) +{ + int i = 0; + for (i = 0; i < 25; i += 5) { + uint64_t A0 = A[0 + i], A1 = A[1 + i]; + A[0 + i] ^= ~A1 & A[2 + i]; + A[1 + i] ^= ~A[2 + i] & A[3 + i]; + A[2 + i] ^= ~A[3 + i] & A[4 + i]; + A[3 + i] ^= ~A[4 + i] & A0; + A[4 + i] ^= ~A0 & A1; + } +} + +static void sha3_permutation(uint64_t *state) +{ + int round = 0; + for (round = 0; round < NumberOfRounds; round++) + { + keccak_theta(state); + + /* apply Keccak rho() transformation */ + state[ 1] = ROTL64(state[ 1], 1); + state[ 2] = ROTL64(state[ 2], 62); + state[ 3] = ROTL64(state[ 3], 28); + state[ 4] = ROTL64(state[ 4], 27); + state[ 5] = ROTL64(state[ 5], 36); + state[ 6] = ROTL64(state[ 6], 44); + state[ 7] = ROTL64(state[ 7], 6); + state[ 8] = ROTL64(state[ 8], 55); + state[ 9] = ROTL64(state[ 9], 20); + state[10] = ROTL64(state[10], 3); + state[11] = ROTL64(state[11], 10); + state[12] = ROTL64(state[12], 43); + state[13] = ROTL64(state[13], 25); + state[14] = ROTL64(state[14], 39); + state[15] = ROTL64(state[15], 41); + state[16] = ROTL64(state[16], 45); + state[17] = ROTL64(state[17], 15); + state[18] = ROTL64(state[18], 21); + state[19] = ROTL64(state[19], 8); + state[20] = ROTL64(state[20], 18); + state[21] = ROTL64(state[21], 2); + state[22] = ROTL64(state[22], 61); + state[23] = ROTL64(state[23], 56); + state[24] = ROTL64(state[24], 14); + + keccak_pi(state); + keccak_chi(state); + + /* apply iota(state, round) */ + *state ^= keccak_round_constants[round]; + } +} + +/** + * The core transformation. Process the specified block of data. + * + * @param hash the algorithm state + * @param block the message block to process + * @param block_size the size of the processed block in bytes + */ +static void sha3_process_block(uint64_t hash[25], const uint64_t *block, size_t block_size) +{ + /* expanded loop */ + hash[ 0] ^= le2me_64(block[ 0]); + hash[ 1] ^= le2me_64(block[ 1]); + hash[ 2] ^= le2me_64(block[ 2]); + hash[ 3] ^= le2me_64(block[ 3]); + hash[ 4] ^= le2me_64(block[ 4]); + hash[ 5] ^= le2me_64(block[ 5]); + hash[ 6] ^= le2me_64(block[ 6]); + hash[ 7] ^= le2me_64(block[ 7]); + hash[ 8] ^= le2me_64(block[ 8]); + /* if not sha3-512 */ + if (block_size > 72) { + hash[ 9] ^= le2me_64(block[ 9]); + hash[10] ^= le2me_64(block[10]); + hash[11] ^= le2me_64(block[11]); + hash[12] ^= le2me_64(block[12]); + /* if not sha3-384 */ + if (block_size > 104) { + hash[13] ^= le2me_64(block[13]); + hash[14] ^= le2me_64(block[14]); + hash[15] ^= le2me_64(block[15]); + hash[16] ^= le2me_64(block[16]); + /* if not sha3-256 */ + if (block_size > 136) { + hash[17] ^= le2me_64(block[17]); +#ifdef FULL_SHA3_FAMILY_SUPPORT + /* if not sha3-224 */ + if (block_size > 144) { + hash[18] ^= le2me_64(block[18]); + hash[19] ^= le2me_64(block[19]); + hash[20] ^= le2me_64(block[20]); + hash[21] ^= le2me_64(block[21]); + hash[22] ^= le2me_64(block[22]); + hash[23] ^= le2me_64(block[23]); + hash[24] ^= le2me_64(block[24]); + } +#endif + } + } + } + /* make a permutation of the hash */ + sha3_permutation(hash); +} + +#define SHA3_FINALIZED 0x80000000 + +/** + * Calculate message hash. + * Can be called repeatedly with chunks of the message to be hashed. + * + * @param ctx the algorithm context containing current hashing state + * @param msg message chunk + * @param size length of the message chunk + */ +void sha3_Update(SHA3_CTX *ctx, const unsigned char *msg, size_t size) +{ + size_t idx = (size_t)ctx->rest; + size_t block_size = (size_t)ctx->block_size; + + if (ctx->rest & SHA3_FINALIZED) return; /* too late for additional input */ + ctx->rest = (unsigned)((ctx->rest + size) % block_size); + + /* fill partial block */ + if (idx) { + size_t left = block_size - idx; + memcpy((char*)ctx->message + idx, msg, (size < left ? size : left)); + if (size < left) return; + + /* process partial block */ + sha3_process_block(ctx->hash, ctx->message, block_size); + msg += left; + size -= left; + } + while (size >= block_size) { + uint64_t *aligned_message_block = NULL; + if (IS_ALIGNED_64(msg)) { + /* the most common case is processing of an already aligned message + without copying it */ + aligned_message_block = (uint64_t*)(void*)msg; + } else { + memcpy(ctx->message, msg, block_size); + aligned_message_block = ctx->message; + } + + sha3_process_block(ctx->hash, aligned_message_block, block_size); + msg += block_size; + size -= block_size; + } + if (size) { + memcpy(ctx->message, msg, size); /* save leftovers */ + } +} + +/** + * Store calculated hash into the given array. + * + * @param ctx the algorithm context containing current hashing state + * @param result calculated hash in binary form + */ +void sha3_Final(SHA3_CTX *ctx, unsigned char* result) +{ + size_t digest_length = 100 - ctx->block_size / 2; + const size_t block_size = ctx->block_size; + + if (!(ctx->rest & SHA3_FINALIZED)) + { + /* clear the rest of the data queue */ + memzero((char*)ctx->message + ctx->rest, block_size - ctx->rest); + ((char*)ctx->message)[ctx->rest] |= 0x06; + ((char*)ctx->message)[block_size - 1] |= 0x80; + + /* process final block */ + sha3_process_block(ctx->hash, ctx->message, block_size); + ctx->rest = SHA3_FINALIZED; /* mark context as finalized */ + } + + assert(block_size > digest_length); + if (result) me64_to_le_str(result, ctx->hash, digest_length); + memzero(ctx, sizeof(SHA3_CTX)); +} + +#if USE_KECCAK +/** +* Store calculated hash into the given array. +* +* @param ctx the algorithm context containing current hashing state +* @param result calculated hash in binary form +*/ +void keccak_Final(SHA3_CTX *ctx, unsigned char* result) +{ + size_t digest_length = 100 - ctx->block_size / 2; + const size_t block_size = ctx->block_size; + + if (!(ctx->rest & SHA3_FINALIZED)) + { + /* clear the rest of the data queue */ + memzero((char*)ctx->message + ctx->rest, block_size - ctx->rest); + ((char*)ctx->message)[ctx->rest] |= 0x01; + ((char*)ctx->message)[block_size - 1] |= 0x80; + + /* process final block */ + sha3_process_block(ctx->hash, ctx->message, block_size); + ctx->rest = SHA3_FINALIZED; /* mark context as finalized */ + } + + assert(block_size > digest_length); + if (result) me64_to_le_str(result, ctx->hash, digest_length); + memzero(ctx, sizeof(SHA3_CTX)); +} + +void keccak_256(const unsigned char* data, size_t len, unsigned char* digest) +{ + SHA3_CTX ctx = {0}; + keccak_256_Init(&ctx); + keccak_Update(&ctx, data, len); + keccak_Final(&ctx, digest); +} + +void keccak_512(const unsigned char* data, size_t len, unsigned char* digest) +{ + SHA3_CTX ctx = {0}; + keccak_512_Init(&ctx); + keccak_Update(&ctx, data, len); + keccak_Final(&ctx, digest); +} +#endif /* USE_KECCAK */ + +void sha3_256(const unsigned char* data, size_t len, unsigned char* digest) +{ + SHA3_CTX ctx = {0}; + sha3_256_Init(&ctx); + sha3_Update(&ctx, data, len); + sha3_Final(&ctx, digest); +} + +void sha3_512(const unsigned char* data, size_t len, unsigned char* digest) +{ + SHA3_CTX ctx = {0}; + sha3_512_Init(&ctx); + sha3_Update(&ctx, data, len); + sha3_Final(&ctx, digest); +} diff --git a/src/crypto/bip39/sha3.h b/src/crypto/bip39/sha3.h new file mode 100644 index 000000000..367369d4d --- /dev/null +++ b/src/crypto/bip39/sha3.h @@ -0,0 +1,89 @@ +/* sha3.h - an implementation of Secure Hash Algorithm 3 (Keccak). + * based on the + * The Keccak SHA-3 submission. Submission to NIST (Round 3), 2011 + * by Guido Bertoni, Joan Daemen, Michaël Peeters and Gilles Van Assche + * + * Copyright: 2013 Aleksey Kravchenko + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. Use this program at your own risk! + */ + +#ifndef __SHA3_H__ +#define __SHA3_H__ + +#include +#include "options.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define sha3_224_hash_size 28 +#define sha3_256_hash_size 32 +#define sha3_384_hash_size 48 +#define sha3_512_hash_size 64 +#define sha3_max_permutation_size 25 +#define sha3_max_rate_in_qwords 24 + +#define SHA3_224_BLOCK_LENGTH 144 +#define SHA3_256_BLOCK_LENGTH 136 +#define SHA3_384_BLOCK_LENGTH 104 +#define SHA3_512_BLOCK_LENGTH 72 + +#define SHA3_224_DIGEST_LENGTH sha3_224_hash_size +#define SHA3_256_DIGEST_LENGTH sha3_256_hash_size +#define SHA3_384_DIGEST_LENGTH sha3_384_hash_size +#define SHA3_512_DIGEST_LENGTH sha3_512_hash_size + +/** + * SHA3 Algorithm context. + */ +typedef struct SHA3_CTX +{ + /* 1600 bits algorithm hashing state */ + uint64_t hash[sha3_max_permutation_size]; + /* 1536-bit buffer for leftovers */ + uint64_t message[sha3_max_rate_in_qwords]; + /* count of bytes in the message[] buffer */ + unsigned rest; + /* size of a message block processed at once */ + unsigned block_size; +} SHA3_CTX; + +/* methods for calculating the hash function */ + +void sha3_224_Init(SHA3_CTX *ctx); +void sha3_256_Init(SHA3_CTX *ctx); +void sha3_384_Init(SHA3_CTX *ctx); +void sha3_512_Init(SHA3_CTX *ctx); +void sha3_Update(SHA3_CTX *ctx, const unsigned char* msg, size_t size); +void sha3_Final(SHA3_CTX *ctx, unsigned char* result); + +#if USE_KECCAK +#define keccak_224_Init sha3_224_Init +#define keccak_256_Init sha3_256_Init +#define keccak_384_Init sha3_384_Init +#define keccak_512_Init sha3_512_Init +#define keccak_Update sha3_Update +void keccak_Final(SHA3_CTX *ctx, unsigned char* result); +void keccak_256(const unsigned char* data, size_t len, unsigned char* digest); +void keccak_512(const unsigned char* data, size_t len, unsigned char* digest); +#endif + +void sha3_256(const unsigned char* data, size_t len, unsigned char* digest); +void sha3_512(const unsigned char* data, size_t len, unsigned char* digest); + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif /* __SHA3_H__ */ From 86ad289a42b3f6b26cbff6a6bb8aa6257bad89c4 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sat, 5 Sep 2020 04:45:54 -0700 Subject: [PATCH 157/255] Clean up dead code --- src/main.cpp | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index d58edff19..60e350c44 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2421,30 +2421,6 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) { return(komodo_ac_block_subsidy(nHeight)); } - /* - // Mining slow start - // The subsidy is ramped up linearly, skipping the middle payout of - // MAX_SUBSIDY/2 to keep the monetary curve consistent with no slow start. - if (nHeight < consensusParams.nSubsidySlowStartInterval / 2) { - nSubsidy /= consensusParams.nSubsidySlowStartInterval; - nSubsidy *= nHeight; - return nSubsidy; - } else if (nHeight < consensusParams.nSubsidySlowStartInterval) { - nSubsidy /= consensusParams.nSubsidySlowStartInterval; - nSubsidy *= (nHeight+1); - return nSubsidy; - } - - assert(nHeight > consensusParams.SubsidySlowStartShift()); - int halvings = (nHeight - consensusParams.SubsidySlowStartShift()) / consensusParams.nSubsidyHalvingInterval;*/ - // Force block reward to zero when right shift is undefined. - //int halvings = nHeight / consensusParams.nSubsidyHalvingInterval; - //if (halvings >= 64) - // return 0; - - // Subsidy is cut in half every 840,000 blocks which will occur approximately every 4 years. - //nSubsidy >>= halvings; - //return nSubsidy; } bool IsInitialBlockDownload() From 0c0b2ec1cc58d1d3f01c1b6a5e3ad847bb9840e5 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sat, 5 Sep 2020 05:36:28 -0700 Subject: [PATCH 158/255] cleanup --- src/komodo_bitcoind.h | 5 +---- src/main.cpp | 4 +--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index e58056a40..93dd18f8b 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1236,10 +1236,7 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); uint64_t komodo_commission(const CBlock *pblock,int32_t height) { - static bool didinit = false,ishush3 = false; - // LABS fungible chains, cannot have any block reward! - if ( is_STAKED(ASSETCHAINS_SYMBOL) == 2 ) - return(0); + static bool didinit = false, ishush3 = false; if (!didinit) { ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; diff --git a/src/main.cpp b/src/main.cpp index 60e350c44..5038a0c00 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2416,9 +2416,7 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) else if ( nHeight < 2*KOMODO_ENDOFERA ) return(2 * COIN); else return(COIN); - } - else - { + } else { return(komodo_ac_block_subsidy(nHeight)); } } From 2bb5454020621d0b9359ff237c65a66c98dc75fc Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sat, 5 Sep 2020 05:38:09 -0700 Subject: [PATCH 159/255] Explicitly set BR in each halving interval This extremely important consensus-changing code takes into account that with our new 75s block time, which gives us twice as many blocks per day, we must divide our block reward by two in the next halving interval, becoming 3.125 HUSH per block insted of 6.25 HUSH under the old rules of 150s blocks. Subsequent halving intervals do not change block times, and so they follow the normal pattern of halving. This commit has a number of rough edges: * Final BR height is still incorrect * Due to above, exact number of halvings is unknown under new 75s blocktime --- src/komodo_bitcoind.h | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 93dd18f8b..1f95052c7 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1250,15 +1250,24 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) //fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); + // Do not change this code unless you really know what you are doing. + // Here Be Dragons! -- Duke Leto if (ishush3) { // TODO: Calculate new BR_END based on 75s block time!!! 2X old BR_END is a rough estimate, not exact! int32_t starting_commission = 125000000, HALVING1 = GetArg("-z2zheight",340000), INTERVAL = 840000, TRANSITION = 129, BR_END = 2*5422111; + // TODO: how many halvings will we have given new 75s blocktime? + int32_t commisions[] = {starting_commision, 3125000000, 1562500000, 781250000, 390625000, + 195312500, 97656250, 48828125, // these are exact + 24414062, 12207031, 6103515 // these have deviation from ideal BR + // Just like BTC, BRs in the far future will be slightly less than + // they should be because exact values are not integers, causing + // slightly less coins to be actually mined + }; // HUSH supply curve cannot be exactly represented via KMD AC CLI args, so we do it ourselves. // You specify the BR, and the FR % gets added so 10% of 12.5 is 1.25 // but to tell the AC params, I need to say "11% of 11.25" is 1.25 // 11% ie. 1/9th cannot be exactly represented and so the FR has tiny amounts of error unless done manually - if( height > HALVING1) { // Block time going from 150s to 75s (half) means the interval between halvings // must be twice as often, i.e. 840000*2=1680000 @@ -1271,25 +1280,25 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) if (height < TRANSITION) { commission = 0; } else if (height < HALVING1) { // before 1st Halving @ Block 340000 (Nov 2020) - commission = starting_commission; + commission = commisions[0]; } else if (height < HALVING1+1*INTERVAL) { // before 2nd Halving @ Block 2020000 - commission = starting_commission / 2; + commission = commisions[1]; } else if (height < HALVING1+2*INTERVAL) { // before 3rd Halving @ Block 3700000 - commission = starting_commission / 4; + commission = commisions[2]; } else if (height < HALVING1+3*INTERVAL) { // before 4th Halving @ Block 5380000 - commission = starting_commission / 8; + commission = commisions[3]; } else if (height < HALVING1+4*INTERVAL) { // before 5th Halving @ Block 7060000 - commission = starting_commission / 16; + commission = commisions[4]; } else if (height < HALVING1+5*INTERVAL) { // before 6th Halving @ Block 8740000 - commission = starting_commission / 32; + commission = commisions[5]; } else if (height < HALVING1+6*INTERVAL) { // before 7th Halving @ Block 10420000 - commission = starting_commission / 64; + commission = commisions[6]; } else if (height < HALVING1+7*INTERVAL) { // before 8th Halving @ Block 12100000 - // Block reward will go to zero between 7th+8th halvings, ac_end may need adjusting - commission = starting_commission / 128; + // TODO: Still true??? Block reward will go to zero between 7th+8th halvings, ac_end may need adjusting + commission = commisions[7]; } else if (height < HALVING1+8*INTERVAL) { // before 9th Halving @ Block 13780000 // BR should be zero before this halving happens - commission = starting_commission / 256; + commission = commisions[8]; } // Explicitly set the last block reward // BR_END is the block with the last non-zero block reward, which overrides From 1c4a2ee13c6e5681ba80b1db7791402e62ac026b Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 7 Sep 2020 08:33:38 -0400 Subject: [PATCH 160/255] WIP hush_supply --- contrib/hush_supply | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/contrib/hush_supply b/contrib/hush_supply index 99659f219..f7813c64d 100755 --- a/contrib/hush_supply +++ b/contrib/hush_supply @@ -5,42 +5,52 @@ use warnings; use strict; # Simulate the total supply on Hush v3 mainnet +# Todo: track FR +# Todo: verify FR off-by-one my $supply = 0.0; -my $block = 0; -my $satoshis = 100_000_000; -my $reward0 = int(12.5*$satoshis); +my $block = 0; # Block 0 in Hush Smart chains is the BTC genesis block +my $puposhis = 100_000_000; +my $reward0 = 1_250_000_000; my $halvings = 0; -my $initial = 6178674 * $satoshis; +my $initial = 6178674 * $puposhis; my $interval = 1_640_000; # 4 years of 75s blocks -my $height = shift || -1; +my $stop = shift || -1; +my $totalfr = 0; # total paid out to FR address +my $reward = $reward0; # Usage: ./hush_supply &> supply.csv # ./hush_supply HEIGHT &> supply.csv # stop at HEIGHT -my $reward = $reward0; +printf "# block, supply, reward, fr, totalfr, halvings\n"; + # We know BR will go to zero between 7 and 8th halvings while ($halvings <= 10) { $block++; + my $fr = 0; # blocks 2-127 of Hush v3 had BR=0 if ($block == 1) { $reward = $initial; # airdropped funds from Hush v2 mainnet } elsif ($block > 1 && $block < 128) { $reward = 0; # blocks 2-127 have BR=0 } else { + $fr = 125_000_000; if ($block < 340_000) { $reward = $reward0; } else { + my $shifted = $block - 340_000; # Past the first halving - $block -= 340_000; - $halvings = 1 + ($block % $interval); - $reward <<= $halvings; + $halvings = 1 + int ($shifted / $interval); + if ($shifted % 840_000 == 0) { + $reward >>= 2; + $fr >>= 2; + } } } - $supply += $reward; - # block, current supply, block reward amount, number of halvings - # all amounts are in satoshis - printf "%s,%s,%s,%s\n",$block, $supply, $reward, $halvings; - #exit(0) if ($block > 200); - exit(0) if $block == $height; + $supply += $reward; + $totalfr += $fr; + + # block, current supply, block reward amount, number of halvings, all amounts are in puposhis + printf "%d,%d,%d,%d,%d,%d\n", $block, $supply, $reward, $fr, $totalfr, $halvings; + exit(0) if $block == $stop; } From b9fd0ce900f51634aa10b79995b66877606aa227 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 7 Sep 2020 08:34:19 -0400 Subject: [PATCH 161/255] Fix bugs in porting zec upstream code --- src/wallet/wallet.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 9d2528073..fe8cbb4f7 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -676,12 +676,14 @@ bool CWallet::Verify(const string& walletFile, string& warningString, string& er boost::filesystem::path path(walletFile); if (path.is_absolute()) { if (!boost::filesystem::exists(path.parent_path())) { - return UIError(strprintf(_("Absolute path %s does not exist!"), walletFile)); + LogPrintf("Absolute path %s does not exist!", walletFile); + return false; } } else { boost::filesystem::path full_path = GetDataDir() / path; if (!boost::filesystem::exists(full_path.parent_path())) { - return UIError(strprintf(_("Relative path %s does not exist!"), walletFile)); + LogPrintf("Relative path %s does not exist!", walletFile); + return false; } } } From 043d58709de8d70ecff9e2cb31bd4627e4d97ecd Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 7 Sep 2020 08:36:48 -0400 Subject: [PATCH 162/255] Fix off-by-one-decimal-place error discovered by @DenioD --- src/komodo_bitcoind.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 1f95052c7..23c35a7b9 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1234,6 +1234,10 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); +// This function defines the Hush Founders Reward (AKA Dev Tax) +// 10% of all block rewards go towards Hush core team +// If you do not like this, you are encouraged to fork the chain +// or start your own Hush Smart Chain: https://github.com/myhush/hush-smart-chains uint64_t komodo_commission(const CBlock *pblock,int32_t height) { static bool didinit = false, ishush3 = false; @@ -1256,9 +1260,8 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) // TODO: Calculate new BR_END based on 75s block time!!! 2X old BR_END is a rough estimate, not exact! int32_t starting_commission = 125000000, HALVING1 = GetArg("-z2zheight",340000), INTERVAL = 840000, TRANSITION = 129, BR_END = 2*5422111; // TODO: how many halvings will we have given new 75s blocktime? - int32_t commisions[] = {starting_commision, 3125000000, 1562500000, 781250000, 390625000, - 195312500, 97656250, 48828125, // these are exact - 24414062, 12207031, 6103515 // these have deviation from ideal BR + int32_t commisions[] = {starting_commission, 312500000, 156250000, 78125000, 39062500, 19531250, 9765625, // these are exact + 4882812, 2441406, 1220703, 610351 // these have deviation from ideal BR // Just like BTC, BRs in the far future will be slightly less than // they should be because exact values are not integers, causing // slightly less coins to be actually mined From 58f7ae13369d5180e2b28d5002026199a1698171 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 7 Sep 2020 08:51:50 -0400 Subject: [PATCH 163/255] Document hushd a bit --- src/hushd | 27 +++++++++++++++++---------- src/hushd-testnet | 2 +- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/hushd b/src/hushd index b5b504ea4..896cc7055 100755 --- a/src/hushd +++ b/src/hushd @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2019 Hush developers +# Copyright (c) 2019-2020 Hush developers # set working directory to the location of this script # readlink -f does not always exist @@ -8,29 +8,36 @@ cd $DIR DIR="$( cd "$( dirname "$( readlink "${BASH_SOURCE[0]}" )" )" && pwd )" cd $DIR +# Chain parameters NAME=HUSH3 + # this corresponds to FR address RHushEyeDm7XwtaTWtyCbjGQumYyV8vMjn SCRIPT=76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac -# Chain parameters +# First Pure Sapling Zcash Protocol chain! +SAPLING=1 + +# We use 3 "eras" of different supply curves ERAS=3 -BLOCKTIME=150 + +# These values are historical and over-ridden by internals! +# Do not change these values, change internals. +BLOCKTIME=150 # Hush goes to 75s blocktime at Block 340K +REWARD=0,1125000000,562500000 +HALVING=129,340000,840000 +PERC=11111111 +END=128,340000,5422111 + # 6250000 - (sprout pool at block 500,000) SUPPLY=6178674 FOUNDERS=1 -REWARD=0,1125000000,562500000 -PERC=11111111 -HALVING=129,340000,840000 -# NOTE: keep in sync with komodo_bitcoind.h -END=128,340000,5422111 +# NOTE: komodo_bitcoind.h decides these values CLIENTNAME=GoldenSandtrout NODE1=188.165.212.101 # EU NODE2=64.120.113.130 # AR NODE3=209.58.144.205 # NA NODE4=94.130.35.94 # EU CCLIB=hush3 -# First Pure Sapling Zcash Protocol chain! -SAPLING=1 # CryptoConditions/Custom Consensus params FAUCET=228 diff --git a/src/hushd-testnet b/src/hushd-testnet index c9da8c1ee..67d724fce 100755 --- a/src/hushd-testnet +++ b/src/hushd-testnet @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2019 Hush developers +# Copyright (c) 2019-2020 Hush developers # set working directory to the location of this script DIR="$( cd "$( dirname "$( readlink -f "${BASH_SOURCE[0]}" )" )" && pwd )" From 880cbc6b0d99e5446920e4a1dac698da7484c418 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 7 Sep 2020 08:54:12 -0400 Subject: [PATCH 164/255] Mo docs for hushd --- src/hushd | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/hushd b/src/hushd index 896cc7055..ca3f28319 100755 --- a/src/hushd +++ b/src/hushd @@ -28,10 +28,9 @@ HALVING=129,340000,840000 PERC=11111111 END=128,340000,5422111 -# 6250000 - (sprout pool at block 500,000) +# 6250000 - (Sprout pool at block 500,000) SUPPLY=6178674 FOUNDERS=1 -# NOTE: komodo_bitcoind.h decides these values CLIENTNAME=GoldenSandtrout NODE1=188.165.212.101 # EU NODE2=64.120.113.130 # AR @@ -40,6 +39,10 @@ NODE4=94.130.35.94 # EU CCLIB=hush3 # CryptoConditions/Custom Consensus params +# CCs will effectively be turned off at Block 340K +# since transparent outputs will not be allowed, except +# for mining and dpow. CCs can be used on Hush Smart +# Chains that do not define ac_private=1 FAUCET=228 HEIR=234 CHANNEL=235 @@ -60,7 +63,6 @@ else fi fi - $KMD -ac_name=$NAME \ -ac_sapling=$SAPLING \ -ac_reward=$REWARD \ From d420e144720b039b5d42015773616db9f991f8b2 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 7 Sep 2020 12:35:15 -0400 Subject: [PATCH 165/255] Explicitly set the Hush block reward and halving intervals for the next two halvings (8 years) --- src/komodo_utils.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 0a1634348..f5acc56b0 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1634,6 +1634,7 @@ uint64_t komodo_ac_block_subsidy(int nHeight) return(subsidy); } +extern bool ishush3; extern int64_t MAX_MONEY; void komodo_cbopretupdate(int32_t forceflag); void SplitStr(const std::string& strVal, std::vector &outVals); @@ -1810,8 +1811,21 @@ void komodo_args(char *argv0) } Split(GetArg("-ac_end",""), sizeof(ASSETCHAINS_ENDSUBSIDY)/sizeof(*ASSETCHAINS_ENDSUBSIDY), ASSETCHAINS_ENDSUBSIDY, 0); - Split(GetArg("-ac_reward",""), sizeof(ASSETCHAINS_REWARD)/sizeof(*ASSETCHAINS_REWARD), ASSETCHAINS_REWARD, 0); Split(GetArg("-ac_halving",""), sizeof(ASSETCHAINS_HALVING)/sizeof(*ASSETCHAINS_HALVING), ASSETCHAINS_HALVING, 0); + Split(GetArg("-ac_reward",""), sizeof(ASSETCHAINS_REWARD)/sizeof(*ASSETCHAINS_REWARD), ASSETCHAINS_REWARD, 0); + if(ishush3) { + // Over-ride HUSH3 values from CLI params. Changing our blocktime to 75s changes things + ASSETCHAINS_REWARD[0] = 0; + ASSETCHAINS_REWARD[1] = 1125000000; + ASSETCHAINS_REWARD[2] = 281250000; // 2.8125 HUSH goes to miners per block after 1st halving at Block 340K + ASSETCHAINS_REWARD[3] = 140625000; // 1.40625 HUSH after 2nd halving at Block 2020000 + ASSETCHAINS_HALVING[0] = 129; + ASSETCHAINS_HALVING[1] = GetArg("-z2zheight",340000); + ASSETCHAINS_HALVING[2] = 2020000; // 2020000 = 340000 + 1680000 (old halving interval plus new halving interval) + ASSETCHAINS_HALVING[3] = 3700000; // ASSETCHAINS_HALVING[2] + 1680000; + // TODO: fill in all possible values for each halving/reward interval + // based on simple halving schedule + } Split(GetArg("-ac_decay",""), sizeof(ASSETCHAINS_DECAY)/sizeof(*ASSETCHAINS_DECAY), ASSETCHAINS_DECAY, 0); Split(GetArg("-ac_notarypay",""), sizeof(ASSETCHAINS_NOTARY_PAY)/sizeof(*ASSETCHAINS_NOTARY_PAY), ASSETCHAINS_NOTARY_PAY, 0); From 727abe0ef2e3c7b9ad2323f7330d9c030ae072e6 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 7 Sep 2020 12:36:26 -0400 Subject: [PATCH 166/255] Be more precise --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index f5acc56b0..252da087f 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1821,7 +1821,7 @@ void komodo_args(char *argv0) ASSETCHAINS_REWARD[3] = 140625000; // 1.40625 HUSH after 2nd halving at Block 2020000 ASSETCHAINS_HALVING[0] = 129; ASSETCHAINS_HALVING[1] = GetArg("-z2zheight",340000); - ASSETCHAINS_HALVING[2] = 2020000; // 2020000 = 340000 + 1680000 (old halving interval plus new halving interval) + ASSETCHAINS_HALVING[2] = 2020000; // 2020000 = 340000 + 1680000 (1st halving block plus new halving interval) ASSETCHAINS_HALVING[3] = 3700000; // ASSETCHAINS_HALVING[2] + 1680000; // TODO: fill in all possible values for each halving/reward interval // based on simple halving schedule From 9ae40031d63bab98b28bce49e545394e6f8bd810 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 7 Sep 2020 12:58:50 -0400 Subject: [PATCH 167/255] Add -ac_halving1 + -ac_halving2 CLI args for devs These new CLI args control the interval of the 1st halving (between 1st and 2nd halving blocks) and the 2nd halving (between 2nd and 3rd halving blocks). -ac_halving2 is used for all subsequent halvings. This allows devs to simulate things via the CLI without changing code, to verify things work as expected at halvings in the far future. --- src/komodo_bitcoind.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 23c35a7b9..b596a60f6 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1258,7 +1258,8 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) // Here Be Dragons! -- Duke Leto if (ishush3) { // TODO: Calculate new BR_END based on 75s block time!!! 2X old BR_END is a rough estimate, not exact! - int32_t starting_commission = 125000000, HALVING1 = GetArg("-z2zheight",340000), INTERVAL = 840000, TRANSITION = 129, BR_END = 2*5422111; + int32_t starting_commission = 125000000, HALVING1 = GetArg("-z2zheight",340000), + INTERVAL = GetArg("-ac_halving1",840000), TRANSITION = 129, BR_END = 2*5422111; // TODO: how many halvings will we have given new 75s blocktime? int32_t commisions[] = {starting_commission, 312500000, 156250000, 78125000, 39062500, 19531250, 9765625, // these are exact 4882812, 2441406, 1220703, 610351 // these have deviation from ideal BR @@ -1276,7 +1277,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) // must be twice as often, i.e. 840000*2=1680000 // With 150s blocks, we have 210,000 blocks per year // With 75s blocks, we have 420,000 blocks per year - INTERVAL = 1680000; + INTERVAL = GetArg("-ac_halving2",1680000); } // Transition period of 128 blocks has BR=FR=0 From b572ef02283cbf27078aae76a5b08eedec6b920a Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 7 Sep 2020 18:40:51 -0400 Subject: [PATCH 168/255] Calculate this value at run-time because it's not set yet when this header file is parsed --- src/komodo_utils.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 252da087f..2c56dad33 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1634,7 +1634,6 @@ uint64_t komodo_ac_block_subsidy(int nHeight) return(subsidy); } -extern bool ishush3; extern int64_t MAX_MONEY; void komodo_cbopretupdate(int32_t forceflag); void SplitStr(const std::string& strVal, std::vector &outVals); @@ -1813,6 +1812,9 @@ void komodo_args(char *argv0) Split(GetArg("-ac_end",""), sizeof(ASSETCHAINS_ENDSUBSIDY)/sizeof(*ASSETCHAINS_ENDSUBSIDY), ASSETCHAINS_ENDSUBSIDY, 0); Split(GetArg("-ac_halving",""), sizeof(ASSETCHAINS_HALVING)/sizeof(*ASSETCHAINS_HALVING), ASSETCHAINS_HALVING, 0); Split(GetArg("-ac_reward",""), sizeof(ASSETCHAINS_REWARD)/sizeof(*ASSETCHAINS_REWARD), ASSETCHAINS_REWARD, 0); + + bool ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; + if(ishush3) { // Over-ride HUSH3 values from CLI params. Changing our blocktime to 75s changes things ASSETCHAINS_REWARD[0] = 0; From d53e39aa4d4b4ce4d28335f5387a3bc94c9efcf2 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Tue, 8 Sep 2020 05:47:53 -0700 Subject: [PATCH 169/255] Good ol' off-by-one strikes again --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index b596a60f6..19d00f319 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1261,7 +1261,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) int32_t starting_commission = 125000000, HALVING1 = GetArg("-z2zheight",340000), INTERVAL = GetArg("-ac_halving1",840000), TRANSITION = 129, BR_END = 2*5422111; // TODO: how many halvings will we have given new 75s blocktime? - int32_t commisions[] = {starting_commission, 312500000, 156250000, 78125000, 39062500, 19531250, 9765625, // these are exact + int32_t commisions[] = {starting_commission, 31250000, 15625000, 78125000, 39062500, 19531250, 9765625, // these are exact 4882812, 2441406, 1220703, 610351 // these have deviation from ideal BR // Just like BTC, BRs in the far future will be slightly less than // they should be because exact values are not integers, causing From 31940f2b3a994dfc457fd003f505a701991f1c04 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 8 Sep 2020 09:54:13 -0400 Subject: [PATCH 170/255] Thanks to @DenioD for reminding me we must modify -ac_end internals variable as well --- src/komodo_utils.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 2c56dad33..985b9f663 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1816,15 +1816,19 @@ void komodo_args(char *argv0) bool ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; if(ishush3) { + fprintf(stderr,"Setting custom HUSH3 chain values...\n"); // Over-ride HUSH3 values from CLI params. Changing our blocktime to 75s changes things - ASSETCHAINS_REWARD[0] = 0; - ASSETCHAINS_REWARD[1] = 1125000000; - ASSETCHAINS_REWARD[2] = 281250000; // 2.8125 HUSH goes to miners per block after 1st halving at Block 340K - ASSETCHAINS_REWARD[3] = 140625000; // 1.40625 HUSH after 2nd halving at Block 2020000 - ASSETCHAINS_HALVING[0] = 129; - ASSETCHAINS_HALVING[1] = GetArg("-z2zheight",340000); - ASSETCHAINS_HALVING[2] = 2020000; // 2020000 = 340000 + 1680000 (1st halving block plus new halving interval) - ASSETCHAINS_HALVING[3] = 3700000; // ASSETCHAINS_HALVING[2] + 1680000; + ASSETCHAINS_REWARD[0] = 0; + ASSETCHAINS_REWARD[1] = 1125000000; + ASSETCHAINS_REWARD[2] = 281250000; // 2.8125 HUSH goes to miners per block after 1st halving at Block 340K + ASSETCHAINS_REWARD[3] = 140625000; // 1.40625 HUSH after 2nd halving at Block 2020000 + ASSETCHAINS_HALVING[0] = 129; + ASSETCHAINS_HALVING[1] = GetArg("-z2zheight",340000); + ASSETCHAINS_HALVING[2] = 2020000; // 2020000 = 340000 + 1680000 (1st halving block plus new halving interval) + ASSETCHAINS_HALVING[3] = 3700000; // ASSETCHAINS_HALVING[2] + 1680000; + ASSETCHAINS_ENDSUBSIDY[0] = 129; + ASSETCHAINS_ENDSUBSIDY[1] = GetArg("-z2zheight",340000); + ASSETCHAINS_ENDSUBSIDY[2] = 2*5422111; // TODO: Fix this, twice the previous end of rewards is an estimate // TODO: fill in all possible values for each halving/reward interval // based on simple halving schedule } From 95ff64404cf2fe6f8113d70748baadc6a238732e Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 8 Sep 2020 11:10:43 -0400 Subject: [PATCH 171/255] Specify that secret_key is a decimal not hex value --- src/wallet/rpcdump.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index 72af5d930..2cd835cbe 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -200,7 +200,7 @@ UniValue importprivkey(const UniValue& params, bool fHelp, const CPubKey& mypk) "2. \"label\" (string, optional, default=\"\") An optional label\n" "3. rescan (boolean, optional, default=true) Rescan the wallet for transactions\n" "4. height (integer, optional, default=0) start at block height?\n" - "5. secret_key (integer, optional, default=188) used to import WIFs of other coins\n" + "5. secret_key (integer, optional, default=188) decimal value used to import WIFs of other coins\n" "\nNote: This call can take minutes to complete if rescan is true.\n" "\nExamples:\n" "\nDump a private key\n" From 67ed136e25a4e510e7a6c91344117da319331ab2 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 8 Sep 2020 11:45:19 -0400 Subject: [PATCH 172/255] Only give 3 values for now to match how many values come in via CLI --- src/komodo_utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 985b9f663..60c10827a 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1821,11 +1821,11 @@ void komodo_args(char *argv0) ASSETCHAINS_REWARD[0] = 0; ASSETCHAINS_REWARD[1] = 1125000000; ASSETCHAINS_REWARD[2] = 281250000; // 2.8125 HUSH goes to miners per block after 1st halving at Block 340K - ASSETCHAINS_REWARD[3] = 140625000; // 1.40625 HUSH after 2nd halving at Block 2020000 + //ASSETCHAINS_REWARD[3] = 140625000; // 1.40625 HUSH after 2nd halving at Block 2020000 ASSETCHAINS_HALVING[0] = 129; ASSETCHAINS_HALVING[1] = GetArg("-z2zheight",340000); ASSETCHAINS_HALVING[2] = 2020000; // 2020000 = 340000 + 1680000 (1st halving block plus new halving interval) - ASSETCHAINS_HALVING[3] = 3700000; // ASSETCHAINS_HALVING[2] + 1680000; + //ASSETCHAINS_HALVING[3] = 3700000; // ASSETCHAINS_HALVING[2] + 1680000; ASSETCHAINS_ENDSUBSIDY[0] = 129; ASSETCHAINS_ENDSUBSIDY[1] = GetArg("-z2zheight",340000); ASSETCHAINS_ENDSUBSIDY[2] = 2*5422111; // TODO: Fix this, twice the previous end of rewards is an estimate From fe4f0f7e9ece22aba55a714e6f71b829ed551473 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 8 Sep 2020 12:01:07 -0400 Subject: [PATCH 173/255] Logspam --- src/komodo_bitcoind.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 19d00f319..dac8de882 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2003,14 +2003,14 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) checktoshis = komodo_commission(pblock,height); if ( checktoshis >= 10000 && pblock->vtx[0].vout.size() < 2 ) { - //fprintf(stderr,"komodo_checkcommission vsize.%d height.%d commission %.8f\n",(int32_t)pblock->vtx[0].vout.size(),height,(double)checktoshis/COIN); + fprintf(stderr,"komodo_checkcommission vsize.%d height.%d commission %.8f\n",(int32_t)pblock->vtx[0].vout.size(),height,(double)checktoshis/COIN); return(-1); } else if ( checktoshis != 0 ) { script = (uint8_t *)&pblock->vtx[0].vout[1].scriptPubKey[0]; scriptlen = (int32_t)pblock->vtx[0].vout[1].scriptPubKey.size(); - if ( 0 ) + if ( 1 ) { int32_t i; for (i=0; i Date: Tue, 8 Sep 2020 12:47:17 -0400 Subject: [PATCH 174/255] Behold vast logspam, refactoring and dead code removal --- src/komodo_bitcoind.h | 5 ++++- src/komodo_utils.h | 29 +++++++++++------------------ src/main.cpp | 15 +++------------ 3 files changed, 18 insertions(+), 31 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index dac8de882..50973ef03 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1240,18 +1240,20 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); // or start your own Hush Smart Chain: https://github.com/myhush/hush-smart-chains uint64_t komodo_commission(const CBlock *pblock,int32_t height) { + fprintf(stderr,"%s at height=%d\n",__func__,height); static bool didinit = false, ishush3 = false; if (!didinit) { ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; didinit = true; + fprintf(stderr,"%s: didinit ishush3=%d\n", __func__, ishush3); } int32_t i,j,n=0,txn_count; int64_t nSubsidy; uint64_t commission,total = 0; if ( ASSETCHAINS_FOUNDERS != 0 ) { nSubsidy = GetBlockSubsidy(height,Params().GetConsensus()); - //fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); + fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); // Do not change this code unless you really know what you are doing. @@ -1997,6 +1999,7 @@ void GetKomodoEarlytxidScriptPub() int64_t komodo_checkcommission(CBlock *pblock,int32_t height) { + fprintf(stderr,"%s at height=%d\n",__func__,height); int64_t checktoshis=0; uint8_t *script,scripthex[8192]; int32_t scriptlen,matched = 0; static bool didinit = false; if ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 ) { diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 60c10827a..6df9366ec 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1548,10 +1548,9 @@ uint64_t komodo_ac_block_subsidy(int nHeight) static uint64_t cached_subsidy; static int32_t cached_numhalvings; static int cached_era; // check for backwards compat, older chains with no explicit rewards had 0.0001 block reward - if ( ASSETCHAINS_ENDSUBSIDY[0] == 0 && ASSETCHAINS_REWARD[0] == 0 ) + if ( ASSETCHAINS_ENDSUBSIDY[0] == 0 && ASSETCHAINS_REWARD[0] == 0 ) { subsidy = 10000; - else if ( (ASSETCHAINS_ENDSUBSIDY[0] == 0 && ASSETCHAINS_REWARD[0] != 0) || ASSETCHAINS_ENDSUBSIDY[0] != 0 ) - { + } else if ( (ASSETCHAINS_ENDSUBSIDY[0] == 0 && ASSETCHAINS_REWARD[0] != 0) || ASSETCHAINS_ENDSUBSIDY[0] != 0 ) { // if we have an end block in the first era, find our current era if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 ) { @@ -1571,16 +1570,14 @@ uint64_t komodo_ac_block_subsidy(int nHeight) { if ( (numhalvings = ((nHeight - nStart) / ASSETCHAINS_HALVING[curEra])) > 0 ) { - if ( ASSETCHAINS_DECAY[curEra] == 0 ) + if ( ASSETCHAINS_DECAY[curEra] == 0 ) { subsidy >>= numhalvings; - else if ( ASSETCHAINS_DECAY[curEra] == 100000000 && ASSETCHAINS_ENDSUBSIDY[curEra] != 0 ) - { + fprintf(stderr,"%s: no decay, numhalvings.%d curEra.%d subsidy.%ld\n",__func__, numhalvings, curEra, subsidy); + } else if ( ASSETCHAINS_DECAY[curEra] == 100000000 && ASSETCHAINS_ENDSUBSIDY[curEra] != 0 ) { if ( curEra == ASSETCHAINS_LASTERA ) { subsidyDifference = subsidy; - } - else - { + } else { // Ex: -ac_eras=3 -ac_reward=0,384,24 -ac_end=1440,260640,0 -ac_halving=1,1440,2103840 -ac_decay 100000000,97750000,0 subsidyDifference = subsidy - ASSETCHAINS_REWARD[curEra + 1]; if (subsidyDifference < 0) @@ -1592,13 +1589,10 @@ uint64_t komodo_ac_block_subsidy(int nHeight) denominator = ASSETCHAINS_ENDSUBSIDY[curEra] - nStart; numerator = denominator - ((ASSETCHAINS_ENDSUBSIDY[curEra] - nHeight) + ((nHeight - nStart) % ASSETCHAINS_HALVING[curEra])); subsidy = subsidy - sign * ((subsidyDifference * numerator) / denominator); - } - else - { - if ( cached_subsidy > 0 && cached_era == curEra && cached_numhalvings == numhalvings ) + } else { + if ( cached_subsidy > 0 && cached_era == curEra && cached_numhalvings == numhalvings ) { subsidy = cached_subsidy; - else - { + } else { for (int i=0; i < numhalvings && subsidy != 0; i++) subsidy = (subsidy * ASSETCHAINS_DECAY[curEra]) / 100000000; cached_subsidy = subsidy; @@ -1614,6 +1608,7 @@ uint64_t komodo_ac_block_subsidy(int nHeight) uint32_t magicExtra = ASSETCHAINS_STAKED ? ASSETCHAINS_MAGIC : (ASSETCHAINS_MAGIC & 0xffffff); if ( ASSETCHAINS_SUPPLY > 10000000000 ) // over 10 billion? { + fprintf(stderr,"%s: Detected supply over 10 billion, danger zone!\n",__func__); if ( nHeight <= ASSETCHAINS_SUPPLY/1000000000 ) { subsidy += (uint64_t)1000000000 * COIN; @@ -1628,9 +1623,7 @@ uint64_t komodo_ac_block_subsidy(int nHeight) else subsidy += ASSETCHAINS_SUPPLY * SATOSHIDEN + magicExtra; } - else if ( is_STAKED(ASSETCHAINS_SYMBOL) == 2 ) - return(0); - // LABS fungible chains, cannot have any block reward! + fprintf(stderr,"%s: ht.%d curEra.%d subsidy.%ld numhalvings.%d\n",__func__,nHeight,curEra,subsidy,numhalvings); return(subsidy); } diff --git a/src/main.cpp b/src/main.cpp index 5038a0c00..c4fb5a26f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2406,19 +2406,10 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,bool checkPOW) CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) { + fprintf(stderr,"%s: ht.%d\n", __func__, nHeight); int32_t numhalvings,i; uint64_t numerator; CAmount nSubsidy = 3 * COIN; - if ( ASSETCHAINS_SYMBOL[0] == 0 ) - { - if ( nHeight == 1 ) - return(100000000 * COIN); // ICO allocation - else if ( nHeight < KOMODO_ENDOFERA ) - return(3 * COIN); - else if ( nHeight < 2*KOMODO_ENDOFERA ) - return(2 * COIN); - else return(COIN); - } else { - return(komodo_ac_block_subsidy(nHeight)); - } + + return komodo_ac_block_subsidy(nHeight); } bool IsInitialBlockDownload() From 5871b3019ab7d2fb22e9326e2b85d006b8dd998e Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 8 Sep 2020 14:57:38 -0400 Subject: [PATCH 175/255] Mo debug regarding current era and block subsidy --- src/komodo_utils.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 6df9366ec..51efd81c1 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1549,6 +1549,7 @@ uint64_t komodo_ac_block_subsidy(int nHeight) // check for backwards compat, older chains with no explicit rewards had 0.0001 block reward if ( ASSETCHAINS_ENDSUBSIDY[0] == 0 && ASSETCHAINS_REWARD[0] == 0 ) { + fprintf(stderr,"%s: defaulting to 0.0001 subsidy\n",__func__); subsidy = 10000; } else if ( (ASSETCHAINS_ENDSUBSIDY[0] == 0 && ASSETCHAINS_REWARD[0] != 0) || ASSETCHAINS_ENDSUBSIDY[0] != 0 ) { // if we have an end block in the first era, find our current era @@ -1564,6 +1565,8 @@ uint64_t komodo_ac_block_subsidy(int nHeight) { int64_t nStart = curEra ? ASSETCHAINS_ENDSUBSIDY[curEra - 1] : 0; subsidy = (int64_t)ASSETCHAINS_REWARD[curEra]; + fprintf(stderr,"%s: nStart.%ld subsidy.%ld curEra.%d\n",__func__,nStart,subsidy,curEra); + if ( subsidy || (curEra != ASSETCHAINS_LASTERA && ASSETCHAINS_REWARD[curEra + 1] != 0) ) { if ( ASSETCHAINS_HALVING[curEra] != 0 ) @@ -1572,7 +1575,7 @@ uint64_t komodo_ac_block_subsidy(int nHeight) { if ( ASSETCHAINS_DECAY[curEra] == 0 ) { subsidy >>= numhalvings; - fprintf(stderr,"%s: no decay, numhalvings.%d curEra.%d subsidy.%ld\n",__func__, numhalvings, curEra, subsidy); + fprintf(stderr,"%s: no decay, numhalvings.%d curEra.%d subsidy.%ld nStart.%ld\n",__func__, numhalvings, curEra, subsidy, nStart); } else if ( ASSETCHAINS_DECAY[curEra] == 100000000 && ASSETCHAINS_ENDSUBSIDY[curEra] != 0 ) { if ( curEra == ASSETCHAINS_LASTERA ) { From 1751f986f1757fda3d42d3dcd92a5ca33576d2f5 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 8 Sep 2020 15:16:00 -0400 Subject: [PATCH 176/255] Logspam for last and max eras --- src/komodo_utils.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 51efd81c1..13ee98890 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1618,15 +1618,13 @@ uint64_t komodo_ac_block_subsidy(int nHeight) if ( nHeight == 1 ) subsidy += (ASSETCHAINS_SUPPLY % 1000000000)*COIN + magicExtra; } - } - else if ( nHeight == 1 ) - { + } else if ( nHeight == 1 ) { if ( ASSETCHAINS_LASTERA == 0 ) subsidy = ASSETCHAINS_SUPPLY * SATOSHIDEN + magicExtra; else subsidy += ASSETCHAINS_SUPPLY * SATOSHIDEN + magicExtra; } - fprintf(stderr,"%s: ht.%d curEra.%d subsidy.%ld numhalvings.%d\n",__func__,nHeight,curEra,subsidy,numhalvings); + fprintf(stderr,"%s: ht.%d curEra.%d lastEra.%d subsidy.%ld numhalvings.%d\n",__func__,nHeight,curEra,ASSETCHAINS_LASTERA,subsidy,numhalvings); return(subsidy); } @@ -1794,6 +1792,7 @@ void komodo_args(char *argv0) printf("ASSETCHAINS_LASTERA, if specified, must be between 1 and %u. ASSETCHAINS_LASTERA set to %lu\n", ASSETCHAINS_MAX_ERAS, ASSETCHAINS_LASTERA); } ASSETCHAINS_LASTERA -= 1; + fprintf(stderr,"%s: lastEra=%d maxEras=%d\n", ASSETCHAINS_LASTERA, ASSETCHAINS_MAX_ERAS); ASSETCHAINS_TIMELOCKGTE = (uint64_t)GetArg("-ac_timelockgte", _ASSETCHAINS_TIMELOCKOFF); ASSETCHAINS_TIMEUNLOCKFROM = GetArg("-ac_timeunlockfrom", 0); @@ -1801,7 +1800,7 @@ void komodo_args(char *argv0) if ( ASSETCHAINS_TIMEUNLOCKFROM > ASSETCHAINS_TIMEUNLOCKTO ) { printf("ASSETCHAINS_TIMELOCKGTE - must specify valid ac_timeunlockfrom and ac_timeunlockto\n"); - ASSETCHAINS_TIMELOCKGTE = _ASSETCHAINS_TIMELOCKOFF; + ASSETCHAINS_TIMELOCKGTE = _ASSETCHAINS_TIMELOCKOFF; ASSETCHAINS_TIMEUNLOCKFROM = ASSETCHAINS_TIMEUNLOCKTO = 0; } From fbc34ef0714bfd02eca306115e6ffcdc6a8ee19b Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 8 Sep 2020 15:49:10 -0400 Subject: [PATCH 177/255] Implement custom Hush block subsidy code since changing our blocktime and using many eras breaks assumptions of existing code --- src/komodo_utils.h | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 13ee98890..24e5933ef 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1534,6 +1534,8 @@ char *argv0names[] = (char *)"MNZ", (char *)"MNZ", (char *)"MNZ", (char *)"MNZ", (char *)"BTCH", (char *)"BTCH", (char *)"BTCH", (char *)"BTCH" }; + +// Large total supplies lead to numerical errors, beware! uint64_t komodo_max_money() { return komodo_current_supply(10000000); @@ -1541,11 +1543,13 @@ uint64_t komodo_max_money() uint64_t komodo_ac_block_subsidy(int nHeight) { - // we have to find our era, start from beginning reward, and determine current subsidy + fprintf(stderr,"%s: ht.%d\n", __func__, nHeight); + // Find current era, start from beginning reward, and determine current subsidy int64_t numerator, denominator, subsidy = 0; int64_t subsidyDifference; int32_t numhalvings, curEra = 0, sign = 1; static uint64_t cached_subsidy; static int32_t cached_numhalvings; static int cached_era; + bool ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; // check for backwards compat, older chains with no explicit rewards had 0.0001 block reward if ( ASSETCHAINS_ENDSUBSIDY[0] == 0 && ASSETCHAINS_REWARD[0] == 0 ) { @@ -1561,6 +1565,7 @@ uint64_t komodo_ac_block_subsidy(int nHeight) break; } } + if ( curEra <= ASSETCHAINS_LASTERA ) { int64_t nStart = curEra ? ASSETCHAINS_ENDSUBSIDY[curEra - 1] : 0; @@ -1571,8 +1576,26 @@ uint64_t komodo_ac_block_subsidy(int nHeight) { if ( ASSETCHAINS_HALVING[curEra] != 0 ) { - if ( (numhalvings = ((nHeight - nStart) / ASSETCHAINS_HALVING[curEra])) > 0 ) - { + if (ishush3) { + //TODO: Cover all halvings until BR=0 + if (nHeight >= 129) { + // This is the beginning of an Era but not a Halving + } else if (nHeight >= GetArg("-z2zheight",340000)) { + numhalvings = 1; + } else if (nHeight >= 2020000) { + numhalvings = 2; + } else if (nHeight >= 3700000) { + numhalvings = 3; + } + + // Since we had 128 blocks of BR=0 when we launched Hush v3 mainnet, it adds an index + // to the beginning of ASSETCHAINS_REWARD, so we must add one to numhalvings to get + // the correct block reward + subsidy = ASSETCHAINS_REWARD[numhalvings+1]; + + fprintf(stderr,"%s: HUSH3 subsidy=%ld numhalvings=%d at height=%d\n",__func__,subsidy,numhalvings,nHeight); + } else if ( (numhalvings = ((nHeight - nStart) / ASSETCHAINS_HALVING[curEra])) > 0 ) { + // The code below is not compatible with HUSH3 mainnet if ( ASSETCHAINS_DECAY[curEra] == 0 ) { subsidy >>= numhalvings; fprintf(stderr,"%s: no decay, numhalvings.%d curEra.%d subsidy.%ld nStart.%ld\n",__func__, numhalvings, curEra, subsidy, nStart); @@ -1606,6 +1629,8 @@ uint64_t komodo_ac_block_subsidy(int nHeight) } } } + } else { + fprintf(stderr,"%s: curEra.%d > lastEra.%lu\n", __func__, curEra, ASSETCHAINS_LASTERA); } } uint32_t magicExtra = ASSETCHAINS_STAKED ? ASSETCHAINS_MAGIC : (ASSETCHAINS_MAGIC & 0xffffff); @@ -1624,7 +1649,7 @@ uint64_t komodo_ac_block_subsidy(int nHeight) else subsidy += ASSETCHAINS_SUPPLY * SATOSHIDEN + magicExtra; } - fprintf(stderr,"%s: ht.%d curEra.%d lastEra.%d subsidy.%ld numhalvings.%d\n",__func__,nHeight,curEra,ASSETCHAINS_LASTERA,subsidy,numhalvings); + fprintf(stderr,"%s: ht.%d curEra.%d lastEra.%lu subsidy.%ld numhalvings.%d magicExtra.%u\n",__func__,nHeight,curEra,ASSETCHAINS_LASTERA,subsidy,numhalvings,magicExtra); return(subsidy); } @@ -1792,7 +1817,7 @@ void komodo_args(char *argv0) printf("ASSETCHAINS_LASTERA, if specified, must be between 1 and %u. ASSETCHAINS_LASTERA set to %lu\n", ASSETCHAINS_MAX_ERAS, ASSETCHAINS_LASTERA); } ASSETCHAINS_LASTERA -= 1; - fprintf(stderr,"%s: lastEra=%d maxEras=%d\n", ASSETCHAINS_LASTERA, ASSETCHAINS_MAX_ERAS); + fprintf(stderr,"%s: lastEra=%lu maxEras=%d\n", __func__, ASSETCHAINS_LASTERA, ASSETCHAINS_MAX_ERAS); ASSETCHAINS_TIMELOCKGTE = (uint64_t)GetArg("-ac_timelockgte", _ASSETCHAINS_TIMELOCKOFF); ASSETCHAINS_TIMEUNLOCKFROM = GetArg("-ac_timeunlockfrom", 0); From 3744f429f29dfe7c1504688b8a0a8a4ce6662b7f Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 8 Sep 2020 15:52:09 -0400 Subject: [PATCH 178/255] Re-enable 3rd block subsidy era --- src/komodo_utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 24e5933ef..b6f8494cf 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1841,11 +1841,11 @@ void komodo_args(char *argv0) ASSETCHAINS_REWARD[0] = 0; ASSETCHAINS_REWARD[1] = 1125000000; ASSETCHAINS_REWARD[2] = 281250000; // 2.8125 HUSH goes to miners per block after 1st halving at Block 340K - //ASSETCHAINS_REWARD[3] = 140625000; // 1.40625 HUSH after 2nd halving at Block 2020000 + ASSETCHAINS_REWARD[3] = 140625000; // 1.40625 HUSH after 2nd halving at Block 2020000 ASSETCHAINS_HALVING[0] = 129; ASSETCHAINS_HALVING[1] = GetArg("-z2zheight",340000); ASSETCHAINS_HALVING[2] = 2020000; // 2020000 = 340000 + 1680000 (1st halving block plus new halving interval) - //ASSETCHAINS_HALVING[3] = 3700000; // ASSETCHAINS_HALVING[2] + 1680000; + ASSETCHAINS_HALVING[3] = 3700000; // ASSETCHAINS_HALVING[2] + 1680000; ASSETCHAINS_ENDSUBSIDY[0] = 129; ASSETCHAINS_ENDSUBSIDY[1] = GetArg("-z2zheight",340000); ASSETCHAINS_ENDSUBSIDY[2] = 2*5422111; // TODO: Fix this, twice the previous end of rewards is an estimate From b432e27f1b1efff046411a44beb94aae5cc18f95 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 8 Sep 2020 16:10:32 -0400 Subject: [PATCH 179/255] Refactor hush block subsidy --- src/komodo_utils.h | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index b6f8494cf..89c1228e6 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1578,21 +1578,17 @@ uint64_t komodo_ac_block_subsidy(int nHeight) { if (ishush3) { //TODO: Cover all halvings until BR=0 - if (nHeight >= 129) { - // This is the beginning of an Era but not a Halving + //if (nHeight >= 3700000) { + // subsidy = ASSETCHAINS_REWARD[4]; + //} else + if (nHeight >= 2020000) { + subsidy = ASSETCHAINS_REWARD[3]; } else if (nHeight >= GetArg("-z2zheight",340000)) { - numhalvings = 1; - } else if (nHeight >= 2020000) { - numhalvings = 2; - } else if (nHeight >= 3700000) { - numhalvings = 3; + subsidy = ASSETCHAINS_REWARD[2]; + } else if (nHeight >= 129) { + subsidy = ASSETCHAINS_REWARD[1]; } - // Since we had 128 blocks of BR=0 when we launched Hush v3 mainnet, it adds an index - // to the beginning of ASSETCHAINS_REWARD, so we must add one to numhalvings to get - // the correct block reward - subsidy = ASSETCHAINS_REWARD[numhalvings+1]; - fprintf(stderr,"%s: HUSH3 subsidy=%ld numhalvings=%d at height=%d\n",__func__,subsidy,numhalvings,nHeight); } else if ( (numhalvings = ((nHeight - nStart) / ASSETCHAINS_HALVING[curEra])) > 0 ) { // The code below is not compatible with HUSH3 mainnet From f4294a25cffccf1dfcc109e2bd541442561cd500 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Tue, 8 Sep 2020 14:33:52 -0700 Subject: [PATCH 180/255] Be more explicit --- src/komodo_utils.h | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 89c1228e6..40a0368bf 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1541,6 +1541,22 @@ uint64_t komodo_max_money() return komodo_current_supply(10000000); } +uint64_t hush_block_subsidy(int nHeight) +{ + uint64_t subsidy=0; + //TODO: Cover all halvings until BR=0 + //if (nHeight >= 3700000) { + // subsidy = ASSETCHAINS_REWARD[4]; + //} else + if (nHeight >= 2020000) { + subsidy = 14062500; + } else if (nHeight >= GetArg("-z2zheight",340000)) { + subsidy = 281250000; + } else if (nHeight >= 129) { + subsidy = 1125000000; + } + return subsidy; +} uint64_t komodo_ac_block_subsidy(int nHeight) { fprintf(stderr,"%s: ht.%d\n", __func__, nHeight); @@ -1577,19 +1593,8 @@ uint64_t komodo_ac_block_subsidy(int nHeight) if ( ASSETCHAINS_HALVING[curEra] != 0 ) { if (ishush3) { - //TODO: Cover all halvings until BR=0 - //if (nHeight >= 3700000) { - // subsidy = ASSETCHAINS_REWARD[4]; - //} else - if (nHeight >= 2020000) { - subsidy = ASSETCHAINS_REWARD[3]; - } else if (nHeight >= GetArg("-z2zheight",340000)) { - subsidy = ASSETCHAINS_REWARD[2]; - } else if (nHeight >= 129) { - subsidy = ASSETCHAINS_REWARD[1]; - } - - fprintf(stderr,"%s: HUSH3 subsidy=%ld numhalvings=%d at height=%d\n",__func__,subsidy,numhalvings,nHeight); + subsidy = hush_block_subsidy(nHeight); + fprintf(stderr,"%s: HUSH3 subsidy=%ld at height=%d\n",__func__,subsidy,nHeight); } else if ( (numhalvings = ((nHeight - nStart) / ASSETCHAINS_HALVING[curEra])) > 0 ) { // The code below is not compatible with HUSH3 mainnet if ( ASSETCHAINS_DECAY[curEra] == 0 ) { From dd13bfb3949f06911a0dfdb4c1902cddea565a88 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Tue, 8 Sep 2020 14:38:58 -0700 Subject: [PATCH 181/255] Yep --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 40a0368bf..5d2980df9 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1549,7 +1549,7 @@ uint64_t hush_block_subsidy(int nHeight) // subsidy = ASSETCHAINS_REWARD[4]; //} else if (nHeight >= 2020000) { - subsidy = 14062500; + subsidy = 140625000; } else if (nHeight >= GetArg("-z2zheight",340000)) { subsidy = 281250000; } else if (nHeight >= 129) { From 844626f4572d04c072ad666f4eb69ea77e4e11c7 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Tue, 8 Sep 2020 15:06:06 -0700 Subject: [PATCH 182/255] Block 128 has a block reward of 11.25 HUSH --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 5d2980df9..52d6899f0 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1552,7 +1552,7 @@ uint64_t hush_block_subsidy(int nHeight) subsidy = 140625000; } else if (nHeight >= GetArg("-z2zheight",340000)) { subsidy = 281250000; - } else if (nHeight >= 129) { + } else if (nHeight >= 128) { subsidy = 1125000000; } return subsidy; From 5412da7d715160259381481246163a2663c90ff9 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 9 Sep 2020 11:42:52 -0400 Subject: [PATCH 183/255] Connect z_listreceivedaddress to the outside world --- src/rpc/client.cpp | 10 +++++----- src/rpc/server.cpp | 1 + src/rpc/server.h | 1 + src/wallet/rpchushwallet.cpp | 7 +++++++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index 4f11a476f..a3e04623a 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -169,11 +169,11 @@ static const CRPCConvertParam vRPCConvertParams[] = { "z_listsentbyaddress", 3}, { "z_listsentbyaddress", 4}, { "z_listsentbyaddress", 5}, - { "z_listreceivedbyaddress", 1}, - { "z_listreceivedbyaddress", 2}, - { "z_listreceivedbyaddress", 3}, - { "z_listreceivedbyaddress", 4}, - { "z_listreceivedbyaddress", 5}, + { "z_listreceivedaddress", 1}, + { "z_listreceivedaddress", 2}, + { "z_listreceivedaddress", 3}, + { "z_listreceivedaddress", 4}, + { "z_listreceivedaddress", 5}, // crosschain { "assetchainproof", 1}, diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 56c038596..16b25ae81 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -652,6 +652,7 @@ static const CRPCCommand vRPCCommands[] = { "wallet", "walletpassphrasechange", &walletpassphrasechange, true }, { "wallet", "walletpassphrase", &walletpassphrase, true }, { "wallet", "z_listreceivedbyaddress",&z_listreceivedbyaddress,false }, + { "wallet", "z_listreceivedaddress", &z_listreceivedaddress, false }, { "wallet", "z_getbalance", &z_getbalance, false }, { "wallet", "z_gettotalbalance", &z_gettotalbalance, false }, { "wallet", "z_mergetoaddress", &z_mergetoaddress, false }, diff --git a/src/rpc/server.h b/src/rpc/server.h index 6568977d7..15c982d81 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -480,6 +480,7 @@ extern UniValue z_listnullifiers(const UniValue& params, bool fHelp, const CPubK extern UniValue z_exportwallet(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcdump.cpp extern UniValue z_importwallet(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcdump.cpp extern UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp +extern UniValue z_listreceivedaddress(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp extern UniValue z_getbalance(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp extern UniValue z_gettotalbalance(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp extern UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rpcwallet.cpp diff --git a/src/wallet/rpchushwallet.cpp b/src/wallet/rpchushwallet.cpp index 64cd0e4a5..5fd77cc97 100644 --- a/src/wallet/rpchushwallet.cpp +++ b/src/wallet/rpchushwallet.cpp @@ -134,6 +134,9 @@ void zsTxSpendsToJSON(const CWalletTx& wtx, UniValue& spends, CAmount& totalSpen void zsTxReceivedToJSON(const CWalletTx& wtx, UniValue& received, CAmount& totalReceived, const std::string& strAddress, bool filterByAddress) { + if(fZdebug) + fprintf(stderr,"%s: txid=%s\n", __func__, wtx.GetHash().ToString().c_str() ); + LOCK2(cs_main, pwalletMain->cs_wallet); //Check address @@ -401,6 +404,10 @@ void zsWalletTxJSON(const CWalletTx& wtx, UniValue& ret, const std::string strAd //Begin Compiling the Decrypted Transaction tx.push_back(Pair("txid", wtx.GetHash().ToString())); + + if(fZdebug) + fprintf(stderr,"%s: txid=%s\n", __func__, wtx.GetHash().ToString().c_str() ); + if (wtx.IsCoinBase()) { tx.push_back(Pair("coinbase", true)); From fc9725ca4421bfc8c395d6959585653aa2ace3e5 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 9 Sep 2020 11:45:23 -0400 Subject: [PATCH 184/255] Fix docs --- src/wallet/rpcwallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index a2fa34b3b..130394413 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3352,8 +3352,8 @@ UniValue z_listreceivedaddress(const UniValue& params, bool fHelp,const CPubKey& if (fHelp || params.size() > 5 || params.size() == 3) throw runtime_error( - "z_listreceivedbyaddress\n" - "\nReturns received outputs for a single address.\n" + "z_listreceivedaddress\n" + "\nReturns received outputs.\n" "\n" "This function only returns information on addresses with full spending keys." "\n" From 0614f51f286a899a87b3ce1b53988ec45853e988 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 9 Sep 2020 11:51:59 -0400 Subject: [PATCH 185/255] Fix more docs bugs --- src/wallet/rpcwallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 130394413..19157432b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3411,8 +3411,8 @@ UniValue z_listreceivedaddress(const UniValue& params, bool fHelp,const CPubKey& " }],\n" " },\n" "\nExamples:\n" - + HelpExampleCli("z_listreceivedbyaddress", "R...") - + HelpExampleRpc("z_listreceivedbyaddress", "R...") + + HelpExampleCli("z_listreceivedaddress", "\"*\"") + + HelpExampleRpc("z_listreceivedaddress", "RHushEyeDm7XwtaTWtyCbjGQumYyV8vMjn") ); LOCK2(cs_main, pwalletMain->cs_wallet); From 032c7cbb9f8d31f19ff002a5ce0f8cc49616782e Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Wed, 9 Sep 2020 12:58:53 -0400 Subject: [PATCH 186/255] Add transaction time to z_listreceivedbyaddress which drastically speeds up SD operations --- src/wallet/rpcwallet.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 19157432b..3b6361fe3 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4086,7 +4086,8 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp, const CPubK " \"txid\": xxxxx, (string) the transaction id\n" " \"amount\": xxxxx, (numeric) the amount of value in the note\n" " \"memo\": xxxxx, (string) hexadecimal string representation of memo field\n" - " \"confirmations\" : n, (numeric) the number of confirmations\n" + " \"confirmations\" : n, (numeric) the number of notarized confirmations (dpowconfs)\n" + " \"rawconfirmations\" : n, (numeric) the number of raw confirmations\n" " \"outindex\" (sapling) : n, (numeric) the output index\n" " \"change\": true|false, (boolean) true if the address that received the note is also one of the sending addresses\n" "}\n" @@ -4131,7 +4132,6 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp, const CPubK if (boost::get(&zaddr) != nullptr) { for (SaplingNoteEntry & entry : saplingEntries) { UniValue obj(UniValue::VOBJ); - int nHeight = tx_height(entry.op.hash); int dpowconfs = komodo_dpowconfs(nHeight, entry.confirmations); // Only return notarized results when minconf>1 @@ -4152,6 +4152,10 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp, const CPubK } obj.push_back(Pair("outindex", (int)entry.op.n)); obj.push_back(Pair("rawconfirmations", entry.confirmations)); + auto wtx = pwalletMain->mapWallet.at(entry.op.hash); //.ToString()); + //fprintf(stderr,"%s: txid=%s not found in wallet!\n", __func__, entry.op.hash.ToString().c_str()); + obj.push_back(Pair("time", wtx.GetTxTime())); + obj.push_back(Pair("confirmations", dpowconfs)); if (hasSpendingKey) { obj.push_back(Pair("change", pwalletMain->IsNoteSaplingChange(nullifierSet, entry.address, entry.op))); From 5d08cd7b577f0322776fe90793c4b5f313f1ef7b Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 11 Sep 2020 07:23:37 -0400 Subject: [PATCH 187/255] Refactor Hush supply curve into a dedicated function and increase logspam --- src/komodo_bitcoind.h | 133 +++++++++++++++++++++++------------------- src/komodo_utils.h | 4 ++ 2 files changed, 76 insertions(+), 61 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 50973ef03..ff37a4847 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1238,6 +1238,70 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); // 10% of all block rewards go towards Hush core team // If you do not like this, you are encouraged to fork the chain // or start your own Hush Smart Chain: https://github.com/myhush/hush-smart-chains +// HUSH supply curve cannot be exactly represented via KMD AC CLI args, so we do it ourselves. +// You specify the BR, and the FR % gets added so 10% of 12.5 is 1.25 +// but to tell the AC params, I need to say "11% of 11.25" is 1.25 +// 11% ie. 1/9th cannot be exactly represented and so the FR has tiny amounts of error unless done manually +// Do not change this code unless you really know what you are doing. +// Here Be Dragons! -- Duke Leto +uint64_t hush_commission(int height) +{ + // TODO: Calculate new BR_END based on 75s block time!!! 2X old BR_END is a rough estimate, not exact! + int32_t starting_commission = 125000000, HALVING1 = GetArg("-z2zheight",340000), + INTERVAL = GetArg("-ac_halving1",840000), TRANSITION = 129, BR_END = 2*5422111; + // TODO: how many halvings will we have given new 75s blocktime? + int32_t commisions[] = {starting_commission, 31250000, 15625000, 78125000, 39062500, 19531250, 9765625, // these are exact + 4882812, 2441406, 1220703, 610351 // these have deviation from ideal BR + // Just like BTC, BRs in the far future will be slightly less than + // they should be because exact values are not integers, causing + // slightly less coins to be actually mined + }; + uint64_t commission = 0; + + if( height > HALVING1) { + // Block time going from 150s to 75s (half) means the interval between halvings + // must be twice as often, i.e. 840000*2=1680000 + // With 150s blocks, we have 210,000 blocks per year + // With 75s blocks, we have 420,000 blocks per year + INTERVAL = GetArg("-ac_halving2",1680000); + fprintf(stderr,"%s: height=%d increasing interval to %d\n", __func__, height, INTERVAL); + } + + // Transition period of 128 blocks has BR=FR=0 + if (height < TRANSITION) { + commission = 0; + } else if (height < HALVING1) { // before 1st Halving @ Block 340000 (Nov 2020) + commission = commisions[0]; + } else if (height < HALVING1+1*INTERVAL) { // before 2nd Halving @ Block 2020000 + commission = commisions[1]; + } else if (height < HALVING1+2*INTERVAL) { // before 3rd Halving @ Block 3700000 + commission = commisions[2]; + } else if (height < HALVING1+3*INTERVAL) { // before 4th Halving @ Block 5380000 + commission = commisions[3]; + } else if (height < HALVING1+4*INTERVAL) { // before 5th Halving @ Block 7060000 + commission = commisions[4]; + } else if (height < HALVING1+5*INTERVAL) { // before 6th Halving @ Block 8740000 + commission = commisions[5]; + } else if (height < HALVING1+6*INTERVAL) { // before 7th Halving @ Block 10420000 + commission = commisions[6]; + } else if (height < HALVING1+7*INTERVAL) { // before 8th Halving @ Block 12100000 + // TODO: Still true??? Block reward will go to zero between 7th+8th halvings, ac_end may need adjusting + commission = commisions[7]; + } else if (height < HALVING1+8*INTERVAL) { // before 9th Halving @ Block 13780000 + // BR should be zero before this halving happens + commission = commisions[8]; + } + // Explicitly set the last block reward + // BR_END is the block with the last non-zero block reward, which overrides + // the -ac_end param on HUSH3 + if(height > BR_END) { + fprintf(stderr,"%s: HUSH block reward has gone to zero at height %d!!! It was a good run folks\n", __func__, height); + commission = 0; + } + fprintf(stderr,"%s: commission=%lu,interval=%d at height %d\n", __func__, commission, INTERVAL, height); + return commission; +} + uint64_t komodo_commission(const CBlock *pblock,int32_t height) { fprintf(stderr,"%s at height=%d\n",__func__,height); @@ -1256,78 +1320,25 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); - // Do not change this code unless you really know what you are doing. - // Here Be Dragons! -- Duke Leto if (ishush3) { - // TODO: Calculate new BR_END based on 75s block time!!! 2X old BR_END is a rough estimate, not exact! - int32_t starting_commission = 125000000, HALVING1 = GetArg("-z2zheight",340000), - INTERVAL = GetArg("-ac_halving1",840000), TRANSITION = 129, BR_END = 2*5422111; - // TODO: how many halvings will we have given new 75s blocktime? - int32_t commisions[] = {starting_commission, 31250000, 15625000, 78125000, 39062500, 19531250, 9765625, // these are exact - 4882812, 2441406, 1220703, 610351 // these have deviation from ideal BR - // Just like BTC, BRs in the far future will be slightly less than - // they should be because exact values are not integers, causing - // slightly less coins to be actually mined - }; - // HUSH supply curve cannot be exactly represented via KMD AC CLI args, so we do it ourselves. - // You specify the BR, and the FR % gets added so 10% of 12.5 is 1.25 - // but to tell the AC params, I need to say "11% of 11.25" is 1.25 - // 11% ie. 1/9th cannot be exactly represented and so the FR has tiny amounts of error unless done manually - - if( height > HALVING1) { - // Block time going from 150s to 75s (half) means the interval between halvings - // must be twice as often, i.e. 840000*2=1680000 - // With 150s blocks, we have 210,000 blocks per year - // With 75s blocks, we have 420,000 blocks per year - INTERVAL = GetArg("-ac_halving2",1680000); - } - - // Transition period of 128 blocks has BR=FR=0 - if (height < TRANSITION) { - commission = 0; - } else if (height < HALVING1) { // before 1st Halving @ Block 340000 (Nov 2020) - commission = commisions[0]; - } else if (height < HALVING1+1*INTERVAL) { // before 2nd Halving @ Block 2020000 - commission = commisions[1]; - } else if (height < HALVING1+2*INTERVAL) { // before 3rd Halving @ Block 3700000 - commission = commisions[2]; - } else if (height < HALVING1+3*INTERVAL) { // before 4th Halving @ Block 5380000 - commission = commisions[3]; - } else if (height < HALVING1+4*INTERVAL) { // before 5th Halving @ Block 7060000 - commission = commisions[4]; - } else if (height < HALVING1+5*INTERVAL) { // before 6th Halving @ Block 8740000 - commission = commisions[5]; - } else if (height < HALVING1+6*INTERVAL) { // before 7th Halving @ Block 10420000 - commission = commisions[6]; - } else if (height < HALVING1+7*INTERVAL) { // before 8th Halving @ Block 12100000 - // TODO: Still true??? Block reward will go to zero between 7th+8th halvings, ac_end may need adjusting - commission = commisions[7]; - } else if (height < HALVING1+8*INTERVAL) { // before 9th Halving @ Block 13780000 - // BR should be zero before this halving happens - commission = commisions[8]; - } - // Explicitly set the last block reward - // BR_END is the block with the last non-zero block reward, which overrides - // the -ac_end param on HUSH3 - if(height > BR_END) { - commission = 0; - } + commission = hush_commission(height); } if ( ASSETCHAINS_FOUNDERS > 1 ) { if ( (height % ASSETCHAINS_FOUNDERS) == 0 ) { - if ( ASSETCHAINS_FOUNDERS_REWARD == 0 ) + if ( ASSETCHAINS_FOUNDERS_REWARD == 0 ) { commission = commission * ASSETCHAINS_FOUNDERS; - else + } else { commission = ASSETCHAINS_FOUNDERS_REWARD; + } + fprintf(stderr,"%s: set commission=%lu at height %d with\n",__func__,commission, height); + } else { + commission = 0; } - else commission = 0; } - } - else if ( pblock != 0 ) - { + } else if ( pblock != 0 ) { txn_count = pblock->vtx.size(); for (i=0; i Date: Fri, 11 Sep 2020 10:27:14 -0400 Subject: [PATCH 188/255] bip39 updates + tweaks --- src/crypto/bip39/bip39.c | 2 + src/crypto/bip39/bip39.h | 14 +- src/crypto/bip39/bip39_english.h | 2393 +++++++++++++++++++++++++----- src/crypto/bip39/hmac.h | 32 +- src/crypto/bip39/memzero.h | 2 +- src/crypto/bip39/options.h | 2 +- src/crypto/bip39/pbkdf2.h | 42 +- 7 files changed, 2085 insertions(+), 402 deletions(-) diff --git a/src/crypto/bip39/bip39.c b/src/crypto/bip39/bip39.c index 33455f6c5..76e0792ad 100644 --- a/src/crypto/bip39/bip39.c +++ b/src/crypto/bip39/bip39.c @@ -35,6 +35,8 @@ #if USE_BIP39_CACHE +int BIP39_WORDS = 2048; + static int bip39_cache_index = 0; static CONFIDENTIAL struct { diff --git a/src/crypto/bip39/bip39.h b/src/crypto/bip39/bip39.h index 07fb21bb2..ac76101d7 100644 --- a/src/crypto/bip39/bip39.h +++ b/src/crypto/bip39/bip39.h @@ -24,13 +24,11 @@ #ifndef __BIP39_H__ #define __BIP39_H__ -#include #include -#define BIP39_WORDS 2048 #define BIP39_PBKDF2_ROUNDS 2048 -const char *mnemonic_generate(int strength); // strength in bits +const char *mnemonic_generate(int strength); // strength in bits const char *mnemonic_from_data(const uint8_t *data, int len); void mnemonic_clear(void); @@ -39,14 +37,8 @@ int mnemonic_check(const char *mnemonic); int mnemonic_to_entropy(const char *mnemonic, uint8_t *entropy); // passphrase must be at most 256 characters otherwise it would be truncated -void mnemonic_to_seed(const char *mnemonic, const char *passphrase, - uint8_t seed[512 / 8], - void (*progress_callback)(uint32_t current, - uint32_t total)); +void mnemonic_to_seed(const char *mnemonic, const char *passphrase, uint8_t seed[512 / 8], void (*progress_callback)(uint32_t current, uint32_t total)); -int mnemonic_find_word(const char *word); -const char *mnemonic_complete_word(const char *prefix, int len); -const char *mnemonic_get_word(int index); -uint32_t mnemonic_word_completion_mask(const char *prefix, int len); +const char * const *mnemonic_wordlist(void); #endif diff --git a/src/crypto/bip39/bip39_english.h b/src/crypto/bip39/bip39_english.h index c57fca365..77607ba7f 100644 --- a/src/crypto/bip39/bip39_english.h +++ b/src/crypto/bip39/bip39_english.h @@ -21,347 +21,2054 @@ * OTHER DEALINGS IN THE SOFTWARE. */ -static const char* const wordlist[] = { - "abandon", "ability", "able", "about", "above", "absent", - "absorb", "abstract", "absurd", "abuse", "access", "accident", - "account", "accuse", "achieve", "acid", "acoustic", "acquire", - "across", "act", "action", "actor", "actress", "actual", - "adapt", "add", "addict", "address", "adjust", "admit", - "adult", "advance", "advice", "aerobic", "affair", "afford", - "afraid", "again", "age", "agent", "agree", "ahead", - "aim", "air", "airport", "aisle", "alarm", "album", - "alcohol", "alert", "alien", "all", "alley", "allow", - "almost", "alone", "alpha", "already", "also", "alter", - "always", "amateur", "amazing", "among", "amount", "amused", - "analyst", "anchor", "ancient", "anger", "angle", "angry", - "animal", "ankle", "announce", "annual", "another", "answer", - "antenna", "antique", "anxiety", "any", "apart", "apology", - "appear", "apple", "approve", "april", "arch", "arctic", - "area", "arena", "argue", "arm", "armed", "armor", - "army", "around", "arrange", "arrest", "arrive", "arrow", - "art", "artefact", "artist", "artwork", "ask", "aspect", - "assault", "asset", "assist", "assume", "asthma", "athlete", - "atom", "attack", "attend", "attitude", "attract", "auction", - "audit", "august", "aunt", "author", "auto", "autumn", - "average", "avocado", "avoid", "awake", "aware", "away", - "awesome", "awful", "awkward", "axis", "baby", "bachelor", - "bacon", "badge", "bag", "balance", "balcony", "ball", - "bamboo", "banana", "banner", "bar", "barely", "bargain", - "barrel", "base", "basic", "basket", "battle", "beach", - "bean", "beauty", "because", "become", "beef", "before", - "begin", "behave", "behind", "believe", "below", "belt", - "bench", "benefit", "best", "betray", "better", "between", - "beyond", "bicycle", "bid", "bike", "bind", "biology", - "bird", "birth", "bitter", "black", "blade", "blame", - "blanket", "blast", "bleak", "bless", "blind", "blood", - "blossom", "blouse", "blue", "blur", "blush", "board", - "boat", "body", "boil", "bomb", "bone", "bonus", - "book", "boost", "border", "boring", "borrow", "boss", - "bottom", "bounce", "box", "boy", "bracket", "brain", - "brand", "brass", "brave", "bread", "breeze", "brick", - "bridge", "brief", "bright", "bring", "brisk", "broccoli", - "broken", "bronze", "broom", "brother", "brown", "brush", - "bubble", "buddy", "budget", "buffalo", "build", "bulb", - "bulk", "bullet", "bundle", "bunker", "burden", "burger", - "burst", "bus", "business", "busy", "butter", "buyer", - "buzz", "cabbage", "cabin", "cable", "cactus", "cage", - "cake", "call", "calm", "camera", "camp", "can", - "canal", "cancel", "candy", "cannon", "canoe", "canvas", - "canyon", "capable", "capital", "captain", "car", "carbon", - "card", "cargo", "carpet", "carry", "cart", "case", - "cash", "casino", "castle", "casual", "cat", "catalog", - "catch", "category", "cattle", "caught", "cause", "caution", - "cave", "ceiling", "celery", "cement", "census", "century", - "cereal", "certain", "chair", "chalk", "champion", "change", - "chaos", "chapter", "charge", "chase", "chat", "cheap", - "check", "cheese", "chef", "cherry", "chest", "chicken", - "chief", "child", "chimney", "choice", "choose", "chronic", - "chuckle", "chunk", "churn", "cigar", "cinnamon", "circle", - "citizen", "city", "civil", "claim", "clap", "clarify", - "claw", "clay", "clean", "clerk", "clever", "click", - "client", "cliff", "climb", "clinic", "clip", "clock", - "clog", "close", "cloth", "cloud", "clown", "club", - "clump", "cluster", "clutch", "coach", "coast", "coconut", - "code", "coffee", "coil", "coin", "collect", "color", - "column", "combine", "come", "comfort", "comic", "common", - "company", "concert", "conduct", "confirm", "congress", "connect", - "consider", "control", "convince", "cook", "cool", "copper", - "copy", "coral", "core", "corn", "correct", "cost", - "cotton", "couch", "country", "couple", "course", "cousin", - "cover", "coyote", "crack", "cradle", "craft", "cram", - "crane", "crash", "crater", "crawl", "crazy", "cream", - "credit", "creek", "crew", "cricket", "crime", "crisp", - "critic", "crop", "cross", "crouch", "crowd", "crucial", - "cruel", "cruise", "crumble", "crunch", "crush", "cry", - "crystal", "cube", "culture", "cup", "cupboard", "curious", - "current", "curtain", "curve", "cushion", "custom", "cute", - "cycle", "dad", "damage", "damp", "dance", "danger", - "daring", "dash", "daughter", "dawn", "day", "deal", - "debate", "debris", "decade", "december", "decide", "decline", - "decorate", "decrease", "deer", "defense", "define", "defy", - "degree", "delay", "deliver", "demand", "demise", "denial", - "dentist", "deny", "depart", "depend", "deposit", "depth", - "deputy", "derive", "describe", "desert", "design", "desk", - "despair", "destroy", "detail", "detect", "develop", "device", - "devote", "diagram", "dial", "diamond", "diary", "dice", - "diesel", "diet", "differ", "digital", "dignity", "dilemma", - "dinner", "dinosaur", "direct", "dirt", "disagree", "discover", - "disease", "dish", "dismiss", "disorder", "display", "distance", - "divert", "divide", "divorce", "dizzy", "doctor", "document", - "dog", "doll", "dolphin", "domain", "donate", "donkey", - "donor", "door", "dose", "double", "dove", "draft", - "dragon", "drama", "drastic", "draw", "dream", "dress", - "drift", "drill", "drink", "drip", "drive", "drop", - "drum", "dry", "duck", "dumb", "dune", "during", - "dust", "dutch", "duty", "dwarf", "dynamic", "eager", - "eagle", "early", "earn", "earth", "easily", "east", - "easy", "echo", "ecology", "economy", "edge", "edit", - "educate", "effort", "egg", "eight", "either", "elbow", - "elder", "electric", "elegant", "element", "elephant", "elevator", - "elite", "else", "embark", "embody", "embrace", "emerge", - "emotion", "employ", "empower", "empty", "enable", "enact", - "end", "endless", "endorse", "enemy", "energy", "enforce", - "engage", "engine", "enhance", "enjoy", "enlist", "enough", - "enrich", "enroll", "ensure", "enter", "entire", "entry", - "envelope", "episode", "equal", "equip", "era", "erase", - "erode", "erosion", "error", "erupt", "escape", "essay", - "essence", "estate", "eternal", "ethics", "evidence", "evil", - "evoke", "evolve", "exact", "example", "excess", "exchange", - "excite", "exclude", "excuse", "execute", "exercise", "exhaust", - "exhibit", "exile", "exist", "exit", "exotic", "expand", - "expect", "expire", "explain", "expose", "express", "extend", - "extra", "eye", "eyebrow", "fabric", "face", "faculty", - "fade", "faint", "faith", "fall", "false", "fame", - "family", "famous", "fan", "fancy", "fantasy", "farm", - "fashion", "fat", "fatal", "father", "fatigue", "fault", - "favorite", "feature", "february", "federal", "fee", "feed", - "feel", "female", "fence", "festival", "fetch", "fever", - "few", "fiber", "fiction", "field", "figure", "file", - "film", "filter", "final", "find", "fine", "finger", - "finish", "fire", "firm", "first", "fiscal", "fish", - "fit", "fitness", "fix", "flag", "flame", "flash", - "flat", "flavor", "flee", "flight", "flip", "float", - "flock", "floor", "flower", "fluid", "flush", "fly", - "foam", "focus", "fog", "foil", "fold", "follow", - "food", "foot", "force", "forest", "forget", "fork", - "fortune", "forum", "forward", "fossil", "foster", "found", - "fox", "fragile", "frame", "frequent", "fresh", "friend", - "fringe", "frog", "front", "frost", "frown", "frozen", - "fruit", "fuel", "fun", "funny", "furnace", "fury", - "future", "gadget", "gain", "galaxy", "gallery", "game", - "gap", "garage", "garbage", "garden", "garlic", "garment", - "gas", "gasp", "gate", "gather", "gauge", "gaze", - "general", "genius", "genre", "gentle", "genuine", "gesture", - "ghost", "giant", "gift", "giggle", "ginger", "giraffe", - "girl", "give", "glad", "glance", "glare", "glass", - "glide", "glimpse", "globe", "gloom", "glory", "glove", - "glow", "glue", "goat", "goddess", "gold", "good", - "goose", "gorilla", "gospel", "gossip", "govern", "gown", - "grab", "grace", "grain", "grant", "grape", "grass", - "gravity", "great", "green", "grid", "grief", "grit", - "grocery", "group", "grow", "grunt", "guard", "guess", - "guide", "guilt", "guitar", "gun", "gym", "habit", - "hair", "half", "hammer", "hamster", "hand", "happy", - "harbor", "hard", "harsh", "harvest", "hat", "have", - "hawk", "hazard", "head", "health", "heart", "heavy", - "hedgehog", "height", "hello", "helmet", "help", "hen", - "hero", "hidden", "high", "hill", "hint", "hip", - "hire", "history", "hobby", "hockey", "hold", "hole", - "holiday", "hollow", "home", "honey", "hood", "hope", - "horn", "horror", "horse", "hospital", "host", "hotel", - "hour", "hover", "hub", "huge", "human", "humble", - "humor", "hundred", "hungry", "hunt", "hurdle", "hurry", - "hurt", "husband", "hybrid", "ice", "icon", "idea", - "identify", "idle", "ignore", "ill", "illegal", "illness", - "image", "imitate", "immense", "immune", "impact", "impose", - "improve", "impulse", "inch", "include", "income", "increase", - "index", "indicate", "indoor", "industry", "infant", "inflict", - "inform", "inhale", "inherit", "initial", "inject", "injury", - "inmate", "inner", "innocent", "input", "inquiry", "insane", - "insect", "inside", "inspire", "install", "intact", "interest", - "into", "invest", "invite", "involve", "iron", "island", - "isolate", "issue", "item", "ivory", "jacket", "jaguar", - "jar", "jazz", "jealous", "jeans", "jelly", "jewel", - "job", "join", "joke", "journey", "joy", "judge", - "juice", "jump", "jungle", "junior", "junk", "just", - "kangaroo", "keen", "keep", "ketchup", "key", "kick", - "kid", "kidney", "kind", "kingdom", "kiss", "kit", - "kitchen", "kite", "kitten", "kiwi", "knee", "knife", - "knock", "know", "lab", "label", "labor", "ladder", - "lady", "lake", "lamp", "language", "laptop", "large", - "later", "latin", "laugh", "laundry", "lava", "law", - "lawn", "lawsuit", "layer", "lazy", "leader", "leaf", - "learn", "leave", "lecture", "left", "leg", "legal", - "legend", "leisure", "lemon", "lend", "length", "lens", - "leopard", "lesson", "letter", "level", "liar", "liberty", - "library", "license", "life", "lift", "light", "like", - "limb", "limit", "link", "lion", "liquid", "list", - "little", "live", "lizard", "load", "loan", "lobster", - "local", "lock", "logic", "lonely", "long", "loop", - "lottery", "loud", "lounge", "love", "loyal", "lucky", - "luggage", "lumber", "lunar", "lunch", "luxury", "lyrics", - "machine", "mad", "magic", "magnet", "maid", "mail", - "main", "major", "make", "mammal", "man", "manage", - "mandate", "mango", "mansion", "manual", "maple", "marble", - "march", "margin", "marine", "market", "marriage", "mask", - "mass", "master", "match", "material", "math", "matrix", - "matter", "maximum", "maze", "meadow", "mean", "measure", - "meat", "mechanic", "medal", "media", "melody", "melt", - "member", "memory", "mention", "menu", "mercy", "merge", - "merit", "merry", "mesh", "message", "metal", "method", - "middle", "midnight", "milk", "million", "mimic", "mind", - "minimum", "minor", "minute", "miracle", "mirror", "misery", - "miss", "mistake", "mix", "mixed", "mixture", "mobile", - "model", "modify", "mom", "moment", "monitor", "monkey", - "monster", "month", "moon", "moral", "more", "morning", - "mosquito", "mother", "motion", "motor", "mountain", "mouse", - "move", "movie", "much", "muffin", "mule", "multiply", - "muscle", "museum", "mushroom", "music", "must", "mutual", - "myself", "mystery", "myth", "naive", "name", "napkin", - "narrow", "nasty", "nation", "nature", "near", "neck", - "need", "negative", "neglect", "neither", "nephew", "nerve", - "nest", "net", "network", "neutral", "never", "news", - "next", "nice", "night", "noble", "noise", "nominee", - "noodle", "normal", "north", "nose", "notable", "note", - "nothing", "notice", "novel", "now", "nuclear", "number", - "nurse", "nut", "oak", "obey", "object", "oblige", - "obscure", "observe", "obtain", "obvious", "occur", "ocean", - "october", "odor", "off", "offer", "office", "often", - "oil", "okay", "old", "olive", "olympic", "omit", - "once", "one", "onion", "online", "only", "open", - "opera", "opinion", "oppose", "option", "orange", "orbit", - "orchard", "order", "ordinary", "organ", "orient", "original", - "orphan", "ostrich", "other", "outdoor", "outer", "output", - "outside", "oval", "oven", "over", "own", "owner", - "oxygen", "oyster", "ozone", "pact", "paddle", "page", - "pair", "palace", "palm", "panda", "panel", "panic", - "panther", "paper", "parade", "parent", "park", "parrot", - "party", "pass", "patch", "path", "patient", "patrol", - "pattern", "pause", "pave", "payment", "peace", "peanut", - "pear", "peasant", "pelican", "pen", "penalty", "pencil", - "people", "pepper", "perfect", "permit", "person", "pet", - "phone", "photo", "phrase", "physical", "piano", "picnic", - "picture", "piece", "pig", "pigeon", "pill", "pilot", - "pink", "pioneer", "pipe", "pistol", "pitch", "pizza", - "place", "planet", "plastic", "plate", "play", "please", - "pledge", "pluck", "plug", "plunge", "poem", "poet", - "point", "polar", "pole", "police", "pond", "pony", - "pool", "popular", "portion", "position", "possible", "post", - "potato", "pottery", "poverty", "powder", "power", "practice", - "praise", "predict", "prefer", "prepare", "present", "pretty", - "prevent", "price", "pride", "primary", "print", "priority", - "prison", "private", "prize", "problem", "process", "produce", - "profit", "program", "project", "promote", "proof", "property", - "prosper", "protect", "proud", "provide", "public", "pudding", - "pull", "pulp", "pulse", "pumpkin", "punch", "pupil", - "puppy", "purchase", "purity", "purpose", "purse", "push", - "put", "puzzle", "pyramid", "quality", "quantum", "quarter", - "question", "quick", "quit", "quiz", "quote", "rabbit", - "raccoon", "race", "rack", "radar", "radio", "rail", - "rain", "raise", "rally", "ramp", "ranch", "random", - "range", "rapid", "rare", "rate", "rather", "raven", - "raw", "razor", "ready", "real", "reason", "rebel", - "rebuild", "recall", "receive", "recipe", "record", "recycle", - "reduce", "reflect", "reform", "refuse", "region", "regret", - "regular", "reject", "relax", "release", "relief", "rely", - "remain", "remember", "remind", "remove", "render", "renew", - "rent", "reopen", "repair", "repeat", "replace", "report", - "require", "rescue", "resemble", "resist", "resource", "response", - "result", "retire", "retreat", "return", "reunion", "reveal", - "review", "reward", "rhythm", "rib", "ribbon", "rice", - "rich", "ride", "ridge", "rifle", "right", "rigid", - "ring", "riot", "ripple", "risk", "ritual", "rival", - "river", "road", "roast", "robot", "robust", "rocket", - "romance", "roof", "rookie", "room", "rose", "rotate", - "rough", "round", "route", "royal", "rubber", "rude", - "rug", "rule", "run", "runway", "rural", "sad", - "saddle", "sadness", "safe", "sail", "salad", "salmon", - "salon", "salt", "salute", "same", "sample", "sand", - "satisfy", "satoshi", "sauce", "sausage", "save", "say", - "scale", "scan", "scare", "scatter", "scene", "scheme", - "school", "science", "scissors", "scorpion", "scout", "scrap", - "screen", "script", "scrub", "sea", "search", "season", - "seat", "second", "secret", "section", "security", "seed", - "seek", "segment", "select", "sell", "seminar", "senior", - "sense", "sentence", "series", "service", "session", "settle", - "setup", "seven", "shadow", "shaft", "shallow", "share", - "shed", "shell", "sheriff", "shield", "shift", "shine", - "ship", "shiver", "shock", "shoe", "shoot", "shop", - "short", "shoulder", "shove", "shrimp", "shrug", "shuffle", - "shy", "sibling", "sick", "side", "siege", "sight", - "sign", "silent", "silk", "silly", "silver", "similar", - "simple", "since", "sing", "siren", "sister", "situate", - "six", "size", "skate", "sketch", "ski", "skill", - "skin", "skirt", "skull", "slab", "slam", "sleep", - "slender", "slice", "slide", "slight", "slim", "slogan", - "slot", "slow", "slush", "small", "smart", "smile", - "smoke", "smooth", "snack", "snake", "snap", "sniff", - "snow", "soap", "soccer", "social", "sock", "soda", - "soft", "solar", "soldier", "solid", "solution", "solve", - "someone", "song", "soon", "sorry", "sort", "soul", - "sound", "soup", "source", "south", "space", "spare", - "spatial", "spawn", "speak", "special", "speed", "spell", - "spend", "sphere", "spice", "spider", "spike", "spin", - "spirit", "split", "spoil", "sponsor", "spoon", "sport", - "spot", "spray", "spread", "spring", "spy", "square", - "squeeze", "squirrel", "stable", "stadium", "staff", "stage", - "stairs", "stamp", "stand", "start", "state", "stay", - "steak", "steel", "stem", "step", "stereo", "stick", - "still", "sting", "stock", "stomach", "stone", "stool", - "story", "stove", "strategy", "street", "strike", "strong", - "struggle", "student", "stuff", "stumble", "style", "subject", - "submit", "subway", "success", "such", "sudden", "suffer", - "sugar", "suggest", "suit", "summer", "sun", "sunny", - "sunset", "super", "supply", "supreme", "sure", "surface", - "surge", "surprise", "surround", "survey", "suspect", "sustain", - "swallow", "swamp", "swap", "swarm", "swear", "sweet", - "swift", "swim", "swing", "switch", "sword", "symbol", - "symptom", "syrup", "system", "table", "tackle", "tag", - "tail", "talent", "talk", "tank", "tape", "target", - "task", "taste", "tattoo", "taxi", "teach", "team", - "tell", "ten", "tenant", "tennis", "tent", "term", - "test", "text", "thank", "that", "theme", "then", - "theory", "there", "they", "thing", "this", "thought", - "three", "thrive", "throw", "thumb", "thunder", "ticket", - "tide", "tiger", "tilt", "timber", "time", "tiny", - "tip", "tired", "tissue", "title", "toast", "tobacco", - "today", "toddler", "toe", "together", "toilet", "token", - "tomato", "tomorrow", "tone", "tongue", "tonight", "tool", - "tooth", "top", "topic", "topple", "torch", "tornado", - "tortoise", "toss", "total", "tourist", "toward", "tower", - "town", "toy", "track", "trade", "traffic", "tragic", - "train", "transfer", "trap", "trash", "travel", "tray", - "treat", "tree", "trend", "trial", "tribe", "trick", - "trigger", "trim", "trip", "trophy", "trouble", "truck", - "true", "truly", "trumpet", "trust", "truth", "try", - "tube", "tuition", "tumble", "tuna", "tunnel", "turkey", - "turn", "turtle", "twelve", "twenty", "twice", "twin", - "twist", "two", "type", "typical", "ugly", "umbrella", - "unable", "unaware", "uncle", "uncover", "under", "undo", - "unfair", "unfold", "unhappy", "uniform", "unique", "unit", - "universe", "unknown", "unlock", "until", "unusual", "unveil", - "update", "upgrade", "uphold", "upon", "upper", "upset", - "urban", "urge", "usage", "use", "used", "useful", - "useless", "usual", "utility", "vacant", "vacuum", "vague", - "valid", "valley", "valve", "van", "vanish", "vapor", - "various", "vast", "vault", "vehicle", "velvet", "vendor", - "venture", "venue", "verb", "verify", "version", "very", - "vessel", "veteran", "viable", "vibrant", "vicious", "victory", - "video", "view", "village", "vintage", "violin", "virtual", - "virus", "visa", "visit", "visual", "vital", "vivid", - "vocal", "voice", "void", "volcano", "volume", "vote", - "voyage", "wage", "wagon", "wait", "walk", "wall", - "walnut", "want", "warfare", "warm", "warrior", "wash", - "wasp", "waste", "water", "wave", "way", "wealth", - "weapon", "wear", "weasel", "weather", "web", "wedding", - "weekend", "weird", "welcome", "west", "wet", "whale", - "what", "wheat", "wheel", "when", "where", "whip", - "whisper", "wide", "width", "wife", "wild", "will", - "win", "window", "wine", "wing", "wink", "winner", - "winter", "wire", "wisdom", "wise", "wish", "witness", - "wolf", "woman", "wonder", "wood", "wool", "word", - "work", "world", "worry", "worth", "wrap", "wreck", - "wrestle", "wrist", "write", "wrong", "yard", "year", - "yellow", "you", "young", "youth", "zebra", "zero", - "zone", "zoo", 0, +static const char * const wordlist[] = { +"abandon", +"ability", +"able", +"about", +"above", +"absent", +"absorb", +"abstract", +"absurd", +"abuse", +"access", +"accident", +"account", +"accuse", +"achieve", +"acid", +"acoustic", +"acquire", +"across", +"act", +"action", +"actor", +"actress", +"actual", +"adapt", +"add", +"addict", +"address", +"adjust", +"admit", +"adult", +"advance", +"advice", +"aerobic", +"affair", +"afford", +"afraid", +"again", +"age", +"agent", +"agree", +"ahead", +"aim", +"air", +"airport", +"aisle", +"alarm", +"album", +"alcohol", +"alert", +"alien", +"all", +"alley", +"allow", +"almost", +"alone", +"alpha", +"already", +"also", +"alter", +"always", +"amateur", +"amazing", +"among", +"amount", +"amused", +"analyst", +"anchor", +"ancient", +"anger", +"angle", +"angry", +"animal", +"ankle", +"announce", +"annual", +"another", +"answer", +"antenna", +"antique", +"anxiety", +"any", +"apart", +"apology", +"appear", +"apple", +"approve", +"april", +"arch", +"arctic", +"area", +"arena", +"argue", +"arm", +"armed", +"armor", +"army", +"around", +"arrange", +"arrest", +"arrive", +"arrow", +"art", +"artefact", +"artist", +"artwork", +"ask", +"aspect", +"assault", +"asset", +"assist", +"assume", +"asthma", +"athlete", +"atom", +"attack", +"attend", +"attitude", +"attract", +"auction", +"audit", +"august", +"aunt", +"author", +"auto", +"autumn", +"average", +"avocado", +"avoid", +"awake", +"aware", +"away", +"awesome", +"awful", +"awkward", +"axis", +"baby", +"bachelor", +"bacon", +"badge", +"bag", +"balance", +"balcony", +"ball", +"bamboo", +"banana", +"banner", +"bar", +"barely", +"bargain", +"barrel", +"base", +"basic", +"basket", +"battle", +"beach", +"bean", +"beauty", +"because", +"become", +"beef", +"before", +"begin", +"behave", +"behind", +"believe", +"below", +"belt", +"bench", +"benefit", +"best", +"betray", +"better", +"between", +"beyond", +"bicycle", +"bid", +"bike", +"bind", +"biology", +"bird", +"birth", +"bitter", +"black", +"blade", +"blame", +"blanket", +"blast", +"bleak", +"bless", +"blind", +"blood", +"blossom", +"blouse", +"blue", +"blur", +"blush", +"board", +"boat", +"body", +"boil", +"bomb", +"bone", +"bonus", +"book", +"boost", +"border", +"boring", +"borrow", +"boss", +"bottom", +"bounce", +"box", +"boy", +"bracket", +"brain", +"brand", +"brass", +"brave", +"bread", +"breeze", +"brick", +"bridge", +"brief", +"bright", +"bring", +"brisk", +"broccoli", +"broken", +"bronze", +"broom", +"brother", +"brown", +"brush", +"bubble", +"buddy", +"budget", +"buffalo", +"build", +"bulb", +"bulk", +"bullet", +"bundle", +"bunker", +"burden", +"burger", +"burst", +"bus", +"business", +"busy", +"butter", +"buyer", +"buzz", +"cabbage", +"cabin", +"cable", +"cactus", +"cage", +"cake", +"call", +"calm", +"camera", +"camp", +"can", +"canal", +"cancel", +"candy", +"cannon", +"canoe", +"canvas", +"canyon", +"capable", +"capital", +"captain", +"car", +"carbon", +"card", +"cargo", +"carpet", +"carry", +"cart", +"case", +"cash", +"casino", +"castle", +"casual", +"cat", +"catalog", +"catch", +"category", +"cattle", +"caught", +"cause", +"caution", +"cave", +"ceiling", +"celery", +"cement", +"census", +"century", +"cereal", +"certain", +"chair", +"chalk", +"champion", +"change", +"chaos", +"chapter", +"charge", +"chase", +"chat", +"cheap", +"check", +"cheese", +"chef", +"cherry", +"chest", +"chicken", +"chief", +"child", +"chimney", +"choice", +"choose", +"chronic", +"chuckle", +"chunk", +"churn", +"cigar", +"cinnamon", +"circle", +"citizen", +"city", +"civil", +"claim", +"clap", +"clarify", +"claw", +"clay", +"clean", +"clerk", +"clever", +"click", +"client", +"cliff", +"climb", +"clinic", +"clip", +"clock", +"clog", +"close", +"cloth", +"cloud", +"clown", +"club", +"clump", +"cluster", +"clutch", +"coach", +"coast", +"coconut", +"code", +"coffee", +"coil", +"coin", +"collect", +"color", +"column", +"combine", +"come", +"comfort", +"comic", +"common", +"company", +"concert", +"conduct", +"confirm", +"congress", +"connect", +"consider", +"control", +"convince", +"cook", +"cool", +"copper", +"copy", +"coral", +"core", +"corn", +"correct", +"cost", +"cotton", +"couch", +"country", +"couple", +"course", +"cousin", +"cover", +"coyote", +"crack", +"cradle", +"craft", +"cram", +"crane", +"crash", +"crater", +"crawl", +"crazy", +"cream", +"credit", +"creek", +"crew", +"cricket", +"crime", +"crisp", +"critic", +"crop", +"cross", +"crouch", +"crowd", +"crucial", +"cruel", +"cruise", +"crumble", +"crunch", +"crush", +"cry", +"crystal", +"cube", +"culture", +"cup", +"cupboard", +"curious", +"current", +"curtain", +"curve", +"cushion", +"custom", +"cute", +"cycle", +"dad", +"damage", +"damp", +"dance", +"danger", +"daring", +"dash", +"daughter", +"dawn", +"day", +"deal", +"debate", +"debris", +"decade", +"december", +"decide", +"decline", +"decorate", +"decrease", +"deer", +"defense", +"define", +"defy", +"degree", +"delay", +"deliver", +"demand", +"demise", +"denial", +"dentist", +"deny", +"depart", +"depend", +"deposit", +"depth", +"deputy", +"derive", +"describe", +"desert", +"design", +"desk", +"despair", +"destroy", +"detail", +"detect", +"develop", +"device", +"devote", +"diagram", +"dial", +"diamond", +"diary", +"dice", +"diesel", +"diet", +"differ", +"digital", +"dignity", +"dilemma", +"dinner", +"dinosaur", +"direct", +"dirt", +"disagree", +"discover", +"disease", +"dish", +"dismiss", +"disorder", +"display", +"distance", +"divert", +"divide", +"divorce", +"dizzy", +"doctor", +"document", +"dog", +"doll", +"dolphin", +"domain", +"donate", +"donkey", +"donor", +"door", +"dose", +"double", +"dove", +"draft", +"dragon", +"drama", +"drastic", +"draw", +"dream", +"dress", +"drift", +"drill", +"drink", +"drip", +"drive", +"drop", +"drum", +"dry", +"duck", +"dumb", +"dune", +"during", +"dust", +"dutch", +"duty", +"dwarf", +"dynamic", +"eager", +"eagle", +"early", +"earn", +"earth", +"easily", +"east", +"easy", +"echo", +"ecology", +"economy", +"edge", +"edit", +"educate", +"effort", +"egg", +"eight", +"either", +"elbow", +"elder", +"electric", +"elegant", +"element", +"elephant", +"elevator", +"elite", +"else", +"embark", +"embody", +"embrace", +"emerge", +"emotion", +"employ", +"empower", +"empty", +"enable", +"enact", +"end", +"endless", +"endorse", +"enemy", +"energy", +"enforce", +"engage", +"engine", +"enhance", +"enjoy", +"enlist", +"enough", +"enrich", +"enroll", +"ensure", +"enter", +"entire", +"entry", +"envelope", +"episode", +"equal", +"equip", +"era", +"erase", +"erode", +"erosion", +"error", +"erupt", +"escape", +"essay", +"essence", +"estate", +"eternal", +"ethics", +"evidence", +"evil", +"evoke", +"evolve", +"exact", +"example", +"excess", +"exchange", +"excite", +"exclude", +"excuse", +"execute", +"exercise", +"exhaust", +"exhibit", +"exile", +"exist", +"exit", +"exotic", +"expand", +"expect", +"expire", +"explain", +"expose", +"express", +"extend", +"extra", +"eye", +"eyebrow", +"fabric", +"face", +"faculty", +"fade", +"faint", +"faith", +"fall", +"false", +"fame", +"family", +"famous", +"fan", +"fancy", +"fantasy", +"farm", +"fashion", +"fat", +"fatal", +"father", +"fatigue", +"fault", +"favorite", +"feature", +"february", +"federal", +"fee", +"feed", +"feel", +"female", +"fence", +"festival", +"fetch", +"fever", +"few", +"fiber", +"fiction", +"field", +"figure", +"file", +"film", +"filter", +"final", +"find", +"fine", +"finger", +"finish", +"fire", +"firm", +"first", +"fiscal", +"fish", +"fit", +"fitness", +"fix", +"flag", +"flame", +"flash", +"flat", +"flavor", +"flee", +"flight", +"flip", +"float", +"flock", +"floor", +"flower", +"fluid", +"flush", +"fly", +"foam", +"focus", +"fog", +"foil", +"fold", +"follow", +"food", +"foot", +"force", +"forest", +"forget", +"fork", +"fortune", +"forum", +"forward", +"fossil", +"foster", +"found", +"fox", +"fragile", +"frame", +"frequent", +"fresh", +"friend", +"fringe", +"frog", +"front", +"frost", +"frown", +"frozen", +"fruit", +"fuel", +"fun", +"funny", +"furnace", +"fury", +"future", +"gadget", +"gain", +"galaxy", +"gallery", +"game", +"gap", +"garage", +"garbage", +"garden", +"garlic", +"garment", +"gas", +"gasp", +"gate", +"gather", +"gauge", +"gaze", +"general", +"genius", +"genre", +"gentle", +"genuine", +"gesture", +"ghost", +"giant", +"gift", +"giggle", +"ginger", +"giraffe", +"girl", +"give", +"glad", +"glance", +"glare", +"glass", +"glide", +"glimpse", +"globe", +"gloom", +"glory", +"glove", +"glow", +"glue", +"goat", +"goddess", +"gold", +"good", +"goose", +"gorilla", +"gospel", +"gossip", +"govern", +"gown", +"grab", +"grace", +"grain", +"grant", +"grape", +"grass", +"gravity", +"great", +"green", +"grid", +"grief", +"grit", +"grocery", +"group", +"grow", +"grunt", +"guard", +"guess", +"guide", +"guilt", +"guitar", +"gun", +"gym", +"habit", +"hair", +"half", +"hammer", +"hamster", +"hand", +"happy", +"harbor", +"hard", +"harsh", +"harvest", +"hat", +"have", +"hawk", +"hazard", +"head", +"health", +"heart", +"heavy", +"hedgehog", +"height", +"hello", +"helmet", +"help", +"hen", +"hero", +"hidden", +"high", +"hill", +"hint", +"hip", +"hire", +"history", +"hobby", +"hockey", +"hold", +"hole", +"holiday", +"hollow", +"home", +"honey", +"hood", +"hope", +"horn", +"horror", +"horse", +"hospital", +"host", +"hotel", +"hour", +"hover", +"hub", +"huge", +"human", +"humble", +"humor", +"hundred", +"hungry", +"hunt", +"hurdle", +"hurry", +"hurt", +"husband", +"hybrid", +"ice", +"icon", +"idea", +"identify", +"idle", +"ignore", +"ill", +"illegal", +"illness", +"image", +"imitate", +"immense", +"immune", +"impact", +"impose", +"improve", +"impulse", +"inch", +"include", +"income", +"increase", +"index", +"indicate", +"indoor", +"industry", +"infant", +"inflict", +"inform", +"inhale", +"inherit", +"initial", +"inject", +"injury", +"inmate", +"inner", +"innocent", +"input", +"inquiry", +"insane", +"insect", +"inside", +"inspire", +"install", +"intact", +"interest", +"into", +"invest", +"invite", +"involve", +"iron", +"island", +"isolate", +"issue", +"item", +"ivory", +"jacket", +"jaguar", +"jar", +"jazz", +"jealous", +"jeans", +"jelly", +"jewel", +"job", +"join", +"joke", +"journey", +"joy", +"judge", +"juice", +"jump", +"jungle", +"junior", +"junk", +"just", +"kangaroo", +"keen", +"keep", +"ketchup", +"key", +"kick", +"kid", +"kidney", +"kind", +"kingdom", +"kiss", +"kit", +"kitchen", +"kite", +"kitten", +"kiwi", +"knee", +"knife", +"knock", +"know", +"lab", +"label", +"labor", +"ladder", +"lady", +"lake", +"lamp", +"language", +"laptop", +"large", +"later", +"latin", +"laugh", +"laundry", +"lava", +"law", +"lawn", +"lawsuit", +"layer", +"lazy", +"leader", +"leaf", +"learn", +"leave", +"lecture", +"left", +"leg", +"legal", +"legend", +"leisure", +"lemon", +"lend", +"length", +"lens", +"leopard", +"lesson", +"letter", +"level", +"liar", +"liberty", +"library", +"license", +"life", +"lift", +"light", +"like", +"limb", +"limit", +"link", +"lion", +"liquid", +"list", +"little", +"live", +"lizard", +"load", +"loan", +"lobster", +"local", +"lock", +"logic", +"lonely", +"long", +"loop", +"lottery", +"loud", +"lounge", +"love", +"loyal", +"lucky", +"luggage", +"lumber", +"lunar", +"lunch", +"luxury", +"lyrics", +"machine", +"mad", +"magic", +"magnet", +"maid", +"mail", +"main", +"major", +"make", +"mammal", +"man", +"manage", +"mandate", +"mango", +"mansion", +"manual", +"maple", +"marble", +"march", +"margin", +"marine", +"market", +"marriage", +"mask", +"mass", +"master", +"match", +"material", +"math", +"matrix", +"matter", +"maximum", +"maze", +"meadow", +"mean", +"measure", +"meat", +"mechanic", +"medal", +"media", +"melody", +"melt", +"member", +"memory", +"mention", +"menu", +"mercy", +"merge", +"merit", +"merry", +"mesh", +"message", +"metal", +"method", +"middle", +"midnight", +"milk", +"million", +"mimic", +"mind", +"minimum", +"minor", +"minute", +"miracle", +"mirror", +"misery", +"miss", +"mistake", +"mix", +"mixed", +"mixture", +"mobile", +"model", +"modify", +"mom", +"moment", +"monitor", +"monkey", +"monster", +"month", +"moon", +"moral", +"more", +"morning", +"mosquito", +"mother", +"motion", +"motor", +"mountain", +"mouse", +"move", +"movie", +"much", +"muffin", +"mule", +"multiply", +"muscle", +"museum", +"mushroom", +"music", +"must", +"mutual", +"myself", +"mystery", +"myth", +"naive", +"name", +"napkin", +"narrow", +"nasty", +"nation", +"nature", +"near", +"neck", +"need", +"negative", +"neglect", +"neither", +"nephew", +"nerve", +"nest", +"net", +"network", +"neutral", +"never", +"news", +"next", +"nice", +"night", +"noble", +"noise", +"nominee", +"noodle", +"normal", +"north", +"nose", +"notable", +"note", +"nothing", +"notice", +"novel", +"now", +"nuclear", +"number", +"nurse", +"nut", +"oak", +"obey", +"object", +"oblige", +"obscure", +"observe", +"obtain", +"obvious", +"occur", +"ocean", +"october", +"odor", +"off", +"offer", +"office", +"often", +"oil", +"okay", +"old", +"olive", +"olympic", +"omit", +"once", +"one", +"onion", +"online", +"only", +"open", +"opera", +"opinion", +"oppose", +"option", +"orange", +"orbit", +"orchard", +"order", +"ordinary", +"organ", +"orient", +"original", +"orphan", +"ostrich", +"other", +"outdoor", +"outer", +"output", +"outside", +"oval", +"oven", +"over", +"own", +"owner", +"oxygen", +"oyster", +"ozone", +"pact", +"paddle", +"page", +"pair", +"palace", +"palm", +"panda", +"panel", +"panic", +"panther", +"paper", +"parade", +"parent", +"park", +"parrot", +"party", +"pass", +"patch", +"path", +"patient", +"patrol", +"pattern", +"pause", +"pave", +"payment", +"peace", +"peanut", +"pear", +"peasant", +"pelican", +"pen", +"penalty", +"pencil", +"people", +"pepper", +"perfect", +"permit", +"person", +"pet", +"phone", +"photo", +"phrase", +"physical", +"piano", +"picnic", +"picture", +"piece", +"pig", +"pigeon", +"pill", +"pilot", +"pink", +"pioneer", +"pipe", +"pistol", +"pitch", +"pizza", +"place", +"planet", +"plastic", +"plate", +"play", +"please", +"pledge", +"pluck", +"plug", +"plunge", +"poem", +"poet", +"point", +"polar", +"pole", +"police", +"pond", +"pony", +"pool", +"popular", +"portion", +"position", +"possible", +"post", +"potato", +"pottery", +"poverty", +"powder", +"power", +"practice", +"praise", +"predict", +"prefer", +"prepare", +"present", +"pretty", +"prevent", +"price", +"pride", +"primary", +"print", +"priority", +"prison", +"private", +"prize", +"problem", +"process", +"produce", +"profit", +"program", +"project", +"promote", +"proof", +"property", +"prosper", +"protect", +"proud", +"provide", +"public", +"pudding", +"pull", +"pulp", +"pulse", +"pumpkin", +"punch", +"pupil", +"puppy", +"purchase", +"purity", +"purpose", +"purse", +"push", +"put", +"puzzle", +"pyramid", +"quality", +"quantum", +"quarter", +"question", +"quick", +"quit", +"quiz", +"quote", +"rabbit", +"raccoon", +"race", +"rack", +"radar", +"radio", +"rail", +"rain", +"raise", +"rally", +"ramp", +"ranch", +"random", +"range", +"rapid", +"rare", +"rate", +"rather", +"raven", +"raw", +"razor", +"ready", +"real", +"reason", +"rebel", +"rebuild", +"recall", +"receive", +"recipe", +"record", +"recycle", +"reduce", +"reflect", +"reform", +"refuse", +"region", +"regret", +"regular", +"reject", +"relax", +"release", +"relief", +"rely", +"remain", +"remember", +"remind", +"remove", +"render", +"renew", +"rent", +"reopen", +"repair", +"repeat", +"replace", +"report", +"require", +"rescue", +"resemble", +"resist", +"resource", +"response", +"result", +"retire", +"retreat", +"return", +"reunion", +"reveal", +"review", +"reward", +"rhythm", +"rib", +"ribbon", +"rice", +"rich", +"ride", +"ridge", +"rifle", +"right", +"rigid", +"ring", +"riot", +"ripple", +"risk", +"ritual", +"rival", +"river", +"road", +"roast", +"robot", +"robust", +"rocket", +"romance", +"roof", +"rookie", +"room", +"rose", +"rotate", +"rough", +"round", +"route", +"royal", +"rubber", +"rude", +"rug", +"rule", +"run", +"runway", +"rural", +"sad", +"saddle", +"sadness", +"safe", +"sail", +"salad", +"salmon", +"salon", +"salt", +"salute", +"same", +"sample", +"sand", +"satisfy", +"satoshi", +"sauce", +"sausage", +"save", +"say", +"scale", +"scan", +"scare", +"scatter", +"scene", +"scheme", +"school", +"science", +"scissors", +"scorpion", +"scout", +"scrap", +"screen", +"script", +"scrub", +"sea", +"search", +"season", +"seat", +"second", +"secret", +"section", +"security", +"seed", +"seek", +"segment", +"select", +"sell", +"seminar", +"senior", +"sense", +"sentence", +"series", +"service", +"session", +"settle", +"setup", +"seven", +"shadow", +"shaft", +"shallow", +"share", +"shed", +"shell", +"sheriff", +"shield", +"shift", +"shine", +"ship", +"shiver", +"shock", +"shoe", +"shoot", +"shop", +"short", +"shoulder", +"shove", +"shrimp", +"shrug", +"shuffle", +"shy", +"sibling", +"sick", +"side", +"siege", +"sight", +"sign", +"silent", +"silk", +"silly", +"silver", +"similar", +"simple", +"since", +"sing", +"siren", +"sister", +"situate", +"six", +"size", +"skate", +"sketch", +"ski", +"skill", +"skin", +"skirt", +"skull", +"slab", +"slam", +"sleep", +"slender", +"slice", +"slide", +"slight", +"slim", +"slogan", +"slot", +"slow", +"slush", +"small", +"smart", +"smile", +"smoke", +"smooth", +"snack", +"snake", +"snap", +"sniff", +"snow", +"soap", +"soccer", +"social", +"sock", +"soda", +"soft", +"solar", +"soldier", +"solid", +"solution", +"solve", +"someone", +"song", +"soon", +"sorry", +"sort", +"soul", +"sound", +"soup", +"source", +"south", +"space", +"spare", +"spatial", +"spawn", +"speak", +"special", +"speed", +"spell", +"spend", +"sphere", +"spice", +"spider", +"spike", +"spin", +"spirit", +"split", +"spoil", +"sponsor", +"spoon", +"sport", +"spot", +"spray", +"spread", +"spring", +"spy", +"square", +"squeeze", +"squirrel", +"stable", +"stadium", +"staff", +"stage", +"stairs", +"stamp", +"stand", +"start", +"state", +"stay", +"steak", +"steel", +"stem", +"step", +"stereo", +"stick", +"still", +"sting", +"stock", +"stomach", +"stone", +"stool", +"story", +"stove", +"strategy", +"street", +"strike", +"strong", +"struggle", +"student", +"stuff", +"stumble", +"style", +"subject", +"submit", +"subway", +"success", +"such", +"sudden", +"suffer", +"sugar", +"suggest", +"suit", +"summer", +"sun", +"sunny", +"sunset", +"super", +"supply", +"supreme", +"sure", +"surface", +"surge", +"surprise", +"surround", +"survey", +"suspect", +"sustain", +"swallow", +"swamp", +"swap", +"swarm", +"swear", +"sweet", +"swift", +"swim", +"swing", +"switch", +"sword", +"symbol", +"symptom", +"syrup", +"system", +"table", +"tackle", +"tag", +"tail", +"talent", +"talk", +"tank", +"tape", +"target", +"task", +"taste", +"tattoo", +"taxi", +"teach", +"team", +"tell", +"ten", +"tenant", +"tennis", +"tent", +"term", +"test", +"text", +"thank", +"that", +"theme", +"then", +"theory", +"there", +"they", +"thing", +"this", +"thought", +"three", +"thrive", +"throw", +"thumb", +"thunder", +"ticket", +"tide", +"tiger", +"tilt", +"timber", +"time", +"tiny", +"tip", +"tired", +"tissue", +"title", +"toast", +"tobacco", +"today", +"toddler", +"toe", +"together", +"toilet", +"token", +"tomato", +"tomorrow", +"tone", +"tongue", +"tonight", +"tool", +"tooth", +"top", +"topic", +"topple", +"torch", +"tornado", +"tortoise", +"toss", +"total", +"tourist", +"toward", +"tower", +"town", +"toy", +"track", +"trade", +"traffic", +"tragic", +"train", +"transfer", +"trap", +"trash", +"travel", +"tray", +"treat", +"tree", +"trend", +"trial", +"tribe", +"trick", +"trigger", +"trim", +"trip", +"trophy", +"trouble", +"truck", +"true", +"truly", +"trumpet", +"trust", +"truth", +"try", +"tube", +"tuition", +"tumble", +"tuna", +"tunnel", +"turkey", +"turn", +"turtle", +"twelve", +"twenty", +"twice", +"twin", +"twist", +"two", +"type", +"typical", +"ugly", +"umbrella", +"unable", +"unaware", +"uncle", +"uncover", +"under", +"undo", +"unfair", +"unfold", +"unhappy", +"uniform", +"unique", +"unit", +"universe", +"unknown", +"unlock", +"until", +"unusual", +"unveil", +"update", +"upgrade", +"uphold", +"upon", +"upper", +"upset", +"urban", +"urge", +"usage", +"use", +"used", +"useful", +"useless", +"usual", +"utility", +"vacant", +"vacuum", +"vague", +"valid", +"valley", +"valve", +"van", +"vanish", +"vapor", +"various", +"vast", +"vault", +"vehicle", +"velvet", +"vendor", +"venture", +"venue", +"verb", +"verify", +"version", +"very", +"vessel", +"veteran", +"viable", +"vibrant", +"vicious", +"victory", +"video", +"view", +"village", +"vintage", +"violin", +"virtual", +"virus", +"visa", +"visit", +"visual", +"vital", +"vivid", +"vocal", +"voice", +"void", +"volcano", +"volume", +"vote", +"voyage", +"wage", +"wagon", +"wait", +"walk", +"wall", +"walnut", +"want", +"warfare", +"warm", +"warrior", +"wash", +"wasp", +"waste", +"water", +"wave", +"way", +"wealth", +"weapon", +"wear", +"weasel", +"weather", +"web", +"wedding", +"weekend", +"weird", +"welcome", +"west", +"wet", +"whale", +"what", +"wheat", +"wheel", +"when", +"where", +"whip", +"whisper", +"wide", +"width", +"wife", +"wild", +"will", +"win", +"window", +"wine", +"wing", +"wink", +"winner", +"winter", +"wire", +"wisdom", +"wise", +"wish", +"witness", +"wolf", +"woman", +"wonder", +"wood", +"wool", +"word", +"work", +"world", +"worry", +"worth", +"wrap", +"wreck", +"wrestle", +"wrist", +"write", +"wrong", +"yard", +"year", +"yellow", +"you", +"young", +"youth", +"zebra", +"zero", +"zone", +"zoo", +0, }; diff --git a/src/crypto/bip39/hmac.h b/src/crypto/bip39/hmac.h index 3921a171e..3cfc0cd0f 100644 --- a/src/crypto/bip39/hmac.h +++ b/src/crypto/bip39/hmac.h @@ -28,33 +28,25 @@ #include "sha2.h" typedef struct _HMAC_SHA256_CTX { - uint8_t o_key_pad[SHA256_BLOCK_LENGTH]; - SHA256_CTX ctx; + uint8_t o_key_pad[SHA256_BLOCK_LENGTH]; + SHA256_CTX ctx; } HMAC_SHA256_CTX; typedef struct _HMAC_SHA512_CTX { - uint8_t o_key_pad[SHA512_BLOCK_LENGTH]; - SHA512_CTX ctx; + uint8_t o_key_pad[SHA512_BLOCK_LENGTH]; + SHA512_CTX ctx; } HMAC_SHA512_CTX; -void hmac_sha256_Init(HMAC_SHA256_CTX *hctx, const uint8_t *key, - const uint32_t keylen); -void hmac_sha256_Update(HMAC_SHA256_CTX *hctx, const uint8_t *msg, - const uint32_t msglen); +void hmac_sha256_Init(HMAC_SHA256_CTX *hctx, const uint8_t *key, const uint32_t keylen); +void hmac_sha256_Update(HMAC_SHA256_CTX *hctx, const uint8_t *msg, const uint32_t msglen); void hmac_sha256_Final(HMAC_SHA256_CTX *hctx, uint8_t *hmac); -void hmac_sha256(const uint8_t *key, const uint32_t keylen, const uint8_t *msg, - const uint32_t msglen, uint8_t *hmac); -void hmac_sha256_prepare(const uint8_t *key, const uint32_t keylen, - uint32_t *opad_digest, uint32_t *ipad_digest); +void hmac_sha256(const uint8_t *key, const uint32_t keylen, const uint8_t *msg, const uint32_t msglen, uint8_t *hmac); +void hmac_sha256_prepare(const uint8_t *key, const uint32_t keylen, uint32_t *opad_digest, uint32_t *ipad_digest); -void hmac_sha512_Init(HMAC_SHA512_CTX *hctx, const uint8_t *key, - const uint32_t keylen); -void hmac_sha512_Update(HMAC_SHA512_CTX *hctx, const uint8_t *msg, - const uint32_t msglen); +void hmac_sha512_Init(HMAC_SHA512_CTX *hctx, const uint8_t *key, const uint32_t keylen); +void hmac_sha512_Update(HMAC_SHA512_CTX *hctx, const uint8_t *msg, const uint32_t msglen); void hmac_sha512_Final(HMAC_SHA512_CTX *hctx, uint8_t *hmac); -void hmac_sha512(const uint8_t *key, const uint32_t keylen, const uint8_t *msg, - const uint32_t msglen, uint8_t *hmac); -void hmac_sha512_prepare(const uint8_t *key, const uint32_t keylen, - uint64_t *opad_digest, uint64_t *ipad_digest); +void hmac_sha512(const uint8_t *key, const uint32_t keylen, const uint8_t *msg, const uint32_t msglen, uint8_t *hmac); +void hmac_sha512_prepare(const uint8_t *key, const uint32_t keylen, uint64_t *opad_digest, uint64_t *ipad_digest); #endif diff --git a/src/crypto/bip39/memzero.h b/src/crypto/bip39/memzero.h index 0a959fbc2..a7797d2b3 100644 --- a/src/crypto/bip39/memzero.h +++ b/src/crypto/bip39/memzero.h @@ -3,6 +3,6 @@ #include -void memzero(void* const pnt, const size_t len); +void memzero(void * const pnt, const size_t len); #endif diff --git a/src/crypto/bip39/options.h b/src/crypto/bip39/options.h index d3a9c2edf..e57654e6c 100644 --- a/src/crypto/bip39/options.h +++ b/src/crypto/bip39/options.h @@ -52,7 +52,7 @@ // support constructing BIP32 nodes from ed25519 and curve25519 curves. #ifndef USE_BIP32_25519_CURVES -#define USE_BIP32_25519_CURVES 1 +#define USE_BIP32_25519_CURVES 1 #endif // implement BIP39 caching diff --git a/src/crypto/bip39/pbkdf2.h b/src/crypto/bip39/pbkdf2.h index c2e3f04a6..e3f440c8f 100644 --- a/src/crypto/bip39/pbkdf2.h +++ b/src/crypto/bip39/pbkdf2.h @@ -28,39 +28,29 @@ #include "sha2.h" typedef struct _PBKDF2_HMAC_SHA256_CTX { - uint32_t odig[SHA256_DIGEST_LENGTH / sizeof(uint32_t)]; - uint32_t idig[SHA256_DIGEST_LENGTH / sizeof(uint32_t)]; - uint32_t f[SHA256_DIGEST_LENGTH / sizeof(uint32_t)]; - uint32_t g[SHA256_BLOCK_LENGTH / sizeof(uint32_t)]; - char first; + uint32_t odig[SHA256_DIGEST_LENGTH / sizeof(uint32_t)]; + uint32_t idig[SHA256_DIGEST_LENGTH / sizeof(uint32_t)]; + uint32_t f[SHA256_DIGEST_LENGTH / sizeof(uint32_t)]; + uint32_t g[SHA256_BLOCK_LENGTH / sizeof(uint32_t)]; + char first; } PBKDF2_HMAC_SHA256_CTX; typedef struct _PBKDF2_HMAC_SHA512_CTX { - uint64_t odig[SHA512_DIGEST_LENGTH / sizeof(uint64_t)]; - uint64_t idig[SHA512_DIGEST_LENGTH / sizeof(uint64_t)]; - uint64_t f[SHA512_DIGEST_LENGTH / sizeof(uint64_t)]; - uint64_t g[SHA512_BLOCK_LENGTH / sizeof(uint64_t)]; - char first; + uint64_t odig[SHA512_DIGEST_LENGTH / sizeof(uint64_t)]; + uint64_t idig[SHA512_DIGEST_LENGTH / sizeof(uint64_t)]; + uint64_t f[SHA512_DIGEST_LENGTH / sizeof(uint64_t)]; + uint64_t g[SHA512_BLOCK_LENGTH / sizeof(uint64_t)]; + char first; } PBKDF2_HMAC_SHA512_CTX; -void pbkdf2_hmac_sha256_Init(PBKDF2_HMAC_SHA256_CTX *pctx, const uint8_t *pass, - int passlen, const uint8_t *salt, int saltlen, - uint32_t blocknr); -void pbkdf2_hmac_sha256_Update(PBKDF2_HMAC_SHA256_CTX *pctx, - uint32_t iterations); +void pbkdf2_hmac_sha256_Init(PBKDF2_HMAC_SHA256_CTX *pctx, const uint8_t *pass, int passlen, const uint8_t *salt, int saltlen, uint32_t blocknr); +void pbkdf2_hmac_sha256_Update(PBKDF2_HMAC_SHA256_CTX *pctx, uint32_t iterations); void pbkdf2_hmac_sha256_Final(PBKDF2_HMAC_SHA256_CTX *pctx, uint8_t *key); -void pbkdf2_hmac_sha256(const uint8_t *pass, int passlen, const uint8_t *salt, - int saltlen, uint32_t iterations, uint8_t *key, - int keylen); +void pbkdf2_hmac_sha256(const uint8_t *pass, int passlen, const uint8_t *salt, int saltlen, uint32_t iterations, uint8_t *key, int keylen); -void pbkdf2_hmac_sha512_Init(PBKDF2_HMAC_SHA512_CTX *pctx, const uint8_t *pass, - int passlen, const uint8_t *salt, int saltlen, - uint32_t blocknr); -void pbkdf2_hmac_sha512_Update(PBKDF2_HMAC_SHA512_CTX *pctx, - uint32_t iterations); +void pbkdf2_hmac_sha512_Init(PBKDF2_HMAC_SHA512_CTX *pctx, const uint8_t *pass, int passlen, const uint8_t *salt, int saltlen, uint32_t blocknr); +void pbkdf2_hmac_sha512_Update(PBKDF2_HMAC_SHA512_CTX *pctx, uint32_t iterations); void pbkdf2_hmac_sha512_Final(PBKDF2_HMAC_SHA512_CTX *pctx, uint8_t *key); -void pbkdf2_hmac_sha512(const uint8_t *pass, int passlen, const uint8_t *salt, - int saltlen, uint32_t iterations, uint8_t *key, - int keylen); +void pbkdf2_hmac_sha512(const uint8_t *pass, int passlen, const uint8_t *salt, int saltlen, uint32_t iterations, uint8_t *key, int keylen); #endif From 514348c427cc35da48fb0cb59dcc087e2227a59a Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 11 Sep 2020 10:29:00 -0400 Subject: [PATCH 189/255] Add various bip39 and base32/base58 stuff --- src/crypto/bip39/base32.c | 233 +++++++++++++++++++++++ src/crypto/bip39/base32.h | 41 +++++ src/crypto/bip39/base58.c | 285 +++++++++++++++++++++++++++++ src/crypto/bip39/base58.h | 49 +++++ src/crypto/bip39/bip32.h | 112 ++++++++++++ src/crypto/bip39/bip39_mnemonic.c | 29 +++ src/crypto/bip39/bip39bruteforce.c | 87 +++++++++ 7 files changed, 836 insertions(+) create mode 100644 src/crypto/bip39/base32.c create mode 100644 src/crypto/bip39/base32.h create mode 100644 src/crypto/bip39/base58.c create mode 100644 src/crypto/bip39/base58.h create mode 100644 src/crypto/bip39/bip32.h create mode 100644 src/crypto/bip39/bip39_mnemonic.c create mode 100644 src/crypto/bip39/bip39bruteforce.c diff --git a/src/crypto/bip39/base32.c b/src/crypto/bip39/base32.c new file mode 100644 index 000000000..06760ccae --- /dev/null +++ b/src/crypto/bip39/base32.c @@ -0,0 +1,233 @@ +/** + * Copyright (c) 2017 Saleem Rashid + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, E1PRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "base32.h" + +#include + +const char *BASE32_ALPHABET_RFC4648 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ23456789"; + +static inline void base32_5to8(const uint8_t *in, uint8_t length, uint8_t *out); +static inline bool base32_8to5(const uint8_t *in, uint8_t length, uint8_t *out, const char *alphabet); +static inline void base32_8to5_raw(const uint8_t *in, uint8_t length, uint8_t *out); + +static inline int base32_encode_character(uint8_t decoded, const char *alphabet); +static inline int base32_decode_character(char encoded, const char *alphabet); + +char *base32_encode(const uint8_t *in, size_t inlen, char *out, size_t outlen, const char *alphabet) { + size_t length = base32_encoded_length(inlen); + if (outlen <= length) { + return NULL; + } + + base32_encode_unsafe(in, inlen, (uint8_t *) out); + + for (size_t i = 0; i < length; i++) { + int ret = base32_encode_character(out[i], alphabet); + + if (ret == -1) { + return false; + } else { + out[i] = ret; + } + } + + out[length] = '\0'; + return &out[length]; +} + +uint8_t *base32_decode(const char *in, size_t inlen, uint8_t *out, size_t outlen, const char *alphabet) { + size_t length = base32_decoded_length(inlen); + if (outlen < length) { + return NULL; + } + + if (!base32_decode_unsafe((uint8_t *) in, inlen, (uint8_t *) out, alphabet)) { + return NULL; + } + + return &out[length]; +} + +void base32_encode_unsafe(const uint8_t *in, size_t inlen, uint8_t *out) { + uint8_t remainder = inlen % 5; + size_t limit = inlen - remainder; + + size_t i, j; + for (i = 0, j = 0; i < limit; i += 5, j += 8) { + base32_5to8(&in[i], 5, &out[j]); + } + + if (remainder) base32_5to8(&in[i], remainder, &out[j]); +} + +bool base32_decode_unsafe(const uint8_t *in, size_t inlen, uint8_t *out, const char *alphabet) { + uint8_t remainder = inlen % 8; + size_t limit = inlen - remainder; + + size_t i, j; + for (i = 0, j = 0; i < limit; i += 8, j += 5) { + if (!base32_8to5(&in[i], 8, &out[j], alphabet)) { + return false; + } + } + + if (remainder && !base32_8to5(&in[i], remainder, &out[j], alphabet)) { + return false; + } + + return true; +} + +size_t base32_encoded_length(size_t inlen) { + uint8_t remainder = inlen % 5; + + return (inlen / 5) * 8 + (remainder * 8 + 4) / 5; +} + +size_t base32_decoded_length(size_t inlen) { + uint8_t remainder = inlen % 8; + + return (inlen / 8) * 5 + (remainder * 5) / 8; +} + +void base32_5to8(const uint8_t *in, uint8_t length, uint8_t *out) { + if (length >= 1) { + out[0] = (in[0] >> 3); + out[1] = (in[0] & 7) << 2; + } + + if (length >= 2) { + out[1] |= (in[1] >> 6); + out[2] = (in[1] >> 1) & 31; + out[3] = (in[1] & 1) << 4; + } + + if (length >= 3) { + out[3] |= (in[2] >> 4); + out[4] = (in[2] & 15) << 1; + } + + if (length >= 4) { + out[4] |= (in[3] >> 7); + out[5] = (in[3] >> 2) & 31; + out[6] = (in[3] & 3) << 3; + } + + if (length >= 5) { + out[6] |= (in[4] >> 5); + out[7] = (in[4] & 31); + } +} + +bool base32_8to5(const uint8_t *in, uint8_t length, uint8_t *out, const char *alphabet) { + if (length == 1 || length == 3 || length == 6 || length > 8) { + return false; + } + + if (alphabet) { + uint8_t decoded[length]; + + for (size_t i = 0; i < length; i++) { + int ret = base32_decode_character(in[i], alphabet); + + if (ret == -1) { + return false; + } else { + decoded[i] = ret; + } + } + + base32_8to5_raw(decoded, length, out); + } else { + base32_8to5_raw(in, length, out); + } + + return true; +} + +void base32_8to5_raw(const uint8_t *in, uint8_t length, uint8_t *out) { + if (length >= 2) { + out[0] = (in[0] << 3); + out[0] |= (in[1] >> 2); + } + + if (length >= 4) { + out[1] = (in[1] & 3) << 6; + out[1] |= (in[2] << 1); + out[1] |= (in[3] >> 4); + } + + if (length >= 5) { + out[2] = (in[3] & 15) << 4; + out[2] |= (in[4] >> 1); + } + + if (length >= 7) { + out[3] = (in[4] & 1) << 7; + out[3] |= (in[5] << 2); + out[3] |= (in[6] >> 3); + } + + if (length >= 8) { + out[4] = (in[6] & 7) << 5; + out[4] |= (in[7] & 31); + } +} + +int base32_encode_character(uint8_t decoded, const char *alphabet) { + if (decoded >> 5) { + return -1; + } + + if (alphabet == BASE32_ALPHABET_RFC4648) { + if (decoded < 26) { + return 'A' + decoded; + } else { + return '2' - 26 + decoded; + } + } + + return alphabet[decoded]; +} + +int base32_decode_character(char encoded, const char *alphabet) { + if (alphabet == BASE32_ALPHABET_RFC4648) { + if (encoded >= 'A' && encoded <= 'Z') { + return encoded - 'A'; + } else if (encoded >= 'a' && encoded <= 'z') { + return encoded - 'a'; + } else if (encoded >= '2' && encoded <= '7') { + return encoded - '2' + 26; + } else { + return -1; + } + } + + const char *occurrence = strchr(alphabet, encoded); + + if (occurrence) { + return occurrence - alphabet; + } else { + return -1; + } +} diff --git a/src/crypto/bip39/base32.h b/src/crypto/bip39/base32.h new file mode 100644 index 000000000..250997967 --- /dev/null +++ b/src/crypto/bip39/base32.h @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2017 Saleem Rashid + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __BASE32_H__ +#define __BASE32_H__ + +#include +#include +#include + +extern const char *BASE32_ALPHABET_RFC4648; + +char *base32_encode(const uint8_t *in, size_t inlen, char *out, size_t outlen, const char *alphabet); +void base32_encode_unsafe(const uint8_t *in, size_t inlen, uint8_t *out); + +uint8_t *base32_decode(const char *in, size_t inlen, uint8_t *out, size_t outlen, const char *alphabet); +bool base32_decode_unsafe(const uint8_t *in, size_t inlen, uint8_t *out, const char *alphabet); + +size_t base32_encoded_length(size_t inlen); +size_t base32_decoded_length(size_t inlen); + +#endif diff --git a/src/crypto/bip39/base58.c b/src/crypto/bip39/base58.c new file mode 100644 index 000000000..cd74617b8 --- /dev/null +++ b/src/crypto/bip39/base58.c @@ -0,0 +1,285 @@ +/** + * Copyright (c) 2012-2014 Luke Dashjr + * Copyright (c) 2013-2014 Pavol Rusnak + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include +#include "base58.h" +#include "sha2.h" +#include "ripemd160.h" +#include "memzero.h" + +const char b58digits_ordered[] = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"; +const int8_t b58digits_map[] = { + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, + -1, 0, 1, 2, 3, 4, 5, 6, 7, 8,-1,-1,-1,-1,-1,-1, + -1, 9,10,11,12,13,14,15,16,-1,17,18,19,20,21,-1, + 22,23,24,25,26,27,28,29,30,31,32,-1,-1,-1,-1,-1, + -1,33,34,35,36,37,38,39,40,41,42,43,-1,44,45,46, + 47,48,49,50,51,52,53,54,55,56,57,-1,-1,-1,-1,-1, +}; + +bool b58tobin(void *bin, size_t *binszp, const char *b58) +{ + size_t binsz = *binszp; + + if (binsz == 0) { + return false; + } + + const unsigned char *b58u = (const unsigned char*)b58; + unsigned char *binu = bin; + size_t outisz = (binsz + 3) / 4; + uint32_t outi[outisz]; + uint64_t t; + uint32_t c; + size_t i, j; + uint8_t bytesleft = binsz % 4; + uint32_t zeromask = bytesleft ? (0xffffffff << (bytesleft * 8)) : 0; + unsigned zerocount = 0; + size_t b58sz; + + b58sz = strlen(b58); + + memzero(outi, sizeof(outi)); + + // Leading zeros, just count + for (i = 0; i < b58sz && b58u[i] == '1'; ++i) + ++zerocount; + + for ( ; i < b58sz; ++i) + { + if (b58u[i] & 0x80) + // High-bit set on invalid digit + return false; + if (b58digits_map[b58u[i]] == -1) + // Invalid base58 digit + return false; + c = (unsigned)b58digits_map[b58u[i]]; + for (j = outisz; j--; ) + { + t = ((uint64_t)outi[j]) * 58 + c; + c = (t & 0x3f00000000) >> 32; + outi[j] = t & 0xffffffff; + } + if (c) + // Output number too big (carry to the next int32) + return false; + if (outi[0] & zeromask) + // Output number too big (last int32 filled too far) + return false; + } + + j = 0; + switch (bytesleft) { + case 3: + *(binu++) = (outi[0] & 0xff0000) >> 16; + //-fallthrough + case 2: + *(binu++) = (outi[0] & 0xff00) >> 8; + //-fallthrough + case 1: + *(binu++) = (outi[0] & 0xff); + ++j; + //-fallthrough + default: + break; + } + + for (; j < outisz; ++j) + { + *(binu++) = (outi[j] >> 0x18) & 0xff; + *(binu++) = (outi[j] >> 0x10) & 0xff; + *(binu++) = (outi[j] >> 8) & 0xff; + *(binu++) = (outi[j] >> 0) & 0xff; + } + + // Count canonical base58 byte count + binu = bin; + for (i = 0; i < binsz; ++i) + { + if (binu[i]) { + if (zerocount > i) { + /* result too large */ + return false; + } + break; + } + --*binszp; + } + *binszp += zerocount; + + return true; +} + +int b58check(const void *bin, size_t binsz, HasherType hasher_type, const char *base58str) +{ + unsigned char buf[32]; + const uint8_t *binc = bin; + unsigned i; + if (binsz < 4) + return -4; + hasher_Raw(hasher_type, bin, binsz - 4, buf); + if (memcmp(&binc[binsz - 4], buf, 4)) + return -1; + + // Check number of zeros is correct AFTER verifying checksum (to avoid possibility of accessing base58str beyond the end) + for (i = 0; binc[i] == '\0' && base58str[i] == '1'; ++i) + {} // Just finding the end of zeros, nothing to do in loop + if (binc[i] == '\0' || base58str[i] == '1') + return -3; + + return binc[0]; +} + +bool b58enc(char *b58, size_t *b58sz, const void *data, size_t binsz) +{ + const uint8_t *bin = data; + int carry; + ssize_t i, j, high, zcount = 0; + size_t size; + + while (zcount < (ssize_t)binsz && !bin[zcount]) + ++zcount; + + size = (binsz - zcount) * 138 / 100 + 1; + uint8_t buf[size]; + memzero(buf, size); + + for (i = zcount, high = size - 1; i < (ssize_t)binsz; ++i, high = j) + { + for (carry = bin[i], j = size - 1; (j > high) || carry; --j) + { + carry += 256 * buf[j]; + buf[j] = carry % 58; + carry /= 58; + } + } + + for (j = 0; j < (ssize_t)size && !buf[j]; ++j); + + if (*b58sz <= zcount + size - j) + { + *b58sz = zcount + size - j + 1; + return false; + } + + if (zcount) + memset(b58, '1', zcount); + for (i = zcount; j < (ssize_t)size; ++i, ++j) + b58[i] = b58digits_ordered[buf[j]]; + b58[i] = '\0'; + *b58sz = i + 1; + + return true; +} + +int base58_encode_check(const uint8_t *data, int datalen, HasherType hasher_type, char *str, int strsize) +{ + if (datalen > 128) { + return 0; + } + uint8_t buf[datalen + 32]; + uint8_t *hash = buf + datalen; + memcpy(buf, data, datalen); + hasher_Raw(hasher_type, data, datalen, hash); + size_t res = strsize; + bool success = b58enc(str, &res, buf, datalen + 4); + memzero(buf, sizeof(buf)); + return success ? res : 0; +} + +int base58_decode_check(const char *str, HasherType hasher_type, uint8_t *data, int datalen) +{ + if (datalen > 128) { + return 0; + } + uint8_t d[datalen + 4]; + size_t res = datalen + 4; + if (b58tobin(d, &res, str) != true) { + return 0; + } + uint8_t *nd = d + datalen + 4 - res; + if (b58check(nd, res, hasher_type, str) < 0) { + return 0; + } + memcpy(data, nd, res - 4); + return res - 4; +} + +#if USE_GRAPHENE +int b58gphcheck(const void *bin, size_t binsz, const char *base58str) +{ + unsigned char buf[32]; + const uint8_t *binc = bin; + unsigned i; + if (binsz < 4) + return -4; + ripemd160(bin, binsz - 4, buf); // No double SHA256, but a single RIPEMD160 + if (memcmp(&binc[binsz - 4], buf, 4)) + return -1; + + // Check number of zeros is correct AFTER verifying checksum (to avoid possibility of accessing base58str beyond the end) + for (i = 0; binc[i] == '\0' && base58str[i] == '1'; ++i) + {} // Just finding the end of zeros, nothing to do in loop + if (binc[i] == '\0' || base58str[i] == '1') + return -3; + + return binc[0]; +} + +int base58gph_encode_check(const uint8_t *data, int datalen, char *str, int strsize) +{ + if (datalen > 128) { + return 0; + } + uint8_t buf[datalen + 32]; + uint8_t *hash = buf + datalen; + memcpy(buf, data, datalen); + ripemd160(data, datalen, hash); // No double SHA256, but a single RIPEMD160 + size_t res = strsize; + bool success = b58enc(str, &res, buf, datalen + 4); + memzero(buf, sizeof(buf)); + return success ? res : 0; +} + +int base58gph_decode_check(const char *str, uint8_t *data, int datalen) +{ + if (datalen > 128) { + return 0; + } + uint8_t d[datalen + 4]; + size_t res = datalen + 4; + if (b58tobin(d, &res, str) != true) { + return 0; + } + uint8_t *nd = d + datalen + 4 - res; + if (b58gphcheck(nd, res, str) < 0) { + return 0; + } + memcpy(data, nd, res - 4); + return res - 4; +} +#endif diff --git a/src/crypto/bip39/base58.h b/src/crypto/bip39/base58.h new file mode 100644 index 000000000..0fa9167bf --- /dev/null +++ b/src/crypto/bip39/base58.h @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2013-2014 Tomas Dzetkulic + * Copyright (c) 2013-2014 Pavol Rusnak + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __BASE58_H__ +#define __BASE58_H__ + +#include +#include +#include "hasher.h" +#include "options.h" + +extern const char b58digits_ordered[]; +extern const int8_t b58digits_map[]; + +int base58_encode_check(const uint8_t *data, int len, HasherType hasher_type, char *str, int strsize); +int base58_decode_check(const char *str, HasherType hasher_type, uint8_t *data, int datalen); + +// Private +bool b58tobin(void *bin, size_t *binszp, const char *b58); +int b58check(const void *bin, size_t binsz, HasherType hasher_type, const char *base58str); +bool b58enc(char *b58, size_t *b58sz, const void *data, size_t binsz); + +#if USE_GRAPHENE +int base58gph_encode_check(const uint8_t *data, int datalen, char *str, int strsize); +int base58gph_decode_check(const char *str, uint8_t *data, int datalen); +int b58gphcheck(const void *bin, size_t binsz, const char *base58str); +#endif + +#endif diff --git a/src/crypto/bip39/bip32.h b/src/crypto/bip39/bip32.h new file mode 100644 index 000000000..c0a04b5f8 --- /dev/null +++ b/src/crypto/bip39/bip32.h @@ -0,0 +1,112 @@ +/** + * Copyright (c) 2013-2014 Tomas Dzetkulic + * Copyright (c) 2013-2014 Pavol Rusnak + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __BIP32_H__ +#define __BIP32_H__ + +#include +#include +#include +#include "ecdsa.h" +#include "ed25519-donna/ed25519.h" +#include "options.h" + +typedef struct { + const char *bip32_name; // string for generating BIP32 xprv from seed + const ecdsa_curve *params; // ecdsa curve parameters, null for ed25519 + + HasherType hasher_base58; + HasherType hasher_sign; + HasherType hasher_pubkey; + HasherType hasher_script; +} curve_info; + +typedef struct { + uint32_t depth; + uint32_t child_num; + uint8_t chain_code[32]; + + uint8_t private_key[32]; + uint8_t private_key_extension[32]; + + uint8_t public_key[33]; + const curve_info *curve; +} HDNode; + +int hdnode_from_xpub(uint32_t depth, uint32_t child_num, const uint8_t *chain_code, const uint8_t *public_key, const char *curve, HDNode *out); + +int hdnode_from_xprv(uint32_t depth, uint32_t child_num, const uint8_t *chain_code, const uint8_t *private_key, const char *curve, HDNode *out); + +int hdnode_from_seed(const uint8_t *seed, int seed_len, const char *curve, HDNode *out); + +#define hdnode_private_ckd_prime(X, I) hdnode_private_ckd((X), ((I) | 0x80000000)) + +int hdnode_private_ckd(HDNode *inout, uint32_t i); + +#if USE_CARDANO +int hdnode_private_ckd_cardano(HDNode *inout, uint32_t i); +int hdnode_from_seed_cardano(const uint8_t *pass, int pass_len, const uint8_t *seed, int seed_len, HDNode *out); +#endif + +int hdnode_public_ckd_cp(const ecdsa_curve *curve, const curve_point *parent, const uint8_t *parent_chain_code, uint32_t i, curve_point *child, uint8_t *child_chain_code); + +int hdnode_public_ckd(HDNode *inout, uint32_t i); + +void hdnode_public_ckd_address_optimized(const curve_point *pub, const uint8_t *chain_code, uint32_t i, uint32_t version, HasherType hasher_pubkey, HasherType hasher_base58, char *addr, int addrsize, int addrformat); + +#if USE_BIP32_CACHE +int hdnode_private_ckd_cached(HDNode *inout, const uint32_t *i, size_t i_count, uint32_t *fingerprint); +#endif + +uint32_t hdnode_fingerprint(HDNode *node); + +void hdnode_fill_public_key(HDNode *node); + +#if USE_ETHEREUM +int hdnode_get_ethereum_pubkeyhash(const HDNode *node, uint8_t *pubkeyhash); +#endif + +#if USE_NEM +int hdnode_get_nem_address(HDNode *node, uint8_t version, char *address); +int hdnode_get_nem_shared_key(const HDNode *node, const ed25519_public_key peer_public_key, const uint8_t *salt, ed25519_public_key mul, uint8_t *shared_key); +int hdnode_nem_encrypt(const HDNode *node, const ed25519_public_key public_key, const uint8_t *iv, const uint8_t *salt, const uint8_t *payload, size_t size, uint8_t *buffer); +int hdnode_nem_decrypt(const HDNode *node, const ed25519_public_key public_key, uint8_t *iv, const uint8_t *salt, const uint8_t *payload, size_t size, uint8_t *buffer); +#endif + +int hdnode_sign(HDNode *node, const uint8_t *msg, uint32_t msg_len, HasherType hasher_sign, uint8_t *sig, uint8_t *pby, int (*is_canonical)(uint8_t by, uint8_t sig[64])); +int hdnode_sign_digest(HDNode *node, const uint8_t *digest, uint8_t *sig, uint8_t *pby, int (*is_canonical)(uint8_t by, uint8_t sig[64])); + +int hdnode_get_shared_key(const HDNode *node, const uint8_t *peer_public_key, uint8_t *session_key, int *result_size); + +int hdnode_serialize_public(const HDNode *node, uint32_t fingerprint, uint32_t version, char *str, int strsize); + +int hdnode_serialize_private(const HDNode *node, uint32_t fingerprint, uint32_t version, char *str, int strsize); + +int hdnode_deserialize(const char *str, uint32_t version_public, uint32_t version_private, const char *curve, HDNode *node, uint32_t *fingerprint); + +void hdnode_get_address_raw(HDNode *node, uint32_t version, uint8_t *addr_raw); +void hdnode_get_address(HDNode *node, uint32_t version, char *addr, int addrsize); + +const curve_info *get_curve_by_name(const char *curve_name); + +#endif diff --git a/src/crypto/bip39/bip39_mnemonic.c b/src/crypto/bip39/bip39_mnemonic.c new file mode 100644 index 000000000..a4dc27b86 --- /dev/null +++ b/src/crypto/bip39/bip39_mnemonic.c @@ -0,0 +1,29 @@ +#include +#include +#include +#include "bip39.h" +#include + +// NOTE: We must override this to implement actual RNG! +void random_buffer(uint8_t *buf, size_t len) { + if( len > 0 ) { + randombytes_buf(buf, len); + } +} + +int main(int argc, char **argv) +{ + char *this = argv[0]; + if (argc > 1) { + fprintf(stderr, "Usage: %s\n", this); + return 1; + } + if (sodium_init() == -1) { + fprintf(stderr, "libsodium init failed! :(\n"); + return 1; + } + int strength = 256; + const char *mnemonic = mnemonic_generate(strength); + printf("%s\n", mnemonic); + return 0; +} diff --git a/src/crypto/bip39/bip39bruteforce.c b/src/crypto/bip39/bip39bruteforce.c new file mode 100644 index 000000000..10fd69da7 --- /dev/null +++ b/src/crypto/bip39/bip39bruteforce.c @@ -0,0 +1,87 @@ +#include +#include +#include +#include "bip39.h" +#include "bip32.h" +#include "ecdsa.h" +#include "curves.h" + +char iter[256]; +uint8_t seed[512 / 8]; +uint8_t addr[21], pubkeyhash[20]; +int count = 0, found = 0; +HDNode node; +clock_t start; + +// around 280 tries per second + +// testing data: +// +// mnemonic: "all all all all all all all all all all all all" +// address: "1JAd7XCBzGudGpJQSDSfpmJhiygtLQWaGL" +// passphrase: "" +// +// mnemonic: "all all all all all all all all all all all all" +// address: "1N3uJ5AU3FTYQ1ZQgTMtYmgSvMBmQiGVBS" +// passphrase: "testing" + +int main(int argc, char **argv) +{ + if (argc != 2 && argc != 3) { + fprintf(stderr, "Usage: bip39bruteforce address [mnemonic]\n"); + return 1; + } + const char *address = argv[1]; + const char *mnemonic, *item; + if (argc == 3) { + mnemonic = argv[2]; + item = "passphrase"; + } else { + mnemonic = NULL; + item = "mnemonic"; + } + if (mnemonic && !mnemonic_check(mnemonic)) { + fprintf(stderr, "\"%s\" is not a valid mnemonic\n", mnemonic); + return 2; + } + if (!ecdsa_address_decode(address, 0, HASHER_SHA2, addr)) { + fprintf(stderr, "\"%s\" is not a valid address\n", address); + return 3; + } + printf("Reading %ss from stdin ...\n", item); + start = clock(); + for (;;) { + if (fgets(iter, 256, stdin) == NULL) break; + int len = strlen(iter); + if (len <= 0) { + continue; + } + count++; + iter[len - 1] = 0; + if (mnemonic) { + mnemonic_to_seed(mnemonic, iter, seed, NULL); + } else { + mnemonic_to_seed(iter, "", seed, NULL); + } + hdnode_from_seed(seed, 512 / 8, SECP256K1_NAME, &node); + hdnode_private_ckd_prime(&node, 44); + hdnode_private_ckd_prime(&node, 0); + hdnode_private_ckd_prime(&node, 0); + hdnode_private_ckd(&node, 0); + hdnode_private_ckd(&node, 0); + hdnode_fill_public_key(&node); + ecdsa_get_pubkeyhash(node.public_key, HASHER_SHA2, pubkeyhash); + if (memcmp(addr + 1, pubkeyhash, 20) == 0) { + found = 1; + break; + } + } + float dur = (float)(clock() - start) / CLOCKS_PER_SEC; + printf("Tried %d %ss in %f seconds = %f tries/second\n", count, item, dur, (float)count/dur); + if (found) { + printf("Correct %s found! :-)\n\"%s\"\n", item, iter); + return 0; + } + printf("Correct %s not found. :-(\n", item); + return 4; +} From 7ae5a565d596edc5097ab53e0f46875c384ae75f Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 11 Sep 2020 10:30:01 -0400 Subject: [PATCH 190/255] Add a bunch of things required by bip39 dependencies --- src/crypto/bip39/blake256.h | 53 ++++++++++++ src/crypto/bip39/blake2_common.h | 39 +++++++++ src/crypto/bip39/blake2b.h | 41 +++++++++ src/crypto/bip39/blake2s.h | 41 +++++++++ src/crypto/bip39/hasher.c | 144 +++++++++++++++++++++++++++++++ src/crypto/bip39/hasher.h | 80 +++++++++++++++++ src/crypto/bip39/memzero.c | 66 ++++++++++++++ src/crypto/bip39/secp256k1.h | 38 ++++++++ 8 files changed, 502 insertions(+) create mode 100644 src/crypto/bip39/blake256.h create mode 100644 src/crypto/bip39/blake2_common.h create mode 100644 src/crypto/bip39/blake2b.h create mode 100644 src/crypto/bip39/blake2s.h create mode 100644 src/crypto/bip39/hasher.c create mode 100644 src/crypto/bip39/hasher.h create mode 100644 src/crypto/bip39/memzero.c create mode 100644 src/crypto/bip39/secp256k1.h diff --git a/src/crypto/bip39/blake256.h b/src/crypto/bip39/blake256.h new file mode 100644 index 000000000..313b6260e --- /dev/null +++ b/src/crypto/bip39/blake256.h @@ -0,0 +1,53 @@ +// Copyright (c) 2014-2017, The Monero Project +// +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without modification, are +// permitted provided that the following conditions are met: +// +// 1. Redistributions of source code must retain the above copyright notice, this list of +// conditions and the following disclaimer. +// +// 2. Redistributions in binary form must reproduce the above copyright notice, this list +// of conditions and the following disclaimer in the documentation and/or other +// materials provided with the distribution. +// +// 3. Neither the name of the copyright holder nor the names of its contributors may be +// used to endorse or promote products derived from this software without specific +// prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL +// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF +// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers + +#ifndef __BLAKE256_H__ +#define __BLAKE256_H__ + +#include +#include + +#define BLAKE256_DIGEST_LENGTH 32 +#define BLAKE256_BLOCK_LENGTH 64 + +typedef struct { + uint32_t h[8], s[4], t[2]; + size_t buflen; + uint8_t nullt; + uint8_t buf[64]; +} BLAKE256_CTX; + +void blake256_Init(BLAKE256_CTX *); +void blake256_Update(BLAKE256_CTX *, const uint8_t *, size_t); +void blake256_Final(BLAKE256_CTX *, uint8_t *); + +void blake256(const uint8_t *, size_t, uint8_t *); + +#endif /* __BLAKE256_H__ */ diff --git a/src/crypto/bip39/blake2_common.h b/src/crypto/bip39/blake2_common.h new file mode 100644 index 000000000..40c6da3b5 --- /dev/null +++ b/src/crypto/bip39/blake2_common.h @@ -0,0 +1,39 @@ +static inline uint32_t load32( const void *src ) +{ + uint32_t w; + memcpy(&w, src, sizeof w); + return w; +} + +static inline uint64_t load64( const void *src ) +{ + uint64_t w; + memcpy(&w, src, sizeof w); + return w; +} + +static inline void store16( void *dst, uint16_t w ) +{ + memcpy(dst, &w, sizeof w); +} + +static inline void store32( void *dst, uint32_t w ) +{ + memcpy(dst, &w, sizeof w); +} + +static inline void store64( void *dst, uint64_t w ) +{ + memcpy(dst, &w, sizeof w); +} + +static inline uint32_t rotr32( const uint32_t w, const unsigned c ) +{ + return ( w >> c ) | ( w << ( 32 - c ) ); +} + +static inline uint64_t rotr64( const uint64_t w, const unsigned c ) +{ + return ( w >> c ) | ( w << ( 64 - c ) ); +} + diff --git a/src/crypto/bip39/blake2b.h b/src/crypto/bip39/blake2b.h new file mode 100644 index 000000000..1a43e92d1 --- /dev/null +++ b/src/crypto/bip39/blake2b.h @@ -0,0 +1,41 @@ +#ifndef __BLAKE2B_H__ +#define __BLAKE2B_H__ + +#include +#include + +enum blake2b_constant +{ + BLAKE2B_BLOCKBYTES = 128, + BLAKE2B_OUTBYTES = 64, + BLAKE2B_KEYBYTES = 64, + BLAKE2B_SALTBYTES = 16, + BLAKE2B_PERSONALBYTES = 16 +}; + +typedef struct __blake2b_state +{ + uint64_t h[8]; + uint64_t t[2]; + uint64_t f[2]; + uint8_t buf[BLAKE2B_BLOCKBYTES]; + size_t buflen; + size_t outlen; + uint8_t last_node; +} blake2b_state; + +#define BLAKE2B_CTX blake2b_state +#define BLAKE2B_BLOCK_LENGTH BLAKE2B_BLOCKBYTES +#define BLAKE2B_DIGEST_LENGTH BLAKE2B_OUTBYTES +#define BLAKE2B_KEY_LENGTH BLAKE2B_KEYBYTES + +int blake2b_Init(blake2b_state *S, size_t outlen); +int blake2b_InitKey(blake2b_state *S, size_t outlen, const void *key, size_t keylen); +int blake2b_InitPersonal(blake2b_state *S, size_t outlen, const void *personal, size_t personal_len); +int blake2b_Update(blake2b_state *S, const void *pin, size_t inlen); +int blake2b_Final(blake2b_state *S, void *out, size_t outlen); + +int blake2b(const uint8_t *msg, uint32_t msg_len, void *out, size_t outlen); +int blake2b_Key(const uint8_t *msg, uint32_t msg_len, const void *key, size_t keylen, void *out, size_t outlen); + +#endif diff --git a/src/crypto/bip39/blake2s.h b/src/crypto/bip39/blake2s.h new file mode 100644 index 000000000..57991bc91 --- /dev/null +++ b/src/crypto/bip39/blake2s.h @@ -0,0 +1,41 @@ +#ifndef __BLAKE2S_H__ +#define __BLAKE2S_H__ + +#include +#include + +enum blake2s_constant +{ + BLAKE2S_BLOCKBYTES = 64, + BLAKE2S_OUTBYTES = 32, + BLAKE2S_KEYBYTES = 32, + BLAKE2S_SALTBYTES = 8, + BLAKE2S_PERSONALBYTES = 8 +}; + +typedef struct __blake2s_state +{ + uint32_t h[8]; + uint32_t t[2]; + uint32_t f[2]; + uint8_t buf[BLAKE2S_BLOCKBYTES]; + uint32_t buflen; + uint8_t outlen; + uint8_t last_node; +} blake2s_state; + +#define BLAKE2S_CTX blake2s_state +#define BLAKE2S_BLOCK_LENGTH BLAKE2S_BLOCKBYTES +#define BLAKE2S_DIGEST_LENGTH BLAKE2S_OUTBYTES +#define BLAKE2S_KEY_LENGTH BLAKE2S_KEYBYTES + +int blake2s_Init(blake2s_state *S, size_t outlen); +int blake2s_InitKey(blake2s_state *S, size_t outlen, const void *key, size_t keylen); +int blake2s_InitPersonal(blake2s_state *S, size_t outlen, const void *personal, size_t personal_len); +int blake2s_Update(blake2s_state *S, const void *pin, size_t inlen); +int blake2s_Final(blake2s_state *S, void *out, size_t outlen); + +int blake2s(const uint8_t *msg, uint32_t msg_len, void *out, size_t outlen); +int blake2s_Key(const uint8_t *msg, uint32_t msg_len, const void *key, size_t keylen, void *out, size_t outlen); + +#endif diff --git a/src/crypto/bip39/hasher.c b/src/crypto/bip39/hasher.c new file mode 100644 index 000000000..dac3e9bf5 --- /dev/null +++ b/src/crypto/bip39/hasher.c @@ -0,0 +1,144 @@ +/** + * Copyright (c) 2017 Saleem Rashid + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "hasher.h" +#include "ripemd160.h" + +void hasher_InitParam(Hasher *hasher, HasherType type, const void *param, uint32_t param_size) { + hasher->type = type; + hasher->param = param; + hasher->param_size = param_size; + + switch (hasher->type) { + case HASHER_SHA2: + case HASHER_SHA2D: + case HASHER_SHA2_RIPEMD: + sha256_Init(&hasher->ctx.sha2); + break; + case HASHER_SHA3: +#if USE_KECCAK + case HASHER_SHA3K: +#endif + sha3_256_Init(&hasher->ctx.sha3); + break; + case HASHER_BLAKE: + case HASHER_BLAKED: + case HASHER_BLAKE_RIPEMD: + blake256_Init(&hasher->ctx.blake); + break; + case HASHER_GROESTLD_TRUNC: + groestl512_Init(&hasher->ctx.groestl); + break; + case HASHER_BLAKE2B: + blake2b_Init(&hasher->ctx.blake2b, 32); + break; + case HASHER_BLAKE2B_PERSONAL: + blake2b_InitPersonal(&hasher->ctx.blake2b, 32, hasher->param, hasher->param_size); + break; + } +} + +void hasher_Init(Hasher *hasher, HasherType type) { + hasher_InitParam(hasher, type, NULL, 0); +} + +void hasher_Reset(Hasher *hasher) { + hasher_InitParam(hasher, hasher->type, hasher->param, hasher->param_size); +} + +void hasher_Update(Hasher *hasher, const uint8_t *data, size_t length) { + switch (hasher->type) { + case HASHER_SHA2: + case HASHER_SHA2D: + case HASHER_SHA2_RIPEMD: + sha256_Update(&hasher->ctx.sha2, data, length); + break; + case HASHER_SHA3: +#if USE_KECCAK + case HASHER_SHA3K: +#endif + sha3_Update(&hasher->ctx.sha3, data, length); + break; + case HASHER_BLAKE: + case HASHER_BLAKED: + case HASHER_BLAKE_RIPEMD: + blake256_Update(&hasher->ctx.blake, data, length); + break; + case HASHER_GROESTLD_TRUNC: + groestl512_Update(&hasher->ctx.groestl, data, length); + break; + case HASHER_BLAKE2B: + case HASHER_BLAKE2B_PERSONAL: + blake2b_Update(&hasher->ctx.blake2b, data, length); + break; + } +} + +void hasher_Final(Hasher *hasher, uint8_t hash[HASHER_DIGEST_LENGTH]) { + switch (hasher->type) { + case HASHER_SHA2: + sha256_Final(&hasher->ctx.sha2, hash); + break; + case HASHER_SHA2D: + sha256_Final(&hasher->ctx.sha2, hash); + hasher_Raw(HASHER_SHA2, hash, HASHER_DIGEST_LENGTH, hash); + break; + case HASHER_SHA2_RIPEMD: + sha256_Final(&hasher->ctx.sha2, hash); + ripemd160(hash, HASHER_DIGEST_LENGTH, hash); + break; + case HASHER_SHA3: + sha3_Final(&hasher->ctx.sha3, hash); + break; +#if USE_KECCAK + case HASHER_SHA3K: + keccak_Final(&hasher->ctx.sha3, hash); + break; +#endif + case HASHER_BLAKE: + blake256_Final(&hasher->ctx.blake, hash); + break; + case HASHER_BLAKED: + blake256_Final(&hasher->ctx.blake, hash); + hasher_Raw(HASHER_BLAKE, hash, HASHER_DIGEST_LENGTH, hash); + break; + case HASHER_BLAKE_RIPEMD: + blake256_Final(&hasher->ctx.blake, hash); + ripemd160(hash, HASHER_DIGEST_LENGTH, hash); + break; + case HASHER_GROESTLD_TRUNC: + groestl512_DoubleTrunc(&hasher->ctx.groestl, hash); + break; + case HASHER_BLAKE2B: + case HASHER_BLAKE2B_PERSONAL: + blake2b_Final(&hasher->ctx.blake2b, hash, 32); + break; + } +} + +void hasher_Raw(HasherType type, const uint8_t *data, size_t length, uint8_t hash[HASHER_DIGEST_LENGTH]) { + Hasher hasher; + + hasher_Init(&hasher, type); + hasher_Update(&hasher, data, length); + hasher_Final(&hasher, hash); +} diff --git a/src/crypto/bip39/hasher.h b/src/crypto/bip39/hasher.h new file mode 100644 index 000000000..0cde1df8b --- /dev/null +++ b/src/crypto/bip39/hasher.h @@ -0,0 +1,80 @@ +/** + * Copyright (c) 2017 Saleem Rashid + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __HASHER_H__ +#define __HASHER_H__ + +#include +#include + +#include "sha2.h" +#include "sha3.h" +#include "blake256.h" +#include "groestl.h" +#include "blake2b.h" + +#define HASHER_DIGEST_LENGTH 32 + +typedef enum { + HASHER_SHA2, + HASHER_SHA2D, + HASHER_SHA2_RIPEMD, + + HASHER_SHA3, +#if USE_KECCAK + HASHER_SHA3K, +#endif + + HASHER_BLAKE, + HASHER_BLAKED, + HASHER_BLAKE_RIPEMD, + + HASHER_GROESTLD_TRUNC, /* Double Groestl512 hasher truncated to 256 bits */ + + HASHER_BLAKE2B, + HASHER_BLAKE2B_PERSONAL, +} HasherType; + +typedef struct { + HasherType type; + + union { + SHA256_CTX sha2; // for HASHER_SHA2{,D} + SHA3_CTX sha3; // for HASHER_SHA3{,K} + BLAKE256_CTX blake; // for HASHER_BLAKE{,D} + GROESTL512_CTX groestl; // for HASHER_GROESTLD_TRUNC + BLAKE2B_CTX blake2b; // for HASHER_BLAKE2B{,_PERSONAL} + } ctx; + + const void *param; + uint32_t param_size; +} Hasher; + +void hasher_InitParam(Hasher *hasher, HasherType type, const void *param, uint32_t param_size); +void hasher_Init(Hasher *hasher, HasherType type); +void hasher_Reset(Hasher *hasher); +void hasher_Update(Hasher *hasher, const uint8_t *data, size_t length); +void hasher_Final(Hasher *hasher, uint8_t hash[HASHER_DIGEST_LENGTH]); + +void hasher_Raw(HasherType type, const uint8_t *data, size_t length, uint8_t hash[HASHER_DIGEST_LENGTH]); + +#endif diff --git a/src/crypto/bip39/memzero.c b/src/crypto/bip39/memzero.c new file mode 100644 index 000000000..3c3a7383d --- /dev/null +++ b/src/crypto/bip39/memzero.c @@ -0,0 +1,66 @@ +#ifndef __STDC_WANT_LIB_EXT1__ +#define __STDC_WANT_LIB_EXT1__ 1 // C11's bounds-checking interface. +#endif +#include + +#ifdef _WIN32 +#include +#endif + +#ifdef __unix__ +#include +#include +#endif + +// C11's bounds-checking interface. +#if defined(__STDC_LIB_EXT1__) +#define HAVE_MEMSET_S 1 +#endif + +// GNU C Library version 2.25 or later. +#if defined(__GLIBC__) && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 25)) +#define HAVE_EXPLICIT_BZERO 1 +#endif + +// Newlib +#if defined( __NEWLIB__) +#define HAVE_EXPLICIT_BZERO 1 +#endif + +// FreeBSD version 11.0 or later. +#if defined(__FreeBSD__) && __FreeBSD_version >= 1100037 +#define HAVE_EXPLICIT_BZERO 1 +#endif + +// OpenBSD version 5.5 or later. +#if defined(__OpenBSD__) && OpenBSD >= 201405 +#define HAVE_EXPLICIT_BZERO 1 +#endif + +// NetBSD version 7.2 or later. +#if defined(__NetBSD__) && __NetBSD_Version__ >= 702000000 +#define HAVE_EXPLICIT_MEMSET 1 +#endif + +// Adapted from https://github.com/jedisct1/libsodium/blob/1647f0d53ae0e370378a9195477e3df0a792408f/src/libsodium/sodium/utils.c#L102-L130 + +void memzero(void *const pnt, const size_t len) +{ +#ifdef _WIN32 + SecureZeroMemory(pnt, len); +#elif defined(HAVE_MEMSET_S) + memset_s(pnt, (rsize_t) len, 0, (rsize_t) len); +#elif defined(HAVE_EXPLICIT_BZERO) + explicit_bzero(pnt, len); +#elif defined(HAVE_EXPLICIT_MEMSET) + explicit_memset(pnt, 0, len); +#else + volatile unsigned char *volatile pnt_ = + (volatile unsigned char *volatile) pnt; + size_t i = (size_t) 0U; + + while (i < len) { + pnt_[i++] = 0U; + } +#endif +} diff --git a/src/crypto/bip39/secp256k1.h b/src/crypto/bip39/secp256k1.h new file mode 100644 index 000000000..234ca97a9 --- /dev/null +++ b/src/crypto/bip39/secp256k1.h @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2013-2014 Tomas Dzetkulic + * Copyright (c) 2013-2014 Pavol Rusnak + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES + * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __SECP256K1_H__ +#define __SECP256K1_H__ + +#include + +#include "ecdsa.h" +#include "bip32.h" + +extern const ecdsa_curve secp256k1; +extern const curve_info secp256k1_info; +extern const curve_info secp256k1_decred_info; +extern const curve_info secp256k1_groestl_info; +extern const curve_info secp256k1_smart_info; + +#endif From a45ee31765e08d2a0c8801d5953d0cec780ac37b Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 11 Sep 2020 10:30:56 -0400 Subject: [PATCH 191/255] Add a static makefile for now --- src/crypto/bip39/Makefile | 66 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/crypto/bip39/Makefile diff --git a/src/crypto/bip39/Makefile b/src/crypto/bip39/Makefile new file mode 100644 index 000000000..4a5dec3d8 --- /dev/null +++ b/src/crypto/bip39/Makefile @@ -0,0 +1,66 @@ +CC ?= gcc + +OPTFLAGS ?= -O3 -g + +CFLAGS += $(OPTFLAGS) \ + -std=gnu99 \ + -W \ + -Wall \ + -Wextra \ + -Wimplicit-function-declaration \ + -Wredundant-decls \ + -Wstrict-prototypes \ + -Wundef \ + -Wshadow \ + -Wpointer-arith \ + -Wformat \ + -Wreturn-type \ + -Wsign-compare \ + -Wmultichar \ + -Wformat-nonliteral \ + -Winit-self \ + -Wuninitialized \ + -Wformat-security \ + -Werror + +VALGRIND ?= 1 + +CFLAGS += -I. +CFLAGS += -DVALGRIND=$(VALGRIND) +CFLAGS += $(shell pkg-config --cflags openssl) + +# disable certain optimizations and features when small footprint is required +ifdef SMALL +CFLAGS += -DUSE_PRECOMPUTED_CP=0 +endif + +SRCS = bignum.c ecdsa.c curves.c secp256k1.c nist256p1.c rand.c hmac.c bip32.c bip39.c pbkdf2.c base58.c base32.c +#SRCS += address.c +#SRCS += script.c +SRCS += ripemd160.c +SRCS += sha2.c +SRCS += sha3.c +SRCS += hasher.c +#SRCS += aes/aescrypt.c aes/aeskey.c aes/aestab.c aes/aes_modes.c +#SRCS += ed25519-donna/curve25519-donna-32bit.c ed25519-donna/curve25519-donna-helpers.c ed25519-donna/modm-donna-32bit.c +#SRCS += ed25519-donna/ed25519-donna-basepoint-table.c ed25519-donna/ed25519-donna-32bit-tables.c ed25519-donna/ed25519-donna-impl-base.c +#SRCS += ed25519-donna/ed25519.c ed25519-donna/curve25519-donna-scalarmult-base.c ed25519-donna/ed25519-sha3.c ed25519-donna/ed25519-keccak.c +#SRCS += blake256.c +#SRCS += blake2b.c blake2s.c +#SRCS += chacha20poly1305/chacha20poly1305.c chacha20poly1305/chacha_merged.c chacha20poly1305/poly1305-donna.c chacha20poly1305/rfc7539.c +SRCS += memzero.c + +OBJS = $(SRCS:.c=.o) + +TESTLIBS = $(shell pkg-config --libs check) -lpthread -lm +TESTSSLLIBS = $(shell pkg-config --libs openssl) + +all: hasher.o bip39.o memzero.o pbkdf2.o base58.o base32.o + @echo "Created object files, donezo" + +%.o: %.c %.h options.h + $(CC) $(CFLAGS) -o $@ -c $< + +clean: + rm -rf *.o + From 5d86afef6a012962701f1385ea45533a660d640c Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Sat, 12 Sep 2020 09:12:40 +0200 Subject: [PATCH 192/255] Port -txsend from str4d #37, https://github.com/zcash/zcash/pull/4522 --- src/init.cpp | 11 +++++++++++ src/rpc/rawtransaction.cpp | 16 ++++++++++++++++ src/wallet/wallet.cpp | 8 ++++++++ 3 files changed, 35 insertions(+) diff --git a/src/init.cpp b/src/init.cpp index cd25e63fd..9f92999c4 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -392,6 +392,7 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-sysperms", _("Create new files with system default permissions, instead of umask 077 (only effective with disabled wallet functionality)")); #endif strUsage += HelpMessageOpt("-txindex", strprintf(_("Maintain a full transaction index, used by the getrawtransaction rpc call (default: %u)"), 0)); + strUsage += HelpMessageOpt("-txsend=", _("Execute command to send a transaction instead of broadcasting (%s in cmd is replaced by transaction hex)")); strUsage += HelpMessageOpt("-addressindex", strprintf(_("Maintain a full address index, used to query for the balance, txids and unspent outputs for addresses (default: %u)"), DEFAULT_ADDRESSINDEX)); strUsage += HelpMessageOpt("-timestampindex", strprintf(_("Maintain a timestamp index for block hashes, used to query blocks hashes by a range of timestamps (default: %u)"), DEFAULT_TIMESTAMPINDEX)); strUsage += HelpMessageOpt("-spentindex", strprintf(_("Maintain a full spent index, used to query the spending txid and input index for an outpoint (default: %u)"), DEFAULT_SPENTINDEX)); @@ -1118,6 +1119,16 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) #endif } + if (mapArgs.count("-txsend")) { + if (GetBoolArg("-walletbroadcast", true)) { + if (SoftSetBoolArg("-walletbroadcast", false)) { + LogPrintf("%s: parameter interaction: -txsend= -> setting -walletbroadcast=0\n", __func__); + } else { + return InitError(_("Wallet transaction broadcasting is incompatible with -txsend (for privacy).")); + } + } + } + // ********************************************************* Step 3: parameter-to-internal-flags fZdebug=GetBoolArg("-zdebug", false); diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 23327faf2..4b24081d7 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -45,7 +45,10 @@ #include +#include + #include +#include #include @@ -1373,6 +1376,19 @@ UniValue sendrawtransaction(const UniValue& params, bool fHelp, const CPubKey& m const CCoins* existingCoins = view.AccessCoins(hashTx); bool fHaveMempool = mempool.exists(hashTx); bool fHaveChain = existingCoins && existingCoins->nHeight < 1000000000; + + // If we are configured to send transactions via an + // external service instead of broadcasting, do that + std::string strCmd = GetArg("-txsend", ""); + if (!strCmd.empty()) { + if (fHaveChain) { + throw JSONRPCError(RPC_TRANSACTION_ALREADY_IN_CHAIN, "transaction already in block chain"); + } + boost::replace_all(strCmd, "%s", EncodeHexTx(tx)); + boost::thread t(runCommand, strCmd); // thread runs free + // Return here so we don't add to our mempool or broadcast to peers + return hashTx.GetHex(); + } if (!fHaveMempool && !fHaveChain) { // push to local node and sync with wallets CValidationState state; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index fe8cbb4f7..a0cd0533f 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3950,6 +3950,8 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey) // Track how many getdata requests our transaction gets mapRequestCount[wtxNew.GetHash()] = 0; + std::string strCmd = GetArg("-txsend", ""); + if (fBroadcastTransactions) { // Broadcast @@ -3962,6 +3964,12 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey) } wtxNew.RelayWalletTransaction(); } + // If we are configured to send transactions via an + // external service instead of broadcasting, do that + else if (!strCmd.empty()) { + boost::replace_all(strCmd, "%s", EncodeHexTx(wtxNew)); + boost::thread t(runCommand, strCmd); // thread runs free + } } return true; } From 2075d0da25c03435e9c827170df974c7fe9efcc7 Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Sat, 12 Sep 2020 10:01:33 +0200 Subject: [PATCH 193/255] Port scheduler race condition fix from BTC upstream #133, https://github.com/bitcoin/bitcoin/commit/12519bf62b8c49b1c1744eca6ea5b3162a61f962 --- src/scheduler.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/scheduler.cpp b/src/scheduler.cpp index 08aba3225..2e1223b8e 100644 --- a/src/scheduler.cpp +++ b/src/scheduler.cpp @@ -66,9 +66,10 @@ void CScheduler::serviceQueue() // Some boost versions have a conflicting overload of wait_until that returns void. // Explicitly use a template here to avoid hitting that overload. - while (!shouldStop() && !taskQueue.empty() && - newTaskScheduled.wait_until<>(lock, taskQueue.begin()->first) != boost::cv_status::timeout) { - // Keep waiting until timeout + while (!shouldStop() && !taskQueue.empty()) { + boost::chrono::system_clock::time_point timeToWaitFor = taskQueue.begin()->first; + if (newTaskScheduled.wait_until<>(lock, timeToWaitFor) == boost::cv_status::timeout) + break; // Exit loop after timeout, it means we reached the time of the event } // If there are multiple threads, the queue can empty while we're waiting (another From 702ea5fe91f11dc09a251dd8c6d7f6e5f392ba09 Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Sat, 12 Sep 2020 15:11:52 +0200 Subject: [PATCH 194/255] delete joinsplit from rawtransactions #127 --- src/rpc/rawtransaction.cpp | 119 ------------------------------------- 1 file changed, 119 deletions(-) diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 4b24081d7..610e79149 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -85,65 +85,6 @@ void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fInclud out.push_back(Pair("addresses", a)); } -UniValue TxJoinSplitToJSON(const CTransaction& tx) { - bool useGroth = tx.fOverwintered && tx.nVersion >= SAPLING_TX_VERSION; - UniValue vjoinsplit(UniValue::VARR); - for (unsigned int i = 0; i < tx.vjoinsplit.size(); i++) { - const JSDescription& jsdescription = tx.vjoinsplit[i]; - UniValue joinsplit(UniValue::VOBJ); - - joinsplit.push_back(Pair("vpub_old", ValueFromAmount(jsdescription.vpub_old))); - joinsplit.push_back(Pair("vpub_oldZat", jsdescription.vpub_old)); - joinsplit.push_back(Pair("vpub_new", ValueFromAmount(jsdescription.vpub_new))); - joinsplit.push_back(Pair("vpub_newZat", jsdescription.vpub_new)); - - joinsplit.push_back(Pair("anchor", jsdescription.anchor.GetHex())); - - { - UniValue nullifiers(UniValue::VARR); - BOOST_FOREACH(const uint256 nf, jsdescription.nullifiers) { - nullifiers.push_back(nf.GetHex()); - } - joinsplit.push_back(Pair("nullifiers", nullifiers)); - } - - { - UniValue commitments(UniValue::VARR); - BOOST_FOREACH(const uint256 commitment, jsdescription.commitments) { - commitments.push_back(commitment.GetHex()); - } - joinsplit.push_back(Pair("commitments", commitments)); - } - - joinsplit.push_back(Pair("onetimePubKey", jsdescription.ephemeralKey.GetHex())); - joinsplit.push_back(Pair("randomSeed", jsdescription.randomSeed.GetHex())); - - { - UniValue macs(UniValue::VARR); - BOOST_FOREACH(const uint256 mac, jsdescription.macs) { - macs.push_back(mac.GetHex()); - } - joinsplit.push_back(Pair("macs", macs)); - } - - CDataStream ssProof(SER_NETWORK, PROTOCOL_VERSION); - auto ps = SproutProofSerializer(ssProof, useGroth); - boost::apply_visitor(ps, jsdescription.proof); - joinsplit.push_back(Pair("proof", HexStr(ssProof.begin(), ssProof.end()))); - - { - UniValue ciphertexts(UniValue::VARR); - for (const ZCNoteEncryption::Ciphertext ct : jsdescription.ciphertexts) { - ciphertexts.push_back(HexStr(ct.begin(), ct.end())); - } - joinsplit.push_back(Pair("ciphertexts", ciphertexts)); - } - - vjoinsplit.push_back(joinsplit); - } - return vjoinsplit; -} - uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256 hash,int32_t n,int32_t checkheight,uint64_t checkvalue,int32_t tipheight); UniValue TxShieldedSpendsToJSON(const CTransaction& tx) { @@ -309,9 +250,6 @@ void TxToJSONExpanded(const CTransaction& tx, const uint256 hashBlock, UniValue& } entry.push_back(Pair("vout", vout)); - UniValue vjoinsplit = TxJoinSplitToJSON(tx); - entry.push_back(Pair("vjoinsplit", vjoinsplit)); - if (tx.fOverwintered && tx.nVersion >= SAPLING_TX_VERSION) { entry.push_back(Pair("valueBalance", ValueFromAmount(tx.valueBalance))); UniValue vspenddesc = TxShieldedSpendsToJSON(tx); @@ -393,9 +331,6 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry) } entry.push_back(Pair("vout", vout)); - UniValue vjoinsplit = TxJoinSplitToJSON(tx); - entry.push_back(Pair("vjoinsplit", vjoinsplit)); - if (tx.fOverwintered && tx.nVersion >= SAPLING_TX_VERSION) { entry.push_back(Pair("valueBalance", ValueFromAmount(tx.valueBalance))); UniValue vspenddesc = TxShieldedSpendsToJSON(tx); @@ -481,33 +416,6 @@ UniValue getrawtransaction(const UniValue& params, bool fHelp, const CPubKey& my " }\n" " ,...\n" " ],\n" - " \"vjoinsplit\" : [ (array of json objects, only for version >= 2)\n" - " {\n" - " \"vpub_old\" : x.xxx, (numeric) public input value\n" - " \"vpub_new\" : x.xxx, (numeric) public output value\n" - " \"anchor\" : \"hex\", (string) the anchor\n" - " \"nullifiers\" : [ (json array of string)\n" - " \"hex\" (string) input note nullifier\n" - " ,...\n" - " ],\n" - " \"commitments\" : [ (json array of string)\n" - " \"hex\" (string) output note commitment\n" - " ,...\n" - " ],\n" - " \"onetimePubKey\" : \"hex\", (string) the onetime public key used to encrypt the ciphertexts\n" - " \"randomSeed\" : \"hex\", (string) the random seed\n" - " \"macs\" : [ (json array of string)\n" - " \"hex\" (string) input note MAC\n" - " ,...\n" - " ],\n" - " \"proof\" : \"hex\", (string) the zero-knowledge proof\n" - " \"ciphertexts\" : [ (json array of string)\n" - " \"hex\" (string) output note ciphertext\n" - " ,...\n" - " ]\n" - " }\n" - " ,...\n" - " ],\n" " \"blockhash\" : \"hash\", (string) the block hash\n" " \"confirmations\" : n, (numeric) The number of notarized DPoW confirmations\n" " \"rawconfirmations\" : n, (numeric) The number of raw confirmations\n" @@ -936,33 +844,6 @@ UniValue decoderawtransaction(const UniValue& params, bool fHelp, const CPubKey& " }\n" " ,...\n" " ],\n" - " \"vjoinsplit\" : [ (array of json objects, only for version >= 2)\n" - " {\n" - " \"vpub_old\" : x.xxx, (numeric) public input value in HUSH\n" - " \"vpub_new\" : x.xxx, (numeric) public output value in HUSH\n" - " \"anchor\" : \"hex\", (string) the anchor\n" - " \"nullifiers\" : [ (json array of string)\n" - " \"hex\" (string) input note nullifier\n" - " ,...\n" - " ],\n" - " \"commitments\" : [ (json array of string)\n" - " \"hex\" (string) output note commitment\n" - " ,...\n" - " ],\n" - " \"onetimePubKey\" : \"hex\", (string) the onetime public key used to encrypt the ciphertexts\n" - " \"randomSeed\" : \"hex\", (string) the random seed\n" - " \"macs\" : [ (json array of string)\n" - " \"hex\" (string) input note MAC\n" - " ,...\n" - " ],\n" - " \"proof\" : \"hex\", (string) the zero-knowledge proof\n" - " \"ciphertexts\" : [ (json array of string)\n" - " \"hex\" (string) output note ciphertext\n" - " ,...\n" - " ]\n" - " }\n" - " ,...\n" - " ],\n" "}\n" "\nExamples:\n" From 85a40ae2ed9fa4c6d8c1f71cccdfbec9af20ae3f Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 13 Sep 2020 11:23:55 -0400 Subject: [PATCH 195/255] Tweak copyright --- src/sietch.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/sietch.h b/src/sietch.h index 65908e2c9..995f4bbfa 100644 --- a/src/sietch.h +++ b/src/sietch.h @@ -1,5 +1,5 @@ /****************************************************************************** - * Copyright © 2019-2020 The Hush developers * + * Copyright © 2019-2020 The Hush developers * * * * See the AUTHORS and LICENSE files at * * the top-level directory of this distribution for the individual copyright * @@ -10,6 +10,7 @@ * or distributed except according to the terms contained in the GPLv3 * * * * Removal or modification of this copyright notice is prohibited. * + * https://myhush.org * * * ******************************************************************************/ @@ -24,6 +25,7 @@ string newSietchZaddr() { SendManyRecipient newSietchRecipient(string zaddr) { int nAmount = 0; + // TODO: Should we randomize length of data, perhaps into buckets? // Sietch zouts have random data in their memos so they are indistinguishable from // encrypted data being stored in the memo field char hex[] = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f'}; From 4f702525246b092e57a5c633e805fadc83f3cf74 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 13 Sep 2020 11:24:47 -0400 Subject: [PATCH 196/255] Increase max --sietch-min-zouts to 50 --- src/wallet/rpcwallet.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 3b6361fe3..29b79e02b 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4744,17 +4744,15 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) // End goal is to have this be as large as possible without slowing xtns down too much // A value of 7 will provide much stronger linkability privacy versus pre-Sietch operations unsigned int DEFAULT_MIN_ZOUTS=7; - unsigned int MAX_ZOUTS=25; + unsigned int MAX_ZOUTS=50; unsigned int MIN_ZOUTS=GetArg("--sietch-min-zouts", DEFAULT_MIN_ZOUTS); if((MIN_ZOUTS<3) || (MIN_ZOUTS>MAX_ZOUTS)) { - fprintf(stderr,"%s: Sietch min zouts must be >=3 and <= 25, setting to default value of %d\n", __FUNCTION__, DEFAULT_MIN_ZOUTS ); + fprintf(stderr,"%s: Sietch min zouts must be >= 3 and <= %d, setting to default value of %d\n", __FUNCTION__, MAX_ZOUTS, DEFAULT_MIN_ZOUTS ); MIN_ZOUTS=DEFAULT_MIN_ZOUTS; } int nAmount = 0; - // Dynamic Sietch zaddrs default to OFF - bool fSietchDynamic = GetArg("--sietch-dynamic",0); while (zaddrRecipients.size() < MIN_ZOUTS) { // OK, we identify this xtn as needing privacy zdust, we must decide how much, non-deterministically int decider = 1 + GetRandInt(100); // random int between 1 and 100 From b22a73fc2927a5a2e9f3868d52675e6ad0ba3733 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 13 Sep 2020 12:35:41 -0400 Subject: [PATCH 197/255] Run-time randomly generated Sietch zdust addresses This commit drastically improves the privacy of the HUSH anonymity set under attacks which ingest wallet.dat's which have been obtained by seizure, i.e. stealing someones HUSH wallet.dat and putting it into chain analysis software. Ciphertrace is known to do this to ZEC and XMR and we can assume all chain analysis companies are implementing new ways to de-anonymize privacy coins with any data they can obtain. Instead of randomly sending to a randomly chosen static address, hushd Sietch zdust addresses are now randomly generated at run-time. These addresses are not stored in wallet.dat in any way and their private keys are not known except by the internal memory of hushd for a few milliseconds. This data is not stored in long-lived data structures of hushd, only as long as the RPC z_getnewaddress is running or the equivalent function for internals code paths. The seeds or private keys of these addresses are never stored on disk. This now brings hushd on par with SDL, which already does this via a different but equivalent seed phrase technique. With this technique, if a HUSH wallet.dat is seized, it's impossible to tell if any of the shielded outputs are random Sietch zdust with random data payload or a one-time-use zaddr with encrypted payload. --- src/sietch.h | 220 +-------------------------------------- src/wallet/rpcwallet.cpp | 25 +++-- 2 files changed, 16 insertions(+), 229 deletions(-) diff --git a/src/sietch.h b/src/sietch.h index 995f4bbfa..d68716bb1 100644 --- a/src/sietch.h +++ b/src/sietch.h @@ -38,223 +38,11 @@ SendManyRecipient newSietchRecipient(string zaddr) { return SendManyRecipient( zaddr, nAmount, string(str) ); } - -// The network essentially DoS's these addresses and reduces their privacy slightly -// by making them public, but in return, the rest of the shielded pool benefits -// and so it's a large benefit for a small cost. string randomSietchZaddr() { - std::vector SietchShieldedPool1 = { - "zs1qqj4aw35ku9yn72g3tha588mxk66mhl5smnn99as40887xvdg49d4yqf43hhqnj9rpsq7qaqqhx", - "zs1qywzq2cutvg6rkynjljtssz246easagumg3hlwjluz4g7qttg9kqrld7s43ewutpph56jmn2zu6", - "zs1qx7swmw28dj992f6zs0aqucds9kag88mnca5u73dddeqek4m97pg7h9qsaxxwwkgqxht6zujaxc", - "zs1q82pkqu58uemrm2749x6g2ta5shnsra9p5jgk0qqzxd3e08ke6vyeezz7lhldj32jxtsuemskk7", - "zs1qvah5w05qq4yhrsqrt73ckgntkmwdv9mntxep8clnxqfph8xggqad96a5nvwg4evfr9pc5ruvc8", - "zs1qwrkjcmnrwrqqkz3dyfjvdvdppe0ndnm8fhhpsz8stje4qcfc54jtuygz2jfwc3aag69wsjcm8h", - "zs1q5pd7h4x7dtnpa4ace7tytye5sd0j4043t4f3jdntyxvg9ex258nu6pw9tthn6t5gmjq5gv0lhc", - "zs1q6vjrpsuf468an545q7fh9cx0xlkwh75a7qjpemjh3ymuqqzxz5ts2n2dcth3yfnlv6vqpjyglr", - "zs1qmsvwtxkwlh3tkh0lqtwqv2mxy94jt778f7j74a8067nejkt4j3m2rkmypccju7cfuw7xyg0gg8", - "zs1qu3jxrw5qwuvl7zfvnsdvywr4a9cn4h00me65te29platx5agek072f5rvxgt8kdt630qs4tgtr", - "zs1qamxwddwrl5xn56alffruk69p304cqf7uf5nhqpwfc374l9ph00m78xv2kzwymyz0fhxcku7v5k", - "zs1q7gv479e6q7d8fxc35v5s27em66mmm5gz50excudf95rzjgnwdy5pnwdfytvm7gt8kt6wpkfphq", - "zs1pqvxd9a2zcsh2v8gaswh3jp2qkzz5umrucl5k4gx0rkvmq68krpx3jesavxftd8t0z56v8whllj", - "zs1ppn2mdznaa2pd9mavfnxrcjtv0c9un8pg6jaa9ww4wy6wdfs8xxwquqk5umtcjwm6vr4zrqy5x7", - "zs1pz9c9ydyrm7e876cvae9ha45ww77ru5fhys2yz33kjy8ej9230wjy8yupfxkynwqr6nfupgmf94", - "zs1p83g95avpsgr847eu3rm3xcmgurt9hc77wtndnmpypa046n529aqdc9ptz04ugsuhvum2ztzwe3", - "zs1p83jle2p8awu4peevq389y5kyrs5tqxxyrk32zy0t98d4cfepmme0myxp68nrq60xwzc5teulvg", - "zs1pg5ggzwx4yaa7g83yuhay8kzh78nahxfe7cgavn88f7rxlnuckhl2vznv0f33yuqhhs3sh62vl6", - "zs1p2nrefmqfhnwrxqfsz4ruvu8wl7742j5rv2fmwlpmpudwqpdn2yrha9rwsu5gc0fdv2j73tfk6a", - "zs1pw29hkrvszxpe2e4tjpj5h9pszjhql2p4tzcj2c5lf67m7d8jtgc22vehftxdnqze33mgtjc25k", - "zs1p0ggg024alu2l5x8df8ucu4lz8r453su56w2mmshru49uh9a0p6ufy3qfj8a9n7xeu8dxxjrk4p", - "zs1psaydszvszu4mar7ef9gk8atmwpnfjjsh8plajn6ttlgdk44jfud5zv8l3uyq73qk3eskec96ut", - "zs1pjf3kczvrwduuy4x99t03wfrgwstueyw0ypvwa44fz2tukux8kqqqs48uag4y39ed4rux8etvv0", - "zs1pnwzzh4mhehkvf4ys9x70q6meq9mgqj6mgl9ddzwvf8excswrj54lfgu4m9slmc90s37q8e63du", - "zs1pnndevupuakjcqyqzu4sfcgdmdzrhutp8ygxwsl5wvq5hgu20u55auu8p08wphvz9mu3k8ynyr5", - "zs1pmy6tvt9p3xxp5edt70mkwfqk0ljgaranzdnluh5ln36g9g3v2udquleuz5974q2mamywmrxl7j", - "zs1pau6lddk3uapms7v7rsmxvxeekqh52z795kzy9z3dv9qvzq3jwh4pr2adg5cf8fw2e3mzqmgstq", - "zs1zpy6wuvy3jlrfmj0363tx6cuume6j0mqfakk7ydw4f6zvn4s7plewk0gtm7r34pjtppvkp8rzl0", - "zs1zpvkccety206ww6c344ehughuyklc3v02q07j4p72pqewxl0n50zugtje6lclj3m292t6vs56fl", - "zs1zzucdg9kalcjnnknt98gpg42qm9aqpkc6qf5ewgr29udu55r0zt862z3zt23sd4mj9t47k7k6w4", - "zs1z9agq4vq7eswwynhmzdsy58nxq3azhn66y853yw9kvercmve8vv6d5pawpwwpwpuyedmzpcqk8q", - "zs1zvddl2e0pve5kl0hu7fcum30lyhx4pdq64jztq2vp09lqtu5gclfg4fe9fqvnm8k2d5svydg7s4", - "zs1zvsmkn6a4celtcg8ece6exnkvnr2u06ej8kjt6mrpm0983e86dr9al6gd5g73k24j0a0zkpjs3w", - "zs1zv33kglx4n5572dg2pez2k3m7tgtz08a70ndpfj6x204pphlm0pzcppetsnjlat3qflswqfmu83", - "zs1zsz5c9xua7arkvd60vsl559d4dvnjz8ejq4rlmmm9cnz942fdmjmvsgrdl7d5ddxh4y9258jk2l", - "zs1z5n6qvch0wfymumxjflezekxa2j5t978eqzh9ldxsl39h2jjrlzdv9rf00wdrvg0t6afq7mq0us", - "zs1z4ymm3gt22f3pcj9p9l2yg00e2m39kfexgaz99s9y4nsuxhlk6u0sl9lsx9awzywumxyuxv9vuw", - "zs1zkjnhz96xepc97rfyven23epymd5s558yqhp488gcxcj794z6p37h5ej5m5waqxfupmc538mej3", - "zs1zcqdekyq656yj2y86lh08u8zpetfanj5u4rhfpcphne9xw7esce8asux2rdr4yjxzds56fuda5r", - "zs1zceru3jt9m3jqzacnffetvrg8zch6le0zactl7ssfky2vwy7pcffkg3pmauqqpkv5v7nv3uzc5a", - "zs1zellp4tdmxdsd6hmg2c4qlx96m39c0cjlqupw085z87lvzcnx2r0gs7plc0wp4m4upk3zcs35e8", - "zs1zm2pcg2d3hnyxufn8cyshjn742gmffwaqdc0nt5uf9gsytdjywsqaasfdxf4sysfu0sgxjwjp0g", - "zs1za9nk7fpgnfetjulq6t8jgfyks06xg4q8rfwpgsfrkn49k34nc7xhm27dnjuzztgnwkww28ztyw", - "zs1zaaz6j6z7z748mck4v55s3fd4htl4f478kulnwr84m8vn4m0r227juddyq0ncu3cyvc765z9gm4", - "zs1zlz59lgwc8pqq33508v5ygk9e58f7fs4rpj3achhwnkcyn2dku44yfjghdf5l2v50nu2gjzgl2l", - "zs1zlgenma0yuqxmqgns2avpnauclxgfvgd6rf0jt09fmfyaflwlhsscem9ypmrvewl9l356dn3jtr", - "zs1rzu2yg2328l2wlfstu27dl024ucqsjx6g635yxmyhs0wr3lduutkc3peuhqe83uueh5n5q624rd", - "zs1rr9jpeemn9ek30x4h65rx0ddul7xet6cc8atwrjftmq9sdrvj9f5zdc9xg7amtc6dv5fxjyhu54", - "zs1rrgccr0yvfn5fdek39x09y2ylyf42xkydcwzq67wdrzyjj2mv874easa4h4tymz5gj852aqpffk", - "zs1rynh7vl05weafzwkp0p5eafuzzqph04prgg74emqq0sx6xudtrs2380v3ycxgp5lzudw6tmc2zd", - "zs1rxqz0a59zx3yduncc3azyzexwu8xl6cc0zu83hfd28mksrgahhvx8604uhf0u5mna9m4znnj4gr", - "zs1rxr2xff2vcv0y9s6ux6c6t9y7r3zvcvrqmwkvsnxj39t0qv7qwyhncnykhzcqg0ggpu423ykzxe", - "zs1r8chvye5uzlskv8jvt6j8nxnyz4lshy3u46yjhc8w9ekhjhneg402knft3t943t5nrhs6d0d5um", - "zs1rgu6mz58xrqxpyl5xw7ss2szz29cg98s8xl25hu7fy4lcxw58zr93a8rgyha52vwxx7hxj2emkw", - "zs1rveutz8ftruljrlctum42kakjqk4cm8dm2807nqm974dz0rptlxcs999ttsvwp65vc9e59vv9fe", - "zs1rwfqhlezm5ln7kq8wp8hkl08ddn74ryr8cs4cu8qc23spdx79xgfqj4lju4u2yqdrkxkwfvk3ed", - "zs1rwklllsk9jwhhf0fedvlzsqfqdkwer05zh8c8hwypl4tls2hdal54lexhca7kghhum5hycurvfe", - "zs1r0ulehrcg9xz0lfdcukjm3qlvqy74t0u8raqf4zn88vdsta8mzp8t8p9ul8jragssvs9qaqpw2e", - "zs1r3t0cve050wufwl8r2tly05vn7w79v53fe6dagjtt2ese0qm6vgjp3rrsfu4n0am840sq5thn72", - "zs1rnd8zwan2xlrnfwylm9khkeutnzg2v9vjdnyellyuzkwmed94uvd2dq8ceumxwspz037zp2ctqa", - "zs1r4tphfnf3zy34dqyjuld2kgtyg88hrxpv756pkkkmrfdeun0cqzpepac4ma9qrjrvdqxg2z5fuv", - "zs1rcpywy0v4sfej85wdaslfwsp4pe9sa87xgzv24ywhps2l4c9jlrqttv0wl9zkc5e7rsekf42wvp", - "zs1r66et0z9xw3qqhzyc2aht294y7yqyz8wx2l2t63unca4k4zh4v9t44kpmg52z9va5968y45fdkx", - "zs1rat3szdulwxwmx7y4rdphvlpjj5phadvz0fsvj7mtg9ggzwd22sn30hzsh27h7t6cvca6a8wu2n", - "zs1rau4jcth66jsg098ucclp9tfa5qe6jmtmfkcluaqnyj3uatkt9dsrgx44xtmxr3e9xuxv6sy208", - "zs1ypf2v2yu4p4mnlmw0wd3mpztpjlhl39jnn6hkvf77ell0h5u6yg2pgeusvku5y5sykyy6kk6yyh", - "zs1yzkt8catgk6slwj7azu79tvwv6tkd6agcykvvht4rxlevtsh99u036jf5503pju3h05w7x02cm8", - "zs1yrty5fmnyaartpcyjnpal0w44g4mt2ey5tyzcmgq4g6qtsfjmxae7fvy2zsw7t0zvseuwcfwt2e", - "zs1y9p5gazcx04kke96xudep0edzkqr06gdjnr5vm99a6qxzatqz5katput4q9nx95e8965sg7d3pl", - "zs1y9vpfgkxwh3xm3j9d38zkeqql2lh8w3ucgerkww2asdv89p87emdavkzurnqpkrmu7e3xv5myue", - "zs1yfa9gwmn0xe4myrg0rf8kmu36243u8773ukeev0set2yv0z9vpxm6ratee52e9zmpvvx7w2xy28", - "zs1ytpjrujfsgs69smqerxeaf8m38jwxc4ejgxxe4pzc5qu4auqrgy8tf7zxc402pxf9uku646kc0q", - "zs1ytvtdwmcn8tnka6w6wa8n3ghnkf7gp2qaudd4233y6m509ntm59rr0n8eudhre0md7m0zedpcsq", - "zs1yjmeu09mzrt8rgehv2gcfhxx6ddqz7ww87ssfapndvc94hxfrfsdkkgm8f8nr36xm8p7q462qy2", - "zs1ynqghdu0r0c20csp3ygrxdw9hk2l89j3g59q8zhht9jyxycpcc9ccvhyyn2f9j0ehp4pk5wkhqs", - "zs1y5ny4jpjm05vp5awjd6muaqqypdv0y9tr6pz0m5t82cwtrearxwf7km4aznydpcjeuzxqvk0z9m", - "zs1yh2vd5usfsyv4pscjrxg9wdy3gnnyuh8vky27ln3u9jspadmpqsjmyvxmvfyyq3nv4deudvygxa", - "zs1yclvhy57hngs7d233e4x8ywfreswslz2gvn0f8epcs0wrzuqqau3hkrvf7ru6jhh0zmsyn5jkj6", - "zs1yunkgwzf0m5suz380j7xqge6rd9e6acjc5wp22z0jhalqdpspdjey7jfjvgrckgsk9ydc9yrnq3", - "zs19p94fnry6p88ms3yh60nl4kxlxmu7uxv9aafmf5pc4nyd64vslaqgmj30nxe3l5j7cxu5kqeqpm", - "zs19x2df6qmd4c9whrgj6m4mssz22x9qj9x8lmcnexnhw32pey24xy9sws5ts2q7guunm7mx9wmllj", - "zs198a984na6qt2z3uyhdkmj7sfevt794dl3mum3782kddjy4uawr2teznpuxvnzc4dvs3c6zyqxey", - "zs192ld62azpypesveqsat6m63sqaw95ejlqfcjsal5t0fea9zjzqnurmpnl6074zdms0amw83rw0x", - "zs19vsx09xmzlj9vr3s3vu8z4237gpcgrl7qs0vapzzawgnu7gxngeaxlgwqf0ppu0f7us9cfe3cqz", - "zs19wfwd8zufu27zugan77wf2g790egdw7vkulf6f375ylq0arnv2nv94l84nl8lp3tpccv763wetn", - "zs19wcqtqqjj0mnrn90ntcmyq5x8qr2wsaslqwt0fysz4xh2mmjy0z9jjh4sj86sjrgen0axx04zt4", - "zs19jypvpjpvhv5et5wq2ny09skt72hxz9adfgk2ev7nza5jyxr6gss5qelygnxn0szmjqyke2h8a7", - "zs195kll03d43her83a65y7z0zsetynlnft4pjxdspegvun0m7cwtx0vsxfm89mv50vxr90qhvcqpz", - "zs195e2g52jpyly7t9vjpfcegt87g7lpa4rm74nxn0zvmtzjhvg7f5gjnskc5ax5skvwprcshenyqs", - "zs194e84mfxc4vn4ssce7hkvgrcm3c8j7vehcetkdf78rele2lwkx9tzcfnrwhykdqa2nmwx5qcr0j", - "zs19cxqspj63ksk6uwtynj0la72zuvh8rxfh0e0pr2y5vuuvw35sm78juzh5gxcuqa8jggv703rplf", - "zs19e04k24qrca0sx5z47dxmtx0swcx2ywxqjt5594gu95rjaeyxrpa2vyylvzxpau5spt2v529me6", - "zs19707gmdvc4hfwg4lgvxg55695gltx3jwye8l2gjekrx4zqz7yr6grq8s8hpfqwggrywx509ln5y", - "zs1xrw8nwla7yrz8l3d7y3rxlhamel2ly4kdmxlc6w4cztxhd6l8wufqv2pcsvtl3d7s6awvjatyx9", - "zs1xymrgyhle6dcvjk5f62k4xygr0vrr2wckqy7sp6wc6cttn29hra77dzhwxst7z9rxqxkz08jd7g", - "zs1x9c8tetxgauxh474hlhnlscuhgzww8vnvxfwm0p8589x73t5yl2fph8q8r8qpl8sh0wfwx0vg62", - "zs1xxcpzsfpyekhvvum3erxjpt34pw3h70ma8vxwecg85tze380f4srlg8zlgxty8yqhutt234nk9q", - "zs1xx6pd3vtj78tg0zpwtc0jjkdxlfy48vegzd6cng4m9w0gtcya8ck7pqgf4l5sxf9ml5zvzru5xg", - "zs1x8qre6x5d8e3tt2m4l9q2tujw8ajun70qelp8tfynyw390rm6vhjtmpf58dmx4hccef9xe50az0", - "zs1x88vjduckqarz2j8tp2me08ya4dgd6pw7j4j98j5jynrze3xy2jjptzye7eftjxd6dn4sj03v7m", - }; - - std::vector SietchShieldedPool2 = { - "zs1ehrs7hetemzsmfz9xwt8xetxag33j3xzj8mhdgywdnvkk4dmtvw6eqys6gm3vr679y865jz7rth", - "zs1ehyr6w0c4mwp0wlp6w5letgm3rjk32rxa9kkkur86e5x8lutr9mwzey0hsesnz0yaarmxra7w2z", - "zs1ec793pjf3anee0qq9ex5u2qygjzk9llmwfygev563l89quc3u8wxvtz9kctlmv2dtjgqwn7krcg", - "zs1eclpgnqy7qll0l5z0gy7m4ew86yjvp397yxyau9y2y43x5mqfdw2sll95l83ux6h8mppzsx3xnp", - "zs1eexedkctuzhjysl00m0j3ekknd32635yd8rejx9ykjp6zz77fyzf5388env642ja2qlg6mrwgsc", - "zs1e77uz8yaj998arp56d0fm4p827wchlf2w09hve6rgkmavhzeyhke8qsk3l7s5k6yh2jwjheqpup", - "zs1elj4qvy42jpts2cu22tcwt0kmwzafpmrjgztwf2xcqaycrlr4rpfxfpswx63e6agvhz96gps9yf", - "zs16q0fzcvf25fh70ysn38v7qkpfspakmelnljgnyrpu7rvllyew57n5cpqjqe0wmy5j57au47j6x8", - "zs16pnkw3mucdef34jjk6q28zd7ghhatdcqn598vs3g70qev234uc5uw6xxxjnzef3pt2t567qev8v", - "zs16rmnl4hd6c226u3v6eekk68y59u0x7v37n8pmytt9xw6drugjml7ryhd243nf3l2pvafw42rnxc", - "zs16ruwvwmetmnnns0rxwtx2kss23da2pccares0tehzw3v3nxd483qn49c9apdfua0hpm8xdecdt4", - "zs16ymafsjd7fp9zdl9vtyvfedecvn7q2vcs7emeglwy7hpuphve97d3j87v2evqs0xm3jrx44nwfe", - "zs1697ggm9zqp4rh0fv4r9hnh9uy6gg4hk7r2lm33tp2we4ry5azpxq6nwuzscha0g2nx03x4sstq8", - "zs168t8u6at9k6kt748dv749dxahnk8rv8yn32z8gcgvc9rkhkewscgu8r8vuzv0zecnq26w9p7x0c", - "zs16gnyx6f8vql24cepamfquhr3jjt7wgmzjcvwtct4lwy9p2studln6ut9kjzf6empwqjtxqmddqy", - "zs1622ra8snywvxufsunk97pccr7k0j32p960evl9yqjadhju22m4sk48md84q5u238gej8xnm4xm5", - "zs162stv8m0udzy4c6ff5kqva2g7pqth2rrdn7rjjgw29dcx7lj3vs4dnj8fz0gczsat3u3q5axgva", - "zs16t78376h9ledgt50k2dmwssuhyy4hn94wfgd8vzegvqy9k9kauuvpe8xz0f3va65l8ufqhgv4gv", - "zs16vxrghgv7mth6k9unzdude9cyt9vl76ms5hm9ce4py92rk69j4p9u570974nh8kqh8e2stqknj5", - "zs1654eafn589g2ujzcasa8caz8exag742tra2dd6mjkp22axh27hda6sy9exh3wkp4c6f5vztafr0", - "zs164u3ntsnn7s3zrp6c5gsqfrwr0ywhspynvunq3fhvr9crwz5eme706j5awwvuatqwh7m2qqkqm9", - "zs16cpqwm4yml5x8j5r3q5j0xljam68pf56xt40hylzn69w45venwdvd4h8drys5t380mspkvt7h8r", - "zs16c6m9aqs0q9kadm4nk6hugmqw6p0lf2h6v5d9ccwszssyecq35sm6284c3uqx2u40da4s2mr2ap", - "zs16u7rc066566j9ux73dcq0m7cq4qdmtd3gefrnhhrpjww3z00j4za7m5mcutmj6qcezkzys87mpp", - "zs1673rm5d5z9sh2k9uc2cvgwk2e44z0sekx6ezt9n4fvgnky5yxa2tc306dw7n2dg5vwfn7ppwr5s", - "zs167nvq5ahvu4s26447rem9j37qglgtle4fghsgpksumkz34g2q9x783pak5jgdhhzylmgs9wemg8", - "zs16lluayez28xevxg0rawxxcd7yx5t7qaraet256sxe8ac69lj7n7ppncsx3m2tddxlzptzyxv0qr", - "zs1mydlmczamey4ydc79n8gj5wtgs79zge4nwhcg8g640r6fvwu6wpt70970p7ptkcrzg6r6frqh0u", - "zs1my6tgqmy3kgdlqncyd5dv9s727x9hcrmj8h06e5whn4hkn5t2x46j84276yd8pw0p6ysx53u38u", - "zs1mte528eue8smvjwpe9cs8qz3wud9735rnk7vrtefu9lhyvh5pyeyenpaq5fa08jpwrl4x7sz069", - "zs1mvmu20syf3u5yzd6hpdd29xfej8237x2k0pcmf7pvra46qem5g0jralrmdcvncgf5j0y5varzr2", - "zs1mw86y6g2c8972a2ndw57648p9qcx2jppxr9g5k24df8hl3rgfzfsfe2xyesemdfmasutk88duht", - "zs1mwca7dqjq0r2mzmn4qarw8acmt4rjk26lyyar35sssqe2fky2nmv3kmf0lfxs2a9htugsadg027", - "zs1m0rpcrkfagzpex9mlw2htyrwpxe48v47pj8zg96l9wm5k8xkj3kev3xca6wumv5avkgsjtygush", - "zs1mjgyju3jnyxjhekv72y448edq3j2cvtk5s4wrej790zzpv3uc20dvewt7nhjdqryuecmykfm0je", - "zs1mjlfwyma3fv45yg50j73wcswnap2s4lsh5c9km6lcem73wky9lej7vy8wrlkr75sy6z2g0agtmw", - "zs1mkh9s9gdfxx4dkug47dqnc98g76dhm09zty779pm6gqc5aye4gvxvduqm5j56nq4lncx5ygqu90", - "zs1mm7tesf30r56l8xmnxjyxvgmnsny2zntsxahllrd930q8ycahz8npdxt7lqwu3k8ljs9sw7uzs8", - "zs1mu34v9wtyhtlr22phfxkp670wt0gj4z8czumx0m4u05elg7kjzu0dzveq5jn28xg5a2wqr6cywd", - "zs1ma3xy4fj0vm0w37a4kur3ghe72f8nstmqmmvh0u48kurtlwg50rqqlw39j6ng8lrxgam2dh0zyr", - "zs1m7yauj7694wjz92m5sxds8udp43z6kclarqwzc22wn2q6svkkk4lpzx53kwctwfn6jqcu4yww5u", - "zs1m77qqksfvuqmjmwdm22xr2u99z3uz4glenk02md4tq5z066gc7jkdayhf2txspqggv29quacpy4", - "zs1uq88d69zrnksytnquejpksdvdlp9e5y3xec3eyf0rrya8zap623zpwjs5mfzadrp7twawkpennl", - "zs1uq0zzag2cmekwn9a35vkf2q45sary5v8nt2adukhej9ydq3qpegskg5naysl3wvvxtzuyv5lu8w", - "zs1uqs3n3j8kfgurz8tj0ea5g2ny200c69rwwpq50kkup8sxntdne6h9uhx3wc2y5jjkcggvpvcl4g", - "zs1uqmnl793xh4cskxjherwlpt7xfnt6fy2sp2l3n58hpmd4msj2g3fjsks02069tqgzzvn77mpfg7", - "zs1uz73f8arfahrvgtxcjwya33ql5w8mwkmyrvxvjrjx5rla07hv3ax49hkeqg3aqynxx39z4y4vtt", - "zs1urzuwedq4qgnqjsjwjeauzyyjwxvs27mau6zmpretn37my92h3jqc0waad4r8s7zeeczq6jfas6", - "zs1urfls60sjxpnla4hhe736qu54w7047akw2p9cksx054y8e8gdyknkhwv6spwzgstf7z2wrsdapw", - "zs1u9jum0rl3959ay3qqxskkak5emv0fpceuhuhcj9rnkzfy6gpe2uv6ny29c399nrc68fx6fffg6c", - "zs1u8fdxg8lu08p6s5z9qe6jf6fkvd74a99yg3n5exlm6wm8paypygy82ue2smf0qqlhdhjzy2jxq4", - "zs1u8u44rlv4ay27248807fqwyf6lw2w76v8evn26nvwv887caqlenjgsw0nqlajzw9equn7phhs95", - "zs1u4jhx25fghqzn2az7he7lrv7xj23xd8spcl660g9kzqa3wyykm5gucuu5wwxvum6l6spq4u4e5s", - "zs1uh85d43vr4wwqnq6e7akxtlwkzx2y8cmdm3wrxzj6m42pzj3xs2heqey79hgxrhwhapwu8tt73g", - "zs1uhwgwkg2y3xex7e34dvnx97d0jdnhmchevcvg54tg4dg00ay9sjucr82py4jqx0kkf7cz5dytad", - "zs1uhkhsv3c3m5r8z7unmceg4zln6edwfr25wjauv5u8fxdqhdflj7vuc2xnkm9028y802w2pyf07g", - "zs1uhuwuzu89j05p9y48nseklu7gfhw4mrwv68f9s66csafrkpsmpsh23zzgxm24nspmsgrvtpttzg", - "zs1ucetuz8ysvz42uvuwndjfnphrtsfgekgef228meuhfrqtm97gql87rsvhxmxplw2xmj27p9jemj", - "zs1ucm95fgyy72rf6x5rwl5m5pldt38lulzqf9ueepel4gvd4cqjhk8xrf4kvl2lnn5ge9fwyfrfva", - "zs1um3pu2u0eu0zpx4czj9dufvxnud2zd0x5lygepp6maz96j572r6mh8gpmlm3w6jhmxxz2sepdfh", - "zs1ulkw8j488xuhhlewedj9dr7atm5jatmlwsxz83lquhz42ln78utqmtqsmhagcquq6uqszk23g9d", - "zs1az03j8f46n2600z47xnf5y28j34rpxljh3j6w5p3xgsmqt2fuklmhyd383aljxf4mx4pcfv0xm8", - "zs1ayal4wq4crwj70u6hae82h6r4jpk7ptycfhs9v5y83lxc7u4gadegu2r5ggsgt95n0rjk284fzj", - "zs1a984wux9sr2594lr24yal43zq6pstczyevj7yr8pn403643zuge88ekrc0cj8n2fk6z6xrxjpsz", - "zs1a95ptq9d6nauwtvgdj2lnct9y6g4cmm258jzyuqhsk4m3gqmaz62t4klqe42eu83n27jcpgz0ed", - "zs1a8xdhdzpjqx0alrjg43enszjnf6nn6nhf6c3xd77ecrvp4kfarvux4u4lcttv3rgyhmgzxukw2q", - "zs1afqnaljmvzunvjhr3m8yf2g4r0pe66kkxkm6ldjhylyjfsclk3nf88u29pskdqx76szdz48tt3m", - "zs1avx0j6mrcqrhp9903xrysptm6gefcyv6uqltta92hsgjpp2f8h8rz8suwxgjkp2f8366y6n6dj8", - "zs1a036amk3q8azryytah2zpdhyazeruq2q7zq2c06l0845kl0v2rmg0h8cdjvta4alxj0my4kcfad", - "zs1ahy2sja2ala03wrc79xx2ks3ujxxnsm44uh6yucmy5p5l0xcfa3g90cdgs4l9rhy975zvd4uzts", - "zs1aeyqta7xs8edzq2c0z6e9v3vjep55e4lg9fp9ls6d55x2mel6snxud6kqcaz8nl7zgrxxj96d6a", - "zs1aap3thj9xna07vlg3yz389c34v9mgd06g234d3htyq667286phjsf98nndm8frts7frmcyjfa90", - "zs17qdqrdgwcafkpgchc4rvk22e4u86alhnmzne5xzantpecwrxf3c6jxqk7xgzanzjj4kmxd2tuwg", - "zs17z3fmn6e84ypzpzn0p0j9nddptrj2nwhk9lhaw952j0lzxslrp24cj0ltuem9g5dustakcq4dsp", - "zs17zut2398dst3hnmnslnk0jv9w4q9yn8akelymvs8ewurdytxushp92nyqv30quqhy0yju7rn7lw", - "zs17r4fuv9ldl3kzwk5stv59exusc7jlsmtcz4t2uzjnrgrr6aj6tvnp04wc9jq2n3eh6fsyqe2ru5", - "zs17rajftxlkcywcenl0cn3fqw4lh2un5lpfegjdz06j3vl9gjmay2d5pk7uequ02vw6tmtzz6jrst", - "zs179rvu8endcr48sft7zg4w6uvxwu4ps94r06uwk7e606yffkgtx7epaamlfdqnc6xa4l9scqcv4v", - "zs178dr2z7zgqrsg5ul3sxx05qky2kemfequf08dxr332n9f5fq9cj98jttssz97lzmf2k22xpn54m", - "zs172zz77ds82urqmsa9pgyz65k04euw7uuk58k4ardcxectjc4t4yjekxm8xxmgd7gqs8k6jupypk", - "zs172eamykp6sl4vx4tsgmg2t0p482hnn3gg4my9y4frd4tl5zgsyrsvjvlxc9zjtqpve6e6djdc4x", - "zs17v4xqdu83fkvrjxrpnjksuanj0pung2kqn9ys533nnm8kq8ad8xv9kd48e4utrz947pejg55p46", - "zs17dgakqvwzgh4dgfe70cjulju698cs50zvchsze2e3zvdp68wytqdcvj4suh4vq2acdg7wuvs7ar", - "zs17snaqr6vukwp4apsdf44h6w3flgphzrnpmdjly662tgqtvkgs72lpz7m7tnkksdmt5uzjgmpg2e", - "zs173ad7l6u8dr90e2t5jkrnw0gc9u2mppv9vjeh8l6q2jdvgnq6tq4anxxltwuxm3wssfzgg6hfcy", - "zs17nez6jn8tnse243f5uf72d8y000ynmjnm6vsrpzpd2fj75wq4u4lu7xc8fmtn2e5v0r7uknphs3", - "zs174c6x8u2yagjnsq2kswnd6fh8u2f3g5dkrk7r7ja5n30zwjm4ke3x84syt9qklqyk0m7vekcx9f", - "zs174mlfm6snsmgj4usez3e6xtd5nkwwl24vgg96srpnv7ulz4de6n4lx6cmxaqszqnk7p9y6wcl8q", - "zs17h5lnrnpprdtkjwq09ax94qetryf65qm5jqv0gpyeesw4wujytks9qljvlry863flf242arvx8f", - "zs1lp07e40usxenrznuuf2nzn5v7tx9pzp9r6eaw6upnm4t9cer8l5fckzm7jr58j5l77tzjrprv8v", - "zs1ly5u5sqeeax9g3uafva7fl35r3wv0nm2aka9m940graqjh0zlw7rrcgay0a7f29j3ar4wrj4uzu", - "zs1lgqckcp2uqx5c6gdm5zklzrxz8ygva9kxtxc4u4dlzpg68m9prga5q3ur3uqutkcy4ztuhclrxw", - "zs1lgz7ychnnhe58hk2e379zhqdxynp30e6fdh6xjxx8u9ga9rmwzdrdvqcq5kps2uetyf6gzeqdn2", - "zs1l2ghymesqwrfw89pqnw08u346es6wn86r77a55n7d7xky2rc58jfhn7man9kjjesnegec3frxeh", - "zs1ls3lyaqhm39zgz3528ereaa48vzsw4cw99k536524a6ruxmdqyvqnv4pl477q7rwptrzx8dhhzu", - "zs1lsnr42d2ez0w55pxws4qn70f68vxllv92wppu24n75y7a0wrmkw6qgup0md5jhjmkwhzu742zx4", - "zs1ljzwlum9nme83hhvkjkxl323u0ezm4sgnk84nzkyu5acum0kxf0s6g06gy78w0hl66f5263g7ha", - "zs1l5kfev0dpl8swjlyvyms5t9yhhnvg0590jfgpxw7zxx6eh29vd7453q9d0ne75x7gsm42j65l3v", - "zs1lhpxmvxmfpdfa5myd35wf24pmacrgdhrcpxydrcwz3qvmfvpt9x78nf2ne3kkqh40m0nvhhd3uj", - "zs1lhkhftvpkvcuyhwgcz4gq9y9l3ly5esglk2g0sgdctrz2cd63lgss2gtn8eedsvtuh8f6shpwww", - }; - //TODO: Assumes pools of 100 - int randIndex = GetRandInt(100); // random int between 0 and 99 - if(randIndex % 2) { - return SietchShieldedPool1[randIndex]; - } else { - return SietchShieldedPool2[randIndex]; - } + auto sk = libzcash::SaplingSpendingKey::random(); + auto expsk = sk.expanded_spending_key(); + auto zdust = sk.default_address(); + return EncodePaymentAddress(zdust); } #endif diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 29b79e02b..c8793b4a8 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -72,7 +72,7 @@ using namespace libzcash; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern std::string ASSETCHAINS_OVERRIDE_PUBKEY; const std::string ADDR_TYPE_SAPLING = "sapling"; -const std::string ADDR_TYPE_DONOTREMEMBER = "donotremember"; +const std::string ADDR_TYPE_AMNESIA = "amnesia"; extern UniValue TxJoinSplitToJSON(const CTransaction& tx); extern int32_t KOMODO_INSYNC; uint32_t komodo_segid32(char *coinaddr); @@ -3895,16 +3895,16 @@ UniValue z_getnewaddress(const UniValue& params, bool fHelp, const CPubKey& mypk throw runtime_error( "z_getnewaddress ( type )\n" "\nReturns a new shielded address for receiving payments.\n" - "\nWith no arguments, returns a Sapling address.\n" - "\nBe very careful with 'donotremember' address type, the extended spending key (xsk) of that address is not stored in wallet.dat!\n" + "\nWith no arguments, returns a Sapling address (zaddr).\n" + "\nBe very careful with 'amnesia' address type, the address is not stored in wallet.dat and if you send funds to it THEY WILL BE LOST FOREVER\n" "\nArguments:\n" - "1. \"type\" (string, optional, default=\"" + defaultType + "\") The type of address. Either "+ ADDR_TYPE_SAPLING + " or " + ADDR_TYPE_DONOTREMEMBER + " .\n" + "1. \"type\" (string, optional, default=\"" + defaultType + "\") The type of address. Either "+ ADDR_TYPE_SAPLING + " or " + ADDR_TYPE_AMNESIA + " .\n" "\nResult:\n" "\"" + strprintf("%s",komodo_chainname()) + "_address\" (string) The new shielded address.\n" "\nExamples:\n" + HelpExampleCli("z_getnewaddress", "") + HelpExampleCli("z_getnewaddress", ADDR_TYPE_SAPLING) - + HelpExampleCli("z_getnewaddress", ADDR_TYPE_DONOTREMEMBER) + + HelpExampleCli("z_getnewaddress", ADDR_TYPE_AMNESIA) ); LOCK2(cs_main, pwalletMain->cs_wallet); @@ -3917,15 +3917,14 @@ UniValue z_getnewaddress(const UniValue& params, bool fHelp, const CPubKey& mypk } if (addrType == ADDR_TYPE_SAPLING) { return EncodePaymentAddress(pwalletMain->GenerateNewSaplingZKey()); - } else if (addrType == ADDR_TYPE_DONOTREMEMBER) { - bool addToWallet = false; - auto zaddr = EncodePaymentAddress(pwalletMain->GenerateNewSaplingZKey(addToWallet)); + } else if (addrType == ADDR_TYPE_AMNESIA) { + auto zaddr = randomSietchZaddr(); if(fZdebug) { - fprintf(stderr,"%s: Sietch zaddr=%s created, xsk not stored in wallet.dat!\n", __FUNCTION__, zaddr.c_str() ); + fprintf(stderr,"%s: Sietch zaddr=%s created, not stored in wallet.dat!\n", __FUNCTION__, zaddr.c_str() ); } return zaddr; } else { - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid address type! Try " + ADDR_TYPE_SAPLING + " or " + ADDR_TYPE_DONOTREMEMBER); + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid address type! Try " + ADDR_TYPE_SAPLING + " or " + ADDR_TYPE_AMNESIA); } } @@ -4758,8 +4757,8 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) int decider = 1 + GetRandInt(100); // random int between 1 and 100 string zdust1, zdust2; - // Which zaddr we send to is non-deterministically chosen from two zpools... - zdust1 = fSietchDynamic ? newSietchZaddr() : randomSietchZaddr(); + // Which zaddr we send to is randomly generated + zdust1 = randomSietchZaddr(); // And their ordering when given to internals is also non-deterministic, which // helps breaks assumptions blockchain analysts may use from z_sendmany internals @@ -4773,7 +4772,7 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) //50% chance of adding another zout if (decider % 2) { - zdust2 = fSietchDynamic ? newSietchZaddr() : randomSietchZaddr(); + zdust2 = randomSietchZaddr(); // 50% chance of adding it to the front or back since all odd numbers are 1 or 3 mod 4 if(decider % 4 == 3) { zaddrRecipients.push_back( newSietchRecipient(zdust2) ); From 5c5e545e75038279fcd8a8f2eeb617f8278aa89d Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 13 Sep 2020 19:12:21 -0400 Subject: [PATCH 198/255] HUSH has no JoinSplits --- src/wallet/rpcwallet.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index c8793b4a8..89d15f14f 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -73,7 +73,6 @@ extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; extern std::string ASSETCHAINS_OVERRIDE_PUBKEY; const std::string ADDR_TYPE_SAPLING = "sapling"; const std::string ADDR_TYPE_AMNESIA = "amnesia"; -extern UniValue TxJoinSplitToJSON(const CTransaction& tx); extern int32_t KOMODO_INSYNC; uint32_t komodo_segid32(char *coinaddr); int32_t komodo_dpowconfs(int32_t height,int32_t numconfs); @@ -170,7 +169,6 @@ void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry) BOOST_FOREACH(const PAIRTYPE(string,string)& item, wtx.mapValue) entry.push_back(Pair(item.first, item.second)); - entry.push_back(Pair("vjoinsplit", TxJoinSplitToJSON(wtx))); } string AccountFromValue(const UniValue& value) From 3f2e814067e1cb90793082a93cc77be8286e8b5b Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 13 Sep 2020 19:15:15 -0400 Subject: [PATCH 199/255] alert system updates --- src/Makefile.am | 2 +- src/sendalert.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 88e33df95..dc66cb4a8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -462,7 +462,7 @@ libbitcoin_server_a_SOURCES += rpc/testtransactions.cpp endif -# cli: zcash-cli +# cli libbitcoin_cli_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) libbitcoin_cli_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) libbitcoin_cli_a_SOURCES = \ diff --git a/src/sendalert.cpp b/src/sendalert.cpp index 7b8ca4589..b626f5b05 100644 --- a/src/sendalert.cpp +++ b/src/sendalert.cpp @@ -1,3 +1,4 @@ +// Copyright (c) 2019-2020 The Hush developers // Copyright (c) 2016 The Zcash developers // Original code from: https://gist.github.com/laanwj/0e689cfa37b52bcbbb44 @@ -74,9 +75,9 @@ void ThreadSendAlert() if (!mapArgs.count("-sendalert") && !mapArgs.count("-printalert")) return; + //TODO: wait until KOMODO_IN_SYNC MilliSleep(60*1000); // Wait a minute so we get connected - // // Alerts are relayed around the network until nRelayUntil, flood // filling to every node. // After the relay time is past, new nodes are told about alerts @@ -87,7 +88,7 @@ void ThreadSendAlert() CAlert alert; alert.nRelayUntil = GetTime() + 15 * 60; alert.nExpiration = GetTime() + 10 * 365 * 24 * 60 * 60; - alert.nID = 1005; // use https://github.com/zcash/zcash/wiki/specification#assigned-numbers to keep track of alert IDs + alert.nID = 1005; // HUSH3 has never had any alert id's alert.nCancel = 1004; // cancels previous messages up to this ID number // These versions are protocol versions @@ -103,12 +104,12 @@ void ThreadSendAlert() // 4000 or higher will put the RPC into safe mode alert.nPriority = 4000; alert.strComment = ""; - alert.strStatusBar = "Your client version has degraded networking behavior. Please update to the most recent version of Hush (3.2.0 or later)."; + alert.strStatusBar = "Your client version has degraded networking behavior. Please update to the most recent version of Hush (3.5.0 or later)."; alert.strRPCError = alert.strStatusBar; // Set specific client version/versions here. If setSubVer is empty, no filtering on subver is done: // alert.setSubVer.insert(std::string("/MagicBean:0.7.2/")); - const std::vector useragents = {}; //{"MagicBean", "BeanStalk", "AppleSeed", "EleosZcash"}; + const std::vector useragents = {}; //{"MagicBean", "BeanStalk", "AppleSeed" }; BOOST_FOREACH(const std::string& useragent, useragents) { } From 5fc4b4c7701f7efe453bae8145d15c12a83dbc70 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 14 Sep 2020 15:14:47 -0400 Subject: [PATCH 200/255] Use the correct interval at z2zheight --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index ff37a4847..4975d24b4 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1258,7 +1258,7 @@ uint64_t hush_commission(int height) }; uint64_t commission = 0; - if( height > HALVING1) { + if( height >= HALVING1) { // Block time going from 150s to 75s (half) means the interval between halvings // must be twice as often, i.e. 840000*2=1680000 // With 150s blocks, we have 210,000 blocks per year From b83f38c615ae43e8469de76c452cb4a0a06101d6 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 14 Sep 2020 15:27:26 -0400 Subject: [PATCH 201/255] komodo_commission logspam --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 4975d24b4..b1870b7c1 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1362,7 +1362,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) } if ( commission < 10000 ) commission = 0; - //fprintf(stderr,"-> %.8f\n",(double)commission/COIN); + fprintf(stderr,"%s: commission=%.8f at height=%d\n",__func__, (double)commission/COIN, height); return(commission); } From 1ae419b54c7220f5aa5028a48860794760034ac3 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 14 Sep 2020 15:34:09 -0400 Subject: [PATCH 202/255] cleanup --- src/main.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c4fb5a26f..2b332593c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2402,13 +2402,8 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,bool checkPOW) return true; } -//uint64_t komodo_moneysupply(int32_t height); - CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams) { - fprintf(stderr,"%s: ht.%d\n", __func__, nHeight); - int32_t numhalvings,i; uint64_t numerator; CAmount nSubsidy = 3 * COIN; - return komodo_ac_block_subsidy(nHeight); } From 65b45d9f8824b12566afd03f8ec08c1e9c31656c Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 14 Sep 2020 15:53:34 -0400 Subject: [PATCH 203/255] mining logspam --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 4ab19638b..edd3a04f4 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -610,7 +610,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 int32_t stakeHeight = chainActive.Height() + 1; - //LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x stake.%i\n", nBlockSize,blocktime,pblock->nBits,isStake); + LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x stake.%i\n", nBlockSize,blocktime,pblock->nBits,isStake); // Create coinbase tx CMutableTransaction txNew = CreateNewContextualCMutableTransaction(consensusParams, nHeight); @@ -621,7 +621,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 txNew.vout.resize(1); txNew.vout[0].scriptPubKey = scriptPubKeyIn; txNew.vout[0].nValue = GetBlockSubsidy(nHeight,consensusParams) + nFees; - //fprintf(stderr,"mine ht.%d with %.8f\n",nHeight,(double)txNew.vout[0].nValue/COIN); + fprintf(stderr,"mine ht.%d with %.8f\n",nHeight,(double)txNew.vout[0].nValue/COIN); txNew.nExpiryHeight = 0; if ( ASSETCHAINS_ADAPTIVEPOW <= 0 ) txNew.nLockTime = std::max(pindexPrev->GetMedianTimePast()+1, GetTime()); From 0920f264be4954fce24986e292a253b15131c3f1 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 14 Sep 2020 15:56:25 -0400 Subject: [PATCH 204/255] cleanup --- src/rpc/mining.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index ab64e8d49..80284108f 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -681,9 +681,6 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp, const CPubKey& myp throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Cannot get a block template while no peers are connected or chain not in sync!"); } - //if (IsInitialBlockDownload()) - // throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Zcash is downloading blocks..."); - static unsigned int nTransactionsUpdatedLast; if (!lpval.isNull()) From c422ec37b7bbe77377ae1366a2d1cb019a14f022 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 15 Sep 2020 10:15:03 -0400 Subject: [PATCH 205/255] Initialize numhalvings and do not print for now, since we dont calculate it here --- src/komodo_utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index f81aaf34e..4f4f45229 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1567,7 +1567,7 @@ uint64_t komodo_ac_block_subsidy(int nHeight) // Find current era, start from beginning reward, and determine current subsidy int64_t numerator, denominator, subsidy = 0; int64_t subsidyDifference; - int32_t numhalvings, curEra = 0, sign = 1; + int32_t numhalvings = 0, curEra = 0, sign = 1; static uint64_t cached_subsidy; static int32_t cached_numhalvings; static int cached_era; bool ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; @@ -1654,7 +1654,7 @@ uint64_t komodo_ac_block_subsidy(int nHeight) else subsidy += ASSETCHAINS_SUPPLY * SATOSHIDEN + magicExtra; } - fprintf(stderr,"%s: ht.%d curEra.%d lastEra.%lu subsidy.%ld numhalvings.%d magicExtra.%u\n",__func__,nHeight,curEra,ASSETCHAINS_LASTERA,subsidy,numhalvings,magicExtra); + fprintf(stderr,"%s: ht.%d curEra.%d lastEra.%lu subsidy.%ld magicExtra.%u\n",__func__,nHeight,curEra,ASSETCHAINS_LASTERA,subsidy,magicExtra); return(subsidy); } From 396488306b68344f11015e940151eb7ae5bc8c73 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 15 Sep 2020 13:09:36 -0400 Subject: [PATCH 206/255] Optional logspam is best logspam --- src/komodo_bitcoind.h | 25 ++++++++++++++++--------- src/komodo_utils.h | 16 ++++++++++------ src/main.cpp | 2 +- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index b1870b7c1..2ee07b6cd 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1298,13 +1298,14 @@ uint64_t hush_commission(int height) fprintf(stderr,"%s: HUSH block reward has gone to zero at height %d!!! It was a good run folks\n", __func__, height); commission = 0; } - fprintf(stderr,"%s: commission=%lu,interval=%d at height %d\n", __func__, commission, INTERVAL, height); + if(fDebug) + fprintf(stderr,"%s: commission=%lu,interval=%d at height %d\n", __func__, commission, INTERVAL, height); return commission; } uint64_t komodo_commission(const CBlock *pblock,int32_t height) { - fprintf(stderr,"%s at height=%d\n",__func__,height); + //fprintf(stderr,"%s at height=%d\n",__func__,height); static bool didinit = false, ishush3 = false; if (!didinit) { @@ -1317,7 +1318,8 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) if ( ASSETCHAINS_FOUNDERS != 0 ) { nSubsidy = GetBlockSubsidy(height,Params().GetConsensus()); - fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); + if(fDebug) + fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); if (ishush3) { @@ -1333,7 +1335,8 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) } else { commission = ASSETCHAINS_FOUNDERS_REWARD; } - fprintf(stderr,"%s: set commission=%lu at height %d with\n",__func__,commission, height); + if(fDebug) + fprintf(stderr,"%s: set commission=%lu at height %d with\n",__func__,commission, height); } else { commission = 0; } @@ -1362,7 +1365,8 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) } if ( commission < 10000 ) commission = 0; - fprintf(stderr,"%s: commission=%.8f at height=%d\n",__func__, (double)commission/COIN, height); + if(fDebug) + fprintf(stderr,"%s: commission=%.8f at height=%d\n",__func__, (double)commission/COIN, height); return(commission); } @@ -2010,21 +2014,22 @@ void GetKomodoEarlytxidScriptPub() int64_t komodo_checkcommission(CBlock *pblock,int32_t height) { - fprintf(stderr,"%s at height=%d\n",__func__,height); + if(fDebug) + fprintf(stderr,"%s at height=%d\n",__func__,height); int64_t checktoshis=0; uint8_t *script,scripthex[8192]; int32_t scriptlen,matched = 0; static bool didinit = false; if ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 ) { checktoshis = komodo_commission(pblock,height); if ( checktoshis >= 10000 && pblock->vtx[0].vout.size() < 2 ) { - fprintf(stderr,"komodo_checkcommission vsize.%d height.%d commission %.8f\n",(int32_t)pblock->vtx[0].vout.size(),height,(double)checktoshis/COIN); + fprintf(stderr,"ERROR: komodo_checkcommission vsize.%d height.%d commission %.8f has checktoshis <10000 or not enough vouts\n",(int32_t)pblock->vtx[0].vout.size(),height,(double)checktoshis/COIN); return(-1); } else if ( checktoshis != 0 ) { script = (uint8_t *)&pblock->vtx[0].vout[1].scriptPubKey[0]; scriptlen = (int32_t)pblock->vtx[0].vout[1].scriptPubKey.size(); - if ( 1 ) + if ( fDebug ) { int32_t i; for (i=0; ivtx[0].vout[1].nValue != checktoshis ) { - fprintf(stderr,"ht.%d checktoshis %.8f vs actual vout[1] %.8f\n",height,dstr(checktoshis),dstr(pblock->vtx[0].vout[1].nValue)); + fprintf(stderr,"ERROR: ht.%d checktoshis %.8f vs actual vout[1] %.8f !!!\n",height,dstr(checktoshis),dstr(pblock->vtx[0].vout[1].nValue)); return(-1); } } } + if(fDebug) + fprintf(stderr,"%s checktoshis=%li at height=%d\n",__func__,checktoshis, height); return(checktoshis); } diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 4f4f45229..e1449c170 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1563,7 +1563,7 @@ uint64_t hush_block_subsidy(int nHeight) // wrapper for more general supply curves of Hush Smart Chains uint64_t komodo_ac_block_subsidy(int nHeight) { - fprintf(stderr,"%s: ht.%d\n", __func__, nHeight); + //fprintf(stderr,"%s: ht.%d\n", __func__, nHeight); // Find current era, start from beginning reward, and determine current subsidy int64_t numerator, denominator, subsidy = 0; int64_t subsidyDifference; @@ -1590,7 +1590,8 @@ uint64_t komodo_ac_block_subsidy(int nHeight) { int64_t nStart = curEra ? ASSETCHAINS_ENDSUBSIDY[curEra - 1] : 0; subsidy = (int64_t)ASSETCHAINS_REWARD[curEra]; - fprintf(stderr,"%s: nStart.%ld subsidy.%ld curEra.%d\n",__func__,nStart,subsidy,curEra); + if(fDebug) + fprintf(stderr,"%s: nStart.%ld subsidy.%ld curEra.%d\n",__func__,nStart,subsidy,curEra); if ( subsidy || (curEra != ASSETCHAINS_LASTERA && ASSETCHAINS_REWARD[curEra + 1] != 0) ) { @@ -1598,7 +1599,8 @@ uint64_t komodo_ac_block_subsidy(int nHeight) { if (ishush3) { subsidy = hush_block_subsidy(nHeight); - fprintf(stderr,"%s: HUSH3 subsidy=%ld at height=%d\n",__func__,subsidy,nHeight); + if(fDebug) + fprintf(stderr,"%s: HUSH3 subsidy=%ld at height=%d\n",__func__,subsidy,nHeight); } else if ( (numhalvings = ((nHeight - nStart) / ASSETCHAINS_HALVING[curEra])) > 0 ) { // The code below is not compatible with HUSH3 mainnet if ( ASSETCHAINS_DECAY[curEra] == 0 ) { @@ -1654,7 +1656,8 @@ uint64_t komodo_ac_block_subsidy(int nHeight) else subsidy += ASSETCHAINS_SUPPLY * SATOSHIDEN + magicExtra; } - fprintf(stderr,"%s: ht.%d curEra.%d lastEra.%lu subsidy.%ld magicExtra.%u\n",__func__,nHeight,curEra,ASSETCHAINS_LASTERA,subsidy,magicExtra); + if(fDebug) + fprintf(stderr,"%s: ht.%d curEra.%d lastEra.%lu subsidy.%ld magicExtra.%u\n",__func__,nHeight,curEra,ASSETCHAINS_LASTERA,subsidy,magicExtra); return(subsidy); } @@ -1822,7 +1825,8 @@ void komodo_args(char *argv0) printf("ASSETCHAINS_LASTERA, if specified, must be between 1 and %u. ASSETCHAINS_LASTERA set to %lu\n", ASSETCHAINS_MAX_ERAS, ASSETCHAINS_LASTERA); } ASSETCHAINS_LASTERA -= 1; - fprintf(stderr,"%s: lastEra=%lu maxEras=%d\n", __func__, ASSETCHAINS_LASTERA, ASSETCHAINS_MAX_ERAS); + if(fDebug) + fprintf(stderr,"%s: lastEra=%lu maxEras=%d\n", __func__, ASSETCHAINS_LASTERA, ASSETCHAINS_MAX_ERAS); ASSETCHAINS_TIMELOCKGTE = (uint64_t)GetArg("-ac_timelockgte", _ASSETCHAINS_TIMELOCKOFF); ASSETCHAINS_TIMEUNLOCKFROM = GetArg("-ac_timeunlockfrom", 0); @@ -1841,7 +1845,7 @@ void komodo_args(char *argv0) bool ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false; if(ishush3) { - fprintf(stderr,"Setting custom HUSH3 chain values...\n"); + fprintf(stderr,"%s: Setting custom HUSH3 reward,halving,subsidy chain values...\n",__func__); // Over-ride HUSH3 values from CLI params. Changing our blocktime to 75s changes things ASSETCHAINS_REWARD[0] = 0; ASSETCHAINS_REWARD[1] = 1125000000; diff --git a/src/main.cpp b/src/main.cpp index 2b332593c..1e13c8ff1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1750,7 +1750,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa // and edge cases. This empty mempool assures there will be no transactions involving taddrs // stuck in the mempool, when the z2z rule takes effect. // Thanks to jl777 for helping design this - fprintf(stderr,"%s: rejecting all tx's during z2z transition window at height=%d\n", __func__,nHeight); + fprintf(stderr,"%s: rejecting all tx's during z2z transition window. Please retry after Block %d !!!\n", __func__,nHeight); return false; } } From 909285b981f88644e8e26777bb1499f1190e644c Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 15 Sep 2020 13:15:11 -0400 Subject: [PATCH 207/255] Where Would I Be Without @DenioD --- src/komodo_bitcoind.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 2ee07b6cd..8aa34e268 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1258,7 +1258,9 @@ uint64_t hush_commission(int height) }; uint64_t commission = 0; - if( height >= HALVING1) { + //TODO: Likely a bug hiding here or at the next halving :) + //if( height >= HALVING1) { + if( height > HALVING1) { // Block time going from 150s to 75s (half) means the interval between halvings // must be twice as often, i.e. 840000*2=1680000 // With 150s blocks, we have 210,000 blocks per year From c5189df0348f3090107d405ec37e18e26039274a Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 15 Sep 2020 13:18:01 -0400 Subject: [PATCH 208/255] A few useful comments in hush_commission() --- src/komodo_bitcoind.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 8aa34e268..e5a5fa06e 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1263,9 +1263,10 @@ uint64_t hush_commission(int height) if( height > HALVING1) { // Block time going from 150s to 75s (half) means the interval between halvings // must be twice as often, i.e. 840000*2=1680000 + // 840000 is 4 years worth of 150s blocks // With 150s blocks, we have 210,000 blocks per year // With 75s blocks, we have 420,000 blocks per year - INTERVAL = GetArg("-ac_halving2",1680000); + INTERVAL = GetArg("-ac_halving2",1680000); // 4 years worth of 75s blocks fprintf(stderr,"%s: height=%d increasing interval to %d\n", __func__, height, INTERVAL); } From 62fc6af52c70710a4d34dc98126d9b62dbdb5462 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 18 Sep 2020 11:47:06 -0400 Subject: [PATCH 209/255] cleanup --- src/komodo_bitcoind.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index e5a5fa06e..cb28cb1df 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -15,12 +15,11 @@ * * ******************************************************************************/ -// komodo functions that interact with bitcoind C++ +// Hush + Komodo functions that interact with bitcoind C++ #include #include #include "consensus/params.h" -//#include "primitives/nonce.h" #include "komodo_defs.h" #include "script/standard.h" #include "cc/CCinclude.h" From 6746d1a46aa26fd02552311ca63ed60345abe4f4 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 18 Sep 2020 12:56:01 -0400 Subject: [PATCH 210/255] Nothing is simple when floats are involved and this is a great example --- contrib/hush_supply | 152 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 125 insertions(+), 27 deletions(-) diff --git a/contrib/hush_supply b/contrib/hush_supply index f7813c64d..8584da0d4 100755 --- a/contrib/hush_supply +++ b/contrib/hush_supply @@ -8,49 +8,147 @@ use strict; # Todo: track FR # Todo: verify FR off-by-one +# Block Reward: Total Coinbase In Block +# Subsidy : Coinbase Earned by Miner +# FR : Founders Reward (10%) +# Block Reward = Subsidy + FR + my $supply = 0.0; my $block = 0; # Block 0 in Hush Smart chains is the BTC genesis block my $puposhis = 100_000_000; -my $reward0 = 1_250_000_000; +my $subsidy0 = 1_250_000_000; my $halvings = 0; my $initial = 6178674 * $puposhis; -my $interval = 1_640_000; # 4 years of 75s blocks +my $interval = 1_680_000; # ~4 years of 75s blocks my $stop = shift || -1; my $totalfr = 0; # total paid out to FR address -my $reward = $reward0; +my $subsidy = [$subsidy0, 31250000, 15625000, 78125000, 39062500, 19531250, 9765625, # these are exact + 4882812, 2441406, 1220703, 610351 ]; # these have deviation from ideal BR # Usage: ./hush_supply &> supply.csv # ./hush_supply HEIGHT &> supply.csv # stop at HEIGHT -printf "# block, supply, reward, fr, totalfr, halvings\n"; +printf "# block, supply, reward, subsidy, fr, totalfr, halvings\n"; + +# Block Reward Amounts in puposhis +# The non-integral amounts cannot be represented exactly +# 12.5 * 100000000 = 1250000000 +# 12.5 * 100000000 / 2 = 625000000 +# 12.5 * 100000000 / 4 = 312500000 +# 12.5 * 100000000 / 8 = 156250000 +# 12.5 * 100000000 / 16 = 78125000 +# 12.5 * 100000000 / 32 = 39062500 +# 12.5 * 100000000 / 64 = 19531250 +# 12.5 * 100000000 / 128 = 9765625 +# 12.5 * 100000000 / 256 = 4882812.5 +# 12.5 * 100000000 / 512 = 2441406.25 +# 12.5 * 100000000 / 1024 = 1220703.125 +# 12.5 * 100000000 / 2048 = 610351.5625 +# 12.5 * 100000000 / 4096 = 305175.78125 +# 12.5 * 100000000 / 8192 = 152587.890625 +# 12.5 * 100000000 / 16384 = 76293.9453125 +# 12.5 * 100000000 / 32768 = 38146.97265625 +# 12.5 * 100000000 / 65536 = 19073.486328125 + + + +# Halving Block Heights +# 340000 + 1680000 = 2020000 +# 340000 + 1680000*2 = 3700000 +# 340000 + 1680000*3 = 5380000 +# 340000 + 1680000*4 = 7060000 +# 340000 + 1680000*5 = 8740000 +# 340000 + 1680000*6 = 10420000 +# 340000 + 1680000*7 = 12100000 +# 340000 + 1680000*8 = 13780000 +# 340000 + 1680000*9 = 15460000 +# 340000 + 1680000*10 = 17140000 +# 340000 + 1680000*11 = 18820000 +# 340000 + 1680000*12 = 20500000 +# 340000 + 1680000*13 = 22180000 +# 340000 + 1680000*14 = 23860000 +# 340000 + 1680000*15 = 25540000 + + +sub hush_block_reward +{ + my $reward = 0; + my $height = shift; + my $halvings = 0; + + # TODO: Cover all halvings until BR=0 + if ($height >= 23860000) { + $reward = 19073; # 0.486328125 deviation + $halvings = 15; + } elsif ($height >= 22180000) { + $reward = 38146; # 0.97265625 deviation + $halvings = 14; + } elsif ($height >= 20500000) { + $reward = 152587; # 0.890625sat deviation + $halvings = 13; + } elsif ($height >= 18820000) { + $reward = 305175; # 0.78125sat deviation + $halvings = 12; + } elsif ($height >= 17140000) { + $reward = 305175; # 0.78125sat deviation + $halvings = 11; + } elsif ($height >= 15460000) { + $reward = 610351; # 0.5625sat deviation + $halvings = 10; + } elsif ($height >= 13780000) { + $reward = 1220703; # 0.125sat deviation + $halvings = 9 + } elsif ($height >= 12100000) { + $reward = 2441406; # 0.25sat deviation + $halvings = 8 + } elsif ($height >= 10420000) { + $reward = 4882812; # 0.5sat deviation + $halvings = 7; + } elsif ($height >= 8740000) { + $reward = 9765625; # last exact reward + $halvings = 6; + } elsif ($height >= 7060000) { + $reward = 19531250; # 0.1953125 HUSH + $halvings = 5; + } elsif ($height >= 5380000) { + $reward = 39062500; # 0.390625 HUSH + $halvings = 4; + } elsif ($height >= 3700000) { + $reward = 78125000; # 0.78125 HUSH + $halvings = 3; + } elsif ($height >= 2020000) { + $reward = 156250000; # 1.5625 HUSH + $halvings = 2; + } elsif ($height >= 340000) { + $reward = 312500000; # 3.125 HUSH + $halvings = 1; + } elsif ($height >= 128) { + $reward = 1250000000; # 12.5 HUSH + } + + return ($reward,$halvings); +} # We know BR will go to zero between 7 and 8th halvings while ($halvings <= 10) { $block++; - my $fr = 0; - # blocks 2-127 of Hush v3 had BR=0 - if ($block == 1) { - $reward = $initial; # airdropped funds from Hush v2 mainnet - } elsif ($block > 1 && $block < 128) { - $reward = 0; # blocks 2-127 have BR=0 - } else { - $fr = 125_000_000; - if ($block < 340_000) { - $reward = $reward0; - } else { - my $shifted = $block - 340_000; - # Past the first halving - $halvings = 1 + int ($shifted / $interval); - if ($shifted % 840_000 == 0) { - $reward >>= 2; - $fr >>= 2; - } - } + my ($reward,$halvings) = hush_block_reward($block); + my $fr = int($reward / 10); + my $subsidy = $reward - $fr; + + if($block == 1) { + # initial airdrop of funds from HUSH v2 network @ Block 500000 + $reward = $initial; + $subsidy= $reward; + $fr = 0; } - $supply += $reward; - $totalfr += $fr; + $supply += $reward; + $totalfr += $fr; - # block, current supply, block reward amount, number of halvings, all amounts are in puposhis - printf "%d,%d,%d,%d,%d,%d\n", $block, $supply, $reward, $fr, $totalfr, $halvings; + # all values in puposhis + # block, current supply, block reward amount, fr, totalfr, number of halvings + printf "%d,%d,%d,%d,%d,%d,%d\n", $block, $supply, $reward, $subsidy, $fr, $totalfr, $halvings; exit(0) if $block == $stop; + exit(0) if ($block > 128 && $reward == 0); + exit(-1) if ($supply >= 21_000_000*$puposhis); } From b277641ca114e153997e1018b3763221a5236d9d Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 18 Sep 2020 13:00:04 -0400 Subject: [PATCH 211/255] Cleanup and cli help --- contrib/hush_supply | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/contrib/hush_supply b/contrib/hush_supply index 8584da0d4..1b4ec43af 100755 --- a/contrib/hush_supply +++ b/contrib/hush_supply @@ -4,14 +4,6 @@ use warnings; use strict; -# Simulate the total supply on Hush v3 mainnet -# Todo: track FR -# Todo: verify FR off-by-one - -# Block Reward: Total Coinbase In Block -# Subsidy : Coinbase Earned by Miner -# FR : Founders Reward (10%) -# Block Reward = Subsidy + FR my $supply = 0.0; my $block = 0; # Block 0 in Hush Smart chains is the BTC genesis block @@ -22,11 +14,22 @@ my $initial = 6178674 * $puposhis; my $interval = 1_680_000; # ~4 years of 75s blocks my $stop = shift || -1; my $totalfr = 0; # total paid out to FR address -my $subsidy = [$subsidy0, 31250000, 15625000, 78125000, 39062500, 19531250, 9765625, # these are exact - 4882812, 2441406, 1220703, 610351 ]; # these have deviation from ideal BR -# Usage: ./hush_supply &> supply.csv -# ./hush_supply HEIGHT &> supply.csv # stop at HEIGHT + +if ($stop eq 'help' or $stop =~ m/-h/) { + die < supply.csv + ./hush_supply HEIGHT &> supply.csv # stop at HEIGHT +# This will generate CSV in the form of: +# block, supply, reward, subsidy, fr, totalfr, halvings +HELP +} + printf "# block, supply, reward, subsidy, fr, totalfr, halvings\n"; From 3e60d1187f1e66f97a8bb563bce613d2ac0d975a Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 18 Sep 2020 13:09:30 -0400 Subject: [PATCH 212/255] Fix logging bug where incorrect number of zins/zouts was shown (block vs tx counts) --- src/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 1e13c8ff1..6bed1c0e4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4789,9 +4789,10 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl nShieldedOutputsInBlock += nShieldedOutputs; nShieldedSpendsInBlock += nShieldedSpends; if (fZdebug) { - fprintf(stderr,"%s: tx=%s has zspends=%d zouts=%d\n", __FUNCTION__, tx.GetHash().ToString().c_str(), nShieldedSpendsInBlock, nShieldedOutputsInBlock ); + fprintf(stderr,"%s: tx=%s has zspends=%d zouts=%d\n", __FUNCTION__, tx.GetHash().ToString().c_str(), nShieldedSpends, nShieldedOutputs ); } } + fprintf(stderr,"%s: block %s has total zspends=%d zouts=%d\n", __FUNCTION__, block.GetHash().ToString().c_str(), nShieldedSpendsInBlock, nShieldedOutputsInBlock ); pindexNew->nSproutValue = sproutValue; pindexNew->nChainSproutValue = boost::none; From 0a96fdc63f9313c7ea198aedad3419cac42db2b7 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 18 Sep 2020 16:19:34 -0400 Subject: [PATCH 213/255] Exactly simulate the Hush block reward until it hits zero at halving 31 --- contrib/hush_supply | 109 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 85 insertions(+), 24 deletions(-) diff --git a/contrib/hush_supply b/contrib/hush_supply index 1b4ec43af..fcf4460dc 100755 --- a/contrib/hush_supply +++ b/contrib/hush_supply @@ -53,24 +53,38 @@ printf "# block, supply, reward, subsidy, fr, totalfr, halvings\n"; # 12.5 * 100000000 / 32768 = 38146.97265625 # 12.5 * 100000000 / 65536 = 19073.486328125 - - -# Halving Block Heights -# 340000 + 1680000 = 2020000 -# 340000 + 1680000*2 = 3700000 -# 340000 + 1680000*3 = 5380000 -# 340000 + 1680000*4 = 7060000 -# 340000 + 1680000*5 = 8740000 -# 340000 + 1680000*6 = 10420000 -# 340000 + 1680000*7 = 12100000 -# 340000 + 1680000*8 = 13780000 -# 340000 + 1680000*9 = 15460000 -# 340000 + 1680000*10 = 17140000 -# 340000 + 1680000*11 = 18820000 -# 340000 + 1680000*12 = 20500000 -# 340000 + 1680000*13 = 22180000 -# 340000 + 1680000*14 = 23860000 -# 340000 + 1680000*15 = 25540000 +# Hush Halving Heights and Block Rewards +# 1,12500000000,340000 +# 2,312500000,2020000 +# 3,156250000,3700000 +# 4,78125000,5380000 +# 5,39062500,7060000 +# 6,19531250,8740000 +# 7,9765625,10420000 +# 8,4882812,12100000 +# 9,2441406,13780000 +# 10,1220703,15460000 +# 11,610351,17140000 +# 12,305175,18820000 +# 13,152587,20500000 +# 14,76293,22180000 +# 15,38146,23860000 +# 16,19073,25540000 +# 17,9536,27220000 +# 18,4768,28900000 +# 19,2384,30580000 +# 20,1192,32260000 +# 21,596,33940000 +# 22,298,35620000 +# 23,149,37300000 +# 24,74,38980000 +# 25,37,40660000 +# 26,18,42340000 +# 27,9,44020000 +# 28,4,45700000 +# 29,2,47380000 +# 30,1,49060000 +# 31,0,50740000 sub hush_block_reward @@ -79,18 +93,65 @@ sub hush_block_reward my $height = shift; my $halvings = 0; - # TODO: Cover all halvings until BR=0 - if ($height >= 23860000) { + if ($height >= 50740000) { + $reward = 0; + $halvings = 31; + } elsif ($height >= 49060000) { + $reward = 1; + $halvings = 30; + } elsif ($height >= 47380000) { + $reward = 1; + $halvings = 29; + } elsif ($height >= 45700000) { + $reward = 2; + $halvings = 28; + } elsif ($height >= 44020000) { + $reward = 4; + $halvings = 27; + } elsif ($height >= 42340000) { + $reward = 9; + $halvings = 26; + } elsif ($height >= 40660000) { + $reward = 18; + $halvings = 25; + } elsif ($height >= 38980000) { + $reward = 37; + $halvings = 24; + } elsif ($height >= 37380000) { + $reward = 74; + $halvings = 23; + } elsif ($height >= 35620000) { + $reward = 149; + $halvings = 22; + } elsif ($height >= 33940000) { + $reward = 298; + $halvings = 21; + } elsif ($height >= 32260001) { + $reward = 596; + $halvings = 20; + } elsif ($height >= 30580000) { + $reward = 1192; + $halvings = 19; + } elsif ($height >= 28900000) { + $reward = 2384; + $halvings = 18; + } elsif ($height >= 27220000) { + $reward = 4768; + $halvings = 17; + } elsif ($height >= 25540000) { + $reward = 9536; + $halvings = 16; + } elsif ($height >= 23860000) { $reward = 19073; # 0.486328125 deviation $halvings = 15; } elsif ($height >= 22180000) { $reward = 38146; # 0.97265625 deviation $halvings = 14; } elsif ($height >= 20500000) { - $reward = 152587; # 0.890625sat deviation + $reward = 76293; # 0.9453125 deviation $halvings = 13; } elsif ($height >= 18820000) { - $reward = 305175; # 0.78125sat deviation + $reward = 152587; # 0.890625 deviation $halvings = 12; } elsif ($height >= 17140000) { $reward = 305175; # 0.78125sat deviation @@ -132,8 +193,8 @@ sub hush_block_reward return ($reward,$halvings); } -# We know BR will go to zero between 7 and 8th halvings -while ($halvings <= 10) { +# Block reward is 0 at the 31st halving +while ($halvings <= 30) { $block++; my ($reward,$halvings) = hush_block_reward($block); my $fr = int($reward / 10); From d65fbabc778f1b4a51e0e04588c27e58e9c6b219 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 18 Sep 2020 16:34:36 -0400 Subject: [PATCH 214/255] Correctly specify the exact block height when Hush block reward goes to zero --- src/komodo_bitcoind.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index cb28cb1df..e8eadbd09 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1245,10 +1245,9 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); // Here Be Dragons! -- Duke Leto uint64_t hush_commission(int height) { - // TODO: Calculate new BR_END based on 75s block time!!! 2X old BR_END is a rough estimate, not exact! + // BR_END is the 31st halving int32_t starting_commission = 125000000, HALVING1 = GetArg("-z2zheight",340000), - INTERVAL = GetArg("-ac_halving1",840000), TRANSITION = 129, BR_END = 2*5422111; - // TODO: how many halvings will we have given new 75s blocktime? + INTERVAL = GetArg("-ac_halving1",840000), TRANSITION = 129, BR_END = 50740000; int32_t commisions[] = {starting_commission, 31250000, 15625000, 78125000, 39062500, 19531250, 9765625, // these are exact 4882812, 2441406, 1220703, 610351 // these have deviation from ideal BR // Just like BTC, BRs in the far future will be slightly less than @@ -1294,9 +1293,9 @@ uint64_t hush_commission(int height) commission = commisions[8]; } // Explicitly set the last block reward - // BR_END is the block with the last non-zero block reward, which overrides + // BR_END is the block with first zero block reward, which overrides // the -ac_end param on HUSH3 - if(height > BR_END) { + if(height >= BR_END) { fprintf(stderr,"%s: HUSH block reward has gone to zero at height %d!!! It was a good run folks\n", __func__, height); commission = 0; } From 70455eb41e3f2fb5b62c06276b95879f84648290 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 18 Sep 2020 16:41:28 -0400 Subject: [PATCH 215/255] update version --- src/clientversion.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/clientversion.h b/src/clientversion.h index fea7d0b05..ed24867a1 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -35,7 +35,7 @@ #define CLIENT_VERSION_MAJOR 3 #define CLIENT_VERSION_MINOR 5 #define CLIENT_VERSION_REVISION 0 -#define CLIENT_VERSION_BUILD 5 +#define CLIENT_VERSION_BUILD 50 //! Set to true for release, false for prerelease or test build #define CLIENT_VERSION_IS_RELEASE true From 5adfbf80ee6dbb77d4dce6f0ae0517ce29d5554d Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 18 Sep 2020 16:42:14 -0400 Subject: [PATCH 216/255] Bump protocol version since this is a mandatory consensus change, in the future we can make this a minimum protocol version --- src/version.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/version.h b/src/version.h index 4056f105d..5cf912492 100644 --- a/src/version.h +++ b/src/version.h @@ -1,6 +1,7 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -24,7 +25,7 @@ * network protocol versioning */ -static const int PROTOCOL_VERSION = 170008; +static const int PROTOCOL_VERSION = 170009; //! initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; From fab0f9494230e8b982445f3facb29601ee79da22 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 18 Sep 2020 16:49:42 -0400 Subject: [PATCH 217/255] Cleanup and update copyrights --- src/addressindex.h | 3 ++- src/alert.h | 1 + src/alertkeys.h | 3 ++- src/arith_uint256.h | 1 + src/asyncrpcoperation.h | 1 + src/asyncrpcqueue.h | 1 + src/coincontrol.h | 1 + src/init.h | 4 +--- src/komodo.h | 1 + src/miner.h | 1 + 10 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/addressindex.h b/src/addressindex.h index 643f06e13..d22426ed6 100644 --- a/src/addressindex.h +++ b/src/addressindex.h @@ -1,5 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2015 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -79,4 +80,4 @@ struct CMempoolAddressDeltaKeyCompare } }; -#endif // BITCOIN_ADDRESSINDEX_H \ No newline at end of file +#endif // BITCOIN_ADDRESSINDEX_H diff --git a/src/alert.h b/src/alert.h index 16204c9c5..d8d762b00 100644 --- a/src/alert.h +++ b/src/alert.h @@ -1,5 +1,6 @@ // Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/alertkeys.h b/src/alertkeys.h index 106576add..1c4bcbc2c 100644 --- a/src/alertkeys.h +++ b/src/alertkeys.h @@ -1,3 +1,4 @@ +// Copyright (c) 2019-2020 The Hush developers /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * @@ -16,7 +17,7 @@ #ifndef BITCOIN_ALERTKEYS_H #define BITCOIN_ALERTKEYS_H -// REMINDER: DO NOT COMMIT YOUR PRIVATE KEYS TO THE GIT REPOSITORY! +// REMINDER: DO NOT COMMIT YOUR PRIVATE KEYS TO THE GIT REPOSITORY, lulz const char* pszPrivKey = "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; const char* pszTestNetPrivKey = "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; diff --git a/src/arith_uint256.h b/src/arith_uint256.h index b51f82f14..f7bc8a585 100644 --- a/src/arith_uint256.h +++ b/src/arith_uint256.h @@ -1,5 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/asyncrpcoperation.h b/src/asyncrpcoperation.h index 3fe966977..5dc102366 100644 --- a/src/asyncrpcoperation.h +++ b/src/asyncrpcoperation.h @@ -1,4 +1,5 @@ // Copyright (c) 2016 The Zcash developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/asyncrpcqueue.h b/src/asyncrpcqueue.h index 0d228564f..32e091aff 100644 --- a/src/asyncrpcqueue.h +++ b/src/asyncrpcqueue.h @@ -1,4 +1,5 @@ // Copyright (c) 2016 The Zcash developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/coincontrol.h b/src/coincontrol.h index 02d487a4c..2daa95919 100644 --- a/src/coincontrol.h +++ b/src/coincontrol.h @@ -1,4 +1,5 @@ // Copyright (c) 2011-2013 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/init.h b/src/init.h index c68d59419..0d8145a41 100644 --- a/src/init.h +++ b/src/init.h @@ -1,5 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -23,8 +24,6 @@ #include -//#include "zcash/JoinSplit.hpp" - class CScheduler; class CWallet; @@ -34,7 +33,6 @@ class thread_group; } // namespace boost extern CWallet* pwalletMain; -//extern ZCJoinSplit* pzcashParams; void StartShutdown(); bool ShutdownRequested(); diff --git a/src/komodo.h b/src/komodo.h index 9816eb20b..1cfbd283b 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -1,3 +1,4 @@ +// Copyright (c) 2019-2020 The Hush developers /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * diff --git a/src/miner.h b/src/miner.h index a3bedd292..c42c2ad54 100644 --- a/src/miner.h +++ b/src/miner.h @@ -1,5 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. From 794c32143c54a681386db17f717197600cd58245 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 18 Sep 2020 16:59:15 -0400 Subject: [PATCH 218/255] Staked notaries are not supported on Hush smart chains --- src/notaries_staked.cpp | 97 +---------------------------------------- 1 file changed, 1 insertion(+), 96 deletions(-) diff --git a/src/notaries_staked.cpp b/src/notaries_staked.cpp index db1696ed5..6bc458078 100644 --- a/src/notaries_staked.cpp +++ b/src/notaries_staked.cpp @@ -9,125 +9,30 @@ extern pthread_mutex_t staked_mutex; int8_t is_STAKED(const char *chain_name) { - static int8_t STAKED,doneinit; - if ( chain_name[0] == 0 ) - return(0); - if (doneinit == 1 && ASSETCHAINS_SYMBOL[0] != 0) - return(STAKED); - else STAKED = 0; - if ( (strcmp(chain_name, "LABS") == 0) ) - STAKED = 1; // These chains are allowed coin emissions. - else if ( (strncmp(chain_name, "LABS", 4) == 0) ) - STAKED = 2; // These chains have no coin emission, block subsidy is always 0, and comission is 0. Notary pay is allowed. - else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) ) - STAKED = 3; // These chains have no speical rules at all. - else if ( (strcmp(chain_name, "TEST") == 0) || (strncmp(chain_name, "TEST", 4) == 0) ) - STAKED = 4; // These chains are for testing consensus to create a chain etc. Not meant to be actually used for anything important. - else if ( (strcmp(chain_name, "THIS_CHAIN_IS_BANNED") == 0) ) - STAKED = 255; // Any chain added to this group is banned, no notarisations are valid, as a consensus rule. Can be used to remove a chain from cluster if needed. - doneinit = 1; + static int8_t STAKED=0; return(STAKED); }; int32_t STAKED_era(int timestamp) { - int8_t era = 0; - if (timestamp <= STAKED_NOTARIES_TIMESTAMP[0]) - return(1); - for (int32_t i = 1; i < NUM_STAKED_ERAS; i++) - { - if (timestamp <= STAKED_NOTARIES_TIMESTAMP[i] && timestamp >= (STAKED_NOTARIES_TIMESTAMP[i-1] + STAKED_ERA_GAP)) - return(i+1); - } - // if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP. return(0); }; int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) { - if ( STAKED_ERA != 0 ) - { - for (int8_t i = 0; i < num_notaries_STAKED[STAKED_ERA-1]; i++) { - if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) { - notaryname.assign(notaries_STAKED[STAKED_ERA-1][i][0]); - return(i); - } - } - } return(-1); } int8_t numStakedNotaries(uint8_t pubkeys[64][33],int8_t era) { int i; int8_t retval = 0; - static uint8_t staked_pubkeys[NUM_STAKED_ERAS][64][33],didinit[NUM_STAKED_ERAS]; - static char ChainName[65]; - - if ( ChainName[0] == 0 ) - { - if ( ASSETCHAINS_SYMBOL[0] == 0 ) - strcpy(ChainName,"KMD"); - else - strcpy(ChainName,ASSETCHAINS_SYMBOL); - } - - if ( era == 0 ) - { - // era is zero so we need to null out the pubkeys. - memset(pubkeys,0,64 * 33); - printf("%s is a STAKED chain and is in an ERA GAP.\n",ChainName); - return(64); - } - else - { - if ( didinit[era-1] == 0 ) - { - for (i=0; i Date: Fri, 18 Sep 2020 17:01:15 -0400 Subject: [PATCH 219/255] Update manpages --- doc/man/hush-cli.1 | 6 +++--- doc/man/hush-tx.1 | 6 +++--- doc/man/hushd.1 | 14 ++++++++++---- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/doc/man/hush-cli.1 b/doc/man/hush-cli.1 index 3e1ca3616..d091ac49f 100644 --- a/doc/man/hush-cli.1 +++ b/doc/man/hush-cli.1 @@ -1,9 +1,9 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.10. -.TH HUSH-CLI "1" "July 2020" "hush-cli v3.5.0" "User Commands" +.TH HUSH-CLI "1" "September 2020" "hush-cli v3.5.0" "User Commands" .SH NAME hush-cli \- manual page for hush-cli v3.5.0 .SH DESCRIPTION -Komodo RPC client version v3.5.0\-beta6\-a59803c32\-dirty +Komodo RPC client version v3.5.0\-beta6\-fab0f9494\-dirty .PP In order to ensure you are adequately protecting your privacy when using Hush, please see . @@ -71,7 +71,7 @@ Timeout in seconds during HTTP requests, or 0 for no timeout. (default: Read extra arguments from standard input, one per line until EOF/Ctrl\-D (recommended for sensitive information such as passphrases) .SH COPYRIGHT -Hush Daemon version v3.5.0-beta6-a59803c32-dirty +Hush Daemon version v3.5.0-beta6-fab0f9494-dirty In order to ensure you are adequately protecting your privacy when using Hush, please see . diff --git a/doc/man/hush-tx.1 b/doc/man/hush-tx.1 index fa3162fda..99212c29b 100644 --- a/doc/man/hush-tx.1 +++ b/doc/man/hush-tx.1 @@ -1,9 +1,9 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.10. -.TH HUSH-TX "1" "July 2020" "hush-tx v3.5.0" "User Commands" +.TH HUSH-TX "1" "September 2020" "hush-tx v3.5.0" "User Commands" .SH NAME hush-tx \- manual page for hush-tx v3.5.0 .SH DESCRIPTION -Hush komodo\-tx utility version v3.5.0\-beta6\-a59803c32\-dirty +Hush komodo\-tx utility version v3.5.0\-beta6\-fab0f9494\-dirty .SS "Usage:" .TP komodo\-tx [options] [commands] @@ -84,7 +84,7 @@ set=NAME:JSON\-STRING .IP Set register NAME to given JSON\-STRING .SH COPYRIGHT -Hush Daemon version v3.5.0-beta6-a59803c32-dirty +Hush Daemon version v3.5.0-beta6-fab0f9494-dirty In order to ensure you are adequately protecting your privacy when using Hush, please see . diff --git a/doc/man/hushd.1 b/doc/man/hushd.1 index 370986f0f..1d4d70cc3 100644 --- a/doc/man/hushd.1 +++ b/doc/man/hushd.1 @@ -1,10 +1,10 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.10. -.TH HUSHD "1" "July 2020" "hushd v3.5.0" "User Commands" +.TH HUSHD "1" "September 2020" "hushd v3.5.0" "User Commands" .SH NAME hushd \- manual page for hushd v3.5.0 .SH DESCRIPTION Found binary: ./komodod -Hush Daemon version v3.5.0\-beta6\-a59803c32\-dirty +Hush Daemon version v3.5.0\-beta6\-fab0f9494\-dirty .PP In order to ensure you are adequately protecting your privacy when using Hush, please see . @@ -114,6 +114,11 @@ Create new files with system default permissions, instead of umask 077 Maintain a full transaction index, used by the getrawtransaction rpc call (default: 0) .HP +\fB\-txsend=\fR +.IP +Execute command to send a transaction instead of broadcasting (%s in cmd +is replaced by transaction hex) +.HP \fB\-addressindex\fR .IP Maintain a full address index, used to query for the balance, txids and @@ -346,7 +351,8 @@ Upgrade wallet to latest format on startup .HP \fB\-wallet=\fR .IP -Specify wallet file (within data directory) (default: wallet.dat) +Specify wallet file absolute path or a path relative to the data +directory (default: wallet.dat) .HP \fB\-walletbroadcast\fR .IP @@ -639,7 +645,7 @@ Starting supply, default is 0 .IP Enforce transaction\-rate limit, default 0 .SH COPYRIGHT -Hush Daemon version v3.5.0-beta6-a59803c32-dirty +Hush Daemon version v3.5.0-beta6-fab0f9494-dirty In order to ensure you are adequately protecting your privacy when using Hush, please see . From 2ea974a402cdd80357145ccecaf1197faeba7825 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 18 Sep 2020 17:15:51 -0400 Subject: [PATCH 220/255] Update comments --- src/komodo_bitcoind.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index e8eadbd09..69d4859af 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1261,10 +1261,10 @@ uint64_t hush_commission(int height) if( height > HALVING1) { // Block time going from 150s to 75s (half) means the interval between halvings // must be twice as often, i.e. 840000*2=1680000 - // 840000 is 4 years worth of 150s blocks + // 840000 is ~4 years worth of 150s blocks // With 150s blocks, we have 210,000 blocks per year // With 75s blocks, we have 420,000 blocks per year - INTERVAL = GetArg("-ac_halving2",1680000); // 4 years worth of 75s blocks + INTERVAL = GetArg("-ac_halving2",1680000); // ~4 years worth of 75s blocks fprintf(stderr,"%s: height=%d increasing interval to %d\n", __func__, height, INTERVAL); } @@ -1286,10 +1286,8 @@ uint64_t hush_commission(int height) } else if (height < HALVING1+6*INTERVAL) { // before 7th Halving @ Block 10420000 commission = commisions[6]; } else if (height < HALVING1+7*INTERVAL) { // before 8th Halving @ Block 12100000 - // TODO: Still true??? Block reward will go to zero between 7th+8th halvings, ac_end may need adjusting commission = commisions[7]; } else if (height < HALVING1+8*INTERVAL) { // before 9th Halving @ Block 13780000 - // BR should be zero before this halving happens commission = commisions[8]; } // Explicitly set the last block reward From 599c8420965f5f9e7f2fe2235baeddc16f714562 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 18 Sep 2020 17:50:04 -0400 Subject: [PATCH 221/255] WIP full supply curve --- src/komodo_bitcoind.h | 122 +++++++++++++++++++++++++++++++++--------- src/komodo_utils.h | 13 +++-- 2 files changed, 103 insertions(+), 32 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 69d4859af..c7aad1778 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1248,12 +1248,6 @@ uint64_t hush_commission(int height) // BR_END is the 31st halving int32_t starting_commission = 125000000, HALVING1 = GetArg("-z2zheight",340000), INTERVAL = GetArg("-ac_halving1",840000), TRANSITION = 129, BR_END = 50740000; - int32_t commisions[] = {starting_commission, 31250000, 15625000, 78125000, 39062500, 19531250, 9765625, // these are exact - 4882812, 2441406, 1220703, 610351 // these have deviation from ideal BR - // Just like BTC, BRs in the far future will be slightly less than - // they should be because exact values are not integers, causing - // slightly less coins to be actually mined - }; uint64_t commission = 0; //TODO: Likely a bug hiding here or at the next halving :) @@ -1267,29 +1261,107 @@ uint64_t hush_commission(int height) INTERVAL = GetArg("-ac_halving2",1680000); // ~4 years worth of 75s blocks fprintf(stderr,"%s: height=%d increasing interval to %d\n", __func__, height, INTERVAL); } +/* +0,1250000000,1125000000,125000000 +1,312500000,281250000,31250000 +2,156250000,140625000,15625000 +3,78125000,70312500,7812500 +4,39062500,35156250,3906250 +5,19531250,17578125,1953125 +6,9765625,8789062,976562 +7,4882812,4394531,488281 +8,2441406,2197265,244140 +9,1220703,1098632,122070 +10,610351,549316,61035 +11,305175,274658,30517 +12,152587,137329,15258 +13,76293,68664,7629 +14,38146,34332,3814 +15,19073,17166,1907 +16,9536,8583,953 +17,4768,4291,476 +18,2384,2145,238 +19,1192,1072,119 +20,596,536,59 +21,298,268,29 +22,149,134,14 +23,74,67,7 +24,37,33,3 +25,18,16,1 +*/ + - // Transition period of 128 blocks has BR=FR=0 if (height < TRANSITION) { commission = 0; - } else if (height < HALVING1) { // before 1st Halving @ Block 340000 (Nov 2020) - commission = commisions[0]; - } else if (height < HALVING1+1*INTERVAL) { // before 2nd Halving @ Block 2020000 - commission = commisions[1]; - } else if (height < HALVING1+2*INTERVAL) { // before 3rd Halving @ Block 3700000 - commission = commisions[2]; - } else if (height < HALVING1+3*INTERVAL) { // before 4th Halving @ Block 5380000 - commission = commisions[3]; - } else if (height < HALVING1+4*INTERVAL) { // before 5th Halving @ Block 7060000 - commission = commisions[4]; - } else if (height < HALVING1+5*INTERVAL) { // before 6th Halving @ Block 8740000 - commission = commisions[5]; - } else if (height < HALVING1+6*INTERVAL) { // before 7th Halving @ Block 10420000 - commission = commisions[6]; - } else if (height < HALVING1+7*INTERVAL) { // before 8th Halving @ Block 12100000 - commission = commisions[7]; - } else if (height < HALVING1+8*INTERVAL) { // before 9th Halving @ Block 13780000 - commission = commisions[8]; + } else { + // Just like BTC, BRs in the far future will be slightly less than + // they should be because exact values are not integers, causing + // slightly less coins to be actually mined + if (height < HALVING1) { // before 1st Halving @ Block 340000 (Nov 2020) + commission = starting_commission; + } else if (height < 2020000 ) { + commission = 312500000; + } else if (height < 3700000 ) { + commission = 156250000; + } else if (height < 5380000 ) { + commission = 78125000; + } else if (height < 7060000 ) { + commission = 39062500; + } else if (height < 8740000 ) { + commission = 19531250; + } else if (height < 10420000) { + commission = 9765625; + } else if (height < 12100000) { + commission = 488281; + } else if (height < 15460000) { + commission = 244140; + } else if (height < 17140000) { + commission = 122070; + } else if (height < 18820000) { + commission = 61035; + } else if (height < 23860000) { + commission = 30517; + } else if (height < 23860000) { + commission = 15258; + } else if (height < 25540000) { + commission = 7629; + } else if (height < 27220000) { + commission = 3814; + } else if (height < 27220000) { + commission = 1907; + } else if (height < 28900000) { + commission = 953; + } else if (height < 30580000) { + commission = 476; + } else if (height < 32260000) { + commission = 238; + } else if (height < 33940000) { + commission = 119; + } else if (height < 35620000) { + commission = 59; + } else if (height < 37300000) { + commission = 29; + } else if (height < 38980000) { + commission = 14; + } else if (height < 40660000) { + commission = 7; + } else if (height < 42340000) { + commission = 3; + } else if (height < 44020000) { + commission = 1; + } else if (height < 45700000) { + commission = 0; + } else if (height < 47380000) { + commission = 0; + } else if (height < 49060000) { + commission = 0; + } else if (height < 50740000) { + commission = 0; + } else { + commission = 0; + } } + // Explicitly set the last block reward // BR_END is the block with first zero block reward, which overrides // the -ac_end param on HUSH3 diff --git a/src/komodo_utils.h b/src/komodo_utils.h index e1449c170..392875dbc 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1543,18 +1543,17 @@ uint64_t komodo_max_money() // This implements the Hush Emission Curve -uint64_t hush_block_subsidy(int nHeight) +uint64_t hush_block_subsidy(int height) { uint64_t subsidy=0; //TODO: Cover all halvings until BR=0 - //if (nHeight >= 3700000) { - // subsidy = ASSETCHAINS_REWARD[4]; - //} else - if (nHeight >= 2020000) { + if (nHeight >= 3700000) { + subsidy = -1; + } else if (height >= 2020000) { subsidy = 140625000; - } else if (nHeight >= GetArg("-z2zheight",340000)) { + } else if (height >= GetArg("-z2zheight",340000)) { subsidy = 281250000; - } else if (nHeight >= 128) { + } else if (height >= 128) { subsidy = 1125000000; } return subsidy; From 65da80de5860ef56f18ba2a8b7e47e1357114e01 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 19 Sep 2020 11:03:35 -0400 Subject: [PATCH 222/255] Implement entire Hush block subsidy schedule We now have our halving schedule implemented until the BR goes to zero. The data was calculated via two new scripts which are in ./contrib : $ ./contrib/hush_halvings 1,12500000000,340000 2,312500000,2020000 3,156250000,3700000 4,78125000,5380000 5,39062500,7060000 6,19531250,8740000 7,9765625,10420000 8,4882812,12100000 9,2441406,13780000 10,1220703,15460000 11,610351,17140000 12,305175,18820000 13,152587,20500000 14,76293,22180000 15,38146,23860000 16,19073,25540000 17,9536,27220000 18,4768,28900000 19,2384,30580000 20,1192,32260000 21,596,33940000 22,298,35620000 23,149,37300000 24,74,38980000 25,37,40660000 26,18,42340000 27,9,44020000 28,4,45700000 29,2,47380000 30,1,49060000 31,0,50740000 32,0,52420000 33,0,54100000 $ ./contrib/hush_block_subsidy_per_halving 0,1250000000,1125000000,125000000 1,625000000,562500000,62500000 2,312500000,281250000,31250000 3,156250000,140625000,15625000 4,78125000,70312500,7812500 5,39062500,35156250,3906250 6,19531250,17578125,1953125 7,9765625,8789062,976562 8,4882812,4394531,488281 9,2441406,2197265,244140 10,1220703,1098632,122070 11,610351,549316,61035 12,305175,274658,30517 13,152587,137329,15258 14,76293,68664,7629 15,38146,34332,3814 16,19073,17166,1907 17,9536,8583,953 18,4768,4291,476 19,2384,2145,238 20,1192,1072,119 21,596,536,59 22,298,268,29 23,149,134,14 24,74,67,7 25,37,33,3 26,18,16,1 27,9,8,0 28,4,4,0 29,2,2,0 30,1,1,0 31,0,0,0 These show that the block subsidy for miners goes to 0 at the 31st halving and that the Founders Reward AKA Dev Tax goes to 0 at the 27th halving. There is also some current KMD internals code that we inherited that prevents the FR from being less than 10000, so that code would currently set our FR to 0 at the 14th halving and lead less HUSH being mined than the planned 21M and even a bit less than the amount under 21M that normally happens, such as in BTC. We have some time to deal with the bug, since halving 14 is in about 52 years. --- contrib/hush_block_subsidy_per_halving | 17 +++++ contrib/hush_halvings | 22 ++++++ src/komodo_bitcoind.h | 60 +++++----------- src/komodo_utils.h | 94 +++++++++++++++++++++++--- 4 files changed, 138 insertions(+), 55 deletions(-) create mode 100755 contrib/hush_block_subsidy_per_halving create mode 100755 contrib/hush_halvings diff --git a/contrib/hush_block_subsidy_per_halving b/contrib/hush_block_subsidy_per_halving new file mode 100755 index 000000000..7e7b05b4b --- /dev/null +++ b/contrib/hush_block_subsidy_per_halving @@ -0,0 +1,17 @@ +#!/usr/bin/env perl +# Copyright 2019-2020 The Hush developers +# Released under the GPLv3 + +use strict; +use warnings; + +my $x = 12.5 * 100000000; +my $n = 0; +while ($n<=31) { + #printf "$n,%.16g,%.16g,%.16g\n", $x, $x*0.90, $x*0.1; + printf "$n,%d,%d,%d\n", $x, $x*0.90, $x*0.1; + $x = $x / 2; + $n++; + exit if ($x <= 0); +} + diff --git a/contrib/hush_halvings b/contrib/hush_halvings new file mode 100755 index 000000000..67246bb13 --- /dev/null +++ b/contrib/hush_halvings @@ -0,0 +1,22 @@ +#!/usr/bin/env perl +# Copyright 2019-2020 The Hush developers +# Released under the GPLv3 + +use strict; +use warnings; + +my $x = 340_000; +my $n = 0; +my $r = 12_500_000_000; +while ($n<=32) { + printf "%d,%d,%d\n", $n+1, $r, $x + 1680000*$n; + # blocktime halving at block 340000 + if ($n==0) { + $r = 3.125 * 100_000_000; + } else { + $r /= 2; + } + + $n++; +} + diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index c7aad1778..76e075bd6 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1241,7 +1241,8 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); // You specify the BR, and the FR % gets added so 10% of 12.5 is 1.25 // but to tell the AC params, I need to say "11% of 11.25" is 1.25 // 11% ie. 1/9th cannot be exactly represented and so the FR has tiny amounts of error unless done manually -// Do not change this code unless you really know what you are doing. +// This must be kept in sync with hush_block_subsidy() in komoto_utils.h! +// Changing these functions are consensus changes! // Here Be Dragons! -- Duke Leto uint64_t hush_commission(int height) { @@ -1261,56 +1262,28 @@ uint64_t hush_commission(int height) INTERVAL = GetArg("-ac_halving2",1680000); // ~4 years worth of 75s blocks fprintf(stderr,"%s: height=%d increasing interval to %d\n", __func__, height, INTERVAL); } -/* -0,1250000000,1125000000,125000000 -1,312500000,281250000,31250000 -2,156250000,140625000,15625000 -3,78125000,70312500,7812500 -4,39062500,35156250,3906250 -5,19531250,17578125,1953125 -6,9765625,8789062,976562 -7,4882812,4394531,488281 -8,2441406,2197265,244140 -9,1220703,1098632,122070 -10,610351,549316,61035 -11,305175,274658,30517 -12,152587,137329,15258 -13,76293,68664,7629 -14,38146,34332,3814 -15,19073,17166,1907 -16,9536,8583,953 -17,4768,4291,476 -18,2384,2145,238 -19,1192,1072,119 -20,596,536,59 -21,298,268,29 -22,149,134,14 -23,74,67,7 -24,37,33,3 -25,18,16,1 -*/ - if (height < TRANSITION) { commission = 0; } else { // Just like BTC, BRs in the far future will be slightly less than // they should be because exact values are not integers, causing - // slightly less coins to be actually mined + // slightly less coins to be actually mined and small deviations + // to the ideal FR/devtax if (height < HALVING1) { // before 1st Halving @ Block 340000 (Nov 2020) commission = starting_commission; } else if (height < 2020000 ) { - commission = 312500000; + commission = 31250000; } else if (height < 3700000 ) { - commission = 156250000; + commission = 15625000; } else if (height < 5380000 ) { - commission = 78125000; + commission = 7812500; } else if (height < 7060000 ) { - commission = 39062500; + commission = 3906250; } else if (height < 8740000 ) { - commission = 19531250; + commission = 1953125; } else if (height < 10420000) { - commission = 9765625; + commission = 976562; // 0.5 puposhi deviation, all further BRs have deviation from ideal } else if (height < 12100000) { commission = 488281; } else if (height < 15460000) { @@ -1350,25 +1323,24 @@ uint64_t hush_commission(int height) } else if (height < 44020000) { commission = 1; } else if (height < 45700000) { + // FR goes to zero at Halving 26 commission = 0; } else if (height < 47380000) { + // FR still zero at Halving 27 commission = 0; } else if (height < 49060000) { + // FR still zero at Halving 28 commission = 0; } else if (height < 50740000) { + // FR still zero at Halving 29 commission = 0; } else { + // enforce FR=0 for all other heights + // This over-rides the -ac_end param via HUSH3 cli args commission = 0; } } - // Explicitly set the last block reward - // BR_END is the block with first zero block reward, which overrides - // the -ac_end param on HUSH3 - if(height >= BR_END) { - fprintf(stderr,"%s: HUSH block reward has gone to zero at height %d!!! It was a good run folks\n", __func__, height); - commission = 0; - } if(fDebug) fprintf(stderr,"%s: commission=%lu,interval=%d at height %d\n", __func__, commission, INTERVAL, height); return commission; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 392875dbc..f134e9957 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1542,20 +1542,92 @@ uint64_t komodo_max_money() } -// This implements the Hush Emission Curve +// This implements the Hush Emission Curve, the miner subsidy part, +// and must be kept in sync with hush_commision() in komoto_bitcoind.h! +// Changing these functions are consensus changes! +// Here Be Dragons! -- Duke Leto uint64_t hush_block_subsidy(int height) { - uint64_t subsidy=0; - //TODO: Cover all halvings until BR=0 - if (nHeight >= 3700000) { - subsidy = -1; - } else if (height >= 2020000) { - subsidy = 140625000; - } else if (height >= GetArg("-z2zheight",340000)) { - subsidy = 281250000; - } else if (height >= 128) { - subsidy = 1125000000; + uint64_t subsidy = 0; + int32_t HALVING1 = GetArg("-z2zheight",340000), + + if (height < TRANSITION) { + if(fDebug) + fprintf(stderr,"%s: setting subsidy=0 during transition at height=%d\n",__func__, height); + subsidy = 0; + } else { + // Just like BTC, BRs in the far future will be slightly less than + // they should be because exact values are not integers, causing + // slightly less coins to be actually mined and small deviations + // to the ideal FR/devtax + if (height < HALVING1) { // before 1st Halving @ Block 340000 (Nov 2020) + subsidy = 1125000000; + } else if (height < 2020000 ) { + subsidy = 281250000; + } else if (height < 3700000 ) { + subsidy = 140625000; + } else if (height < 5380000 ) { + subsidy = 70312500; + } else if (height < 7060000 ) { + subsidy = 35156250; + } else if (height < 8740000 ) { + subsidy = 17578125; + } else if (height < 10420000) { + subsidy = 8789062; + } else if (height < 12100000) { + subsidy = 4394531; + } else if (height < 15460000) { + subsidy = 2197265; + } else if (height < 17140000) { + subsidy = 1098632; + } else if (height < 18820000) { + subsidy = 549316; + } else if (height < 23860000) { + subsidy = 274658; + } else if (height < 23860000) { + subsidy = 137329; + } else if (height < 25540000) { + subsidy = 68664; + } else if (height < 27220000) { + subsidy = 34332; + } else if (height < 27220000) { + subsidy = 17166; + } else if (height < 28900000) { + subsidy = 8583; + } else if (height < 30580000) { + subsidy = 4291; + } else if (height < 32260000) { + subsidy = 2145; + } else if (height < 33940000) { + subsidy = 1072; + } else if (height < 35620000) { + subsidy = 536; + } else if (height < 37300000) { + subsidy = 268; + } else if (height < 38980000) { + subsidy = 134; + } else if (height < 40660000) { + subsidy = 67; + } else if (height < 42340000) { + subsidy = 33; + } else if (height < 44020000) { + subsidy = 16; + } else if (height < 45700000) { + subsidy = 8; + } else if (height < 47380000) { + subsidy = 4; + } else if (height < 49060000) { + subsidy = 2; + } else if (height < 50740000) { + subsidy = 1; + } else { + // HUSH Block Reward rounds down to 0 at Block 50740000 which is the 31st halving + // because Bitcoin/Zcash/Hush internals don't support 0.5 sat block reward yet ;) + subsidy = 0; + } } + if(fDebug) + fprintf(stderr,"%s: subsidy=%ul at height=%d\n",__func__,subsidy,height); return subsidy; } From 9e288d185b069b3a0cac13c9850a4f9613772860 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 19 Sep 2020 12:17:26 -0400 Subject: [PATCH 223/255] Define the halving interval, initial transition period and fix format string bug --- src/komodo_utils.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index f134e9957..9cf26d6ba 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1549,7 +1549,10 @@ uint64_t komodo_max_money() uint64_t hush_block_subsidy(int height) { uint64_t subsidy = 0; - int32_t HALVING1 = GetArg("-z2zheight",340000), + int32_t HALVING1 = GetArg("-z2zheight",340000); + //TODO: support INTERVAL :( + //int32_t INTERVAL = GetArg("-ac_halving1",840000); + int32_t TRANSITION = 129; if (height < TRANSITION) { if(fDebug) @@ -1627,7 +1630,7 @@ uint64_t hush_block_subsidy(int height) } } if(fDebug) - fprintf(stderr,"%s: subsidy=%ul at height=%d\n",__func__,subsidy,height); + fprintf(stderr,"%s: subsidy=%lu at height=%d\n",__func__,subsidy,height); return subsidy; } From 01e493d207cddcea11b3b99be206e80c3d711b34 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 19 Sep 2020 12:38:11 -0400 Subject: [PATCH 224/255] Update checkpoints up to block 295K --- contrib/checkpoints.pl | 2 +- src/chainparams.cpp | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/contrib/checkpoints.pl b/contrib/checkpoints.pl index 8d14b1619..bf11a8f7f 100755 --- a/contrib/checkpoints.pl +++ b/contrib/checkpoints.pl @@ -57,4 +57,4 @@ if ($line1 =~ m/tx=(\d+)/) { } print "(int64_t) $time, // time of last checkpointed block\n"; print "(int64_t) $total_txs, // total txs\n"; -print "(double) $txs_per_day, // txs in the last day before block $blocks\n"; +print "(double) $txs_per_day // txs in the last day before block $blocks\n"; diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 3714e0857..c773916ff 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -598,6 +598,7 @@ void *chainparams_commandline() { boost::assign::map_list_of (0, pCurrentParams->consensus.hashGenesisBlock) + // Generated at 1600532337 via hush3 contrib/checkpoints.pl by Duke Leto (5000, uint256S("0x000000018f8543066baa9c5f83e981749da4cb625fad02c187b4a9c4693ebd60")) (10000, uint256S("0x00000002d177d1cbfeaf7c27a2a32766ea9063d222cbcc7623dc08355b07a3ad")) (15000, uint256S("0x000000008dbfbd5d5e27d819bf2989c5658c3494608bfa1320ad0b090660cd44")) @@ -651,10 +652,15 @@ void *chainparams_commandline() (255000, uint256S("0x00000000b76f444f3f5258a2d20d2639c0bffebb6ee0217caa56fcd0404337d5")) (260000, uint256S("0x00000001f2dc5f292d9ee232d463faf1bc59362b9b3432f5bd1f72ffc76716f8")) (265000, uint256S("0x00000003c2dc488c16fc1d73b288065e89bfb9e38dd08cc543867b0b7aa26047")) - (270000, uint256S("0x000000026cc545eed18b508c3368cd20256c012bfa10f5f115b21ad0101c02cb")), - (int64_t) 1596129098, // time of last checkpointed block - (int64_t) 527001, // total txs - (double) 891 // txs in the last day before block 270407 + (270000, uint256S("0x000000026cc545eed18b508c3368cd20256c012bfa10f5f115b21ad0101c02cb")) + (275000, uint256S("0x0000000376ee6074814c8274238f88e48f96a87ee6ba63e7d349554128087014")) + (280000, uint256S("0x000000036b2c0edb762736b4243cdba4d5b576456cc4c6b6a29ed69d27f0c4d9")) + (285000, uint256S("0x000000064ca1b27d679ffc9e25af53d531d9f80bc00fd130f5a71054b2f96124")) + (290000, uint256S("0x00000000c9bd5248099f4caca2a5b1da88548cd1824bb22a0efa6c30cf6ccfce")) + (295000, uint256S("0x00000002fb6bbf41e4f17f88301895c9143ea93e628523b97e5bd5765070d803")), + (int64_t) 1599924956, // time of last checkpointed block + (int64_t) 573115, // total txs + (double) 970 // txs in the last day before block 298951 }; } else { checkpointData = //(Checkpoints::CCheckpointData) From 9e6cdec2f67df78c877b1efd5e2221a23552e56e Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 19 Sep 2020 20:38:43 -0400 Subject: [PATCH 225/255] Update hush-cli cli help --- src/bitcoin-cli.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 544972586..1c9b86959 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -1,7 +1,8 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -101,12 +102,12 @@ static int AppInitRPC(int argc, char* argv[]) strncpy(ASSETCHAINS_SYMBOL,name.c_str(),sizeof(ASSETCHAINS_SYMBOL)-1); if (argc<2 || mapArgs.count("-?") || mapArgs.count("-h") || mapArgs.count("-help") || mapArgs.count("-version")) { - std::string strUsage = _("Komodo RPC client version") + " " + FormatFullVersion() + "\n" + PrivacyInfo(); + std::string strUsage = _("Hush RPC client version") + " " + FormatFullVersion() + "\n" + PrivacyInfo(); if (!mapArgs.count("-version")) { strUsage += "\n" + _("Usage:") + "\n" + - " komodo-cli [options] [params] " + _("Send command to Komodo") + "\n" + - " komodo-cli [options] help " + _("List commands") + "\n" + - " komodo-cli [options] help " + _("Get help for a command") + "\n"; + " hush-cli [options] [params] " + _("Send command to Hush") + "\n" + + " hush-cli [options] help " + _("List commands") + "\n" + + " hush-cli [options] help " + _("Get help for a command") + "\n"; strUsage += "\n" + HelpMessageCli(); } else { From 1064d33f434c70a7e8af8307eb640c7030b63000 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 20 Sep 2020 11:13:38 -0400 Subject: [PATCH 226/255] Update some copyright stuff in windows files --- src/bitcoin-cli-res.rc | 6 +++--- src/clientversion.h | 2 +- src/init.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/bitcoin-cli-res.rc b/src/bitcoin-cli-res.rc index 3e46f5a16..a2fc33737 100644 --- a/src/bitcoin-cli-res.rc +++ b/src/bitcoin-cli-res.rc @@ -16,12 +16,12 @@ BEGIN BEGIN BLOCK "040904E4" // U.S. English - multilingual (hex) BEGIN - VALUE "CompanyName", "Komodo" - VALUE "FileDescription", "komodo-cli (JSON-RPC client for Komodo)" + VALUE "CompanyName", "Hush" + VALUE "FileDescription", "komodo-cli (JSON-RPC client for Hush-flavored Komodo)" VALUE "FileVersion", VER_FILEVERSION_STR VALUE "InternalName", "komodo-cli" VALUE "LegalCopyright", COPYRIGHT_STR - VALUE "LegalTrademarks1", "Distributed under the MIT software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php." + VALUE "LegalTrademarks1", "Distributed under the MIT software license, see the accompanying file COPYING or https://www.opensource.org/licenses/mit-license.php" VALUE "OriginalFilename", "komodo-cli.exe" VALUE "ProductName", "komodo-cli" VALUE "ProductVersion", VER_PRODUCTVERSION_STR diff --git a/src/clientversion.h b/src/clientversion.h index ed24867a1..3e570841e 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -56,7 +56,7 @@ #define DO_STRINGIZE(X) #X //! Copyright string used in Windows .rc files -#define COPYRIGHT_STR "2009-" STRINGIZE(COPYRIGHT_YEAR) " The Bitcoin Core Developers, The Zcash developers, Komodo developers, Hush developers" +#define COPYRIGHT_STR "2009-" STRINGIZE(COPYRIGHT_YEAR) " The Bitcoin Core, Zcash, Komodo, Hush Developers" /** * bitcoind-res.rc includes this file, but it cannot cope with real c++ code. diff --git a/src/init.cpp b/src/init.cpp index 9f92999c4..8a495304c 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -2050,7 +2050,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) } #endif // ENABLE_MINING - // Start the thread that notifies listeners of transactions that have been + // Start the thread that notifies listeners of transactions that have been // recently added to the mempool, or have been added to or removed from the // chain. We perform this before step 10 (import blocks) so that the // original value of chainActive.Tip(), which corresponds with the wallet's From e87101bd1f1b23c6beec0e31a87cd87299aef71a Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 20 Sep 2020 11:16:42 -0400 Subject: [PATCH 227/255] RPC help fixes --- src/rpc/blockchain.cpp | 2 +- src/rpc/net.cpp | 2 +- src/rpc/rawtransaction.cpp | 6 +++--- src/wallet/rpcdump.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 6e2efbd57..6d10652e6 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -1440,7 +1440,7 @@ UniValue gettxout(const UniValue& params, bool fHelp, const CPubKey& mypk) " \"reqSigs\" : n, (numeric) Number of required signatures\n" " \"type\" : \"pubkeyhash\", (string) The type, eg pubkeyhash\n" " \"addresses\" : [ (array of string) array of Komodo addresses\n" - " \"komodoaddress\" (string) Komodo address\n" + " \"hushaddress\" (string) Hush address\n" " ,...\n" " ]\n" " },\n" diff --git a/src/rpc/net.cpp b/src/rpc/net.cpp index c93f6a409..e869e02e4 100644 --- a/src/rpc/net.cpp +++ b/src/rpc/net.cpp @@ -321,7 +321,7 @@ UniValue getaddednodeinfo(const UniValue& params, bool fHelp, const CPubKey& myp " \"connected\" : true|false, (boolean) If connected\n" " \"addresses\" : [\n" " {\n" - " \"address\" : \"192.168.0.201:8233\", (string) The Komodo server host and port\n" + " \"address\" : \"192.168.0.201:8233\", (string) The Hush server host and port\n" " \"connected\" : \"outbound\" (string) connection, inbound or outbound\n" " }\n" " ,...\n" diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 610e79149..94c891a80 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -409,7 +409,7 @@ UniValue getrawtransaction(const UniValue& params, bool fHelp, const CPubKey& my " \"reqSigs\" : n, (numeric) The required sigs\n" " \"type\" : \"pubkeyhash\", (string) The type, eg 'pubkeyhash'\n" " \"addresses\" : [ (json array of string)\n" - " \"komodoaddress\" (string) Komodo address\n" + " \"hushaddress\" (string) Hush address\n" " ,...\n" " ]\n" " }\n" @@ -773,7 +773,7 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp, const CPubKey& } } else { - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Komodo address or script: ") + name_); + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, std::string("Invalid Hush address or script: ") + name_); } if (!(fExperimentalMode && IS_KOMODO_NOTARY)) { @@ -880,7 +880,7 @@ UniValue decodescript(const UniValue& params, bool fHelp, const CPubKey& mypk) " \"type\":\"type\", (string) The output type\n" " \"reqSigs\": n, (numeric) The required signatures\n" " \"addresses\": [ (json array of string)\n" - " \"address\" (string) Komodo address\n" + " \"address\" (string) Hush address\n" " ,...\n" " ],\n" " \"p2sh\",\"address\" (string) script address\n" diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index 2cd835cbe..af50bb9d1 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -100,7 +100,7 @@ UniValue convertpassphrase(const UniValue& params, bool fHelp, const CPubKey& my "1. \"agamapassphrase\" (string, required) Agama passphrase\n" "\nResult:\n" "\"agamapassphrase\": \"agamapassphrase\", (string) Agama passphrase you entered\n" - "\"address\": \"komodoaddress\", (string) Address corresponding to your passphrase\n" + "\"address\": \"hushaddress\", (string) Address corresponding to your passphrase\n" "\"pubkey\": \"publickeyhex\", (string) The hex value of the raw public key\n" "\"privkey\": \"privatekeyhex\", (string) The hex value of the raw private key\n" "\"wif\": \"wif\" (string) The private key in WIF format to use with 'importprivkey'\n" From a64b721d4cade396f32ef2f9f0126924d7ee2033 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 20 Sep 2020 11:55:56 -0400 Subject: [PATCH 228/255] update coin name in exceptions --- src/util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util.cpp b/src/util.cpp index d6ceb1997..cb52c3f70 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -512,7 +512,7 @@ static std::string FormatException(const std::exception* pex, const char* pszThr char pszModule[MAX_PATH] = ""; GetModuleFileNameA(NULL, pszModule, sizeof(pszModule)); #else - const char* pszModule = "Komodo"; + const char* pszModule = "Hush"; #endif if (pex) return strprintf( From 3a2288bcc41be8a28f98c8324e3fb2587c119ef8 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 20 Sep 2020 12:06:37 -0400 Subject: [PATCH 229/255] Logspam --- src/wallet/wallet.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index a0cd0533f..fc27679e5 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1524,6 +1524,9 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx) bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate) { + if(fDebug) + fprintf(stderr,"%s: tx=%s\n", __func__, tx.GetHash().ToString().c_str() ); + { AssertLockHeld(cs_wallet); if ( tx.IsCoinBase() && tx.vout[0].nValue == 0 ) @@ -1606,6 +1609,8 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl void CWallet::SyncTransaction(const CTransaction& tx, const CBlock* pblock) { LOCK(cs_wallet); + if(fDebug) + fprintf(stderr,"%s: tx=%s\n", __func__, tx.GetHash().ToString().c_str() ); if (!AddToWalletIfInvolvingMe(tx, pblock, true)) return; // Not one of ours @@ -1614,6 +1619,8 @@ void CWallet::SyncTransaction(const CTransaction& tx, const CBlock* pblock) void CWallet::MarkAffectedTransactionsDirty(const CTransaction& tx) { + if(fDebug) + fprintf(stderr,"%s: tx=%s\n", __func__, tx.GetHash().ToString().c_str() ); // If a transaction changes 'conflicted' state, that changes the balance // available of the outputs it spends. So force those to be // recomputed, also: @@ -1630,6 +1637,8 @@ void CWallet::MarkAffectedTransactionsDirty(const CTransaction& tx) mapWallet[mapSaplingNullifiersToNotes[nullifier].hash].MarkDirty(); } } + if(fDebug) + fprintf(stderr,"%s: finished marking dirty transactions\n", __func__); } void CWallet::EraseFromWallet(const uint256 &hash) From b4de87db04a3218d229207d9604fb669158f4417 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 20 Sep 2020 12:34:11 -0400 Subject: [PATCH 230/255] Fix off-by-one found by our Legendary Warrior @denioD --- src/komodo_bitcoind.h | 3 +-- src/komodo_utils.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 76e075bd6..87add6128 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1246,9 +1246,8 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); // Here Be Dragons! -- Duke Leto uint64_t hush_commission(int height) { - // BR_END is the 31st halving int32_t starting_commission = 125000000, HALVING1 = GetArg("-z2zheight",340000), - INTERVAL = GetArg("-ac_halving1",840000), TRANSITION = 129, BR_END = 50740000; + INTERVAL = GetArg("-ac_halving1",840000), TRANSITION = 128; uint64_t commission = 0; //TODO: Likely a bug hiding here or at the next halving :) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 9cf26d6ba..2e4e679ca 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1552,7 +1552,7 @@ uint64_t hush_block_subsidy(int height) int32_t HALVING1 = GetArg("-z2zheight",340000); //TODO: support INTERVAL :( //int32_t INTERVAL = GetArg("-ac_halving1",840000); - int32_t TRANSITION = 129; + int32_t TRANSITION = 128; if (height < TRANSITION) { if(fDebug) From 287310e81c47346382bb355407c6d1471d04d0e5 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 20 Sep 2020 12:45:05 -0400 Subject: [PATCH 231/255] Better logspam --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 87add6128..fe495e176 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2064,7 +2064,7 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) checktoshis = komodo_commission(pblock,height); if ( checktoshis >= 10000 && pblock->vtx[0].vout.size() < 2 ) { - fprintf(stderr,"ERROR: komodo_checkcommission vsize.%d height.%d commission %.8f has checktoshis <10000 or not enough vouts\n",(int32_t)pblock->vtx[0].vout.size(),height,(double)checktoshis/COIN); + fprintf(stderr,"ERROR: komodo_checkcommission vsize.%d height.%d commission %.8f has checktoshis=%lu <10000 or less than 2 vouts (vouts=%lu)\n",(int32_t)pblock->vtx[0].vout.size(),height,(double)checktoshis/COIN, checktoshis, pblock->vtx[0].vout.size() ); return(-1); } else if ( checktoshis != 0 ) From cb09e7feda45f8f13cc9842066f15f9930a4b6f5 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 20 Sep 2020 12:59:08 -0400 Subject: [PATCH 232/255] Update some copyrights --- src/bech32.cpp | 3 ++- src/bech32.h | 5 +++-- src/dbwrapper.cpp | 3 ++- src/hash.cpp | 1 + src/metrics.h | 1 + src/protocol.cpp | 1 + src/pubkey.cpp | 9 +++++---- src/sync.cpp | 3 ++- 8 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/bech32.cpp b/src/bech32.cpp index 78c35b976..ba2ba8904 100644 --- a/src/bech32.cpp +++ b/src/bech32.cpp @@ -1,6 +1,7 @@ // Copyright (c) 2017 Pieter Wuille +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "bech32.h" diff --git a/src/bech32.h b/src/bech32.h index 2e2823e97..88a11486f 100644 --- a/src/bech32.h +++ b/src/bech32.h @@ -1,8 +1,9 @@ // Copyright (c) 2017 Pieter Wuille +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php -// Bech32 is a string encoding format used in newer address types. +// Bech32 is a string encoding format used in Sapling zaddrs // The output consists of a human-readable part (alphanumeric), a // separator character (1), and a base32 data section, the last // 6 characters of which are a checksum. diff --git a/src/dbwrapper.cpp b/src/dbwrapper.cpp index 47bbb0f05..7b7529a1f 100644 --- a/src/dbwrapper.cpp +++ b/src/dbwrapper.cpp @@ -1,6 +1,7 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "dbwrapper.h" diff --git a/src/hash.cpp b/src/hash.cpp index 7471da8fb..c15212a84 100644 --- a/src/hash.cpp +++ b/src/hash.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2013-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/metrics.h b/src/metrics.h index 84ea9ed51..c110573a2 100644 --- a/src/metrics.h +++ b/src/metrics.h @@ -1,4 +1,5 @@ // Copyright (c) 2016 The Zcash developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/protocol.cpp b/src/protocol.cpp index 36ed63934..77892bae6 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -1,5 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. diff --git a/src/pubkey.cpp b/src/pubkey.cpp index c714c8671..0d9096f61 100644 --- a/src/pubkey.cpp +++ b/src/pubkey.cpp @@ -1,7 +1,8 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2017 The Zcash developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -41,12 +42,12 @@ bool CPubKey::Verify(const uint256 &hash, const std::vector& vchS if (vchSig.size() == 0) { return false; } - /* Zcash, unlike Bitcoin, has always enforced strict DER signatures. */ + /* Hush, unlike Bitcoin, has always enforced strict DER signatures. */ if (!secp256k1_ecdsa_signature_parse_der(secp256k1_context_verify, &sig, &vchSig[0], vchSig.size())) { return false; } /* libsecp256k1's ECDSA verification requires lower-S signatures, which have - * not historically been enforced in Bitcoin or Zcash, so normalize them first. */ + * not historically been enforced in Bitcoin or Hush, so normalize them first. */ secp256k1_ecdsa_signature_normalize(secp256k1_context_verify, &sig, &sig); return secp256k1_ecdsa_verify(secp256k1_context_verify, &sig, hash.begin(), &pubkey); } @@ -142,7 +143,7 @@ bool CExtPubKey::Derive(CExtPubKey &out, unsigned int nChild) const { /* static */ bool CPubKey::CheckLowS(const std::vector& vchSig) { secp256k1_ecdsa_signature sig; - /* Zcash, unlike Bitcoin, has always enforced strict DER signatures. */ + /* Hush, unlike Bitcoin, has always enforced strict DER signatures. */ if (!secp256k1_ecdsa_signature_parse_der(secp256k1_context_verify, &sig, &vchSig[0], vchSig.size())) { return false; } diff --git a/src/sync.cpp b/src/sync.cpp index 31c3301bd..8322a6383 100644 --- a/src/sync.cpp +++ b/src/sync.cpp @@ -1,6 +1,7 @@ // Copyright (c) 2011-2012 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// Copyright (c) 2019-2020 The Hush developers +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * From a7f88a87aade3d02d6d443f4f5d0eef6682d622e Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 20 Sep 2020 13:17:38 -0400 Subject: [PATCH 233/255] Update copyright URL to be https --- COPYING | 2 +- contrib/devtools/symbol-check.py | 2 +- contrib/hush-cli.bash-completion | 2 +- contrib/hush-tx.bash-completion | 2 +- contrib/hushd.bash-completion | 2 +- contrib/komodo-cli.bash-completion | 2 +- contrib/komodo-tx.bash-completion | 2 +- contrib/komodod.bash-completion | 2 +- contrib/linearize/linearize-data.py | 2 +- contrib/linearize/linearize-hashes.py | 2 +- contrib/seeds/generate-seeds.py | 2 +- contrib/zmq/zmq_sub.py | 2 +- doc/man/hush-cli.1 | 14 +++++++------- doc/man/hush-tx.1 | 6 +++--- doc/man/hushd.1 | 6 +++--- qa/hush/create_wallet_200k_utxos.py | 2 +- qa/rpc-tests/ac_private.py | 2 +- qa/rpc-tests/addressindex.py | 2 +- qa/rpc-tests/bip65-cltv-p2p.py | 2 +- qa/rpc-tests/bipdersig-p2p.py | 2 +- qa/rpc-tests/blockchain.py | 2 +- qa/rpc-tests/cryptoconditions.py | 2 +- qa/rpc-tests/cryptoconditions_channels.py | 2 +- qa/rpc-tests/cryptoconditions_dice.py | 2 +- qa/rpc-tests/cryptoconditions_faucet.py | 2 +- qa/rpc-tests/cryptoconditions_gateways.py | 2 +- qa/rpc-tests/cryptoconditions_heir.py | 2 +- qa/rpc-tests/cryptoconditions_oracles.py | 2 +- qa/rpc-tests/cryptoconditions_rewards.py | 2 +- qa/rpc-tests/cryptoconditions_token.py | 2 +- qa/rpc-tests/decodescript.py | 2 +- qa/rpc-tests/disablewallet.py | 2 +- qa/rpc-tests/dpowconfs.py | 2 +- qa/rpc-tests/finalsaplingroot.py | 2 +- qa/rpc-tests/forknotify.py | 2 +- qa/rpc-tests/fundrawtransaction.py | 2 +- qa/rpc-tests/getblocktemplate.py | 2 +- qa/rpc-tests/getblocktemplate_longpoll.py | 2 +- qa/rpc-tests/getblocktemplate_proposals.py | 2 +- qa/rpc-tests/getchaintips.py | 2 +- qa/rpc-tests/httpbasics.py | 2 +- qa/rpc-tests/invalidateblock.py | 2 +- qa/rpc-tests/invalidblockrequest.py | 2 +- qa/rpc-tests/ivk_import_export.py | 2 +- qa/rpc-tests/key_import_export.py | 2 +- qa/rpc-tests/keypool.py | 2 +- qa/rpc-tests/listtransactions.py | 2 +- qa/rpc-tests/maxblocksinflight.py | 2 +- qa/rpc-tests/mempool_nu_activation.py | 2 +- qa/rpc-tests/mempool_reorg.py | 2 +- qa/rpc-tests/mempool_resurrect_test.py | 2 +- qa/rpc-tests/mempool_spendcoinbase.py | 2 +- qa/rpc-tests/mempool_tx_expiry.py | 2 +- qa/rpc-tests/mempool_tx_input_limit.py | 2 +- qa/rpc-tests/merkle_blocks.py | 2 +- qa/rpc-tests/nodehandling.py | 2 +- qa/rpc-tests/p2p-acceptblock.py | 2 +- qa/rpc-tests/p2p_node_bloom.py | 2 +- qa/rpc-tests/p2p_txexpiry_dos.py | 2 +- qa/rpc-tests/prioritisetransaction.py | 2 +- qa/rpc-tests/proxy_test.py | 2 +- qa/rpc-tests/pruning.py | 2 +- qa/rpc-tests/rawtransactions.py | 2 +- qa/rpc-tests/receivedby.py | 2 +- qa/rpc-tests/regtest_signrawtransaction.py | 2 +- qa/rpc-tests/rest.py | 2 +- qa/rpc-tests/rewind_index.py | 2 +- qa/rpc-tests/rpcbind_test.py | 2 +- qa/rpc-tests/script_test.py | 2 +- qa/rpc-tests/signrawtransactions.py | 2 +- qa/rpc-tests/smartfees.py | 2 +- qa/rpc-tests/spentindex.py | 2 +- qa/rpc-tests/test_framework/bignum.py | 2 +- qa/rpc-tests/test_framework/blocktools.py | 2 +- qa/rpc-tests/test_framework/comptool.py | 2 +- qa/rpc-tests/test_framework/netutil.py | 2 +- qa/rpc-tests/test_framework/script.py | 2 +- qa/rpc-tests/test_framework/socks5.py | 2 +- qa/rpc-tests/test_framework/util.py | 2 +- qa/rpc-tests/txindex.py | 2 +- qa/rpc-tests/txn_doublespend.py | 2 +- qa/rpc-tests/wallet.py | 2 +- qa/rpc-tests/wallet_1941.py | 2 +- qa/rpc-tests/wallet_addresses.py | 2 +- qa/rpc-tests/wallet_anchorfork.py | 2 +- qa/rpc-tests/wallet_changeindicator.py | 2 +- qa/rpc-tests/wallet_import_export.py | 2 +- qa/rpc-tests/wallet_listnotes.py | 2 +- qa/rpc-tests/wallet_listreceived.py | 2 +- qa/rpc-tests/wallet_mergetoaddress.py | 2 +- qa/rpc-tests/wallet_nullifiers.py | 2 +- qa/rpc-tests/wallet_overwintertx.py | 2 +- qa/rpc-tests/wallet_persistence.py | 2 +- qa/rpc-tests/wallet_protectcoinbase.py | 2 +- qa/rpc-tests/wallet_shieldcoinbase.py | 2 +- qa/rpc-tests/wallet_treestate.py | 2 +- qa/rpc-tests/walletbackup.py | 2 +- qa/rpc-tests/zapwallettxes.py | 2 +- qa/rpc-tests/zkey_import_export.py | 2 +- qa/rpc-tests/zmq_test.py | 2 +- src/addressindex.h | 2 +- src/addrman.cpp | 2 +- src/alert.h | 2 +- src/amount.cpp | 2 +- src/amount.h | 2 +- src/arith_uint256.cpp | 2 +- src/arith_uint256.h | 2 +- src/asyncrpcoperation.cpp | 2 +- src/asyncrpcoperation.h | 2 +- src/asyncrpcqueue.cpp | 2 +- src/asyncrpcqueue.h | 2 +- src/base58.cpp | 2 +- src/base58.h | 2 +- src/bitcoin-tx-res.rc | 2 +- src/bitcoind-res.rc | 2 +- src/bitcoind.cpp | 2 +- src/bloom.cpp | 2 +- src/bloom.h | 2 +- src/chain.cpp | 2 +- src/chain.h | 2 +- src/chainparams.cpp | 2 +- src/chainparams.h | 2 +- src/chainparamsbase.cpp | 2 +- src/chainparamsbase.h | 2 +- src/checkpoints.cpp | 2 +- src/checkpoints.h | 2 +- src/checkqueue.h | 2 +- src/clientversion.cpp | 2 +- src/clientversion.h | 2 +- src/coincontrol.h | 2 +- src/coins.cpp | 2 +- src/coins.h | 2 +- src/compat.h | 2 +- src/compat/byteswap.h | 2 +- src/compat/endian.h | 2 +- src/compat/glibc_compat.cpp | 2 +- src/compat/glibc_sanity.cpp | 2 +- src/compat/glibcxx_sanity.cpp | 2 +- src/compat/sanity.h | 2 +- src/compat/strnlen.cpp | 2 +- src/compressor.cpp | 2 +- src/compressor.h | 2 +- src/consensus/consensus.h | 2 +- src/consensus/upgrades.cpp | 2 +- src/consensus/upgrades.h | 2 +- src/consensus/validation.h | 2 +- src/core_io.h | 2 +- src/core_memusage.h | 2 +- src/core_read.cpp | 2 +- src/core_write.cpp | 2 +- src/crypto/common.h | 2 +- src/crypto/ctaes/ctaes.c | 2 +- src/crypto/ctaes/ctaes.h | 2 +- src/crypto/ctaes/test.c | 2 +- src/crypto/equihash.cpp | 2 +- src/crypto/equihash.h | 2 +- src/crypto/equihash.tcc | 2 +- src/crypto/hmac_sha256.cpp | 2 +- src/crypto/hmac_sha256.h | 2 +- src/crypto/hmac_sha512.cpp | 2 +- src/crypto/hmac_sha512.h | 2 +- src/crypto/ripemd160.cpp | 2 +- src/crypto/ripemd160.h | 2 +- src/crypto/sha1.cpp | 2 +- src/crypto/sha1.h | 2 +- src/crypto/sha256.cpp | 2 +- src/crypto/sha256.h | 2 +- src/crypto/sha256_sse4.cpp | 2 +- src/crypto/sha512.cpp | 2 +- src/crypto/sha512.h | 2 +- .../include/secp256k1/contrib/lax_der_parsing.c | 2 +- .../include/secp256k1/contrib/lax_der_parsing.h | 2 +- .../secp256k1/contrib/lax_der_privatekey_parsing.c | 2 +- .../secp256k1/contrib/lax_der_privatekey_parsing.h | 2 +- .../include/secp256k1/src/asm/field_10x26_arm.s | 2 +- .../src/include/secp256k1/src/basic-config.h | 2 +- .../src/include/secp256k1/src/bench.h | 2 +- .../src/include/secp256k1/src/bench_ecdh.c | 2 +- .../src/include/secp256k1/src/bench_internal.c | 2 +- .../src/include/secp256k1/src/bench_recover.c | 2 +- .../src/include/secp256k1/src/bench_sign.c | 2 +- .../src/include/secp256k1/src/bench_verify.c | 2 +- .../src/include/secp256k1/src/ecdsa.h | 2 +- .../src/include/secp256k1/src/ecdsa_impl.h | 2 +- .../src/include/secp256k1/src/eckey.h | 2 +- .../src/include/secp256k1/src/eckey_impl.h | 2 +- .../src/include/secp256k1/src/ecmult.h | 2 +- .../src/include/secp256k1/src/ecmult_const.h | 4 ++-- .../src/include/secp256k1/src/ecmult_const_impl.h | 2 +- .../src/include/secp256k1/src/ecmult_gen.h | 2 +- .../src/include/secp256k1/src/ecmult_gen_impl.h | 2 +- .../src/include/secp256k1/src/ecmult_impl.h | 2 +- .../src/include/secp256k1/src/field.h | 2 +- .../src/include/secp256k1/src/field_10x26.h | 2 +- .../src/include/secp256k1/src/field_10x26_impl.h | 2 +- .../src/include/secp256k1/src/field_5x52.h | 2 +- .../include/secp256k1/src/field_5x52_asm_impl.h | 2 +- .../src/include/secp256k1/src/field_5x52_impl.h | 2 +- .../include/secp256k1/src/field_5x52_int128_impl.h | 2 +- .../src/include/secp256k1/src/field_impl.h | 2 +- .../src/include/secp256k1/src/gen_context.c | 2 +- .../src/include/secp256k1/src/group.h | 2 +- .../src/include/secp256k1/src/group_impl.h | 2 +- .../src/include/secp256k1/src/hash.h | 2 +- .../src/include/secp256k1/src/hash_impl.h | 2 +- .../include/secp256k1/src/modules/ecdh/main_impl.h | 2 +- .../secp256k1/src/modules/ecdh/tests_impl.h | 2 +- .../secp256k1/src/modules/recovery/main_impl.h | 2 +- .../secp256k1/src/modules/recovery/tests_impl.h | 2 +- .../src/include/secp256k1/src/num.h | 2 +- .../src/include/secp256k1/src/num_gmp.h | 2 +- .../src/include/secp256k1/src/num_gmp_impl.h | 2 +- .../src/include/secp256k1/src/num_impl.h | 2 +- .../src/include/secp256k1/src/scalar.h | 2 +- .../src/include/secp256k1/src/scalar_4x64.h | 2 +- .../src/include/secp256k1/src/scalar_4x64_impl.h | 2 +- .../src/include/secp256k1/src/scalar_8x32.h | 2 +- .../src/include/secp256k1/src/scalar_8x32_impl.h | 2 +- .../src/include/secp256k1/src/scalar_impl.h | 2 +- .../src/include/secp256k1/src/scalar_low.h | 2 +- .../src/include/secp256k1/src/scalar_low_impl.h | 2 +- .../src/include/secp256k1/src/secp256k1.c | 2 +- .../src/include/secp256k1/src/testrand.h | 2 +- .../src/include/secp256k1/src/testrand_impl.h | 2 +- .../src/include/secp256k1/src/tests.c | 2 +- .../src/include/secp256k1/src/tests_exhaustive.c | 2 +- .../src/include/secp256k1/src/util.h | 2 +- src/dbwrapper.h | 2 +- src/deprecation.cpp | 2 +- src/deprecation.h | 2 +- src/hash.cpp | 2 +- src/hash.h | 2 +- src/httprpc.h | 2 +- src/httpserver.cpp | 2 +- src/httpserver.h | 2 +- src/init.cpp | 2 +- src/init.h | 2 +- src/key.cpp | 2 +- src/key.h | 2 +- src/key_io.cpp | 2 +- src/key_io.h | 2 +- src/keystore.cpp | 2 +- src/keystore.h | 2 +- src/komodo-tx.cpp | 2 +- src/limitedmap.h | 2 +- src/main.cpp | 2 +- src/main.h | 2 +- src/memusage.h | 2 +- src/merkleblock.cpp | 2 +- src/merkleblock.h | 2 +- src/metrics.cpp | 2 +- src/metrics.h | 2 +- src/miner.h | 2 +- src/mruset.h | 2 +- src/net.cpp | 2 +- src/net.h | 2 +- src/netbase.cpp | 2 +- src/netbase.h | 2 +- src/noui.cpp | 2 +- src/noui.h | 2 +- src/policy/fees.cpp | 2 +- src/policy/fees.h | 2 +- src/pow.cpp | 2 +- src/pow.h | 2 +- src/primitives/block.cpp | 2 +- src/primitives/block.h | 2 +- src/primitives/transaction.cpp | 2 +- src/primitives/transaction.h | 2 +- src/protocol.cpp | 2 +- src/protocol.h | 2 +- src/pubkey.h | 2 +- src/random.cpp | 2 +- src/random.h | 2 +- src/rest.cpp | 2 +- src/reverselock.h | 2 +- src/rpc/blockchain.cpp | 2 +- src/rpc/client.cpp | 2 +- src/rpc/client.h | 2 +- src/rpc/mining.cpp | 2 +- src/rpc/misc.cpp | 2 +- src/rpc/protocol.cpp | 2 +- src/rpc/protocol.h | 2 +- src/rpc/rawtransaction.cpp | 2 +- src/rpc/register.h | 2 +- src/rpc/server.cpp | 2 +- src/rpc/server.h | 2 +- src/rpc/testtransactions.cpp | 2 +- src/scheduler.cpp | 2 +- src/scheduler.h | 2 +- src/script/interpreter.cpp | 2 +- src/script/interpreter.h | 2 +- src/script/script.cpp | 2 +- src/script/script.h | 2 +- src/script/script_error.cpp | 2 +- src/script/script_error.h | 2 +- src/script/serverchecker.cpp | 2 +- src/script/serverchecker.h | 2 +- src/script/sigcache.cpp | 2 +- src/script/sigcache.h | 2 +- src/script/sign.cpp | 2 +- src/script/sign.h | 2 +- src/script/standard.cpp | 2 +- src/script/standard.h | 2 +- src/script/zcashconsensus.cpp | 2 +- src/script/zcashconsensus.h | 2 +- src/secp256k1/contrib/lax_der_parsing.c | 2 +- src/secp256k1/contrib/lax_der_parsing.h | 2 +- src/secp256k1/contrib/lax_der_privatekey_parsing.c | 2 +- src/secp256k1/contrib/lax_der_privatekey_parsing.h | 2 +- src/secp256k1/src/asm/field_10x26_arm.s | 2 +- src/secp256k1/src/basic-config.h | 2 +- src/secp256k1/src/bench.h | 2 +- src/secp256k1/src/bench_ecdh.c | 2 +- src/secp256k1/src/bench_internal.c | 2 +- src/secp256k1/src/bench_recover.c | 2 +- src/secp256k1/src/bench_sign.c | 2 +- src/secp256k1/src/bench_verify.c | 2 +- src/secp256k1/src/ecdsa.h | 2 +- src/secp256k1/src/ecdsa_impl.h | 2 +- src/secp256k1/src/eckey.h | 2 +- src/secp256k1/src/eckey_impl.h | 2 +- src/secp256k1/src/ecmult.h | 4 ++-- src/secp256k1/src/ecmult_const.h | 4 ++-- src/secp256k1/src/ecmult_const_impl.h | 4 ++-- src/secp256k1/src/ecmult_gen.h | 2 +- src/secp256k1/src/ecmult_gen_impl.h | 2 +- src/secp256k1/src/ecmult_impl.h | 4 ++-- src/secp256k1/src/field.h | 2 +- src/secp256k1/src/field_10x26.h | 2 +- src/secp256k1/src/field_10x26_impl.h | 2 +- src/secp256k1/src/field_5x52.h | 2 +- src/secp256k1/src/field_5x52_asm_impl.h | 2 +- src/secp256k1/src/field_5x52_impl.h | 2 +- src/secp256k1/src/field_5x52_int128_impl.h | 2 +- src/secp256k1/src/field_impl.h | 2 +- src/secp256k1/src/gen_context.c | 2 +- src/secp256k1/src/group.h | 2 +- src/secp256k1/src/group_impl.h | 2 +- src/secp256k1/src/hash.h | 2 +- src/secp256k1/src/hash_impl.h | 2 +- src/secp256k1/src/modules/ecdh/main_impl.h | 2 +- src/secp256k1/src/modules/ecdh/tests_impl.h | 2 +- src/secp256k1/src/modules/musig/example.c | 2 +- src/secp256k1/src/modules/musig/main_impl.h | 2 +- src/secp256k1/src/modules/musig/tests_impl.h | 2 +- src/secp256k1/src/modules/recovery/main_impl.h | 2 +- src/secp256k1/src/modules/recovery/tests_impl.h | 2 +- src/secp256k1/src/modules/schnorrsig/main_impl.h | 2 +- src/secp256k1/src/modules/schnorrsig/tests_impl.h | 2 +- src/secp256k1/src/num.h | 2 +- src/secp256k1/src/num_gmp.h | 2 +- src/secp256k1/src/num_gmp_impl.h | 2 +- src/secp256k1/src/num_impl.h | 2 +- src/secp256k1/src/scalar.h | 4 ++-- src/secp256k1/src/scalar_4x64.h | 4 ++-- src/secp256k1/src/scalar_4x64_impl.h | 4 ++-- src/secp256k1/src/scalar_8x32.h | 4 ++-- src/secp256k1/src/scalar_8x32_impl.h | 4 ++-- src/secp256k1/src/scalar_impl.h | 4 ++-- src/secp256k1/src/scalar_low.h | 4 ++-- src/secp256k1/src/scalar_low_impl.h | 4 ++-- src/secp256k1/src/scratch.h | 2 +- src/secp256k1/src/scratch_impl.h | 2 +- src/secp256k1/src/secp256k1.c | 2 +- src/secp256k1/src/testrand.h | 2 +- src/secp256k1/src/testrand_impl.h | 2 +- src/secp256k1/src/tests.c | 2 +- src/secp256k1/src/tests_exhaustive.c | 2 +- src/secp256k1/src/util.h | 2 +- src/serialize.h | 2 +- src/spentindex.h | 2 +- src/streams.h | 2 +- src/support/allocators/secure.h | 2 +- src/support/allocators/zeroafterfree.h | 2 +- src/support/cleanse.cpp | 2 +- src/support/cleanse.h | 2 +- src/support/events.h | 2 +- src/support/pagelocker.cpp | 2 +- src/support/pagelocker.h | 2 +- src/sync.h | 2 +- src/test/Checkpoints_tests.cpp | 2 +- src/test/DoS_tests.cpp | 2 +- src/test/accounting_tests.cpp | 2 +- src/test/addrman_tests.cpp | 2 +- src/test/alert_tests.cpp | 2 +- src/test/allocator_tests.cpp | 2 +- src/test/arith_uint256_tests.cpp | 2 +- src/test/base32_tests.cpp | 2 +- src/test/base58_tests.cpp | 2 +- src/test/base64_tests.cpp | 2 +- src/test/bctest.py | 2 +- src/test/bech32_tests.cpp | 2 +- src/test/bignum.h | 2 +- src/test/bip32_tests.cpp | 2 +- src/test/bitcoin-util-test.py | 2 +- src/test/bloom_tests.cpp | 2 +- src/test/checkblock_tests.cpp | 2 +- src/test/coins_tests.cpp | 2 +- src/test/compress_tests.cpp | 2 +- src/test/convertbits_tests.cpp | 2 +- src/test/crypto_tests.cpp | 2 +- src/test/data/README.md | 2 +- src/test/dbwrapper_tests.cpp | 2 +- src/test/equihash_tests.cpp | 2 +- src/test/getarg_tests.cpp | 2 +- src/test/hash_tests.cpp | 2 +- src/test/key_tests.cpp | 2 +- src/test/main_tests.cpp | 2 +- src/test/mempool_tests.cpp | 2 +- src/test/miner_tests.cpp | 2 +- src/test/mruset_tests.cpp | 2 +- src/test/multisig_tests.cpp | 2 +- src/test/netbase_tests.cpp | 2 +- src/test/pmt_tests.cpp | 2 +- src/test/policyestimator_tests.cpp | 2 +- src/test/pow_tests.cpp | 2 +- src/test/prevector_tests.cpp | 2 +- src/test/raii_event_tests.cpp | 2 +- src/test/reverselock_tests.cpp | 2 +- src/test/rpc_tests.cpp | 2 +- src/test/sanity_tests.cpp | 2 +- src/test/scheduler_tests.cpp | 2 +- src/test/script_P2PKH_tests.cpp | 2 +- src/test/script_P2SH_tests.cpp | 2 +- src/test/script_tests.cpp | 2 +- src/test/scriptnum_tests.cpp | 2 +- src/test/serialize_tests.cpp | 2 +- src/test/sighash_tests.cpp | 2 +- src/test/sigopcount_tests.cpp | 2 +- src/test/skiplist_tests.cpp | 2 +- src/test/test_bitcoin.cpp | 2 +- src/test/timedata_tests.cpp | 2 +- src/test/torcontrol_tests.cpp | 2 +- src/test/transaction_tests.cpp | 2 +- src/test/uint256_tests.cpp | 2 +- src/test/univalue_tests.cpp | 2 +- src/test/util_tests.cpp | 2 +- src/test/wallet-utility.py | 2 +- src/threadsafety.h | 2 +- src/torcontrol.cpp | 2 +- src/torcontrol.h | 2 +- src/transaction_builder.cpp | 2 +- src/transaction_builder.h | 2 +- src/txdb.cpp | 2 +- src/txdb.h | 2 +- src/txmempool.cpp | 2 +- src/txmempool.h | 2 +- src/ui_interface.h | 2 +- src/uint256.cpp | 2 +- src/uint256.h | 2 +- src/undo.h | 2 +- src/univalue/gen/gen.cpp | 2 +- src/univalue/include/univalue.h | 2 +- src/univalue/lib/univalue.cpp | 2 +- src/univalue/lib/univalue_read.cpp | 2 +- src/univalue/lib/univalue_utffilter.h | 2 +- src/univalue/lib/univalue_write.cpp | 2 +- src/univalue/test/unitester.cpp | 2 +- src/util.cpp | 4 ++-- src/util.h | 2 +- src/utilmoneystr.cpp | 2 +- src/utilmoneystr.h | 2 +- src/utilstrencodings.cpp | 2 +- src/utilstrencodings.h | 2 +- src/utiltime.cpp | 2 +- src/utiltime.h | 2 +- src/validationinterface.h | 2 +- src/wallet/asyncrpcoperation_mergetoaddress.h | 2 +- .../asyncrpcoperation_saplingconsolidation.cpp | 2 +- .../asyncrpcoperation_saplingconsolidation.h | 2 +- src/wallet/asyncrpcoperation_sendmany.h | 2 +- src/wallet/asyncrpcoperation_shieldcoinbase.cpp | 2 +- src/wallet/asyncrpcoperation_shieldcoinbase.h | 2 +- src/wallet/crypter.h | 2 +- src/wallet/db.cpp | 2 +- src/wallet/db.h | 2 +- src/wallet/rpcdump.cpp | 2 +- src/wallet/rpchushwallet.cpp | 2 +- src/wallet/rpchushwallet.h | 2 +- src/wallet/rpcwallet.cpp | 2 +- src/wallet/rpcwallet.h | 2 +- src/wallet/test/wallet_tests.cpp | 2 +- src/wallet/wallet.cpp | 2 +- src/wallet/wallet.h | 2 +- src/wallet/wallet_ismine.cpp | 2 +- src/wallet/wallet_ismine.h | 2 +- src/wallet/walletdb.cpp | 2 +- src/zcash/zip32.cpp | 2 +- src/zcash/zip32.h | 2 +- src/zmq/zmqabstractnotifier.cpp | 2 +- src/zmq/zmqabstractnotifier.h | 2 +- src/zmq/zmqconfig.h | 2 +- src/zmq/zmqnotificationinterface.cpp | 2 +- src/zmq/zmqnotificationinterface.h | 2 +- src/zmq/zmqpublishnotifier.cpp | 2 +- src/zmq/zmqpublishnotifier.h | 2 +- 496 files changed, 520 insertions(+), 520 deletions(-) diff --git a/COPYING b/COPYING index a03819aee..768d77b05 100644 --- a/COPYING +++ b/COPYING @@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -The MIT software license (http://www.opensource.org/licenses/mit-license.php) +The MIT software license (https://www.opensource.org/licenses/mit-license.php) above applies to the code directly included in this source distribution. Dependencies downloaded as part of the build process may be covered by other open-source licenses. For further details see 'contrib/debian/copyright'. diff --git a/contrib/devtools/symbol-check.py b/contrib/devtools/symbol-check.py index 52b48ef74..4dfffbbe9 100755 --- a/contrib/devtools/symbol-check.py +++ b/contrib/devtools/symbol-check.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # Copyright (c) 2014 Wladimir J. van der Laan # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php ''' A script to check that the (Linux) executables produced by gitian only contain allowed gcc, glibc and libstdc++ version symbols. This makes sure they are diff --git a/contrib/hush-cli.bash-completion b/contrib/hush-cli.bash-completion index 32cfe6b22..539ba8885 100644 --- a/contrib/hush-cli.bash-completion +++ b/contrib/hush-cli.bash-completion @@ -2,7 +2,7 @@ # Copyright (c) 2012-2016 The Bitcoin Core developers # Copyright (c) 2018 The Hush developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # call $hush-cli for RPC _hush_rpc() { diff --git a/contrib/hush-tx.bash-completion b/contrib/hush-tx.bash-completion index d43d0cba3..de151bcfb 100644 --- a/contrib/hush-tx.bash-completion +++ b/contrib/hush-tx.bash-completion @@ -1,7 +1,7 @@ # bash programmable completion for hush-tx(1) # Copyright (c) 2016 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php _hush_tx() { local cur prev words=() cword diff --git a/contrib/hushd.bash-completion b/contrib/hushd.bash-completion index 8a80c96a0..313607f09 100644 --- a/contrib/hushd.bash-completion +++ b/contrib/hushd.bash-completion @@ -3,7 +3,7 @@ # Copyright (c) 2016-2017 The Zcash developers # Copyright (c) 2018 The Hush developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php _hushd() { local cur prev words=() cword diff --git a/contrib/komodo-cli.bash-completion b/contrib/komodo-cli.bash-completion index 1efc05d46..9e34cd589 100644 --- a/contrib/komodo-cli.bash-completion +++ b/contrib/komodo-cli.bash-completion @@ -1,7 +1,7 @@ # bash programmable completion for komodo-cli(1) # Copyright (c) 2012-2016 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # call $komodo-cli for RPC _komodo_rpc() { diff --git a/contrib/komodo-tx.bash-completion b/contrib/komodo-tx.bash-completion index 69e259381..af0c65ef9 100644 --- a/contrib/komodo-tx.bash-completion +++ b/contrib/komodo-tx.bash-completion @@ -1,7 +1,7 @@ # bash programmable completion for komodo-tx(1) # Copyright (c) 2016 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php _komodo_tx() { local cur prev words=() cword diff --git a/contrib/komodod.bash-completion b/contrib/komodod.bash-completion index 4c1ec516f..5509a4852 100644 --- a/contrib/komodod.bash-completion +++ b/contrib/komodod.bash-completion @@ -2,7 +2,7 @@ # Copyright (c) 2012-2017 The Bitcoin Core developers # Copyright (c) 2016-2017 The komodo developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php _komodod() { local cur prev words=() cword diff --git a/contrib/linearize/linearize-data.py b/contrib/linearize/linearize-data.py index 8badb4b31..55488a009 100755 --- a/contrib/linearize/linearize-data.py +++ b/contrib/linearize/linearize-data.py @@ -4,7 +4,7 @@ # # Copyright (c) 2013-2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # from __future__ import print_function, division diff --git a/contrib/linearize/linearize-hashes.py b/contrib/linearize/linearize-hashes.py index 7e9cf8898..b5644ee62 100755 --- a/contrib/linearize/linearize-hashes.py +++ b/contrib/linearize/linearize-hashes.py @@ -4,7 +4,7 @@ # # Copyright (c) 2013-2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # from __future__ import print_function diff --git a/contrib/seeds/generate-seeds.py b/contrib/seeds/generate-seeds.py index c6a2ce636..54809a314 100755 --- a/contrib/seeds/generate-seeds.py +++ b/contrib/seeds/generate-seeds.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # Copyright (c) 2014 Wladimir J. van der Laan # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php ''' Script to generate list of seed nodes for chainparams.cpp. diff --git a/contrib/zmq/zmq_sub.py b/contrib/zmq/zmq_sub.py index 3dea5e3c1..3a31b519f 100755 --- a/contrib/zmq/zmq_sub.py +++ b/contrib/zmq/zmq_sub.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014-2016 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php import array import binascii diff --git a/doc/man/hush-cli.1 b/doc/man/hush-cli.1 index d091ac49f..bba162cd6 100644 --- a/doc/man/hush-cli.1 +++ b/doc/man/hush-cli.1 @@ -3,19 +3,19 @@ .SH NAME hush-cli \- manual page for hush-cli v3.5.0 .SH DESCRIPTION -Komodo RPC client version v3.5.0\-beta6\-fab0f9494\-dirty +Hush RPC client version v3.5.0\-beta6\-cb09e7fed\-dirty .PP In order to ensure you are adequately protecting your privacy when using Hush, please see . .SS "Usage:" .TP -komodo\-cli [options] [params] -Send command to Komodo +hush\-cli [options] [params] +Send command to Hush .TP -komodo\-cli [options] help +hush\-cli [options] help List commands .TP -komodo\-cli [options] help +hush\-cli [options] help Get help for a command .SH OPTIONS .HP @@ -71,7 +71,7 @@ Timeout in seconds during HTTP requests, or 0 for no timeout. (default: Read extra arguments from standard input, one per line until EOF/Ctrl\-D (recommended for sensitive information such as passphrases) .SH COPYRIGHT -Hush Daemon version v3.5.0-beta6-fab0f9494-dirty +Hush Daemon version v3.5.0-beta6-cb09e7fed-dirty In order to ensure you are adequately protecting your privacy when using Hush, please see . @@ -84,7 +84,7 @@ Copyright (C) 2018-2020 The Hush developers This is experimental software!!! Distributed under the MIT software license, see the accompanying file COPYING -or . +or . This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit and cryptographic software written diff --git a/doc/man/hush-tx.1 b/doc/man/hush-tx.1 index 99212c29b..1ac3f4b2b 100644 --- a/doc/man/hush-tx.1 +++ b/doc/man/hush-tx.1 @@ -3,7 +3,7 @@ .SH NAME hush-tx \- manual page for hush-tx v3.5.0 .SH DESCRIPTION -Hush komodo\-tx utility version v3.5.0\-beta6\-fab0f9494\-dirty +Hush komodo\-tx utility version v3.5.0\-beta6\-cb09e7fed\-dirty .SS "Usage:" .TP komodo\-tx [options] [commands] @@ -84,7 +84,7 @@ set=NAME:JSON\-STRING .IP Set register NAME to given JSON\-STRING .SH COPYRIGHT -Hush Daemon version v3.5.0-beta6-fab0f9494-dirty +Hush Daemon version v3.5.0-beta6-cb09e7fed-dirty In order to ensure you are adequately protecting your privacy when using Hush, please see . @@ -97,7 +97,7 @@ Copyright (C) 2018-2020 The Hush developers This is experimental software!!! Distributed under the MIT software license, see the accompanying file COPYING -or . +or . This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit and cryptographic software written diff --git a/doc/man/hushd.1 b/doc/man/hushd.1 index 1d4d70cc3..e17db3d83 100644 --- a/doc/man/hushd.1 +++ b/doc/man/hushd.1 @@ -4,7 +4,7 @@ hushd \- manual page for hushd v3.5.0 .SH DESCRIPTION Found binary: ./komodod -Hush Daemon version v3.5.0\-beta6\-fab0f9494\-dirty +Hush Daemon version v3.5.0\-beta6\-cb09e7fed\-dirty .PP In order to ensure you are adequately protecting your privacy when using Hush, please see . @@ -645,7 +645,7 @@ Starting supply, default is 0 .IP Enforce transaction\-rate limit, default 0 .SH COPYRIGHT -Hush Daemon version v3.5.0-beta6-fab0f9494-dirty +Hush Daemon version v3.5.0-beta6-cb09e7fed-dirty In order to ensure you are adequately protecting your privacy when using Hush, please see . @@ -658,7 +658,7 @@ Copyright (C) 2018-2020 The Hush developers This is experimental software!!! Distributed under the MIT software license, see the accompanying file COPYING -or . +or . This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit and cryptographic software written diff --git a/qa/hush/create_wallet_200k_utxos.py b/qa/hush/create_wallet_200k_utxos.py index d4a1d9d48..4a8fea2a8 100644 --- a/qa/hush/create_wallet_200k_utxos.py +++ b/qa/hush/create_wallet_200k_utxos.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2017 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Create a large wallet diff --git a/qa/rpc-tests/ac_private.py b/qa/rpc-tests/ac_private.py index 9b462f50d..000d900dc 100755 --- a/qa/rpc-tests/ac_private.py +++ b/qa/rpc-tests/ac_private.py @@ -4,7 +4,7 @@ # Released under the GPLv3 # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.authproxy import JSONRPCException diff --git a/qa/rpc-tests/addressindex.py b/qa/rpc-tests/addressindex.py index 11fa7ffdb..be02aa43e 100755 --- a/qa/rpc-tests/addressindex.py +++ b/qa/rpc-tests/addressindex.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014-2015 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test addressindex generation and fetching diff --git a/qa/rpc-tests/bip65-cltv-p2p.py b/qa/rpc-tests/bip65-cltv-p2p.py index cfd2df01e..645507a4b 100755 --- a/qa/rpc-tests/bip65-cltv-p2p.py +++ b/qa/rpc-tests/bip65-cltv-p2p.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # # Distributed under the MIT/X11 software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # from test_framework.test_framework import ComparisonTestFramework diff --git a/qa/rpc-tests/bipdersig-p2p.py b/qa/rpc-tests/bipdersig-p2p.py index f254843f1..cbc42f85e 100755 --- a/qa/rpc-tests/bipdersig-p2p.py +++ b/qa/rpc-tests/bipdersig-p2p.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # # Distributed under the MIT/X11 software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # from test_framework.test_framework import ComparisonTestFramework diff --git a/qa/rpc-tests/blockchain.py b/qa/rpc-tests/blockchain.py index c37db8b84..7248a9a88 100755 --- a/qa/rpc-tests/blockchain.py +++ b/qa/rpc-tests/blockchain.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test RPC calls related to blockchain state. Tests correspond to code in diff --git a/qa/rpc-tests/cryptoconditions.py b/qa/rpc-tests/cryptoconditions.py index d5456e801..67f8db904 100755 --- a/qa/rpc-tests/cryptoconditions.py +++ b/qa/rpc-tests/cryptoconditions.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 SuperNET developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.authproxy import JSONRPCException diff --git a/qa/rpc-tests/cryptoconditions_channels.py b/qa/rpc-tests/cryptoconditions_channels.py index 7f82f2f3c..a832fbfed 100755 --- a/qa/rpc-tests/cryptoconditions_channels.py +++ b/qa/rpc-tests/cryptoconditions_channels.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 SuperNET developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php import time diff --git a/qa/rpc-tests/cryptoconditions_dice.py b/qa/rpc-tests/cryptoconditions_dice.py index 7b9d3fbae..cdb6f8a9e 100755 --- a/qa/rpc-tests/cryptoconditions_dice.py +++ b/qa/rpc-tests/cryptoconditions_dice.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 SuperNET developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import CryptoconditionsTestFramework diff --git a/qa/rpc-tests/cryptoconditions_faucet.py b/qa/rpc-tests/cryptoconditions_faucet.py index 27c5fce4e..6d72dac0c 100755 --- a/qa/rpc-tests/cryptoconditions_faucet.py +++ b/qa/rpc-tests/cryptoconditions_faucet.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 SuperNET developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import CryptoconditionsTestFramework diff --git a/qa/rpc-tests/cryptoconditions_gateways.py b/qa/rpc-tests/cryptoconditions_gateways.py index b12ea9f7e..d38baa941 100755 --- a/qa/rpc-tests/cryptoconditions_gateways.py +++ b/qa/rpc-tests/cryptoconditions_gateways.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 SuperNET developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import CryptoconditionsTestFramework diff --git a/qa/rpc-tests/cryptoconditions_heir.py b/qa/rpc-tests/cryptoconditions_heir.py index 12ca8b3da..2c273d394 100755 --- a/qa/rpc-tests/cryptoconditions_heir.py +++ b/qa/rpc-tests/cryptoconditions_heir.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 SuperNET developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php import time diff --git a/qa/rpc-tests/cryptoconditions_oracles.py b/qa/rpc-tests/cryptoconditions_oracles.py index 1db33bef7..347654979 100755 --- a/qa/rpc-tests/cryptoconditions_oracles.py +++ b/qa/rpc-tests/cryptoconditions_oracles.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 SuperNET developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import CryptoconditionsTestFramework from test_framework.authproxy import JSONRPCException diff --git a/qa/rpc-tests/cryptoconditions_rewards.py b/qa/rpc-tests/cryptoconditions_rewards.py index 57d3032b8..0444cba60 100755 --- a/qa/rpc-tests/cryptoconditions_rewards.py +++ b/qa/rpc-tests/cryptoconditions_rewards.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 SuperNET developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import CryptoconditionsTestFramework diff --git a/qa/rpc-tests/cryptoconditions_token.py b/qa/rpc-tests/cryptoconditions_token.py index 263d85dde..774dbe0ec 100755 --- a/qa/rpc-tests/cryptoconditions_token.py +++ b/qa/rpc-tests/cryptoconditions_token.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 SuperNET developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import CryptoconditionsTestFramework diff --git a/qa/rpc-tests/decodescript.py b/qa/rpc-tests/decodescript.py index 293fd0ebb..ff3c83097 100755 --- a/qa/rpc-tests/decodescript.py +++ b/qa/rpc-tests/decodescript.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2015 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, initialize_chain_clean, \ diff --git a/qa/rpc-tests/disablewallet.py b/qa/rpc-tests/disablewallet.py index 339c6a8f6..ab5ec14f9 100755 --- a/qa/rpc-tests/disablewallet.py +++ b/qa/rpc-tests/disablewallet.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Exercise API with -disablewallet. diff --git a/qa/rpc-tests/dpowconfs.py b/qa/rpc-tests/dpowconfs.py index 24b328da6..491b9f25d 100755 --- a/qa/rpc-tests/dpowconfs.py +++ b/qa/rpc-tests/dpowconfs.py @@ -2,7 +2,7 @@ # Copyright (c) 2018-2019 The Hush developers # Copyright (c) 2019 The SuperNET developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import * diff --git a/qa/rpc-tests/finalsaplingroot.py b/qa/rpc-tests/finalsaplingroot.py index 83f16edec..aa05fb870 100755 --- a/qa/rpc-tests/finalsaplingroot.py +++ b/qa/rpc-tests/finalsaplingroot.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import ( diff --git a/qa/rpc-tests/forknotify.py b/qa/rpc-tests/forknotify.py index 1be750a64..f61a21412 100755 --- a/qa/rpc-tests/forknotify.py +++ b/qa/rpc-tests/forknotify.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test -alertnotify diff --git a/qa/rpc-tests/fundrawtransaction.py b/qa/rpc-tests/fundrawtransaction.py index 42896be4f..4c3c92356 100755 --- a/qa/rpc-tests/fundrawtransaction.py +++ b/qa/rpc-tests/fundrawtransaction.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.authproxy import JSONRPCException diff --git a/qa/rpc-tests/getblocktemplate.py b/qa/rpc-tests/getblocktemplate.py index af050110e..013836b1e 100755 --- a/qa/rpc-tests/getblocktemplate.py +++ b/qa/rpc-tests/getblocktemplate.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2016 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, connect_nodes_bi, \ diff --git a/qa/rpc-tests/getblocktemplate_longpoll.py b/qa/rpc-tests/getblocktemplate_longpoll.py index 37a40384b..20ff4a6ad 100755 --- a/qa/rpc-tests/getblocktemplate_longpoll.py +++ b/qa/rpc-tests/getblocktemplate_longpoll.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.authproxy import AuthServiceProxy diff --git a/qa/rpc-tests/getblocktemplate_proposals.py b/qa/rpc-tests/getblocktemplate_proposals.py index 16b2e9b94..450e13cfa 100755 --- a/qa/rpc-tests/getblocktemplate_proposals.py +++ b/qa/rpc-tests/getblocktemplate_proposals.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.authproxy import JSONRPCException diff --git a/qa/rpc-tests/getchaintips.py b/qa/rpc-tests/getchaintips.py index 6a2bcb296..2a90b2a2a 100755 --- a/qa/rpc-tests/getchaintips.py +++ b/qa/rpc-tests/getchaintips.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # Exercise the getchaintips API. We introduce a network split, work # on chains of different lengths, and join the network together again. diff --git a/qa/rpc-tests/httpbasics.py b/qa/rpc-tests/httpbasics.py index b1a4623bd..2170a7b8e 100755 --- a/qa/rpc-tests/httpbasics.py +++ b/qa/rpc-tests/httpbasics.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test rpc http basics diff --git a/qa/rpc-tests/invalidateblock.py b/qa/rpc-tests/invalidateblock.py index 5cbd1ea98..6c9f15d38 100755 --- a/qa/rpc-tests/invalidateblock.py +++ b/qa/rpc-tests/invalidateblock.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test InvalidateBlock code diff --git a/qa/rpc-tests/invalidblockrequest.py b/qa/rpc-tests/invalidblockrequest.py index 05b33d772..16030c3b4 100755 --- a/qa/rpc-tests/invalidblockrequest.py +++ b/qa/rpc-tests/invalidblockrequest.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # # Distributed under the MIT/X11 software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # from test_framework.test_framework import ComparisonTestFramework diff --git a/qa/rpc-tests/ivk_import_export.py b/qa/rpc-tests/ivk_import_export.py index 0546b0a44..ccaa05bd2 100755 --- a/qa/rpc-tests/ivk_import_export.py +++ b/qa/rpc-tests/ivk_import_export.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2019 Bartlomiej Lisiecki # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from decimal import Decimal from test_framework.test_framework import BitcoinTestFramework diff --git a/qa/rpc-tests/key_import_export.py b/qa/rpc-tests/key_import_export.py index 87b2daa2b..7b5c042a8 100755 --- a/qa/rpc-tests/key_import_export.py +++ b/qa/rpc-tests/key_import_export.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2017 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from decimal import Decimal from test_framework.test_framework import BitcoinTestFramework diff --git a/qa/rpc-tests/keypool.py b/qa/rpc-tests/keypool.py index a7b32e13f..54a022324 100755 --- a/qa/rpc-tests/keypool.py +++ b/qa/rpc-tests/keypool.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # Exercise the wallet keypool, and interaction with wallet encryption/locking diff --git a/qa/rpc-tests/listtransactions.py b/qa/rpc-tests/listtransactions.py index a735f41ab..07444741b 100755 --- a/qa/rpc-tests/listtransactions.py +++ b/qa/rpc-tests/listtransactions.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # Exercise the listtransactions API diff --git a/qa/rpc-tests/maxblocksinflight.py b/qa/rpc-tests/maxblocksinflight.py index beef3d2ea..e38f49c7b 100755 --- a/qa/rpc-tests/maxblocksinflight.py +++ b/qa/rpc-tests/maxblocksinflight.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # # Distributed under the MIT/X11 software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # from test_framework.mininode import NodeConn, NodeConnCB, NetworkThread, \ diff --git a/qa/rpc-tests/mempool_nu_activation.py b/qa/rpc-tests/mempool_nu_activation.py index 2ed238c65..71fba44b5 100755 --- a/qa/rpc-tests/mempool_nu_activation.py +++ b/qa/rpc-tests/mempool_nu_activation.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, initialize_chain_clean, \ diff --git a/qa/rpc-tests/mempool_reorg.py b/qa/rpc-tests/mempool_reorg.py index ad12dadf2..b0bb2a7e1 100755 --- a/qa/rpc-tests/mempool_reorg.py +++ b/qa/rpc-tests/mempool_reorg.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test re-org scenarios with a mempool that contains transactions diff --git a/qa/rpc-tests/mempool_resurrect_test.py b/qa/rpc-tests/mempool_resurrect_test.py index faa97d461..975f6bac2 100755 --- a/qa/rpc-tests/mempool_resurrect_test.py +++ b/qa/rpc-tests/mempool_resurrect_test.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test resurrection of mined transactions when diff --git a/qa/rpc-tests/mempool_spendcoinbase.py b/qa/rpc-tests/mempool_spendcoinbase.py index 5366fb955..22c8ef88a 100755 --- a/qa/rpc-tests/mempool_spendcoinbase.py +++ b/qa/rpc-tests/mempool_spendcoinbase.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test spending coinbase transactions. diff --git a/qa/rpc-tests/mempool_tx_expiry.py b/qa/rpc-tests/mempool_tx_expiry.py index b5ee4bd2a..7abebd643 100755 --- a/qa/rpc-tests/mempool_tx_expiry.py +++ b/qa/rpc-tests/mempool_tx_expiry.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test proper expiry for transactions >= version 3 diff --git a/qa/rpc-tests/mempool_tx_input_limit.py b/qa/rpc-tests/mempool_tx_input_limit.py index 9a7131cfe..861cb0423 100755 --- a/qa/rpc-tests/mempool_tx_input_limit.py +++ b/qa/rpc-tests/mempool_tx_input_limit.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2017 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.authproxy import JSONRPCException diff --git a/qa/rpc-tests/merkle_blocks.py b/qa/rpc-tests/merkle_blocks.py index 13b98e140..b9613bf0f 100755 --- a/qa/rpc-tests/merkle_blocks.py +++ b/qa/rpc-tests/merkle_blocks.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test merkleblock fetch/validation diff --git a/qa/rpc-tests/nodehandling.py b/qa/rpc-tests/nodehandling.py index 391a935d0..4e9eb5d8f 100755 --- a/qa/rpc-tests/nodehandling.py +++ b/qa/rpc-tests/nodehandling.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test node handling diff --git a/qa/rpc-tests/p2p-acceptblock.py b/qa/rpc-tests/p2p-acceptblock.py index 25221fbed..0a71f2eb3 100755 --- a/qa/rpc-tests/p2p-acceptblock.py +++ b/qa/rpc-tests/p2p-acceptblock.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # # Distributed under the MIT/X11 software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # from test_framework.mininode import CBlockHeader, CInv, NodeConn, NodeConnCB, \ diff --git a/qa/rpc-tests/p2p_node_bloom.py b/qa/rpc-tests/p2p_node_bloom.py index 18476a981..8b9687d3a 100755 --- a/qa/rpc-tests/p2p_node_bloom.py +++ b/qa/rpc-tests/p2p_node_bloom.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.mininode import NodeConn, NodeConnCB, NetworkThread, \ msg_filteradd, msg_filterclear, mininode_lock, SPROUT_PROTO_VERSION diff --git a/qa/rpc-tests/p2p_txexpiry_dos.py b/qa/rpc-tests/p2p_txexpiry_dos.py index ec970435a..0ee0718a1 100755 --- a/qa/rpc-tests/p2p_txexpiry_dos.py +++ b/qa/rpc-tests/p2p_txexpiry_dos.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.mininode import NodeConn, NodeConnCB, NetworkThread, \ CTransaction, msg_tx, mininode_lock, OVERWINTER_PROTO_VERSION diff --git a/qa/rpc-tests/prioritisetransaction.py b/qa/rpc-tests/prioritisetransaction.py index 134b9b160..94424ce51 100755 --- a/qa/rpc-tests/prioritisetransaction.py +++ b/qa/rpc-tests/prioritisetransaction.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2017 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, initialize_chain_clean, \ diff --git a/qa/rpc-tests/proxy_test.py b/qa/rpc-tests/proxy_test.py index e4fb48820..2678dd6c9 100755 --- a/qa/rpc-tests/proxy_test.py +++ b/qa/rpc-tests/proxy_test.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2015 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.socks5 import Socks5Configuration, Socks5Command, Socks5Server, AddressType from test_framework.test_framework import BitcoinTestFramework diff --git a/qa/rpc-tests/pruning.py b/qa/rpc-tests/pruning.py index 2639060fa..7cab0fc9c 100755 --- a/qa/rpc-tests/pruning.py +++ b/qa/rpc-tests/pruning.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test pruning code diff --git a/qa/rpc-tests/rawtransactions.py b/qa/rpc-tests/rawtransactions.py index 182f87f08..4b9ed5ef0 100755 --- a/qa/rpc-tests/rawtransactions.py +++ b/qa/rpc-tests/rawtransactions.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test re-org scenarios with a mempool that contains transactions diff --git a/qa/rpc-tests/receivedby.py b/qa/rpc-tests/receivedby.py index 59f7bf258..9e60cb639 100755 --- a/qa/rpc-tests/receivedby.py +++ b/qa/rpc-tests/receivedby.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # Exercise the listreceivedbyaddress API diff --git a/qa/rpc-tests/regtest_signrawtransaction.py b/qa/rpc-tests/regtest_signrawtransaction.py index 78ec1fbc8..26e66bd9b 100755 --- a/qa/rpc-tests/regtest_signrawtransaction.py +++ b/qa/rpc-tests/regtest_signrawtransaction.py @@ -2,7 +2,7 @@ # Copyright (c) 2019-2020 The Hush developers # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import start_nodes, wait_and_assert_operationid_status diff --git a/qa/rpc-tests/rest.py b/qa/rpc-tests/rest.py index b14ec765d..afdf7c4d2 100755 --- a/qa/rpc-tests/rest.py +++ b/qa/rpc-tests/rest.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test REST interface diff --git a/qa/rpc-tests/rewind_index.py b/qa/rpc-tests/rewind_index.py index 8c5c606df..a96c190e9 100755 --- a/qa/rpc-tests/rewind_index.py +++ b/qa/rpc-tests/rewind_index.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, initialize_chain_clean, \ diff --git a/qa/rpc-tests/rpcbind_test.py b/qa/rpc-tests/rpcbind_test.py index 72e14d655..df2f5a0ef 100755 --- a/qa/rpc-tests/rpcbind_test.py +++ b/qa/rpc-tests/rpcbind_test.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # Test for -rpcbind, as well as -rpcallowip and -rpcconnect diff --git a/qa/rpc-tests/script_test.py b/qa/rpc-tests/script_test.py index c3ad541e5..b0f78a20d 100755 --- a/qa/rpc-tests/script_test.py +++ b/qa/rpc-tests/script_test.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # # Distributed under the MIT/X11 software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # ''' diff --git a/qa/rpc-tests/signrawtransactions.py b/qa/rpc-tests/signrawtransactions.py index 95d242854..3fe32f03a 100755 --- a/qa/rpc-tests/signrawtransactions.py +++ b/qa/rpc-tests/signrawtransactions.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2015 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, initialize_chain_clean, \ diff --git a/qa/rpc-tests/smartfees.py b/qa/rpc-tests/smartfees.py index e111a406b..b20847868 100755 --- a/qa/rpc-tests/smartfees.py +++ b/qa/rpc-tests/smartfees.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014-2015 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test fee estimation code diff --git a/qa/rpc-tests/spentindex.py b/qa/rpc-tests/spentindex.py index ebe2b8cc2..672b8b2e7 100755 --- a/qa/rpc-tests/spentindex.py +++ b/qa/rpc-tests/spentindex.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014-2015 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test addressindex generation and fetching diff --git a/qa/rpc-tests/test_framework/bignum.py b/qa/rpc-tests/test_framework/bignum.py index b0c58ccd4..f77e36824 100644 --- a/qa/rpc-tests/test_framework/bignum.py +++ b/qa/rpc-tests/test_framework/bignum.py @@ -5,7 +5,7 @@ # This file is copied from python-bitcoinlib. # # Distributed under the MIT/X11 software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # """Bignum routines""" diff --git a/qa/rpc-tests/test_framework/blocktools.py b/qa/rpc-tests/test_framework/blocktools.py index 1fe2a5dda..fbcc9a36f 100644 --- a/qa/rpc-tests/test_framework/blocktools.py +++ b/qa/rpc-tests/test_framework/blocktools.py @@ -1,7 +1,7 @@ # blocktools.py - utilities for manipulating blocks and transactions # # Distributed under the MIT/X11 software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # from mininode import CBlock, CTransaction, CTxIn, CTxOut, COutPoint diff --git a/qa/rpc-tests/test_framework/comptool.py b/qa/rpc-tests/test_framework/comptool.py index 7f9a97d68..d38595ba1 100755 --- a/qa/rpc-tests/test_framework/comptool.py +++ b/qa/rpc-tests/test_framework/comptool.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # # Distributed under the MIT/X11 software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # from mininode import CBlock, CTransaction, CInv, NodeConn, NodeConnCB, \ diff --git a/qa/rpc-tests/test_framework/netutil.py b/qa/rpc-tests/test_framework/netutil.py index b30a88a4f..bd71d21cf 100644 --- a/qa/rpc-tests/test_framework/netutil.py +++ b/qa/rpc-tests/test_framework/netutil.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # Linux network utilities import sys diff --git a/qa/rpc-tests/test_framework/script.py b/qa/rpc-tests/test_framework/script.py index 55a7f8e51..5c81f84d1 100644 --- a/qa/rpc-tests/test_framework/script.py +++ b/qa/rpc-tests/test_framework/script.py @@ -4,7 +4,7 @@ # This file is modified from python-bitcoinlib. # # Distributed under the MIT/X11 software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # """Scripts diff --git a/qa/rpc-tests/test_framework/socks5.py b/qa/rpc-tests/test_framework/socks5.py index 1dbfb98d5..bc4cd466a 100644 --- a/qa/rpc-tests/test_framework/socks5.py +++ b/qa/rpc-tests/test_framework/socks5.py @@ -1,6 +1,6 @@ # Copyright (c) 2015 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php ''' Dummy Socks5 server for testing. ''' diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py index 78c66089a..b6fe49625 100644 --- a/qa/rpc-tests/test_framework/util.py +++ b/qa/rpc-tests/test_framework/util.py @@ -2,7 +2,7 @@ # Copyright (c) 2018-2019 The SuperNET developers # Copyright (c) 2018-2020 The Hush developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Helpful routines for regression testing # diff --git a/qa/rpc-tests/txindex.py b/qa/rpc-tests/txindex.py index e59b6d7d9..aa3fb69b2 100755 --- a/qa/rpc-tests/txindex.py +++ b/qa/rpc-tests/txindex.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014-2015 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test txindex generation and fetching diff --git a/qa/rpc-tests/txn_doublespend.py b/qa/rpc-tests/txn_doublespend.py index bbe383d16..ce3b7713a 100755 --- a/qa/rpc-tests/txn_doublespend.py +++ b/qa/rpc-tests/txn_doublespend.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test proper accounting with malleable transactions diff --git a/qa/rpc-tests/wallet.py b/qa/rpc-tests/wallet.py index 0268dd292..c0c407bde 100755 --- a/qa/rpc-tests/wallet.py +++ b/qa/rpc-tests/wallet.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework diff --git a/qa/rpc-tests/wallet_1941.py b/qa/rpc-tests/wallet_1941.py index 6f90f33bd..b3033d8ed 100755 --- a/qa/rpc-tests/wallet_1941.py +++ b/qa/rpc-tests/wallet_1941.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2016 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # This is a regression test for #1941. diff --git a/qa/rpc-tests/wallet_addresses.py b/qa/rpc-tests/wallet_addresses.py index 0b9669972..dffdc2bd6 100755 --- a/qa/rpc-tests/wallet_addresses.py +++ b/qa/rpc-tests/wallet_addresses.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, start_nodes diff --git a/qa/rpc-tests/wallet_anchorfork.py b/qa/rpc-tests/wallet_anchorfork.py index 1cb16e152..17f342b1b 100755 --- a/qa/rpc-tests/wallet_anchorfork.py +++ b/qa/rpc-tests/wallet_anchorfork.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, initialize_chain_clean, \ diff --git a/qa/rpc-tests/wallet_changeindicator.py b/qa/rpc-tests/wallet_changeindicator.py index 428d0c508..98591405b 100755 --- a/qa/rpc-tests/wallet_changeindicator.py +++ b/qa/rpc-tests/wallet_changeindicator.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, assert_true, assert_false, wait_and_assert_operationid_status diff --git a/qa/rpc-tests/wallet_import_export.py b/qa/rpc-tests/wallet_import_export.py index cdcc01d1f..2b4c25a66 100755 --- a/qa/rpc-tests/wallet_import_export.py +++ b/qa/rpc-tests/wallet_import_export.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, assert_true, start_nodes diff --git a/qa/rpc-tests/wallet_listnotes.py b/qa/rpc-tests/wallet_listnotes.py index 90fbcced1..2a1aa8fce 100755 --- a/qa/rpc-tests/wallet_listnotes.py +++ b/qa/rpc-tests/wallet_listnotes.py @@ -2,7 +2,7 @@ # Copyright (c) 2019-2020 The Hush developers # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, start_nodes, wait_and_assert_operationid_status diff --git a/qa/rpc-tests/wallet_listreceived.py b/qa/rpc-tests/wallet_listreceived.py index ec9ac9371..dbc8a3fa9 100755 --- a/qa/rpc-tests/wallet_listreceived.py +++ b/qa/rpc-tests/wallet_listreceived.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, assert_true, assert_false diff --git a/qa/rpc-tests/wallet_mergetoaddress.py b/qa/rpc-tests/wallet_mergetoaddress.py index e5d5089a4..61cf8baef 100755 --- a/qa/rpc-tests/wallet_mergetoaddress.py +++ b/qa/rpc-tests/wallet_mergetoaddress.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2017 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.authproxy import JSONRPCException diff --git a/qa/rpc-tests/wallet_nullifiers.py b/qa/rpc-tests/wallet_nullifiers.py index 9b4e5649c..9da25ce45 100755 --- a/qa/rpc-tests/wallet_nullifiers.py +++ b/qa/rpc-tests/wallet_nullifiers.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2016 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework diff --git a/qa/rpc-tests/wallet_overwintertx.py b/qa/rpc-tests/wallet_overwintertx.py index d77a114db..3969927a4 100755 --- a/qa/rpc-tests/wallet_overwintertx.py +++ b/qa/rpc-tests/wallet_overwintertx.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import assert_equal, initialize_chain_clean, \ diff --git a/qa/rpc-tests/wallet_persistence.py b/qa/rpc-tests/wallet_persistence.py index 581cad473..190509a58 100755 --- a/qa/rpc-tests/wallet_persistence.py +++ b/qa/rpc-tests/wallet_persistence.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2018 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.util import ( diff --git a/qa/rpc-tests/wallet_protectcoinbase.py b/qa/rpc-tests/wallet_protectcoinbase.py index 71512840d..b181c02c6 100755 --- a/qa/rpc-tests/wallet_protectcoinbase.py +++ b/qa/rpc-tests/wallet_protectcoinbase.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2016 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework diff --git a/qa/rpc-tests/wallet_shieldcoinbase.py b/qa/rpc-tests/wallet_shieldcoinbase.py index f325b29ca..8f24a2587 100755 --- a/qa/rpc-tests/wallet_shieldcoinbase.py +++ b/qa/rpc-tests/wallet_shieldcoinbase.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2017 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.authproxy import JSONRPCException diff --git a/qa/rpc-tests/wallet_treestate.py b/qa/rpc-tests/wallet_treestate.py index b3edcd7c5..d965558a2 100755 --- a/qa/rpc-tests/wallet_treestate.py +++ b/qa/rpc-tests/wallet_treestate.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2016 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework diff --git a/qa/rpc-tests/walletbackup.py b/qa/rpc-tests/walletbackup.py index 78128ad49..b552cf961 100755 --- a/qa/rpc-tests/walletbackup.py +++ b/qa/rpc-tests/walletbackup.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php """ Exercise the wallet backup code. Ported from walletbackup.sh. diff --git a/qa/rpc-tests/zapwallettxes.py b/qa/rpc-tests/zapwallettxes.py index 5da4ba125..a61f18ebb 100755 --- a/qa/rpc-tests/zapwallettxes.py +++ b/qa/rpc-tests/zapwallettxes.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2014 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from test_framework.test_framework import BitcoinTestFramework from test_framework.authproxy import JSONRPCException diff --git a/qa/rpc-tests/zkey_import_export.py b/qa/rpc-tests/zkey_import_export.py index 775233b6d..aeae9aa9f 100755 --- a/qa/rpc-tests/zkey_import_export.py +++ b/qa/rpc-tests/zkey_import_export.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2017 The Zcash developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php from decimal import Decimal from test_framework.test_framework import BitcoinTestFramework diff --git a/qa/rpc-tests/zmq_test.py b/qa/rpc-tests/zmq_test.py index dcb899861..117d16048 100755 --- a/qa/rpc-tests/zmq_test.py +++ b/qa/rpc-tests/zmq_test.py @@ -1,7 +1,7 @@ #!/usr/bin/env python2 # Copyright (c) 2015 The Bitcoin Core developers # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php # # Test ZMQ interface diff --git a/src/addressindex.h b/src/addressindex.h index d22426ed6..804dd57cd 100644 --- a/src/addressindex.h +++ b/src/addressindex.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2015 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_ADDRESSINDEX_H #define BITCOIN_ADDRESSINDEX_H diff --git a/src/addrman.cpp b/src/addrman.cpp index 3ff108c44..2f02f3b17 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2012 Pieter Wuille // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/alert.h b/src/alert.h index d8d762b00..01bec7fdd 100644 --- a/src/alert.h +++ b/src/alert.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2013 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/amount.cpp b/src/amount.cpp index 3feb37ccc..874d0dc72 100644 --- a/src/amount.cpp +++ b/src/amount.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/amount.h b/src/amount.h index c5f49593c..942b22e69 100644 --- a/src/amount.h +++ b/src/amount.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/arith_uint256.cpp b/src/arith_uint256.cpp index d7a5c0afe..23c897f5f 100644 --- a/src/arith_uint256.cpp +++ b/src/arith_uint256.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/arith_uint256.h b/src/arith_uint256.h index f7bc8a585..223e97be5 100644 --- a/src/arith_uint256.h +++ b/src/arith_uint256.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/asyncrpcoperation.cpp b/src/asyncrpcoperation.cpp index 75c8da9e6..dd4e481da 100644 --- a/src/asyncrpcoperation.cpp +++ b/src/asyncrpcoperation.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2016 The Zcash developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/asyncrpcoperation.h b/src/asyncrpcoperation.h index 5dc102366..5c6125df7 100644 --- a/src/asyncrpcoperation.h +++ b/src/asyncrpcoperation.h @@ -1,7 +1,7 @@ // Copyright (c) 2016 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/asyncrpcqueue.cpp b/src/asyncrpcqueue.cpp index 5bcb20f8d..bb7532ad0 100644 --- a/src/asyncrpcqueue.cpp +++ b/src/asyncrpcqueue.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2016 The Zcash developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/asyncrpcqueue.h b/src/asyncrpcqueue.h index 32e091aff..ac42270e3 100644 --- a/src/asyncrpcqueue.h +++ b/src/asyncrpcqueue.h @@ -1,7 +1,7 @@ // Copyright (c) 2016 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/base58.cpp b/src/base58.cpp index 383666d82..c270e5473 100644 --- a/src/base58.cpp +++ b/src/base58.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/base58.h b/src/base58.h index 8be0247e0..dbedc677f 100644 --- a/src/base58.h +++ b/src/base58.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/bitcoin-tx-res.rc b/src/bitcoin-tx-res.rc index cb540fdc1..a1b64f529 100644 --- a/src/bitcoin-tx-res.rc +++ b/src/bitcoin-tx-res.rc @@ -21,7 +21,7 @@ BEGIN VALUE "FileVersion", VER_FILEVERSION_STR VALUE "InternalName", "hush-tx" VALUE "LegalCopyright", COPYRIGHT_STR - VALUE "LegalTrademarks1", "Distributed under the MIT software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php." + VALUE "LegalTrademarks1", "Distributed under the MIT software license, see the accompanying file COPYING or https://www.opensource.org/licenses/mit-license.php" VALUE "OriginalFilename", "hush-tx.exe" VALUE "ProductName", "hush-tx" VALUE "ProductVersion", VER_PRODUCTVERSION_STR diff --git a/src/bitcoind-res.rc b/src/bitcoind-res.rc index 246ba98ac..4e9f11470 100644 --- a/src/bitcoind-res.rc +++ b/src/bitcoind-res.rc @@ -21,7 +21,7 @@ BEGIN VALUE "FileVersion", VER_FILEVERSION_STR VALUE "InternalName", "komodod" VALUE "LegalCopyright", COPYRIGHT_STR - VALUE "LegalTrademarks1", "Distributed under the MIT software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php." + VALUE "LegalTrademarks1", "Distributed under the MIT software license, see the accompanying file COPYING or https://www.opensource.org/licenses/mit-license.php" VALUE "OriginalFilename", "komodod.exe" VALUE "ProductName", "komodod" VALUE "ProductVersion", VER_PRODUCTVERSION_STR diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index f8dac619b..ac9a94d46 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2013 The Bitcoin Core developers // Copyright (c) 2019 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/bloom.cpp b/src/bloom.cpp index d7a7742fe..dbef9b97a 100644 --- a/src/bloom.cpp +++ b/src/bloom.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/bloom.h b/src/bloom.h index e4677d6d0..c5df9f4be 100644 --- a/src/bloom.h +++ b/src/bloom.h @@ -1,6 +1,6 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/chain.cpp b/src/chain.cpp index f8530056d..50bacf9ac 100644 --- a/src/chain.cpp +++ b/src/chain.cpp @@ -3,7 +3,7 @@ // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/chain.h b/src/chain.h index 77d17114e..4f8d20b0d 100644 --- a/src/chain.h +++ b/src/chain.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/chainparams.cpp b/src/chainparams.cpp index c773916ff..6f2f81225 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/chainparams.h b/src/chainparams.h index 7bd1057ec..3cbca2f9b 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/chainparamsbase.cpp b/src/chainparamsbase.cpp index 4ec957ba1..ad08fd314 100644 --- a/src/chainparamsbase.cpp +++ b/src/chainparamsbase.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/chainparamsbase.h b/src/chainparamsbase.h index 94e3a4238..68e15dc06 100644 --- a/src/chainparamsbase.h +++ b/src/chainparamsbase.h @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index 73a514262..50c1dd992 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/checkpoints.h b/src/checkpoints.h index 6e2f62c5d..2c8e9943a 100644 --- a/src/checkpoints.h +++ b/src/checkpoints.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/checkqueue.h b/src/checkqueue.h index f81bb49c7..9c09dfdc1 100644 --- a/src/checkqueue.h +++ b/src/checkqueue.h @@ -1,7 +1,7 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/clientversion.cpp b/src/clientversion.cpp index b490e9f9e..aa3a02198 100644 --- a/src/clientversion.cpp +++ b/src/clientversion.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/clientversion.h b/src/clientversion.h index 3e570841e..1b82e158b 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -2,7 +2,7 @@ // Copyright (c) 2016-2017 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/coincontrol.h b/src/coincontrol.h index 2daa95919..38cc9fc96 100644 --- a/src/coincontrol.h +++ b/src/coincontrol.h @@ -1,7 +1,7 @@ // Copyright (c) 2011-2013 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/coins.cpp b/src/coins.cpp index 03b046a70..3f96cead9 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/coins.h b/src/coins.h index 2d08be42c..bebd99f77 100644 --- a/src/coins.h +++ b/src/coins.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/compat.h b/src/compat.h index 44b7dcee2..53f08d928 100644 --- a/src/compat.h +++ b/src/compat.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/compat/byteswap.h b/src/compat/byteswap.h index 899220bdc..70832d157 100644 --- a/src/compat/byteswap.h +++ b/src/compat/byteswap.h @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_COMPAT_BYTESWAP_H #define BITCOIN_COMPAT_BYTESWAP_H diff --git a/src/compat/endian.h b/src/compat/endian.h index 9fec2a07f..faf83fa48 100644 --- a/src/compat/endian.h +++ b/src/compat/endian.h @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_COMPAT_ENDIAN_H #define BITCOIN_COMPAT_ENDIAN_H diff --git a/src/compat/glibc_compat.cpp b/src/compat/glibc_compat.cpp index 3b9c70df7..9edc33d27 100644 --- a/src/compat/glibc_compat.cpp +++ b/src/compat/glibc_compat.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #if defined(HAVE_CONFIG_H) #include "config/bitcoin-config.h" diff --git a/src/compat/glibc_sanity.cpp b/src/compat/glibc_sanity.cpp index d62d74d46..9103be293 100644 --- a/src/compat/glibc_sanity.cpp +++ b/src/compat/glibc_sanity.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #if defined(HAVE_CONFIG_H) #include "config/bitcoin-config.h" diff --git a/src/compat/glibcxx_sanity.cpp b/src/compat/glibcxx_sanity.cpp index cee8a98c7..800ea93e2 100644 --- a/src/compat/glibcxx_sanity.cpp +++ b/src/compat/glibcxx_sanity.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include #include diff --git a/src/compat/sanity.h b/src/compat/sanity.h index 909c4f6da..90536fcc5 100644 --- a/src/compat/sanity.h +++ b/src/compat/sanity.h @@ -1,6 +1,6 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_COMPAT_SANITY_H #define BITCOIN_COMPAT_SANITY_H diff --git a/src/compat/strnlen.cpp b/src/compat/strnlen.cpp index 1ac266c2d..db7acc1fa 100644 --- a/src/compat/strnlen.cpp +++ b/src/compat/strnlen.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #if defined(HAVE_CONFIG_H) #include "config/bitcoin-config.h" diff --git a/src/compressor.cpp b/src/compressor.cpp index e3479474d..86dbcc562 100644 --- a/src/compressor.cpp +++ b/src/compressor.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/compressor.h b/src/compressor.h index f4e4a256d..e1626410e 100644 --- a/src/compressor.h +++ b/src/compressor.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/consensus/consensus.h b/src/consensus/consensus.h index eba39b644..8613c89e7 100644 --- a/src/consensus/consensus.h +++ b/src/consensus/consensus.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/consensus/upgrades.cpp b/src/consensus/upgrades.cpp index 984ca377e..f7a4ffe8f 100644 --- a/src/consensus/upgrades.cpp +++ b/src/consensus/upgrades.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2019-2020 The Hush developers // Copyright (c) 2018 The Zcash developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/consensus/upgrades.h b/src/consensus/upgrades.h index 38eadc9ef..912968508 100644 --- a/src/consensus/upgrades.h +++ b/src/consensus/upgrades.h @@ -1,6 +1,6 @@ // Copyright (c) 2018 The Zcash developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/consensus/validation.h b/src/consensus/validation.h index a3d718c05..52a30cfd1 100644 --- a/src/consensus/validation.h +++ b/src/consensus/validation.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/core_io.h b/src/core_io.h index dbf30b9e9..4627aa7b2 100644 --- a/src/core_io.h +++ b/src/core_io.h @@ -1,6 +1,6 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/core_memusage.h b/src/core_memusage.h index b2f4a28ae..3b53d320d 100644 --- a/src/core_memusage.h +++ b/src/core_memusage.h @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_CORE_MEMUSAGE_H #define BITCOIN_CORE_MEMUSAGE_H diff --git a/src/core_read.cpp b/src/core_read.cpp index 9817a2165..e0366c2fc 100644 --- a/src/core_read.cpp +++ b/src/core_read.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/core_write.cpp b/src/core_write.cpp index 780540027..63cb51dae 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/crypto/common.h b/src/crypto/common.h index 12bdbec19..130f78fa9 100644 --- a/src/crypto/common.h +++ b/src/crypto/common.h @@ -2,7 +2,7 @@ // Copyright (c) 2019-2020 The Hush developers // Released under the GPLv3 // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_CRYPTO_COMMON_H #define BITCOIN_CRYPTO_COMMON_H diff --git a/src/crypto/ctaes/ctaes.c b/src/crypto/ctaes/ctaes.c index 55962bf25..a21b9f3ee 100644 --- a/src/crypto/ctaes/ctaes.c +++ b/src/crypto/ctaes/ctaes.c @@ -1,7 +1,7 @@ /********************************************************************* * Copyright (c) 2016 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ /* Constant time, unoptimized, concise, plain C, AES implementation diff --git a/src/crypto/ctaes/ctaes.h b/src/crypto/ctaes/ctaes.h index 2f0af0421..eb9d24176 100644 --- a/src/crypto/ctaes/ctaes.h +++ b/src/crypto/ctaes/ctaes.h @@ -1,7 +1,7 @@ /********************************************************************* * Copyright (c) 2016 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef _CTAES_H_ diff --git a/src/crypto/ctaes/test.c b/src/crypto/ctaes/test.c index 21439a16f..f13d02685 100644 --- a/src/crypto/ctaes/test.c +++ b/src/crypto/ctaes/test.c @@ -1,7 +1,7 @@ /********************************************************************* * Copyright (c) 2016 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include "ctaes.h" diff --git a/src/crypto/equihash.cpp b/src/crypto/equihash.cpp index 9a16fc085..aef2effa4 100644 --- a/src/crypto/equihash.cpp +++ b/src/crypto/equihash.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2016 Jack Grigg // Copyright (c) 2016 The Zcash developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php // Implementation of the Equihash Proof-of-Work algorithm. // diff --git a/src/crypto/equihash.h b/src/crypto/equihash.h index 533e0d512..3d04cc3f5 100644 --- a/src/crypto/equihash.h +++ b/src/crypto/equihash.h @@ -1,7 +1,7 @@ // Copyright (c) 2016 Jack Grigg // Copyright (c) 2016 The Zcash developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_EQUIHASH_H #define BITCOIN_EQUIHASH_H diff --git a/src/crypto/equihash.tcc b/src/crypto/equihash.tcc index 625749e47..a5fcbc4cc 100644 --- a/src/crypto/equihash.tcc +++ b/src/crypto/equihash.tcc @@ -1,7 +1,7 @@ // Copyright (c) 2016 Jack Grigg // Copyright (c) 2016 The Zcash developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include #include diff --git a/src/crypto/hmac_sha256.cpp b/src/crypto/hmac_sha256.cpp index 3c791625d..6ce7721de 100644 --- a/src/crypto/hmac_sha256.cpp +++ b/src/crypto/hmac_sha256.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "crypto/hmac_sha256.h" diff --git a/src/crypto/hmac_sha256.h b/src/crypto/hmac_sha256.h index 1519c1457..502b72326 100644 --- a/src/crypto/hmac_sha256.h +++ b/src/crypto/hmac_sha256.h @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_CRYPTO_HMAC_SHA256_H #define BITCOIN_CRYPTO_HMAC_SHA256_H diff --git a/src/crypto/hmac_sha512.cpp b/src/crypto/hmac_sha512.cpp index 5939c6ec4..c34dd1925 100644 --- a/src/crypto/hmac_sha512.cpp +++ b/src/crypto/hmac_sha512.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "crypto/hmac_sha512.h" diff --git a/src/crypto/hmac_sha512.h b/src/crypto/hmac_sha512.h index 17dee61ea..d53dcf1a2 100644 --- a/src/crypto/hmac_sha512.h +++ b/src/crypto/hmac_sha512.h @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_CRYPTO_HMAC_SHA512_H #define BITCOIN_CRYPTO_HMAC_SHA512_H diff --git a/src/crypto/ripemd160.cpp b/src/crypto/ripemd160.cpp index 77c9acfc2..4b2574bc8 100644 --- a/src/crypto/ripemd160.cpp +++ b/src/crypto/ripemd160.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "crypto/ripemd160.h" diff --git a/src/crypto/ripemd160.h b/src/crypto/ripemd160.h index 687204fda..eafa7f131 100644 --- a/src/crypto/ripemd160.h +++ b/src/crypto/ripemd160.h @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_CRYPTO_RIPEMD160_H #define BITCOIN_CRYPTO_RIPEMD160_H diff --git a/src/crypto/sha1.cpp b/src/crypto/sha1.cpp index 0b895b33a..402bcfb1c 100644 --- a/src/crypto/sha1.cpp +++ b/src/crypto/sha1.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "crypto/sha1.h" diff --git a/src/crypto/sha1.h b/src/crypto/sha1.h index 7b2a21bc6..ed4c98146 100644 --- a/src/crypto/sha1.h +++ b/src/crypto/sha1.h @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_CRYPTO_SHA1_H #define BITCOIN_CRYPTO_SHA1_H diff --git a/src/crypto/sha256.cpp b/src/crypto/sha256.cpp index 0718d2d25..82c7fb579 100644 --- a/src/crypto/sha256.cpp +++ b/src/crypto/sha256.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "crypto/sha256.h" #include "crypto/common.h" diff --git a/src/crypto/sha256.h b/src/crypto/sha256.h index 24c9c666d..6d9ca1335 100644 --- a/src/crypto/sha256.h +++ b/src/crypto/sha256.h @@ -1,6 +1,6 @@ // Copyright (c) 2014-2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_CRYPTO_SHA256_H #define BITCOIN_CRYPTO_SHA256_H diff --git a/src/crypto/sha256_sse4.cpp b/src/crypto/sha256_sse4.cpp index 89f529a3a..a4eafef86 100644 --- a/src/crypto/sha256_sse4.cpp +++ b/src/crypto/sha256_sse4.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2017 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php // // This is a translation to GCC extended asm syntax from YASM code by Intel // (available at the bottom of this file). diff --git a/src/crypto/sha512.cpp b/src/crypto/sha512.cpp index 564127cc3..1e0de1317 100644 --- a/src/crypto/sha512.cpp +++ b/src/crypto/sha512.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "crypto/sha512.h" diff --git a/src/crypto/sha512.h b/src/crypto/sha512.h index f1f17caf9..a04e27f84 100644 --- a/src/crypto/sha512.h +++ b/src/crypto/sha512.h @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_CRYPTO_SHA512_H #define BITCOIN_CRYPTO_SHA512_H diff --git a/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_parsing.c b/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_parsing.c index 5b141a994..74acf8c4f 100644 --- a/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_parsing.c +++ b/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_parsing.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include diff --git a/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_parsing.h b/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_parsing.h index 7eaf63bf6..9c5a51fbb 100644 --- a/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_parsing.h +++ b/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_parsing.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ /**** diff --git a/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_privatekey_parsing.c b/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_privatekey_parsing.c index c2e63b4b8..3fadba3f4 100644 --- a/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_privatekey_parsing.c +++ b/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_privatekey_parsing.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014, 2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include diff --git a/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_privatekey_parsing.h b/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_privatekey_parsing.h index fece261fb..d5c2e7487 100644 --- a/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_privatekey_parsing.h +++ b/src/cryptoconditions/src/include/secp256k1/contrib/lax_der_privatekey_parsing.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014, 2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ /**** diff --git a/src/cryptoconditions/src/include/secp256k1/src/asm/field_10x26_arm.s b/src/cryptoconditions/src/include/secp256k1/src/asm/field_10x26_arm.s index 5a9cc3ffc..e2029eb0c 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/asm/field_10x26_arm.s +++ b/src/cryptoconditions/src/include/secp256k1/src/asm/field_10x26_arm.s @@ -2,7 +2,7 @@ /********************************************************************** * Copyright (c) 2014 Wladimir J. van der Laan * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ /* ARM implementation of field_10x26 inner loops. diff --git a/src/cryptoconditions/src/include/secp256k1/src/basic-config.h b/src/cryptoconditions/src/include/secp256k1/src/basic-config.h index fc588061c..a9adbda17 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/basic-config.h +++ b/src/cryptoconditions/src/include/secp256k1/src/basic-config.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_BASIC_CONFIG_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/bench.h b/src/cryptoconditions/src/include/secp256k1/src/bench.h index d5ebe0130..c8d038ff3 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/bench.h +++ b/src/cryptoconditions/src/include/secp256k1/src/bench.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_BENCH_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/bench_ecdh.c b/src/cryptoconditions/src/include/secp256k1/src/bench_ecdh.c index 2de5126d6..95c44bb4a 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/bench_ecdh.c +++ b/src/cryptoconditions/src/include/secp256k1/src/bench_ecdh.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2015 Pieter Wuille, Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include diff --git a/src/cryptoconditions/src/include/secp256k1/src/bench_internal.c b/src/cryptoconditions/src/include/secp256k1/src/bench_internal.c index 9b30c50d0..cae5f5d7e 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/bench_internal.c +++ b/src/cryptoconditions/src/include/secp256k1/src/bench_internal.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014-2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include diff --git a/src/cryptoconditions/src/include/secp256k1/src/bench_recover.c b/src/cryptoconditions/src/include/secp256k1/src/bench_recover.c index 506fc1880..0288c1c79 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/bench_recover.c +++ b/src/cryptoconditions/src/include/secp256k1/src/bench_recover.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014-2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include "include/secp256k1.h" diff --git a/src/cryptoconditions/src/include/secp256k1/src/bench_sign.c b/src/cryptoconditions/src/include/secp256k1/src/bench_sign.c index 544b43963..266df9c79 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/bench_sign.c +++ b/src/cryptoconditions/src/include/secp256k1/src/bench_sign.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include "include/secp256k1.h" diff --git a/src/cryptoconditions/src/include/secp256k1/src/bench_verify.c b/src/cryptoconditions/src/include/secp256k1/src/bench_verify.c index 418defa0a..3f154ea17 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/bench_verify.c +++ b/src/cryptoconditions/src/include/secp256k1/src/bench_verify.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include diff --git a/src/cryptoconditions/src/include/secp256k1/src/ecdsa.h b/src/cryptoconditions/src/include/secp256k1/src/ecdsa.h index 80590c7cc..fea457c20 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/ecdsa.h +++ b/src/cryptoconditions/src/include/secp256k1/src/ecdsa.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECDSA_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/ecdsa_impl.h b/src/cryptoconditions/src/include/secp256k1/src/ecdsa_impl.h index c3400042d..a86fb9a44 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/ecdsa_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/ecdsa_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013-2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ diff --git a/src/cryptoconditions/src/include/secp256k1/src/eckey.h b/src/cryptoconditions/src/include/secp256k1/src/eckey.h index b621f1e6c..913f1215c 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/eckey.h +++ b/src/cryptoconditions/src/include/secp256k1/src/eckey.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECKEY_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/eckey_impl.h b/src/cryptoconditions/src/include/secp256k1/src/eckey_impl.h index 1ab9a68ec..0fccaffc6 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/eckey_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/eckey_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECKEY_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/ecmult.h b/src/cryptoconditions/src/include/secp256k1/src/ecmult.h index 6d44aba60..28b1b14b7 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/ecmult.h +++ b/src/cryptoconditions/src/include/secp256k1/src/ecmult.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/ecmult_const.h b/src/cryptoconditions/src/include/secp256k1/src/ecmult_const.h index 5a36ba40b..a3ab99007 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/ecmult_const.h +++ b/src/cryptoconditions/src/include/secp256k1/src/ecmult_const.h @@ -3,7 +3,7 @@ /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_CONST_H @@ -21,7 +21,7 @@ static void secp256k1_ecmult_const(secp256k1_gej *r, const secp256k1_ge *a, cons /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_CONST_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/ecmult_const_impl.h b/src/cryptoconditions/src/include/secp256k1/src/ecmult_const_impl.h index 7d7a172b7..395ed9f00 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/ecmult_const_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/ecmult_const_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2015 Pieter Wuille, Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_CONST_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/ecmult_gen.h b/src/cryptoconditions/src/include/secp256k1/src/ecmult_gen.h index 7564b7015..486feb13e 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/ecmult_gen.h +++ b/src/cryptoconditions/src/include/secp256k1/src/ecmult_gen.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_GEN_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/ecmult_gen_impl.h b/src/cryptoconditions/src/include/secp256k1/src/ecmult_gen_impl.h index 714f02e94..a316e1c2a 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/ecmult_gen_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/ecmult_gen_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014, 2015 Pieter Wuille, Gregory Maxwell * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_GEN_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/ecmult_impl.h b/src/cryptoconditions/src/include/secp256k1/src/ecmult_impl.h index 93d3794cb..17b8541db 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/ecmult_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/ecmult_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/field.h b/src/cryptoconditions/src/include/secp256k1/src/field.h index bb6692ad5..30b6e50f0 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/field.h +++ b/src/cryptoconditions/src/include/secp256k1/src/field.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_FIELD_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/field_10x26.h b/src/cryptoconditions/src/include/secp256k1/src/field_10x26.h index 727c5267f..c93cd4c86 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/field_10x26.h +++ b/src/cryptoconditions/src/include/secp256k1/src/field_10x26.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_FIELD_REPR_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/field_10x26_impl.h b/src/cryptoconditions/src/include/secp256k1/src/field_10x26_impl.h index 94f8132fc..29799b418 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/field_10x26_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/field_10x26_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_FIELD_REPR_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/field_5x52.h b/src/cryptoconditions/src/include/secp256k1/src/field_5x52.h index bccd8feb4..e9446b859 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/field_5x52.h +++ b/src/cryptoconditions/src/include/secp256k1/src/field_5x52.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_FIELD_REPR_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/field_5x52_asm_impl.h b/src/cryptoconditions/src/include/secp256k1/src/field_5x52_asm_impl.h index 1fc3171f6..759101d0e 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/field_5x52_asm_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/field_5x52_asm_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013-2014 Diederik Huys, Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ /** diff --git a/src/cryptoconditions/src/include/secp256k1/src/field_5x52_impl.h b/src/cryptoconditions/src/include/secp256k1/src/field_5x52_impl.h index 957c61b01..f5dc9dc9d 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/field_5x52_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/field_5x52_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_FIELD_REPR_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/field_5x52_int128_impl.h b/src/cryptoconditions/src/include/secp256k1/src/field_5x52_int128_impl.h index 95a0d1791..a26fb3c16 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/field_5x52_int128_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/field_5x52_int128_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_FIELD_INNER5X52_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/field_impl.h b/src/cryptoconditions/src/include/secp256k1/src/field_impl.h index 20428648a..34827651c 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/field_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/field_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_FIELD_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/gen_context.c b/src/cryptoconditions/src/include/secp256k1/src/gen_context.c index 1835fd491..5cd725509 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/gen_context.c +++ b/src/cryptoconditions/src/include/secp256k1/src/gen_context.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014, 2015 Thomas Daede, Cory Fields * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #define USE_BASIC_CONFIG 1 diff --git a/src/cryptoconditions/src/include/secp256k1/src/group.h b/src/cryptoconditions/src/include/secp256k1/src/group.h index ea1302deb..3b8a24883 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/group.h +++ b/src/cryptoconditions/src/include/secp256k1/src/group.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_GROUP_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/group_impl.h b/src/cryptoconditions/src/include/secp256k1/src/group_impl.h index b31b6c12e..de6307c42 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/group_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/group_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_GROUP_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/hash.h b/src/cryptoconditions/src/include/secp256k1/src/hash.h index de26e4b89..991b38699 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/hash.h +++ b/src/cryptoconditions/src/include/secp256k1/src/hash.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_HASH_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/hash_impl.h b/src/cryptoconditions/src/include/secp256k1/src/hash_impl.h index c06db9e33..1f6dcc317 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/hash_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/hash_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_HASH_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/modules/ecdh/main_impl.h b/src/cryptoconditions/src/include/secp256k1/src/modules/ecdh/main_impl.h index bd8739eeb..e80ed4af3 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/modules/ecdh/main_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/modules/ecdh/main_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_MODULE_ECDH_MAIN_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/modules/ecdh/tests_impl.h b/src/cryptoconditions/src/include/secp256k1/src/modules/ecdh/tests_impl.h index 0c53f8ee0..99c400365 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/modules/ecdh/tests_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/modules/ecdh/tests_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_MODULE_ECDH_TESTS_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/modules/recovery/main_impl.h b/src/cryptoconditions/src/include/secp256k1/src/modules/recovery/main_impl.h index 2f6691c5a..a63903ccb 100755 --- a/src/cryptoconditions/src/include/secp256k1/src/modules/recovery/main_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/modules/recovery/main_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013-2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_MODULE_RECOVERY_MAIN_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/modules/recovery/tests_impl.h b/src/cryptoconditions/src/include/secp256k1/src/modules/recovery/tests_impl.h index 5c9bbe861..de2b0cab3 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/modules/recovery/tests_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/modules/recovery/tests_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013-2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_MODULE_RECOVERY_TESTS_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/num.h b/src/cryptoconditions/src/include/secp256k1/src/num.h index 49f2dd791..48cc43488 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/num.h +++ b/src/cryptoconditions/src/include/secp256k1/src/num.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_NUM_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/num_gmp.h b/src/cryptoconditions/src/include/secp256k1/src/num_gmp.h index 3619844bd..7c2f3387b 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/num_gmp.h +++ b/src/cryptoconditions/src/include/secp256k1/src/num_gmp.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_NUM_REPR_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/num_gmp_impl.h b/src/cryptoconditions/src/include/secp256k1/src/num_gmp_impl.h index 0ae2a8ba0..a18ecb969 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/num_gmp_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/num_gmp_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_NUM_REPR_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/num_impl.h b/src/cryptoconditions/src/include/secp256k1/src/num_impl.h index c45193b03..1ed66335b 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/num_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/num_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_NUM_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/scalar.h b/src/cryptoconditions/src/include/secp256k1/src/scalar.h index 59304cb66..0b2393ff5 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/scalar.h +++ b/src/cryptoconditions/src/include/secp256k1/src/scalar.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/scalar_4x64.h b/src/cryptoconditions/src/include/secp256k1/src/scalar_4x64.h index 19c7495d1..3fc3f8fae 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/scalar_4x64.h +++ b/src/cryptoconditions/src/include/secp256k1/src/scalar_4x64.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/scalar_4x64_impl.h b/src/cryptoconditions/src/include/secp256k1/src/scalar_4x64_impl.h index db1ebf94b..2a2a21f45 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/scalar_4x64_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/scalar_4x64_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/scalar_8x32.h b/src/cryptoconditions/src/include/secp256k1/src/scalar_8x32.h index 2c9a348e2..799c4806e 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/scalar_8x32.h +++ b/src/cryptoconditions/src/include/secp256k1/src/scalar_8x32.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/scalar_8x32_impl.h b/src/cryptoconditions/src/include/secp256k1/src/scalar_8x32_impl.h index 4f9ed61fe..9e15725d2 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/scalar_8x32_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/scalar_8x32_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/scalar_impl.h b/src/cryptoconditions/src/include/secp256k1/src/scalar_impl.h index fa790570f..2a98abf40 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/scalar_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/scalar_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/scalar_low.h b/src/cryptoconditions/src/include/secp256k1/src/scalar_low.h index 5836febc5..016b4642b 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/scalar_low.h +++ b/src/cryptoconditions/src/include/secp256k1/src/scalar_low.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/scalar_low_impl.h b/src/cryptoconditions/src/include/secp256k1/src/scalar_low_impl.h index c80e70c5a..7801a4a98 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/scalar_low_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/scalar_low_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/secp256k1.c b/src/cryptoconditions/src/include/secp256k1/src/secp256k1.c index cecb1550b..d0a7c0c4f 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/secp256k1.c +++ b/src/cryptoconditions/src/include/secp256k1/src/secp256k1.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013-2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include "include/secp256k1.h" diff --git a/src/cryptoconditions/src/include/secp256k1/src/testrand.h b/src/cryptoconditions/src/include/secp256k1/src/testrand.h index f1f9be077..7b1acd16a 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/testrand.h +++ b/src/cryptoconditions/src/include/secp256k1/src/testrand.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_TESTRAND_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/testrand_impl.h b/src/cryptoconditions/src/include/secp256k1/src/testrand_impl.h index 30a91e529..bcdbd149c 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/testrand_impl.h +++ b/src/cryptoconditions/src/include/secp256k1/src/testrand_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013-2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_TESTRAND_IMPL_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/tests.c b/src/cryptoconditions/src/include/secp256k1/src/tests.c index f307b99d5..890e6c977 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/tests.c +++ b/src/cryptoconditions/src/include/secp256k1/src/tests.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014, 2015 Pieter Wuille, Gregory Maxwell * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #if defined HAVE_CONFIG_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/tests_exhaustive.c b/src/cryptoconditions/src/include/secp256k1/src/tests_exhaustive.c index b040bb073..4e439bac4 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/tests_exhaustive.c +++ b/src/cryptoconditions/src/include/secp256k1/src/tests_exhaustive.c @@ -1,7 +1,7 @@ /*********************************************************************** * Copyright (c) 2016 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #if defined HAVE_CONFIG_H diff --git a/src/cryptoconditions/src/include/secp256k1/src/util.h b/src/cryptoconditions/src/include/secp256k1/src/util.h index b0441d8e3..617d5701d 100644 --- a/src/cryptoconditions/src/include/secp256k1/src/util.h +++ b/src/cryptoconditions/src/include/secp256k1/src/util.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_UTIL_H diff --git a/src/dbwrapper.h b/src/dbwrapper.h index a43383a0a..d967974cf 100644 --- a/src/dbwrapper.h +++ b/src/dbwrapper.h @@ -1,7 +1,7 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers // Copyright (c) 2019 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_DBWRAPPER_H #define BITCOIN_DBWRAPPER_H diff --git a/src/deprecation.cpp b/src/deprecation.cpp index b32f24880..5ca2c0afa 100644 --- a/src/deprecation.cpp +++ b/src/deprecation.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2017 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/deprecation.h b/src/deprecation.h index eae3c92b9..e0d6d6cc3 100644 --- a/src/deprecation.h +++ b/src/deprecation.h @@ -1,7 +1,7 @@ // Copyright (c) 2017 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/hash.cpp b/src/hash.cpp index c15212a84..5b528c417 100644 --- a/src/hash.cpp +++ b/src/hash.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2013-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/hash.h b/src/hash.h index a062ea94c..a97fcac10 100644 --- a/src/hash.h +++ b/src/hash.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2013 The Bitcoin Core developers // Copyright (c) 2019 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/httprpc.h b/src/httprpc.h index 6827a7063..13359c027 100644 --- a/src/httprpc.h +++ b/src/httprpc.h @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/httpserver.cpp b/src/httpserver.cpp index 603e1e6ae..407473ee3 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "httpserver.h" diff --git a/src/httpserver.h b/src/httpserver.h index f04a332ec..b8507a053 100644 --- a/src/httpserver.h +++ b/src/httpserver.h @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_HTTPSERVER_H #define BITCOIN_HTTPSERVER_H diff --git a/src/init.cpp b/src/init.cpp index 8a495304c..b401079d6 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/init.h b/src/init.h index 0d8145a41..fcf188082 100644 --- a/src/init.h +++ b/src/init.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/key.cpp b/src/key.cpp index 6e2370dc2..0f24f7fba 100644 --- a/src/key.cpp +++ b/src/key.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2017 The Zcash developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/key.h b/src/key.h index 16492b151..a755dc15a 100644 --- a/src/key.h +++ b/src/key.h @@ -3,7 +3,7 @@ // Copyright (c) 2017 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/key_io.cpp b/src/key_io.cpp index 2e0dfeb9a..185baf685 100644 --- a/src/key_io.cpp +++ b/src/key_io.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2016-2018 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include diff --git a/src/key_io.h b/src/key_io.h index 567c9a2f2..6dc794920 100644 --- a/src/key_io.h +++ b/src/key_io.h @@ -3,7 +3,7 @@ // Copyright (c) 2016-2018 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_KEYIO_H #define BITCOIN_KEYIO_H diff --git a/src/keystore.cpp b/src/keystore.cpp index ca4fa3712..db0413ee0 100644 --- a/src/keystore.cpp +++ b/src/keystore.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/keystore.h b/src/keystore.h index 6f34d9bc4..a6b078290 100644 --- a/src/keystore.h +++ b/src/keystore.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/komodo-tx.cpp b/src/komodo-tx.cpp index 0f0b59421..8b2e4a61d 100644 --- a/src/komodo-tx.cpp +++ b/src/komodo-tx.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/limitedmap.h b/src/limitedmap.h index e8ea54965..843a68a20 100644 --- a/src/limitedmap.h +++ b/src/limitedmap.h @@ -1,6 +1,6 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_LIMITEDMAP_H #define BITCOIN_LIMITEDMAP_H diff --git a/src/main.cpp b/src/main.cpp index 6bed1c0e4..942c45cf8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/main.h b/src/main.h index 060b6b7cc..5f4a784cf 100644 --- a/src/main.h +++ b/src/main.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/memusage.h b/src/memusage.h index a3fd11b5f..7a6e28832 100644 --- a/src/memusage.h +++ b/src/memusage.h @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/merkleblock.cpp b/src/merkleblock.cpp index db4ccfc96..2f48b7503 100644 --- a/src/merkleblock.cpp +++ b/src/merkleblock.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/merkleblock.h b/src/merkleblock.h index f970ee91d..c3f4221d4 100644 --- a/src/merkleblock.h +++ b/src/merkleblock.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/metrics.cpp b/src/metrics.cpp index adbef02f2..12fcc0375 100644 --- a/src/metrics.cpp +++ b/src/metrics.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2016 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/metrics.h b/src/metrics.h index c110573a2..3c1fbf92e 100644 --- a/src/metrics.h +++ b/src/metrics.h @@ -1,7 +1,7 @@ // Copyright (c) 2016 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/miner.h b/src/miner.h index c42c2ad54..cd4326074 100644 --- a/src/miner.h +++ b/src/miner.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2013 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/mruset.h b/src/mruset.h index cd3af8664..d95b182f9 100644 --- a/src/mruset.h +++ b/src/mruset.h @@ -1,6 +1,6 @@ // Copyright (c) 2012-2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/net.cpp b/src/net.cpp index 5be64b291..882192660 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/net.h b/src/net.h index 2fa4e31b1..70972759e 100644 --- a/src/net.h +++ b/src/net.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/netbase.cpp b/src/netbase.cpp index fa8b80435..24d5125b5 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/netbase.h b/src/netbase.h index 8eb40b6b7..bc5475bfe 100644 --- a/src/netbase.h +++ b/src/netbase.h @@ -1,6 +1,6 @@ // Copyright (c) 2009-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/noui.cpp b/src/noui.cpp index 5e2b28318..436e78bda 100644 --- a/src/noui.cpp +++ b/src/noui.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/noui.h b/src/noui.h index 185d4d0ce..e5ff97544 100644 --- a/src/noui.h +++ b/src/noui.h @@ -1,6 +1,6 @@ // Copyright (c) 2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp index 3d12aee15..4104823a6 100644 --- a/src/policy/fees.cpp +++ b/src/policy/fees.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2015 The Bitcoin developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/policy/fees.h b/src/policy/fees.h index 514f17724..2c5631eb6 100644 --- a/src/policy/fees.h +++ b/src/policy/fees.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2015 The Bitcoin developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/pow.cpp b/src/pow.cpp index 6d0262699..c6e128564 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/pow.h b/src/pow.h index 1de85d5cb..64badc4bd 100644 --- a/src/pow.h +++ b/src/pow.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/primitives/block.cpp b/src/primitives/block.cpp index 3243b4564..7b898df95 100644 --- a/src/primitives/block.cpp +++ b/src/primitives/block.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/primitives/block.h b/src/primitives/block.h index 9a6ddf100..385eae880 100644 --- a/src/primitives/block.h +++ b/src/primitives/block.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2013 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp index 53aeeda99..47cfcde09 100644 --- a/src/primitives/transaction.cpp +++ b/src/primitives/transaction.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index 7a46b9c00..43cf355f1 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/protocol.cpp b/src/protocol.cpp index 77892bae6..a006d407c 100644 --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/protocol.h b/src/protocol.h index b7ad483ac..c01bea400 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/pubkey.h b/src/pubkey.h index 18e4dda8f..299866fa9 100644 --- a/src/pubkey.h +++ b/src/pubkey.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2017 The Zcash developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/random.cpp b/src/random.cpp index f9aa7622d..8b0ca9c12 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/random.h b/src/random.h index b65c7e08a..9c0f4ffdf 100644 --- a/src/random.h +++ b/src/random.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/rest.cpp b/src/rest.cpp index 72187f671..b62096a83 100644 --- a/src/rest.cpp +++ b/src/rest.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/reverselock.h b/src/reverselock.h index dd79cf3da..3e0263808 100644 --- a/src/reverselock.h +++ b/src/reverselock.h @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/rpc/blockchain.cpp b/src/rpc/blockchain.cpp index 6d10652e6..cdfe567ee 100644 --- a/src/rpc/blockchain.cpp +++ b/src/rpc/blockchain.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/rpc/client.cpp b/src/rpc/client.cpp index a3e04623a..5acaf5931 100644 --- a/src/rpc/client.cpp +++ b/src/rpc/client.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/rpc/client.h b/src/rpc/client.h index 79527b7be..51a3f0d9f 100644 --- a/src/rpc/client.h +++ b/src/rpc/client.h @@ -1,7 +1,7 @@ // Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 80284108f..3659398da 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index d741a9748..bc3ff3a74 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/rpc/protocol.cpp b/src/rpc/protocol.cpp index 2366fca14..d001d329b 100644 --- a/src/rpc/protocol.cpp +++ b/src/rpc/protocol.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/rpc/protocol.h b/src/rpc/protocol.h index 91a14c023..98fae3efc 100644 --- a/src/rpc/protocol.h +++ b/src/rpc/protocol.h @@ -1,7 +1,7 @@ // Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 94c891a80..15fe89729 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2015 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/rpc/register.h b/src/rpc/register.h index 245f76e22..11bdeef7e 100644 --- a/src/rpc/register.h +++ b/src/rpc/register.h @@ -1,6 +1,6 @@ // Copyright (c) 2009-2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 16b25ae81..42af7b39c 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/rpc/server.h b/src/rpc/server.h index 15c982d81..37d4a16e9 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush Developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/rpc/testtransactions.cpp b/src/rpc/testtransactions.cpp index c41e97e10..33a92200d 100644 --- a/src/rpc/testtransactions.cpp +++ b/src/rpc/testtransactions.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/scheduler.cpp b/src/scheduler.cpp index 2e1223b8e..b3f6aecfc 100644 --- a/src/scheduler.cpp +++ b/src/scheduler.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/scheduler.h b/src/scheduler.h index af1d7a24c..5faa8f83b 100644 --- a/src/scheduler.h +++ b/src/scheduler.h @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp index 64d98d783..21c8d3135 100644 --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/interpreter.h b/src/script/interpreter.h index 11812b6e3..f73b26d4d 100644 --- a/src/script/interpreter.h +++ b/src/script/interpreter.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/script.cpp b/src/script/script.cpp index 475acdfd5..1ee2a4673 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/script.h b/src/script/script.h index b1294ab25..026771f4f 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/script_error.cpp b/src/script/script_error.cpp index 199161364..6ce0d15b3 100644 --- a/src/script/script_error.cpp +++ b/src/script/script_error.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/script_error.h b/src/script/script_error.h index 85fe1cff3..bd2f6539e 100644 --- a/src/script/script_error.h +++ b/src/script/script_error.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/serverchecker.cpp b/src/script/serverchecker.cpp index 9fc470e14..2d7d393fb 100644 --- a/src/script/serverchecker.cpp +++ b/src/script/serverchecker.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/serverchecker.h b/src/script/serverchecker.h index 08f3acc6c..94cc63cf0 100644 --- a/src/script/serverchecker.h +++ b/src/script/serverchecker.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/sigcache.cpp b/src/script/sigcache.cpp index b78fc3ce3..07a2a686f 100644 --- a/src/script/sigcache.cpp +++ b/src/script/sigcache.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/sigcache.h b/src/script/sigcache.h index e9169eab6..c5a7b7cc6 100644 --- a/src/script/sigcache.h +++ b/src/script/sigcache.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/sign.cpp b/src/script/sign.cpp index d1d24b3d0..32abc327a 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/sign.h b/src/script/sign.h index 4455d4281..468d5019e 100644 --- a/src/script/sign.h +++ b/src/script/sign.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/standard.cpp b/src/script/standard.cpp index d38c0a351..9175b16cc 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/standard.h b/src/script/standard.h index ae7336e2f..b4505932d 100644 --- a/src/script/standard.h +++ b/src/script/standard.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/zcashconsensus.cpp b/src/script/zcashconsensus.cpp index dc4ec7dc1..cea92bbaa 100644 --- a/src/script/zcashconsensus.cpp +++ b/src/script/zcashconsensus.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/script/zcashconsensus.h b/src/script/zcashconsensus.h index e01a50421..f73e14d5e 100644 --- a/src/script/zcashconsensus.h +++ b/src/script/zcashconsensus.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/secp256k1/contrib/lax_der_parsing.c b/src/secp256k1/contrib/lax_der_parsing.c index 5b141a994..74acf8c4f 100644 --- a/src/secp256k1/contrib/lax_der_parsing.c +++ b/src/secp256k1/contrib/lax_der_parsing.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include diff --git a/src/secp256k1/contrib/lax_der_parsing.h b/src/secp256k1/contrib/lax_der_parsing.h index 7eaf63bf6..9c5a51fbb 100644 --- a/src/secp256k1/contrib/lax_der_parsing.h +++ b/src/secp256k1/contrib/lax_der_parsing.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ /**** diff --git a/src/secp256k1/contrib/lax_der_privatekey_parsing.c b/src/secp256k1/contrib/lax_der_privatekey_parsing.c index c2e63b4b8..3fadba3f4 100644 --- a/src/secp256k1/contrib/lax_der_privatekey_parsing.c +++ b/src/secp256k1/contrib/lax_der_privatekey_parsing.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014, 2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include diff --git a/src/secp256k1/contrib/lax_der_privatekey_parsing.h b/src/secp256k1/contrib/lax_der_privatekey_parsing.h index fece261fb..d5c2e7487 100644 --- a/src/secp256k1/contrib/lax_der_privatekey_parsing.h +++ b/src/secp256k1/contrib/lax_der_privatekey_parsing.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014, 2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ /**** diff --git a/src/secp256k1/src/asm/field_10x26_arm.s b/src/secp256k1/src/asm/field_10x26_arm.s index 5a9cc3ffc..e2029eb0c 100644 --- a/src/secp256k1/src/asm/field_10x26_arm.s +++ b/src/secp256k1/src/asm/field_10x26_arm.s @@ -2,7 +2,7 @@ /********************************************************************** * Copyright (c) 2014 Wladimir J. van der Laan * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ /* ARM implementation of field_10x26 inner loops. diff --git a/src/secp256k1/src/basic-config.h b/src/secp256k1/src/basic-config.h index fc588061c..a9adbda17 100644 --- a/src/secp256k1/src/basic-config.h +++ b/src/secp256k1/src/basic-config.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_BASIC_CONFIG_H diff --git a/src/secp256k1/src/bench.h b/src/secp256k1/src/bench.h index d5ebe0130..c8d038ff3 100644 --- a/src/secp256k1/src/bench.h +++ b/src/secp256k1/src/bench.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_BENCH_H diff --git a/src/secp256k1/src/bench_ecdh.c b/src/secp256k1/src/bench_ecdh.c index 2de5126d6..95c44bb4a 100644 --- a/src/secp256k1/src/bench_ecdh.c +++ b/src/secp256k1/src/bench_ecdh.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2015 Pieter Wuille, Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include diff --git a/src/secp256k1/src/bench_internal.c b/src/secp256k1/src/bench_internal.c index 9b30c50d0..cae5f5d7e 100644 --- a/src/secp256k1/src/bench_internal.c +++ b/src/secp256k1/src/bench_internal.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014-2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include diff --git a/src/secp256k1/src/bench_recover.c b/src/secp256k1/src/bench_recover.c index 506fc1880..0288c1c79 100644 --- a/src/secp256k1/src/bench_recover.c +++ b/src/secp256k1/src/bench_recover.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014-2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include "include/secp256k1.h" diff --git a/src/secp256k1/src/bench_sign.c b/src/secp256k1/src/bench_sign.c index 544b43963..266df9c79 100644 --- a/src/secp256k1/src/bench_sign.c +++ b/src/secp256k1/src/bench_sign.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include "include/secp256k1.h" diff --git a/src/secp256k1/src/bench_verify.c b/src/secp256k1/src/bench_verify.c index 418defa0a..3f154ea17 100644 --- a/src/secp256k1/src/bench_verify.c +++ b/src/secp256k1/src/bench_verify.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include diff --git a/src/secp256k1/src/ecdsa.h b/src/secp256k1/src/ecdsa.h index 80590c7cc..fea457c20 100644 --- a/src/secp256k1/src/ecdsa.h +++ b/src/secp256k1/src/ecdsa.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECDSA_H diff --git a/src/secp256k1/src/ecdsa_impl.h b/src/secp256k1/src/ecdsa_impl.h index c3400042d..a86fb9a44 100644 --- a/src/secp256k1/src/ecdsa_impl.h +++ b/src/secp256k1/src/ecdsa_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013-2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ diff --git a/src/secp256k1/src/eckey.h b/src/secp256k1/src/eckey.h index b621f1e6c..913f1215c 100644 --- a/src/secp256k1/src/eckey.h +++ b/src/secp256k1/src/eckey.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECKEY_H diff --git a/src/secp256k1/src/eckey_impl.h b/src/secp256k1/src/eckey_impl.h index 1ab9a68ec..0fccaffc6 100644 --- a/src/secp256k1/src/eckey_impl.h +++ b/src/secp256k1/src/eckey_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECKEY_IMPL_H diff --git a/src/secp256k1/src/ecmult.h b/src/secp256k1/src/ecmult.h index 3ed2e435a..5f1ddfd2a 100644 --- a/src/secp256k1/src/ecmult.h +++ b/src/secp256k1/src/ecmult.h @@ -3,7 +3,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_H @@ -36,7 +36,7 @@ static void secp256k1_ecmult(const secp256k1_ecmult_context *ctx, secp256k1_gej /********************************************************************** * Copyright (c) 2013, 2014, 2017 Pieter Wuille, Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_H diff --git a/src/secp256k1/src/ecmult_const.h b/src/secp256k1/src/ecmult_const.h index 0d32fa389..166005b96 100644 --- a/src/secp256k1/src/ecmult_const.h +++ b/src/secp256k1/src/ecmult_const.h @@ -3,7 +3,7 @@ /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_CONST_H @@ -20,7 +20,7 @@ static void secp256k1_ecmult_const(secp256k1_gej *r, const secp256k1_ge *a, cons /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_CONST_H diff --git a/src/secp256k1/src/ecmult_const_impl.h b/src/secp256k1/src/ecmult_const_impl.h index 28636290d..a12477ec9 100644 --- a/src/secp256k1/src/ecmult_const_impl.h +++ b/src/secp256k1/src/ecmult_const_impl.h @@ -3,7 +3,7 @@ /********************************************************************** * Copyright (c) 2015 Pieter Wuille, Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_CONST_IMPL_H @@ -246,7 +246,7 @@ static void secp256k1_ecmult_const(secp256k1_gej *r, const secp256k1_ge *a, cons /********************************************************************** * Copyright (c) 2015 Pieter Wuille, Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_CONST_IMPL_H diff --git a/src/secp256k1/src/ecmult_gen.h b/src/secp256k1/src/ecmult_gen.h index 7564b7015..486feb13e 100644 --- a/src/secp256k1/src/ecmult_gen.h +++ b/src/secp256k1/src/ecmult_gen.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_GEN_H diff --git a/src/secp256k1/src/ecmult_gen_impl.h b/src/secp256k1/src/ecmult_gen_impl.h index 714f02e94..a316e1c2a 100644 --- a/src/secp256k1/src/ecmult_gen_impl.h +++ b/src/secp256k1/src/ecmult_gen_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014, 2015 Pieter Wuille, Gregory Maxwell * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_GEN_IMPL_H diff --git a/src/secp256k1/src/ecmult_impl.h b/src/secp256k1/src/ecmult_impl.h index b761304cf..5a45d0ff1 100644 --- a/src/secp256k1/src/ecmult_impl.h +++ b/src/secp256k1/src/ecmult_impl.h @@ -4,7 +4,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_ECMULT_IMPL_H @@ -413,7 +413,7 @@ static void secp256k1_ecmult(const secp256k1_ecmult_context *ctx, secp256k1_gej /***************************************************************************** * Copyright (c) 2013, 2014, 2017 Pieter Wuille, Andrew Poelstra, Jonas Nick * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php. * + * file COPYING or https://www.opensource.org/licenses/mit-license.php * *****************************************************************************/ #ifndef SECP256K1_ECMULT_IMPL_H diff --git a/src/secp256k1/src/field.h b/src/secp256k1/src/field.h index bb6692ad5..30b6e50f0 100644 --- a/src/secp256k1/src/field.h +++ b/src/secp256k1/src/field.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_FIELD_H diff --git a/src/secp256k1/src/field_10x26.h b/src/secp256k1/src/field_10x26.h index 727c5267f..c93cd4c86 100644 --- a/src/secp256k1/src/field_10x26.h +++ b/src/secp256k1/src/field_10x26.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_FIELD_REPR_H diff --git a/src/secp256k1/src/field_10x26_impl.h b/src/secp256k1/src/field_10x26_impl.h index 94f8132fc..29799b418 100644 --- a/src/secp256k1/src/field_10x26_impl.h +++ b/src/secp256k1/src/field_10x26_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_FIELD_REPR_IMPL_H diff --git a/src/secp256k1/src/field_5x52.h b/src/secp256k1/src/field_5x52.h index bccd8feb4..e9446b859 100644 --- a/src/secp256k1/src/field_5x52.h +++ b/src/secp256k1/src/field_5x52.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_FIELD_REPR_H diff --git a/src/secp256k1/src/field_5x52_asm_impl.h b/src/secp256k1/src/field_5x52_asm_impl.h index 1fc3171f6..759101d0e 100644 --- a/src/secp256k1/src/field_5x52_asm_impl.h +++ b/src/secp256k1/src/field_5x52_asm_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013-2014 Diederik Huys, Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ /** diff --git a/src/secp256k1/src/field_5x52_impl.h b/src/secp256k1/src/field_5x52_impl.h index 957c61b01..f5dc9dc9d 100644 --- a/src/secp256k1/src/field_5x52_impl.h +++ b/src/secp256k1/src/field_5x52_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_FIELD_REPR_IMPL_H diff --git a/src/secp256k1/src/field_5x52_int128_impl.h b/src/secp256k1/src/field_5x52_int128_impl.h index 95a0d1791..a26fb3c16 100644 --- a/src/secp256k1/src/field_5x52_int128_impl.h +++ b/src/secp256k1/src/field_5x52_int128_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_FIELD_INNER5X52_IMPL_H diff --git a/src/secp256k1/src/field_impl.h b/src/secp256k1/src/field_impl.h index 20428648a..34827651c 100644 --- a/src/secp256k1/src/field_impl.h +++ b/src/secp256k1/src/field_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_FIELD_IMPL_H diff --git a/src/secp256k1/src/gen_context.c b/src/secp256k1/src/gen_context.c index 1835fd491..5cd725509 100644 --- a/src/secp256k1/src/gen_context.c +++ b/src/secp256k1/src/gen_context.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014, 2015 Thomas Daede, Cory Fields * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #define USE_BASIC_CONFIG 1 diff --git a/src/secp256k1/src/group.h b/src/secp256k1/src/group.h index ea1302deb..3b8a24883 100644 --- a/src/secp256k1/src/group.h +++ b/src/secp256k1/src/group.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_GROUP_H diff --git a/src/secp256k1/src/group_impl.h b/src/secp256k1/src/group_impl.h index b31b6c12e..de6307c42 100644 --- a/src/secp256k1/src/group_impl.h +++ b/src/secp256k1/src/group_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_GROUP_IMPL_H diff --git a/src/secp256k1/src/hash.h b/src/secp256k1/src/hash.h index de26e4b89..991b38699 100644 --- a/src/secp256k1/src/hash.h +++ b/src/secp256k1/src/hash.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_HASH_H diff --git a/src/secp256k1/src/hash_impl.h b/src/secp256k1/src/hash_impl.h index c06db9e33..1f6dcc317 100644 --- a/src/secp256k1/src/hash_impl.h +++ b/src/secp256k1/src/hash_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_HASH_IMPL_H diff --git a/src/secp256k1/src/modules/ecdh/main_impl.h b/src/secp256k1/src/modules/ecdh/main_impl.h index 74332ba1d..91be6a5d8 100644 --- a/src/secp256k1/src/modules/ecdh/main_impl.h +++ b/src/secp256k1/src/modules/ecdh/main_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_MODULE_ECDH_MAIN_H diff --git a/src/secp256k1/src/modules/ecdh/tests_impl.h b/src/secp256k1/src/modules/ecdh/tests_impl.h index 0c53f8ee0..99c400365 100644 --- a/src/secp256k1/src/modules/ecdh/tests_impl.h +++ b/src/secp256k1/src/modules/ecdh/tests_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_MODULE_ECDH_TESTS_H diff --git a/src/secp256k1/src/modules/musig/example.c b/src/secp256k1/src/modules/musig/example.c index 70d183e7d..ecce75ff2 100644 --- a/src/secp256k1/src/modules/musig/example.c +++ b/src/secp256k1/src/modules/musig/example.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2018 Jonas Nick * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ /** diff --git a/src/secp256k1/src/modules/musig/main_impl.h b/src/secp256k1/src/modules/musig/main_impl.h index 8bd2f1831..fee1d084f 100644 --- a/src/secp256k1/src/modules/musig/main_impl.h +++ b/src/secp256k1/src/modules/musig/main_impl.h @@ -2,7 +2,7 @@ /********************************************************************** * Copyright (c) 2018 Andrew Poelstra, Jonas Nick * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef _SECP256K1_MODULE_MUSIG_MAIN_ diff --git a/src/secp256k1/src/modules/musig/tests_impl.h b/src/secp256k1/src/modules/musig/tests_impl.h index c58ae95af..b45b0be4d 100644 --- a/src/secp256k1/src/modules/musig/tests_impl.h +++ b/src/secp256k1/src/modules/musig/tests_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2018 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef _SECP256K1_MODULE_MUSIG_TESTS_ diff --git a/src/secp256k1/src/modules/recovery/main_impl.h b/src/secp256k1/src/modules/recovery/main_impl.h index 2f6691c5a..a63903ccb 100755 --- a/src/secp256k1/src/modules/recovery/main_impl.h +++ b/src/secp256k1/src/modules/recovery/main_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013-2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_MODULE_RECOVERY_MAIN_H diff --git a/src/secp256k1/src/modules/recovery/tests_impl.h b/src/secp256k1/src/modules/recovery/tests_impl.h index 5c9bbe861..de2b0cab3 100644 --- a/src/secp256k1/src/modules/recovery/tests_impl.h +++ b/src/secp256k1/src/modules/recovery/tests_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013-2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_MODULE_RECOVERY_TESTS_H diff --git a/src/secp256k1/src/modules/schnorrsig/main_impl.h b/src/secp256k1/src/modules/schnorrsig/main_impl.h index f2b418159..ea98edbf2 100644 --- a/src/secp256k1/src/modules/schnorrsig/main_impl.h +++ b/src/secp256k1/src/modules/schnorrsig/main_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2018 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef _SECP256K1_MODULE_SCHNORRSIG_MAIN_ diff --git a/src/secp256k1/src/modules/schnorrsig/tests_impl.h b/src/secp256k1/src/modules/schnorrsig/tests_impl.h index de84992a9..9273cf62a 100644 --- a/src/secp256k1/src/modules/schnorrsig/tests_impl.h +++ b/src/secp256k1/src/modules/schnorrsig/tests_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2018 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef _SECP256K1_MODULE_SCHNORRSIG_TESTS_ diff --git a/src/secp256k1/src/num.h b/src/secp256k1/src/num.h index 49f2dd791..48cc43488 100644 --- a/src/secp256k1/src/num.h +++ b/src/secp256k1/src/num.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_NUM_H diff --git a/src/secp256k1/src/num_gmp.h b/src/secp256k1/src/num_gmp.h index 3619844bd..7c2f3387b 100644 --- a/src/secp256k1/src/num_gmp.h +++ b/src/secp256k1/src/num_gmp.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_NUM_REPR_H diff --git a/src/secp256k1/src/num_gmp_impl.h b/src/secp256k1/src/num_gmp_impl.h index 0ae2a8ba0..a18ecb969 100644 --- a/src/secp256k1/src/num_gmp_impl.h +++ b/src/secp256k1/src/num_gmp_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_NUM_REPR_IMPL_H diff --git a/src/secp256k1/src/num_impl.h b/src/secp256k1/src/num_impl.h index c45193b03..1ed66335b 100644 --- a/src/secp256k1/src/num_impl.h +++ b/src/secp256k1/src/num_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_NUM_IMPL_H diff --git a/src/secp256k1/src/scalar.h b/src/secp256k1/src/scalar.h index d83ccc22a..ca388eefe 100644 --- a/src/secp256k1/src/scalar.h +++ b/src/secp256k1/src/scalar.h @@ -3,7 +3,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_H @@ -112,7 +112,7 @@ static void secp256k1_scalar_mul_shift_var(secp256k1_scalar *r, const secp256k1_ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_H diff --git a/src/secp256k1/src/scalar_4x64.h b/src/secp256k1/src/scalar_4x64.h index 68096f2a9..82ecaf20e 100644 --- a/src/secp256k1/src/scalar_4x64.h +++ b/src/secp256k1/src/scalar_4x64.h @@ -3,7 +3,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_H @@ -24,7 +24,7 @@ typedef struct { /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_H diff --git a/src/secp256k1/src/scalar_4x64_impl.h b/src/secp256k1/src/scalar_4x64_impl.h index 04f1da85d..a3c8cdcab 100644 --- a/src/secp256k1/src/scalar_4x64_impl.h +++ b/src/secp256k1/src/scalar_4x64_impl.h @@ -3,7 +3,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_IMPL_H @@ -955,7 +955,7 @@ SECP256K1_INLINE static void secp256k1_scalar_mul_shift_var(secp256k1_scalar *r, /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_IMPL_H diff --git a/src/secp256k1/src/scalar_8x32.h b/src/secp256k1/src/scalar_8x32.h index 8a630ac40..fc548d1b2 100644 --- a/src/secp256k1/src/scalar_8x32.h +++ b/src/secp256k1/src/scalar_8x32.h @@ -3,7 +3,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_H @@ -24,7 +24,7 @@ typedef struct { /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_H diff --git a/src/secp256k1/src/scalar_8x32_impl.h b/src/secp256k1/src/scalar_8x32_impl.h index f1429b162..381bec319 100644 --- a/src/secp256k1/src/scalar_8x32_impl.h +++ b/src/secp256k1/src/scalar_8x32_impl.h @@ -3,7 +3,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_IMPL_H @@ -726,7 +726,7 @@ SECP256K1_INLINE static void secp256k1_scalar_mul_shift_var(secp256k1_scalar *r, /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_IMPL_H diff --git a/src/secp256k1/src/scalar_impl.h b/src/secp256k1/src/scalar_impl.h index d69a94880..e6205339b 100644 --- a/src/secp256k1/src/scalar_impl.h +++ b/src/secp256k1/src/scalar_impl.h @@ -3,7 +3,7 @@ /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_IMPL_H @@ -339,7 +339,7 @@ static void secp256k1_scalar_split_lambda(secp256k1_scalar *r1, secp256k1_scalar /********************************************************************** * Copyright (c) 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_IMPL_H diff --git a/src/secp256k1/src/scalar_low.h b/src/secp256k1/src/scalar_low.h index 16b167f9c..0c7823ce7 100644 --- a/src/secp256k1/src/scalar_low.h +++ b/src/secp256k1/src/scalar_low.h @@ -3,7 +3,7 @@ /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_H @@ -20,7 +20,7 @@ typedef uint32_t secp256k1_scalar; /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_H diff --git a/src/secp256k1/src/scalar_low_impl.h b/src/secp256k1/src/scalar_low_impl.h index 956cccd04..1bd50279e 100644 --- a/src/secp256k1/src/scalar_low_impl.h +++ b/src/secp256k1/src/scalar_low_impl.h @@ -3,7 +3,7 @@ /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_IMPL_H @@ -119,7 +119,7 @@ SECP256K1_INLINE static int secp256k1_scalar_eq(const secp256k1_scalar *a, const /********************************************************************** * Copyright (c) 2015 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_SCALAR_REPR_IMPL_H diff --git a/src/secp256k1/src/scratch.h b/src/secp256k1/src/scratch.h index 04faa9f0a..85f9faf40 100644 --- a/src/secp256k1/src/scratch.h +++ b/src/secp256k1/src/scratch.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2017 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef _SECP256K1_SCRATCH_ diff --git a/src/secp256k1/src/scratch_impl.h b/src/secp256k1/src/scratch_impl.h index 1ce3ff9b0..677d90ce0 100644 --- a/src/secp256k1/src/scratch_impl.h +++ b/src/secp256k1/src/scratch_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2017 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef _SECP256K1_SCRATCH_IMPL_H_ diff --git a/src/secp256k1/src/secp256k1.c b/src/secp256k1/src/secp256k1.c index 7861a5f79..3b627b3e9 100644 --- a/src/secp256k1/src/secp256k1.c +++ b/src/secp256k1/src/secp256k1.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013-2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #include "../include/secp256k1.h" diff --git a/src/secp256k1/src/testrand.h b/src/secp256k1/src/testrand.h index f1f9be077..7b1acd16a 100644 --- a/src/secp256k1/src/testrand.h +++ b/src/secp256k1/src/testrand.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_TESTRAND_H diff --git a/src/secp256k1/src/testrand_impl.h b/src/secp256k1/src/testrand_impl.h index 30a91e529..bcdbd149c 100644 --- a/src/secp256k1/src/testrand_impl.h +++ b/src/secp256k1/src/testrand_impl.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013-2015 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_TESTRAND_IMPL_H diff --git a/src/secp256k1/src/tests.c b/src/secp256k1/src/tests.c index 345fb0bdf..ab02e88cc 100644 --- a/src/secp256k1/src/tests.c +++ b/src/secp256k1/src/tests.c @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014, 2015 Pieter Wuille, Gregory Maxwell * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #if defined HAVE_CONFIG_H diff --git a/src/secp256k1/src/tests_exhaustive.c b/src/secp256k1/src/tests_exhaustive.c index 1e58c3b5f..4f6959382 100644 --- a/src/secp256k1/src/tests_exhaustive.c +++ b/src/secp256k1/src/tests_exhaustive.c @@ -1,7 +1,7 @@ /*********************************************************************** * Copyright (c) 2016 Andrew Poelstra * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #if defined HAVE_CONFIG_H diff --git a/src/secp256k1/src/util.h b/src/secp256k1/src/util.h index b0441d8e3..617d5701d 100644 --- a/src/secp256k1/src/util.h +++ b/src/secp256k1/src/util.h @@ -1,7 +1,7 @@ /********************************************************************** * Copyright (c) 2013, 2014 Pieter Wuille * * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* + * file COPYING or https://www.opensource.org/licenses/mit-license.php* **********************************************************************/ #ifndef SECP256K1_UTIL_H diff --git a/src/serialize.h b/src/serialize.h index 9d23b469c..d68752a98 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2009-2014 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/spentindex.h b/src/spentindex.h index f8bd3f961..5cb3b3599 100644 --- a/src/spentindex.h +++ b/src/spentindex.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_SPENTINDEX_H #define BITCOIN_SPENTINDEX_H diff --git a/src/streams.h b/src/streams.h index 83c90cd39..fadb058fc 100644 --- a/src/streams.h +++ b/src/streams.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/support/allocators/secure.h b/src/support/allocators/secure.h index 5e7bb66ea..af3828a83 100644 --- a/src/support/allocators/secure.h +++ b/src/support/allocators/secure.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_SUPPORT_ALLOCATORS_SECURE_H #define BITCOIN_SUPPORT_ALLOCATORS_SECURE_H diff --git a/src/support/allocators/zeroafterfree.h b/src/support/allocators/zeroafterfree.h index 41e23392e..c7351d1c4 100644 --- a/src/support/allocators/zeroafterfree.h +++ b/src/support/allocators/zeroafterfree.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_SUPPORT_ALLOCATORS_ZEROAFTERFREE_H #define BITCOIN_SUPPORT_ALLOCATORS_ZEROAFTERFREE_H diff --git a/src/support/cleanse.cpp b/src/support/cleanse.cpp index a2141b244..c92d43849 100644 --- a/src/support/cleanse.cpp +++ b/src/support/cleanse.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "cleanse.h" diff --git a/src/support/cleanse.h b/src/support/cleanse.h index 3e02aa8fd..e9fc9625f 100644 --- a/src/support/cleanse.h +++ b/src/support/cleanse.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_SUPPORT_CLEANSE_H #define BITCOIN_SUPPORT_CLEANSE_H diff --git a/src/support/events.h b/src/support/events.h index 4f2f3cf9e..662966ce8 100644 --- a/src/support/events.h +++ b/src/support/events.h @@ -1,6 +1,6 @@ // Copyright (c) 2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_SUPPORT_EVENTS_H #define BITCOIN_SUPPORT_EVENTS_H diff --git a/src/support/pagelocker.cpp b/src/support/pagelocker.cpp index d0b0d4dd8..ed9148fe1 100644 --- a/src/support/pagelocker.cpp +++ b/src/support/pagelocker.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2009-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "support/pagelocker.h" diff --git a/src/support/pagelocker.h b/src/support/pagelocker.h index 7385bc444..df5d98903 100644 --- a/src/support/pagelocker.h +++ b/src/support/pagelocker.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_SUPPORT_PAGELOCKER_H #define BITCOIN_SUPPORT_PAGELOCKER_H diff --git a/src/sync.h b/src/sync.h index a8f29eb66..729952a4d 100644 --- a/src/sync.h +++ b/src/sync.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/test/Checkpoints_tests.cpp b/src/test/Checkpoints_tests.cpp index 32b14cb93..9bc17acbb 100644 --- a/src/test/Checkpoints_tests.cpp +++ b/src/test/Checkpoints_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php // // Unit tests for block-chain checkpoints diff --git a/src/test/DoS_tests.cpp b/src/test/DoS_tests.cpp index 6044b221f..086b2f4d3 100644 --- a/src/test/DoS_tests.cpp +++ b/src/test/DoS_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php // // Unit tests for denial-of-service detection/prevention code diff --git a/src/test/accounting_tests.cpp b/src/test/accounting_tests.cpp index 0c2ade48d..e6e3f77d9 100644 --- a/src/test/accounting_tests.cpp +++ b/src/test/accounting_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "wallet/wallet.h" #include "wallet/walletdb.h" diff --git a/src/test/addrman_tests.cpp b/src/test/addrman_tests.cpp index 612802445..10b3031ad 100644 --- a/src/test/addrman_tests.cpp +++ b/src/test/addrman_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "addrman.h" #include "test/test_bitcoin.h" #include diff --git a/src/test/alert_tests.cpp b/src/test/alert_tests.cpp index 533b8f1ef..638340815 100644 --- a/src/test/alert_tests.cpp +++ b/src/test/alert_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php // // Unit tests for alert system diff --git a/src/test/allocator_tests.cpp b/src/test/allocator_tests.cpp index 2108efece..954793171 100644 --- a/src/test/allocator_tests.cpp +++ b/src/test/allocator_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "util.h" diff --git a/src/test/arith_uint256_tests.cpp b/src/test/arith_uint256_tests.cpp index 17d6bed6d..e7355427f 100644 --- a/src/test/arith_uint256_tests.cpp +++ b/src/test/arith_uint256_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include #include diff --git a/src/test/base32_tests.cpp b/src/test/base32_tests.cpp index 0b883fbef..c6aa39842 100644 --- a/src/test/base32_tests.cpp +++ b/src/test/base32_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "utilstrencodings.h" #include "test/test_bitcoin.h" diff --git a/src/test/base58_tests.cpp b/src/test/base58_tests.cpp index 80b2bb1dc..f7a2fefdd 100644 --- a/src/test/base58_tests.cpp +++ b/src/test/base58_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "base58.h" diff --git a/src/test/base64_tests.cpp b/src/test/base64_tests.cpp index b134e49ca..e2eebf0b5 100644 --- a/src/test/base64_tests.cpp +++ b/src/test/base64_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "utilstrencodings.h" #include "test/test_bitcoin.h" diff --git a/src/test/bctest.py b/src/test/bctest.py index 86724241b..50311cfea 100644 --- a/src/test/bctest.py +++ b/src/test/bctest.py @@ -1,6 +1,6 @@ # Copyright 2014 BitPay, Inc. # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php import subprocess import json diff --git a/src/test/bech32_tests.cpp b/src/test/bech32_tests.cpp index 02252bcbf..ac8ab33eb 100644 --- a/src/test/bech32_tests.cpp +++ b/src/test/bech32_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2017 Pieter Wuille // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "bech32.h" #include "test/test_bitcoin.h" diff --git a/src/test/bignum.h b/src/test/bignum.h index a7fb18953..5c530dda2 100644 --- a/src/test/bignum.h +++ b/src/test/bignum.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_TEST_BIGNUM_H #define BITCOIN_TEST_BIGNUM_H diff --git a/src/test/bip32_tests.cpp b/src/test/bip32_tests.cpp index 8815d1c54..9702b26bf 100644 --- a/src/test/bip32_tests.cpp +++ b/src/test/bip32_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include diff --git a/src/test/bitcoin-util-test.py b/src/test/bitcoin-util-test.py index 6551eb6f2..0f0204ae2 100755 --- a/src/test/bitcoin-util-test.py +++ b/src/test/bitcoin-util-test.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # Copyright 2014 BitPay, Inc. # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php import os import bctest diff --git a/src/test/bloom_tests.cpp b/src/test/bloom_tests.cpp index 9189e4af8..51e3096ec 100644 --- a/src/test/bloom_tests.cpp +++ b/src/test/bloom_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "bloom.h" diff --git a/src/test/checkblock_tests.cpp b/src/test/checkblock_tests.cpp index c813c9af9..3a5b6229c 100644 --- a/src/test/checkblock_tests.cpp +++ b/src/test/checkblock_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2013-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "clientversion.h" #include "consensus/validation.h" diff --git a/src/test/coins_tests.cpp b/src/test/coins_tests.cpp index 8067b42b9..897c38117 100644 --- a/src/test/coins_tests.cpp +++ b/src/test/coins_tests.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "coins.h" #include "random.h" diff --git a/src/test/compress_tests.cpp b/src/test/compress_tests.cpp index 92fe4728e..6a3934fc5 100644 --- a/src/test/compress_tests.cpp +++ b/src/test/compress_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "compressor.h" #include "util.h" diff --git a/src/test/convertbits_tests.cpp b/src/test/convertbits_tests.cpp index a8908ebfc..85fb924d0 100644 --- a/src/test/convertbits_tests.cpp +++ b/src/test/convertbits_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2018 The Zcash developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include #include diff --git a/src/test/crypto_tests.cpp b/src/test/crypto_tests.cpp index aeb2a5caa..4fe7f4da6 100644 --- a/src/test/crypto_tests.cpp +++ b/src/test/crypto_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "crypto/ripemd160.h" #include "crypto/sha1.h" diff --git a/src/test/data/README.md b/src/test/data/README.md index 2463daa42..49fc3a6b4 100644 --- a/src/test/data/README.md +++ b/src/test/data/README.md @@ -8,5 +8,5 @@ License The data files in this directory are distributed under the MIT software license, see the accompanying file COPYING or -http://www.opensource.org/licenses/mit-license.php. +https://www.opensource.org/licenses/mit-license.php diff --git a/src/test/dbwrapper_tests.cpp b/src/test/dbwrapper_tests.cpp index a047938db..7cef1e05d 100644 --- a/src/test/dbwrapper_tests.cpp +++ b/src/test/dbwrapper_tests.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2018 The Zcash developers // Copyright (c) 2012-2017 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "dbwrapper.h" #include "uint256.h" diff --git a/src/test/equihash_tests.cpp b/src/test/equihash_tests.cpp index 6f2f0b858..213022421 100644 --- a/src/test/equihash_tests.cpp +++ b/src/test/equihash_tests.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2016 Jack Grigg // Copyright (c) 2016 The Zcash developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #if defined(HAVE_CONFIG_H) #include "config/bitcoin-config.h" diff --git a/src/test/getarg_tests.cpp b/src/test/getarg_tests.cpp index a0c5592a9..8fbbf04d8 100644 --- a/src/test/getarg_tests.cpp +++ b/src/test/getarg_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "util.h" #include "test/test_bitcoin.h" diff --git a/src/test/hash_tests.cpp b/src/test/hash_tests.cpp index e5d2e5a43..549d5dcc1 100644 --- a/src/test/hash_tests.cpp +++ b/src/test/hash_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "hash.h" #include "utilstrencodings.h" diff --git a/src/test/key_tests.cpp b/src/test/key_tests.cpp index 390b2bc7b..4c659b6ed 100644 --- a/src/test/key_tests.cpp +++ b/src/test/key_tests.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "key.h" diff --git a/src/test/main_tests.cpp b/src/test/main_tests.cpp index ec02352e8..ef3b2c32c 100644 --- a/src/test/main_tests.cpp +++ b/src/test/main_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "chainparams.h" #include "main.h" diff --git a/src/test/mempool_tests.cpp b/src/test/mempool_tests.cpp index a82f5bce6..e7c509b8f 100644 --- a/src/test/mempool_tests.cpp +++ b/src/test/mempool_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "consensus/upgrades.h" #include "main.h" diff --git a/src/test/miner_tests.cpp b/src/test/miner_tests.cpp index 277b726c8..49e307f3b 100644 --- a/src/test/miner_tests.cpp +++ b/src/test/miner_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "arith_uint256.h" #include "consensus/validation.h" diff --git a/src/test/mruset_tests.cpp b/src/test/mruset_tests.cpp index 2b68f8899..59e173404 100644 --- a/src/test/mruset_tests.cpp +++ b/src/test/mruset_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "mruset.h" diff --git a/src/test/multisig_tests.cpp b/src/test/multisig_tests.cpp index a7e48ee4c..6bd6060d2 100644 --- a/src/test/multisig_tests.cpp +++ b/src/test/multisig_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "consensus/upgrades.h" #include "key.h" diff --git a/src/test/netbase_tests.cpp b/src/test/netbase_tests.cpp index 40b32a7b3..65a079c31 100644 --- a/src/test/netbase_tests.cpp +++ b/src/test/netbase_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "netbase.h" #include "test/test_bitcoin.h" diff --git a/src/test/pmt_tests.cpp b/src/test/pmt_tests.cpp index 3975dff2e..b70ec9f5d 100644 --- a/src/test/pmt_tests.cpp +++ b/src/test/pmt_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "merkleblock.h" #include "serialize.h" diff --git a/src/test/policyestimator_tests.cpp b/src/test/policyestimator_tests.cpp index a530749e7..159171199 100644 --- a/src/test/policyestimator_tests.cpp +++ b/src/test/policyestimator_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011-2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "policy/fees.h" #include "txmempool.h" diff --git a/src/test/pow_tests.cpp b/src/test/pow_tests.cpp index 8837a43c8..ca24fb449 100644 --- a/src/test/pow_tests.cpp +++ b/src/test/pow_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "main.h" #include "pow.h" diff --git a/src/test/prevector_tests.cpp b/src/test/prevector_tests.cpp index 01a45b540..fa475e3d2 100644 --- a/src/test/prevector_tests.cpp +++ b/src/test/prevector_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include #include "prevector.h" diff --git a/src/test/raii_event_tests.cpp b/src/test/raii_event_tests.cpp index 0f40874f5..2cf13950c 100644 --- a/src/test/raii_event_tests.cpp +++ b/src/test/raii_event_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include diff --git a/src/test/reverselock_tests.cpp b/src/test/reverselock_tests.cpp index 8bdff9700..189db4ae2 100644 --- a/src/test/reverselock_tests.cpp +++ b/src/test/reverselock_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "reverselock.h" #include "test/test_bitcoin.h" diff --git a/src/test/rpc_tests.cpp b/src/test/rpc_tests.cpp index d0e94ab5d..ab7000a33 100644 --- a/src/test/rpc_tests.cpp +++ b/src/test/rpc_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "rpc/server.h" #include "rpc/client.h" diff --git a/src/test/sanity_tests.cpp b/src/test/sanity_tests.cpp index f5f7f381d..fdb57c455 100644 --- a/src/test/sanity_tests.cpp +++ b/src/test/sanity_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "compat/sanity.h" #include "key.h" diff --git a/src/test/scheduler_tests.cpp b/src/test/scheduler_tests.cpp index d6c93ef3b..6c0087bf3 100644 --- a/src/test/scheduler_tests.cpp +++ b/src/test/scheduler_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "random.h" #include "scheduler.h" diff --git a/src/test/script_P2PKH_tests.cpp b/src/test/script_P2PKH_tests.cpp index 8fbb054b9..cc3868138 100644 --- a/src/test/script_P2PKH_tests.cpp +++ b/src/test/script_P2PKH_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "script/script.h" #include "test/test_bitcoin.h" diff --git a/src/test/script_P2SH_tests.cpp b/src/test/script_P2SH_tests.cpp index fac63dbf5..6ab9380ae 100644 --- a/src/test/script_P2SH_tests.cpp +++ b/src/test/script_P2SH_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "consensus/upgrades.h" #include "core_io.h" diff --git a/src/test/script_tests.cpp b/src/test/script_tests.cpp index 4e8388358..46b82c80b 100644 --- a/src/test/script_tests.cpp +++ b/src/test/script_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "data/script_invalid.json.h" #include "data/script_valid.json.h" diff --git a/src/test/scriptnum_tests.cpp b/src/test/scriptnum_tests.cpp index d95724dbe..736f24397 100644 --- a/src/test/scriptnum_tests.cpp +++ b/src/test/scriptnum_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "bignum.h" #include "script/script.h" diff --git a/src/test/serialize_tests.cpp b/src/test/serialize_tests.cpp index eaf69f175..230d74c65 100644 --- a/src/test/serialize_tests.cpp +++ b/src/test/serialize_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "serialize.h" #include "streams.h" diff --git a/src/test/sighash_tests.cpp b/src/test/sighash_tests.cpp index f7ecfe5c8..fa8c60240 100644 --- a/src/test/sighash_tests.cpp +++ b/src/test/sighash_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "consensus/upgrades.h" #include "consensus/validation.h" diff --git a/src/test/sigopcount_tests.cpp b/src/test/sigopcount_tests.cpp index ea2b9b795..1d3131dd9 100644 --- a/src/test/sigopcount_tests.cpp +++ b/src/test/sigopcount_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "pubkey.h" #include "key.h" diff --git a/src/test/skiplist_tests.cpp b/src/test/skiplist_tests.cpp index 3c33db168..fd389d7d1 100644 --- a/src/test/skiplist_tests.cpp +++ b/src/test/skiplist_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "main.h" #include "random.h" diff --git a/src/test/test_bitcoin.cpp b/src/test/test_bitcoin.cpp index 176d90848..96b13e083 100644 --- a/src/test/test_bitcoin.cpp +++ b/src/test/test_bitcoin.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #define BOOST_TEST_MODULE Bitcoin Test Suite diff --git a/src/test/timedata_tests.cpp b/src/test/timedata_tests.cpp index 887cfb476..e1566007e 100644 --- a/src/test/timedata_tests.cpp +++ b/src/test/timedata_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php // #include "timedata.h" #include "test/test_bitcoin.h" diff --git a/src/test/torcontrol_tests.cpp b/src/test/torcontrol_tests.cpp index b7affaacd..8c1488003 100644 --- a/src/test/torcontrol_tests.cpp +++ b/src/test/torcontrol_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2017 The Zcash developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php // #include "test/test_bitcoin.h" #include "torcontrol.cpp" diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp index eb948f92d..4a56e71f2 100644 --- a/src/test/transaction_tests.cpp +++ b/src/test/transaction_tests.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2019-2020 The Hush developers // Copyright (c) 2011-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "data/tx_invalid.json.h" #include "data/tx_valid.json.h" diff --git a/src/test/uint256_tests.cpp b/src/test/uint256_tests.cpp index a6501faa1..8e7b12494 100644 --- a/src/test/uint256_tests.cpp +++ b/src/test/uint256_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "arith_uint256.h" #include "uint256.h" #include "version.h" diff --git a/src/test/univalue_tests.cpp b/src/test/univalue_tests.cpp index f3bbfaef1..ef5937d7f 100644 --- a/src/test/univalue_tests.cpp +++ b/src/test/univalue_tests.cpp @@ -1,6 +1,6 @@ // Copyright 2014 BitPay, Inc. // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include #include diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index 0fcdd6530..fa26c005e 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2011-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "util.h" diff --git a/src/test/wallet-utility.py b/src/test/wallet-utility.py index c0a7bfb9e..bb32b5a4f 100644 --- a/src/test/wallet-utility.py +++ b/src/test/wallet-utility.py @@ -1,7 +1,7 @@ #!/usr/bin/python # Copyright 2014 BitPay, Inc. # Distributed under the MIT software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# file COPYING or https://www.opensource.org/licenses/mit-license.php import subprocess import os diff --git a/src/threadsafety.h b/src/threadsafety.h index d01c50abb..21fb50975 100644 --- a/src/threadsafety.h +++ b/src/threadsafety.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2012 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_THREADSAFETY_H #define BITCOIN_THREADSAFETY_H diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp index c2eb490da..a2efb9fa1 100644 --- a/src/torcontrol.cpp +++ b/src/torcontrol.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2017 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "torcontrol.h" #include "utilstrencodings.h" diff --git a/src/torcontrol.h b/src/torcontrol.h index 44611c7b6..f3d3c504a 100644 --- a/src/torcontrol.h +++ b/src/torcontrol.h @@ -1,7 +1,7 @@ // Copyright (c) 2015 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /** * Functionality for communicating with Tor. diff --git a/src/transaction_builder.cpp b/src/transaction_builder.cpp index e1879e1d4..da9a220fa 100644 --- a/src/transaction_builder.cpp +++ b/src/transaction_builder.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2018 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "transaction_builder.h" diff --git a/src/transaction_builder.h b/src/transaction_builder.h index 39225433a..716166a85 100644 --- a/src/transaction_builder.h +++ b/src/transaction_builder.h @@ -1,7 +1,7 @@ // Copyright (c) 2018 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef TRANSACTION_BUILDER_H #define TRANSACTION_BUILDER_H diff --git a/src/txdb.cpp b/src/txdb.cpp index 78769c07c..bb1d5d60d 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -3,7 +3,7 @@ // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/txdb.h b/src/txdb.h index 81c0bb3ad..374e834da 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 2f10856d4..10cd053f8 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -3,7 +3,7 @@ // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/txmempool.h b/src/txmempool.h index 59eeb0d98..aeccdea85 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/ui_interface.h b/src/ui_interface.h index 59a549a9d..fa48f67f9 100644 --- a/src/ui_interface.h +++ b/src/ui_interface.h @@ -1,7 +1,7 @@ // Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2012 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_UI_INTERFACE_H #define BITCOIN_UI_INTERFACE_H diff --git a/src/uint256.cpp b/src/uint256.cpp index c238490b8..dad9c616b 100644 --- a/src/uint256.cpp +++ b/src/uint256.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/uint256.h b/src/uint256.h index d819dc630..360f1963c 100644 --- a/src/uint256.h +++ b/src/uint256.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/undo.h b/src/undo.h index fbb350e60..d670be812 100644 --- a/src/undo.h +++ b/src/undo.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2013 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_UNDO_H #define BITCOIN_UNDO_H diff --git a/src/univalue/gen/gen.cpp b/src/univalue/gen/gen.cpp index 17f361941..55e60e418 100644 --- a/src/univalue/gen/gen.cpp +++ b/src/univalue/gen/gen.cpp @@ -1,6 +1,6 @@ // Copyright 2014 BitPay Inc. // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php // // To re-create univalue_escapes.h: diff --git a/src/univalue/include/univalue.h b/src/univalue/include/univalue.h index dfc84f921..7cba19bd4 100644 --- a/src/univalue/include/univalue.h +++ b/src/univalue/include/univalue.h @@ -1,7 +1,7 @@ // Copyright 2014 BitPay Inc. // Copyright 2015 Bitcoin Core Developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef UNIVALUE_H__ #define UNIVALUE_H__ diff --git a/src/univalue/lib/univalue.cpp b/src/univalue/lib/univalue.cpp index 0e8005f23..8901cd5de 100644 --- a/src/univalue/lib/univalue.cpp +++ b/src/univalue/lib/univalue.cpp @@ -1,7 +1,7 @@ // Copyright 2014 BitPay Inc. // Copyright 2015 Bitcoin Core Developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include #include diff --git a/src/univalue/lib/univalue_read.cpp b/src/univalue/lib/univalue_read.cpp index e0a5b44ab..bbaa2d32b 100644 --- a/src/univalue/lib/univalue_read.cpp +++ b/src/univalue/lib/univalue_read.cpp @@ -1,6 +1,6 @@ // Copyright 2014 BitPay Inc. // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include #include diff --git a/src/univalue/lib/univalue_utffilter.h b/src/univalue/lib/univalue_utffilter.h index b4a9ddc0a..d4329af8a 100644 --- a/src/univalue/lib/univalue_utffilter.h +++ b/src/univalue/lib/univalue_utffilter.h @@ -1,6 +1,6 @@ // Copyright 2016 Wladimir J. van der Laan // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef UNIVALUE_UTFFILTER_H #define UNIVALUE_UTFFILTER_H diff --git a/src/univalue/lib/univalue_write.cpp b/src/univalue/lib/univalue_write.cpp index cf2783599..c0f9fd9a4 100644 --- a/src/univalue/lib/univalue_write.cpp +++ b/src/univalue/lib/univalue_write.cpp @@ -1,6 +1,6 @@ // Copyright 2014 BitPay Inc. // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include #include diff --git a/src/univalue/test/unitester.cpp b/src/univalue/test/unitester.cpp index 27cf1d845..edd3eec81 100644 --- a/src/univalue/test/unitester.cpp +++ b/src/univalue/test/unitester.cpp @@ -1,6 +1,6 @@ // Copyright 2014 BitPay Inc. // Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include #include diff --git a/src/util.cpp b/src/util.cpp index cb52c3f70..1edced4bc 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * @@ -1036,7 +1036,7 @@ std::string LicenseInfo() "\n" + FormatParagraph(_("This is experimental software!!!")) + "\n" + "\n" + - FormatParagraph(_("Distributed under the MIT software license, see the accompanying file COPYING or .")) + "\n" + + FormatParagraph(_("Distributed under the MIT software license, see the accompanying file COPYING or .")) + "\n" + "\n" + FormatParagraph(_("This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit and cryptographic software written by Eric Young.")) + "\n"; diff --git a/src/util.h b/src/util.h index d1bbdd26d..e742ef975 100644 --- a/src/util.h +++ b/src/util.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/utilmoneystr.cpp b/src/utilmoneystr.cpp index 0f3203432..b5e692e1b 100644 --- a/src/utilmoneystr.cpp +++ b/src/utilmoneystr.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "utilmoneystr.h" diff --git a/src/utilmoneystr.h b/src/utilmoneystr.h index 99c3ba830..5b36a7b5a 100644 --- a/src/utilmoneystr.h +++ b/src/utilmoneystr.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /** * Money parsing/formatting utilities. diff --git a/src/utilstrencodings.cpp b/src/utilstrencodings.cpp index 132ae82ab..6d9475e89 100644 --- a/src/utilstrencodings.cpp +++ b/src/utilstrencodings.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "utilstrencodings.h" diff --git a/src/utilstrencodings.h b/src/utilstrencodings.h index 2d851093f..b31464b23 100644 --- a/src/utilstrencodings.h +++ b/src/utilstrencodings.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /** * Utilities for converting data from/to strings. diff --git a/src/utiltime.cpp b/src/utiltime.cpp index f1a408a31..7918254ce 100644 --- a/src/utiltime.cpp +++ b/src/utiltime.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #if defined(HAVE_CONFIG_H) #include "config/bitcoin-config.h" diff --git a/src/utiltime.h b/src/utiltime.h index 900992f87..91d344ec1 100644 --- a/src/utiltime.h +++ b/src/utiltime.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_UTILTIME_H #define BITCOIN_UTILTIME_H diff --git a/src/validationinterface.h b/src/validationinterface.h index bc5477c99..d01bc271a 100644 --- a/src/validationinterface.h +++ b/src/validationinterface.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_VALIDATIONINTERFACE_H #define BITCOIN_VALIDATIONINTERFACE_H diff --git a/src/wallet/asyncrpcoperation_mergetoaddress.h b/src/wallet/asyncrpcoperation_mergetoaddress.h index 69150161e..00a4feffa 100644 --- a/src/wallet/asyncrpcoperation_mergetoaddress.h +++ b/src/wallet/asyncrpcoperation_mergetoaddress.h @@ -2,7 +2,7 @@ // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/wallet/asyncrpcoperation_saplingconsolidation.cpp b/src/wallet/asyncrpcoperation_saplingconsolidation.cpp index 0c6cae7c1..88231c1ed 100644 --- a/src/wallet/asyncrpcoperation_saplingconsolidation.cpp +++ b/src/wallet/asyncrpcoperation_saplingconsolidation.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2019-2020 The Hush developers // Copyright (c) 2019 CryptoForge // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "assert.h" #include "boost/variant/static_visitor.hpp" diff --git a/src/wallet/asyncrpcoperation_saplingconsolidation.h b/src/wallet/asyncrpcoperation_saplingconsolidation.h index 5d14b9335..7124cea98 100644 --- a/src/wallet/asyncrpcoperation_saplingconsolidation.h +++ b/src/wallet/asyncrpcoperation_saplingconsolidation.h @@ -1,7 +1,7 @@ // Copyright (c) 2020 The Hush developers // Copyright (c) 2019 CryptoForge // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "amount.h" #include "asyncrpcoperation.h" diff --git a/src/wallet/asyncrpcoperation_sendmany.h b/src/wallet/asyncrpcoperation_sendmany.h index 86e6ef775..8839805c2 100644 --- a/src/wallet/asyncrpcoperation_sendmany.h +++ b/src/wallet/asyncrpcoperation_sendmany.h @@ -1,7 +1,7 @@ // Copyright (c) 2016 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/wallet/asyncrpcoperation_shieldcoinbase.cpp b/src/wallet/asyncrpcoperation_shieldcoinbase.cpp index 78b89712e..22964b835 100644 --- a/src/wallet/asyncrpcoperation_shieldcoinbase.cpp +++ b/src/wallet/asyncrpcoperation_shieldcoinbase.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2017 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/wallet/asyncrpcoperation_shieldcoinbase.h b/src/wallet/asyncrpcoperation_shieldcoinbase.h index 3eb1a6cfc..7dfd0842f 100644 --- a/src/wallet/asyncrpcoperation_shieldcoinbase.h +++ b/src/wallet/asyncrpcoperation_shieldcoinbase.h @@ -1,7 +1,7 @@ // Copyright (c) 2017 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/wallet/crypter.h b/src/wallet/crypter.h index 8a7de32b4..5d441770d 100644 --- a/src/wallet/crypter.h +++ b/src/wallet/crypter.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp index 1814e9209..6a9579b12 100644 --- a/src/wallet/db.cpp +++ b/src/wallet/db.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/wallet/db.h b/src/wallet/db.h index 31ba88f11..18d6462ad 100644 --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index af50bb9d1..d1af21da7 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/wallet/rpchushwallet.cpp b/src/wallet/rpchushwallet.cpp index 5fd77cc97..36d35d952 100644 --- a/src/wallet/rpchushwallet.cpp +++ b/src/wallet/rpchushwallet.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2019-2020 The Hush developers // Copyright (c) 2019 Cryptoforge // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "init.h" #include "key_io.h" diff --git a/src/wallet/rpchushwallet.h b/src/wallet/rpchushwallet.h index b9a6d6f6f..33915caeb 100644 --- a/src/wallet/rpchushwallet.h +++ b/src/wallet/rpchushwallet.h @@ -1,7 +1,7 @@ // Copyright (c) 2020 The Hush developers // Copyright (c) 2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_WALLET_RPCHUSHWALLET_H #define BITCOIN_WALLET_RPCHUSHWALLET_H diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 89d15f14f..f4066c547 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/wallet/rpcwallet.h b/src/wallet/rpcwallet.h index 7739e94a2..00d7897e2 100644 --- a/src/wallet/rpcwallet.h +++ b/src/wallet/rpcwallet.h @@ -1,6 +1,6 @@ // Copyright (c) 2016 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp index 01482e08e..c70d7a8ca 100644 --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2012-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "wallet/wallet.h" diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index fc27679e5..0cc5b81b4 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 475214919..5a8ee7012 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/wallet/wallet_ismine.cpp b/src/wallet/wallet_ismine.cpp index 692d0280d..ed260125a 100644 --- a/src/wallet/wallet_ismine.cpp +++ b/src/wallet/wallet_ismine.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/wallet/wallet_ismine.h b/src/wallet/wallet_ismine.h index 409def1ef..57b0a164b 100644 --- a/src/wallet/wallet_ismine.h +++ b/src/wallet/wallet_ismine.h @@ -1,7 +1,7 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp index 71331ed93..6fb3e543e 100644 --- a/src/wallet/walletdb.cpp +++ b/src/wallet/walletdb.cpp @@ -2,7 +2,7 @@ // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * diff --git a/src/zcash/zip32.cpp b/src/zcash/zip32.cpp index 615c5896d..820c99fa2 100644 --- a/src/zcash/zip32.cpp +++ b/src/zcash/zip32.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2018 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "zip32.h" diff --git a/src/zcash/zip32.h b/src/zcash/zip32.h index 1521dddd1..88095f981 100644 --- a/src/zcash/zip32.h +++ b/src/zcash/zip32.h @@ -1,7 +1,7 @@ // Copyright (c) 2018 The Zcash developers // Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef ZCASH_ZIP32_H #define ZCASH_ZIP32_H diff --git a/src/zmq/zmqabstractnotifier.cpp b/src/zmq/zmqabstractnotifier.cpp index 3562a8824..75bb7b505 100644 --- a/src/zmq/zmqabstractnotifier.cpp +++ b/src/zmq/zmqabstractnotifier.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "zmqabstractnotifier.h" #include "util.h" diff --git a/src/zmq/zmqabstractnotifier.h b/src/zmq/zmqabstractnotifier.h index 8873b71d8..090b0b8f5 100644 --- a/src/zmq/zmqabstractnotifier.h +++ b/src/zmq/zmqabstractnotifier.h @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_ZMQ_ZMQABSTRACTNOTIFIER_H #define BITCOIN_ZMQ_ZMQABSTRACTNOTIFIER_H diff --git a/src/zmq/zmqconfig.h b/src/zmq/zmqconfig.h index 6057f5d1a..d382071df 100644 --- a/src/zmq/zmqconfig.h +++ b/src/zmq/zmqconfig.h @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_ZMQ_ZMQCONFIG_H #define BITCOIN_ZMQ_ZMQCONFIG_H diff --git a/src/zmq/zmqnotificationinterface.cpp b/src/zmq/zmqnotificationinterface.cpp index 0d8c36ad2..0745890b4 100644 --- a/src/zmq/zmqnotificationinterface.cpp +++ b/src/zmq/zmqnotificationinterface.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "zmqnotificationinterface.h" #include "zmqpublishnotifier.h" diff --git a/src/zmq/zmqnotificationinterface.h b/src/zmq/zmqnotificationinterface.h index e0fe3b570..0fe2f4bab 100644 --- a/src/zmq/zmqnotificationinterface.h +++ b/src/zmq/zmqnotificationinterface.h @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_ZMQ_ZMQNOTIFICATIONINTERFACE_H #define BITCOIN_ZMQ_ZMQNOTIFICATIONINTERFACE_H diff --git a/src/zmq/zmqpublishnotifier.cpp b/src/zmq/zmqpublishnotifier.cpp index e3fd635f2..14ff40f08 100644 --- a/src/zmq/zmqpublishnotifier.cpp +++ b/src/zmq/zmqpublishnotifier.cpp @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #include "zmqpublishnotifier.h" #include "main.h" diff --git a/src/zmq/zmqpublishnotifier.h b/src/zmq/zmqpublishnotifier.h index 627c8af96..d5b752eda 100644 --- a/src/zmq/zmqpublishnotifier.h +++ b/src/zmq/zmqpublishnotifier.h @@ -1,6 +1,6 @@ // Copyright (c) 2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or https://www.opensource.org/licenses/mit-license.php #ifndef BITCOIN_ZMQ_ZMQPUBLISHNOTIFIER_H #define BITCOIN_ZMQ_ZMQPUBLISHNOTIFIER_H From e880a45995abfb1747246403bdeb70bd4a498f8e Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 20 Sep 2020 13:58:16 -0400 Subject: [PATCH 234/255] Fix block 128 bug discoverd by @denioD --- src/komodo_bitcoind.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index fe495e176..f21f0cc71 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1247,7 +1247,7 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); uint64_t hush_commission(int height) { int32_t starting_commission = 125000000, HALVING1 = GetArg("-z2zheight",340000), - INTERVAL = GetArg("-ac_halving1",840000), TRANSITION = 128; + INTERVAL = GetArg("-ac_halving1",840000), TRANSITION = 129; uint64_t commission = 0; //TODO: Likely a bug hiding here or at the next halving :) @@ -1262,6 +1262,7 @@ uint64_t hush_commission(int height) fprintf(stderr,"%s: height=%d increasing interval to %d\n", __func__, height, INTERVAL); } + // Block 128 had a miner subsidy but no FR!!! Discovered by Denio if (height < TRANSITION) { commission = 0; } else { From 8317beef1e36219a1abe36c5055713d7ce786f61 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sun, 20 Sep 2020 14:33:15 -0400 Subject: [PATCH 235/255] Increase logspam for deletetx=1 and -zdebug --- src/wallet/wallet.cpp | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 0cc5b81b4..ffab54fd4 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2389,6 +2389,8 @@ void CWallet::WitnessNoteCommitment(std::vector commitments, void CWallet::ReorderWalletTransactions(std::map, CWalletTx*> &mapSorted, int64_t &maxOrderPos) { LOCK2(cs_main, cs_wallet); + if(fZdebug) + fprintf(stderr,"%s: maxOrderPos=%li\n",__func__, maxOrderPos); int maxSortNumber = chainActive.Tip()->GetHeight() + 1; @@ -2419,8 +2421,11 @@ void CWallet::UpdateWalletTransactionOrder(std::map, CWalletT int64_t previousPosition = 0; std::map mapUpdatedTxs; + if(fZdebug) + fprintf(stderr,"%s: maxSorted.size=%li\n",__func__, mapSorted.size()); + //Check the postion of each transaction relative to the previous one. -for (map, CWalletTx*>::iterator it = mapSorted.begin(); it != mapSorted.end(); ++it) { + for (map, CWalletTx*>::iterator it = mapSorted.begin(); it != mapSorted.end(); ++it) { CWalletTx* pwtx = it->second; const uint256 wtxid = pwtx->GetHash(); @@ -2456,9 +2461,13 @@ for (map, CWalletTx*>::iterator it = mapSorted.begin(); it != void CWallet::DeleteTransactions(std::vector &removeTxs) { LOCK(cs_wallet); + int numTx = removeTxs.size(); + if(fZdebug) + fprintf(stderr,"%s: removeTxs.size=%d\n", __func__, numTx); + CWalletDB walletdb(strWalletFile, "r+", false); - for (int i = 0; i< removeTxs.size(); i++) { + for (int i = 0; i< numTx; i++) { if (mapWallet.erase(removeTxs[i])) { walletdb.EraseTx(removeTxs[i]); LogPrintf("%s: Deleting tx %s, %i.\n", __func__, removeTxs[i].ToString(),i); @@ -2481,6 +2490,9 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { int nDeleteAfter = (int)fDeleteTransactionsAfterNBlocks; bool runCompact = false; + if(fZdebug) + fprintf(stderr,"%s: nDeleteAfter=%d\n",__func__,nDeleteAfter); + if (pindex && fTxDeleteEnabled) { //Check for acentries - exit function if found @@ -2646,8 +2658,11 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { LogPrintf("Delete Tx - Total Transaction Count %i, Transactions Deleted %i\n ", txCount, int(removeTxs.size())); //Compress Wallet - if (runCompact) - CWalletDB::Compact(bitdb,strWalletFile); + if (runCompact) { + if(fZdebug) + fprintf(stderr,"%s: compacting wallet\n",__func__); + CWalletDB::Compact(bitdb,strWalletFile); + } } } @@ -2689,11 +2704,9 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) } } - //SproutMerkleTree sproutTree; SaplingMerkleTree saplingTree; // This should never fail: we should always be able to get the tree // state on the path to the tip of our chain - //assert(pcoinsTip->GetSproutAnchorAt(pindex->hashSproutAnchor, sproutTree)); if (pindex->pprev) { if (NetworkUpgradeActive(pindex->pprev->GetHeight(), Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) { assert(pcoinsTip->GetSaplingAnchorAt(pindex->pprev->hashFinalSaplingRoot, saplingTree)); From 61e805083cbc4a577502e3216a803a5ae8d39c43 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 21 Sep 2020 00:16:03 -0400 Subject: [PATCH 236/255] deletetx=1 logspam --- src/wallet/wallet.cpp | 109 +++++++++++++++++++++++++----------------- 1 file changed, 66 insertions(+), 43 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index ffab54fd4..42014f75e 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -487,7 +487,7 @@ void CWallet::ChainTip(const CBlockIndex *pindex, RunSaplingConsolidation(pindex->GetHeight()); DeleteWalletTransactions(pindex); } else { - //Build intial witnesses on every block + //Build initial witnesses on every block BuildWitnessCache(pindex, true); if (initialDownloadCheck && pindex->GetHeight() % fDeleteInterval == 0) { DeleteWalletTransactions(pindex); @@ -503,12 +503,18 @@ void CWallet::RunSaplingConsolidation(int blockHeight) { if (!NetworkUpgradeActive(blockHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) { return; } - LOCK(cs_wallet); + + LOCK(cs_wallet); + if (!fSaplingConsolidationEnabled) { return; } int consolidateInterval = rand() % 5 + 5; + + if(fZdebug) + fprintf(stderr,"%s: height=%d interval=%d\n", __func__, blockHeight, consolidateInterval); + if (blockHeight % consolidateInterval == 0) { std::shared_ptr q = getAsyncRPCQueue(); std::shared_ptr lastOperation = q->getOperationForId(saplingConsolidationOperationId); @@ -2397,20 +2403,21 @@ void CWallet::ReorderWalletTransactions(std::map, CWalletTx*> for (map::iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { CWalletTx* pwtx = &(it->second); - int confirms = pwtx->GetDepthInMainChain(); - maxOrderPos = max(maxOrderPos, pwtx->nOrderPos); + int confirms = pwtx->GetDepthInMainChain(); + maxOrderPos = max(maxOrderPos, pwtx->nOrderPos); if (confirms > 0) { int wtxHeight = mapBlockIndex[pwtx->hashBlock]->GetHeight(); auto key = std::make_pair(wtxHeight, pwtx->nIndex); mapSorted.insert(make_pair(key, pwtx)); - } - else { + } else { auto key = std::make_pair(maxSortNumber, 0); mapSorted.insert(std::make_pair(key, pwtx)); maxSortNumber++; } } + if(fZdebug) + fprintf(stderr,"%s: mapSorted.size=%lu\n",__func__, mapSorted.size()); } /**Update the nOrderPos with passed in ordered map. */ @@ -2422,37 +2429,43 @@ void CWallet::UpdateWalletTransactionOrder(std::map, CWalletT std::map mapUpdatedTxs; if(fZdebug) - fprintf(stderr,"%s: maxSorted.size=%li\n",__func__, mapSorted.size()); + fprintf(stderr,"%s: maxSorted.size=%li resetOrder=%d\n",__func__, mapSorted.size(),resetOrder); - //Check the postion of each transaction relative to the previous one. + //Check the position of each transaction relative to the previous one. for (map, CWalletTx*>::iterator it = mapSorted.begin(); it != mapSorted.end(); ++it) { - CWalletTx* pwtx = it->second; + CWalletTx* pwtx = it->second; const uint256 wtxid = pwtx->GetHash(); if (pwtx->nOrderPos <= previousPosition || resetOrder) { previousPosition++; pwtx->nOrderPos = previousPosition; mapUpdatedTxs.insert(std::make_pair(wtxid, pwtx)); - } - else { + } else { previousPosition = pwtx->nOrderPos; } } + if(fZdebug) + fprintf(stderr,"%s: updating %li changed transactions\n",__func__, mapUpdatedTxs.size() ); + //Update transactions nOrderPos for transactions that changed CWalletDB walletdb(strWalletFile, "r+", false); for (map::iterator it = mapUpdatedTxs.begin(); it != mapUpdatedTxs.end(); ++it) { CWalletTx* pwtx = it->second; LogPrintf("%s: Updating Positon to %i for Tx %s\n ", __func__, pwtx->nOrderPos, pwtx->GetHash().ToString()); - pwtx->WriteToDisk(&walletdb); + bool ret = pwtx->WriteToDisk(&walletdb); + if(fZdebug) + fprintf(stderr,"%s: wrote data to disk at %s for tx=%s ret=%d\n",__func__, strWalletFile.c_str(), pwtx->GetHash().ToString().c_str(), ret ); + mapWallet[pwtx->GetHash()].nOrderPos = pwtx->nOrderPos; } //Update Next Wallet Tx Positon nOrderPosNext = previousPosition++; CWalletDB(strWalletFile).WriteOrderPosNext(nOrderPosNext); + if(fZdebug) + fprintf(stderr,"%s: wrote data to disk at %s nOrderPosNext=%li\n",__func__, strWalletFile.c_str(), nOrderPosNext ); LogPrint("%s: Total Transactions Reordered %i, Next Position %i\n ", __func__, mapUpdatedTxs.size(), nOrderPosNext); - } /** @@ -2470,9 +2483,9 @@ void CWallet::DeleteTransactions(std::vector &removeTxs) { for (int i = 0; i< numTx; i++) { if (mapWallet.erase(removeTxs[i])) { walletdb.EraseTx(removeTxs[i]); - LogPrintf("%s: Deleting tx %s, %i.\n", __func__, removeTxs[i].ToString(),i); + LogPrintf("%s: Deleted tx %s, %i.\n", __func__, removeTxs[i].ToString(),i); } else { - LogPrintf("%s: Deleting tx %failed.\n", __func__, removeTxs[i].ToString()); + LogPrintf("%s: Deleting tx %s failed.\n", __func__, removeTxs[i].ToString()); return; } } @@ -2481,10 +2494,12 @@ void CWallet::DeleteTransactions(std::vector &removeTxs) { #else // On Mac and Win memory isn't kept back upon vector or list member erase, different garbage collector strategy. No need to force trimming. #endif + + if(fZdebug) + fprintf(stderr,"%s: finished deleting %d transactions\n", __func__, numTx); } void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { - LOCK2(cs_main, cs_wallet); int nDeleteAfter = (int)fDeleteTransactionsAfterNBlocks; @@ -2494,7 +2509,6 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { fprintf(stderr,"%s: nDeleteAfter=%d\n",__func__,nDeleteAfter); if (pindex && fTxDeleteEnabled) { - //Check for acentries - exit function if found { std::list acentries; @@ -2514,10 +2528,9 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { if (maxOrderPos > int64_t(mapSorted.size())*10) { //reset the postion when the max postion is 10x bigger than the //number of transactions in the wallet - LogPrint("deletetx","Reorder Tx - maxOrderPos %i mapSorted Size %i\n", maxOrderPos, int64_t(mapSorted.size())*10); + LogPrintf("%s: Reorder Tx - maxOrderPos %i mapSorted Size %i\n", __func__, maxOrderPos, int64_t(mapSorted.size())*10); UpdateWalletTransactionOrder(mapSorted, true); - } - else { + } else { UpdateWalletTransactionOrder(mapSorted, false); } @@ -2542,14 +2555,16 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { txUnConfirmed++; if (wtxDepth < nDeleteAfter && wtxDepth >= 0) { - LogPrint("deletetx","DeleteTx - Transaction above minimum depth, tx %s\n", pwtx->GetHash().ToString()); + if(fZdebug) + LogPrintf("%s: Transaction above minimum depth, tx %s\n", __func__, pwtx->GetHash().ToString()); deleteTx = false; txSaveCount++; continue; } else if (wtxDepth == -1) { //Enabled by default if (!fTxConflictDeleteEnabled) { - LogPrint("deletetx","DeleteTx - Conflict delete is not enabled tx %s\n", pwtx->GetHash().ToString()); + if(fZdebug) + LogPrintf("%s: Conflict delete is not enabled tx %s\n", __func__, pwtx->GetHash().ToString()); deleteTx = false; txSaveCount++; continue; @@ -2557,12 +2572,12 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { txConflictCount++; } } else { - //Check for unspent inputs or spend less than N Blocks ago. (Sapling) for (auto & pair : pwtx->mapSaplingNoteData) { SaplingNoteData nd = pair.second; if (!nd.nullifier || pwalletMain->GetSaplingSpendDepth(*nd.nullifier) <= fDeleteTransactionsAfterNBlocks) { - LogPrint("deletetx","DeleteTx - Unspent sapling input tx %s\n", pwtx->GetHash().ToString()); + if(fZdebug) + LogPrintf("%s: Unspent sapling input tx %s\n", __func__, pwtx->GetHash().ToString()); deleteTx = false; continue; } @@ -2573,6 +2588,9 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { continue; } + if(fZdebug) + LogPrintf("%s: Unspent sapling input tx %s\n", __func__, pwtx->GetHash().ToString()); + //Check for outputs that no longer have parents in the wallet. Exclude parents that are in the same transaction. (Sapling) for (int i = 0; i < pwtx->vShieldedSpend.size(); i++) { const SpendDescription& spendDesc = pwtx->vShieldedSpend[i]; @@ -2580,7 +2598,8 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { const uint256& parentHash = pwalletMain->mapSaplingNullifiersToNotes[spendDesc.nullifier].hash; const CWalletTx* parent = pwalletMain->GetWalletTx(parentHash); if (parent != NULL && parentHash != wtxid) { - LogPrint("deletetx","DeleteTx - Parent of sapling tx %s found\n", pwtx->GetHash().ToString()); + if(fZdebug) + LogPrintf("%s: Parent of sapling tx %s found\n", __func__, pwtx->GetHash().ToString()); deleteTx = false; continue; } @@ -2592,23 +2611,16 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { continue; } - if (!deleteTx) { - txSaveCount++; - continue; - } + if(fZdebug) + LogPrintf("%s: Checking for unspent transparent inputs or spends less than %d Blocks ago\n",__func__, fDeleteTransactionsAfterNBlocks); - if (!deleteTx) { - txSaveCount++; - continue; - } - - //Check for unspent inputs or spend less than N Blocks ago. (Transparent) for (unsigned int i = 0; i < pwtx->vout.size(); i++) { CTxDestination address; ExtractDestination(pwtx->vout[i].scriptPubKey, address); if(IsMine(pwtx->vout[i])) { if (pwalletMain->GetSpendDepth(pwtx->GetHash(), i) <= fDeleteTransactionsAfterNBlocks) { - LogPrint("deletetx","DeleteTx - Unspent transparent input tx %s\n", pwtx->GetHash().ToString()); + if(fZdebug) + LogPrintf("%s: Unspent transparent input tx %s\n", __func__, pwtx->GetHash().ToString()); deleteTx = false; continue; } @@ -2620,13 +2632,15 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { continue; } - //Chcek for output with that no longer have parents in the wallet. (Transparent) + if(fZdebug) + LogPrintf("%s: Checking for transparent outputs that no longer have parents in the wallet\n",__func__); for (int i = 0; i < pwtx->vin.size(); i++) { const CTxIn& txin = pwtx->vin[i]; const uint256& parentHash = txin.prevout.hash; const CWalletTx* parent = pwalletMain->GetWalletTx(txin.prevout.hash); if (parent != NULL && parentHash != wtxid) { - LogPrint("deletetx","DeleteTx - Parent of transparent tx %s found\n", pwtx->GetHash().ToString()); + if(fZdebug) + LogPrintf("%s: Parent of transparent tx %s found\n", __func__, pwtx->GetHash().ToString()); deleteTx = false; continue; } @@ -2639,7 +2653,8 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { //Keep Last N Transactions if (mapSorted.size() - txCount < fKeepLastNTransactions + txConflictCount + txUnConfirmed) { - LogPrint("deletetx","DeleteTx - Transaction set position %i, tx %s\n", mapSorted.size() - txCount, wtxid.ToString()); + if(fZdebug) + LogPrint("%s: Transaction set position %i, tx %s\n", __func__, mapSorted.size() - txCount, wtxid.ToString()); deleteTx = false; txSaveCount++; continue; @@ -2655,7 +2670,7 @@ void CWallet::DeleteWalletTransactions(const CBlockIndex* pindex) { //Delete Transactions from wallet DeleteTransactions(removeTxs); - LogPrintf("Delete Tx - Total Transaction Count %i, Transactions Deleted %i\n ", txCount, int(removeTxs.size())); + LogPrintf("%s: Total Transaction Count %i, Transactions Deleted %i\n ", __func__, txCount, int(removeTxs.size())); //Compress Wallet if (runCompact) { @@ -2676,9 +2691,10 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) int ret = 0; int64_t nNow = GetTime(); const CChainParams& chainParams = Params(); + if(fZdebug) + LogPrintf("%s: fUpdate=%d now=%li\n",fUpdate,nNow); CBlockIndex* pindex = pindexStart; - { LOCK2(cs_main, cs_wallet); @@ -2713,7 +2729,7 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) } } - // Build inital witness caches + // Build initial witness caches BuildWitnessCache(pindex, true); //Delete Transactions @@ -2737,6 +2753,10 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) void CWallet::ReacceptWalletTransactions() { + int64_t nNow = GetTime(); + if(fZdebug) + LogPrintf("%s: now=%li\n",nNow); + if ( IsInitialBlockDownload() ) return; // If transactions aren't being broadcasted, don't let them into local mempool either @@ -2779,7 +2799,7 @@ void CWallet::ReacceptWalletTransactions() if (!wtx.IsCoinBase() && invalid && nDoS > 0 && state.GetRejectReason() != "tx-overwinter-expired") { - LogPrintf("erasing transaction %s\n", wtx.GetHash().GetHex().c_str()); + LogPrintf("%s: erasing transaction %s\n", __func__, wtx.GetHash().GetHex().c_str()); vwtxh.push_back(wtx.GetHash()); } } @@ -2792,6 +2812,9 @@ void CWallet::ReacceptWalletTransactions() bool CWalletTx::RelayWalletTransaction() { + int64_t nNow = GetTime(); + if(fZdebug) + LogPrintf("%s: now=%li\n",nNow); if ( pwallet == 0 ) { //fprintf(stderr,"unexpected null pwallet in RelayWalletTransaction\n"); From b5d308f182709f228533ba840ffdc3e94d57ebac Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 21 Sep 2020 01:03:38 -0400 Subject: [PATCH 237/255] Fix deletetx=1 coredump and more logspam --- src/asyncrpcoperation.cpp | 2 +- .../asyncrpcoperation_saplingconsolidation.cpp | 4 ++-- src/wallet/wallet.cpp | 14 ++++++++------ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/asyncrpcoperation.cpp b/src/asyncrpcoperation.cpp index dd4e481da..328b3b9ff 100644 --- a/src/asyncrpcoperation.cpp +++ b/src/asyncrpcoperation.cpp @@ -1,7 +1,7 @@ // Copyright (c) 2016 The Zcash developers +// Copyright (c) 2019-2020 The Hush developers // Distributed under the MIT software license, see the accompanying // file COPYING or https://www.opensource.org/licenses/mit-license.php - /****************************************************************************** * Copyright © 2014-2019 The SuperNET Developers. * * * diff --git a/src/wallet/asyncrpcoperation_saplingconsolidation.cpp b/src/wallet/asyncrpcoperation_saplingconsolidation.cpp index 88231c1ed..855df3835 100644 --- a/src/wallet/asyncrpcoperation_saplingconsolidation.cpp +++ b/src/wallet/asyncrpcoperation_saplingconsolidation.cpp @@ -78,7 +78,7 @@ void AsyncRPCOperation_saplingconsolidation::main() { bool AsyncRPCOperation_saplingconsolidation::main_impl() { bool status=true; auto opid=getId(); - LogPrint("zrpcunsafe", "%s: Beginning AsyncRPCOperation_saplingconsolidation.\n", opid); + LogPrintf("%s: Beginning AsyncRPCOperation_saplingconsolidation.\n", __func__, opid); auto consensusParams = Params().GetConsensus(); auto nextActivationHeight = NextActivationHeight(targetHeight_, consensusParams); if (nextActivationHeight && targetHeight_ + CONSOLIDATION_EXPIRY_DELTA >= nextActivationHeight.get()) { @@ -161,7 +161,7 @@ bool AsyncRPCOperation_saplingconsolidation::main_impl() { auto builder = TransactionBuilder(consensusParams, targetHeight_, pwalletMain); //builder.SetExpiryHeight(targetHeight_ + CONSOLIDATION_EXPIRY_DELTA); auto actualAmountToSend = amountToSend < fConsolidationTxFee ? 0 : amountToSend - fConsolidationTxFee; - LogPrint("zrpcunsafe", "%s: Beginning to create transaction with Sapling output amount=%s\n", opid, FormatMoney(actualAmountToSend)); + LogPrintf("%s: %s Beginning to create transaction with Sapling output amount=%s\n", __func__, opid, FormatMoney(actualAmountToSend)); // Select Sapling notes std::vector ops; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 42014f75e..b6548cb42 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2452,20 +2452,22 @@ void CWallet::UpdateWalletTransactionOrder(std::map, CWalletT CWalletDB walletdb(strWalletFile, "r+", false); for (map::iterator it = mapUpdatedTxs.begin(); it != mapUpdatedTxs.end(); ++it) { CWalletTx* pwtx = it->second; - LogPrintf("%s: Updating Positon to %i for Tx %s\n ", __func__, pwtx->nOrderPos, pwtx->GetHash().ToString()); + LogPrintf("%s: Updating Position to %i for Tx %s\n ", __func__, pwtx->nOrderPos, pwtx->GetHash().ToString()); bool ret = pwtx->WriteToDisk(&walletdb); if(fZdebug) fprintf(stderr,"%s: wrote data to disk at %s for tx=%s ret=%d\n",__func__, strWalletFile.c_str(), pwtx->GetHash().ToString().c_str(), ret ); mapWallet[pwtx->GetHash()].nOrderPos = pwtx->nOrderPos; } + if(fZdebug) + fprintf(stderr,"%s: updated nOrderPos on %lu transactions\n",__func__, mapUpdatedTxs.size() ); - //Update Next Wallet Tx Positon + //Update Next Wallet Tx Position nOrderPosNext = previousPosition++; CWalletDB(strWalletFile).WriteOrderPosNext(nOrderPosNext); if(fZdebug) fprintf(stderr,"%s: wrote data to disk at %s nOrderPosNext=%li\n",__func__, strWalletFile.c_str(), nOrderPosNext ); - LogPrint("%s: Total Transactions Reordered %i, Next Position %i\n ", __func__, mapUpdatedTxs.size(), nOrderPosNext); + LogPrintf("%s: Total Transactions Reordered %i, Next Position %i\n ", __func__, mapUpdatedTxs.size(), nOrderPosNext); } /** @@ -2692,7 +2694,7 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) int64_t nNow = GetTime(); const CChainParams& chainParams = Params(); if(fZdebug) - LogPrintf("%s: fUpdate=%d now=%li\n",fUpdate,nNow); + LogPrintf("%s: fUpdate=%d now=%li\n",__func__,fUpdate,nNow); CBlockIndex* pindex = pindexStart; { @@ -2755,7 +2757,7 @@ void CWallet::ReacceptWalletTransactions() { int64_t nNow = GetTime(); if(fZdebug) - LogPrintf("%s: now=%li\n",nNow); + LogPrintf("%s: now=%li\n",__func__,nNow); if ( IsInitialBlockDownload() ) return; @@ -2814,7 +2816,7 @@ bool CWalletTx::RelayWalletTransaction() { int64_t nNow = GetTime(); if(fZdebug) - LogPrintf("%s: now=%li\n",nNow); + LogPrintf("%s: now=%li\n",__func__,nNow); if ( pwallet == 0 ) { //fprintf(stderr,"unexpected null pwallet in RelayWalletTransaction\n"); From edb0f4be9014398fb51e7ee04afad2cf6bda2aae Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Mon, 21 Sep 2020 07:27:53 -0400 Subject: [PATCH 238/255] less logspam --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index f21f0cc71..9e2182104 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -710,7 +710,7 @@ bool hush_hardfork_active(uint32_t time) uint32_t nHardForkHeight = GetArg("-hardfork-height", nHushHardforkHeight); bool isactive = chainActive.Height() > nHardForkHeight; if(fDebug) { - fprintf(stderr, "%s: active=%d at height=%d and forkheight=%d\n", __FUNCTION__, (int)isactive, chainActive.Height(), nHardForkHeight); + //fprintf(stderr, "%s: active=%d at height=%d and forkheight=%d\n", __FUNCTION__, (int)isactive, chainActive.Height(), nHardForkHeight); } return isactive; } From 4128dce2eaa29f263d85ebf63e3200169bfa1c88 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Tue, 22 Sep 2020 18:11:35 -0400 Subject: [PATCH 239/255] Add checkpoint for our beloved block 300K --- src/chainparams.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 6f2f81225..f53af85c5 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -657,10 +657,11 @@ void *chainparams_commandline() (280000, uint256S("0x000000036b2c0edb762736b4243cdba4d5b576456cc4c6b6a29ed69d27f0c4d9")) (285000, uint256S("0x000000064ca1b27d679ffc9e25af53d531d9f80bc00fd130f5a71054b2f96124")) (290000, uint256S("0x00000000c9bd5248099f4caca2a5b1da88548cd1824bb22a0efa6c30cf6ccfce")) - (295000, uint256S("0x00000002fb6bbf41e4f17f88301895c9143ea93e628523b97e5bd5765070d803")), - (int64_t) 1599924956, // time of last checkpointed block - (int64_t) 573115, // total txs - (double) 970 // txs in the last day before block 298951 + (295000, uint256S("0x00000002fb6bbf41e4f17f88301895c9143ea93e628523b97e5bd5765070d803")) + (300000, uint256S("0x000000033322d90275a09f4094e5c43db1f7017f788145d5a0edfa8200ecedad")), + (int64_t) 1600695750, // time of last checkpointed block + (int64_t) 576831, // total txs + (double) 1134 // txs in the last day before block 300768 }; } else { checkpointData = //(Checkpoints::CCheckpointData) From 7835fbd3411100b6f2ff8194c5f15e5dd93427ce Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Wed, 23 Sep 2020 12:51:37 -0700 Subject: [PATCH 240/255] Fix for win64 systems, hopefully --- src/wallet/wallet.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index b6548cb42..4ead8000c 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2491,7 +2491,8 @@ void CWallet::DeleteTransactions(std::vector &removeTxs) { return; } } -#if defined(__GLIBC__) +//TODO: the build system should check for malloc_trim support +#if defined(__unix__) malloc_trim(0); #else // On Mac and Win memory isn't kept back upon vector or list member erase, different garbage collector strategy. No need to force trimming. From 410a1bdf9459adc9d3061bd82c47e8690e033d59 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 25 Sep 2020 09:37:06 -0400 Subject: [PATCH 241/255] Add script to make linux bins --- contrib/devtools/gen-linux-binary-release.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 contrib/devtools/gen-linux-binary-release.sh diff --git a/contrib/devtools/gen-linux-binary-release.sh b/contrib/devtools/gen-linux-binary-release.sh new file mode 100644 index 000000000..21d4d70b9 --- /dev/null +++ b/contrib/devtools/gen-linux-binary-release.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# Copyright (c) 2019-2020 The Hush developers +# Released under the GPLv3 + + +#TODO: autodect version number, error handling +FILE="hush-3.5.0-linux-amd64.tar" + +mkdir build +cp sapling*.params build/ +cd src +cp komodod komodo-cli komodo-tx hushd hush-cli hush-tx hush-smart-chain ../build +cd ../build +tar -f $FILE -c * +gzip $FILE + From b33b1db4f1225c13e003d1241531433ff269487a Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Sat, 26 Sep 2020 23:33:25 -0400 Subject: [PATCH 242/255] lol --- src/wallet/wallet.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 4ead8000c..452bfea89 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1018,7 +1018,7 @@ int CWallet::VerifyAndSetInitialWitness(const CBlockIndex* pindex, bool witnessO pblockindex = chainActive[wtxHeight]; ::ClearSingleNoteWitnessCache(nd); - LogPrintf("Setting Initial Sapling Witness for tx %s, %i of %i\n", wtxHash.ToString(), nWitnessTxIncrement, nWitnessTotalTxCount); + LogPrintf("%s: Setting Initial Sapling Witness for tx %s, %i of %i\n", __func__, wtxHash.ToString(), nWitnessTxIncrement, nWitnessTotalTxCount); SaplingMerkleTree saplingTree; blockRoot = pblockindex->pprev->hashFinalSaplingRoot; @@ -1063,6 +1063,8 @@ int CWallet::VerifyAndSetInitialWitness(const CBlockIndex* pindex, bool witnessO } } + if(fZdebug) + LogPrintf("%s: nMinimumHeight=%d\n",__func__, nMinimumHeight); return nMinimumHeight; } @@ -1077,10 +1079,11 @@ void CWallet::BuildWitnessCache(const CBlockIndex* pindex, bool witnessOnly) return; } - uint256 sproutRoot; uint256 saplingRoot; CBlockIndex* pblockindex = chainActive[startHeight]; int height = chainActive.Height(); + if(fZdebug) + LogPrintf("%s: height=%d, startHeight=%\n", __func__, height, startHeight); while (pblockindex) { From 3e81631dc93e5fe094d6d7f36698b9013305ef13 Mon Sep 17 00:00:00 2001 From: miodragpop Date: Mon, 28 Sep 2020 15:25:42 +0200 Subject: [PATCH 243/255] openssl updated from 1.1.1a to 1.1.1h Complete list of improvements and bugfixes can be found at the link below https://www.openssl.org/news/openssl-1.1.1-notes.html --- depends/packages/openssl.mk | 46 ++--- depends/patches/openssl/ssl_fix.patch | 273 -------------------------- 2 files changed, 24 insertions(+), 295 deletions(-) delete mode 100644 depends/patches/openssl/ssl_fix.patch diff --git a/depends/packages/openssl.mk b/depends/packages/openssl.mk index 276e887a7..5a2a70138 100644 --- a/depends/packages/openssl.mk +++ b/depends/packages/openssl.mk @@ -1,9 +1,8 @@ package=openssl -$(package)_version=1.1.1a -$(package)_download_path=https://www.openssl.org/source/old/1.1.1 +$(package)_version=1.1.1h +$(package)_download_path=https://www.openssl.org/source $(package)_file_name=$(package)-$($(package)_version).tar.gz -$(package)_sha256_hash=fc20130f8b7cbd2fb918b2f14e2f429e109c31ddd0fb38fc5d71d9ffed3f9f41 -$(package)_patches=ssl_fix.patch +$(package)_sha256_hash=5c9ca8774bd7b03e5784f26ae9e9e6d749c9da2438545077e6b3d755a06595d9 define $(package)_set_vars $(package)_config_env=AR="$($(package)_ar)" RANLIB="$($(package)_ranlib)" CC="$($(package)_cc)" @@ -14,39 +13,40 @@ $(package)_config_opts+=no-async $(package)_config_opts+=no-bf $(package)_config_opts+=no-blake2 $(package)_config_opts+=no-camellia -$(package)_config_opts+=no-capieng +#$(package)_config_opts+=no-capieng $(package)_config_opts+=no-cast $(package)_config_opts+=no-chacha $(package)_config_opts+=no-cmac $(package)_config_opts+=no-cms -$(package)_config_opts+=no-comp +#$(package)_config_opts+=no-comp $(package)_config_opts+=no-crypto-mdebug $(package)_config_opts+=no-crypto-mdebug-backtrace -$(package)_config_opts+=no-ct +#$(package)_config_opts+=no-ct +#$(package)_config_opts+=no-des $(package)_config_opts+=no-dgram -$(package)_config_opts+=no-dsa +#$(package)_config_opts+=no-dsa $(package)_config_opts+=no-dso $(package)_config_opts+=no-dtls $(package)_config_opts+=no-dtls1 $(package)_config_opts+=no-dtls1-method $(package)_config_opts+=no-dynamic-engine -$(package)_config_opts+=no-ec2m -$(package)_config_opts+=no-ec_nistp_64_gcc_128 +#$(package)_config_opts+=no-ec2m +#$(package)_config_opts+=no-ec_nistp_64_gcc_128 $(package)_config_opts+=no-egd $(package)_config_opts+=no-engine -$(package)_config_opts+=no-err +#$(package)_config_opts+=no-err $(package)_config_opts+=no-gost $(package)_config_opts+=no-heartbeats -$(package)_config_opts+=no-idea +#$(package)_config_opts+=no-idea $(package)_config_opts+=no-md2 $(package)_config_opts+=no-md4 $(package)_config_opts+=no-mdc2 $(package)_config_opts+=no-multiblock $(package)_config_opts+=no-nextprotoneg $(package)_config_opts+=no-ocb -$(package)_config_opts+=no-ocsp +#$(package)_config_opts+=no-ocsp $(package)_config_opts+=no-poly1305 -$(package)_config_opts+=no-posix-io +#$(package)_config_opts+=no-posix-io $(package)_config_opts+=no-psk $(package)_config_opts+=no-rc2 $(package)_config_opts+=no-rc4 @@ -58,21 +58,24 @@ $(package)_config_opts+=no-scrypt $(package)_config_opts+=no-sctp $(package)_config_opts+=no-seed $(package)_config_opts+=no-shared +#$(package)_config_opts+=no-sock $(package)_config_opts+=no-srp $(package)_config_opts+=no-srtp +$(package)_config_opts+=no-ssl $(package)_config_opts+=no-ssl3 $(package)_config_opts+=no-ssl3-method $(package)_config_opts+=no-ssl-trace -$(package)_config_opts+=no-stdio -$(package)_config_opts+=no-tls1 -$(package)_config_opts+=no-tls1-method +#$(package)_config_opts+=no-stdio +#$(package)_config_opts+=no-tls +#$(package)_config_opts+=no-tls1 +#$(package)_config_opts+=no-tls1-method $(package)_config_opts+=no-ts $(package)_config_opts+=no-ui $(package)_config_opts+=no-unit-test $(package)_config_opts+=no-weak-ssl-ciphers $(package)_config_opts+=no-whirlpool -$(package)_config_opts+=no-zlib -$(package)_config_opts+=no-zlib-dynamic +#$(package)_config_opts+=no-zlib +#$(package)_config_opts+=no-zlib-dynamic $(package)_config_opts+=$($(package)_cflags) $($(package)_cppflags) $(package)_config_opts+=-DPURIFY $(package)_config_opts_linux=-fPIC -Wa,--noexecstack @@ -89,9 +92,8 @@ $(package)_config_opts_i686_mingw32=mingw endef define $(package)_preprocess_cmds - sed -i.old 's/built on: $date/built on: not available/' util/mkbuildinf.pl && \ - sed -i.old "s|\"engines\", \"apps\", \"test\"|\"engines\"|" Configure && \ - patch -p1 < $($(package)_patch_dir)/ssl_fix.patch + sed -i.old 's/built on: $$$$date/built on: date not available/' util/mkbuildinf.pl && \ + sed -i.old "s|\"engines\", \"apps\", \"test\"|\"engines\"|" Configure endef define $(package)_config_cmds diff --git a/depends/patches/openssl/ssl_fix.patch b/depends/patches/openssl/ssl_fix.patch deleted file mode 100644 index d7f79fed5..000000000 --- a/depends/patches/openssl/ssl_fix.patch +++ /dev/null @@ -1,273 +0,0 @@ -From f725fe5b4b6504df08e30f5194d321c3025e2336 Mon Sep 17 00:00:00 2001 -From: Matt Caswell -Date: Tue, 20 Nov 2018 15:32:55 +0000 -Subject: [PATCH] Fix a RUN_ONCE bug - -We have a number of instances where there are multiple "init" functions for -a single CRYPTO_ONCE variable, e.g. to load config automatically or to not -load config automatically. Unfortunately the RUN_ONCE mechanism was not -correctly giving the right return value where an alternative init function -was being used. - -Reviewed-by: Tim Hudson -(Merged from https://github.com/openssl/openssl/pull/7983) ---- - crypto/init.c | 38 +++++++++----- - include/internal/thread_once.h | 92 ++++++++++++++++++++++++++++++++++ - ssl/ssl_init.c | 6 ++- - 3 files changed, 121 insertions(+), 15 deletions(-) - -diff --git a/crypto/init.c b/crypto/init.c -index 209d1a483da..f20a12f069a 100644 ---- a/crypto/init.c -+++ b/crypto/init.c -@@ -177,12 +177,6 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_load_crypto_nodelete) - - static CRYPTO_ONCE load_crypto_strings = CRYPTO_ONCE_STATIC_INIT; - static int load_crypto_strings_inited = 0; --DEFINE_RUN_ONCE_STATIC(ossl_init_no_load_crypto_strings) --{ -- /* Do nothing in this case */ -- return 1; --} -- - DEFINE_RUN_ONCE_STATIC(ossl_init_load_crypto_strings) - { - int ret = 1; -@@ -201,6 +195,13 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_load_crypto_strings) - return ret; - } - -+DEFINE_RUN_ONCE_STATIC_ALT(ossl_init_no_load_crypto_strings, -+ ossl_init_load_crypto_strings) -+{ -+ /* Do nothing in this case */ -+ return 1; -+} -+ - static CRYPTO_ONCE add_all_ciphers = CRYPTO_ONCE_STATIC_INIT; - DEFINE_RUN_ONCE_STATIC(ossl_init_add_all_ciphers) - { -@@ -218,6 +219,13 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_add_all_ciphers) - return 1; - } - -+DEFINE_RUN_ONCE_STATIC_ALT(ossl_init_no_add_all_ciphers, -+ ossl_init_add_all_ciphers) -+{ -+ /* Do nothing */ -+ return 1; -+} -+ - static CRYPTO_ONCE add_all_digests = CRYPTO_ONCE_STATIC_INIT; - DEFINE_RUN_ONCE_STATIC(ossl_init_add_all_digests) - { -@@ -235,7 +243,8 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_add_all_digests) - return 1; - } - --DEFINE_RUN_ONCE_STATIC(ossl_init_no_add_algs) -+DEFINE_RUN_ONCE_STATIC_ALT(ossl_init_no_add_all_digests, -+ ossl_init_add_all_digests) - { - /* Do nothing */ - return 1; -@@ -255,7 +264,7 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_config) - config_inited = 1; - return 1; - } --DEFINE_RUN_ONCE_STATIC(ossl_init_no_config) -+DEFINE_RUN_ONCE_STATIC_ALT(ossl_init_no_config, ossl_init_config) - { - #ifdef OPENSSL_INIT_DEBUG - fprintf(stderr, -@@ -595,8 +604,9 @@ int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings) - return 0; - - if ((opts & OPENSSL_INIT_NO_LOAD_CRYPTO_STRINGS) -- && !RUN_ONCE(&load_crypto_strings, -- ossl_init_no_load_crypto_strings)) -+ && !RUN_ONCE_ALT(&load_crypto_strings, -+ ossl_init_no_load_crypto_strings, -+ ossl_init_load_crypto_strings)) - return 0; - - if ((opts & OPENSSL_INIT_LOAD_CRYPTO_STRINGS) -@@ -604,7 +614,8 @@ int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings) - return 0; - - if ((opts & OPENSSL_INIT_NO_ADD_ALL_CIPHERS) -- && !RUN_ONCE(&add_all_ciphers, ossl_init_no_add_algs)) -+ && !RUN_ONCE_ALT(&add_all_ciphers, ossl_init_no_add_all_ciphers, -+ ossl_init_add_all_ciphers)) - return 0; - - if ((opts & OPENSSL_INIT_ADD_ALL_CIPHERS) -@@ -612,7 +623,8 @@ int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings) - return 0; - - if ((opts & OPENSSL_INIT_NO_ADD_ALL_DIGESTS) -- && !RUN_ONCE(&add_all_digests, ossl_init_no_add_algs)) -+ && !RUN_ONCE_ALT(&add_all_digests, ossl_init_no_add_all_digests, -+ ossl_init_add_all_digests)) - return 0; - - if ((opts & OPENSSL_INIT_ADD_ALL_DIGESTS) -@@ -624,7 +636,7 @@ int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings) - return 0; - - if ((opts & OPENSSL_INIT_NO_LOAD_CONFIG) -- && !RUN_ONCE(&config, ossl_init_no_config)) -+ && !RUN_ONCE_ALT(&config, ossl_init_no_config, ossl_init_config)) - return 0; - - if (opts & OPENSSL_INIT_LOAD_CONFIG) { -diff --git a/include/internal/thread_once.h b/include/internal/thread_once.h -index 224244353ab..e268a959ef3 100644 ---- a/include/internal/thread_once.h -+++ b/include/internal/thread_once.h -@@ -9,6 +9,20 @@ - - #include - -+/* -+ * DEFINE_RUN_ONCE: Define an initialiser function that should be run exactly -+ * once. It takes no arguments and returns and int result (1 for success or -+ * 0 for failure). Typical usage might be: -+ * -+ * DEFINE_RUN_ONCE(myinitfunc) -+ * { -+ * do_some_initialisation(); -+ * if (init_is_successful()) -+ * return 1; -+ * -+ * return 0; -+ * } -+ */ - #define DEFINE_RUN_ONCE(init) \ - static int init(void); \ - int init##_ossl_ret_ = 0; \ -@@ -17,10 +31,30 @@ - init##_ossl_ret_ = init(); \ - } \ - static int init(void) -+ -+/* -+ * DECLARE_RUN_ONCE: Declare an initialiser function that should be run exactly -+ * once that has been defined in another file via DEFINE_RUN_ONCE(). -+ */ - #define DECLARE_RUN_ONCE(init) \ - extern int init##_ossl_ret_; \ - void init##_ossl_(void); - -+/* -+ * DEFINE_RUN_ONCE_STATIC: Define an initialiser function that should be run -+ * exactly once. This function will be declared as static within the file. It -+ * takes no arguments and returns and int result (1 for success or 0 for -+ * failure). Typical usage might be: -+ * -+ * DEFINE_RUN_ONCE_STATIC(myinitfunc) -+ * { -+ * do_some_initialisation(); -+ * if (init_is_successful()) -+ * return 1; -+ * -+ * return 0; -+ * } -+ */ - #define DEFINE_RUN_ONCE_STATIC(init) \ - static int init(void); \ - static int init##_ossl_ret_ = 0; \ -@@ -30,6 +64,46 @@ - } \ - static int init(void) - -+/* -+ * DEFINE_RUN_ONCE_STATIC_ALT: Define an alternative initialiser function. This -+ * function will be declared as static within the file. It takes no arguments -+ * and returns an int result (1 for success or 0 for failure). An alternative -+ * initialiser function is expected to be associated with a primary initialiser -+ * function defined via DEFINE_ONCE_STATIC where both functions use the same -+ * CRYPTO_ONCE object to synchronise. Where an alternative initialiser function -+ * is used only one of the primary or the alternative initialiser function will -+ * ever be called - and that function will be called exactly once. Definitition -+ * of an alternative initialiser function MUST occur AFTER the definition of the -+ * primary initialiser function. -+ * -+ * Typical usage might be: -+ * -+ * DEFINE_RUN_ONCE_STATIC(myinitfunc) -+ * { -+ * do_some_initialisation(); -+ * if (init_is_successful()) -+ * return 1; -+ * -+ * return 0; -+ * } -+ * -+ * DEFINE_RUN_ONCE_STATIC_ALT(myaltinitfunc, myinitfunc) -+ * { -+ * do_some_alternative_initialisation(); -+ * if (init_is_successful()) -+ * return 1; -+ * -+ * return 0; -+ * } -+ */ -+#define DEFINE_RUN_ONCE_STATIC_ALT(initalt, init) \ -+ static int initalt(void); \ -+ static void initalt##_ossl_(void) \ -+ { \ -+ init##_ossl_ret_ = initalt(); \ -+ } \ -+ static int initalt(void) -+ - /* - * RUN_ONCE - use CRYPTO_THREAD_run_once, and check if the init succeeded - * @once: pointer to static object of type CRYPTO_ONCE -@@ -43,3 +117,21 @@ - */ - #define RUN_ONCE(once, init) \ - (CRYPTO_THREAD_run_once(once, init##_ossl_) ? init##_ossl_ret_ : 0) -+ -+/* -+ * RUN_ONCE_ALT - use CRYPTO_THREAD_run_once, to run an alternative initialiser -+ * function and check if that initialisation succeeded -+ * @once: pointer to static object of type CRYPTO_ONCE -+ * @initalt: alternative initialiser function name that was previously given to -+ * DEFINE_RUN_ONCE_STATIC_ALT. This function must return 1 for -+ * success or 0 for failure. -+ * @init: primary initialiser function name that was previously given to -+ * DEFINE_RUN_ONCE_STATIC. This function must return 1 for success or -+ * 0 for failure. -+ * -+ * The return value is 1 on success (*) or 0 in case of error. -+ * -+ * (*) by convention, since the init function must return 1 on success. -+ */ -+#define RUN_ONCE_ALT(once, initalt, init) \ -+ (CRYPTO_THREAD_run_once(once, initalt##_ossl_) ? init##_ossl_ret_ : 0) -diff --git a/ssl/ssl_init.c b/ssl/ssl_init.c -index c0ccb9304a6..96526472c57 100644 ---- a/ssl/ssl_init.c -+++ b/ssl/ssl_init.c -@@ -134,7 +134,8 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_load_ssl_strings) - return 1; - } - --DEFINE_RUN_ONCE_STATIC(ossl_init_no_load_ssl_strings) -+DEFINE_RUN_ONCE_STATIC_ALT(ossl_init_no_load_ssl_strings, -+ ossl_init_load_ssl_strings) - { - /* Do nothing in this case */ - return 1; -@@ -207,7 +208,8 @@ int OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS * settings) - return 0; - - if ((opts & OPENSSL_INIT_NO_LOAD_SSL_STRINGS) -- && !RUN_ONCE(&ssl_strings, ossl_init_no_load_ssl_strings)) -+ && !RUN_ONCE_ALT(&ssl_strings, ossl_init_no_load_ssl_strings, -+ ossl_init_load_ssl_strings)) - return 0; - - if ((opts & OPENSSL_INIT_LOAD_SSL_STRINGS) From 62f67821ecd801cc26b9f3aa14de8735d6563a0a Mon Sep 17 00:00:00 2001 From: miodragpop Date: Tue, 29 Sep 2020 13:08:45 +0200 Subject: [PATCH 244/255] tls implemented --- src/Makefile.am | 26 ++- src/hush/tlsenums.h | 8 + src/hush/tlsmanager.cpp | 484 +++++++++++++++++++++++++++++++++++++++ src/hush/tlsmanager.h | 58 +++++ src/hush/utiltls.cpp | 494 ++++++++++++++++++++++++++++++++++++++++ src/hush/utiltls.h | 56 +++++ src/init.cpp | 23 ++ src/net.cpp | 365 +++++++++++++++++++++++------ src/net.h | 28 ++- src/rpc/misc.cpp | 2 + src/rpc/net.cpp | 7 +- 11 files changed, 1479 insertions(+), 72 deletions(-) create mode 100644 src/hush/tlsenums.h create mode 100644 src/hush/tlsmanager.cpp create mode 100644 src/hush/tlsmanager.h create mode 100644 src/hush/utiltls.cpp create mode 100644 src/hush/utiltls.h diff --git a/src/Makefile.am b/src/Makefile.am index dc66cb4a8..6c4a62a8d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -50,6 +50,7 @@ LIBSECP256K1=secp256k1/libsecp256k1.la LIBCRYPTOCONDITIONS=cryptoconditions/libcryptoconditions_core.la LIBUNIVALUE=univalue/libunivalue.la LIBZCASH=libzcash.a +LIBHUSH=libhush.a if ENABLE_ZMQ LIBBITCOIN_ZMQ=libbitcoin_zmq.a @@ -78,7 +79,8 @@ EXTRA_LIBRARIES += \ $(LIBBITCOIN_COMMON) \ $(LIBBITCOIN_SERVER) \ $(LIBBITCOIN_CLI) \ - libzcash.a + libzcash.a \ + libhush.a if ENABLE_WALLET BITCOIN_INCLUDES += $(BDB_CPPFLAGS) EXTRA_LIBRARIES += $(LIBBITCOIN_WALLET) @@ -238,6 +240,8 @@ BITCOIN_CORE_H = \ zmq/zmqnotificationinterface.h \ zmq/zmqpublishnotifier.h +LIBHUSH_H = \ + hush/utiltls.h obj/build.h: FORCE @$(MKDIR_P) $(builddir)/obj @@ -314,7 +318,8 @@ libbitcoin_server_a_SOURCES = \ txmempool.cpp \ validationinterface.cpp \ $(BITCOIN_CORE_H) \ - $(LIBZCASH_H) + $(LIBZCASH_H) \ + $(LIBHUSH_H) if ENABLE_ZMQ libbitcoin_zmq_a_CPPFLAGS = $(BITCOIN_INCLUDES) $(ZMQ_CFLAGS) @@ -491,6 +496,7 @@ komodod_LDADD = \ $(LIBBITCOIN_ZMQ) \ $(LIBBITCOIN_CRYPTO) \ $(LIBZCASH) \ + $(LIBHUSH) \ $(LIBLEVELDB) \ $(LIBMEMENV) \ $(LIBSECP256K1) \ @@ -556,6 +562,7 @@ komodo_cli_LDADD = \ $(CRYPTO_LIBS) \ $(EVENT_LIBS) \ $(LIBZCASH) \ + $(LIBHUSH) \ $(LIBBITCOIN_CRYPTO) \ $(LIBZCASH_LIBS) @@ -590,6 +597,7 @@ komodo_tx_LDADD = \ $(LIBBITCOIN_UTIL) \ $(LIBSECP256K1) \ $(LIBZCASH) \ + $(LIBHUSH) \ $(LIBBITCOIN_CRYPTO) \ $(LIBZCASH_LIBS) \ $(LIBCRYPTOCONDITIONS) @@ -649,6 +657,20 @@ libzcashconsensus_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) endif # +# hush-specific sources # +libhush_a_SOURCES = \ + hush/utiltls.cpp\ + hush/tlsmanager.cpp + +libhush_a_CPPFLAGS = -DMULTICORE -fopenmp -fPIC -DBINARY_OUTPUT -DCURVE_ALT_BN128 -DBOOST_SPIRIT_THREADSAFE -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS $(HARDENED_CPPFLAGS) -pipe -O1 -g -Wstack-protector -fstack-protector-all -fPIE -fvisibility=hidden -DSTATIC $(BITCOIN_INCLUDES) + +libhush_a_CXXFLAGS = $(HARDENED_CXXFLAGS) -fwrapv -fno-strict-aliasing + +libhush_a_LDFLAGS = $(HARDENED_LDFLAGS) + +libhush_a_CPPFLAGS += -DMONTGOMERY_OUTPUT +# + CLEANFILES = leveldb/libleveldb.a leveldb/libmemenv.a *.gcda *.gcno */*.gcno wallet/*/*.gcno DISTCLEANFILES = obj/build.h diff --git a/src/hush/tlsenums.h b/src/hush/tlsenums.h new file mode 100644 index 000000000..a7caf3a6c --- /dev/null +++ b/src/hush/tlsenums.h @@ -0,0 +1,8 @@ +namespace hush +{ +typedef enum { SSL_ACCEPT, + SSL_CONNECT, + SSL_SHUTDOWN } SSLConnectionRoutine; +typedef enum { CLIENT_CONTEXT, + SERVER_CONTEXT } TLSContextType; +} diff --git a/src/hush/tlsmanager.cpp b/src/hush/tlsmanager.cpp new file mode 100644 index 000000000..73bdd4407 --- /dev/null +++ b/src/hush/tlsmanager.cpp @@ -0,0 +1,484 @@ +#include +#include +#include +#include "utiltls.h" + +#include +#include +#include "../util.h" +#include "../protocol.h" + +#include +#include + +#include "tlsmanager.h" +using namespace std; +namespace hush +{ +/** +* @brief If verify_callback always returns 1, the TLS/SSL handshake will not be terminated with respect to verification failures and the connection will be established. +* +* @param preverify_ok +* @param chainContext +* @return int +*/ +int tlsCertVerificationCallback(int preverify_ok, X509_STORE_CTX* chainContext) +{ + return 1; +} +/** + * @brief Wait for a given SSL connection event. + * + * @param eRoutine a SSLConnectionRoutine value which determines the type of the event. + * @param hSocket + * @param ssl pointer to an SSL instance. + * @param timeoutSec timeout in seconds. + * @return int returns nError corresponding to the connection event. + */ +int TLSManager::waitFor(SSLConnectionRoutine eRoutine, SOCKET hSocket, SSL* ssl, int timeoutSec) +{ + int nErr = 0; + ERR_clear_error(); // clear the error queue + + while (true) { + switch (eRoutine) { + case SSL_CONNECT: + nErr = SSL_connect(ssl); + break; + + case SSL_ACCEPT: + nErr = SSL_accept(ssl); + break; + + case SSL_SHUTDOWN: + nErr = SSL_shutdown(ssl); + break; + + default: + return -1; + } + + if (eRoutine == SSL_SHUTDOWN) { + if (nErr >= 0) + break; + } else { + if (nErr == 1) + break; + } + + int sslErr = SSL_get_error(ssl, nErr); + + if (sslErr != SSL_ERROR_WANT_READ && sslErr != SSL_ERROR_WANT_WRITE) { + LogPrint("net", "TLS: WARNING: %s: %s: ssl_err_code: %s; errno: %s\n", __FILE__, __func__, ERR_error_string(sslErr, NULL), strerror(errno)); + nErr = -1; + break; + } + + fd_set socketSet; + FD_ZERO(&socketSet); + FD_SET(hSocket, &socketSet); + + struct timeval timeout = {timeoutSec, 0}; + + if (sslErr == SSL_ERROR_WANT_READ) { + int result = select(hSocket + 1, &socketSet, NULL, NULL, &timeout); + if (result == 0) { + LogPrint("net", "TLS: ERROR: %s: %s: WANT_READ timeout\n", __FILE__, __func__); + nErr = -1; + break; + } else if (result == -1) { + LogPrint("net", "TLS: ERROR: %s: %s: WANT_READ ssl_err_code: %s; errno: %s\n", __FILE__, __func__, ERR_error_string(sslErr, NULL), strerror(errno)); + nErr = -1; + break; + } + } else { + int result = select(hSocket + 1, NULL, &socketSet, NULL, &timeout); + if (result == 0) { + LogPrint("net", "TLS: ERROR: %s: %s: WANT_WRITE timeout\n", __FILE__, __func__); + nErr = -1; + break; + } else if (result == -1) { + LogPrint("net", "TLS: ERROR: %s: %s: WANT_WRITE ssl_err_code: %s; errno: %s\n", __FILE__, __func__, ERR_error_string(sslErr, NULL), strerror(errno)); + nErr = -1; + break; + } + } + } + + return nErr; +} +/** + * @brief establish TLS connection to an address + * + * @param hSocket socket + * @param addrConnect the outgoing address + * @param tls_ctx_client TLS Client context + * @return SSL* returns a ssl* if successful, otherwise returns NULL. + */ +SSL* TLSManager::connect(SOCKET hSocket, const CAddress& addrConnect) +{ + LogPrint("net", "TLS: establishing connection (tid = %X), (peerid = %s)\n", pthread_self(), addrConnect.ToString()); + + SSL* ssl = NULL; + bool bConnectedTLS = false; + + if ((ssl = SSL_new(tls_ctx_client))) { + if (SSL_set_fd(ssl, hSocket)) { + if (TLSManager::waitFor(SSL_CONNECT, hSocket, ssl, (DEFAULT_CONNECT_TIMEOUT / 1000)) == 1) + + bConnectedTLS = true; + } + } + + if (bConnectedTLS) { + LogPrintf("TLS: connection to %s has been established. Using cipher: %s\n", addrConnect.ToString(), SSL_get_cipher(ssl)); + } else { + LogPrintf("TLS: %s: %s: TLS connection to %s failed\n", __FILE__, __func__, addrConnect.ToString()); + + if (ssl) { + SSL_free(ssl); + ssl = NULL; + } + } + return ssl; +} +/** + * @brief Initialize TLS Context + * + * @param ctxType context type + * @param privateKeyFile private key file path + * @param certificateFile certificate key file path + * @param trustedDirs trusted directories + * @return SSL_CTX* returns the context. + */ +SSL_CTX* TLSManager::initCtx( + TLSContextType ctxType, + const boost::filesystem::path& privateKeyFile, + const boost::filesystem::path& certificateFile, + const std::vector& trustedDirs) +{ + if (!boost::filesystem::exists(privateKeyFile) || + !boost::filesystem::exists(certificateFile)) + return NULL; + + bool bInitialized = false; + SSL_CTX* tlsCtx = NULL; + + if ((tlsCtx = SSL_CTX_new(ctxType == SERVER_CONTEXT ? TLS_server_method() : TLS_client_method()))) { + SSL_CTX_set_mode(tlsCtx, SSL_MODE_AUTO_RETRY); + + int rootCertsNum = LoadDefaultRootCertificates(tlsCtx); + int trustedPathsNum = 0; + + for (boost::filesystem::path trustedDir : trustedDirs) { + if (SSL_CTX_load_verify_locations(tlsCtx, NULL, trustedDir.string().c_str()) == 1) + trustedPathsNum++; + } + + if (rootCertsNum == 0 && trustedPathsNum == 0) + LogPrintf("TLS: WARNING: %s: %s: failed to set up verified certificates. It will be impossible to verify peer certificates. \n", __FILE__, __func__); + + SSL_CTX_set_verify(tlsCtx, SSL_VERIFY_PEER, tlsCertVerificationCallback); + + if (SSL_CTX_use_certificate_file(tlsCtx, certificateFile.string().c_str(), SSL_FILETYPE_PEM) > 0) { + if (SSL_CTX_use_PrivateKey_file(tlsCtx, privateKeyFile.string().c_str(), SSL_FILETYPE_PEM) > 0) { + if (SSL_CTX_check_private_key(tlsCtx)) + bInitialized = true; + else + LogPrintf("TLS: ERROR: %s: %s: private key does not match the certificate public key\n", __FILE__, __func__); + } else + LogPrintf("TLS: ERROR: %s: %s: failed to use privateKey file\n", __FILE__, __func__); + } else { + LogPrintf("TLS: ERROR: %s: %s: failed to use certificate file\n", __FILE__, __func__); + ERR_print_errors_fp(stderr); + } + } else + LogPrintf("TLS: ERROR: %s: %s: failed to create TLS context\n", __FILE__, __func__); + + if (!bInitialized) { + if (tlsCtx) { + SSL_CTX_free(tlsCtx); + tlsCtx = NULL; + } + } + + return tlsCtx; +} +/** + * @brief load the certificate credentials from file. + * + * @return true returns true is successful. + * @return false returns false if an error has occured. + */ +bool TLSManager::prepareCredentials() +{ + boost::filesystem::path + defaultKeyPath(GetDataDir() / TLS_KEY_FILE_NAME), + defaultCertPath(GetDataDir() / TLS_CERT_FILE_NAME); + + CredentialsStatus credStatus = + VerifyCredentials( + boost::filesystem::path(GetArg("-tlskeypath", defaultKeyPath.string())), + boost::filesystem::path(GetArg("-tlscertpath", defaultCertPath.string())), + GetArg("-tlskeypwd", "")); + + bool bPrepared = (credStatus == credOk); + + if (!bPrepared) { + if (!mapArgs.count("-tlskeypath") && !mapArgs.count("-tlscertpath")) { + // Default paths were used + + if (credStatus == credAbsent) { + // Generate new credentials (key and self-signed certificate on it) only if credentials were absent previously + // + bPrepared = GenerateCredentials( + defaultKeyPath, + defaultCertPath, + GetArg("-tlskeypwd", "")); + } + } + } + + return bPrepared; +} +/** + * @brief accept a TLS connection + * + * @param hSocket the TLS socket. + * @param addr incoming address. + * @param tls_ctx_server TLS server context. + * @return SSL* returns pointer to the ssl object if successful, otherwise returns NULL + */ +SSL* TLSManager::accept(SOCKET hSocket, const CAddress& addr) +{ + LogPrint("net", "TLS: accepting connection from %s (tid = %X)\n", addr.ToString(), pthread_self()); + + SSL* ssl = NULL; + bool bAcceptedTLS = false; + + if ((ssl = SSL_new(tls_ctx_server))) { + if (SSL_set_fd(ssl, hSocket)) { + if (TLSManager::waitFor(SSL_ACCEPT, hSocket, ssl, (DEFAULT_CONNECT_TIMEOUT / 1000)) == 1) + bAcceptedTLS = true; + } + } + + if (bAcceptedTLS) { + LogPrintf("TLS: connection from %s has been accepted. Using cipher: %s\n", addr.ToString(), SSL_get_cipher(ssl)); + } else { + LogPrintf("TLS: ERROR: %s: %s: TLS connection from %s failed\n", __FILE__, __func__, addr.ToString()); + + if (ssl) { + SSL_free(ssl); + ssl = NULL; + } + } + + return ssl; +} +/** + * @brief Determines whether a string exists in the non-TLS address pool. + * + * @param strAddr The address. + * @param vPool Pool to search in. + * @param cs reference to the corresponding CCriticalSection. + * @return true returns true if address exists in the given pool. + * @return false returns false if address doesnt exist in the given pool. + */ +bool TLSManager::isNonTLSAddr(const string& strAddr, const vector& vPool, CCriticalSection& cs) +{ + LOCK(cs); + return (find(vPool.begin(), vPool.end(), NODE_ADDR(strAddr)) != vPool.end()); +} +/** + * @brief Removes non-TLS node addresses based on timeout. + * + * @param vPool + * @param cs + */ +void TLSManager::cleanNonTLSPool(std::vector& vPool, CCriticalSection& cs) +{ + LOCK(cs); + + vector vDeleted; + + BOOST_FOREACH (NODE_ADDR nodeAddr, vPool) { + if ((GetTimeMillis() - nodeAddr.time) >= 900000) { + vDeleted.push_back(nodeAddr); + LogPrint("net", "TLS: Node %s is deleted from the non-TLS pool\n", nodeAddr.ipAddr); + } + } + + BOOST_FOREACH (NODE_ADDR nodeAddrDeleted, vDeleted) { + vPool.erase( + remove( + vPool.begin(), + vPool.end(), + nodeAddrDeleted), + vPool.end()); + } +} + +/** + * @brief Handles send and recieve functionality in TLS Sockets. + * + * @param pnode reference to the CNode object. + * @param fdsetRecv + * @param fdsetSend + * @param fdsetError + * @return int returns -1 when socket is invalid. returns 0 otherwise. + */ +int TLSManager::threadSocketHandler(CNode* pnode, fd_set& fdsetRecv, fd_set& fdsetSend, fd_set& fdsetError) +{ + // + // Receive + // + bool recvSet = false, sendSet = false, errorSet = false; + + { + LOCK(pnode->cs_hSocket); + + if (pnode->hSocket == INVALID_SOCKET) + return -1; + + recvSet = FD_ISSET(pnode->hSocket, &fdsetRecv); + sendSet = FD_ISSET(pnode->hSocket, &fdsetSend); + errorSet = FD_ISSET(pnode->hSocket, &fdsetError); + } + + if (recvSet || errorSet) { + TRY_LOCK(pnode->cs_vRecvMsg, lockRecv); + if (lockRecv) { + { + // typical socket buffer is 8K-64K + // maximum record size is 16kB for SSLv3/TLSv1 + char pchBuf[0x10000]; + bool bIsSSL = false; + int nBytes = 0, nRet = 0; + + { + LOCK(pnode->cs_hSocket); + + if (pnode->hSocket == INVALID_SOCKET) { + LogPrint("net", "Receive: connection with %s is already closed\n", pnode->addr.ToString()); + return -1; + } + + bIsSSL = (pnode->ssl != NULL); + + if (bIsSSL) { + ERR_clear_error(); // clear the error queue, otherwise we may be reading an old error that occurred previously in the current thread + nBytes = SSL_read(pnode->ssl, pchBuf, sizeof(pchBuf)); + nRet = SSL_get_error(pnode->ssl, nBytes); + } else { + nBytes = recv(pnode->hSocket, pchBuf, sizeof(pchBuf), MSG_DONTWAIT); + nRet = WSAGetLastError(); + } + } + + if (nBytes > 0) { + if (!pnode->ReceiveMsgBytes(pchBuf, nBytes)) + pnode->CloseSocketDisconnect(); + pnode->nLastRecv = GetTime(); + pnode->nRecvBytes += nBytes; + pnode->RecordBytesRecv(nBytes); + } else if (nBytes == 0) { + // socket closed gracefully (peer disconnected) + // + if (!pnode->fDisconnect) + LogPrint("net", "socket closed (%s)\n", pnode->addr.ToString()); + pnode->CloseSocketDisconnect(); + } else if (nBytes < 0) { + // error + // + if (bIsSSL) { + if (nRet != SSL_ERROR_WANT_READ && nRet != SSL_ERROR_WANT_WRITE) // SSL_read() operation has to be repeated because of SSL_ERROR_WANT_READ or SSL_ERROR_WANT_WRITE (https://wiki.openssl.org/index.php/Manual:SSL_read(3)#NOTES) + { + if (!pnode->fDisconnect) + LogPrintf("ERROR: SSL_read %s\n", ERR_error_string(nRet, NULL)); + pnode->CloseSocketDisconnect(); + } else { + // preventive measure from exhausting CPU usage + // + MilliSleep(1); // 1 msec + } + } else { + if (nRet != WSAEWOULDBLOCK && nRet != WSAEMSGSIZE && nRet != WSAEINTR && nRet != WSAEINPROGRESS) { + if (!pnode->fDisconnect) + LogPrintf("ERROR: socket recv %s\n", NetworkErrorString(nRet)); + pnode->CloseSocketDisconnect(); + } + } + } + } + } + } + + // + // Send + // + if (sendSet) { + TRY_LOCK(pnode->cs_vSend, lockSend); + if (lockSend) + SocketSendData(pnode); + } + return 0; +} +/** + * @brief Initialization of the server and client contexts + * + * @return true returns True if successful. + * @return false returns False if an error has occured. + */ +bool TLSManager::initialize() +{ + bool bInitializationStatus = false; + + // Initialization routines for the OpenSSL library + // + SSL_load_error_strings(); + ERR_load_crypto_strings(); + OpenSSL_add_ssl_algorithms(); // OpenSSL_add_ssl_algorithms() always returns "1", so it is safe to discard the return value. + + namespace fs = boost::filesystem; + fs::path certFile = GetArg("-tlscertpath", ""); + if (!fs::exists(certFile)) + certFile = (GetDataDir() / TLS_CERT_FILE_NAME); + + fs::path privKeyFile = GetArg("-tlskeypath", ""); + if (!fs::exists(privKeyFile)) + privKeyFile = (GetDataDir() / TLS_KEY_FILE_NAME); + + std::vector trustedDirs; + fs::path trustedDir = GetArg("-tlstrustdir", ""); + if (fs::exists(trustedDir)) + // Use only the specified trusted directory + trustedDirs.push_back(trustedDir); + else + // If specified directory can't be used, then setting the default trusted directories + trustedDirs = GetDefaultTrustedDirectories(); + + for (fs::path dir : trustedDirs) + LogPrintf("TLS: trusted directory '%s' will be used\n", dir.string().c_str()); + + // Initialization of the server and client contexts + // + if ((tls_ctx_server = TLSManager::initCtx(SERVER_CONTEXT, privKeyFile, certFile, trustedDirs))) + { + if ((tls_ctx_client = TLSManager::initCtx(CLIENT_CONTEXT, privKeyFile, certFile, trustedDirs))) + { + LogPrint("net", "TLS: contexts are initialized\n"); + bInitializationStatus = true; + } + else + { + LogPrintf("TLS: ERROR: %s: %s: failed to initialize TLS client context\n", __FILE__, __func__); + SSL_CTX_free (tls_ctx_server); + } + } + else + LogPrintf("TLS: ERROR: %s: %s: failed to initialize TLS server context\n", __FILE__, __func__); + + return bInitializationStatus; +} +} diff --git a/src/hush/tlsmanager.h b/src/hush/tlsmanager.h new file mode 100644 index 000000000..da2c61b93 --- /dev/null +++ b/src/hush/tlsmanager.h @@ -0,0 +1,58 @@ +#include +#include +#include +#include "utiltls.h" +#include "tlsenums.h" +#include +#include +#include "../util.h" +#include "../protocol.h" +#include "../net.h" +#include "sync.h" +#include +#include +#include +#ifdef WIN32 +#include +#else +#include +#endif + +using namespace std; + +namespace hush +{ +typedef struct _NODE_ADDR { + std::string ipAddr; + int64_t time; // time in msec, of an attempt to connect via TLS + + _NODE_ADDR(std::string _ipAddr, int64_t _time = 0) : ipAddr(_ipAddr), time(_time) {} +bool operator==(const _NODE_ADDR b) const +{ + return (ipAddr == b.ipAddr); +} +} NODE_ADDR, *PNODE_ADDR; + +/** + * @brief A class to wrap some of hush specific TLS functionalities used in the net.cpp + * + */ +class TLSManager +{ +public: + int waitFor(SSLConnectionRoutine eRoutine, SOCKET hSocket, SSL* ssl, int timeoutSec); + SSL* connect(SOCKET hSocket, const CAddress& addrConnect); + SSL_CTX* initCtx( + TLSContextType ctxType, + const boost::filesystem::path& privateKeyFile, + const boost::filesystem::path& certificateFile, + const std::vector& trustedDirs); + + bool prepareCredentials(); + SSL* accept(SOCKET hSocket, const CAddress& addr); + bool isNonTLSAddr(const string& strAddr, const vector& vPool, CCriticalSection& cs); + void cleanNonTLSPool(std::vector& vPool, CCriticalSection& cs); + int threadSocketHandler(CNode* pnode, fd_set& fdsetRecv, fd_set& fdsetSend, fd_set& fdsetError); + bool initialize(); +}; +} diff --git a/src/hush/utiltls.cpp b/src/hush/utiltls.cpp new file mode 100644 index 000000000..b70fa9fd4 --- /dev/null +++ b/src/hush/utiltls.cpp @@ -0,0 +1,494 @@ +// Copyright (c) 2017 The Zen Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "util.h" +#include "utiltls.h" + +namespace hush { + +// Set of most common default trusted certificates directories used by OpenSSL +static const char* defaultTrustedDirs[] = +{ +#ifdef WIN32 + "" +#elif MAC_OSX + "/System/Library/OpenSSL/certs" +#else // Linux build + "/etc/ssl/certs", + "/usr/local/ssl/certs", + "/usr/lib/ssl/certs", + "/usr/share/ssl/certs", + "/etc/pki/tls/certs", + "/var/lib/ca-certificates" +#endif +}; + +// Default root certificates (PEM encoded) +static const char defaultRootCerts[] = +{ +// // Example of specifying a certificate +// // +// "-----BEGIN CERTIFICATE-----\n" +// "MIIDYDCCAkigAwIBAgIJAJMakdoBYY67MA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV\n" +// "BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX\n" +// "aWRnaXRzIFB0eSBMdGQwHhcNMTcwODE0MTc0MTMyWhcNNDQxMjMwMTc0MTMyWjBF\n" +// "MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50\n" +// "ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\n" +// "CgKCAQEAzNV+SPRCKSEGlntfpCRMVSfz99NoEo3K1SRyw6GTSb1LNSTQCn1EsCSH\n" +// "cVZTmyfjcTHpwz4aF14yw8lQC42f218AOsG1DV5suCaUXhSmZlajMkvEJVwfBOft\n" +// "xpcqE1fA9wovXlnJLXVgyJGMc896S8tcbrCU/l/BsqKh5QX8N60MQ3w376nSGvVP\n" +// "ussN8bVH3aKRwjhateqx1GRt0GPnM8/u7EkgF8Bc+m8WZYcUfkPC5Am2D0MO1HOA\n" +// "u3IKxXZMs/fYd6nF5DZBwg+D23EP/V8oqenn8ilvrSORq5PguOl1QoDyY66PhmjN\n" +// "L9c4Spxw8HXUDlrfuSQn2NJnw1XhdQIDAQABo1MwUTAdBgNVHQ4EFgQU/KD+n5Bz\n" +// "QLbp09qKzwwyNwOQU4swHwYDVR0jBBgwFoAU/KD+n5BzQLbp09qKzwwyNwOQU4sw\n" +// "DwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAVtprBxZD6O+WNYUM\n" +// "ksdKiVVoszEJXlt7wajuaPBPK/K3buxE9FLVxS+LiH1PUhPCc6V28guyKWwn109/\n" +// "4WnO51LQjygvd7SaePlbiO7iIatkOk4oETJQZ+tEJ7fv/NITY/GQUfgPNkANmPPz\n" +// "Mz9I6He8XhIpO6NGuDG+74aR1RhvR3PWJJYT0QpL0STVR4qTc/HfnymF5XnnjOYZ\n" +// "mwzT8jXX5dhLYwJmyPBS+uv+oa1quM/FitA63N9anYtRBiPaBtund9Ikjat1hM0h\n" +// "neo2tz7Mfsgjb0aiORtiyaH2OetvwR0QuCSVPnknkfGWPDINdUdkgKyA1PX58Smw\n" +// "vaXEcw==\n" +// "-----END CERTIFICATE-----" + + "" +}; + +// Generates RSA keypair (a private key of 'bits' length for a specified 'uPublicKey') +// +static EVP_PKEY* GenerateRsaKey(int bits, BN_ULONG uPublicKey) +{ + EVP_PKEY *evpPrivKey = NULL; + + BIGNUM *pubKey = BN_new(); + if (pubKey) + { + if (BN_set_word(pubKey, uPublicKey)) + { + RSA *privKey = RSA_new(); + if (privKey) + { + if (RAND_poll() && // The pseudo-random number generator must be seeded prior to calling RSA_generate_key_ex(). (https://www.openssl.org/docs/man1.1.0/crypto/RSA_generate_key.html) + RSA_generate_key_ex(privKey, bits, pubKey, NULL)) + { + if ((evpPrivKey = EVP_PKEY_new())) + { + if (!EVP_PKEY_assign_RSA(evpPrivKey, privKey)) + { + EVP_PKEY_free(evpPrivKey); + evpPrivKey = NULL; + } + } + } + + if(!evpPrivKey) // EVP_PKEY_assign_RSA uses the supplied key internally + RSA_free(privKey); + } + } + BN_free(pubKey); + } + + return evpPrivKey; +} + +// Generates certificate for a specified public key using a corresponding private key (both of them should be specified in the 'keypair'). +// +static X509* GenerateCertificate(EVP_PKEY *keypair) +{ + if (!keypair) + return NULL; + + X509 *cert = X509_new(); + if (cert) + { + bool bCertSigned = false; + long sn = 0; + + if (RAND_bytes((unsigned char*)&sn, sizeof sn) && + ASN1_INTEGER_set(X509_get_serialNumber(cert), sn)) + { + X509_gmtime_adj(X509_get_notBefore(cert), 0); + X509_gmtime_adj(X509_get_notAfter(cert), (60 * 60 * 24 * CERT_VALIDITY_DAYS)); + + // setting a public key from the keypair + if (X509_set_pubkey(cert, keypair)) + { + X509_NAME *subjectName = X509_get_subject_name(cert); + if (subjectName) + { + // an issuer name is the same as a subject name, due to certificate is self-signed + if (X509_set_issuer_name(cert, subjectName)) + { + // private key from keypair is used; signature will be set inside of the cert + bCertSigned = X509_sign(cert, keypair, EVP_sha512()); + } + } + } + } + + if (!bCertSigned) + { + X509_free(cert); + cert = NULL; + } + } + + return cert; +} + +// Stores key to file, specified by the 'filePath' +// +static bool StoreKey(EVP_PKEY *key, const boost::filesystem::path &filePath, const std::string &passphrase) +{ + if (!key) + return false; + + bool bStored = false; + + FILE *keyfd = fopen(filePath.string().c_str(), "wb"); + if (keyfd) + { + const EVP_CIPHER* pCipher = NULL; + + if (passphrase.length() && (pCipher = EVP_aes_256_cbc())) + bStored = PEM_write_PrivateKey(keyfd, key, pCipher, NULL, 0, NULL, (void*)passphrase.c_str()); + else + bStored = PEM_write_PrivateKey(keyfd, key, NULL, NULL, 0, NULL, NULL); + + fclose(keyfd); + } + + return bStored; +} + +// Stores certificate to file, specified by the 'filePath' +// +static bool StoreCertificate(X509 *cert, const boost::filesystem::path &filePath) +{ + if (!cert) + return false; + + bool bStored = false; + + FILE *certfd = fopen(filePath.string().c_str(), "wb"); + if (certfd) + { + bStored = PEM_write_X509(certfd, cert); + fclose(certfd); + } + + return bStored; +} + +// Loads key from file, specified by the 'filePath' +// +static EVP_PKEY* LoadKey(const boost::filesystem::path &filePath, const std::string &passphrase) +{ + if (!boost::filesystem::exists(filePath)) + return NULL; + + EVP_PKEY *key = NULL; + FILE *keyfd = fopen(filePath.string().c_str(), "rb"); + if (keyfd) + { + key = PEM_read_PrivateKey(keyfd, NULL, NULL, passphrase.length() ? (void*)passphrase.c_str() : NULL); + fclose(keyfd); + } + + return key; +} + +// Loads certificate from file, specified by the 'filePath' +// +static X509* LoadCertificate(const boost::filesystem::path &filePath) +{ + if (!boost::filesystem::exists(filePath)) + return NULL; + + X509 *cert = NULL; + FILE *certfd = fopen(filePath.string().c_str(), "rb"); + if (certfd) + { + cert = PEM_read_X509(certfd, NULL, NULL, NULL); + fclose(certfd); + } + + return cert; +} + +// Verifies if the private key in 'key' matches the public key in 'cert' +// (Signs random bytes on 'key' and verifies signature correctness on public key from 'cert') +// +static bool IsMatching(EVP_PKEY *key, X509 *cert) +{ + if (!key || !cert) + return false; + + bool bIsMatching = false; + + EVP_PKEY_CTX *ctxSign = EVP_PKEY_CTX_new(key, NULL); + if (ctxSign) + { + if (EVP_PKEY_sign_init(ctxSign) == 1 && + EVP_PKEY_CTX_set_signature_md(ctxSign, EVP_sha512()) > 0) + { + unsigned char digest[SHA512_DIGEST_LENGTH] = { 0 }; + size_t digestSize = sizeof digest, signatureSize = 0; + + if (RAND_bytes((unsigned char*)&digest, digestSize) && // set random bytes as a digest + EVP_PKEY_sign(ctxSign, NULL, &signatureSize, digest, digestSize) == 1) // determine buffer length + { + unsigned char *signature = (unsigned char*)OPENSSL_malloc(signatureSize); + if (signature) + { + if (EVP_PKEY_sign(ctxSign, signature, &signatureSize, digest, digestSize) == 1) + { + EVP_PKEY *pubkey = X509_get_pubkey(cert); + if (pubkey) + { + EVP_PKEY_CTX *ctxVerif = EVP_PKEY_CTX_new(pubkey, NULL); + if (ctxVerif) + { + if (EVP_PKEY_verify_init(ctxVerif) == 1 && + EVP_PKEY_CTX_set_signature_md(ctxVerif, EVP_sha512()) > 0) + { + bIsMatching = (EVP_PKEY_verify(ctxVerif, signature, signatureSize, digest, digestSize) == 1); + } + EVP_PKEY_CTX_free(ctxVerif); + } + EVP_PKEY_free(pubkey); + } + } + OPENSSL_free(signature); + } + } + } + EVP_PKEY_CTX_free(ctxSign); + } + + return bIsMatching; +} + +// Checks the correctness of a private-public key pair and the validity of a certificate using public key from key pair +// +static bool CheckCredentials(EVP_PKEY *key, X509 *cert) +{ + if (!key || !cert) + return false; + + bool bIsOk = false; + + // Validating the correctness of a private-public key pair, depending on a key type + // + switch (EVP_PKEY_base_id(key)) + { + case EVP_PKEY_RSA: + case EVP_PKEY_RSA2: + { + RSA *rsaKey = EVP_PKEY_get1_RSA(key); + if (rsaKey) + { + bIsOk = (RSA_check_key(rsaKey) == 1); + RSA_free(rsaKey); + } + break; + } + + // Currently only RSA keys are supported. + // Other key types can be added here in further. + + default: + bIsOk = false; + } + + // Verifying if the private key matches the public key in certificate + if (bIsOk) + bIsOk = IsMatching(key, cert); + + return bIsOk; +} + +// Verifies credentials (a private key, a certificate for public key and a correspondence between the private and the public key) +// +CredentialsStatus VerifyCredentials( + const boost::filesystem::path &keyPath, + const boost::filesystem::path &certPath, + const std::string &passphrase) +{ + CredentialsStatus status = credAbsent; + + EVP_PKEY *key = NULL; + X509 *cert = NULL; + + key = LoadKey(keyPath, passphrase); + cert = LoadCertificate(certPath); + + if (key && cert) + status = CheckCredentials(key, cert) ? credOk : credNonConsistent; + else if (!key && !cert) + status = credAbsent; + else + status = credPartiallyAbsent; + + if (key) + EVP_PKEY_free(key); + if (cert) + X509_free(cert); + + return status; +} + +// Generates public key pair and the self-signed certificate for it, and then stores them by the specified paths 'keyPath' and 'certPath' respectively. +// +bool GenerateCredentials( + const boost::filesystem::path &keyPath, + const boost::filesystem::path &certPath, + const std::string &passphrase) +{ + bool bGenerated = false; + + EVP_PKEY *key = NULL; + X509 *cert = NULL; + + // Generating RSA key and the self-signed certificate for it + // + key = GenerateRsaKey(TLS_RSA_KEY_SIZE, RSA_F4); + if (key) + { + cert = GenerateCertificate(key); + if (cert) + { + if (StoreKey(key, keyPath, passphrase) && + StoreCertificate(cert, certPath)) + { + bGenerated = true; + LogPrintStr("TLS: New private key and self-signed certificate were generated successfully\n"); + } + + X509_free(cert); + } + EVP_PKEY_free(key); + } + + return bGenerated; +} + +// Checks if certificate of a peer is valid (by internal means of the TLS protocol) +// +// Validates peer certificate using a chain of CA certificates. +// If some of intermediate CA certificates are absent in the trusted certificates store, then validation status will be 'false') +// +bool ValidatePeerCertificate(SSL *ssl) +{ + if (!ssl) + return false; + + bool bIsOk = false; + + X509 *cert = SSL_get_peer_certificate (ssl); + if (cert) + { + // NOTE: SSL_get_verify_result() is only useful in connection with SSL_get_peer_certificate (https://www.openssl.org/docs/man1.0.2/ssl/SSL_get_verify_result.html) + // + bIsOk = (SSL_get_verify_result(ssl) == X509_V_OK); + X509_free(cert); + } + else + { + LogPrint("net", "TLS: Peer does not have certificate\n"); + bIsOk = false; + } + return bIsOk; +} + +// Check if a given context is set up with a cert that can be validated by this context +// +bool ValidateCertificate(SSL_CTX *ssl_ctx) +{ + if (!ssl_ctx) + return false; + + bool bIsOk = false; + + X509_STORE *store = SSL_CTX_get_cert_store(ssl_ctx); + + if (store) + { + X509_STORE_CTX *ctx = X509_STORE_CTX_new(); + if (ctx) + { + if (X509_STORE_CTX_init(ctx, store, SSL_CTX_get0_certificate(ssl_ctx), NULL) == 1) + bIsOk = X509_verify_cert(ctx) == 1; + + X509_STORE_CTX_free(ctx); + } + } + + return bIsOk; +} + +// Creates the list of available OpenSSL default directories for trusted certificates storage +// +std::vector GetDefaultTrustedDirectories() +{ + namespace fs = boost::filesystem; + std::vector defaultDirectoriesList; + + // Default certificates directory specified in OpenSSL build + fs::path libDefaultDir = X509_get_default_cert_dir(); + + if (fs::exists(libDefaultDir)) + defaultDirectoriesList.push_back(libDefaultDir); + + // Check and set all possible standard default directories + for (const char *dir : defaultTrustedDirs) + { + fs::path defaultDir(dir); + + if (defaultDir != libDefaultDir && + fs::exists(defaultDir)) + defaultDirectoriesList.push_back(defaultDir); + } + + return defaultDirectoriesList; +} + +// Loads default root certificates (placed in the 'defaultRootCerts') into the specified context. +// Returns the number of loaded certificates. +// +int LoadDefaultRootCertificates(SSL_CTX *ctx) +{ + if (!ctx) + return 0; + + int certsLoaded = 0; + + // Certificate text buffer 'defaultRootCerts' is a C string with certificates in PEM format + BIO *memBuf = BIO_new_mem_buf(defaultRootCerts, -1); + if (memBuf) + { + X509 *cert = NULL; + while ((cert = PEM_read_bio_X509(memBuf, NULL, 0, NULL))) + { + if (X509_STORE_add_cert(SSL_CTX_get_cert_store(ctx), cert) > 0) + certsLoaded++; + + X509_free(cert); + } + BIO_free(memBuf); + } + + return certsLoaded; +} +} diff --git a/src/hush/utiltls.h b/src/hush/utiltls.h new file mode 100644 index 000000000..2dee400bd --- /dev/null +++ b/src/hush/utiltls.h @@ -0,0 +1,56 @@ +// Copyright (c) 2017 The Zen Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef UTILTLS_H +#define UTILTLS_H + +#include +namespace hush { + +#define TLS_KEY_FILE_NAME "key.pem" // default name of a private key +#define TLS_CERT_FILE_NAME "cert.pem" // default name of a certificate + +#define CERT_VALIDITY_DAYS (365 * 10) // period of validity, in days, for a self-signed certificate + +#define TLS_RSA_KEY_SIZE 2048 // size of a private RSA key, in bits, that will be generated, if no other key is specified + +typedef enum {credOk, credNonConsistent, credAbsent, credPartiallyAbsent} CredentialsStatus; + +// Verifies credentials (a private key, a certificate for public key and a correspondence between the private and the public key) +// +CredentialsStatus VerifyCredentials( + const boost::filesystem::path &keyPath, + const boost::filesystem::path &certPath, + const std::string &passphrase); + +// Generates public key pair and the self-signed certificate for it, and then stores them by the specified paths 'keyPath' and 'certPath' respectively. +// +bool GenerateCredentials( + const boost::filesystem::path &keyPath, + const boost::filesystem::path &certPath, + const std::string &passphrase); + +// Checks if certificate of a peer is valid (by internal means of the TLS protocol) +// +// Validates peer certificate using a chain of CA certificates. +// If some of intermediate CA certificates are absent in the trusted certificates store, then validation status will be 'false') +// +bool ValidatePeerCertificate(SSL *ssl); + +// Check if a given context is set up with a cert that can be validated by this context +// +bool ValidateCertificate(SSL_CTX *ssl_ctx); + +// Creates the list of available OpenSSL default directories for trusted certificates storage +// +std::vector GetDefaultTrustedDirectories(); + +// Loads default root certificates (placed in the 'defaultRootCerts') into the specified context. +// Returns the number of loaded certificates. +// +int LoadDefaultRootCertificates(SSL_CTX *ctx); + +} + +#endif // UTILTLS_H diff --git a/src/init.cpp b/src/init.cpp index b401079d6..6510424af 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -426,6 +426,11 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-timeout=", strprintf(_("Specify connection timeout in milliseconds (minimum: 1, default: %d)"), DEFAULT_CONNECT_TIMEOUT)); strUsage += HelpMessageOpt("-torcontrol=:", strprintf(_("Tor control port to use if onion listening enabled (default: %s)"), DEFAULT_TOR_CONTROL)); strUsage += HelpMessageOpt("-torpassword=", _("Tor control port password (default: empty)")); + strUsage += HelpMessageOpt("-tls=