-
Notifications
You must be signed in to change notification settings - Fork 992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Save slate participant messages in database #2441
Changes from all commits
a6792d7
20c424d
a8f5d60
5a9ba25
62d70ec
e2e5c0a
f816670
0f46233
4855045
483cb5d
9980a63
72d0a79
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,8 @@ use crate::libwallet::{Error, ErrorKind}; | |
use crate::util; | ||
use crate::util::secp::{pedersen, ContextFlag, Secp256k1}; | ||
|
||
const USER_MESSAGE_MAX_LEN: usize = 256; | ||
|
||
/// Functions intended for use by the owner (e.g. master seed holder) of the wallet. | ||
pub struct APIOwner<W: ?Sized, C, K> | ||
where | ||
|
@@ -551,7 +553,8 @@ where | |
/// ParticipantData within the slate. This message will include a signature created with the | ||
/// sender's private keys, and will be publically verifiable. Note this message is for | ||
/// the convenience of the participants during the exchange; it is not included in the final | ||
/// transaction sent to the chain. Validation of this message is optional. | ||
/// transaction sent to the chain. The message will be truncated to 256 characters. | ||
/// Validation of this message is optional. | ||
/// | ||
/// # Returns | ||
/// * a result containing: | ||
|
@@ -640,6 +643,14 @@ where | |
None => w.parent_key_id(), | ||
}; | ||
|
||
let message = match message { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nitpick: I'd suggest to introduce SlateMessage type and define semantic (it could be None, if not String has limited length) there, we truncate twice in this pr, could forget to do it introducing some new logic later on |
||
Some(mut m) => { | ||
m.truncate(USER_MESSAGE_MAX_LEN); | ||
Some(m) | ||
} | ||
None => None, | ||
}; | ||
|
||
let (slate, context, lock_fn) = tx::create_send_tx( | ||
&mut *w, | ||
amount, | ||
|
@@ -685,12 +696,12 @@ where | |
let context = w.get_private_context(slate.id.as_bytes())?; | ||
tx::complete_tx(&mut *w, slate, &context)?; | ||
tx::update_stored_tx(&mut *w, slate)?; | ||
tx::update_message(&mut *w, slate)?; | ||
{ | ||
let mut batch = w.batch()?; | ||
batch.delete_private_context(slate.id.as_bytes())?; | ||
batch.commit()?; | ||
} | ||
|
||
w.close()?; | ||
Ok(()) | ||
} | ||
|
@@ -873,6 +884,15 @@ where | |
return Err(ErrorKind::TransactionAlreadyReceived(slate.id.to_string()).into()); | ||
} | ||
} | ||
|
||
let message = match message { | ||
Some(mut m) => { | ||
m.truncate(USER_MESSAGE_MAX_LEN); | ||
Some(m) | ||
} | ||
None => None, | ||
}; | ||
|
||
let res = tx::receive_tx(&mut *w, slate, &parent_key_id, message); | ||
w.close()?; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyone have any major problems with this dev-dependency? Would rather avoid but seems best way to run serialization tests.