Compare commits
72 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1503ec6629 | |||
| 0f744520ad | |||
| caf52cca20 | |||
| 1c4309c400 | |||
| 13efd79f88 | |||
| 0c273d3571 | |||
| d22389b37a | |||
| f9b060e552 | |||
| 7d13f90e4a | |||
| 6f0f5b5e83 | |||
| 6fbd3184b1 | |||
| d5fee31ec6 | |||
| 2a93e04180 | |||
| b902ec9406 | |||
| e3ba570fb1 | |||
| fac65e5093 | |||
| eebc1f1d26 | |||
| 502ece5ba3 | |||
| 62967db201 | |||
| 4b7f863c71 | |||
| 55a6f17c91 | |||
| 8a32d7f73b | |||
| dfb6a705ea | |||
| 5246138398 | |||
| cc3e6a0822 | |||
| 8e68f58eff | |||
| 0a79a4d9fd | |||
| 48fb95bdc1 | |||
| bb4d3768b2 | |||
| cea3f0f341 | |||
| 35fc88c0ec | |||
| 312413aeb0 | |||
| 6ba060e116 | |||
| 88d5e1f50e | |||
| 644a8d3b4d | |||
| e80d135c15 | |||
| a40026f941 | |||
| fb25a36bf2 | |||
| 6f3f7c8e9a | |||
| c6c35d5639 | |||
| 63433cc58f | |||
| 940c0e03f7 | |||
| 445e498fbf | |||
| 09ad75f0cc | |||
| f8d9f9335e | |||
| cd31dafa97 | |||
| 6aa32701b8 | |||
| f84a622bfa | |||
| f60b7209f8 | |||
| 3b00a41fff | |||
| 119a7fab57 | |||
| 6d0a4a4d7b | |||
| 45404ecc71 | |||
| e5bfc2f6ad | |||
| c5be51053a | |||
| 4bfb5f51bf | |||
| d7a9facee9 | |||
| 260bc3721b | |||
| 3e0457de09 | |||
| ce6f6e0593 | |||
| f1efb700d2 | |||
| dd246296b9 | |||
| 22334d7c6c | |||
| c07698fcc8 | |||
| ce69272638 | |||
| 2b95d100b3 | |||
| b7706d4def | |||
| 845d46d7b3 | |||
| e4f8929f2c | |||
| c03402d525 | |||
| 24f9916287 | |||
| cd22e55296 |
@@ -22,7 +22,7 @@ env:
|
||||
|
||||
jobs:
|
||||
build-cross:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-22.04
|
||||
env:
|
||||
CCACHE_TEMPDIR: /tmp/.ccache-temp
|
||||
strategy:
|
||||
@@ -52,10 +52,10 @@ jobs:
|
||||
packages: "gperf cmake python3-zmq libdbus-1-dev libharfbuzz-dev"
|
||||
- name: "Cross-Mac x86_64"
|
||||
host: "x86_64-apple-darwin"
|
||||
packages: "cmake imagemagick libcap-dev librsvg2-bin libz-dev libbz2-dev libtiff-tools python-dev python3-setuptools-git"
|
||||
packages: "cmake imagemagick libcap-dev librsvg2-bin libz-dev libbz2-dev libtiff-tools python3-dev python3-setuptools-git"
|
||||
- name: "Cross-Mac aarch64"
|
||||
host: "aarch64-apple-darwin"
|
||||
packages: "cmake imagemagick libcap-dev librsvg2-bin libz-dev libbz2-dev libtiff-tools python-dev python3-setuptools-git"
|
||||
packages: "cmake imagemagick libcap-dev librsvg2-bin libz-dev libbz2-dev libtiff-tools python3-dev python3-setuptools-git"
|
||||
- name: "x86_64 Freebsd"
|
||||
host: "x86_64-unknown-freebsd"
|
||||
packages: "clang-8 gperf cmake python3-zmq libdbus-1-dev libharfbuzz-dev"
|
||||
@@ -105,7 +105,7 @@ jobs:
|
||||
${{env.CCACHE_SETTINGS}}
|
||||
make depends target=${{ matrix.toolchain.host }} -j2
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: ${{ matrix.toolchain.host == 'x86_64-w64-mingw32' || matrix.toolchain.host == 'x86_64-apple-darwin' || matrix.toolchain.host == 'aarch64-apple-darwin' || matrix.toolchain.host == 'x86_64-unknown-linux-gnu' }}
|
||||
if: ${{ matrix.toolchain.host == 'x86_64-w64-mingw32' || matrix.toolchain.host == 'x86_64-apple-darwin' || matrix.toolchain.host == 'aarch64-apple-darwin' || matrix.toolchain.host == 'x86_64-unknown-linux-gnu' || matrix.toolchain.host == 'aarch64-linux-gnu' }}
|
||||
with:
|
||||
name: ${{ matrix.toolchain.name }}
|
||||
path: |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Salvium One v1.0.0
|
||||
# Salvium One v1.0.6
|
||||
|
||||
Copyright (c) 2023-2024, Salvium
|
||||
Copyright (c) 2023-2025, Salvium
|
||||
Portions Copyright (c) 2014-2023, The Monero Project
|
||||
Portions Copyright (c) 2012-2013 The Cryptonote developers.
|
||||
|
||||
@@ -47,7 +47,7 @@ As with many development projects, the repository on GitHub is considered to be
|
||||
|
||||
## Supporting the project
|
||||
|
||||
Salvium is a 100% community-sponsored endeavor. If you want to join our efforts, the easiest thing you can do is support the project financially. Go to [https://salvium.io/donate/](https://salvium.io/donate/) for more information.
|
||||
Salvium is a 100% community-sponsored endeavor. If you want to join our efforts, the easiest thing you can do is support the project financially. Go to [https://salvium.io/donate](https://salvium.io/donate) for more information.
|
||||
|
||||
## License
|
||||
|
||||
@@ -172,7 +172,7 @@ invokes cmake commands as needed.
|
||||
|
||||
```bash
|
||||
cd salvium
|
||||
git checkout v1.0.0
|
||||
git checkout v1.0.6
|
||||
make
|
||||
```
|
||||
|
||||
@@ -251,7 +251,7 @@ Tested on a Raspberry Pi Zero with a clean install of minimal Raspbian Stretch (
|
||||
```bash
|
||||
git clone https://github.com/salvium/salvium
|
||||
cd salvium
|
||||
git checkout v1.0.0
|
||||
git checkout v1.0.6
|
||||
```
|
||||
|
||||
* Build:
|
||||
@@ -370,10 +370,10 @@ application.
|
||||
cd salvium
|
||||
```
|
||||
|
||||
* If you would like a specific [version/tag](https://github.com/salvium/salvium/tags), do a git checkout for that version. eg. 'v1.0.0'. If you don't care about the version and just want binaries from master, skip this step:
|
||||
* If you would like a specific [version/tag](https://github.com/salvium/salvium/tags), do a git checkout for that version. eg. 'v1.0.6'. If you don't care about the version and just want binaries from master, skip this step:
|
||||
|
||||
```bash
|
||||
git checkout v1.0.0
|
||||
git checkout v1.0.6
|
||||
```
|
||||
|
||||
* If you are on a 64-bit system, run:
|
||||
|
||||
@@ -214,11 +214,9 @@ plot 'stats.csv' index "DATA" using (timecolumn(1,"%Y-%m-%d")):4 with lines, ''
|
||||
#define MAX_RINGS 0xffffffff
|
||||
|
||||
struct tm prevtm = {0}, currtm;
|
||||
uint64_t prevsz = 0, currsz = 0;
|
||||
uint64_t prevtxs = 0, currtxs = 0;
|
||||
uint64_t currsz = 0;
|
||||
uint64_t currtxs = 0;
|
||||
uint64_t currblks = 0;
|
||||
uint32_t txhr[24] = {0};
|
||||
unsigned int i;
|
||||
|
||||
const std::map<uint8_t, std::pair<uint64_t, std::pair<std::string, std::string>>> audit_hard_forks = get_config(net_type).AUDIT_HARD_FORKS;
|
||||
|
||||
@@ -247,8 +245,6 @@ plot 'stats.csv' index "DATA" using (timecolumn(1,"%Y-%m-%d")):4 with lines, ''
|
||||
}
|
||||
skip:
|
||||
currsz += bd.size();
|
||||
uint64_t coinbase_amount;
|
||||
uint64_t tx_fee_amount = 0;
|
||||
std::set<std::string> used_assets, miner_tx_assets, protocol_tx_assets;
|
||||
std::map<size_t, std::vector<std::string>> used_tx_versions;
|
||||
used_assets.insert("SAL");
|
||||
|
||||
@@ -211,8 +211,15 @@ int main(int argc, char* argv[])
|
||||
throw std::runtime_error("Failed to initialize a database");
|
||||
}
|
||||
|
||||
const std::string filename = (boost::filesystem::path(opt_data_dir) / db->get_db_name()).string();
|
||||
LOG_PRINT_L0("Loading blockchain from folder " << filename << " ...");
|
||||
boost::filesystem::path folder(opt_data_dir);
|
||||
if (opt_stagenet) {
|
||||
folder /= std::to_string(STAGENET_VERSION);
|
||||
} else if (opt_testnet) {
|
||||
folder /= std::to_string(TESTNET_VERSION);
|
||||
}
|
||||
folder /= db->get_db_name();
|
||||
LOG_PRINT_L0("Loading blockchain from folder " << folder << " ...");
|
||||
const std::string filename = folder.string();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
Binary file not shown.
@@ -282,13 +282,62 @@ crypto::key_image carrot_and_legacy_account::derive_key_image(const crypto::publ
|
||||
return L;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
void carrot_and_legacy_account::generate_subaddress_map()
|
||||
crypto::key_image carrot_and_legacy_account::derive_key_image_view_only(const crypto::public_key &address_spend_pubkey,
|
||||
const crypto::secret_key &sender_extension_g,
|
||||
const crypto::secret_key &sender_extension_t,
|
||||
const crypto::public_key &onetime_address) const
|
||||
{
|
||||
const auto it = subaddress_map.find(address_spend_pubkey);
|
||||
CHECK_AND_ASSERT_THROW_MES(it != subaddress_map.cend(),
|
||||
"carrot and legacy account: derive key image view only: cannot find subaddress");
|
||||
|
||||
const bool is_subaddress = it->second.index.is_subaddress();
|
||||
const uint32_t major_index = it->second.index.major;
|
||||
const uint32_t minor_index = it->second.index.minor;
|
||||
|
||||
const cryptonote::account_keys &keys = get_keys();
|
||||
|
||||
crypto::secret_key address_index_generator;
|
||||
crypto::secret_key subaddress_scalar;
|
||||
crypto::secret_key subaddress_extension;
|
||||
crypto::secret_key address_privkey_g;
|
||||
crypto::secret_key x;
|
||||
|
||||
CHECK_AND_ASSERT_THROW_MES(it->second.derive_type == AddressDeriveType::Carrot,
|
||||
"carrot and legacy account: derive key image view only: not a Carrot address");
|
||||
|
||||
// s^j_gen = H_32[s_ga](j_major, j_minor)
|
||||
make_carrot_index_extension_generator(keys.s_generate_address, major_index, minor_index, address_index_generator);
|
||||
|
||||
if (is_subaddress)
|
||||
{
|
||||
// k^j_subscal = H_n(K_s, j_major, j_minor, s^j_gen)
|
||||
make_carrot_subaddress_scalar(keys.m_carrot_account_address.m_spend_public_key, address_index_generator, major_index, minor_index, subaddress_scalar);
|
||||
}
|
||||
else
|
||||
{
|
||||
// k^j_subscal = 1
|
||||
sc_1(to_bytes(subaddress_scalar));
|
||||
}
|
||||
|
||||
// k^g_a = k_gi * k^j_subscal
|
||||
sc_mul(to_bytes(address_privkey_g), to_bytes(keys.k_generate_image), to_bytes(subaddress_scalar));
|
||||
|
||||
// x = k^{j,g}_addr + k^g_o
|
||||
sc_add(to_bytes(x), to_bytes(address_privkey_g), to_bytes(sender_extension_g));
|
||||
|
||||
crypto::key_image L;
|
||||
crypto::generate_key_image(onetime_address, x, L);
|
||||
return L;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
void carrot_and_legacy_account::generate_subaddress_map(const std::pair<size_t, size_t>& lookahead_size)
|
||||
{
|
||||
const std::vector<AddressDeriveType> derive_types{AddressDeriveType::Carrot, AddressDeriveType::PreCarrot};
|
||||
|
||||
for (uint32_t major_index = 0; major_index <= MAX_SUBADDRESS_MAJOR_INDEX; ++major_index)
|
||||
for (uint32_t major_index = 0; major_index <= lookahead_size.first; ++major_index)
|
||||
{
|
||||
for (uint32_t minor_index = 0; minor_index <= MAX_SUBADDRESS_MINOR_INDEX; ++minor_index)
|
||||
for (uint32_t minor_index = 0; minor_index <= lookahead_size.second; ++minor_index)
|
||||
{
|
||||
for (const AddressDeriveType derive_type : derive_types)
|
||||
{
|
||||
@@ -337,7 +386,7 @@ void carrot_and_legacy_account::set_keys(const cryptonote::account_keys& keys, b
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
void carrot_and_legacy_account::create_from_svb_key(const cryptonote::account_public_address& address, const crypto::secret_key& svb_key)
|
||||
{
|
||||
{
|
||||
// top level keys
|
||||
m_keys.s_master = crypto::null_skey;
|
||||
make_carrot_provespend_key(m_keys.s_master, m_keys.k_prove_spend);
|
||||
@@ -359,9 +408,18 @@ void carrot_and_legacy_account::create_from_svb_key(const cryptonote::account_pu
|
||||
k_view_incoming_dev.view_key_scalar_mult_ed25519(crypto::get_G(),
|
||||
m_keys.m_carrot_main_address.m_view_public_key
|
||||
);
|
||||
|
||||
|
||||
// Store fields for Carrot
|
||||
m_keys.m_spend_secret_key = crypto::null_skey;
|
||||
m_keys.m_view_secret_key = crypto::null_skey;
|
||||
m_keys.m_account_address = {crypto::null_pkey, crypto::null_pkey, false};
|
||||
|
||||
// Update ALL addresses to be Carrot-only
|
||||
m_keys.m_carrot_account_address.m_is_carrot = true;
|
||||
m_keys.m_carrot_main_address.m_is_carrot = true;
|
||||
|
||||
// Set the default derive type for addresses
|
||||
this->default_derive_type = AddressDeriveType::Carrot;
|
||||
generate_subaddress_map();
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
void carrot_and_legacy_account::set_carrot_keys(const AddressDeriveType default_derive_type)
|
||||
@@ -393,13 +451,19 @@ void carrot_and_legacy_account::set_carrot_keys(const AddressDeriveType default_
|
||||
m_keys.m_carrot_main_address.m_is_carrot = true;
|
||||
|
||||
this->default_derive_type = default_derive_type;
|
||||
generate_subaddress_map();
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
void carrot_and_legacy_account::insert_subaddresses(const std::unordered_map<crypto::public_key, subaddress_index_extended>& subaddress_map_cn)
|
||||
{
|
||||
for (const auto &p : subaddress_map_cn)
|
||||
subaddress_map.insert({p.first, {{p.second.index.major, p.second.index.minor}, p.second.derive_type, p.second.is_return_spend_key}});
|
||||
for (const auto &p : subaddress_map_cn) {
|
||||
subaddress_map.insert({p.first, {{p.second.index.major, p.second.index.minor}, p.second.derive_type, p.second.is_return_spend_key}});
|
||||
if (p.second.derive_type == AddressDeriveType::PreCarrot) {
|
||||
// Create a matching Carrot address
|
||||
const subaddress_index_extended subaddr_index{{p.second.index.major, p.second.index.minor}, AddressDeriveType::Carrot, p.second.is_return_spend_key};
|
||||
const CarrotDestinationV1 addr = subaddress(subaddr_index);
|
||||
subaddress_map.insert({addr.address_spend_pubkey, subaddr_index});
|
||||
}
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------------------------
|
||||
void carrot_and_legacy_account::insert_return_output_info(const std::unordered_map<crypto::public_key, return_output_info_t>& roi_map)
|
||||
|
||||
+61
-21
@@ -48,12 +48,59 @@ namespace carrot
|
||||
input_context_t input_context;
|
||||
crypto::public_key K_o; // output onetime address
|
||||
crypto::public_key K_change; // change output onetime address
|
||||
crypto::public_key K_spend_pubkey; // change output spend pubkey
|
||||
crypto::key_image key_image;
|
||||
crypto::secret_key sum_g;
|
||||
crypto::secret_key sender_extension_t;
|
||||
|
||||
return_output_info_t() {
|
||||
// Default constructor for serialization
|
||||
input_context = input_context_t();
|
||||
K_o = crypto::public_key();
|
||||
K_change = crypto::public_key();
|
||||
K_spend_pubkey = crypto::public_key();
|
||||
key_image = crypto::key_image();
|
||||
sum_g = crypto::secret_key();
|
||||
sender_extension_t = crypto::secret_key();
|
||||
}
|
||||
|
||||
return_output_info_t(
|
||||
const input_context_t &input_context,
|
||||
const crypto::public_key &K_o,
|
||||
const crypto::public_key &K_change,
|
||||
const crypto::public_key &K_spend_pubkey,
|
||||
const crypto::key_image &key_image,
|
||||
const crypto::secret_key &sum_g,
|
||||
const crypto::secret_key &sender_extension_t):
|
||||
input_context(input_context),
|
||||
K_o(K_o),
|
||||
K_change(K_change),
|
||||
K_spend_pubkey(K_spend_pubkey),
|
||||
key_image(key_image),
|
||||
sum_g(sum_g),
|
||||
sender_extension_t(sender_extension_t) {}
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
FIELD(input_context)
|
||||
FIELD(K_o)
|
||||
FIELD(K_change)
|
||||
FIELD(K_spend_pubkey)
|
||||
FIELD(key_image)
|
||||
FIELD(sum_g)
|
||||
FIELD(sender_extension_t)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
// Old return_output_info_t format (for deserializing version 2 wallet caches)
|
||||
struct return_output_info_retired_t {
|
||||
input_context_t input_context;
|
||||
crypto::public_key K_o;
|
||||
crypto::public_key K_change;
|
||||
crypto::key_image key_image;
|
||||
crypto::secret_key x;
|
||||
crypto::secret_key y;
|
||||
|
||||
return_output_info_t() {
|
||||
// Default constructor for serialization
|
||||
return_output_info_retired_t() {
|
||||
input_context = input_context_t();
|
||||
K_o = crypto::public_key();
|
||||
K_change = crypto::public_key();
|
||||
@@ -62,20 +109,6 @@ namespace carrot
|
||||
y = crypto::secret_key();
|
||||
}
|
||||
|
||||
return_output_info_t(
|
||||
const input_context_t &input_context,
|
||||
const crypto::public_key &K_o,
|
||||
const crypto::public_key &K_change,
|
||||
const crypto::key_image &key_image,
|
||||
const crypto::secret_key &x,
|
||||
const crypto::secret_key &y):
|
||||
input_context(input_context),
|
||||
K_o(K_o),
|
||||
K_change(K_change),
|
||||
key_image(key_image),
|
||||
x(x),
|
||||
y(y) {}
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
FIELD(input_context)
|
||||
FIELD(K_o)
|
||||
@@ -144,7 +177,12 @@ namespace carrot
|
||||
const crypto::secret_key &sender_extension_t,
|
||||
const crypto::public_key &onetime_address) const;
|
||||
|
||||
void generate_subaddress_map();
|
||||
crypto::key_image derive_key_image_view_only(const crypto::public_key &address_spend_pubkey,
|
||||
const crypto::secret_key &sender_extension_g,
|
||||
const crypto::secret_key &sender_extension_t,
|
||||
const crypto::public_key &onetime_address) const;
|
||||
|
||||
void generate_subaddress_map(const std::pair<size_t, size_t>& lookahead_size);
|
||||
|
||||
crypto::secret_key generate(
|
||||
const crypto::secret_key& recovery_key = crypto::secret_key(),
|
||||
@@ -183,9 +221,10 @@ namespace boost
|
||||
x.input_context = carrot::input_context_t();
|
||||
x.K_o = crypto::public_key();
|
||||
x.K_change = crypto::public_key();
|
||||
x.K_spend_pubkey = crypto::public_key();
|
||||
x.key_image = crypto::key_image();
|
||||
x.x = crypto::secret_key();
|
||||
x.y = crypto::secret_key();
|
||||
x.sum_g = crypto::secret_key();
|
||||
x.sender_extension_t = crypto::secret_key();
|
||||
}
|
||||
|
||||
template <class Archive>
|
||||
@@ -194,9 +233,10 @@ namespace boost
|
||||
a & x.input_context;
|
||||
a & x.K_o;
|
||||
a & x.K_change;
|
||||
a & x.K_spend_pubkey;
|
||||
a & x.key_image;
|
||||
a & x.x;
|
||||
a & x.y;
|
||||
a & x.sum_g;
|
||||
a & x.sender_extension_t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,9 +41,9 @@
|
||||
|
||||
namespace carrot
|
||||
{
|
||||
#define CARROT_DEFINE_SIMPLE_ERROR_TYPE(e, b) class e: b { using b::b; };
|
||||
#define CARROT_DEFINE_SIMPLE_ERROR_TYPE(e, b) class e: public b { using b::b; };
|
||||
|
||||
class carrot_logic_error: std::logic_error { using std::logic_error::logic_error; };
|
||||
class carrot_logic_error: public std::logic_error { using std::logic_error::logic_error; };
|
||||
|
||||
CARROT_DEFINE_SIMPLE_ERROR_TYPE(bad_address_type, carrot_logic_error)
|
||||
CARROT_DEFINE_SIMPLE_ERROR_TYPE(component_out_of_order, carrot_logic_error)
|
||||
@@ -55,7 +55,7 @@ CARROT_DEFINE_SIMPLE_ERROR_TYPE(too_few_outputs, carrot_logic_error)
|
||||
CARROT_DEFINE_SIMPLE_ERROR_TYPE(too_many_outputs, carrot_logic_error)
|
||||
CARROT_DEFINE_SIMPLE_ERROR_TYPE(invalid_tx_type, carrot_logic_error)
|
||||
|
||||
class carrot_runtime_error: std::runtime_error { using std::runtime_error::runtime_error; };
|
||||
class carrot_runtime_error: public std::runtime_error { using std::runtime_error::runtime_error; };
|
||||
|
||||
CARROT_DEFINE_SIMPLE_ERROR_TYPE(crypto_function_failed, carrot_runtime_error)
|
||||
CARROT_DEFINE_SIMPLE_ERROR_TYPE(not_enough_money, carrot_runtime_error)
|
||||
|
||||
@@ -77,7 +77,7 @@ std::optional<AdditionalOutputType> get_additional_output_type(const size_t num_
|
||||
}
|
||||
else if (!need_change_output)
|
||||
{
|
||||
return AdditionalOutputType::DUMMY;
|
||||
return AdditionalOutputType::CHANGE_UNIQUE;
|
||||
}
|
||||
else // num_selfsend == 1 && need_change_output
|
||||
{
|
||||
|
||||
@@ -219,6 +219,7 @@ bool operator==(const CarrotPaymentProposalV1 &a, const CarrotPaymentProposalV1
|
||||
{
|
||||
return a.destination == b.destination &&
|
||||
a.amount == b.amount &&
|
||||
a.asset_type == b.asset_type &&
|
||||
a.randomness == b.randomness;
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
@@ -228,6 +229,7 @@ bool operator==(const CarrotPaymentProposalSelfSendV1 &a, const CarrotPaymentPro
|
||||
a.amount == b.amount &&
|
||||
a.enote_type == b.enote_type &&
|
||||
a.internal_message == b.internal_message &&
|
||||
a.asset_type == b.asset_type &&
|
||||
0 == memcmp(&a.enote_ephemeral_pubkey, &b.enote_ephemeral_pubkey, sizeof(mx25519_pubkey));
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -82,6 +82,8 @@ struct CarrotPaymentProposalSelfSendV1 final
|
||||
std::optional<mx25519_pubkey> enote_ephemeral_pubkey;
|
||||
/// anchor: arbitrary, pre-encrypted message for _internal_ selfsends
|
||||
std::optional<janus_anchor_t> internal_message;
|
||||
/// asset type
|
||||
std::string asset_type;
|
||||
};
|
||||
|
||||
struct RCTOutputEnoteProposal
|
||||
|
||||
+19
-18
@@ -387,6 +387,11 @@ bool try_scan_carrot_enote_external_sender(const CarrotEnoteV1 &enote,
|
||||
CarrotEnoteType &enote_type_out,
|
||||
const bool check_pid)
|
||||
{
|
||||
epee::span<const crypto::public_key> main_address_spend_pubkeys;
|
||||
if (destination.is_subaddress)
|
||||
main_address_spend_pubkeys = {};
|
||||
else
|
||||
main_address_spend_pubkeys = {&destination.address_spend_pubkey, 1};
|
||||
crypto::public_key recovered_address_spend_pubkey;
|
||||
payment_id_t recovered_payment_id;
|
||||
CarrotEnoteType recovered_enote_type;
|
||||
@@ -395,7 +400,7 @@ bool try_scan_carrot_enote_external_sender(const CarrotEnoteV1 &enote,
|
||||
if (!try_scan_carrot_enote_external_normal_checked(enote,
|
||||
encrypted_payment_id,
|
||||
s_sender_receiver_unctx,
|
||||
{&destination.address_spend_pubkey, 1},
|
||||
main_address_spend_pubkeys,
|
||||
sender_extension_g_out,
|
||||
sender_extension_t_out,
|
||||
recovered_address_spend_pubkey,
|
||||
@@ -470,6 +475,9 @@ bool try_scan_carrot_enote_internal_receiver(const CarrotEnoteV1 &enote,
|
||||
crypto::public_key &return_address_out,
|
||||
bool &is_return_out)
|
||||
{
|
||||
// Determine whether this is a full wallet or a watch-only wallet
|
||||
const cryptonote::account_keys &keys = account.get_keys();
|
||||
|
||||
// input_context
|
||||
const input_context_t input_context = make_carrot_input_context(enote.tx_first_key_image);
|
||||
|
||||
@@ -518,24 +526,17 @@ bool try_scan_carrot_enote_internal_receiver(const CarrotEnoteV1 &enote,
|
||||
// calculate the key image for the return output
|
||||
crypto::secret_key sum_g;
|
||||
sc_add(to_bytes(sum_g), to_bytes(sender_extension_g_out), to_bytes(k_return));
|
||||
crypto::key_image key_image = account.derive_key_image(
|
||||
account.get_keys().m_carrot_account_address.m_spend_public_key,
|
||||
sum_g,
|
||||
sender_extension_t_out,
|
||||
K_r
|
||||
);
|
||||
crypto::key_image key_image = account.derive_key_image_view_only(address_spend_pubkey_out,
|
||||
sum_g,
|
||||
sender_extension_t_out,
|
||||
K_r
|
||||
);
|
||||
|
||||
crypto::secret_key x, y;
|
||||
account.try_searching_for_opening_for_onetime_address(
|
||||
account.get_keys().m_carrot_account_address.m_spend_public_key,
|
||||
sum_g,
|
||||
sender_extension_t_out,
|
||||
x,
|
||||
y
|
||||
);
|
||||
|
||||
// save the input context & change output key
|
||||
account.insert_return_output_info({{K_r, {input_context, output_key, enote.onetime_address, key_image, x, y}}});
|
||||
// HERE BE DRAGONS!!!
|
||||
// SRCG: test whether this will even work for return_payment detection
|
||||
account.insert_return_output_info({{K_r, {input_context, output_key, enote.onetime_address, address_spend_pubkey_out, key_image, sum_g, sender_extension_t_out}}});
|
||||
//account.insert_return_output_info({{K_r, {input_context, output_key, address_spend_pubkey_out, key_image, sum_g, sender_extension_t_out}}});
|
||||
// LAND AHOY!!!
|
||||
}
|
||||
|
||||
// janus protection checks are not needed for internal scans
|
||||
|
||||
@@ -275,7 +275,8 @@ void make_carrot_transaction_proposal_v1_transfer(
|
||||
.proposal = CarrotPaymentProposalSelfSendV1{
|
||||
.destination_address_spend_pubkey = change_address_spend_pubkey,
|
||||
.amount = 0,
|
||||
.enote_type = add_payment_type_selfsend ? CarrotEnoteType::PAYMENT : CarrotEnoteType::CHANGE
|
||||
.enote_type = add_payment_type_selfsend ? CarrotEnoteType::PAYMENT : CarrotEnoteType::CHANGE,
|
||||
.asset_type = "SAL1"
|
||||
},
|
||||
.subaddr_index = change_address_index
|
||||
});
|
||||
|
||||
@@ -89,12 +89,24 @@ DISABLE_VS_WARNINGS(4244 4345)
|
||||
void account_keys::xor_with_key_stream(const crypto::chacha_key &key)
|
||||
{
|
||||
// encrypt a large enough byte stream with chacha20
|
||||
epee::wipeable_string key_stream = get_key_stream(key, m_encryption_iv, sizeof(crypto::secret_key) * (2 + m_multisig_keys.size()));
|
||||
epee::wipeable_string key_stream = get_key_stream(key, m_encryption_iv, sizeof(crypto::secret_key) * (8 + m_multisig_keys.size()));
|
||||
const char *ptr = key_stream.data();
|
||||
for (size_t i = 0; i < sizeof(crypto::secret_key); ++i)
|
||||
m_spend_secret_key.data[i] ^= *ptr++;
|
||||
for (size_t i = 0; i < sizeof(crypto::secret_key); ++i)
|
||||
m_view_secret_key.data[i] ^= *ptr++;
|
||||
for (size_t i = 0; i < sizeof(crypto::secret_key); ++i)
|
||||
s_master.data[i] ^= *ptr++;
|
||||
for (size_t i = 0; i < sizeof(crypto::secret_key); ++i)
|
||||
k_prove_spend.data[i] ^= *ptr++;
|
||||
for (size_t i = 0; i < sizeof(crypto::secret_key); ++i)
|
||||
s_view_balance.data[i] ^= *ptr++;
|
||||
for (size_t i = 0; i < sizeof(crypto::secret_key); ++i)
|
||||
k_view_incoming.data[i] ^= *ptr++;
|
||||
for (size_t i = 0; i < sizeof(crypto::secret_key); ++i)
|
||||
k_generate_image.data[i] ^= *ptr++;
|
||||
for (size_t i = 0; i < sizeof(crypto::secret_key); ++i)
|
||||
s_generate_address.data[i] ^= *ptr++;
|
||||
for (crypto::secret_key &k: m_multisig_keys)
|
||||
{
|
||||
for (size_t i = 0; i < sizeof(crypto::secret_key); ++i)
|
||||
@@ -116,11 +128,20 @@ DISABLE_VS_WARNINGS(4244 4345)
|
||||
void account_keys::encrypt_viewkey(const crypto::chacha_key &key)
|
||||
{
|
||||
// encrypt a large enough byte stream with chacha20
|
||||
epee::wipeable_string key_stream = get_key_stream(key, m_encryption_iv, sizeof(crypto::secret_key) * 2);
|
||||
epee::wipeable_string key_stream = get_key_stream(key, m_encryption_iv, sizeof(crypto::secret_key) * 8);
|
||||
const char *ptr = key_stream.data();
|
||||
ptr += sizeof(crypto::secret_key);
|
||||
ptr += sizeof(crypto::secret_key); // Skip m_spend_secret_key
|
||||
for (size_t i = 0; i < sizeof(crypto::secret_key); ++i)
|
||||
m_view_secret_key.data[i] ^= *ptr++;
|
||||
ptr += (2 * sizeof(crypto::secret_key)); // Skip s_master, k_prove_spend
|
||||
for (size_t i = 0; i < sizeof(crypto::secret_key); ++i)
|
||||
s_view_balance.data[i] ^= *ptr++;
|
||||
for (size_t i = 0; i < sizeof(crypto::secret_key); ++i)
|
||||
k_view_incoming.data[i] ^= *ptr++;
|
||||
for (size_t i = 0; i < sizeof(crypto::secret_key); ++i)
|
||||
k_generate_image.data[i] ^= *ptr++;
|
||||
for (size_t i = 0; i < sizeof(crypto::secret_key); ++i)
|
||||
s_generate_address.data[i] ^= *ptr++;
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
void account_keys::decrypt_viewkey(const crypto::chacha_key &key)
|
||||
@@ -283,9 +304,9 @@ DISABLE_VS_WARNINGS(4244 4345)
|
||||
std::string account_base::get_carrot_public_address_str(network_type nettype) const
|
||||
{
|
||||
// Build the cryptonote::account_public_address
|
||||
account_public_address addr{m_keys.m_carrot_main_address.m_spend_public_key, m_keys.m_carrot_main_address.m_view_public_key};
|
||||
account_public_address addr{m_keys.m_carrot_main_address.m_spend_public_key, m_keys.m_carrot_main_address.m_view_public_key, true};
|
||||
// change this code into base 58
|
||||
return get_account_address_as_str(nettype, false, addr, true);
|
||||
return get_account_address_as_str(nettype, false, addr);
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
std::string account_base::get_public_integrated_address_str(const crypto::hash8 &payment_id, network_type nettype) const
|
||||
|
||||
@@ -75,6 +75,11 @@ namespace cryptonote
|
||||
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(m_multisig_keys)
|
||||
const crypto::chacha_iv default_iv{{0, 0, 0, 0, 0, 0, 0, 0}};
|
||||
KV_SERIALIZE_VAL_POD_AS_BLOB_OPT(m_encryption_iv, default_iv)
|
||||
if (m_account_address.m_spend_public_key == crypto::null_pkey) {
|
||||
KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE(s_view_balance)
|
||||
KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE(k_view_incoming)
|
||||
KV_SERIALIZE(m_carrot_account_address)
|
||||
}
|
||||
END_KV_SERIALIZE_MAP()
|
||||
|
||||
void encrypt(const crypto::chacha_key &key);
|
||||
|
||||
@@ -155,10 +155,9 @@ namespace cryptonote {
|
||||
network_type nettype
|
||||
, bool subaddress
|
||||
, account_public_address const & adr
|
||||
, bool is_carrot
|
||||
)
|
||||
{
|
||||
uint64_t address_prefix = is_carrot
|
||||
uint64_t address_prefix = adr.m_is_carrot
|
||||
? (subaddress ? get_config(nettype).CARROT_PUBLIC_SUBADDRESS_BASE58_PREFIX : get_config(nettype).CARROT_PUBLIC_ADDRESS_BASE58_PREFIX)
|
||||
: (subaddress ? get_config(nettype).CRYPTONOTE_PUBLIC_SUBADDRESS_BASE58_PREFIX : get_config(nettype).CRYPTONOTE_PUBLIC_ADDRESS_BASE58_PREFIX);
|
||||
|
||||
@@ -169,10 +168,9 @@ namespace cryptonote {
|
||||
network_type nettype
|
||||
, account_public_address const & adr
|
||||
, crypto::hash8 const & payment_id
|
||||
, bool is_carrot
|
||||
)
|
||||
{
|
||||
uint64_t integrated_address_prefix = is_carrot ? get_config(nettype).CARROT_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX : get_config(nettype).CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX;
|
||||
uint64_t integrated_address_prefix = adr.m_is_carrot ? get_config(nettype).CARROT_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX : get_config(nettype).CRYPTONOTE_PUBLIC_INTEGRATED_ADDRESS_BASE58_PREFIX;
|
||||
|
||||
integrated_address iadr = {
|
||||
adr, payment_id
|
||||
|
||||
@@ -88,14 +88,12 @@ namespace cryptonote {
|
||||
network_type nettype
|
||||
, bool subaddress
|
||||
, const account_public_address& adr
|
||||
, bool is_carrot = false
|
||||
);
|
||||
|
||||
std::string get_account_integrated_address_as_str(
|
||||
network_type nettype
|
||||
, const account_public_address& adr
|
||||
, const crypto::hash8& payment_id
|
||||
, bool is_carrot = false
|
||||
);
|
||||
|
||||
bool get_account_address_from_str(
|
||||
|
||||
@@ -6514,7 +6514,7 @@ void Blockchain::cancel()
|
||||
}
|
||||
|
||||
#if defined(PER_BLOCK_CHECKPOINT)
|
||||
static const char expected_block_hashes_hash[] = "a2a5a9bc5d606392ac5c14be55b90a92b8577b8ffdac5c63cc6174f41764c753";
|
||||
static const char expected_block_hashes_hash[] = "1cf6e8892e0512c246cef62610ccf524f30f484e307ae01959a5a7dd166aa328";
|
||||
void Blockchain::load_compiled_in_block_hashes(const GetCheckpointsCallback& get_checkpoints)
|
||||
{
|
||||
if (get_checkpoints == nullptr || !m_fast_sync)
|
||||
|
||||
@@ -1749,6 +1749,16 @@ namespace cryptonote
|
||||
LOG_PRINT_L2(" key images already seen");
|
||||
continue;
|
||||
}
|
||||
if (version < HF_VERSION_CARROT && tx.version >= TRANSACTION_VERSION_CARROT)
|
||||
{
|
||||
LOG_PRINT_L2(" is a Carrot transaction - cannot be mined");
|
||||
continue;
|
||||
}
|
||||
if (version >= HF_VERSION_CARROT && tx.version < TRANSACTION_VERSION_CARROT)
|
||||
{
|
||||
LOG_PRINT_L2(" is not a Carrot transaction - cannot be mined");
|
||||
continue;
|
||||
}
|
||||
|
||||
bl.tx_hashes.push_back(sorted_it->second);
|
||||
total_weight += meta.weight;
|
||||
|
||||
@@ -1355,7 +1355,7 @@ bool t_rpc_command_executor::print_transaction_pool_stats() {
|
||||
bool t_rpc_command_executor::start_mining(cryptonote::account_public_address address, uint64_t num_threads, cryptonote::network_type nettype, bool do_background_mining, bool ignore_battery, bool is_carrot) {
|
||||
cryptonote::COMMAND_RPC_START_MINING::request req;
|
||||
cryptonote::COMMAND_RPC_START_MINING::response res;
|
||||
req.miner_address = cryptonote::get_account_address_as_str(nettype, false, address, is_carrot);
|
||||
req.miner_address = cryptonote::get_account_address_as_str(nettype, false, address);
|
||||
req.threads_count = num_threads;
|
||||
req.do_background_mining = do_background_mining;
|
||||
req.ignore_battery = ignore_battery;
|
||||
|
||||
@@ -881,12 +881,6 @@ namespace nodetool
|
||||
if (m_nettype == cryptonote::MAINNET)
|
||||
{
|
||||
return {
|
||||
"xwvz3ekocr3dkyxfkmgm2hvbpzx2ysqmaxgter7znnqrhoicygkfswid.onion:18083",
|
||||
"4pixvbejrvihnkxmduo2agsnmc3rrulrqc7s3cbwwrep6h6hrzsibeqd.onion:18083",
|
||||
"zbjkbsxc5munw3qusl7j2hpcmikhqocdf4pqhnhtpzw5nt5jrmofptid.onion:18083",
|
||||
"qz43zul2x56jexzoqgkx2trzwcfnr6l3hbtfcfx54g4r3eahy3bssjyd.onion:18083",
|
||||
"plowsof3t5hogddwabaeiyrno25efmzfxyro2vligremt7sxpsclfaid.onion:18083",
|
||||
"plowsoffjexmxalw73tkjmf422gq6575fc7vicuu4javzn2ynnte6tyd.onion:18083",
|
||||
};
|
||||
}
|
||||
return {};
|
||||
@@ -894,10 +888,6 @@ namespace nodetool
|
||||
if (m_nettype == cryptonote::MAINNET)
|
||||
{
|
||||
return {
|
||||
"s3l6ke4ed3df466khuebb4poienoingwof7oxtbo6j4n56sghe3a.b32.i2p:18080",
|
||||
"sel36x6fibfzujwvt4hf5gxolz6kd3jpvbjqg6o3ud2xtionyl2q.b32.i2p:18080",
|
||||
"uqj3aphckqtjsitz7kxx5flqpwjlq5ppr3chazfued7xucv3nheq.b32.i2p:18080",
|
||||
"vdmnehdjkpkg57nthgnjfuaqgku673r5bpbqg56ix6fyqoywgqrq.b32.i2p:18080",
|
||||
};
|
||||
}
|
||||
return {};
|
||||
@@ -2054,13 +2044,6 @@ namespace nodetool
|
||||
return true;
|
||||
|
||||
static const std::vector<std::string> dns_urls = {
|
||||
"blocklist.moneropulse.se"
|
||||
, "blocklist.moneropulse.org"
|
||||
, "blocklist.moneropulse.net"
|
||||
, "blocklist.moneropulse.no"
|
||||
, "blocklist.moneropulse.fr"
|
||||
, "blocklist.moneropulse.de"
|
||||
, "blocklist.moneropulse.ch"
|
||||
};
|
||||
|
||||
std::vector<std::string> records;
|
||||
|
||||
@@ -1879,12 +1879,29 @@ namespace cryptonote
|
||||
}
|
||||
blobdata block_blob = t_serializable_object_to_blob(b);
|
||||
crypto::public_key tx_pub_key = cryptonote::get_tx_pub_key_from_extra(b.miner_tx);
|
||||
const std::vector<crypto::public_key> additional_tx_pub_keys = cryptonote::get_additional_tx_pub_keys_from_extra(b.miner_tx);
|
||||
if(tx_pub_key == crypto::null_pkey)
|
||||
{
|
||||
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
|
||||
error_resp.message = "Internal error: failed to create block template";
|
||||
LOG_ERROR("Failed to get tx pub key in coinbase extra");
|
||||
return false;
|
||||
// Check for Carrot treasury payout
|
||||
const uint8_t hf_version = m_core.get_blockchain_storage().get_current_hard_fork_version();
|
||||
if (hf_version >= HF_VERSION_CARROT && b.miner_tx.vout.size() == 2) {
|
||||
|
||||
const auto treasury_payout_data = get_config(nettype()).TREASURY_SAL1_MINT_OUTPUT_DATA;
|
||||
const bool treasury_payout_exists = (treasury_payout_data.count(height) == 1);
|
||||
if (!treasury_payout_exists) {
|
||||
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
|
||||
error_resp.message = "Internal error: failed to create block template (missing treasury payout)";
|
||||
LOG_ERROR("Failed to get tx pub key in coinbase extra (missing treasury payout)");
|
||||
return false;
|
||||
}
|
||||
tx_pub_key = additional_tx_pub_keys.back();
|
||||
|
||||
} else {
|
||||
error_resp.code = CORE_RPC_ERROR_CODE_INTERNAL_ERROR;
|
||||
error_resp.message = "Internal error: failed to create block template";
|
||||
LOG_ERROR("Failed to get tx pub key in coinbase extra");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
uint64_t next_height;
|
||||
|
||||
@@ -316,7 +316,7 @@ namespace
|
||||
const char* USAGE_RPC_PAYMENT_INFO("rpc_payment_info");
|
||||
const char* USAGE_START_MINING_FOR_RPC("start_mining_for_rpc [<number_of_threads>]");
|
||||
const char* USAGE_STOP_MINING_FOR_RPC("stop_mining_for_rpc");
|
||||
const char* USAGE_SHOW_QR_CODE("show_qr_code [<subaddress_index>]");
|
||||
const char* USAGE_SHOW_QR_CODE("show_qr_code [<subaddress_index>] [<address_type>]");
|
||||
const char* USAGE_VERSION("version");
|
||||
const char* USAGE_HELP("help [<command> | all]");
|
||||
const char* USAGE_APROPOS("apropos <keyword> [<keyword> ...]");
|
||||
@@ -2559,6 +2559,7 @@ bool simple_wallet::stop_mining_for_rpc(const std::vector<std::string> &args)
|
||||
bool simple_wallet::show_qr_code(const std::vector<std::string> &args)
|
||||
{
|
||||
uint32_t subaddress_index = 0;
|
||||
carrot::AddressDeriveType derive_type;
|
||||
if (args.size() >= 1)
|
||||
{
|
||||
if (!string_tools::get_xtype_from_string(subaddress_index, args[0]))
|
||||
@@ -2572,6 +2573,25 @@ bool simple_wallet::show_qr_code(const std::vector<std::string> &args)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (args.size() >= 2)
|
||||
{
|
||||
// Convert string to AddressDeriveType enum
|
||||
if (args[1] == "carrot" || args[1] == "Carrot")
|
||||
{
|
||||
derive_type = carrot::AddressDeriveType::Carrot;
|
||||
}
|
||||
else if (args[1] == "precarrot" || args[1] == "PreCarrot")
|
||||
{
|
||||
derive_type = carrot::AddressDeriveType::PreCarrot;
|
||||
}
|
||||
else
|
||||
{
|
||||
fail_msg_writer() << tr("invalid derive type: must be 'carrot' or 'precarrot'");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
derive_type = carrot::AddressDeriveType::Auto;
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
#define PRINT_UTF8(pre, x) std::wcout << pre ## x
|
||||
@@ -2586,7 +2606,8 @@ bool simple_wallet::show_qr_code(const std::vector<std::string> &args)
|
||||
WTEXTON();
|
||||
try
|
||||
{
|
||||
const std::string address = "salvium:" + m_wallet->get_subaddress_as_str({m_current_subaddress_account, subaddress_index});
|
||||
const std::string address = "salvium:" + m_wallet->get_subaddress_as_str({m_current_subaddress_account, subaddress_index, derive_type, false});
|
||||
message_writer() << "Showing QR code for address: " << address.c_str() << std::endl;
|
||||
const qrcodegen::QrCode qr = qrcodegen::QrCode::encodeText(address.c_str(), qrcodegen::QrCode::Ecc::LOW);
|
||||
for (int y = -2; y < qr.getSize() + 2; y+=2)
|
||||
{
|
||||
@@ -5314,7 +5335,7 @@ boost::optional<epee::wipeable_string> simple_wallet::new_wallet(const boost::pr
|
||||
.m_is_carrot = true
|
||||
};
|
||||
message_writer(console_color_white, true) << tr("Generated new Carrot wallet: ")
|
||||
<< cryptonote::get_account_address_as_str(m_wallet->nettype(), false, carrot_address, true);
|
||||
<< cryptonote::get_account_address_as_str(m_wallet->nettype(), false, carrot_address);
|
||||
PAUSE_READLINE();
|
||||
std::cout << tr("View key: ");
|
||||
print_secret_key(m_wallet->get_account().get_keys().m_view_secret_key);
|
||||
@@ -5594,6 +5615,12 @@ boost::optional<epee::wipeable_string> simple_wallet::open_wallet(const boost::p
|
||||
m_wallet->rewrite(m_wallet_file, password);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_wallet->force_rescan()) {
|
||||
m_wallet->force_rescan(false);
|
||||
refresh_main(m_wallet->get_refresh_from_block_height(), ResetSoft);
|
||||
}
|
||||
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
@@ -6429,6 +6456,10 @@ bool simple_wallet::refresh_main(uint64_t start_height, enum ResetType reset, bo
|
||||
bool simple_wallet::refresh(const std::vector<std::string>& args)
|
||||
{
|
||||
uint64_t start_height = 0;
|
||||
if (m_wallet->force_rescan()) {
|
||||
m_wallet->force_rescan(false);
|
||||
return refresh_main(start_height, ResetSoft);
|
||||
}
|
||||
if(!args.empty()){
|
||||
try
|
||||
{
|
||||
@@ -6472,7 +6503,7 @@ bool simple_wallet::show_balance_unlocked(bool detailed)
|
||||
if (!detailed || balance_per_subaddress.empty())
|
||||
continue;
|
||||
success_msg_writer() << tr("Balance per address:");
|
||||
success_msg_writer() << boost::format("%15s %21s %21s %7s %21s") % tr("Address") % tr("Balance") % tr("Unlocked balance") % tr("Outputs") % tr("Label");
|
||||
success_msg_writer() << boost::format("%16s %21s %21s %7s %21s") % tr("Address") % tr("Balance") % tr("Unlocked balance") % tr("Outputs") % tr("Label");
|
||||
std::vector<tools::wallet2::transfer_details> transfers;
|
||||
m_wallet->get_transfers(transfers);
|
||||
for (const auto& i : balance_per_subaddress)
|
||||
@@ -6480,9 +6511,9 @@ bool simple_wallet::show_balance_unlocked(bool detailed)
|
||||
carrot::subaddress_index_extended subaddr = {{m_current_subaddress_account, i.first},
|
||||
is_carrot ? carrot::AddressDeriveType::Carrot : carrot::AddressDeriveType::PreCarrot};
|
||||
cryptonote::subaddress_index subaddr_index = {m_current_subaddress_account, i.first};
|
||||
std::string address_str = m_wallet->get_subaddress_as_str(subaddr).substr(0, 6);
|
||||
std::string address_str = m_wallet->get_subaddress_as_str(subaddr).substr(0, 8);
|
||||
uint64_t num_unspent_outputs = std::count_if(transfers.begin(), transfers.end(), [&subaddr_index](const tools::wallet2::transfer_details& td) { return !td.m_spent && td.m_subaddr_index == subaddr_index; });
|
||||
success_msg_writer() << boost::format(tr("%8u %6s %21s %21s %7u %21s")) % i.first % address_str % print_money(i.second) % print_money(unlocked_balance_per_subaddress[i.first].first) % num_unspent_outputs % m_wallet->get_subaddress_label(subaddr_index);
|
||||
success_msg_writer() << boost::format(tr("%8u %8s %21s %21s %7u %21s")) % i.first % address_str % print_money(i.second) % print_money(unlocked_balance_per_subaddress[i.first].first) % num_unspent_outputs % m_wallet->get_subaddress_label(subaddr_index);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -9902,7 +9933,7 @@ bool simple_wallet::get_transfers(std::vector<std::string>& local_args, std::vec
|
||||
if (payment_id.substr(16).find_first_not_of('0') == std::string::npos)
|
||||
payment_id = payment_id.substr(0,16);
|
||||
std::string note = m_wallet->get_tx_note(pd.m_tx_hash);
|
||||
std::string destination = m_wallet->get_subaddress_as_str({m_current_subaddress_account, pd.m_subaddr_index.minor});
|
||||
std::string destination = m_wallet->get_subaddress_as_str({{m_current_subaddress_account, pd.m_subaddr_index.minor}, pd.m_is_carrot ? carrot::AddressDeriveType::Carrot : carrot::AddressDeriveType::PreCarrot});
|
||||
const std::string type =
|
||||
pd.m_tx_type == cryptonote::transaction_type::STAKE ? "stake" :
|
||||
pd.m_coinbase ? tr("block") : tr("in");
|
||||
@@ -10095,7 +10126,9 @@ bool simple_wallet::show_transfers(const std::vector<std::string> &args_)
|
||||
transfer.type == "burnt" ? console_color_yellow :
|
||||
transfer.type == "stake" ? console_color_cyan :
|
||||
transfer.type == "yield" ? console_color_magenta :
|
||||
transfer.confirmed ? ((transfer.direction == "in" || transfer.direction == "block") ? console_color_green : console_color_white) : console_color_default;
|
||||
transfer.confirmed ?
|
||||
((transfer.direction == "in" || transfer.direction == "block") ?
|
||||
(transfer.asset_type == "SAL" ? console_color_green : console_color_blue) : console_color_white) : console_color_default;
|
||||
|
||||
std::string destinations = "-";
|
||||
if (!transfer.outputs.empty())
|
||||
@@ -10105,7 +10138,7 @@ bool simple_wallet::show_transfers(const std::vector<std::string> &args_)
|
||||
{
|
||||
if (!destinations.empty())
|
||||
destinations += ", ";
|
||||
destinations += (transfer.direction == "in" ? output.first.substr(0, 6) : output.first) + ":" + print_money(output.second);
|
||||
destinations += ((transfer.direction == "in" || transfer.direction == "block") ? output.first.substr(0, 8) : output.first) + ":" + print_money(output.second);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10631,7 +10664,7 @@ std::string simple_wallet::get_prompt() const
|
||||
{
|
||||
if (m_locked)
|
||||
return std::string("[") + tr("locked due to inactivity") + "]";
|
||||
std::string addr_start = m_wallet->get_subaddress_as_str({m_current_subaddress_account, 0}).substr(0, 6);
|
||||
std::string addr_start = m_wallet->get_subaddress_as_str({m_current_subaddress_account, 0}).substr(0, 8);
|
||||
std::string prompt = std::string("[") + tr("wallet") + " " + addr_start;
|
||||
if (!m_wallet->check_connection(NULL))
|
||||
prompt += tr(" (no daemon)");
|
||||
@@ -10854,7 +10887,7 @@ void simple_wallet::print_accounts(const std::string& tag)
|
||||
success_msg_writer() << tr("Accounts with tag: ") << tag;
|
||||
success_msg_writer() << tr("Tag's description: ") << account_tags.first.find(tag)->second;
|
||||
}
|
||||
success_msg_writer() << boost::format(" %15s %21s %21s %21s %21s") % tr("Account") % tr("Balance") % tr("Unlocked balance") % tr("Asset") % tr("Label");
|
||||
success_msg_writer() << boost::format(" %18s %21s %21s %6s %21s") % tr("Account") % tr("Balance") % tr("Unlocked balance") % tr("Asset") % tr("Label");
|
||||
std::map<std::string, std::pair<uint64_t, uint64_t>> total_balances;
|
||||
std::vector<std::string> asset_types_in_wallet = m_wallet->list_asset_types();
|
||||
for (const auto& asset: asset_types_in_wallet) {
|
||||
@@ -10868,10 +10901,10 @@ void simple_wallet::print_accounts(const std::string& tag)
|
||||
auto unlocked_balance = m_wallet->unlocked_balance(account_index, asset, false);
|
||||
if (balance == 0)
|
||||
continue;
|
||||
success_msg_writer() << boost::format(tr(" %c%8u %6s %21s %21s %21s %21s"))
|
||||
success_msg_writer() << boost::format(tr(" %c%8u %8s %21s %21s %6s %21s"))
|
||||
% (m_current_subaddress_account == account_index ? '*' : ' ')
|
||||
% account_index
|
||||
% m_wallet->get_subaddress_as_str({account_index, 0}).substr(0, 6)
|
||||
% m_wallet->get_subaddress_as_str({{account_index, 0}, carrot::AddressDeriveType::Auto}).substr(0, 8)
|
||||
% print_money(balance)
|
||||
% print_money(unlocked_balance)
|
||||
% asset
|
||||
@@ -10882,9 +10915,9 @@ void simple_wallet::print_accounts(const std::string& tag)
|
||||
if (total_balance > 0)
|
||||
total_balances[asset] = std::pair<uint64_t, uint64_t>(total_balance, total_unlocked_balance);
|
||||
}
|
||||
success_msg_writer() << tr("------------------------------------------------------------------------------------");
|
||||
success_msg_writer() << tr("------------------------------------------------------------------------------------------------------");
|
||||
for (const auto& it: total_balances)
|
||||
success_msg_writer() << boost::format(tr("%15s %21s %21s %15s")) % "Total" % print_money(it.second.first) % print_money(it.second.second) % it.first;
|
||||
success_msg_writer() << boost::format(tr("%18s %21s %21s %6s")) % "Total" % print_money(it.second.first) % print_money(it.second.second) % it.first;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::print_address(const std::vector<std::string> &args/* = std::vector<std::string>()*/)
|
||||
@@ -10900,16 +10933,35 @@ bool simple_wallet::print_address(const std::vector<std::string> &args/* = std::
|
||||
std::vector<std::string> local_args = args;
|
||||
tools::wallet2::transfer_container transfers;
|
||||
m_wallet->get_transfers(transfers);
|
||||
bool is_carrot = m_wallet->get_current_hard_fork() >= HF_VERSION_CARROT;
|
||||
|
||||
auto print_address_sub = [this, &transfers, is_carrot](uint32_t index)
|
||||
auto print_address_sub = [this, &transfers](uint32_t index, bool cryptonote = true, bool carrot = true)
|
||||
{
|
||||
bool used = std::find_if(
|
||||
transfers.begin(), transfers.end(),
|
||||
[this, &index](const tools::wallet2::transfer_details& td) {
|
||||
return td.m_subaddr_index == cryptonote::subaddress_index{ m_current_subaddress_account, index };
|
||||
}) != transfers.end();
|
||||
success_msg_writer() << index << " " << m_wallet->get_subaddress_as_str({{m_current_subaddress_account, index}, is_carrot ? carrot::AddressDeriveType::Carrot : carrot::AddressDeriveType::PreCarrot}) << " " << (index == 0 ? tr("Primary address") : m_wallet->get_subaddress_label({m_current_subaddress_account, index})) << " " << (used ? tr("(used)") : "");
|
||||
if (!cryptonote) {
|
||||
success_msg_writer() << boost::format(tr("%8u %96s %21s %6s"))
|
||||
% index
|
||||
% m_wallet->get_subaddress_as_str({{m_current_subaddress_account, index}, carrot::AddressDeriveType::Carrot})
|
||||
% (index == 0 ? tr("Primary address") : m_wallet->get_subaddress_label({m_current_subaddress_account, index}))
|
||||
% (used ? tr("(used)") : "");
|
||||
} else if (!carrot) {
|
||||
success_msg_writer() << boost::format(tr("%8u %96s %21s %6s"))
|
||||
% index
|
||||
% m_wallet->get_subaddress_as_str({{m_current_subaddress_account, index}, carrot::AddressDeriveType::PreCarrot})
|
||||
% (index == 0 ? tr("Primary address") : m_wallet->get_subaddress_label({m_current_subaddress_account, index}))
|
||||
% (used ? tr("(used)") : "");
|
||||
} else {
|
||||
success_msg_writer() << boost::format(tr("%8u CN %96s %21s %6s\n Carrot %96s\n"))
|
||||
% index
|
||||
% m_wallet->get_subaddress_as_str({{m_current_subaddress_account, index}, carrot::AddressDeriveType::PreCarrot})
|
||||
% (index == 0 ? tr("Primary address") : m_wallet->get_subaddress_label({m_current_subaddress_account, index}))
|
||||
% (used ? tr("(used)") : "")
|
||||
% m_wallet->get_subaddress_as_str({{m_current_subaddress_account, index}, carrot::AddressDeriveType::Carrot});
|
||||
}
|
||||
//success_msg_writer() << index << " " << m_wallet->get_subaddress_as_str({{m_current_subaddress_account, index}, is_carrot ? carrot::AddressDeriveType::Carrot : carrot::AddressDeriveType::PreCarrot}) << " " << (index == 0 ? tr("Primary address") : m_wallet->get_subaddress_label({m_current_subaddress_account, index})) << " " << (used ? tr("(used)") : "");
|
||||
};
|
||||
|
||||
uint32_t index = 0;
|
||||
@@ -10917,11 +10969,22 @@ bool simple_wallet::print_address(const std::vector<std::string> &args/* = std::
|
||||
{
|
||||
print_address_sub(index);
|
||||
}
|
||||
else if (local_args.size() == 1 && local_args[0] == "all")
|
||||
else if (local_args[0] == "all")
|
||||
{
|
||||
local_args.erase(local_args.begin());
|
||||
for (; index < m_wallet->get_num_subaddresses(m_current_subaddress_account); ++index)
|
||||
print_address_sub(index);
|
||||
if (local_args.size() == 0) {
|
||||
message_writer(console_color_green, true) << tr(" INDEX TYPE ADDRESS");
|
||||
for (; index < m_wallet->get_num_subaddresses(m_current_subaddress_account); ++index)
|
||||
print_address_sub(index);
|
||||
} else if (local_args[0] == "cn") {
|
||||
message_writer(console_color_green, true) << tr(" INDEX ADDRESS");
|
||||
for (; index < m_wallet->get_num_subaddresses(m_current_subaddress_account); ++index)
|
||||
print_address_sub(index, true, false);
|
||||
} else {
|
||||
message_writer(console_color_green, true) << tr(" INDEX ADDRESS");
|
||||
for (; index < m_wallet->get_num_subaddresses(m_current_subaddress_account); ++index)
|
||||
print_address_sub(index, false, true);
|
||||
}
|
||||
}
|
||||
else if (local_args[0] == "new")
|
||||
{
|
||||
@@ -11180,9 +11243,9 @@ bool simple_wallet::address_book(const std::vector<std::string> &args/* = std::v
|
||||
success_msg_writer() << tr("Index: ") << i;
|
||||
std::string address;
|
||||
if (row.m_has_payment_id)
|
||||
address = cryptonote::get_account_integrated_address_as_str(m_wallet->nettype(), row.m_address, row.m_payment_id, row.m_is_carrot);
|
||||
address = cryptonote::get_account_integrated_address_as_str(m_wallet->nettype(), row.m_address, row.m_payment_id);
|
||||
else
|
||||
address = get_account_address_as_str(m_wallet->nettype(), row.m_is_subaddress, row.m_address, row.m_is_carrot);
|
||||
address = get_account_address_as_str(m_wallet->nettype(), row.m_is_subaddress, row.m_address);
|
||||
success_msg_writer() << tr("Address: ") << address;
|
||||
success_msg_writer() << tr("Description: ") << row.m_description << "\n";
|
||||
}
|
||||
@@ -11321,7 +11384,9 @@ bool simple_wallet::wallet_info(const std::vector<std::string> &args)
|
||||
}
|
||||
message_writer() << tr("Filename: ") << m_wallet->get_wallet_file();
|
||||
message_writer() << tr("Description: ") << description;
|
||||
message_writer() << tr("Address: ") << m_wallet->get_account().get_public_address_str(m_wallet->nettype());
|
||||
message_writer() << tr("CN Address: ") << m_wallet->get_account().get_public_address_str(m_wallet->nettype());
|
||||
message_writer() << tr("Carrot Address: ") << m_wallet->get_account().get_carrot_public_address_str(m_wallet->nettype());
|
||||
|
||||
std::string type;
|
||||
if (m_wallet->watch_only())
|
||||
type = tr("Watch only");
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
#define DEF_SALVIUM_VERSION_TAG "@VERSIONTAG@"
|
||||
#define DEF_SALVIUM_VERSION "1.0.0-rc6"
|
||||
#define DEF_SALVIUM_VERSION "1.0.6"
|
||||
#define DEF_MONERO_VERSION_TAG "release"
|
||||
#define DEF_MONERO_VERSION "0.18.3.4"
|
||||
#define DEF_MONERO_RELEASE_NAME "One"
|
||||
|
||||
@@ -166,9 +166,15 @@ uint64_t PendingTransactionImpl::amount() const
|
||||
{
|
||||
uint64_t result = 0;
|
||||
for (const auto &ptx : m_pending_tx) {
|
||||
if (ptx.tx.type == cryptonote::transaction_type::AUDIT ||
|
||||
ptx.tx.type == cryptonote::transaction_type::BURN ||
|
||||
ptx.tx.type == cryptonote::transaction_type::STAKE) {
|
||||
result += ptx.tx.amount_burnt;
|
||||
} else {
|
||||
for (const auto &dest : ptx.dests) {
|
||||
result += dest.amount;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -175,7 +175,13 @@ void TransactionHistoryImpl::refresh()
|
||||
|
||||
uint64_t change = pd.m_change == (uint64_t)-1 ? 0 : pd.m_change; // change may not be known
|
||||
uint64_t fee = pd.m_amount_in - pd.m_amount_out;
|
||||
|
||||
uint64_t amount = pd.m_amount_in - change - fee;
|
||||
if (ptx.tx.type == cryptonote::transaction_type::AUDIT ||
|
||||
ptx.tx.type == cryptonote::transaction_type::BURN ||
|
||||
ptx.tx.type == cryptonote::transaction_type::STAKE) {
|
||||
amount = pd.m_tx.amount_burnt;
|
||||
if (fee > amount) fee -= amount;
|
||||
}
|
||||
|
||||
std::string payment_id = string_tools::pod_to_hex(i->second.m_payment_id);
|
||||
if (payment_id.substr(16).find_first_not_of('0') == std::string::npos)
|
||||
@@ -184,7 +190,7 @@ void TransactionHistoryImpl::refresh()
|
||||
|
||||
TransactionInfoImpl * ti = new TransactionInfoImpl();
|
||||
ti->m_paymentid = payment_id;
|
||||
ti->m_amount = pd.m_amount_in - change - fee;
|
||||
ti->m_amount = amount;
|
||||
ti->m_fee = fee;
|
||||
ti->m_direction = TransactionInfo::Direction_Out;
|
||||
ti->m_hash = string_tools::pod_to_hex(hash);
|
||||
@@ -212,8 +218,16 @@ void TransactionHistoryImpl::refresh()
|
||||
for (std::list<std::pair<crypto::hash, tools::wallet2::unconfirmed_transfer_details>>::const_iterator i = upayments_out.begin(); i != upayments_out.end(); ++i) {
|
||||
const tools::wallet2::unconfirmed_transfer_details &pd = i->second;
|
||||
const crypto::hash &hash = i->first;
|
||||
uint64_t amount = pd.m_amount_in;
|
||||
uint64_t fee = amount - pd.m_amount_out;
|
||||
uint64_t change = pd.m_change == (uint64_t)-1 ? 0 : pd.m_change; // change may not be known
|
||||
uint64_t fee = pd.m_amount_in - pd.m_amount_out;
|
||||
uint64_t amount = pd.m_amount_in - change - fee;
|
||||
if (ptx.tx.type == cryptonote::transaction_type::AUDIT ||
|
||||
ptx.tx.type == cryptonote::transaction_type::BURN ||
|
||||
ptx.tx.type == cryptonote::transaction_type::STAKE) {
|
||||
amount = pd.m_tx.amount_burnt;
|
||||
if (fee > amount) fee -= amount;
|
||||
}
|
||||
|
||||
std::string payment_id = string_tools::pod_to_hex(i->second.m_payment_id);
|
||||
if (payment_id.substr(16).find_first_not_of('0') == std::string::npos)
|
||||
payment_id = payment_id.substr(0,16);
|
||||
@@ -221,7 +235,7 @@ void TransactionHistoryImpl::refresh()
|
||||
|
||||
TransactionInfoImpl * ti = new TransactionInfoImpl();
|
||||
ti->m_paymentid = payment_id;
|
||||
ti->m_amount = amount - pd.m_change - fee;
|
||||
ti->m_amount = amount;
|
||||
ti->m_fee = fee;
|
||||
ti->m_direction = TransactionInfo::Direction_Out;
|
||||
ti->m_failed = is_failed;
|
||||
|
||||
@@ -877,40 +877,64 @@ bool WalletImpl::setDevicePassphrase(const std::string &passphrase)
|
||||
return status() == Status_Ok;
|
||||
}
|
||||
|
||||
std::string WalletImpl::address(uint32_t accountIndex, uint32_t addressIndex) const
|
||||
std::string WalletImpl::address(uint32_t accountIndex, uint32_t addressIndex, bool carrot) const
|
||||
{
|
||||
return m_wallet->get_subaddress_as_str({accountIndex, addressIndex});
|
||||
return m_wallet->get_subaddress_as_str({{accountIndex, addressIndex}, carrot ? carrot::AddressDeriveType::Carrot : carrot::AddressDeriveType::PreCarrot});
|
||||
}
|
||||
|
||||
std::string WalletImpl::integratedAddress(const std::string &payment_id) const
|
||||
std::string WalletImpl::integratedAddress(const std::string &payment_id, bool carrot) const
|
||||
{
|
||||
crypto::hash8 pid;
|
||||
if (!tools::wallet2::parse_short_payment_id(payment_id, pid)) {
|
||||
return "";
|
||||
}
|
||||
return m_wallet->get_integrated_address_as_str(pid);
|
||||
return m_wallet->get_integrated_address_as_str(pid, carrot);
|
||||
}
|
||||
|
||||
std::string WalletImpl::secretViewKey() const
|
||||
{
|
||||
uint32_t hf_version = m_wallet->estimate_current_hard_fork();
|
||||
if (hf_version >= HF_VERSION_CARROT)
|
||||
return epee::string_tools::pod_to_hex(unwrap(unwrap(m_wallet->get_account().get_keys().k_view_incoming)));
|
||||
else
|
||||
return epee::string_tools::pod_to_hex(unwrap(unwrap(m_wallet->get_account().get_keys().m_view_secret_key)));
|
||||
}
|
||||
|
||||
std::string WalletImpl::publicViewKey() const
|
||||
{
|
||||
uint32_t hf_version = m_wallet->estimate_current_hard_fork();
|
||||
if (hf_version >= HF_VERSION_CARROT)
|
||||
return epee::string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_carrot_account_address.m_view_public_key);
|
||||
else
|
||||
return epee::string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_account_address.m_view_public_key);
|
||||
}
|
||||
|
||||
std::string WalletImpl::secretSpendKey() const
|
||||
{
|
||||
return epee::string_tools::pod_to_hex(unwrap(unwrap(m_wallet->get_account().get_keys().m_spend_secret_key)));
|
||||
return epee::string_tools::pod_to_hex(unwrap(unwrap(m_wallet->get_account().get_keys().m_spend_secret_key)));
|
||||
}
|
||||
|
||||
std::string WalletImpl::publicSpendKey() const
|
||||
{
|
||||
uint32_t hf_version = m_wallet->estimate_current_hard_fork();
|
||||
if (hf_version >= HF_VERSION_CARROT)
|
||||
return epee::string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_carrot_account_address.m_spend_public_key);
|
||||
else
|
||||
return epee::string_tools::pod_to_hex(m_wallet->get_account().get_keys().m_account_address.m_spend_public_key);
|
||||
}
|
||||
|
||||
std::vector<std::string> WalletImpl::carrotKeys() const
|
||||
{
|
||||
return {
|
||||
epee::string_tools::pod_to_hex(m_wallet->get_account().get_keys().s_master),
|
||||
epee::string_tools::pod_to_hex(m_wallet->get_account().get_keys().k_prove_spend),
|
||||
epee::string_tools::pod_to_hex(m_wallet->get_account().get_keys().s_view_balance),
|
||||
epee::string_tools::pod_to_hex(m_wallet->get_account().get_keys().k_view_incoming),
|
||||
epee::string_tools::pod_to_hex(m_wallet->get_account().get_keys().k_generate_image),
|
||||
epee::string_tools::pod_to_hex(m_wallet->get_account().get_keys().s_generate_address)
|
||||
};
|
||||
}
|
||||
|
||||
std::string WalletImpl::publicMultisigSignerKey() const
|
||||
{
|
||||
try {
|
||||
@@ -921,6 +945,26 @@ std::string WalletImpl::publicMultisigSignerKey() const
|
||||
}
|
||||
}
|
||||
|
||||
std::string WalletImpl::secretViewBalance() const
|
||||
{
|
||||
return epee::string_tools::pod_to_hex(m_wallet->get_account().get_keys().s_view_balance);
|
||||
}
|
||||
|
||||
std::string WalletImpl::secretProveSpend() const
|
||||
{
|
||||
return epee::string_tools::pod_to_hex(m_wallet->get_account().get_keys().k_prove_spend);
|
||||
}
|
||||
|
||||
std::string WalletImpl::secretGenerateAddress() const
|
||||
{
|
||||
return epee::string_tools::pod_to_hex(m_wallet->get_account().get_keys().s_generate_address);
|
||||
}
|
||||
|
||||
std::string WalletImpl::secretGenerateImage() const
|
||||
{
|
||||
return epee::string_tools::pod_to_hex(m_wallet->get_account().get_keys().k_generate_image);
|
||||
}
|
||||
|
||||
std::string WalletImpl::path() const
|
||||
{
|
||||
return m_wallet->path();
|
||||
@@ -1588,7 +1632,8 @@ PendingTransaction* WalletImpl::restoreMultisigTransaction(const string& signDat
|
||||
PendingTransaction *WalletImpl::createStakeTransaction(uint64_t amount, uint32_t mixin_count, PendingTransaction::Priority priority, uint32_t subaddr_account, std::set<uint32_t> subaddr_indices)
|
||||
{
|
||||
// Need to populate {dst_entr, payment_id, asset_type, is_return}
|
||||
const string dst_addr = m_wallet->get_subaddress_as_str({subaddr_account, 0});//MY LOCAL (SUB)ADDRESS
|
||||
const bool is_carrot = m_wallet->get_current_hard_fork() >= HF_VERSION_CARROT;
|
||||
const string dst_addr = m_wallet->get_subaddress_as_str({{subaddr_account, 0}, is_carrot ? carrot::AddressDeriveType::Carrot : carrot::AddressDeriveType::PreCarrot});//MY LOCAL (SUB)ADDRESS
|
||||
const string payment_id = "";
|
||||
const string asset_type = "SAL1";
|
||||
const bool is_return = false;
|
||||
@@ -1605,7 +1650,8 @@ PendingTransaction *WalletImpl::createAuditTransaction(
|
||||
std::set<uint32_t> subaddr_indices
|
||||
) {
|
||||
// Need to populate {dst_entr, payment_id, asset_type, is_return}
|
||||
const string dst_addr = m_wallet->get_subaddress_as_str({subaddr_account, 0});//MY LOCAL (SUB)ADDRESS
|
||||
const bool is_carrot = m_wallet->get_current_hard_fork() >= HF_VERSION_CARROT;
|
||||
const string dst_addr = m_wallet->get_subaddress_as_str({{subaddr_account, 0}, is_carrot ? carrot::AddressDeriveType::Carrot : carrot::AddressDeriveType::PreCarrot});//MY LOCAL (SUB)ADDRESS
|
||||
const string payment_id = "";
|
||||
const string asset_type = "SAL";
|
||||
const bool is_return = false;
|
||||
|
||||
@@ -93,13 +93,18 @@ public:
|
||||
const std::string& getPassword() const override;
|
||||
bool setDevicePin(const std::string &password) override;
|
||||
bool setDevicePassphrase(const std::string &password) override;
|
||||
std::string address(uint32_t accountIndex = 0, uint32_t addressIndex = 0) const override;
|
||||
std::string integratedAddress(const std::string &payment_id) const override;
|
||||
std::string address(uint32_t accountIndex = 0, uint32_t addressIndex = 0, bool carrot = true) const override;
|
||||
std::string integratedAddress(const std::string &payment_id, bool carrot = true) const override;
|
||||
std::string secretViewKey() const override;
|
||||
std::string publicViewKey() const override;
|
||||
std::string secretSpendKey() const override;
|
||||
std::string publicSpendKey() const override;
|
||||
std::vector<std::string> carrotKeys() const override;
|
||||
std::string publicMultisigSignerKey() const override;
|
||||
std::string secretViewBalance() const override;
|
||||
std::string secretProveSpend() const override;
|
||||
std::string secretGenerateAddress() const override;
|
||||
std::string secretGenerateImage() const override;
|
||||
std::string path() const override;
|
||||
void stop() override;
|
||||
bool store(const std::string &path) override;
|
||||
|
||||
@@ -513,8 +513,8 @@ struct Wallet
|
||||
virtual const std::string& getPassword() const = 0;
|
||||
virtual bool setDevicePin(const std::string &pin) { (void)pin; return false; };
|
||||
virtual bool setDevicePassphrase(const std::string &passphrase) { (void)passphrase; return false; };
|
||||
virtual std::string address(uint32_t accountIndex = 0, uint32_t addressIndex = 0) const = 0;
|
||||
std::string mainAddress() const { return address(0, 0); }
|
||||
virtual std::string address(uint32_t accountIndex = 0, uint32_t addressIndex = 0, bool carrot = true) const = 0;
|
||||
std::string mainAddress(bool carrot = true) const { return address(0, 0, carrot); }
|
||||
virtual std::string path() const = 0;
|
||||
virtual NetworkType nettype() const = 0;
|
||||
bool mainnet() const { return nettype() == MAINNET; }
|
||||
@@ -533,7 +533,7 @@ struct Wallet
|
||||
* generated
|
||||
* \return - 106 characters string representing integrated address
|
||||
*/
|
||||
virtual std::string integratedAddress(const std::string &payment_id) const = 0;
|
||||
virtual std::string integratedAddress(const std::string &payment_id, bool carrot = true) const = 0;
|
||||
|
||||
/*!
|
||||
* \brief secretViewKey - returns secret view key
|
||||
@@ -559,12 +559,48 @@ struct Wallet
|
||||
*/
|
||||
virtual std::string publicSpendKey() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief allCarrotKeys - returns all Carrot keys
|
||||
* [0] - s_master
|
||||
* [1] - k_prove_spend
|
||||
* [2] - s_view_balance
|
||||
* [3] - k_view_incoming
|
||||
* [4] - k_generate_image
|
||||
* [5] - s_generate_address
|
||||
* \return - vector of all Carrot keys
|
||||
*/
|
||||
virtual std::vector<std::string> carrotKeys() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief publicMultisigSignerKey - returns public signer key
|
||||
* \return - public multisignature signer key or empty string if wallet is not multisig
|
||||
*/
|
||||
virtual std::string publicMultisigSignerKey() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief secretViewBalance - returns Carrot "view balance" secret
|
||||
* \return - Carrot s_vb
|
||||
*/
|
||||
virtual std::string secretViewBalance() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief secretProveSpend - returns Carrot "prove spend" secret
|
||||
* \return - Carrot secret k_ps
|
||||
*/
|
||||
virtual std::string secretProveSpend() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief secretGenerateAddress - returns Carrot "generate address" secret
|
||||
* \return - Carrot secret s_ga
|
||||
*/
|
||||
virtual std::string secretGenerateAddress() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief secretGenerateImage - returns Carrot "generate key image" secret
|
||||
* \return - Carrot secret k_gi
|
||||
*/
|
||||
virtual std::string secretGenerateImage() const = 0;
|
||||
|
||||
/*!
|
||||
* \brief stop - interrupts wallet refresh() loop once (doesn't stop background refresh thread)
|
||||
*/
|
||||
|
||||
@@ -973,7 +973,14 @@ std::optional<crypto::key_image> try_derive_enote_key_image(
|
||||
// x = k_s + k^j_subext + k^g_o
|
||||
rct::key x;
|
||||
if (enote_scan_info.is_carrot) {
|
||||
return acc.derive_key_image(enote_scan_info.address_spend_pubkey,
|
||||
// if we don't have the s_master key, derive view-only key image
|
||||
if (acc.get_keys().s_master == crypto::null_skey) {
|
||||
return acc.derive_key_image_view_only(enote_scan_info.address_spend_pubkey,
|
||||
enote_scan_info.sender_extension_g,
|
||||
enote_scan_info.sender_extension_t,
|
||||
rct::rct2pk(onetime_address));
|
||||
}
|
||||
return acc.derive_key_image(enote_scan_info.address_spend_pubkey,
|
||||
enote_scan_info.sender_extension_g,
|
||||
enote_scan_info.sender_extension_t,
|
||||
rct::rct2pk(onetime_address));
|
||||
|
||||
+27
-12
@@ -148,9 +148,10 @@ static cryptonote::tx_destination_entry make_tx_destination_entry(
|
||||
const carrot::CarrotPaymentProposalV1 &payment_proposal)
|
||||
{
|
||||
cryptonote::tx_destination_entry dest = cryptonote::tx_destination_entry(payment_proposal.amount,
|
||||
{payment_proposal.destination.address_spend_pubkey, payment_proposal.destination.address_view_pubkey},
|
||||
{payment_proposal.destination.address_spend_pubkey, payment_proposal.destination.address_view_pubkey, /*m_is_carrot*/true},
|
||||
payment_proposal.destination.is_subaddress);
|
||||
dest.is_integrated = payment_proposal.destination.payment_id != carrot::null_payment_id;
|
||||
dest.asset_type = payment_proposal.asset_type;
|
||||
return dest;
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
@@ -165,9 +166,11 @@ static cryptonote::tx_destination_entry make_tx_destination_entry(
|
||||
address_view_pubkey),
|
||||
"make_tx_destination_entry: view-key multiplication failed");
|
||||
|
||||
return cryptonote::tx_destination_entry(payment_proposal.proposal.amount,
|
||||
{payment_proposal.proposal.destination_address_spend_pubkey, address_view_pubkey},
|
||||
payment_proposal.subaddr_index.index.is_subaddress());
|
||||
cryptonote::tx_destination_entry dest = cryptonote::tx_destination_entry(payment_proposal.proposal.amount,
|
||||
{payment_proposal.proposal.destination_address_spend_pubkey, address_view_pubkey, /*m_is_carrot*/true},
|
||||
payment_proposal.subaddr_index.index.is_subaddress());
|
||||
dest.asset_type = payment_proposal.proposal.asset_type;
|
||||
return dest;
|
||||
}
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
//-------------------------------------------------------------------------------------------------------------------
|
||||
@@ -815,8 +818,14 @@ bool get_address_openings_x_y(
|
||||
if (return_output_map.find(rct::rct2pk(src.outputs[src.real_output].second.dest)) != return_output_map.end())
|
||||
{
|
||||
const auto &return_output = return_output_map.at(rct::rct2pk(src.outputs[src.real_output].second.dest));
|
||||
x_out = return_output.x;
|
||||
y_out = return_output.y;
|
||||
bool r = w.get_account().try_searching_for_opening_for_onetime_address(
|
||||
return_output.K_spend_pubkey,
|
||||
return_output.sum_g,
|
||||
return_output.sender_extension_t,
|
||||
x_out,
|
||||
y_out
|
||||
);
|
||||
CHECK_AND_ASSERT_THROW_MES(r, "Failed to obtain openings for onetime address (return_payment)");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1288,7 +1297,8 @@ wallet2::pending_tx make_pending_carrot_tx(const carrot::CarrotTransactionPropos
|
||||
carrot::encrypted_payment_id_t encrypted_payment_id;
|
||||
std::vector<std::pair<bool, std::size_t>> sorted_payment_proposal_indices;
|
||||
carrot::get_output_enote_proposals_from_proposal_v1(tx_proposal,
|
||||
/*s_view_balance_dev=*/nullptr,
|
||||
&account.s_view_balance_dev,
|
||||
///*s_view_balance_dev=*/nullptr,
|
||||
&account.k_view_incoming_dev,
|
||||
output_enote_proposals,
|
||||
encrypted_payment_id,
|
||||
@@ -1360,11 +1370,16 @@ wallet2::pending_tx make_pending_carrot_tx(const carrot::CarrotTransactionPropos
|
||||
ptx.change_dts = change_dts;
|
||||
ptx.selected_transfers = std::move(selected_transfers);
|
||||
ptx.key_images = key_images_string.str();
|
||||
ptx.tx_key = shared_ephemeral_pubkey ? ephemeral_privkeys.at(0) : crypto::null_skey;
|
||||
if (shared_ephemeral_pubkey)
|
||||
ptx.additional_tx_keys = std::move(ephemeral_privkeys);
|
||||
else
|
||||
ptx.additional_tx_keys.clear();
|
||||
if (ephemeral_privkeys.size() == 1) {
|
||||
ptx.tx_key = ephemeral_privkeys.at(0);
|
||||
ptx.additional_tx_keys.clear();
|
||||
} else if (ephemeral_privkeys.size() == 2 && shared_ephemeral_pubkey) {
|
||||
ptx.tx_key = (ephemeral_privkeys.at(0) == crypto::null_skey) ? ephemeral_privkeys.at(1) : ephemeral_privkeys.at(0);
|
||||
ptx.additional_tx_keys.clear();
|
||||
} else {
|
||||
ptx.tx_key = crypto::null_skey;
|
||||
ptx.additional_tx_keys = std::move(ephemeral_privkeys);
|
||||
}
|
||||
ptx.dests = std::move(dests);
|
||||
ptx.multisig_sigs = {};
|
||||
ptx.multisig_tx_key_entropy = {};
|
||||
|
||||
+172
-32
@@ -1572,10 +1572,12 @@ cryptonote::account_public_address wallet2::get_subaddress(const cryptonote::sub
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
boost::optional<cryptonote::subaddress_index> wallet2::get_subaddress_index(const cryptonote::account_public_address& address) const
|
||||
{
|
||||
auto index = m_subaddresses.find(address.m_spend_public_key);
|
||||
if (index == m_subaddresses.end())
|
||||
const auto subaddress_map = m_account.get_subaddress_map_ref();
|
||||
auto carrot_index = subaddress_map.find(address.m_spend_public_key);
|
||||
if (carrot_index == subaddress_map.end())
|
||||
return boost::none;
|
||||
return index->second;
|
||||
cryptonote::subaddress_index index{carrot_index->second.index.major, carrot_index->second.index.minor};
|
||||
return index;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
crypto::public_key wallet2::get_subaddress_spend_public_key(const cryptonote::subaddress_index& index) const
|
||||
@@ -1584,21 +1586,41 @@ crypto::public_key wallet2::get_subaddress_spend_public_key(const cryptonote::su
|
||||
return hwdev.get_subaddress_spend_public_key(m_account.get_keys(), index);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
std::string wallet2::get_subaddress_as_str(const carrot::subaddress_index_extended& subaddr) const
|
||||
std::string wallet2::get_subaddress_as_str(const carrot::subaddress_index_extended& subaddr_const) const
|
||||
{
|
||||
carrot::CarrotDestinationV1 address = m_account.subaddress(subaddr);
|
||||
// Make a non-const copy of subaddr
|
||||
carrot::subaddress_index_extended subaddr(subaddr_const);
|
||||
|
||||
// Handle "auto" - the account class doesn't know the HF version, so this is the cleanest solution
|
||||
if (subaddr.derive_type == carrot::AddressDeriveType::Auto) {
|
||||
|
||||
// Get the HF version
|
||||
uint32_t hf_version = estimate_current_hard_fork();
|
||||
THROW_WALLET_EXCEPTION_IF(hf_version == 0, error::wallet_internal_error, "unable to estimate the current hard fork - cannot generate subaddress as string");
|
||||
|
||||
// Change the non-const derivation type
|
||||
subaddr.derive_type = (hf_version >= HF_VERSION_CARROT) ? carrot::AddressDeriveType::Carrot : carrot::AddressDeriveType::PreCarrot;
|
||||
}
|
||||
|
||||
// Build the cryptonote::account_public_address
|
||||
carrot::CarrotDestinationV1 address = m_account.subaddress(subaddr);
|
||||
account_public_address addr{address.address_spend_pubkey, address.address_view_pubkey};
|
||||
addr.m_is_carrot = subaddr.derive_type == carrot::AddressDeriveType::Carrot;
|
||||
|
||||
// change this code into base 58
|
||||
return cryptonote::get_account_address_as_str(m_nettype, address.is_subaddress, addr, addr.m_is_carrot);
|
||||
return cryptonote::get_account_address_as_str(m_nettype, address.is_subaddress, addr);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
std::string wallet2::get_integrated_address_as_str(const crypto::hash8& payment_id) const
|
||||
std::string wallet2::get_integrated_address_as_str(const crypto::hash8& payment_id, bool carrot) const
|
||||
{
|
||||
return cryptonote::get_account_integrated_address_as_str(m_nettype, get_address(), payment_id);
|
||||
carrot::subaddress_index_extended subaddr{{0, 0}, carrot ? carrot::AddressDeriveType::Carrot : carrot::AddressDeriveType::PreCarrot};
|
||||
carrot::CarrotDestinationV1 address = m_account.subaddress(subaddr);
|
||||
|
||||
// Build the cryptonote::account_public_address
|
||||
account_public_address addr{address.address_spend_pubkey, address.address_view_pubkey};
|
||||
addr.m_is_carrot = carrot;
|
||||
|
||||
return cryptonote::get_account_integrated_address_as_str(m_nettype, addr, payment_id);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void wallet2::add_subaddress_account(const std::string& label)
|
||||
@@ -1631,6 +1653,7 @@ bool wallet2::should_expand(const cryptonote::subaddress_index &index) const
|
||||
void wallet2::expand_subaddresses(const cryptonote::subaddress_index& index)
|
||||
{
|
||||
hw::device &hwdev = m_account.get_device();
|
||||
std::unordered_map<crypto::public_key, carrot::subaddress_index_extended> new_addresses;
|
||||
if (m_subaddress_labels.size() <= index.major)
|
||||
{
|
||||
// add new accounts
|
||||
@@ -1644,6 +1667,7 @@ void wallet2::expand_subaddresses(const cryptonote::subaddress_index& index)
|
||||
{
|
||||
const crypto::public_key &D = pkeys[index2.minor];
|
||||
m_subaddresses[D] = index2;
|
||||
new_addresses.insert({D, {{index2.major, index2.minor}, carrot::AddressDeriveType::PreCarrot, false}});
|
||||
}
|
||||
}
|
||||
m_subaddress_labels.resize(index.major + 1, {"Untitled account"});
|
||||
@@ -1661,9 +1685,12 @@ void wallet2::expand_subaddresses(const cryptonote::subaddress_index& index)
|
||||
{
|
||||
const crypto::public_key &D = pkeys[index2.minor - begin];
|
||||
m_subaddresses[D] = index2;
|
||||
new_addresses.insert({D, {{index2.major, index2.minor}, carrot::AddressDeriveType::PreCarrot, false}});
|
||||
}
|
||||
m_subaddress_labels[index.major].resize(index.minor + 1);
|
||||
}
|
||||
// Add to the Carrot account
|
||||
m_account.insert_subaddresses(new_addresses);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void wallet2::create_one_off_subaddress(const cryptonote::subaddress_index& index)
|
||||
@@ -2412,7 +2439,7 @@ void wallet2::scan_key_image(const wallet::enote_view_incoming_scan_info_t &enot
|
||||
{
|
||||
ki_out = std::nullopt;
|
||||
|
||||
if (m_multisig || m_background_syncing || m_watch_only) // no complete spend privkey
|
||||
if (m_multisig || m_background_syncing/* || m_watch_only*/) // no complete spend privkey
|
||||
return;
|
||||
|
||||
// if keys are encrypted, ask for password
|
||||
@@ -2929,6 +2956,7 @@ void wallet2::process_new_scanned_transaction(
|
||||
payment.m_coinbase = miner_tx;
|
||||
payment.m_subaddr_index = i.first;
|
||||
payment.m_tx_type = tx.type;
|
||||
payment.m_is_carrot = (tx.version >= TRANSACTION_VERSION_CARROT);
|
||||
if (pool) {
|
||||
if (emplace_or_replace(m_unconfirmed_payments, payment_id, pool_payment_details{payment, double_spend_seen}))
|
||||
all_same = false;
|
||||
@@ -3372,7 +3400,10 @@ void wallet2::process_parsed_blocks(const uint64_t start_height, const std::vect
|
||||
{
|
||||
if (tx.vout.empty())
|
||||
{
|
||||
MWARNING("Skipping tx without any outputs: " << get_transaction_hash(tx) << ", height: " << m_blockchain.size());
|
||||
if (tx.type == cryptonote::transaction_type::PROTOCOL)
|
||||
MDEBUG("Skipping protocol tx without any outputs: " << get_transaction_hash(tx) << ", height: " << m_blockchain.size());
|
||||
else
|
||||
MWARNING("Skipping tx without any outputs: " << get_transaction_hash(tx) << ", height: " << m_blockchain.size());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -5436,14 +5467,31 @@ bool wallet2::load_keys_buf(const std::string& keys_buf, const epee::wipeable_st
|
||||
}
|
||||
const cryptonote::account_keys& keys = m_account.get_keys();
|
||||
hw::device &hwdev = m_account.get_device();
|
||||
r = r && hwdev.verify_keys(keys.m_view_secret_key, keys.m_account_address.m_view_public_key);
|
||||
if (m_watch_only) {
|
||||
|
||||
// Check to see if this is a Carrot SVB wallet
|
||||
crypto::secret_key kv_recomputed;
|
||||
carrot::make_carrot_viewincoming_key(keys.s_view_balance, kv_recomputed);
|
||||
THROW_WALLET_EXCEPTION_IF(keys.k_view_incoming != kv_recomputed, error::wallet_internal_error, "cannot compute viable wallet");
|
||||
|
||||
// assume Carrot SVB wallet
|
||||
m_account.create_from_svb_key(keys.m_carrot_account_address, keys.s_view_balance);
|
||||
|
||||
// Now verify that the account address has a public view key that matches k_view_incoming
|
||||
r = r && hwdev.verify_keys(keys.k_view_incoming, keys.m_carrot_main_address.m_view_public_key);
|
||||
|
||||
} else {
|
||||
// Assume normal wallet
|
||||
r = r && hwdev.verify_keys(keys.m_view_secret_key, keys.m_account_address.m_view_public_key);
|
||||
}
|
||||
if (!m_watch_only && !m_multisig && hwdev.device_protocol() != hw::device::PROTOCOL_COLD && !m_is_background_wallet)
|
||||
r = r && hwdev.verify_keys(keys.m_spend_secret_key, keys.m_account_address.m_spend_public_key);
|
||||
THROW_WALLET_EXCEPTION_IF(!r, error::wallet_files_doesnt_correspond, m_keys_file, m_wallet_file);
|
||||
|
||||
if (r)
|
||||
{
|
||||
m_account.set_carrot_keys();
|
||||
if (!m_watch_only)
|
||||
m_account.set_carrot_keys();
|
||||
|
||||
if (!m_is_background_wallet)
|
||||
setup_keys(password);
|
||||
@@ -5533,7 +5581,7 @@ bool wallet2::verify_password(const std::string& keys_file_name, const epee::wip
|
||||
encrypted_secret_keys = field_encrypted_secret_keys;
|
||||
}
|
||||
|
||||
cryptonote::account_base account_data_check;
|
||||
carrot::carrot_and_legacy_account account_data_check;
|
||||
|
||||
r = epee::serialization::load_t_from_binary(account_data_check, account_data);
|
||||
|
||||
@@ -5541,7 +5589,14 @@ bool wallet2::verify_password(const std::string& keys_file_name, const epee::wip
|
||||
account_data_check.decrypt_keys(key);
|
||||
|
||||
const cryptonote::account_keys& keys = account_data_check.get_keys();
|
||||
r = r && hwdev.verify_keys(keys.m_view_secret_key, keys.m_account_address.m_view_public_key);
|
||||
if (no_spend_key) {
|
||||
// assume Carrot SVB wallet
|
||||
account_data_check.create_from_svb_key(keys.m_carrot_account_address, keys.s_view_balance);
|
||||
// Now verify that the account address has a public view key that matches k_view_incoming
|
||||
r = r && hwdev.verify_keys(keys.k_view_incoming, keys.m_carrot_main_address.m_view_public_key);
|
||||
} else {
|
||||
r = r && hwdev.verify_keys(keys.m_view_secret_key, keys.m_account_address.m_view_public_key);
|
||||
}
|
||||
if(!no_spend_key)
|
||||
r = r && hwdev.verify_keys(keys.m_spend_secret_key, keys.m_account_address.m_spend_public_key);
|
||||
spend_key_out = (!no_spend_key && r) ? keys.m_spend_secret_key : crypto::null_skey;
|
||||
@@ -5602,7 +5657,8 @@ void wallet2::create_keys_file(const std::string &wallet_, bool watch_only, cons
|
||||
|
||||
if (create_address_file)
|
||||
{
|
||||
r = save_to_file(m_wallet_file + ".address.txt", m_account.get_public_address_str(m_nettype), true);
|
||||
std::string addresses = m_account.get_public_address_str(m_nettype) + "\n" + m_account.get_carrot_public_address_str(m_nettype) + "\n";
|
||||
r = save_to_file(m_wallet_file + ".address.txt", addresses, true);
|
||||
if(!r) MERROR("String with address text not saved");
|
||||
}
|
||||
}
|
||||
@@ -6585,7 +6641,9 @@ void wallet2::load(const std::string& wallet_, const epee::wipeable_string& pass
|
||||
{
|
||||
THROW_WALLET_EXCEPTION_IF(true, error::file_read_error, m_keys_file);
|
||||
}
|
||||
LOG_PRINT_L0("Loaded wallet keys file, with public address: " << m_account.get_public_address_str(m_nettype));
|
||||
LOG_PRINT_L0("Loaded wallet keys file, with public addresses: ");
|
||||
LOG_PRINT_L0(" CN : " << m_account.get_public_address_str(m_nettype));
|
||||
LOG_PRINT_L0(" Carrot : " << m_account.get_carrot_public_address_str(m_nettype));
|
||||
lock_keys_file();
|
||||
}
|
||||
else if (!load_keys_buf(keys_buf, password))
|
||||
@@ -6632,6 +6690,8 @@ void wallet2::load(const std::string& wallet_, const epee::wipeable_string& pass
|
||||
if (get_num_subaddress_accounts() == 0)
|
||||
add_subaddress_account(tr("Primary account"));
|
||||
|
||||
m_account.generate_subaddress_map(get_subaddress_lookahead());
|
||||
|
||||
// populate account subaddress list
|
||||
if (!m_subaddresses.empty())
|
||||
{
|
||||
@@ -6793,10 +6853,17 @@ void wallet2::load_wallet_cache(const bool use_fs, const std::string& cache_buf)
|
||||
ar >> *this;
|
||||
}
|
||||
}
|
||||
THROW_WALLET_EXCEPTION_IF(
|
||||
m_account_public_address.m_spend_public_key != m_account.get_keys().m_account_address.m_spend_public_key ||
|
||||
m_account_public_address.m_view_public_key != m_account.get_keys().m_account_address.m_view_public_key,
|
||||
error::wallet_files_doesnt_correspond, m_keys_file, m_wallet_file);
|
||||
if (m_watch_only) {
|
||||
THROW_WALLET_EXCEPTION_IF(
|
||||
m_account_public_address.m_spend_public_key != m_account.get_keys().m_carrot_main_address.m_spend_public_key ||
|
||||
m_account_public_address.m_view_public_key != m_account.get_keys().m_carrot_main_address.m_view_public_key,
|
||||
error::wallet_files_doesnt_correspond, m_keys_file, m_wallet_file);
|
||||
} else {
|
||||
THROW_WALLET_EXCEPTION_IF(
|
||||
m_account_public_address.m_spend_public_key != m_account.get_keys().m_account_address.m_spend_public_key ||
|
||||
m_account_public_address.m_view_public_key != m_account.get_keys().m_account_address.m_view_public_key,
|
||||
error::wallet_files_doesnt_correspond, m_keys_file, m_wallet_file);
|
||||
}
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@@ -7803,7 +7870,7 @@ void wallet2::commit_tx(pending_tx& ptx)
|
||||
amount_in += m_transfers[idx].amount();
|
||||
}
|
||||
add_unconfirmed_tx(ptx.tx, amount_in, dests, payment_id, ptx.change_dts.amount, subaddr_account, subaddr_indices);
|
||||
if (store_tx_info() && ptx.tx_key != crypto::null_skey)
|
||||
if (store_tx_info() && (ptx.tx_key != crypto::null_skey || ptx.additional_tx_keys.size() != 0))
|
||||
{
|
||||
m_tx_keys[txid] = ptx.tx_key;
|
||||
m_additional_tx_keys[txid] = ptx.additional_tx_keys;
|
||||
@@ -11624,6 +11691,9 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_all(uint64_t below
|
||||
const bool do_carrot_tx_construction = use_fork_rules(HF_VERSION_CARROT);
|
||||
if (do_carrot_tx_construction)
|
||||
{
|
||||
// Sanity checks
|
||||
THROW_WALLET_EXCEPTION_IF(!address.m_is_carrot, error::wallet_internal_error, "CryptoNote address supplied, but Carrot is now active");
|
||||
|
||||
const auto tx_proposals = tools::wallet::make_carrot_transaction_proposals_wallet2_sweep_all(*this, below, address, is_subaddress, outputs, priority, extra, tx_type, subaddr_account, subaddr_indices);
|
||||
std::vector<pending_tx> ptx_vector;
|
||||
ptx_vector.reserve(tx_proposals.size());
|
||||
@@ -11632,6 +11702,9 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_all(uint64_t below
|
||||
return ptx_vector;
|
||||
}
|
||||
|
||||
// Sanity checks
|
||||
THROW_WALLET_EXCEPTION_IF(address.m_is_carrot, error::wallet_internal_error, "Carrot address supplied, but Carrot not yet active");
|
||||
|
||||
std::vector<size_t> unused_transfers_indices;
|
||||
std::vector<size_t> unused_dust_indices;
|
||||
const bool use_per_byte_fee = true;
|
||||
@@ -11714,6 +11787,9 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_single(const crypt
|
||||
const bool do_carrot_tx_construction = use_fork_rules(HF_VERSION_CARROT);
|
||||
if (do_carrot_tx_construction)
|
||||
{
|
||||
// Sanity checks
|
||||
THROW_WALLET_EXCEPTION_IF(!address.m_is_carrot, error::wallet_internal_error, "CryptoNote address supplied, but Carrot is now active");
|
||||
|
||||
const auto tx_proposals = tools::wallet::make_carrot_transaction_proposals_wallet2_sweep(*this, {ki}, address, is_subaddress, outputs, priority, extra, tx_type);
|
||||
std::vector<pending_tx> ptx_vector;
|
||||
ptx_vector.reserve(tx_proposals.size());
|
||||
@@ -11723,6 +11799,9 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_single(const crypt
|
||||
return ptx_vector;
|
||||
}
|
||||
|
||||
// Sanity checks
|
||||
THROW_WALLET_EXCEPTION_IF(address.m_is_carrot, error::wallet_internal_error, "Carrot address supplied, but Carrot not yet active");
|
||||
|
||||
std::vector<size_t> unused_transfers_indices;
|
||||
std::vector<size_t> unused_dust_indices;
|
||||
const bool use_rct = use_fork_rules(4, 0);
|
||||
@@ -11810,8 +11889,13 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_return(std::vector
|
||||
} else {
|
||||
THROW_WALLET_EXCEPTION_IF(true, error::wallet_internal_error, "Unsupported input type for return_payment");
|
||||
}
|
||||
const mx25519_pubkey origin_tx_shared_secret_unctx = carrot::raw_byte_convert<mx25519_pubkey>(main_derivations[0]);
|
||||
THROW_WALLET_EXCEPTION_IF(!main_derivations.size() && !additional_derivations.size(), error::wallet_internal_error, "No derivations found");
|
||||
THROW_WALLET_EXCEPTION_IF(!main_derivations.size() && additional_derivations.size() < td_origin.m_internal_output_index + 1, error::wallet_internal_error, "No derivations found");
|
||||
|
||||
const key_derivation derivation = (main_derivations.size() == 1) ? main_derivations[0] : additional_derivations[td_origin.m_internal_output_index];
|
||||
const mx25519_pubkey origin_tx_shared_secret_unctx = carrot::raw_byte_convert<mx25519_pubkey>(derivation);
|
||||
|
||||
|
||||
// 4. compute m_return
|
||||
crypto::public_key output_key;
|
||||
carrot::encrypted_return_pubkey_t m_return;
|
||||
@@ -11841,7 +11925,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_return(std::vector
|
||||
|
||||
// 6. compute the change index
|
||||
crypto::secret_key z_i;
|
||||
derivation_to_scalar(main_derivations[0], td_origin.m_internal_output_index, z_i);
|
||||
derivation_to_scalar(derivation, td_origin.m_internal_output_index, z_i);
|
||||
struct {
|
||||
char domain_separator[8];
|
||||
crypto::secret_key output_index_key;
|
||||
@@ -11865,6 +11949,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_return(std::vector
|
||||
cryptonote::account_public_address address;
|
||||
address.m_spend_public_key = change_key;
|
||||
address.m_view_public_key = return_pub;
|
||||
address.m_is_carrot = true;
|
||||
|
||||
return create_transactions_from(address, cryptonote::transaction_type::RETURN, asset_type, is_subaddress, outputs, transfers_indices, unused_dust_indices, fake_outs_count, unlock_time, priority, extra);
|
||||
}
|
||||
@@ -12305,6 +12390,31 @@ void wallet2::device_show_address(uint32_t account_index, uint32_t address_index
|
||||
hwdev.display_address(subaddress_index{account_index, address_index}, payment_id);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
uint8_t wallet2::estimate_current_hard_fork(const uint64_t height) const
|
||||
{
|
||||
// Get the last-seen top height by the wallet
|
||||
uint64_t guessed_height = (height > 0) ? height : m_blockchain.size();
|
||||
|
||||
// Get the correct hardfork table, based on current net type
|
||||
const hardfork_t *hfs =
|
||||
(m_nettype == cryptonote::MAINNET) ? mainnet_hard_forks :
|
||||
(m_nettype == cryptonote::TESTNET) ? testnet_hard_forks :
|
||||
stagenet_hard_forks;
|
||||
size_t hfs_count =
|
||||
(m_nettype == cryptonote::MAINNET) ? num_mainnet_hard_forks :
|
||||
(m_nettype == cryptonote::TESTNET) ? num_testnet_hard_forks :
|
||||
num_stagenet_hard_forks;
|
||||
|
||||
// Iterate over the hard fork table, to see what the current fork is for the guessed height
|
||||
for (size_t i = hfs_count-1; i>=0; --i) {
|
||||
if (hfs[i].height <= guessed_height)
|
||||
return hfs[i].version;
|
||||
}
|
||||
|
||||
// return "no value found" to the caller
|
||||
return 0;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
uint8_t wallet2::get_current_hard_fork()
|
||||
{
|
||||
if (m_offline)
|
||||
@@ -12524,8 +12634,8 @@ bool wallet2::get_tx_key_cached(const crypto::hash &txid, crypto::secret_key &tx
|
||||
if (i == m_tx_keys.end())
|
||||
return false;
|
||||
tx_key = i->second;
|
||||
if (tx_key == crypto::null_skey)
|
||||
return false;
|
||||
//if (tx_key == crypto::null_skey)
|
||||
// return false;
|
||||
const auto j = m_additional_tx_keys.find(txid);
|
||||
if (j != m_additional_tx_keys.end())
|
||||
additional_tx_keys = j->second;
|
||||
@@ -12923,15 +13033,44 @@ bool wallet2::check_spend_proof(const crypto::hash &txid, const std::string &mes
|
||||
void wallet2::check_tx_key(const crypto::hash &txid, const crypto::secret_key &tx_key, const std::vector<crypto::secret_key> &additional_tx_keys, const cryptonote::account_public_address &address, uint64_t &received, bool &in_pool, uint64_t &confirmations)
|
||||
{
|
||||
crypto::key_derivation derivation;
|
||||
THROW_WALLET_EXCEPTION_IF(!crypto::generate_key_derivation(address.m_view_public_key, tx_key, derivation), error::wallet_internal_error,
|
||||
"Failed to generate key derivation from supplied parameters");
|
||||
|
||||
std::vector<crypto::key_derivation> additional_derivations;
|
||||
additional_derivations.resize(additional_tx_keys.size());
|
||||
for (size_t i = 0; i < additional_tx_keys.size(); ++i)
|
||||
THROW_WALLET_EXCEPTION_IF(!crypto::generate_key_derivation(address.m_view_public_key, additional_tx_keys[i], additional_derivations[i]), error::wallet_internal_error,
|
||||
if (address.m_is_carrot)
|
||||
{
|
||||
// For Carrot enotes, use X25519 scalar multiplication
|
||||
mx25519_pubkey s_sender_receiver_unctx;
|
||||
bool success = carrot::make_carrot_uncontextualized_shared_key_sender(
|
||||
tx_key,
|
||||
address.m_view_public_key,
|
||||
s_sender_receiver_unctx);
|
||||
THROW_WALLET_EXCEPTION_IF(!success, error::wallet_internal_error,
|
||||
"Failed to generate X25519 key derivation from supplied parameters (main)");
|
||||
derivation = carrot::raw_byte_convert<crypto::key_derivation>(s_sender_receiver_unctx);
|
||||
|
||||
additional_derivations.resize(additional_tx_keys.size());
|
||||
for (size_t i = 0; i < additional_tx_keys.size(); ++i)
|
||||
{
|
||||
mx25519_pubkey additional_s_sender_receiver_unctx;
|
||||
success = carrot::make_carrot_uncontextualized_shared_key_sender(
|
||||
additional_tx_keys[i],
|
||||
address.m_view_public_key,
|
||||
additional_s_sender_receiver_unctx);
|
||||
THROW_WALLET_EXCEPTION_IF(!success, error::wallet_internal_error,
|
||||
"Failed to generate X25519 key derivation from supplied parameters (additional)");
|
||||
additional_derivations[i] = carrot::raw_byte_convert<crypto::key_derivation>(additional_s_sender_receiver_unctx);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// For legacy enotes, use Edwards curve multiplication
|
||||
THROW_WALLET_EXCEPTION_IF(!crypto::generate_key_derivation(address.m_view_public_key, tx_key, derivation), error::wallet_internal_error,
|
||||
"Failed to generate key derivation from supplied parameters");
|
||||
|
||||
additional_derivations.resize(additional_tx_keys.size());
|
||||
for (size_t i = 0; i < additional_tx_keys.size(); ++i)
|
||||
THROW_WALLET_EXCEPTION_IF(!crypto::generate_key_derivation(address.m_view_public_key, additional_tx_keys[i], additional_derivations[i]), error::wallet_internal_error,
|
||||
"Failed to generate key derivation from supplied parameters");
|
||||
}
|
||||
|
||||
check_tx_key_helper(txid, derivation, additional_derivations, address, received, in_pool, confirmations);
|
||||
}
|
||||
|
||||
@@ -12939,8 +13078,9 @@ void wallet2::check_tx_key_helper(const cryptonote::transaction &tx, const crypt
|
||||
{
|
||||
received = 0;
|
||||
|
||||
const bool use_additional_derivations = !additional_derivations.empty() && address.m_is_carrot;
|
||||
const auto enote_scan_infos = wallet::view_incoming_scan_transaction_as_sender(tx,
|
||||
{&derivation, 1},
|
||||
use_additional_derivations ? epee::span<const crypto::key_derivation>{} : epee::span<const crypto::key_derivation>{&derivation, 1},
|
||||
epee::to_span(additional_derivations),
|
||||
address);
|
||||
|
||||
|
||||
+29
-4
@@ -496,9 +496,10 @@ private:
|
||||
bool m_coinbase;
|
||||
cryptonote::subaddress_index m_subaddr_index;
|
||||
cryptonote::transaction_type m_tx_type;
|
||||
bool m_is_carrot;
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
VERSION_FIELD(0)
|
||||
VERSION_FIELD(1)
|
||||
FIELD(m_tx_hash)
|
||||
VARINT_FIELD(m_amount)
|
||||
FIELD(m_asset_type)
|
||||
@@ -510,6 +511,11 @@ private:
|
||||
FIELD(m_coinbase)
|
||||
FIELD(m_subaddr_index)
|
||||
VARINT_FIELD(m_tx_type)
|
||||
if (version < 1) {
|
||||
m_is_carrot = false;
|
||||
return true;
|
||||
}
|
||||
FIELD(m_is_carrot)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
@@ -1197,8 +1203,9 @@ private:
|
||||
std::vector<crypto::public_key> get_subaddress_spend_public_keys(uint32_t account, uint32_t begin, uint32_t end) const;
|
||||
//std::string get_subaddress_as_str(const cryptonote::subaddress_index& index) const;
|
||||
std::string get_subaddress_as_str(const carrot::subaddress_index_extended& index) const;
|
||||
std::string get_subaddress_as_str(const carrot::subaddress_index_extended& index, const uint64_t height) const;
|
||||
std::string get_address_as_str() const { return get_subaddress_as_str({0, 0}); }
|
||||
std::string get_integrated_address_as_str(const crypto::hash8& payment_id) const;
|
||||
std::string get_integrated_address_as_str(const crypto::hash8& payment_id, bool carrot = true) const;
|
||||
void add_subaddress_account(const std::string& label);
|
||||
size_t get_num_subaddress_accounts() const { return m_subaddress_labels.size(); }
|
||||
size_t get_num_subaddresses(uint32_t index_major) const { return index_major < m_subaddress_labels.size() ? m_subaddress_labels[index_major].size() : 0; }
|
||||
@@ -1470,7 +1477,7 @@ private:
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
MAGIC_FIELD("monero wallet cache")
|
||||
VERSION_FIELD(2)
|
||||
VERSION_FIELD(3)
|
||||
FIELD(m_blockchain)
|
||||
FIELD(m_transfers)
|
||||
FIELD(m_transfers_indices)
|
||||
@@ -1514,6 +1521,14 @@ private:
|
||||
}
|
||||
FIELD(m_background_sync_data)
|
||||
FIELD(m_subaddresses_extended)
|
||||
if (version == 2)
|
||||
{
|
||||
serializable_unordered_map<crypto::public_key, carrot::return_output_info_retired_t> old_roi;
|
||||
FIELD(old_roi)
|
||||
m_return_output_info = {};
|
||||
m_force_rescan = true;
|
||||
return true;
|
||||
}
|
||||
FIELD(m_return_output_info)
|
||||
END_SERIALIZE()
|
||||
|
||||
@@ -1548,6 +1563,8 @@ private:
|
||||
void set_default_priority(uint32_t p) { m_default_priority = p; }
|
||||
bool auto_refresh() const { return m_auto_refresh; }
|
||||
void auto_refresh(bool r) { m_auto_refresh = r; }
|
||||
bool force_rescan() const { return m_force_rescan; }
|
||||
void force_rescan(bool r) { m_force_rescan = r; }
|
||||
AskPasswordType ask_password() const { return m_ask_password; }
|
||||
void ask_password(AskPasswordType ask) { m_ask_password = ask; }
|
||||
void set_min_output_count(uint32_t count) { m_min_output_count = count; }
|
||||
@@ -1661,6 +1678,7 @@ private:
|
||||
size_t get_num_transfer_details() const { return m_transfers.size(); }
|
||||
const transfer_details &get_transfer_details(size_t idx) const;
|
||||
|
||||
uint8_t estimate_current_hard_fork(const uint64_t height = 0) const;
|
||||
uint8_t get_current_hard_fork();
|
||||
void get_hard_fork_info(uint8_t version, uint64_t &earliest_height);
|
||||
bool use_fork_rules(uint8_t version, int64_t early_blocks = 0);
|
||||
@@ -2192,6 +2210,7 @@ private:
|
||||
uint32_t m_default_priority;
|
||||
RefreshType m_refresh_type;
|
||||
bool m_auto_refresh;
|
||||
bool m_force_rescan = false;
|
||||
bool m_first_refresh_done;
|
||||
uint64_t m_refresh_from_block_height;
|
||||
// If m_refresh_from_block_height is explicitly set to zero we need this to differentiate it from the case that
|
||||
@@ -2293,7 +2312,7 @@ BOOST_CLASS_VERSION(tools::wallet2::transfer_details, 12)
|
||||
BOOST_CLASS_VERSION(tools::wallet2::multisig_info, 1)
|
||||
BOOST_CLASS_VERSION(tools::wallet2::multisig_info::LR, 0)
|
||||
BOOST_CLASS_VERSION(tools::wallet2::multisig_tx_set, 1)
|
||||
BOOST_CLASS_VERSION(tools::wallet2::payment_details, 5)
|
||||
BOOST_CLASS_VERSION(tools::wallet2::payment_details, 6)
|
||||
BOOST_CLASS_VERSION(tools::wallet2::pool_payment_details, 1)
|
||||
BOOST_CLASS_VERSION(tools::wallet2::unconfirmed_transfer_details, 8)
|
||||
BOOST_CLASS_VERSION(tools::wallet2::confirmed_transfer_details, 6)
|
||||
@@ -2622,6 +2641,12 @@ namespace boost
|
||||
a & x.m_amounts;
|
||||
a & x.m_asset_type;
|
||||
a & x.m_tx_type;
|
||||
if (ver < 6)
|
||||
{
|
||||
x.m_is_carrot = false;
|
||||
return;
|
||||
}
|
||||
a & x.m_is_carrot;
|
||||
}
|
||||
|
||||
template <class Archive>
|
||||
|
||||
@@ -439,7 +439,7 @@ namespace tools
|
||||
entry.subaddr_index = pd.m_subaddr_index;
|
||||
entry.subaddr_indices.push_back(pd.m_subaddr_index);
|
||||
//entry.address = m_wallet->get_subaddress_as_str(pd.m_subaddr_index);
|
||||
bool is_carrot = m_wallet->get_current_hard_fork() >= HF_VERSION_CARROT;
|
||||
bool is_carrot = m_wallet->estimate_current_hard_fork(entry.height) >= HF_VERSION_CARROT;
|
||||
entry.address = m_wallet->get_subaddress_as_str({{pd.m_subaddr_index.major, pd.m_subaddr_index.minor}, is_carrot ? carrot::AddressDeriveType::Carrot : carrot::AddressDeriveType::PreCarrot});
|
||||
set_confirmations(entry, m_wallet->get_blockchain_current_height(), m_wallet->get_last_block_reward(), pd.m_unlock_time);
|
||||
}
|
||||
@@ -473,7 +473,7 @@ namespace tools
|
||||
for (uint32_t i: pd.m_subaddr_indices)
|
||||
entry.subaddr_indices.push_back({pd.m_subaddr_account, i});
|
||||
//entry.address = m_wallet->get_subaddress_as_str({pd.m_subaddr_account, 0});
|
||||
bool is_carrot = m_wallet->get_current_hard_fork() >= HF_VERSION_CARROT;
|
||||
bool is_carrot = m_wallet->estimate_current_hard_fork(entry.height) >= HF_VERSION_CARROT;
|
||||
entry.address = m_wallet->get_subaddress_as_str({{pd.m_subaddr_account, 0}, is_carrot ? carrot::AddressDeriveType::Carrot : carrot::AddressDeriveType::PreCarrot});
|
||||
set_confirmations(entry, m_wallet->get_blockchain_current_height(), m_wallet->get_last_block_reward(), pd.m_unlock_time);
|
||||
}
|
||||
@@ -508,7 +508,7 @@ namespace tools
|
||||
for (uint32_t i: pd.m_subaddr_indices)
|
||||
entry.subaddr_indices.push_back({pd.m_subaddr_account, i});
|
||||
//entry.address = m_wallet->get_subaddress_as_str({pd.m_subaddr_account, 0});
|
||||
bool is_carrot = m_wallet->get_current_hard_fork() >= HF_VERSION_CARROT;
|
||||
bool is_carrot = m_wallet->estimate_current_hard_fork(entry.height) >= HF_VERSION_CARROT;
|
||||
entry.address = m_wallet->get_subaddress_as_str({{pd.m_subaddr_account, 0}, is_carrot ? carrot::AddressDeriveType::Carrot : carrot::AddressDeriveType::PreCarrot});
|
||||
set_confirmations(entry, m_wallet->get_blockchain_current_height(), m_wallet->get_last_block_reward(), pd.m_tx.unlock_time);
|
||||
}
|
||||
@@ -533,7 +533,7 @@ namespace tools
|
||||
entry.subaddr_index = pd.m_subaddr_index;
|
||||
entry.subaddr_indices.push_back(pd.m_subaddr_index);
|
||||
//entry.address = m_wallet->get_subaddress_as_str(pd.m_subaddr_index);
|
||||
bool is_carrot = m_wallet->get_current_hard_fork() >= HF_VERSION_CARROT;
|
||||
bool is_carrot = m_wallet->estimate_current_hard_fork(entry.height) >= HF_VERSION_CARROT;
|
||||
entry.address = m_wallet->get_subaddress_as_str({{pd.m_subaddr_index.major, pd.m_subaddr_index.minor}, is_carrot ? carrot::AddressDeriveType::Carrot : carrot::AddressDeriveType::PreCarrot});
|
||||
set_confirmations(entry, m_wallet->get_blockchain_current_height(), m_wallet->get_last_block_reward(), pd.m_unlock_time);
|
||||
}
|
||||
@@ -542,8 +542,8 @@ namespace tools
|
||||
{
|
||||
if (!m_wallet) return not_open(er);
|
||||
|
||||
bool is_carrot = m_wallet->get_current_hard_fork() >= HF_VERSION_CARROT;
|
||||
|
||||
bool is_carrot = m_wallet->estimate_current_hard_fork() >= HF_VERSION_CARROT;
|
||||
|
||||
std::vector<std::string> assets_in_wallet = m_wallet->list_asset_types();
|
||||
std::string asset_type = req.asset_type.empty() ? "SAL1" : boost::algorithm::to_upper_copy(req.asset_type);
|
||||
// verify that the asset is in the list of in-wallet assets
|
||||
@@ -627,8 +627,6 @@ namespace tools
|
||||
{
|
||||
if (!m_wallet) return not_open(er);
|
||||
|
||||
bool is_carrot = m_wallet->get_current_hard_fork() >= HF_VERSION_CARROT;
|
||||
|
||||
try
|
||||
{
|
||||
THROW_WALLET_EXCEPTION_IF(req.account_index >= m_wallet->get_num_subaddress_accounts(), error::account_index_outofbound);
|
||||
@@ -651,8 +649,9 @@ namespace tools
|
||||
res.addresses.resize(res.addresses.size() + 1);
|
||||
auto& info = res.addresses.back();
|
||||
const cryptonote::subaddress_index index = {req.account_index, i};
|
||||
//info.address = m_wallet->get_subaddress_as_str(index);
|
||||
info.address = m_wallet->get_subaddress_as_str({{req.account_index, i}, is_carrot ? carrot::AddressDeriveType::Carrot : carrot::AddressDeriveType::PreCarrot});
|
||||
info.address = m_wallet->get_subaddress_as_str({req.account_index, i});
|
||||
info.address_cn = req.cryptonote ? m_wallet->get_subaddress_as_str({{req.account_index, i}, carrot::AddressDeriveType::PreCarrot}) : "";
|
||||
info.address_carrot = req.carrot ? m_wallet->get_subaddress_as_str({{req.account_index, i}, carrot::AddressDeriveType::Carrot}) : "";
|
||||
info.label = m_wallet->get_subaddress_label(index);
|
||||
info.address_index = index.minor;
|
||||
info.used = std::find_if(transfers.begin(), transfers.end(), [&](const tools::wallet2::transfer_details& td) { return td.m_subaddr_index == index; }) != transfers.end();
|
||||
@@ -746,8 +745,6 @@ namespace tools
|
||||
{
|
||||
if (!m_wallet) return not_open(er);
|
||||
|
||||
bool is_carrot = m_wallet->get_current_hard_fork() >= HF_VERSION_CARROT;
|
||||
|
||||
try
|
||||
{
|
||||
res.total_balance = 0;
|
||||
@@ -768,8 +765,7 @@ namespace tools
|
||||
continue;
|
||||
wallet_rpc::COMMAND_RPC_GET_ACCOUNTS::subaddress_account_info info;
|
||||
info.account_index = subaddr_index.major;
|
||||
//info.base_address = m_wallet->get_subaddress_as_str(subaddr_index);
|
||||
info.base_address = m_wallet->get_subaddress_as_str({{subaddr_index.major, subaddr_index.minor}, is_carrot ? carrot::AddressDeriveType::Carrot : carrot::AddressDeriveType::PreCarrot});
|
||||
info.base_address = m_wallet->get_subaddress_as_str({{subaddr_index.major, 0}, carrot::AddressDeriveType::Auto});
|
||||
|
||||
//for (const auto& asset: asset_types) {
|
||||
info.balance = m_wallet->balance(subaddr_index.major, "SAL1", req.strict_balances);
|
||||
@@ -2103,8 +2099,6 @@ namespace tools
|
||||
{
|
||||
if (!m_wallet) return not_open(er);
|
||||
|
||||
bool is_carrot = m_wallet->get_current_hard_fork() >= HF_VERSION_CARROT;
|
||||
|
||||
crypto::hash payment_id;
|
||||
crypto::hash8 payment_id8;
|
||||
cryptonote::blobdata payment_id_blob;
|
||||
@@ -2145,7 +2139,7 @@ namespace tools
|
||||
rpc_payment.unlock_time = payment.m_unlock_time;
|
||||
rpc_payment.locked = !m_wallet->is_transfer_unlocked(payment.m_unlock_time, payment.m_block_height);
|
||||
rpc_payment.subaddr_index = payment.m_subaddr_index;
|
||||
//rpc_payment.address = m_wallet->get_subaddress_as_str(payment.m_subaddr_index);
|
||||
bool is_carrot = m_wallet->estimate_current_hard_fork(payment.m_block_height) >= HF_VERSION_CARROT;
|
||||
rpc_payment.address = m_wallet->get_subaddress_as_str({{payment.m_subaddr_index.major, payment.m_subaddr_index.minor}, is_carrot ? carrot::AddressDeriveType::Carrot : carrot::AddressDeriveType::PreCarrot});
|
||||
res.payments.push_back(rpc_payment);
|
||||
}
|
||||
@@ -2157,8 +2151,6 @@ namespace tools
|
||||
{
|
||||
res.payments.clear();
|
||||
|
||||
bool is_carrot = m_wallet->get_current_hard_fork() >= HF_VERSION_CARROT;
|
||||
|
||||
if (!m_wallet) return not_open(er);
|
||||
|
||||
/* If the payment ID list is empty, we get payments to any payment ID (or lack thereof) */
|
||||
@@ -2176,7 +2168,7 @@ namespace tools
|
||||
rpc_payment.block_height = payment.second.m_block_height;
|
||||
rpc_payment.unlock_time = payment.second.m_unlock_time;
|
||||
rpc_payment.subaddr_index = payment.second.m_subaddr_index;
|
||||
//rpc_payment.address = m_wallet->get_subaddress_as_str(payment.second.m_subaddr_index);
|
||||
bool is_carrot = m_wallet->estimate_current_hard_fork(payment.second.m_block_height) >= HF_VERSION_CARROT;
|
||||
rpc_payment.address = m_wallet->get_subaddress_as_str({{payment.second.m_subaddr_index.major, payment.second.m_subaddr_index.minor}, is_carrot ? carrot::AddressDeriveType::Carrot : carrot::AddressDeriveType::PreCarrot});
|
||||
rpc_payment.locked = !m_wallet->is_transfer_unlocked(payment.second.m_unlock_time, payment.second.m_block_height);
|
||||
res.payments.push_back(std::move(rpc_payment));
|
||||
@@ -2232,7 +2224,7 @@ namespace tools
|
||||
rpc_payment.block_height = payment.m_block_height;
|
||||
rpc_payment.unlock_time = payment.m_unlock_time;
|
||||
rpc_payment.subaddr_index = payment.m_subaddr_index;
|
||||
//rpc_payment.address = m_wallet->get_subaddress_as_str(payment.m_subaddr_index);
|
||||
bool is_carrot = m_wallet->estimate_current_hard_fork(payment.m_block_height) >= HF_VERSION_CARROT;
|
||||
rpc_payment.address = m_wallet->get_subaddress_as_str({{payment.m_subaddr_index.major, payment.m_subaddr_index.minor}, is_carrot ? carrot::AddressDeriveType::Carrot : carrot::AddressDeriveType::PreCarrot});
|
||||
rpc_payment.locked = !m_wallet->is_transfer_unlocked(payment.m_unlock_time, payment.m_block_height);
|
||||
res.payments.push_back(std::move(rpc_payment));
|
||||
@@ -2363,6 +2355,55 @@ namespace tools
|
||||
epee::wipeable_string key = epee::to_hex::wipeable_string(m_wallet->get_account().get_keys().m_spend_secret_key);
|
||||
res.key = std::string(key.data(), key.size());
|
||||
}
|
||||
else if(req.key_type.compare("s_master") == 0)
|
||||
{
|
||||
if (m_wallet->watch_only())
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_WATCH_ONLY;
|
||||
er.message = "The wallet is watch-only. Cannot retrieve s_master key.";
|
||||
return false;
|
||||
}
|
||||
CHECK_IF_BACKGROUND_SYNCING();
|
||||
epee::wipeable_string key = epee::to_hex::wipeable_string(m_wallet->get_account().get_keys().s_master);
|
||||
res.key = std::string(key.data(), key.size());
|
||||
}
|
||||
else if(req.key_type.compare("k_prove_spend") == 0)
|
||||
{
|
||||
if (m_wallet->watch_only())
|
||||
{
|
||||
er.code = WALLET_RPC_ERROR_CODE_WATCH_ONLY;
|
||||
er.message = "The wallet is watch-only. Cannot retrieve k_prove_spend key.";
|
||||
return false;
|
||||
}
|
||||
CHECK_IF_BACKGROUND_SYNCING();
|
||||
epee::wipeable_string key = epee::to_hex::wipeable_string(m_wallet->get_account().get_keys().k_prove_spend);
|
||||
res.key = std::string(key.data(), key.size());
|
||||
}
|
||||
else if(req.key_type.compare("s_view_balance") == 0)
|
||||
{
|
||||
epee::wipeable_string key = epee::to_hex::wipeable_string(m_wallet->get_account().get_keys().s_view_balance);
|
||||
res.key = std::string(key.data(), key.size());
|
||||
}
|
||||
else if(req.key_type.compare("s_view_balance") == 0)
|
||||
{
|
||||
epee::wipeable_string key = epee::to_hex::wipeable_string(m_wallet->get_account().get_keys().s_view_balance);
|
||||
res.key = std::string(key.data(), key.size());
|
||||
}
|
||||
else if(req.key_type.compare("k_view_incoming") == 0)
|
||||
{
|
||||
epee::wipeable_string key = epee::to_hex::wipeable_string(m_wallet->get_account().get_keys().k_view_incoming);
|
||||
res.key = std::string(key.data(), key.size());
|
||||
}
|
||||
else if(req.key_type.compare("k_generate_image") == 0)
|
||||
{
|
||||
epee::wipeable_string key = epee::to_hex::wipeable_string(m_wallet->get_account().get_keys().k_generate_image);
|
||||
res.key = std::string(key.data(), key.size());
|
||||
}
|
||||
else if(req.key_type.compare("s_generate_address") == 0)
|
||||
{
|
||||
epee::wipeable_string key = epee::to_hex::wipeable_string(m_wallet->get_account().get_keys().s_generate_address);
|
||||
res.key = std::string(key.data(), key.size());
|
||||
}
|
||||
else
|
||||
{
|
||||
er.message = "key_type " + req.key_type + " not found";
|
||||
@@ -3313,9 +3354,9 @@ namespace tools
|
||||
const auto &entry = ab[idx];
|
||||
std::string address;
|
||||
if (entry.m_has_payment_id)
|
||||
address = cryptonote::get_account_integrated_address_as_str(m_wallet->nettype(), entry.m_address, entry.m_payment_id, entry.m_is_carrot);
|
||||
address = cryptonote::get_account_integrated_address_as_str(m_wallet->nettype(), entry.m_address, entry.m_payment_id);
|
||||
else
|
||||
address = get_account_address_as_str(m_wallet->nettype(), entry.m_is_subaddress, entry.m_address, entry.m_is_carrot);
|
||||
address = get_account_address_as_str(m_wallet->nettype(), entry.m_is_subaddress, entry.m_address);
|
||||
res.entries.push_back(wallet_rpc::COMMAND_RPC_GET_ADDRESS_BOOK_ENTRY::entry{idx, address, entry.m_description});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,9 +139,13 @@ namespace wallet_rpc
|
||||
{
|
||||
uint32_t account_index;
|
||||
std::vector<uint32_t> address_index;
|
||||
bool carrot;
|
||||
bool cryptonote;
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(account_index)
|
||||
KV_SERIALIZE(address_index)
|
||||
KV_SERIALIZE_OPT(carrot, true);
|
||||
KV_SERIALIZE_OPT(cryptonote, true);
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
typedef epee::misc_utils::struct_init<request_t> request;
|
||||
@@ -149,12 +153,16 @@ namespace wallet_rpc
|
||||
struct address_info
|
||||
{
|
||||
std::string address;
|
||||
std::string address_cn;
|
||||
std::string address_carrot;
|
||||
std::string label;
|
||||
uint32_t address_index;
|
||||
bool used;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(address)
|
||||
KV_SERIALIZE(address_cn)
|
||||
KV_SERIALIZE(address_carrot)
|
||||
KV_SERIALIZE(label)
|
||||
KV_SERIALIZE(address_index)
|
||||
KV_SERIALIZE(used)
|
||||
|
||||
+3637
-3375
File diff suppressed because it is too large
Load Diff
+3833
-3572
File diff suppressed because one or more lines are too long
+3832
-3571
File diff suppressed because it is too large
Load Diff
+3973
-3712
File diff suppressed because one or more lines are too long
+3832
-3571
File diff suppressed because it is too large
Load Diff
+3832
-3571
File diff suppressed because one or more lines are too long
+3832
-3571
File diff suppressed because it is too large
Load Diff
+3832
-3571
File diff suppressed because it is too large
Load Diff
+3832
-3571
File diff suppressed because one or more lines are too long
+3832
-3571
File diff suppressed because it is too large
Load Diff
+3832
-3571
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user