This tutorial will give an example of setting up cold-staking using pystratis.
This guide follows the official cold-staking instructions from the Stratis Academy.
Disclaimer: DO NOT install pystratis on your cold-staking node. Installing ANY unnecessary software on this device could potentially become an attack vector and defeats the purpose.
This setup assumes you are running a fully synced node with a wallet called 'ExampleWallet'
from pystratis.nodes import StraxNode
strax_hot_node = StraxNode()
# First setup a coldstaking account in your online wallet
hot_account = strax_hot_node.coldstaking.account(
wallet_name='ExampleWallet',
wallet_password='abc123',
is_cold_wallet_account=False
)You will now see an account in your node dashboard: ExampleWallet/coldStakingHotAddresses
coldstaking_address_model = strax_hot_node.coldstaking.address(
wallet_name=hot_wallet_name,
is_cold_wallet_address=False,
segwit=False
)
coldstaking_hot_address = coldstaking_address_model.addressSave the value of coldstaking_hot_address as you'll need it to setup on your offline device.
Official documentation recommends keeping a text file with the data on a thumb drive.
Please follow the official documentation to setup your cold wallet on the offline node.
Things you'll need from this cold wallet (see official documention for details)
- An address to fund (from receive tab).
- Send funds to this address (see sending a transaction tutorial for details on doing this with pystratis)
- Fund with 10.0002 Strax for this example (enough extra to cover the fee).
- Send funds to this address (see sending a transaction tutorial for details on doing this with pystratis)
- Your coldstaking address. We'll call this
coldstaking_cold_addressfor usage below. - The extended public key of the cold wallet.
First we need to import the cold wallet's extended public key on the online node.
strax_hot_node.wallet.recover_via_extpubkey(
extpubkey='<offline_wallet_default_extpubkey>',
name='<The name for the cold wallet on the online node>',
account_index=0
)Next, build a template transaction on the online node.
offline_template = strax_hot_node.coldstaking.setup_offline(
wallet_name='<The name for the cold wallet on the online node>',
wallet_account='account 0',
cold_wallet_address=coldstaking_cold_address,
hot_wallet_address=coldstaking_hot_address,
amount=Money(10), # The amount you want to cold stake
fees=Money(0.0002) # The fee.
)Transfer the value from offline_template.unsigned_transaction to your thumb drive for signing on your offline wallet.
See the official documentation for obtaining the signed transaction hex from the offline wallet.
Bring the thumb drive back to the online node, retrieve the signed transaction hex value from your thumb drive, and send the transaction.
strax_hot_node.wallet.send_transaction('<signed hex transaction from offline node>')That's it!
Note: Per official documentation, you will only get rewards if your hot staking node is online and has staking enabled.