diff --git a/api/src/owner_rpc.rs b/api/src/owner_rpc.rs index 7caf46c61..e159beceb 100644 --- a/api/src/owner_rpc.rs +++ b/api/src/owner_rpc.rs @@ -378,7 +378,7 @@ pub trait OwnerRpc { "num_change_outputs": 1, "selection_strategy_is_use_all": true, "target_slate_version": null, - "payment_proof_recipient_address": "slatepack10qlk22rxjap2ny8qltc2tl996kenxr3hhwuu6hrzs6tdq08yaqgqnlumr7", + "payment_proof_recipient_address": "tgrin1xtxavwfgs48ckf3gk8wwgcndmn0nt4tvkl8a7ltyejjcy2mc6nfs9gm2lp", "ttl_blocks": null, "send_args": null } @@ -398,7 +398,7 @@ pub trait OwnerRpc { "id": "0436430c-2b02-624c-2032-570501212b00", "off": "0gKWSQAAAADTApZJAAAAANQClkkAAAAA1QKWSQAAAAA=", "proof": { - "raddr": "eD9lKGaXQqmQ4Prwpfyl1bMzDje7uc1cYoaW0Dzk6BA=", + "raddr": "Ms3WOSiFT4smKLHc5GJt3N811Wy3z999ZMylgit41NM=", "saddr": "Ms3WOSiFT4smKLHc5GJt3N811Wy3z999ZMylgit41NM=" }, "sigs": [ @@ -1409,7 +1409,7 @@ pub trait OwnerRpc { "id": 1, "jsonrpc": "2.0", "result": { - "Ok": "slatepack1xtxavwfgs48ckf3gk8wwgcndmn0nt4tvkl8a7ltyejjcy2mc6nfskdvkdu" + "Ok": "tgrin1xtxavwfgs48ckf3gk8wwgcndmn0nt4tvkl8a7ltyejjcy2mc6nfs9gm2lp" } } # "# @@ -1498,7 +1498,7 @@ pub trait OwnerRpc { "id": 1, "jsonrpc": "2.0", "result": { - "Ok": "BEGINSLATEPACK. 8GQrdcwdLKJD28F 3a9siP7ZhZgAh7w BR2EiZHza5WMWmZ Cc8zBUemrrYRjhq j3VBwA8vYnvXXKU BDmQBN2yKgmR8mX UzvXHezfznA61d7 qFZYChhz94vd8Ew NEPLz7jmcVN2C3w wrfHbeiLubYozP2 uhLouFiYRrbe3fQ 4uhWGfT3sQYXScT dAeo29EaZJpfauh j8VL5jsxST2SPHq nzXFC2w9yYVjt7D ju7GSgHEp5aHz9R xstGbHjbsb4JQod kYLuELta1ohUwDD pvjhyJmsbLcsPei k5AQhZsJ8RJGBtY bou6cU7tZeFJvor 4LB9CBfFB3pmVWD vSLd5RPS75dcnHP nbXD8mSDZ8hJS2Q A9wgvppWzuWztJ2 dLUU8f9tLJgsRBw YZAs71HiVeg7. ENDSLATEPACK.\n" + "Ok": "BEGINSLATEPACK. t9EcGgrKr1GFCQB SK2jPCxME6Hgpqx bntpQm3zKFycoPY nW4UeoL4KQ7ExNK At6EQsvpz6MjUs8 6WG8KHEbMfqufJQ ZJTw2gkcdJmJjiJ f29oGgYqqXDZox4 ujPSjrtoxCN4h3e i1sZ8dYsm3dPeXL 7VQLsYNjAefciqj ZJXPm4Pqd7VDdd4 okGBGBu3YJvYzT6 arAxeCEx66us31h AJLcDweFwyWBkW5 J1DLiYAjt5ftFTo CjpfW9KjiLq2LM5 jepXWEHJPSDAYVK 4macDZUhRbJiG6E hrQcPrJBVC716mb Hw5E1PFrE6on5wq oEmrS4j9vaB5nw8 Z9ZyXvPc2LN7tER yt6pSHZeY9EpYdY zv4bthzfRfF8ePT TMeMpV2gpgyRXQa CPD2TR. ENDSLATEPACK.\n" } } # "# @@ -1577,7 +1577,7 @@ pub trait OwnerRpc { "jsonrpc": "2.0", "method": "decode_slatepack_message", "params": { - "message": "BEGINSLATEPACK. 8GQrdcwdLKJD28F 3a9siP7ZhZgAh7w\nBR2EiZHza5WMWmZ Cc8zBUemrrYRjhq j3VBwA8vYnvXXKU\nBDmQBN2yKgmR8mX UzvXHezfznA61d7 qFZYChhz94vd8Ew\nNEPLz7jmcVN2C3w wrfHbeiLubYozP2 uhLouFiYRrbe3fQ\n4uhWGfT3sQYXScT dAeo29EaZJpfauh j8VL5jsxST2SPHq\nnzXFC2w9yYVjt7D ju7GSgHEp5aHz9R xstGbHjbsb4JQod\nkYLuELta1ohUwDD pvjhyJmsbLcsPei k5AQhZsJ8RJGBtY\nbou6cU7tZeFJvor 4LB9CBfFB3pmVWD vSLd5RPS75dcnHP\nnbXD8mSDZ8hJS2Q A9wgvppWzuWztJ2 dLUU8f9tLJgsRBw\nYZAs71HiVeg7. ENDSLATEPACK.\n", + "message": "BEGINSLATEPACK. t9EcGgrKr1GFCQB SK2jPCxME6Hgpqx bntpQm3zKFycoPY nW4UeoL4KQ7ExNK At6EQsvpz6MjUs8 6WG8KHEbMfqufJQ ZJTw2gkcdJmJjiJ f29oGgYqqXDZox4 ujPSjrtoxCN4h3e i1sZ8dYsm3dPeXL 7VQLsYNjAefciqj ZJXPm4Pqd7VDdd4 okGBGBu3YJvYzT6 arAxeCEx66us31h AJLcDweFwyWBkW5 J1DLiYAjt5ftFTo CjpfW9KjiLq2LM5 jepXWEHJPSDAYVK 4macDZUhRbJiG6E hrQcPrJBVC716mb Hw5E1PFrE6on5wq oEmrS4j9vaB5nw8 Z9ZyXvPc2LN7tER yt6pSHZeY9EpYdY zv4bthzfRfF8ePT TMeMpV2gpgyRXQa CPD2TR. ENDSLATEPACK.\n", "decrypt" : false }, "id": 1 @@ -1592,7 +1592,7 @@ pub trait OwnerRpc { "Ok": { "mode": 0, "payload": "AAQAAgQ2QwwrAmJMIDJXBQEhKwAB0gKWSQAAAADTApZJAAAAANQClkkAAAAA1QKWSQAAAAAGAAAAAWWgvAAAAAAAAHoSAAEAAjh4zoRXJ/Ok7HbKPz20s4otBdY2uMNjIQi4V/7WPJbeAxuExVZ7EmRAmV0+1aq6BWXXHhg0YEgZ/5wX9enV3QePAjLN1jkohU+LJiix3ORibdzfNdVst8/ffWTMpYIreNTTeD9lKGaXQqmQ4Prwpfyl1bMzDje7uc1cYoaW0Dzk6BAA", - "sender": "slatepack1xtxavwfgs48ckf3gk8wwgcndmn0nt4tvkl8a7ltyejjcy2mc6nfskdvkdu", + "sender": "tgrin1xtxavwfgs48ckf3gk8wwgcndmn0nt4tvkl8a7ltyejjcy2mc6nfs9gm2lp", "slatepack": "1.0" } } @@ -1634,9 +1634,9 @@ pub trait OwnerRpc { "Ok": { "amount": "60000000000", "excess": "091f151170bfac881479bfb56c7012c52cd4ce4198ad661586374dd499925922fb", - "recipient_address": "slatepack10qlk22rxjap2ny8qltc2tl996kenxr3hhwuu6hrzs6tdq08yaqgqnlumr7", + "recipient_address": "tgrin10qlk22rxjap2ny8qltc2tl996kenxr3hhwuu6hrzs6tdq08yaqgqq6t83r", "recipient_sig": "b9b1885a3f33297df32e1aa4db23220bd305da8ed92ff6873faf3ab2c116fea25e9d0e34bd4f567f022b88a37400821ffbcaec71c9a8c3a327c4626611886d0d", - "sender_address": "slatepack1xtxavwfgs48ckf3gk8wwgcndmn0nt4tvkl8a7ltyejjcy2mc6nfskdvkdu", + "sender_address": "tgrin1xtxavwfgs48ckf3gk8wwgcndmn0nt4tvkl8a7ltyejjcy2mc6nfs9gm2lp", "sender_sig": "611b92331e395c3d29871ac35b1fce78ec595e28ccbe8cc55452da40775e8e46d35a2e84eaffd986935da3275e34d46a8d777d02dabcf4339704c2a621da9700" } } diff --git a/libwallet/src/slatepack/address.rs b/libwallet/src/slatepack/address.rs index 1ba63a0db..316039432 100644 --- a/libwallet/src/slatepack/address.rs +++ b/libwallet/src/slatepack/address.rs @@ -20,6 +20,7 @@ use rand::{thread_rng, Rng}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use x25519_dalek::PublicKey as xDalekPublicKey; +use crate::grin_core::global; use crate::grin_core::ser::{self, Readable, Reader, Writeable, Writer}; use crate::grin_util::secp::key::SecretKey; use crate::util::OnionV3Address; @@ -43,8 +44,12 @@ pub struct SlatepackAddress { impl SlatepackAddress { /// new with default hrp pub fn new(pub_key: &edDalekPublicKey) -> Self { + let hrp = match global::get_chain_type() { + global::ChainTypes::Mainnet => "grin", + _ => "tgrin", + }; Self { - hrp: String::from("slatepack"), + hrp: String::from(hrp), pub_key: pub_key.clone(), } } @@ -236,6 +241,7 @@ impl Readable for SlatepackAddress { #[test] fn slatepack_address() -> Result<(), Error> { use rand::{thread_rng, Rng}; + global::set_local_chain_type(global::ChainTypes::AutomatedTesting); let sec_key_bytes: [u8; 32] = thread_rng().gen(); let ed_sec_key = edDalekSecretKey::from_bytes(&sec_key_bytes).unwrap(); diff --git a/libwallet/src/slatepack/types.rs b/libwallet/src/slatepack/types.rs index 6ae7252e8..1f50e581a 100644 --- a/libwallet/src/slatepack/types.rs +++ b/libwallet/src/slatepack/types.rs @@ -640,7 +640,9 @@ fn slatepack_bin_basic_ser() -> Result<(), grin_wallet_util::byte_ser::Error> { #[test] fn slatepack_bin_opt_fields_ser() -> Result<(), grin_wallet_util::byte_ser::Error> { + use crate::grin_core::global; use grin_wallet_util::byte_ser; + global::set_local_chain_type(global::ChainTypes::AutomatedTesting); let mut payload: Vec = Vec::with_capacity(243); for _ in 0..payload.capacity() { payload.push(rand::random()); @@ -663,11 +665,12 @@ fn slatepack_bin_opt_fields_ser() -> Result<(), grin_wallet_util::byte_ser::Erro // ensure that a slatepack with unknown data in the optional fields can be read #[test] fn slatepack_bin_future() -> Result<(), grin_wallet_util::byte_ser::Error> { + use crate::grin_core::global; use byteorder::{BigEndian, ReadBytesExt, WriteBytesExt}; use grin_wallet_util::byte_ser; use rand::{thread_rng, Rng}; use std::io::Cursor; - + global::set_local_chain_type(global::ChainTypes::AutomatedTesting); let payload_size = 1234; let mut payload: Vec = Vec::with_capacity(payload_size); for _ in 0..payload.capacity() { @@ -696,14 +699,14 @@ fn slatepack_bin_future() -> Result<(), grin_wallet_util::byte_ser::Error> { // opt fields len (bytes to payload) 4 // bytes 5-8 are opt fields len - // sender 68 + // sender 64 let mut opt_fields_len_bytes = [0u8; 4]; opt_fields_len_bytes.copy_from_slice(&ser[5..9]); let mut rdr = Cursor::new(opt_fields_len_bytes.to_vec()); let opt_fields_len = rdr.read_u32::().unwrap(); // check this matches what we expect below - assert_eq!(opt_fields_len, 69); + assert_eq!(opt_fields_len, 65); let end_head_pos = opt_fields_len as usize + 8 + 1; @@ -740,11 +743,14 @@ fn slatepack_bin_future() -> Result<(), grin_wallet_util::byte_ser::Error> { // if mode == 1 #[test] fn slatepack_encrypted_meta() -> Result<(), Error> { + use crate::grin_core::global; use crate::{Slate, SlateVersion, VersionedBinSlate, VersionedSlate}; use ed25519_dalek::PublicKey as edDalekPublicKey; use ed25519_dalek::SecretKey as edDalekSecretKey; use rand::{thread_rng, Rng}; use std::convert::TryFrom; + global::set_local_chain_type(global::ChainTypes::AutomatedTesting); + let sec_key_bytes: [u8; 32] = thread_rng().gen(); let ed_sec_key = edDalekSecretKey::from_bytes(&sec_key_bytes).unwrap(); @@ -786,11 +792,14 @@ fn slatepack_encrypted_meta() -> Result<(), Error> { // metadata won't break parsing #[test] fn slatepack_encrypted_meta_future() -> Result<(), Error> { + use crate::grin_core::global; use crate::{Slate, SlateVersion, VersionedBinSlate, VersionedSlate}; use ed25519_dalek::PublicKey as edDalekPublicKey; use ed25519_dalek::SecretKey as edDalekSecretKey; use rand::{thread_rng, Rng}; use std::convert::TryFrom; + global::set_local_chain_type(global::ChainTypes::AutomatedTesting); + let sec_key_bytes: [u8; 32] = thread_rng().gen(); let ed_sec_key = edDalekSecretKey::from_bytes(&sec_key_bytes).unwrap(); diff --git a/tests/cmd_line_basic.rs b/tests/cmd_line_basic.rs index 3de7b43a6..1b991f2ce 100644 --- a/tests/cmd_line_basic.rs +++ b/tests/cmd_line_basic.rs @@ -302,7 +302,7 @@ fn command_line_test_impl(test_dir: &str) -> Result<(), grin_wallet_controller:: "mining", "send", "-d", - "slatepack1ak8aaxpjg6ct5uje4lgzvjp65l0nrmgxndp5xjy74sumzp7wasyspux2f5", + "tgrin1ak8aaxpjg6ct5uje4lgzvjp65l0nrmgxndp5xjy74sumzp7wasysje3kmf", "10", ]; execute_command(&app, test_dir, "wallet1", &client1, arg_vec)?;