mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-10-17 07:11:36 +02:00
Remove V2 Slate, Add V4 (#354)
* add V4 slate * add V4 slate * deprecation warnings as reminders * fix doctests, add warnings and change upstream grin back to master
This commit is contained in:
@@ -26,16 +26,18 @@ pub struct PathToSlate(pub PathBuf);
|
||||
impl SlatePutter for PathToSlate {
|
||||
fn put_tx(&self, slate: &Slate) -> Result<(), Error> {
|
||||
let mut pub_tx = File::create(&self.0)?;
|
||||
let _r: crate::adapters::Reminder;
|
||||
let out_slate = {
|
||||
if slate.payment_proof.is_some() || slate.ttl_cutoff_height.is_some() {
|
||||
warn!("Transaction contains features that require grin-wallet 3.0.0 or later");
|
||||
warn!("Please ensure the other party is running grin-wallet v3.0.0 or later before sending");
|
||||
VersionedSlate::into_version(slate.clone(), SlateVersion::V3)
|
||||
// TODO: This will need to be filled with any incompatibilities in the V4 Slate
|
||||
if false {
|
||||
warn!("Transaction contains features that require grin-wallet 4.0.0 or later");
|
||||
warn!("Please ensure the other party is running grin-wallet v4.0.0 or later before sending");
|
||||
VersionedSlate::into_version(slate.clone(), SlateVersion::V4)
|
||||
} else {
|
||||
let mut s = slate.clone();
|
||||
s.version_info.version = 2;
|
||||
s.version_info.orig_version = 2;
|
||||
VersionedSlate::into_version(s, SlateVersion::V2)
|
||||
s.version_info.version = 3;
|
||||
s.version_info.orig_version = 3;
|
||||
VersionedSlate::into_version(s, SlateVersion::V3)
|
||||
}
|
||||
};
|
||||
pub_tx.write_all(
|
||||
|
||||
+16
-13
@@ -111,12 +111,12 @@ impl HttpSlateSender {
|
||||
return Err(ErrorKind::ClientCallback(report).into());
|
||||
}
|
||||
|
||||
if supported_slate_versions.contains(&"V4".to_owned()) {
|
||||
return Ok(SlateVersion::V4);
|
||||
}
|
||||
if supported_slate_versions.contains(&"V3".to_owned()) {
|
||||
return Ok(SlateVersion::V3);
|
||||
}
|
||||
if supported_slate_versions.contains(&"V2".to_owned()) {
|
||||
return Ok(SlateVersion::V2);
|
||||
}
|
||||
|
||||
let report = "Unable to negotiate slate format with other wallet.".to_string();
|
||||
error!("{}", report);
|
||||
@@ -143,6 +143,10 @@ impl HttpSlateSender {
|
||||
}
|
||||
}
|
||||
|
||||
#[deprecated(
|
||||
since = "3.0.0",
|
||||
note = "Remember to handle SlateV4 incompatibilities here"
|
||||
)]
|
||||
impl SlateSender for HttpSlateSender {
|
||||
fn send_tx(&self, slate: &Slate) -> Result<Slate, Error> {
|
||||
let trailing = match self.base_url.ends_with('/') {
|
||||
@@ -177,18 +181,17 @@ impl SlateSender for HttpSlateSender {
|
||||
}
|
||||
|
||||
let slate_send = match self.check_other_version(&url_str)? {
|
||||
SlateVersion::V3 => VersionedSlate::into_version(slate.clone(), SlateVersion::V3),
|
||||
SlateVersion::V2 => {
|
||||
SlateVersion::V4 => VersionedSlate::into_version(slate.clone(), SlateVersion::V4),
|
||||
SlateVersion::V3 => {
|
||||
let mut slate = slate.clone();
|
||||
if slate.payment_proof.is_some() {
|
||||
return Err(ErrorKind::ClientCallback("Payment proof requested, but other wallet does not support payment proofs. Please urge other user to upgrade, or re-send tx without a payment proof".into()).into());
|
||||
let _r: crate::adapters::Reminder;
|
||||
//TODO: Fill out with Slate V4 incompatibilities
|
||||
if false {
|
||||
return Err(ErrorKind::ClientCallback("feature x requested, but other wallet does not support feature x. Please urge other user to upgrade, or re-send tx without feature x".into()).into());
|
||||
}
|
||||
if slate.ttl_cutoff_height.is_some() {
|
||||
warn!("Slate TTL value will be ignored and removed by other wallet, as other wallet does not support this feature. Please urge other user to upgrade");
|
||||
}
|
||||
slate.version_info.version = 2;
|
||||
slate.version_info.orig_version = 2;
|
||||
VersionedSlate::into_version(slate, SlateVersion::V2)
|
||||
slate.version_info.version = 3;
|
||||
slate.version_info.orig_version = 3;
|
||||
VersionedSlate::into_version(slate, SlateVersion::V3)
|
||||
}
|
||||
};
|
||||
// Note: not using easy-jsonrpc as don't want the dependencies in this crate
|
||||
|
||||
@@ -25,6 +25,13 @@ use crate::libwallet::{Error, ErrorKind, Slate};
|
||||
use crate::tor::config::complete_tor_address;
|
||||
use crate::util::ZeroingString;
|
||||
|
||||
/// Little SlateV4 reminder warning helper
|
||||
#[deprecated(
|
||||
since = "3.0.0",
|
||||
note = "Remember to handle SlateV4 incompatibilities here"
|
||||
)]
|
||||
pub struct Reminder;
|
||||
|
||||
/// Sends transactions to a corresponding SlateReceiver
|
||||
pub trait SlateSender {
|
||||
/// Send a transaction slate to another listening wallet and return result
|
||||
|
||||
@@ -26,7 +26,7 @@ use crate::core::pow;
|
||||
use crate::keychain::Keychain;
|
||||
use crate::libwallet;
|
||||
use crate::libwallet::api_impl::foreign;
|
||||
use crate::libwallet::slate_versions::v3::SlateV3;
|
||||
use crate::libwallet::slate_versions::v4::SlateV4;
|
||||
use crate::libwallet::{NodeClient, NodeVersionInfo, Slate, WalletInst, WalletLCProvider};
|
||||
use crate::util;
|
||||
use crate::util::secp::key::SecretKey;
|
||||
@@ -205,7 +205,7 @@ where
|
||||
Some(w) => w,
|
||||
};
|
||||
|
||||
let slate: SlateV3 = serde_json::from_str(&m.body).context(
|
||||
let slate: SlateV4 = serde_json::from_str(&m.body).context(
|
||||
libwallet::ErrorKind::ClientCallback("Error parsing TxWrapper".to_owned()),
|
||||
)?;
|
||||
|
||||
@@ -238,7 +238,7 @@ where
|
||||
sender_id: m.dest,
|
||||
dest: m.sender_id,
|
||||
method: m.method,
|
||||
body: serde_json::to_string(&SlateV3::from(slate)).unwrap(),
|
||||
body: serde_json::to_string(&SlateV4::from(slate)).unwrap(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -399,7 +399,7 @@ impl LocalWalletClient {
|
||||
sender_id: self.id.clone(),
|
||||
dest: dest.to_owned(),
|
||||
method: "send_tx_slate".to_owned(),
|
||||
body: serde_json::to_string(&SlateV3::from(slate)).unwrap(),
|
||||
body: serde_json::to_string(&SlateV4::from(slate)).unwrap(),
|
||||
};
|
||||
{
|
||||
let p = self.proxy_tx.lock();
|
||||
@@ -410,7 +410,7 @@ impl LocalWalletClient {
|
||||
let r = self.rx.lock();
|
||||
let m = r.recv().unwrap();
|
||||
trace!("Received send_tx_slate response: {:?}", m.clone());
|
||||
let slate: SlateV3 = serde_json::from_str(&m.body).context(
|
||||
let slate: SlateV4 = serde_json::from_str(&m.body).context(
|
||||
libwallet::ErrorKind::ClientCallback("Parsing send_tx_slate response".to_owned()),
|
||||
)?;
|
||||
Ok(Slate::from(slate))
|
||||
|
||||
Reference in New Issue
Block a user