Skip to content

Instantly share code, notes, and snippets.

@himu007
Last active December 6, 2019 10:14
Show Gist options
  • Save himu007/5b61ebb330ee46c4c1f7518d34e30d42 to your computer and use it in GitHub Desktop.
Save himu007/5b61ebb330ee46c4c1f7518d34e30d42 to your computer and use it in GitHub Desktop.

Start ImportGateway Testing!

The guide here is based on Ubuntu/(debian) for initial testing. There may be typo or other incorrect information present as the system is being constantly updated based on specification, bugfix or other improvements. Please let us know in #cc-pegs channel of Komodo Discord if you find any issues or incorrect information. Also use the same channel for test reports, feedbacks. If you want to setup your own test side-chain follow this guide https://github.com/Mixa84/komodo/wiki/Side-chain-setup-(Import-Gateway-CC).

Explorers

Source Repo

Test Cases

  • Deposit
  • Withdraw
  • Test with invalid parameters, wrong amount, wrong/invalid address, wrong/invalid pubkey
  • Deposit to two different addresses, and then send total amount to single address and try withdraw all that you have
  • Parallel multiple withdraw

Install deps

sudo apt-get update && sudo apt-get upgrade -y
sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python zlib1g-dev wget bsdmainutils automake libboost-all-dev libssl-dev libprotobuf-dev protobuf-compiler libgtest-dev libqt4-dev libqrencode-dev libdb++-dev ntp ntpdate software-properties-common curl clang libcurl4-gnutls-dev cmake clang libsodium-dev -y

Optional

Create swap partition if you are using VPS with low amount of RAM. The following commands creates 4GB SWAP file. You can create 8GB if you have the required free storage and want it.

	sudo swapon --show
	free -h
	df -h
	sudo fallocate -l 4G /swapfile
	ls -lh /swapfile 
	sudo chmod 600 /swapfile 
	ls -lh /swapfile 
	sudo mkswap /swapfile 
	sudo swapon /swapfile
	sudo swapon --show 
	free -h
	sudo cp /etc/fstab /etc/fstab.bak
	echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
	sudo sysctl vm.swappiness=10 # This setting will persist until the next reboot. We can set this value automatically at restart by adding the line to our /etc/sysctl.conf file:
	sudo nano /etc/sysctl.conf 
	vm.swappiness=10

Build Komodo daemon

git clone https://github.com/Mixa84/komodo
cd komodo
git checkout importgateway
export CONFIGURE_FLAGS='CPPFLAGS=-DTESTMODE'
./zcutil/fetch-params.sh
./zcutil/build.sh -j$(nproc)
cd src

Test Chain (MBTCTEST) start command:

Once MBTCTEST chain is ready, generate a new address or import existing and use setpubkey. If you already know your pubkey, you can add it in the launch command like -pubkey=03e732c82d87e1ee47071f3900a79a7507b93321f5bddbb4236c10b6ca4f27e0a2.

./komodod -ac_name=MBTCTEST -pubkey=$pubkey -ac_cc=2 -ac_import=KMD -ac_end=1 -ac_reward=1 -ac_supply=1000 -ac_perc=0 -dns=0 -dnsseed=0 -listenonion=0 -debug=importgateway-2 -printtoconsole=1 -addnode=116.203.17.138 -addnode=78.47.131.224 -earlytxid=564027c872ee30a82aa9ce7b2f6a5041669d4b63ea9d86d7253c4b773fce22ab &

ImportGateway Info:

You can get the following info by issuing importgatewayinfo with bindtxid (earlytxid on chain start command is the bindtxid). So, the call for this test chain would be ./komodo-cli -ac_name=MBTCTEST importgatewayinfo 564027c872ee30a82aa9ce7b2f6a5041669d4b63ea9d86d7253c4b773fce22ab which will generate the output like below. We need the deposit address that starts with b to deposit funds.

{
  "result": "success",
  "name": "ImportGateway",
  "M": 2,
  "N": 2,
  "pubkeys": [
    "027cd5ecb55d6c3bc2bda876b34def014f6c485375a4f9be9845bf40287865c995",
    "037da889241e36a062abde5d6083d70899d32c680d84ea82940ee55b4ddcf71a0e"
  ],
  "coin": "KMD",
  "oracletxid": "40e2959f8063a3ff52fadfecf17cd0a393aa075a1091518d438bb5cbc72ad9e8",
  "taddr": 0,
  "prefix": 60,
  "prefix2": 85,
  "wiftype": 188,
  "deposit": "bJktnoQ8tdvfU4cSx2VmL17MgDUqzcYDPV"
}

You also need to be running KMD daemon and have a little bit of KMD to test. i.e.: 0.5 KMD or 1 KMD. Test depositing 0.001 or 0.01 KMD and import it to MBTCTEST chain. Claim, withdraw. Try invalid commands, different pubkey to break things intentionally. If you find any bug, please report here.

Make sure both KMD & MBTCTEST chain are fully synced. (getinfo should display "synced": true, on 4th line)

Useful Commands

importgatewayaddress [pubkey]
importgatewaybind coin orcletxid M N pubkeys pubtype p2shtype wiftype [taddr]
importgatewaydeposit bindtxid height coin cointxid markervout rawhex rawproof destpubkey amount
importgatewaydumpprivkey bindtxid address
importgatewayexternaladdress bindtxid pubkey
importgatewayinfo bindtxid
importgatewaymarkdone withdrawsigntxid coin
importgatewaypendingsignwithdraws bindtxid coin
importgatewaysignedwithdraws bindtxid coin
importgatewaywithdraw bindtxid coin withdrawpubkey amount
importgatewaywithdrawsign lasttxid coin hex

How to do a deposit?

Use z_sendmany like ./komodo-cli z_sendmany "FROM_ADDRESS" '[{"address":"myaddress","amount":MARKER_AMOUNT},{"address":"Import_Gateways_Deposit_Address","amount":AMOUNT_YOU_WANT_TO_DEPOSIT}]'. myaddress is the address that corresponds to your pubkey that you started the daemon with.

Note: Before depositing, make sure you have very low number of utxos in your wallet. Ideal to have 1 to 5 utxos. You can find how many utxos you have by issuing listunspent call on the source chain. If you have a lot of utxos, try consolidating them using sendtoaddress call to same wallet address before doing the z_sendmany. Otherwise, you might run into issues when importing them into destination chain. The daemon might complain with bad-txns-opret-too-big.

Check the following example.

./komodo-cli z_sendmany "RWzux9j8EhYb85E7xoH18BcP1fRyDPYWYL" '[{"address":"RTQ7GDHsnHZ4njDbTjUnmm8GCkRhjifFES","amount":0.0001},{"address":"bKEBwCtejNynumGH7qP2rXF67Z3Hk4LVkd","amount":0.01}]'

Get the txid of your deposit

You should get an opid from the z_sendmany which you need to examine for the txid. Alternatively you can check explorer for the txid by searching with the corresponding address(es). Then, you need to check the txid details of your deposit to find necessary info for the importgatwaydeposit call on the destination chain.

./komodo-cli z_getoperationstatus '["opid-af960d24-95ec-4a28-ab4c-152a612619f0"]'

Output:

[
  {
    "id": "opid-af960d24-95ec-4a28-ab4c-152a612619f0",
    "status": "success",
    "creation_time": 1571922576,
    "result": {
      "txid": "88a3d630f4454345b146a4d38f3684c4879ec1d82795fc75350767ad48ca36bd"
    },
    "execution_secs": 0.017099197,
    "method": "z_sendmany",
    "params": {
      "fromaddress": "RWzux9j8EhYb85E7xoH18BcP1fRyDPYWYL",
      "amounts": [
        {
          "address": "RTQ7GDHsnHZ4njDbTjUnmm8GCkRhjifFES",
          "amount": 0.0001
        },
        {
          "address": "bKEBwCtejNynumGH7qP2rXF67Z3Hk4LVkd",
          "amount": 0.001
        }
      ],
      "minconf": 1,
      "fee": 0.0001
    }
  }
]

Import the Gateway deposit

Usage: importgatewaydeposit bindtxid height coin burntxid nvout rawburntx rawproof destpubkey amount Details:

bindtxid   = This is your importgateway identifier which is also known as "earlytxid"
height     = In which block your deposit txid was confirmed from the earlier step (use explorer if searching manually)
coin       = Ticker of the coin you deposited
burntxid   = txid of your deposit
nvout      = The marker UTXO's vout number in the external deposit tx; it is always 0 when z_sendmany as shown in the guide is used
rawburntx  = The HEX value from gettransaction call for the deposited txid (available at the end of output)
rawproof   = Use "gettxoutproof" with the deposit txid
destpubkey = The pubkey you are running the desination daemon with
amount     = the amount you sent/deposited

In order to import the deposit, we need to collect some information about your deposit first which will be used on the destination chain with this RPC call. Let's gather them first. Then, we construct the call and execute it.

Get the rawburntx value

Use gettransaction RPC call on the origin chain with the txid you got from above which will display hex value at the end of output. That is your rawburntx value.

./komodo-cli gettransaction 88a3d630f4454345b146a4d38f3684c4879ec1d82795fc75350767ad48ca36bd

Output:

{
  "amount": -0.00110000,
  "fee": -0.00010000,
  "rawconfirmations": 1168,
  "confirmations": 1168,
  "blockhash": "0862877ae69fcb29283c28d731063427ed47c44a1dd448b7ac0681de65752223",
  "blockindex": 1,
  "blocktime": 1572282132,
  "expiryheight": 1594294,
  "txid": "88a3d630f4454345b146a4d38f3684c4879ec1d82795fc75350767ad48ca36bd",
  "walletconflicts": [
  ],
  "time": 1572282056,
  "timereceived": 1572282056,
  "vjoinsplit": [
  ],
  "details": [
    {
      "account": "",
      "address": "RTQ7GDHsnHZ4njDbTjUnmm8GCkRhjifFES",
      "category": "send",
      "amount": -0.00010000,
      "vout": 0,
      "fee": -0.00010000,
      "size": 276
    },
    {
      "account": "",
      "address": "bKEBwCtejNynumGH7qP2rXF67Z3Hk4LVkd",
      "category": "send",
      "amount": -0.00100000,
      "vout": 1,
      "fee": -0.00010000,
      "size": 276
    },
    {
      "account": "",
      "address": "RSgL9Af3uNTJ79P14Q4nmjHQNmmQQKYZGv",
      "category": "send",
      "amount": -1.97735000,
      "vout": 2,
      "fee": -0.00010000,
      "size": 276
    },
    {
      "account": "",
      "address": "RSgL9Af3uNTJ79P14Q4nmjHQNmmQQKYZGv",
      "category": "receive",
      "amount": 1.97735000,
      "vout": 2,
      "size": 276
    }
  ],
  "hex": "0400008085202f8901842214f9fab327d2ca256605637bcbce349c691feef19e1dac796f0ad7c8a0c6020000006a47304402207ce3b7a9159688db84507022b84e46344e7b6aa1b1d807f8d154e18fd25dac15022066d9717774b16c8ce363df580af1e6b8343acdfa26ff32751060623d82dbb34e0121029782fe2477bf26ab7a443d2349df3cd0af2bc07acff0256c43fb563b67e706e1ffffffff0310270000000000001976a914c6c127efb1d82969ff35baacf852d1c493e4691988aca08601000000000017a9144748d84df2176c67e74b20e600b15bdd9b4fc4f8875832c90b000000001976a914beda6fa1911c00959440407ec9287c9265a73b6688ac8b1eb75db65318000000000000000000000000"
}

Get rawproof value

Use gettxoutproof with the deposit txid and you will be given a hex value.

./komodo-cli gettxoutproof '["88a3d630f4454345b146a4d38f3684c4879ec1d82795fc75350767ad48ca36bd"]'

Output:

04000000b286fe28873b8e1d1472b0374f3188c8a25b593e22dfcbfd73b0d801c3230a0d767e1bc4ad4367964e4cb3b233386b66bde45fb99b20e1a9b4506e7e82ca124ba2d8a734eb73a4dc734072dbfd12406f1e7121bfe0e3d6c10922495c44e5cc1c141fb75d67ef001d0800680d6f5935a3659be03cd2a2937e2e439d1d74380db15380477d414f0000fd4005000ad03756988aa1ba3070f70a7f6ab0f7cae9f4792355e2d4121093b74ffb045ca4ae9f025d3114415c15a85ece33aba853a67042762a4eff696b3bbfa7912c0c42810d59a63fbad79380fc416f79bbf9b022b10b81a23453d405e39835836914d16651ee55378d3b2b1661eab50fdcf987fe598888fbee7a98533b19b434a1ead98228404d87bfc7692eee1bda445194ed7c3a96df1e23afb025bd6993ffcc637bd5c0dcdf207802945b16f6967a97e2df48d19650a8533dfbda18cd737b2e3a3c1d1a999294ac340675453b0f3efd200e0e4a96597a949ec9a909330e0f4ffaa97b0c7036e010f8dfc9868cec67b2e251a0242c9e752cadfb9731039c855a88975ca6faf58741f4ba9a7a665fb6adf959a3fe044b64034bbea795dd336339018f82d4bf2303a9d37445262847521bf0c2dffcad1b523f9f88a52515e5910ae5014743225396f8a2d1a57d397d316b04c950e35091f6c8d1a6e36e902b887f85c55c7e1f126facf51a1d603ba73112bdc5b32892c2e778fad018cc6de2b20685dad16ea61259e0549e7e6b5fba0a45cf73daed12d7591134881b70f896be7cc3b5b4010bb032e31686a8fb883e492b14dafdaeafd6ba07191d06e5a32cd72ea950a4857864bf6c3d877a358bef0c52def9758dcafd59fb9175a960e4d487bd68cc841d5ce2239c22755780df42bb48de6d95d5b45aac4005939750ac033aa36e46c40f66d87ba19eeb700ded1019e4d036386441e8fbf8b337f2ae4f481e9f8e6d06a9a1f20c4b3241798d12bce9fcd118c3c0389a64089735ff714f00b76994a0ae100f7f04ff816ec26d0eae730d301edefbeac352854d350068a9090eb75326eeafedf7aacb1b670072ba3a190f6d35d797b3aa38e1a29741b7df77c7c28496d8d76361feb65b98c73acf6511eb16615d2ff7f5014eceae3f7b0cbe63860088f9781458f51d0543b7f214d74f9a058d50d933297b93c772eaa7cfd4aa130bc35a4fcaf788dc38b6035793693e92e013d891da0da0e96616eb5c1c2ddc2063e737208f71ad57804307854dd0ed778dbd912d036273732dc750e2ca1cd4e48fcb57d79dde5ef6bc1390e79ed24700aedab0e26c6fc6db72adfeb8f7f724147d9b840f21a705a8330a655087bef1c6bc672469856382056280a14c6ab8d606e1b3fe6622d926230b8f359415639e77660f721e376f73dce2e16bcfa8198bfbc439d75e86c62a6307d24523d93fc92f4f0e19d91a36d0dee4adbd0be21948f3319df32074df66a22e873b55fac24ff11e8aecbae7c336c00ab6536e0bac84ad674320107d7b13c3bc3bed15e5903bc3791bc4a69e18a188eb1a9e93dc0275ffbd149c0adb8b19f96b54db4d3467c77925a18b546ef5c88b17e110390c64c7edd614f1edd7f4452371c4395f84efb40f00fe6ef0b0a8b3a3fc00241ebad2a662afd658f062082ff7e5fc95dcefd73e8204b32ceaeef77a58bc4c06da789ff29299c98a09a14dc2bac7edfc3abcf53c5374bcab41a02ec31aef47e11e6f8aaa22495f23a70223c7b284136a19efd640d6f821391044735f126916593a81b71e926148f4d715b7c1863ee44d3daf8a106506f08a471d02d448e240e96664693f3c5a88ac10b402bb394a2114a69971ec93785345a2ddff7f9e027c2f78439fd1bdc228779d294dc9d2453e1d5f7e17f53bcac350e5156ac2082971595b22f60e7df1aa06561d416f07b6d881dae1ed9bebbb7db012543de7139c3467b550cdd7ca40063e4168a5b5c9cefc951a05b490a521119444d411f3dd23220640fba1148b02219ee152312900a3a7d7d23a16d551b226ad7451e31564a3781b68f631acf178ca2763247ac624b902fc28f0d3f0ba221dd75fe6d3810a7335e9d946eef7530e000000057ebd44495a95579bebf5358c413428a940e4fa755c9bce6d26895f6a5602c8d0bd36ca48ad67073575fc9527d8c19e87c484368fd3a446b1454345f430d6a388f0a7077b57a493497c6eb70025477198ebd79c121b1bc5ceb77cbe4eeed5824fb06330cf948cead7b6c92516fb240865520968f8f048df764d719eb9f814e1f657dc5bdeb7fd6aaaf54dd64d554e58dcc5b38c4b4e8809f23f7cc73395647073022f00

Execute the importgatewaydeposit command

Now, we have gathered all necessary info. Let's build the importgatewaydeposit call and execute it.

./komodo-cli -ac_name=MBTCTEST importgatewaydeposit fec28fa1840bfddc532ca8fd4fbd9cfc9d927514ed988d95d5759675736739bc 1594095 KMD 88a3d630f4454345b146a4d38f3684c4879ec1d82795fc75350767ad48ca36bd 0.001 0400008085202f8901842214f9fab327d2ca256605637bcbce349c691feef19e1dac796f0ad7c8a0c6020000006a47304402207ce3b7a9159688db84507022b84e46344e7b6aa1b1d807f8d154e18fd25dac15022066d9717774b16c8ce363df580af1e6b8343acdfa26ff32751060623d82dbb34e0121029782fe2477bf26ab7a443d2349df3cd0af2bc07acff0256c43fb563b67e706e1ffffffff0310270000000000001976a914c6c127efb1d82969ff35baacf852d1c493e4691988aca08601000000000017a9144748d84df2176c67e74b20e600b15bdd9b4fc4f8875832c90b000000001976a914beda6fa1911c00959440407ec9287c9265a73b6688ac8b1eb75db65318000000000000000000000000 04000000b286fe28873b8e1d1472b0374f3188c8a25b593e22dfcbfd73b0d801c3230a0d767e1bc4ad4367964e4cb3b233386b66bde45fb99b20e1a9b4506e7e82ca124ba2d8a734eb73a4dc734072dbfd12406f1e7121bfe0e3d6c10922495c44e5cc1c141fb75d67ef001d0800680d6f5935a3659be03cd2a2937e2e439d1d74380db15380477d414f0000fd4005000ad03756988aa1ba3070f70a7f6ab0f7cae9f4792355e2d4121093b74ffb045ca4ae9f025d3114415c15a85ece33aba853a67042762a4eff696b3bbfa7912c0c42810d59a63fbad79380fc416f79bbf9b022b10b81a23453d405e39835836914d16651ee55378d3b2b1661eab50fdcf987fe598888fbee7a98533b19b434a1ead98228404d87bfc7692eee1bda445194ed7c3a96df1e23afb025bd6993ffcc637bd5c0dcdf207802945b16f6967a97e2df48d19650a8533dfbda18cd737b2e3a3c1d1a999294ac340675453b0f3efd200e0e4a96597a949ec9a909330e0f4ffaa97b0c7036e010f8dfc9868cec67b2e251a0242c9e752cadfb9731039c855a88975ca6faf58741f4ba9a7a665fb6adf959a3fe044b64034bbea795dd336339018f82d4bf2303a9d37445262847521bf0c2dffcad1b523f9f88a52515e5910ae5014743225396f8a2d1a57d397d316b04c950e35091f6c8d1a6e36e902b887f85c55c7e1f126facf51a1d603ba73112bdc5b32892c2e778fad018cc6de2b20685dad16ea61259e0549e7e6b5fba0a45cf73daed12d7591134881b70f896be7cc3b5b4010bb032e31686a8fb883e492b14dafdaeafd6ba07191d06e5a32cd72ea950a4857864bf6c3d877a358bef0c52def9758dcafd59fb9175a960e4d487bd68cc841d5ce2239c22755780df42bb48de6d95d5b45aac4005939750ac033aa36e46c40f66d87ba19eeb700ded1019e4d036386441e8fbf8b337f2ae4f481e9f8e6d06a9a1f20c4b3241798d12bce9fcd118c3c0389a64089735ff714f00b76994a0ae100f7f04ff816ec26d0eae730d301edefbeac352854d350068a9090eb75326eeafedf7aacb1b670072ba3a190f6d35d797b3aa38e1a29741b7df77c7c28496d8d76361feb65b98c73acf6511eb16615d2ff7f5014eceae3f7b0cbe63860088f9781458f51d0543b7f214d74f9a058d50d933297b93c772eaa7cfd4aa130bc35a4fcaf788dc38b6035793693e92e013d891da0da0e96616eb5c1c2ddc2063e737208f71ad57804307854dd0ed778dbd912d036273732dc750e2ca1cd4e48fcb57d79dde5ef6bc1390e79ed24700aedab0e26c6fc6db72adfeb8f7f724147d9b840f21a705a8330a655087bef1c6bc672469856382056280a14c6ab8d606e1b3fe6622d926230b8f359415639e77660f721e376f73dce2e16bcfa8198bfbc439d75e86c62a6307d24523d93fc92f4f0e19d91a36d0dee4adbd0be21948f3319df32074df66a22e873b55fac24ff11e8aecbae7c336c00ab6536e0bac84ad674320107d7b13c3bc3bed15e5903bc3791bc4a69e18a188eb1a9e93dc0275ffbd149c0adb8b19f96b54db4d3467c77925a18b546ef5c88b17e110390c64c7edd614f1edd7f4452371c4395f84efb40f00fe6ef0b0a8b3a3fc00241ebad2a662afd658f062082ff7e5fc95dcefd73e8204b32ceaeef77a58bc4c06da789ff29299c98a09a14dc2bac7edfc3abcf53c5374bcab41a02ec31aef47e11e6f8aaa22495f23a70223c7b284136a19efd640d6f821391044735f126916593a81b71e926148f4d715b7c1863ee44d3daf8a106506f08a471d02d448e240e96664693f3c5a88ac10b402bb394a2114a69971ec93785345a2ddff7f9e027c2f78439fd1bdc228779d294dc9d2453e1d5f7e17f53bcac350e5156ac2082971595b22f60e7df1aa06561d416f07b6d881dae1ed9bebbb7db012543de7139c3467b550cdd7ca40063e4168a5b5c9cefc951a05b490a521119444d411f3dd23220640fba1148b02219ee152312900a3a7d7d23a16d551b226ad7451e31564a3781b68f631acf178ca2763247ac624b902fc28f0d3f0ba221dd75fe6d3810a7335e9d946eef7530e000000057ebd44495a95579bebf5358c413428a940e4fa755c9bce6d26895f6a5602c8d0bd36ca48ad67073575fc9527d8c19e87c484368fd3a446b1454345f430d6a388f0a7077b57a493497c6eb70025477198ebd79c121b1bc5ceb77cbe4eeed5824fb06330cf948cead7b6c92516fb240865520968f8f048df764d719eb9f814e1f657dc5bdeb7fd6aaaf54dd64d554e58dcc5b38c4b4e8809f23f7cc73395647073022f00 03e732c82d87e1ee47071f3900a79a7507b93321f5bddbb4236c10b6ca4f27e0a2 0.001

Output:

{
  "result": "success",
  "hex": "0400008085202f89018f2da3c582bbcd0b5343037cd8bf107e410d35523fbbc1054d4c137b4940534f00ca9a3b0201e2ffffffff02a086010000000000232103e732c82d87e1ee47071f3900a79a7507b93321f5bddbb4236c10b6ca4f27e0a2ac0000000000000000fd320b6a4d2e0be211bd36ca48ad67073575fc9527d8c19e87c484368fd3a446b1454345f430d6a3880001bd36ca48ad67073575fc9527d8c19e87c484368fd3a446b1454345f430d6a3880400008085202f8901842214f9fab327d2ca256605637bcbce349c691feef19e1dac796f0ad7c8a0c6020000006a47304402207ce3b7a9159688db84507022b84e46344e7b6aa1b1d807f8d154e18fd25dac15022066d9717774b16c8ce363df580af1e6b8343acdfa26ff32751060623d82dbb34e0121029782fe2477bf26ab7a443d2349df3cd0af2bc07acff0256c43fb563b67e706e1ffffffff0410270000000000001976a914c6c127efb1d82969ff35baacf852d1c493e4691988aca08601000000000017a9144748d84df2176c67e74b20e600b15bdd9b4fc4f8875832c90b000000001976a914beda6fa1911c00959440407ec9287c9265a73b6688aca086010000000000fdcb096a4dc709e28efefefe7f034b4d44605437a68f48e0e4cadb07d20a77a6b0ed37faa9d9b5db79b912b04920b7d410fd770604000000b286fe28873b8e1d1472b0374f3188c8a25b593e22dfcbfd73b0d801c3230a0d767e1bc4ad4367964e4cb3b233386b66bde45fb99b20e1a9b4506e7e82ca124ba2d8a734eb73a4dc734072dbfd12406f1e7121bfe0e3d6c10922495c44e5cc1c141fb75d67ef001d0800680d6f5935a3659be03cd2a2937e2e439d1d74380db15380477d414f0000fd4005000ad03756988aa1ba3070f70a7f6ab0f7cae9f4792355e2d4121093b74ffb045ca4ae9f025d3114415c15a85ece33aba853a67042762a4eff696b3bbfa7912c0c42810d59a63fbad79380fc416f79bbf9b022b10b81a23453d405e39835836914d16651ee55378d3b2b1661eab50fdcf987fe598888fbee7a98533b19b434a1ead98228404d87bfc7692eee1bda445194ed7c3a96df1e23afb025bd6993ffcc637bd5c0dcdf207802945b16f6967a97e2df48d19650a8533dfbda18cd737b2e3a3c1d1a999294ac340675453b0f3efd200e0e4a96597a949ec9a909330e0f4ffaa97b0c7036e010f8dfc9868cec67b2e251a0242c9e752cadfb9731039c855a88975ca6faf58741f4ba9a7a665fb6adf959a3fe044b64034bbea795dd336339018f82d4bf2303a9d37445262847521bf0c2dffcad1b523f9f88a52515e5910ae5014743225396f8a2d1a57d397d316b04c950e35091f6c8d1a6e36e902b887f85c55c7e1f126facf51a1d603ba73112bdc5b32892c2e778fad018cc6de2b20685dad16ea61259e0549e7e6b5fba0a45cf73daed12d7591134881b70f896be7cc3b5b4010bb032e31686a8fb883e492b14dafdaeafd6ba07191d06e5a32cd72ea950a4857864bf6c3d877a358bef0c52def9758dcafd59fb9175a960e4d487bd68cc841d5ce2239c22755780df42bb48de6d95d5b45aac4005939750ac033aa36e46c40f66d87ba19eeb700ded1019e4d036386441e8fbf8b337f2ae4f481e9f8e6d06a9a1f20c4b3241798d12bce9fcd118c3c0389a64089735ff714f00b76994a0ae100f7f04ff816ec26d0eae730d301edefbeac352854d350068a9090eb75326eeafedf7aacb1b670072ba3a190f6d35d797b3aa38e1a29741b7df77c7c28496d8d76361feb65b98c73acf6511eb16615d2ff7f5014eceae3f7b0cbe63860088f9781458f51d0543b7f214d74f9a058d50d933297b93c772eaa7cfd4aa130bc35a4fcaf788dc38b6035793693e92e013d891da0da0e96616eb5c1c2ddc2063e737208f71ad57804307854dd0ed778dbd912d036273732dc750e2ca1cd4e48fcb57d79dde5ef6bc1390e79ed24700aedab0e26c6fc6db72adfeb8f7f724147d9b840f21a705a8330a655087bef1c6bc672469856382056280a14c6ab8d606e1b3fe6622d926230b8f359415639e77660f721e376f73dce2e16bcfa8198bfbc439d75e86c62a6307d24523d93fc92f4f0e19d91a36d0dee4adbd0be21948f3319df32074df66a22e873b55fac24ff11e8aecbae7c336c00ab6536e0bac84ad674320107d7b13c3bc3bed15e5903bc3791bc4a69e18a188eb1a9e93dc0275ffbd149c0adb8b19f96b54db4d3467c77925a18b546ef5c88b17e110390c64c7edd614f1edd7f4452371c4395f84efb40f00fe6ef0b0a8b3a3fc00241ebad2a662afd658f062082ff7e5fc95dcefd73e8204b32ceaeef77a58bc4c06da789ff29299c98a09a14dc2bac7edfc3abcf53c5374bcab41a02ec31aef47e11e6f8aaa22495f23a70223c7b284136a19efd640d6f821391044735f126916593a81b71e926148f4d715b7c1863ee44d3daf8a106506f08a471d02d448e240e96664693f3c5a88ac10b402bb394a2114a69971ec93785345a2ddff7f9e027c2f78439fd1bdc228779d294dc9d2453e1d5f7e17f53bcac350e5156ac2082971595b22f60e7df1aa06561d416f07b6d881dae1ed9bebbb7db012543de7139c3467b550cdd7ca40063e4168a5b5c9cefc951a05b490a521119444d411f3dd23220640fba1148b02219ee152312900a3a7d7d23a16d551b226ad7451e31564a3781b68f631acf178ca2763247ac624b902fc28f0d3f0ba221dd75fe6d3810a7335e9d946eef7530e000000057ebd44495a95579bebf5358c413428a940e4fa755c9bce6d26895f6a5602c8d0bd36ca48ad67073575fc9527d8c19e87c484368fd3a446b1454345f430d6a388f0a7077b57a493497c6eb70025477198ebd79c121b1bc5ceb77cbe4eeed5824fb06330cf948cead7b6c92516fb240865520968f8f048df764d719eb9f814e1f657dc5bdeb7fd6aaaf54dd64d554e58dcc5b38c4b4e8809f23f7cc73395647073022f00bc396773759675d5958d98ed1475929dfc9cbd4ffda82c53dcfd0b84a18fc2fe022102a827db0926b93ce574fcc0d1f4fd0604c248eecfa6825ae62dfd4de03bc94f762103e3e5292cd6f9cb218993771c7174350fd71d42c9bb61a6b825119799f825c872024c6cabdaa7c85539082a4d46bde050bce07e1c572e3990f6d53a2451f7b77d4271f9bf37fd7b590d6ebdff7b7f64698d365fec8c16c52af2eb0ef1f82bdd2224bd36ca48ad67073575fc9527d8c19e87c484368fd3a446b1454345f430d6a388ef52180000000000fd28023034303030303830383532303266383930313834323231346639666162333237643263613235363630353633376263626365333439633639316665656631396531646163373936663061643763386130633630323030303030303661343733303434303232303763653362376139313539363838646238343530373032326238346534363334346537623661613162316438303766386431353465313866643235646163313530323230363664393731373737346231366338636533363364663538306166316536623833343361636466613236666633323735313036303632336438326462623334653031323130323937383266653234373762663236616237613434336432333439646633636430616632626330376163666630323536633433666235363362363765373036653166666666666666663033313032373030303030303030303030303139373661393134633663313237656662316438323936396666333562616163663835326431633439336534363931393838616361303836303130303030303030303030313761393134343734386438346466323137366336376537346232306536303062313562646439623466633466383837353833326339306230303030303030303139373661393134626564613666613139313163303039353934343034303765633932383763393236356137336236363838616338623165623735646236353331383030303030303030303030303030303030303030303030302103e732c82d87e1ee47071f3900a79a7507b93321f5bddbb4236c10b6ca4f27e0a2a0860100000000008b1eb75db6531800000000000000000000000000000000000000000000000000000000000000"
}

Now, we need to use sendrawtransaction to broadcast this tx.

./komodo-cli -ac_name=MBTCTEST sendrawtransaction 0400008085202f89018f2da3c582bbcd0b5343037cd8bf107e410d35523fbbc1054d4c137b4940534f00ca9a3b0201e2ffffffff02a086010000000000232103e732c82d87e1ee47071f3900a79a7507b93321f5bddbb4236c10b6ca4f27e0a2ac0000000000000000fd320b6a4d2e0be211bd36ca48ad67073575fc9527d8c19e87c484368fd3a446b1454345f430d6a3880001bd36ca48ad67073575fc9527d8c19e87c484368fd3a446b1454345f430d6a3880400008085202f8901842214f9fab327d2ca256605637bcbce349c691feef19e1dac796f0ad7c8a0c6020000006a47304402207ce3b7a9159688db84507022b84e46344e7b6aa1b1d807f8d154e18fd25dac15022066d9717774b16c8ce363df580af1e6b8343acdfa26ff32751060623d82dbb34e0121029782fe2477bf26ab7a443d2349df3cd0af2bc07acff0256c43fb563b67e706e1ffffffff0410270000000000001976a914c6c127efb1d82969ff35baacf852d1c493e4691988aca08601000000000017a9144748d84df2176c67e74b20e600b15bdd9b4fc4f8875832c90b000000001976a914beda6fa1911c00959440407ec9287c9265a73b6688aca086010000000000fdcb096a4dc709e28efefefe7f034b4d44605437a68f48e0e4cadb07d20a77a6b0ed37faa9d9b5db79b912b04920b7d410fd770604000000b286fe28873b8e1d1472b0374f3188c8a25b593e22dfcbfd73b0d801c3230a0d767e1bc4ad4367964e4cb3b233386b66bde45fb99b20e1a9b4506e7e82ca124ba2d8a734eb73a4dc734072dbfd12406f1e7121bfe0e3d6c10922495c44e5cc1c141fb75d67ef001d0800680d6f5935a3659be03cd2a2937e2e439d1d74380db15380477d414f0000fd4005000ad03756988aa1ba3070f70a7f6ab0f7cae9f4792355e2d4121093b74ffb045ca4ae9f025d3114415c15a85ece33aba853a67042762a4eff696b3bbfa7912c0c42810d59a63fbad79380fc416f79bbf9b022b10b81a23453d405e39835836914d16651ee55378d3b2b1661eab50fdcf987fe598888fbee7a98533b19b434a1ead98228404d87bfc7692eee1bda445194ed7c3a96df1e23afb025bd6993ffcc637bd5c0dcdf207802945b16f6967a97e2df48d19650a8533dfbda18cd737b2e3a3c1d1a999294ac340675453b0f3efd200e0e4a96597a949ec9a909330e0f4ffaa97b0c7036e010f8dfc9868cec67b2e251a0242c9e752cadfb9731039c855a88975ca6faf58741f4ba9a7a665fb6adf959a3fe044b64034bbea795dd336339018f82d4bf2303a9d37445262847521bf0c2dffcad1b523f9f88a52515e5910ae5014743225396f8a2d1a57d397d316b04c950e35091f6c8d1a6e36e902b887f85c55c7e1f126facf51a1d603ba73112bdc5b32892c2e778fad018cc6de2b20685dad16ea61259e0549e7e6b5fba0a45cf73daed12d7591134881b70f896be7cc3b5b4010bb032e31686a8fb883e492b14dafdaeafd6ba07191d06e5a32cd72ea950a4857864bf6c3d877a358bef0c52def9758dcafd59fb9175a960e4d487bd68cc841d5ce2239c22755780df42bb48de6d95d5b45aac4005939750ac033aa36e46c40f66d87ba19eeb700ded1019e4d036386441e8fbf8b337f2ae4f481e9f8e6d06a9a1f20c4b3241798d12bce9fcd118c3c0389a64089735ff714f00b76994a0ae100f7f04ff816ec26d0eae730d301edefbeac352854d350068a9090eb75326eeafedf7aacb1b670072ba3a190f6d35d797b3aa38e1a29741b7df77c7c28496d8d76361feb65b98c73acf6511eb16615d2ff7f5014eceae3f7b0cbe63860088f9781458f51d0543b7f214d74f9a058d50d933297b93c772eaa7cfd4aa130bc35a4fcaf788dc38b6035793693e92e013d891da0da0e96616eb5c1c2ddc2063e737208f71ad57804307854dd0ed778dbd912d036273732dc750e2ca1cd4e48fcb57d79dde5ef6bc1390e79ed24700aedab0e26c6fc6db72adfeb8f7f724147d9b840f21a705a8330a655087bef1c6bc672469856382056280a14c6ab8d606e1b3fe6622d926230b8f359415639e77660f721e376f73dce2e16bcfa8198bfbc439d75e86c62a6307d24523d93fc92f4f0e19d91a36d0dee4adbd0be21948f3319df32074df66a22e873b55fac24ff11e8aecbae7c336c00ab6536e0bac84ad674320107d7b13c3bc3bed15e5903bc3791bc4a69e18a188eb1a9e93dc0275ffbd149c0adb8b19f96b54db4d3467c77925a18b546ef5c88b17e110390c64c7edd614f1edd7f4452371c4395f84efb40f00fe6ef0b0a8b3a3fc00241ebad2a662afd658f062082ff7e5fc95dcefd73e8204b32ceaeef77a58bc4c06da789ff29299c98a09a14dc2bac7edfc3abcf53c5374bcab41a02ec31aef47e11e6f8aaa22495f23a70223c7b284136a19efd640d6f821391044735f126916593a81b71e926148f4d715b7c1863ee44d3daf8a106506f08a471d02d448e240e96664693f3c5a88ac10b402bb394a2114a69971ec93785345a2ddff7f9e027c2f78439fd1bdc228779d294dc9d2453e1d5f7e17f53bcac350e5156ac2082971595b22f60e7df1aa06561d416f07b6d881dae1ed9bebbb7db012543de7139c3467b550cdd7ca40063e4168a5b5c9cefc951a05b490a521119444d411f3dd23220640fba1148b02219ee152312900a3a7d7d23a16d551b226ad7451e31564a3781b68f631acf178ca2763247ac624b902fc28f0d3f0ba221dd75fe6d3810a7335e9d946eef7530e000000057ebd44495a95579bebf5358c413428a940e4fa755c9bce6d26895f6a5602c8d0bd36ca48ad67073575fc9527d8c19e87c484368fd3a446b1454345f430d6a388f0a7077b57a493497c6eb70025477198ebd79c121b1bc5ceb77cbe4eeed5824fb06330cf948cead7b6c92516fb240865520968f8f048df764d719eb9f814e1f657dc5bdeb7fd6aaaf54dd64d554e58dcc5b38c4b4e8809f23f7cc73395647073022f00bc396773759675d5958d98ed1475929dfc9cbd4ffda82c53dcfd0b84a18fc2fe022102a827db0926b93ce574fcc0d1f4fd0604c248eecfa6825ae62dfd4de03bc94f762103e3e5292cd6f9cb218993771c7174350fd71d42c9bb61a6b825119799f825c872024c6cabdaa7c85539082a4d46bde050bce07e1c572e3990f6d53a2451f7b77d4271f9bf37fd7b590d6ebdff7b7f64698d365fec8c16c52af2eb0ef1f82bdd2224bd36ca48ad67073575fc9527d8c19e87c484368fd3a446b1454345f430d6a388ef52180000000000fd28023034303030303830383532303266383930313834323231346639666162333237643263613235363630353633376263626365333439633639316665656631396531646163373936663061643763386130633630323030303030303661343733303434303232303763653362376139313539363838646238343530373032326238346534363334346537623661613162316438303766386431353465313866643235646163313530323230363664393731373737346231366338636533363364663538306166316536623833343361636466613236666633323735313036303632336438326462623334653031323130323937383266653234373762663236616237613434336432333439646633636430616632626330376163666630323536633433666235363362363765373036653166666666666666663033313032373030303030303030303030303139373661393134633663313237656662316438323936396666333562616163663835326431633439336534363931393838616361303836303130303030303030303030313761393134343734386438346466323137366336376537346232306536303062313562646439623466633466383837353833326339306230303030303030303139373661393134626564613666613139313163303039353934343034303765633932383763393236356137336236363838616338623165623735646236353331383030303030303030303030303030303030303030303030302103e732c82d87e1ee47071f3900a79a7507b93321f5bddbb4236c10b6ca4f27e0a2a0860100000000008b1eb75db6531800000000000000000000000000000000000000000000000000000000000000

Output:

4d5ee8e5eb1df415e2ac202f6f49fae58f72e43b722f4ce7bcf58ef8794c52df

Congratulations! We successfully imported the deposit in our destination chain.

Check the imported balance

You can issue getbalance call on the destination chain to see the balance or query importgatewayaddress with your pubkey using the following call.

./komodo-cli -ac_name=MBTCTEST importgatewayaddress 564027c872ee30a82aa9ce7b2f6a5041669d4b63ea9d86d7253c4b773fce22ab

Output:

{
  "result": "success",
  "ImportGatewayCCAddress": "RXJT6CRAXHFuQ2UjqdxMj7EfrayF6UJpzZ",
  "ImportGatewayCCBalance": 0.00001000,
  "ImportGatewayNormalAddress": "RNFRho63Ddz1Rh2eGPETykrU4fA8r67S4Y",
  "ImportGatewayNormalBalance": 0.00000000,
  "ImportGatewayCCTokensAddress": "RAczoarH6zfAzcsY2dX6xuCm6tEU2K6tVK",
  "myCCAddress(ImportGateway)": "RD3Fjm4m7p5esuukUzxsAMepiu2Erhq9rv",
  "myCCbalance(ImportGateway)": 0.00000000,
  "myaddress": "REz25A9g1yoD6ioXfb7g7kDTRqNKnWHvHK",
  "mybalance": 0.01128000
}

Withdraw Funds

To withdraw funds you need to issue importgatewaywithdraw with the bindtxid coin destpubkey amount which will give you a raw HEX value and you need to broadcast it. Here is an example.

Issue importgatewaywithdraw

./komodo-cli -ac_name=MBTCTEST importgatewaywithdraw 564027c872ee30a82aa9ce7b2f6a5041669d4b63ea9d86d7253c4b773fce22ab KMD 0272be30b24055010df25f2a895d2bd485cbe9993ff9e96d7cbe9ff8f91472042d 0.01

Output:

0400008085202f890290d596ebb578d0fe35489175b349a14626dacf8560d9ed798b570b69180fae110000000049483045022100c04cd6e2d56841a675ca87e186c305902e8e78a66e2a0a73de33a1f0776bc24002202f1fe981886b43e08397382c92802eb3daf5cca4f5d4fc0247fd3910a1e0e9eb01ffffffff86f1f35ba40af4f8923e6c506ed2a0106ad585347f59b0eed36baa4d91e27182000000004847304402204d8c088ac695d47733ba54f72ba9a21567d02e9eba07e1d5cc0f3bf6d0a5016e02204cd7dee162289fbf33ef0eb5d0d222a0f5c9ed248b5249ffedf27ecb850d623e01ffffffff04e803000000000000302ea22c802023fdb7aec87075c24597e7d04613e9ee31f5ed9bf1a799de3c42a2e9a11c28f58103120c008203000401cc40420f0000000000232102ab22ce3f774b3c25d7869dea634b9d6641506a2f7bcea92aa830ee72c8274056ac384a000000000000232102ed3e21e06ff9ff06c55058da4399a25f755ca66f4418617fb2251b0e89837886ac0000000000000000756a4c72f357ab22ce3f774b3c25d7869dea634b9d6641506a2f7bcea92aa830ee72c82740562102ed3e21e06ff9ff06c55058da4399a25f755ca66f4418617fb2251b0e89837886034b4d44210272be30b24055010df25f2a895d2bd485cbe9993ff9e96d7cbe9ff8f91472042d40420f0000000000000000000b1900000000000000000000000000

Broadcast the HEX

./komodo-cli -ac_name=MBTCTEST sendrawtransaction 0400008085202f890290d596ebb578d0fe35489175b349a14626dacf8560d9ed798b570b69180fae110000000049483045022100c04cd6e2d56841a675ca87e186c305902e8e78a66e2a0a73de33a1f0776bc24002202f1fe981886b43e08397382c92802eb3daf5cca4f5d4fc0247fd3910a1e0e9eb01ffffffff86f1f35ba40af4f8923e6c506ed2a0106ad585347f59b0eed36baa4d91e27182000000004847304402204d8c088ac695d47733ba54f72ba9a21567d02e9eba07e1d5cc0f3bf6d0a5016e02204cd7dee162289fbf33ef0eb5d0d222a0f5c9ed248b5249ffedf27ecb850d623e01ffffffff04e803000000000000302ea22c802023fdb7aec87075c24597e7d04613e9ee31f5ed9bf1a799de3c42a2e9a11c28f58103120c008203000401cc40420f0000000000232102ab22ce3f774b3c25d7869dea634b9d6641506a2f7bcea92aa830ee72c8274056ac384a000000000000232102ed3e21e06ff9ff06c55058da4399a25f755ca66f4418617fb2251b0e89837886ac0000000000000000756a4c72f357ab22ce3f774b3c25d7869dea634b9d6641506a2f7bcea92aa830ee72c82740562102ed3e21e06ff9ff06c55058da4399a25f755ca66f4418617fb2251b0e89837886034b4d44210272be30b24055010df25f2a895d2bd485cbe9993ff9e96d7cbe9ff8f91472042d40420f0000000000000000000b1900000000000000000000000000

Broadcasting the above HEX will should you a txid which corresponds, it worked. If it didn't work or not valid, you should see some error message.
You can check the unconfirmed balance on KMD chain using ./komodo-cli getunconfirmedbalance or ./komodo-cli getwalletinfo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment