Created
December 12, 2018 13:40
-
-
Save monacoinproject/734f65c15e0a375c68d62ffe3254dc33 to your computer and use it in GitHub Desktop.
MonacoinにLua VMを組み込んでみました
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
・coindを立ち上げておくだけで任意の処理をしてくれると便利になるかも | |
・採用例が増えればノードが増えるかも | |
・coindを使った学習をする際に、rpcからスタートするよりかは若干楽 | |
という期待をしつつ作成。 | |
ソースはplugin_devブランチ | |
>git clone -b plugin_dev https://github.com/monacoinproject/monacoin.git | |
使い方は、wallet.datと同じフォルダにpluginフォルダを作成して、その中にluaで書かれたプログラムを入れ | |
> loadplugin luaファイル名 | |
でロードします。 | |
> unloadplugin luaファイル名 | |
で削除されます。 | |
sampleフォルダ内にあるpluginフォルダを、そのままwallet.datと同じフォルダにコピーすれば以下のサンプルが試せます。 | |
(スクリプト内のアドレスやアカウントは適宜修正してください) | |
・empty.lua coindから呼び出されるコールバック関数の説明 | |
・blocknotify_test.lua OnBlockNotify のテスト | |
・send_test.lua 送金コマンドテスト | |
・thread_testlua スレッドテスト | |
・etc.lua その他関数のテスト | |
現在、使える関数は以下の11つです。 | |
少ないのは単に手間の問題で、需要があれば増やしていこうかと思います。 | |
// thread func | |
{"CreateThread", l_CreateThread}, | |
{"Join", l_Join}, | |
// coind internal func | |
{"IsInitialBlockDownload", l_IsInitialBlockDownload}, | |
// coind command | |
{"getaccount", l_getaccount}, | |
{"getaddressesbyaccount", l_getaddressesbyaccount}, | |
{"getbalance", l_getbalance}, | |
{"getblock", l_getblock}, | |
{"gettransaction", l_gettransaction}, | |
{"sendfrom", l_sendfrom}, | |
{"sendmany", l_sendmany}, | |
{"sendtoaddress", l_sendtoaddress}, | |
今回初めてLuaを触って数日なので、Luaのお作法的なものは詳しくないです。 | |
ubuntu以外ではテストしていません。 | |
ネイティブcolored coinと組み合わせるとなんか面白そうなことができそう? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment