mirror of
https://github.com/danog/toncontest.git
synced 2024-11-26 20:15:01 +01:00
Add wallet creation script
This commit is contained in:
parent
f5e5f6b0e7
commit
308b6a688c
3
.gitignore
vendored
3
.gitignore
vendored
@ -1 +1,4 @@
|
||||
ton-db-dir
|
||||
*.pk
|
||||
*.addr
|
||||
*.boc
|
||||
|
15
.vscode/c_cpp_properties.json
vendored
Normal file
15
.vscode/c_cpp_properties.json
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Linux",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**"
|
||||
],
|
||||
"defines": [],
|
||||
"compilerPath": "/usr/bin/clang",
|
||||
"intelliSenseMode": "clang-x64",
|
||||
"compileCommands": "${workspaceFolder}/lib/build/compile_commands.json"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
18
README.md
18
README.md
@ -0,0 +1,18 @@
|
||||
# Daniil Gentili entry
|
||||
|
||||
This is my entry for the TON contest.
|
||||
|
||||
## Building
|
||||
|
||||
Simply run the build.sh script to automatically build tonlib and set up some simplified wrapper scripts.
|
||||
|
||||
```
|
||||
toolchain/build.sh
|
||||
```
|
||||
|
||||
This will automatically build the lite client, fift and func, and will also edit .bashrc to add some wrapper scripts to the PATH.
|
||||
|
||||
* `lite-client` runs the lite client, already preconfigured to connect to the testnet, with db path set to $TONLIB_HOME/../ton-db-dir (aka this repo/ton-db-dir).
|
||||
* `funcompile` is a wrapper for the `func` compiler, automatically including the stdlib while compiling.
|
||||
* `fift` is a simple wrapper for the fift compiler.
|
||||
|
@ -40,14 +40,15 @@ PROGRAM{
|
||||
SWAP
|
||||
SETCODE
|
||||
}>ELSE<{
|
||||
WHILEEND:<{
|
||||
WHILE:<{
|
||||
DUP
|
||||
SREFS
|
||||
}>DO<{
|
||||
8 LDU
|
||||
LDREF
|
||||
s0 s2 XCHG
|
||||
SENDRAWMSG
|
||||
}>
|
||||
8 LDU
|
||||
LDREF
|
||||
s0 s2 XCHG
|
||||
SENDRAWMSG
|
||||
}>
|
||||
ENDS
|
||||
INC
|
||||
@ -63,4 +64,3 @@ PROGRAM{
|
||||
32 PLDU
|
||||
}>
|
||||
}END>c
|
||||
2 boc+>B "RS" B>file
|
||||
|
37
wallet-create.fif
Normal file
37
wallet-create.fif
Normal file
@ -0,0 +1,37 @@
|
||||
"Asm.fif" include
|
||||
"TonUtil.fif" include
|
||||
|
||||
{ ."usage: " @' $0 type ." <workchain-id> [<filename-base>]" cr
|
||||
."Creates a new advanced wallet in specified workchain, with private key saved to or loaded from <filename-base>.pk" cr
|
||||
."('new-wallet.pk' by default)" cr 1 halt
|
||||
} : usage
|
||||
$# 1- -2 and ' usage if
|
||||
|
||||
$1 parse-workchain-id =: wc // set workchain id from command line argument
|
||||
def? $2 { @' $2 } { "new-wallet" } cond constant file-base
|
||||
|
||||
."Creating new advanced wallet in workchain " wc . cr
|
||||
|
||||
"wallet-code.fif" include
|
||||
// code
|
||||
<b 0 32 u,
|
||||
file-base +".pk" load-generate-keypair
|
||||
constant wallet_pk
|
||||
B,
|
||||
b> // data
|
||||
null // no libraries
|
||||
<b b{0011} s, 3 roll ref, rot ref, swap dict, b> // create StateInit
|
||||
dup ."StateInit: " <s csr. cr
|
||||
dup hash wc swap 2dup 2constant wallet_addr
|
||||
."new wallet address = " 2dup .addr cr
|
||||
2dup file-base +".addr" save-address-verbose
|
||||
."Non-bounceable address (for init): " 2dup 7 .Addr cr
|
||||
."Bounceable address (for later access): " 6 .Addr cr
|
||||
<b 0 32 u, -1 32 i, b>
|
||||
dup ."signing message: " <s csr. cr
|
||||
dup hash wallet_pk ed25519_sign_uint rot
|
||||
<b b{1000100} s, wallet_addr addr, b{000010} s, swap <s s, b{0} s, swap B, swap <s s, b>
|
||||
dup ."External message for initialization is " <s csr. cr
|
||||
2 boc+>B dup Bx. cr
|
||||
file-base +"-query.boc" tuck B>file
|
||||
."(Saved wallet creating query to file " type .")" cr
|
Loading…
Reference in New Issue
Block a user