[Solved] One command send AE from node!


#1

##################################English Edition#################
One command to send ae!
Need Use linux expect

sudo apt-get install tcl tk expect

##if ubuntu 18 vi has some wrong with paste。 you can : echo “set pastetoggle=” >> ~/.vimrc
vi tx ####paste follows content,And chenge secretpassword123 to your self node PrivetKeygen password!

#!/usr/bin/expect
set recepientAdd [lindex $argv 0]
set sendAmount [lindex $argv 1]
set accountNonce [lindex $argv 2]
set blockHeight [lindex $argv 3]
incr accountNonce
set unlockHeight [expr {$blockHeight + 10}]
puts $recepientAdd
puts $sendAmount
puts $accountNonce
puts $unlockHeight

spawn bin/epoch remote_console
expect “)1>"
send “{ok, EncryptedPrivKeyBin} = file:read_file(“generated_keys/key”).\r”
expect "
)2>”
send “Password = “secretpassword123”.\r”
expect “)3>"
send “DecryptedPrivKeyBin = crypto:block_decrypt(aes_ecb, crypto:hash(sha256, Password), EncryptedPrivKeyBin).\r”
expect "
)4>”
send “{ok, EncryptedPubKeyBin} = file:read_file(“generated_keys/key.pub”).\r”
expect “)5>"
send “DecryptedPubKeyBin = crypto:block_decrypt(aes_ecb, crypto:hash(sha256, Password), EncryptedPubKeyBin).\r”
expect "
)6>”
send “RecepientAddress = <<”${recepientAdd}">>.\r"
expect “)7>"
send “{ok, RecepientPubKey} = aehttp_api_encoder:safe_decode(account_pubkey, RecepientAddress).\r”
expect "
)8>”
send “Nonce = ${accountNonce}.\r”
expect “)9>"
send “{ok, SpendTx} = aec_spend_tx:new(#{
sender_id => aec_id:create(account, DecryptedPubKeyBin),
recipient_id => aec_id:create(account, RecepientPubKey),
amount => round(${sendAmount}.0e18),
fee => 20000,
ttl => ${blockHeight},
nonce => ${accountNonce},
payload => <<”">>
}).\r"
expect "
)10>”
send “EncodedSpendTx = aetx:serialize_to_binary(SpendTx),
EncodedSpendTxForNetwork = aec_governance:add_network_id(EncodedSpendTx),
Signature = enacl:sign_detached(EncodedSpendTxForNetwork, DecryptedPrivKeyBin),
SignedSpendTx = aetx_sign:new(SpendTx,[Signature]).\r”
expect “)11>"
send “aec_tx_pool:push(SignedSpendTx).\r”
expect "
)12>”

chmod 777 tx

example:
check yourself node account(sender account) to get nonce number
#curl -G ‘http://127.0.0.1:3013/v2/accounts/ak_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
return:
{“balance”:733,“id”:“ak_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx”,“nonce”:4}
yes !nonce is 4 rember it.
Get block height from any explorer
https://explorer.aepps.com or https://www.aeknow.org/
yes~! is 7948 rember it.

send example: argument 1:recepientAddress argument 2: sendAmount argument 3: Nonce argument 4: blockHeight

./tx ak_2a9icm3Ed3BSboch3L2VomrgurgRzr46Uw1BTromTx3uWUS5P6 50 4 7948
#return:
([email protected])11> aec_tx_pool:push(SignedSpendTx).
ok!

#note!! ak_2a9icm3Ed3BSboch3L2VomrgurgRzr46Uw1BTromTx3uWUS5P6 is my wallet please chenge to your recepientAddress

IF usefull for you !
Thank to donation a little AE to me!

donation address: ak_2a9icm3Ed3BSboch3L2VomrgurgRzr46Uw1BTromTx3uWUS5P6
Just a little! Thanks!

QQ:86558732


#2

Forget !
precondition is :your node is running! you in epoch dir!
if your node is running and you get node is not running error 。
please redownload sourcecode edition epoch ,and compile it by yourself!
!Rember!! backup your generated_keys !!