package tezos-client-012-Psithaca
Tezos/Protocol: protocol specific library for `tezos-client`
Install
Dune Dependency
Authors
Maintainers
Sources
tezos-16.1.tar.gz
sha256=43723d096307603703a1a89ed1b2eb202b365f5e7824b96b0cbf813b343a6cf7
sha512=b2a637f2e965000d3d49ad85277ca24d6cb07a1a7cf2bc69d296d8b03ad78c3eaa8e21e94b9162e62c2e11649cd03bc845b2a3dafe623b91065df69d47dc8e4f
doc/src/tezos-client-012-Psithaca.sapling/client_sapling_commands.ml.html
Source file client_sapling_commands.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2019-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. *) (* *) (*****************************************************************************) open Client_keys_v0 open Tezos_sapling.Core.Client let json_switch = Tezos_clic.switch ~long:"json" ~doc:"Use JSON format" () let save_json_to_file json file = let output_channel = open_out_bin file in let ppf = Format.formatter_of_out_channel output_channel in Data_encoding.Json.pp ppf json ; Format.pp_print_flush ppf () ; close_out output_channel let group = { Tezos_clic.name = "sapling"; title = "Commands for working with Sapling transactions"; } let keys_of_implicit_account cctxt source = match Protocol.Alpha_context.Contract.is_implicit source with | None -> assert false | Some src -> Client_keys_v0.get_key cctxt src >>=? fun (_, pk, sk) -> return (src, pk, sk) let viewing_key_of_string s = let exception Unknown_sapling_address in let encoding = Viewing_key.address_b58check_encoding in WithExceptions.Option.to_exn ~none:Unknown_sapling_address (Tezos_crypto.Base58.simple_decode encoding s) (** All signatures are done with an anti-replay string. In Tezos' protocol this string is set to be chain_id + KT1. **) let anti_replay cctxt contract = Tezos_shell_services.Chain_services.chain_id cctxt ~chain:cctxt#chain () >>=? fun chain_id -> let address = Protocol.Alpha_context.Contract.to_b58check contract in let chain_id = Chain_id.to_b58check chain_id in return (address ^ chain_id) let do_unshield cctxt contract src_name stez dst = anti_replay cctxt contract >>=? fun anti_replay -> Wallet.new_address cctxt src_name None >>=? fun (src, _, backdst) -> Context.Client_state.sync_and_scan cctxt contract >>=? fun contract_state -> Lwt.return @@ Context.unshield ~src ~dst ~backdst stez contract_state anti_replay let do_shield cctxt ?message contract utez dst = anti_replay cctxt contract >>=? fun anti_replay -> Context.Client_state.sync_and_scan cctxt contract >>=? fun contract_state -> let dst = viewing_key_of_string dst in Context.shield cctxt ~dst ?message utez contract_state anti_replay let do_sapling_transfer cctxt ?message contract src_name amount dst = anti_replay cctxt contract >>=? fun anti_replay -> Wallet.new_address cctxt src_name None >>=? fun (src, _, backdst) -> Context.Client_state.sync_and_scan cctxt contract >>=? fun contract_state -> let dst = viewing_key_of_string dst in Context.transfer cctxt ~src ~dst ~backdst ?message amount contract_state anti_replay let message_arg = let open Tezos_clic in arg ~long:"message" ~placeholder:"" ~doc:"Message for Sapling transaction" (parameter (fun _ x -> return @@ Bytes.of_string x)) let memo_size_arg = let open Tezos_clic in arg ~long:"memo-size" ~placeholder:"memo-size" ~doc:"Expected length for message of Sapling transaction" (parameter (fun _ s -> match let i = int_of_string s in assert (i >= 0 && i <= 65535) ; i with | i -> return i | exception _ -> failwith "invalid memo-size (must be between 0 and 65535)")) let shield_cmd = let open Client_proto_args in let open Client_proto_context_commands in let open Protocol.Alpha_context in let open Client_proto_contracts in Tezos_clic.command ~group ~desc:"Shield tokens from an implicit account to a Sapling address." (Tezos_clic.args14 fee_arg dry_run_switch verbose_signing_switch gas_limit_arg storage_limit_arg counter_arg no_print_source_flag minimal_fees_arg minimal_nanotez_per_byte_arg minimal_nanotez_per_gas_unit_arg force_low_fee_arg fee_cap_arg burn_cap_arg message_arg) (Tezos_clic.prefixes ["sapling"; "shield"] @@ tez_param ~name:"qty" ~desc:"Amount taken from transparent wallet of source." @@ Tezos_clic.prefix "from" @@ ContractAlias.destination_param ~name:"src-tz" ~desc:"Transparent source account." @@ Tezos_clic.prefix "to" @@ Tezos_clic.string ~name:"dst-sap" ~desc:"Sapling address of destination." @@ Tezos_clic.prefix "using" @@ ContractAlias.destination_param ~name:"sapling contract" ~desc:"Smart contract to submit this transaction to." @@ Tezos_clic.stop) (fun ( fee, dry_run, verbose_signing, gas_limit, storage_limit, counter, no_print_source, minimal_fees, minimal_nanotez_per_byte, minimal_nanotez_per_gas_unit, force_low_fee, fee_cap, burn_cap, message ) amount (_, source) sapling_dst (_contract_name, contract_dst) cctxt -> keys_of_implicit_account cctxt source >>=? fun (pkh, src_pk, src_sk) -> let open Context in cctxt#warning "Shielding %a from %a to %s@ entails a loss of privacy@." Tez.pp amount Contract.pp source sapling_dst >>= fun () -> do_shield cctxt ?message contract_dst amount sapling_dst >>=? fun sapling_input -> let arg = Shielded_tez_contract_input.as_arg sapling_input in let fee_parameter = { Injection.minimal_fees; minimal_nanotez_per_byte; minimal_nanotez_per_gas_unit; force_low_fee; fee_cap; burn_cap; } in Client_proto_context.transfer cctxt ~chain:cctxt#chain ~block:cctxt#block ~fee_parameter ~amount ~src_pk ~src_sk ~destination:contract_dst ~source:pkh ~arg ?confirmations:cctxt#confirmations ?fee ~dry_run ~verbose_signing ?gas_limit ?storage_limit ?counter () >>= fun errors -> report_michelson_errors ~no_print_source ~msg:"transfer simulation failed" cctxt errors >>= function | None -> return_unit | Some (_res, _contracts) -> return_unit) let unshield_cmd = let open Client_proto_args in let open Client_proto_context_commands in let open Protocol.Alpha_context in let open Client_proto_contracts in Tezos_clic.command ~group ~desc:"Unshield tokens from a Sapling address to an implicit account." (Tezos_clic.args13 fee_arg dry_run_switch verbose_signing_switch gas_limit_arg storage_limit_arg counter_arg no_print_source_flag minimal_fees_arg minimal_nanotez_per_byte_arg minimal_nanotez_per_gas_unit_arg force_low_fee_arg fee_cap_arg burn_cap_arg) (Tezos_clic.prefixes ["sapling"; "unshield"] @@ tez_param ~name:"qty" ~desc:"Amount taken from shielded wallet of source." @@ Tezos_clic.prefix "from" @@ Sapling_key.alias_param ~name:"src-sap" ~desc:"Sapling account of source." @@ Tezos_clic.prefix "to" @@ ContractAlias.destination_param ~name:"dst-tz" ~desc:"Transparent destination account." @@ Tezos_clic.prefix "using" @@ ContractAlias.destination_param ~name:"sapling contract" ~desc:"Smart contract to submit this transaction to." @@ Tezos_clic.stop) (fun ( fee, dry_run, verbose_signing, gas_limit, storage_limit, counter, no_print_source, minimal_fees, minimal_nanotez_per_byte, minimal_nanotez_per_gas_unit, force_low_fee, fee_cap, burn_cap ) amount (name, _sapling_uri) (_, tz_dst) (_contract_name, contract_dst) cctxt -> let open Context in let stez = Shielded_tez.of_tez amount in cctxt#warning "Unshielding %a from %s to %a@ entails a loss of privacy@." Shielded_tez.pp stez name Contract.pp tz_dst >>= fun () -> keys_of_implicit_account cctxt tz_dst >>=? fun (source, src_pk, src_sk) -> do_unshield cctxt contract_dst name stez source >>=? fun sapling_input -> let arg = Shielded_tez_contract_input.as_arg sapling_input in let fee_parameter = { Injection.minimal_fees; minimal_nanotez_per_byte; minimal_nanotez_per_gas_unit; force_low_fee; fee_cap; burn_cap; } in Client_proto_context.transfer cctxt ~chain:cctxt#chain ~block:cctxt#block ~fee_parameter ~amount:Tez.zero ~src_pk ~src_sk ~destination:contract_dst ~source ~arg ?confirmations:cctxt#confirmations ?fee ~dry_run ~verbose_signing ?gas_limit ?storage_limit ?counter () >>= fun errors -> report_michelson_errors ~no_print_source ~msg:"transfer simulation failed" cctxt errors >>= function | None -> return_unit | Some (_res, _contracts) -> return_unit) (* Default name for Sapling transaction file *) let sapling_transaction_file = "sapling_transaction" let file_arg default_filename = let open Tezos_clic in arg ~long:"file" ~placeholder:default_filename ~doc:"file name" (parameter (fun _ x -> return x)) (** Shielded transaction are first forged and printed in a file. Then they are submitted with the next command. **) let forge_shielded_cmd = let open Client_proto_args in let open Client_proto_context_commands in let open Client_proto_contracts in Tezos_clic.command ~group ~desc:"Forge a sapling transaction and save it to a file." (Tezos_clic.args16 fee_arg dry_run_switch verbose_signing_switch gas_limit_arg storage_limit_arg counter_arg no_print_source_flag minimal_fees_arg minimal_nanotez_per_byte_arg minimal_nanotez_per_gas_unit_arg force_low_fee_arg fee_cap_arg burn_cap_arg message_arg (file_arg sapling_transaction_file) json_switch) (Tezos_clic.prefixes ["sapling"; "forge"; "transaction"] @@ tez_param ~name:"qty" ~desc:"Amount taken from shielded wallet of source." @@ Tezos_clic.prefix "from" @@ Sapling_key.alias_param ~name:"src-sap" ~desc:"Sapling account of source." @@ Tezos_clic.prefix "to" @@ Tezos_clic.string ~name:"dst-sap" ~desc:"Sapling address of destination." @@ Tezos_clic.prefix "using" @@ ContractAlias.destination_param ~name:"sapling contract" ~desc:"Smart contract to submit this transaction to." @@ Tezos_clic.stop) (fun ( _fee, _dry_run, _verbose_signing, _gas_limit, _storage_limit, _counter, _no_print_source, _minimal_fees, _minimal_nanotez_per_byte, _minimal_nanotez_per_gas_unit, _force_low_fee, _fee_cap, _burn_cap, message, file, use_json_format ) amount (name, _sapling_uri) destination (_contract_name, contract_dst) cctxt -> let open Context in let stez = Shielded_tez.of_tez amount in do_sapling_transfer cctxt ?message contract_dst name stez destination >>=? fun transaction -> let file = Option.value ~default:sapling_transaction_file file in cctxt#message "Writing transaction to %s@." file >>= fun () -> (if use_json_format then save_json_to_file (Data_encoding.Json.construct UTXO.transaction_encoding transaction) file else let bytes = Hex.of_bytes (Data_encoding.Binary.to_bytes_exn UTXO.transaction_encoding transaction) in let file = open_out_bin file in Printf.fprintf file "0x%s" (Hex.show bytes) ; close_out file) ; return_unit) let submit_shielded_cmd = let open Client_proto_context_commands in let open Client_proto_args in let open Client_proto_contracts in Tezos_clic.command ~group ~desc:"Submit a forged sapling transaction." (Tezos_clic.args14 fee_arg dry_run_switch verbose_signing_switch gas_limit_arg storage_limit_arg counter_arg no_print_source_flag minimal_fees_arg minimal_nanotez_per_byte_arg minimal_nanotez_per_gas_unit_arg force_low_fee_arg fee_cap_arg burn_cap_arg json_switch) (Tezos_clic.prefixes ["sapling"; "submit"] (* TODO: Add a dedicated abstracted Tezos_clic element to parse filenames, potentially using Sys.file_exists *) @@ Tezos_clic.string ~name:"file" ~desc:"Filename of the forged transaction." @@ Tezos_clic.prefix "from" @@ ContractAlias.destination_param ~name:"alias-tz" ~desc:"Transparent account paying the fees." @@ Tezos_clic.prefix "using" @@ ContractAlias.destination_param ~name:"sapling contract" ~desc:"Smart contract to submit this transaction to." @@ Tezos_clic.stop) (fun ( fee, dry_run, verbose_signing, gas_limit, storage_limit, counter, no_print_source, minimal_fees, minimal_nanotez_per_byte, minimal_nanotez_per_gas_unit, force_low_fee, fee_cap, burn_cap, use_json_format ) filename (_, source) (contract_name, destination) (cctxt : Protocol_client_context.full) -> cctxt#message "Reading forge transaction from file %s -- sending it to %s@." filename contract_name >>= fun () -> let open Context in (if use_json_format then Lwt_utils_unix.Json.read_file filename >>=? fun json -> return @@ Data_encoding.Json.destruct UTXO.transaction_encoding json else Lwt_utils_unix.read_file filename >>= fun hex -> let hex = (* remove 0x *) String.sub hex 2 (String.length hex - 2) in return @@ Data_encoding.Binary.of_bytes_exn UTXO.transaction_encoding Hex.(to_bytes_exn (`Hex hex))) >>=? fun transaction -> return Shielded_tez_contract_input.(as_arg (create transaction)) >>=? fun contract_input -> let chain = cctxt#chain and block = cctxt#block in keys_of_implicit_account cctxt source >>=? fun (source, src_pk, src_sk) -> let open Protocol.Alpha_context in let fee_parameter = { Injection.minimal_fees; minimal_nanotez_per_byte; minimal_nanotez_per_gas_unit; force_low_fee; fee_cap; burn_cap; } in Client_proto_context.transfer cctxt ~chain ~block ~fee_parameter ~amount:Tez.zero ~src_pk ~src_sk ~destination ~source ~arg:contract_input ?confirmations:cctxt#confirmations ?fee ~dry_run ~verbose_signing ?gas_limit ?storage_limit ?counter () >>= fun errors -> report_michelson_errors ~no_print_source ~msg:"transfer simulation failed" cctxt errors >>= function | None -> return_unit | Some (_res, _contracts) -> return_unit) let for_contract_arg = Client_proto_contracts.ContractAlias.destination_arg ~name:"for-contract" ~doc:"name of the contract to associate new key with" () let unencrypted_switch () = Tezos_clic.switch ~long:"unencrypted" ~doc:"Do not encrypt the key on-disk (for testing and debugging)." () let generate_key_cmd = Tezos_clic.command ~group ~desc:"Generate a new sapling key." (Tezos_clic.args2 (Sapling_key.force_switch ()) (unencrypted_switch ())) (Tezos_clic.prefixes ["sapling"; "gen"; "key"] @@ Sapling_key.fresh_alias_param @@ Tezos_clic.stop) (fun (force, unencrypted) name (cctxt : Protocol_client_context.full) -> Sapling_key.of_fresh cctxt force name >>=? fun name -> let mnemonic = Wallet.Mnemonic.new_random in cctxt#message "It is important to save this mnemonic in a secure place:@\n\ @\n\ %a@\n\ @\n\ The mnemonic can be used to recover your spending key.@." Wallet.Mnemonic.words_pp (Bip39.to_words mnemonic) >>= fun () -> Wallet.register cctxt ~force ~unencrypted mnemonic name >>=? fun _vk -> return_unit) let use_key_for_contract_cmd = Tezos_clic.command ~group ~desc:"Use a sapling key for a contract." (Tezos_clic.args1 memo_size_arg) (Tezos_clic.prefixes ["sapling"; "use"; "key"] @@ Sapling_key.alias_param ~name:"sapling-key" ~desc:"Sapling key to use for the contract." @@ Tezos_clic.prefixes ["for"; "contract"] @@ Client_proto_contracts.ContractAlias.destination_param ~name:"contract" ~desc:"Contract the key will be used on." @@ Tezos_clic.stop) (fun default_memo_size (name, _sapling_uri) (_contract_name, contract) (cctxt : Protocol_client_context.full) -> Wallet.find_vk cctxt name >>=? fun vk -> Context.Client_state.register cctxt ~default_memo_size ~force:false contract vk) let import_key_cmd = Tezos_clic.command ~group ~desc:"Restore a sapling key from mnemonic." (Tezos_clic.args3 (Sapling_key.force_switch ()) (unencrypted_switch ()) (Tezos_clic.arg ~long:"mnemonic" ~placeholder:"mnemonic" ~doc:"Mnemonic as an option, only used for testing and debugging." Client_proto_args.string_parameter)) (Tezos_clic.prefixes ["sapling"; "import"; "key"] @@ Sapling_key.fresh_alias_param @@ Tezos_clic.stop) (fun (force, unencrypted, mnemonic_opt) fresh_name (cctxt : Protocol_client_context.full) -> (match mnemonic_opt with | None -> let rec loop_words (acc : string list) i = if i > 23 then return (List.rev acc) else cctxt#prompt_password "Enter word %d: " i >>=? fun word_raw -> let word = Bytes.to_string word_raw in match Bip39.index_of_word word with | None -> loop_words acc i | Some _ -> loop_words (word :: acc) (succ i) in loop_words [] 0 | Some mnemonic -> return (String.split_on_char ' ' mnemonic)) >>=? fun words -> match Bip39.of_words words with | None -> failwith "Not a valid mnemonic" | Some mnemonic -> Sapling_key.of_fresh cctxt force fresh_name >>=? fun name -> Wallet.register cctxt ~force ~unencrypted mnemonic name >>=? fun _ -> return_unit) let commands () = let child_index_param = Tezos_clic.param ~name:"child-index" ~desc:"Index of the child to derive." Client_proto_args.int_parameter in let index_arg = Tezos_clic.arg ~doc:"index of the address to generate" ~long:"address-index" ~placeholder:"idx" Client_proto_args.int_parameter in [ generate_key_cmd; use_key_for_contract_cmd; import_key_cmd; Tezos_clic.command ~group ~desc:"Derive a key from an existing one using zip32." (Tezos_clic.args4 (Sapling_key.force_switch ()) for_contract_arg (unencrypted_switch ()) memo_size_arg) (Tezos_clic.prefixes ["sapling"; "derive"; "key"] @@ Sapling_key.fresh_alias_param @@ Tezos_clic.prefix "from" @@ Sapling_key.alias_param @@ Tezos_clic.prefixes ["at"; "index"] @@ child_index_param @@ Tezos_clic.stop) (fun (force, contract_opt, unencrypted, default_memo_size) fresh_name (existing_name, _existing_uri) child_index (cctxt : Protocol_client_context.full) -> Sapling_key.of_fresh cctxt force fresh_name >>=? fun new_name -> Wallet.derive cctxt ~force ~unencrypted existing_name new_name child_index >>=? fun (path, vk) -> cctxt#message "Derived new key %s from %s with path %s@." new_name existing_name path >>= fun () -> (* TODO must pass contract address for now *) let _, contract = WithExceptions.Option.get ~loc:__LOC__ contract_opt in Context.Client_state.register cctxt ~default_memo_size ~force contract vk); Tezos_clic.command ~group ~desc:"Generate an address for a key referenced by alias." (Tezos_clic.args1 index_arg) (Tezos_clic.prefixes ["sapling"; "gen"; "address"] @@ Sapling_key.alias_param @@ Tezos_clic.stop) (fun index_opt (name, _sapling_uri) (cctxt : Protocol_client_context.full) -> Wallet.new_address cctxt name index_opt >>=? fun (_, corrected_index, address) -> let address_b58 = Tezos_crypto.Base58.simple_encode Viewing_key.address_b58check_encoding address in cctxt#message "Generated address:@.%s@.at index %Ld" address_b58 (Viewing_key.index_to_int64 corrected_index) >>= fun () -> return_unit); Tezos_clic.command ~group ~desc:"Save a sapling viewing key in a JSON file." Tezos_clic.no_options (Tezos_clic.prefixes ["sapling"; "export"; "key"] @@ Sapling_key.alias_param @@ Tezos_clic.prefix "in" @@ Tezos_clic.param ~name:"file" ~desc:"Filename." Client_proto_args.string_parameter @@ Tezos_clic.stop) (fun () (name, _sapling_uri) file (cctxt : Protocol_client_context.full) -> Wallet.export_vk cctxt name >>=? fun vk_json -> return (save_json_to_file vk_json file)); Tezos_clic.command ~group ~desc:"Get balance associated with given sapling key and contract" (Tezos_clic.args1 (Tezos_clic.switch ~doc:"Print the collection of non-spent inputs." ~short:'v' ~long:"verbose" ())) (Tezos_clic.prefixes ["sapling"; "get"; "balance"; "for"] @@ Sapling_key.alias_param ~name:"sapling-key" ~desc:"Sapling key we get balance for." @@ Tezos_clic.prefixes ["in"; "contract"] @@ Client_proto_contracts.ContractAlias.destination_param ~name:"contract" ~desc:"Contract we get balance from." @@ Tezos_clic.stop) (fun verbose (name, _sapling_uri) (_contract_name, contract) (cctxt : Protocol_client_context.full) -> Wallet.find_vk cctxt name >>= function | Error _ -> cctxt#error "Account %s not found" name | Ok vk -> ( Context.Client_state.sync_and_scan cctxt contract >>=? fun contract_state -> Context.Contract_state.find_account vk contract_state |> function | None -> cctxt#error "Account %s not found" name | Some account -> (if verbose then cctxt#answer "@[<v 2>Received Sapling transactions for %s@,@[<v>%a@]@]" name Context.Account.pp_unspent account else Lwt.return_unit) >>= fun () -> cctxt#answer "Total Sapling funds %a%s" Context.Shielded_tez.pp (Context.Account.balance account) Client_proto_args.tez_sym >>= fun () -> return_unit)); Tezos_clic.command ~group ~desc:"List sapling keys." Tezos_clic.no_options (Tezos_clic.fixed ["sapling"; "list"; "keys"]) (fun () (cctxt : Protocol_client_context.full) -> Sapling_key.load cctxt >>=? fun l -> List.iter_s (fun (s, _) -> cctxt#message "%s" s) (List.sort (fun (s1, _) (s2, _) -> String.compare s1 s2) l) >>= fun () -> return_unit); shield_cmd; unshield_cmd; forge_shielded_cmd; submit_shielded_cmd; ]
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>