mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-10-17 07:11:36 +02:00
keep outgoing slatepacks readable
This commit is contained in:
+1
-1
@@ -2345,7 +2345,7 @@ where
|
||||
/// * `keychain_mask` - Wallet secret mask to XOR against the stored wallet seed before using, if
|
||||
/// * `sender_index` - If Some(n), the index along the derivation path to include as the sender
|
||||
/// * `recipients` - Optional recipients for which to encrypt the slatepack's payload (i.e. the
|
||||
/// slate). If an empty vec, the payload will remain unencrypted
|
||||
/// slate). The sender is also able to decrypt it. If empty, the payload remains unencrypted
|
||||
///
|
||||
/// # Returns
|
||||
/// * Ok with a String representing an armored slatepack if successful
|
||||
|
||||
@@ -721,7 +721,6 @@ where
|
||||
Some(a) => vec![a],
|
||||
None => vec![],
|
||||
};
|
||||
// TODO: what is sender_index?
|
||||
message = api.create_slatepack_message(m, &slate, Some(0), recipients)?;
|
||||
// Trim the \n at the end.
|
||||
let len_withoutcrlf = message.trim_end().len();
|
||||
|
||||
@@ -594,10 +594,17 @@ fn slatepack_api_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
|
||||
..Default::default()
|
||||
};
|
||||
let slate = api.init_send_tx(m, args)?;
|
||||
// create an encrypted slatepack (just encrypted for self)
|
||||
let enc_addr = api.get_slatepack_address(m, 0)?;
|
||||
let slatepack = api.create_slatepack_message(m, &slate, Some(0), vec![enc_addr])?;
|
||||
let recipient_key = edDalekSecretKey::from_bytes(&[1u8; 32]);
|
||||
let recipient = SlatepackAddress::new(&edDalekPublicKey::from(&recipient_key));
|
||||
let slatepack = api.create_slatepack_message(m, &slate, Some(0), vec![recipient])?;
|
||||
println!("{}", slatepack);
|
||||
let recipient_packer = Slatepacker::new(SlatepackerArgs {
|
||||
sender: None,
|
||||
recipients: vec![],
|
||||
dec_key: Some(&recipient_key),
|
||||
});
|
||||
let recipient_copy = recipient_packer.deser_slatepack(slatepack.as_bytes(), true)?;
|
||||
recipient_packer.get_slate(&recipient_copy)?;
|
||||
let slatepack_raw = api.decode_slatepack_message(m, slatepack.clone(), vec![0])?;
|
||||
println!("{}", slatepack_raw);
|
||||
let decoded_slate = api.slate_from_slatepack_message(m, slatepack, vec![0])?;
|
||||
|
||||
@@ -148,7 +148,7 @@ pub fn create_slatepack_message<'a, L, C, K>(
|
||||
keychain_mask: Option<&SecretKey>,
|
||||
slate: &Slate,
|
||||
sender_index: Option<u32>,
|
||||
recipients: Vec<SlatepackAddress>,
|
||||
mut recipients: Vec<SlatepackAddress>,
|
||||
) -> Result<String, Error>
|
||||
where
|
||||
L: WalletLCProvider<'a, C, K>,
|
||||
@@ -159,6 +159,13 @@ where
|
||||
Some(i) => Some(get_slatepack_address(wallet_inst, keychain_mask, i)?),
|
||||
None => None,
|
||||
};
|
||||
if !recipients.is_empty() {
|
||||
if let Some(sender) = &sender {
|
||||
if !recipients.contains(sender) {
|
||||
recipients.push(sender.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
let packer = Slatepacker::new(SlatepackerArgs {
|
||||
sender,
|
||||
recipients,
|
||||
|
||||
@@ -44,8 +44,6 @@ Separating side effects until the 'save_step' part would make these functions mu
|
||||
- Expose the kernel feature constants from `grin_core` and reuse them here.
|
||||
- Move payment-proof creation and verification onto `Slate` so it can also be used
|
||||
outside contracts and is versioned with the slate format.
|
||||
- Choose the sender derivation path explicitly and keep encrypted outgoing files
|
||||
identifiable locally.
|
||||
- Add contract history, lookup and transport.
|
||||
- Decide whether the foreign JSON-RPC API should expose `new` and `sign`.
|
||||
- Add full API and RPC examples once the contract interface is stable.
|
||||
|
||||
Reference in New Issue
Block a user