mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-12-03 04:13:57 +01:00
unpack plain slatepacks without password (#805)
* unpack plain slatepacks without password * cli: better open wallet handling on wallet subcommand --------- Co-authored-by: ardocrat <ardocrat@gri.mw>
This commit is contained in:
committed by
GitHub
co-authored by
ardocrat
parent
e0873a1b2e
commit
f31f307767
+20
-18
@@ -24,7 +24,7 @@ use crate::impls::SlateGetter as _;
|
||||
use crate::keychain;
|
||||
use crate::libwallet::api_impl::types::update_tx_slate_state;
|
||||
use crate::libwallet::{
|
||||
self, InitTxArgs, IssueInvoiceTxArgs, NodeClient, PaymentProof, Slate, SlateState,
|
||||
self, InitTxArgs, IssueInvoiceTxArgs, NodeClient, PaymentProof, Slate, SlateState, Slatepack,
|
||||
SlatepackAddress, Slatepacker, SlatepackerArgs, WalletLCProvider,
|
||||
};
|
||||
use crate::util::secp::key::SecretKey;
|
||||
@@ -783,32 +783,34 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn read_slatepack(args: ReceiveArgs) -> Result<Slatepack, Error> {
|
||||
let packer = Slatepacker::new(SlatepackerArgs {
|
||||
sender: None,
|
||||
recipients: vec![],
|
||||
dec_key: None,
|
||||
});
|
||||
let slatepack = match args.input_file {
|
||||
Some(f) => PathToSlatepack::new(f.into(), &packer, true).get_slatepack(false)?,
|
||||
None => match args.input_slatepack_message {
|
||||
Some(message) => packer.deser_slatepack(message.as_bytes(), false)?,
|
||||
None => {
|
||||
return Err(Error::ArgumentError("Invalid Slatepack Input".into()).into());
|
||||
}
|
||||
},
|
||||
};
|
||||
Ok(slatepack)
|
||||
}
|
||||
|
||||
pub fn unpack<L, C, K>(
|
||||
owner_api: &mut Owner<L, C, K>,
|
||||
keychain_mask: Option<&SecretKey>,
|
||||
args: ReceiveArgs,
|
||||
mut slatepack: Slatepack,
|
||||
) -> Result<(), Error>
|
||||
where
|
||||
L: WalletLCProvider<'static, C, K> + 'static,
|
||||
C: NodeClient + 'static,
|
||||
K: keychain::Keychain + 'static,
|
||||
{
|
||||
let mut slatepack = match args.input_file {
|
||||
Some(f) => {
|
||||
let packer = Slatepacker::new(SlatepackerArgs {
|
||||
sender: None,
|
||||
recipients: vec![],
|
||||
dec_key: None,
|
||||
});
|
||||
PathToSlatepack::new(f.into(), &packer, true).get_slatepack(false)?
|
||||
}
|
||||
None => match args.input_slatepack_message {
|
||||
Some(mes) => owner_api.decode_slatepack_message(keychain_mask, mes, vec![])?,
|
||||
None => {
|
||||
return Err(Error::ArgumentError("Invalid Slatepack Input".into()).into());
|
||||
}
|
||||
},
|
||||
};
|
||||
println!();
|
||||
println!("SLATEPACK CONTENTS");
|
||||
println!("------------------");
|
||||
|
||||
Reference in New Issue
Block a user