diff --git a/crates/by-chain/icepick-solana/src/lib.rs b/crates/by-chain/icepick-solana/src/lib.rs index 04241e6..ec3fb42 100644 --- a/crates/by-chain/icepick-solana/src/lib.rs +++ b/crates/by-chain/icepick-solana/src/lib.rs @@ -1,3 +1,45 @@ +//! Solana support for Icepick. +//! +//! # Command Line Arguments +//! +//! The first thing you'll want is a wallet. For this, you can run the command +//! `icepick sol generate-wallet`. The output of the command will be a request to derive a key, +//! which Icepick will interpret upon subsequent invocations and replace with the derived key - +//! after appending the valid `bip44` path. You can then pipe the output of the command to +//! `icepick sol get-wallet-address`, which will take the derived key and format it as a Solana +//! address. In full, the commands look like: +//! +//! ```sh +//! icepick sol generate-wallet | icepick sol get-wallet-address +//! ``` +//! +//! Next, you'll want to either airdrop some funds into the wallet if on devnet, or transfer some +//! funds using another source if on mainnet. +//! +//! +//! To transfer funds out of the wallet, you'll need a recent blockhash. The command +//! `icepick sol get-blockhash` can be used to get a recent blockhash. This blockhash must be used +//! within 150 blocks, or about 1 minute, or transactions won't be accepted. +//! +//! The blockhash is then used in the next command, `icepick sol transfer`, which also requires an +//! amount, a to-address, and a from-address. The output of this command can then be saved to +//! removable media, then transferred to an offline signer system where `icepick sol sign` is used +//! to sign the transaction, with the signed result also persisted to removable media. Once the +//! signed transaction is back on an online system, the transaction can be broadcasted using +//! `icepick sol broadcast`. +//! +//! ```sh +//! # On an online system +//! blockhash=$(icepick sol get-blockhash | jq -r .blob) +//! icepick sol transfer $amount $to_address $from_address $blockhash > sdcard/unsigned.json +//! +//! # On an offline system +//! icepick sol sign < sdcard/unsigned.json > sdcard/signed.json +//! +//! # On the online system, again +//! icepick sol broadcast < sdcard/signed.json +//! ``` + use icepick_module::{ help::{Argument, ArgumentType}, Module, @@ -39,7 +81,7 @@ pub struct GetBlockhash { #[derive(Serialize, Deserialize, Debug)] #[serde(rename_all = "kebab-case")] pub struct GenerateWallet { - account: String, + account: Option, } #[derive(Serialize, Deserialize, Debug)] @@ -239,7 +281,7 @@ impl Module for Solana { })) } Operation::GenerateWallet(GenerateWallet { account }) => { - let account = u32::from_str(&account).expect("account index"); + let account = u32::from_str(account.as_deref().unwrap_or("0")).unwrap(); Ok(serde_json::json!({ "blob": null, "derivation-accounts": [(account | 1 << 31)],