ton-blockchain / ton

Main TON monorepo
Other
2.95k stars 891 forks source link

[bug] Fift interpreting adresses starting with "-1" #207

Closed ank-everstake closed 4 years ago

ank-everstake commented 4 years ago

Using commit.

Can't make request to elector using fift. Apparently the problem is in interpreting adresses.

(env) ton@poligon_1 /m/o/T/b/b6f67> ./fift -s wallet.fif wallet_19_11_2019 -1:3333333333333333333333333333333333333333333333333333333333333333  40 1. -B recover-query.boc result
usage: wallet.fif <filename-base> <dest-addr> <seqno> <amount> [-n|-b] [-B <body-boc>] [-C <comment>] [<savefile>]
    Creates a request to simple wallet created by new-wallet.fif, with private key loaded from file <filename-base>.pk and address from <filename-base>.addr, and saves it into <savefile>.boc ('wallet-query.boc' by default)
-n/--no-bounce  Clears bounce flag
-b/--force-bounce   Forces bounce flag
-B/--body=<optarg>  Sets the payload of the transfer message
-C/--comment=<optarg>   Sets the comment to be sent in the transfer message
-m/--mode=<optarg>  Sets transfer mode (0..255) for SENDRAWMSG (3 by default)
-h/--help   Shows a help message
[ 1][t 0][1575886859.649007797][words.cpp:2984] wallet.fif:30: parse-options: cannot parse command line options near `-1:3333333333333333333333333333333333333333333333333333333333333333`
[ 1][t 0][1575886859.649032593][fift-main.cpp:196]  Error interpreting file `wallet.fif`: error interpreting included file `wallet.fif` : wallet.fif:30: parse-options: cannot parse command line options near `-1:3333333333333333333333333333333333333333333333333333333333333333`

(env) ton@poligon_1 /m/o/T/b/b6f67> ./fift -s wallet.fif wallet_19_11_2019 0:3333333333333333333333333333333333333333333333333333333333333333  40 1. -B recover-query.boc result
Source wallet address = -1:5c5d20fd3423b60b9e9875adcbbfc139b7ea60abbe4e39ed4c2a582de74bb669
kf9cXSD9NCO2C56Yda3Lv8E5t-pgq75OOe1MKlgt50u2aQts
Loading private key from file wallet_19_11_2019.pk
Transferring GR$1. to account kQAzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMw8H = 0:3333333333333333333333333333333333333333333333333333333333333333 seqno=0x28 bounce=-1
Body of transfer message is x{47657424000000005DEE11D9}

signing message: x{0000002803}
 x{62001999999999999999999999999999999999999999999999999999999999999999A1DCD650000000000000000000000000000047657424000000005DEE11D9}

resulting external message: x{89FEB8BA41FA68476C173D30EB5B977F82736FD4C1577C9C73DA9854B05BCE976CD206C021766EF0A5F193E94C8E7D237F3F9164455BA03F791BA29781F1512B5A4CB8006BAE42CF1D63AAD3C83C5177361803C4C175D57E98B20CF9D6C039FDC2F048000001401C_}
 x{62001999999999999999999999999999999999999999999999999999999999999999A1DCD650000000000000000000000000000047657424000000005DEE11D9}

B5EE9C724101020100AD0001CF89FEB8BA41FA68476C173D30EB5B977F82736FD4C1577C9C73DA9854B05BCE976CD206C021766EF0A5F193E94C8E7D237F3F9164455BA03F791BA29781F1512B5A4CB8006BAE42CF1D63AAD3C83C5177361803C4C175D57E98B20CF9D6C039FDC2F048000001401C01008062001999999999999999999999999999999999999999999999999999999999999999A1DCD650000000000000000000000000000047657424000000005DEE11D927B7E90E
(Saved to file result.boc)

Maybe it is a regression?

Also, we need ability to use raw addresses to omit converting in scripts, so please don't propose using base64-coded.

ton-blockchain commented 4 years ago

This is due to the newly-introduced Getopt-like command line options parser. It attempts to parse a command line argument beginning with "-1" as a short option '1' with some parameters, and fails because there is no such option.

The obvious way to circumvent this problem is to insert -- after all command line options and before the rest of the command line arguments:

./fift -s wallet.fif wallet_19_11_2019 -B recover-query.boc -- -1:3333333333333333333333333333333333333333333333333333333333333333 40 1. result

Note that -B recover-query.boc has to be moved before --.

ank-everstake commented 4 years ago

Ok, it's a feature then. So, the documentation should be updated on test.ton.org and obviously usage sections in smart-contract sources, because now it is outdated:

usage: wallet.fif <filename-base> <dest-addr> <seqno> <amount> [-n|-b] [-B <body-boc>] [-C <comment>] [<savefile>]
ton-blockchain commented 4 years ago

What's wrong with "usage" sections?

ton-blockchain commented 4 years ago

We have introduced an optional incompatibility with getopt in commit d41ce55305718d207867f0dac60319ec4b6846f2 by making our GetOpt ignore all options beginning with - followed by a decimal digit, and enabled this behavior for wallet.fif and similar scripts. You can now use addresses -1:xxx as before without any additional manipulations.