-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Noble forwarding address registration in pcli (#4865)
## Describe your changes This adds support for registering Noble forwarding addresses, for example: `pcli tx register-forwarding-account --noble-node http://noble-testnet-grpc.polkachu.com:21590 --channel channel-216 --address-or-index 2` Note that your address will need to be funded prior to being registered; the [faucet](https://faucet.circle.com/) can be used along with the `pcli view noble-address ADDRESS_OR_INDEX --channel channel-216` command to get test funds. ## Issue ticket number and link Closes #4857 ## Checklist before requesting a review - [ ] If this code contains consensus-breaking changes, I have added the "consensus-breaking" label. Otherwise, I declare my belief that there are not consensus-breaking changes, for the following reason: > pcli only
- Loading branch information
Showing
24 changed files
with
6,898 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use anyhow::Result; | ||
use rand_core::OsRng; | ||
|
||
use penumbra_keys::{Address, FullViewingKey}; | ||
|
||
#[derive(Debug, clap::Parser)] | ||
pub struct NobleAddressCmd { | ||
/// The address to provide information about | ||
#[clap(default_value = "0")] | ||
address_or_index: String, | ||
/// Generate an ephemeral address instead of an indexed one. | ||
#[clap(short, long)] | ||
ephemeral: bool, | ||
/// The Noble IBC channel to use for forwarding. | ||
#[clap(long)] | ||
channel: String, | ||
} | ||
|
||
impl NobleAddressCmd { | ||
/// Determine if this command requires a network sync before it executes. | ||
pub fn offline(&self) -> bool { | ||
true | ||
} | ||
|
||
pub fn exec(&self, fvk: &FullViewingKey) -> Result<()> { | ||
let index: Result<u32, _> = self.address_or_index.parse(); | ||
|
||
let address = if let Ok(index) = index { | ||
// address index provided | ||
let (address, _dtk) = match self.ephemeral { | ||
false => fvk.incoming().payment_address(index.into()), | ||
true => fvk.incoming().ephemeral_address(OsRng, index.into()), | ||
}; | ||
|
||
address | ||
} else { | ||
// address or nothing provided | ||
let address: Address = self | ||
.address_or_index | ||
.parse() | ||
.map_err(|_| anyhow::anyhow!("Provided address is invalid."))?; | ||
|
||
address | ||
}; | ||
|
||
let noble_address = address.noble_forwarding_address(&self.channel); | ||
|
||
println!("{}", noble_address); | ||
|
||
Ok(()) | ||
} | ||
} |
This file contains 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
Oops, something went wrong.