123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2020 Nomadic Labs, <contact@nomadic-labs.com> *)(* *)(* 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. *)(* *)(*****************************************************************************)openTezos_client_basetypebootstrap_secret={name:string;sk_uri:Client_keys.sk_uri}letdefault_bootstrap_accounts=letopenLwt_result_syntaxinletunencrypted_keys=["edsk3gUfUPyBSfrS9CCgmCiQsTCHGkviBDusMxDJstFtojtc1zcpsh";"edsk39qAm1fiMjgmPkw1EgQYkMzkJezLNewd7PLNHTkr6w9XA2zdfo";"edsk4ArLQgBTLWG5FJmnGnT689VKoqhXwmDPBuGx3z4cvwU9MmrPZZ";"edsk2uqQB9AY4FvioK2YMdfmyMrer5R8mGFyuaLLFfSRo8EoyNdht3";"edsk4QLrcijEffxV31gGdN2HU7UpyJjA8drFoNcmnB28n89YjPNRFm";]inletbasename="bootstrap"inList.mapi_es(funiukey->let*?sk_uri=Client_keys.make_sk_uri@@Uri.of_string("unencrypted:"^ukey)inletname=basename^string_of_int(i+1)inreturn{name;sk_uri})unencrypted_keysletadd_bootstrap_secretcctxt{name;sk_uri}=letopenLwt_result_syntaxinletforce=falseinlet*pk_uri=Client_keys.neuterizesk_uriinlet*()=let*o=Client_keys.Public_key.find_optcctxtnameinmatchowith|None->return_unit|Some(pk_uri_found,_)->fail_unless(pk_uri=pk_uri_found||force)(error_of_fmt"public and secret keys '%s' don't correspond, please don't use \
--force"name)inlet*pkh,public_key=Client_keys.import_secret_key~io:(cctxt:>Client_context.io_wallet)pk_uriinlet*!()=cctxt#message"Tezos address added: %a"Tezos_crypto.Signature.Public_key_hash.pppkhinClient_keys.register_keycctxt~force(pkh,pk_uri,sk_uri)?public_keynameletbootstrap_secret_encoding=letopenData_encodinginconv(funp->(p.name,p.sk_uri,""))(fun(name,sk_uri,_)->{name;sk_uri})(obj3(req"name"string)(req"sk_uri"Client_keys.Secret_key.encoding)(req"amount"string))letbootstrap_secrets_encoding=Data_encoding.listbootstrap_secret_encodingletpopulate(cctxt:#Tezos_client_base.Client_context.io_wallet)bootstrap_accounts_file=letopenLwt_result_syntaxinlet*accounts=matchbootstrap_accounts_filewith|None->default_bootstrap_accounts|Someaccounts_file->(let*json=Tezos_stdlib_unix.Lwt_utils_unix.Json.read_fileaccounts_fileinmatchData_encoding.Json.destructbootstrap_secrets_encodingjsonwith|accounts->returnaccounts|exceptione->failwith"cannot read definitions of bootstrap accounts in %s because: %s"accounts_file(Printexc.to_stringe))inList.iter_es(add_bootstrap_secretcctxt)accounts