Skip to content

Commit 78f5a31

Browse files
committed
get_subaccount_full_path: add is_internal
1 parent da1770f commit 78f5a31

File tree

6 files changed

+16
-8
lines changed

6 files changed

+16
-8
lines changed

src/ga_rust.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,13 @@ namespace sdk {
326326
return call_session("get_subaccount_root_path", nlohmann::json({ { "subaccount", subaccount } })).at("path");
327327
}
328328

329-
std::vector<uint32_t> ga_rust::get_subaccount_full_path(uint32_t subaccount, uint32_t pointer)
329+
std::vector<uint32_t> ga_rust::get_subaccount_full_path(uint32_t subaccount, uint32_t pointer, bool is_internal)
330330
{
331-
throw std::runtime_error("get_subaccount_full_path not implemented");
331+
// FIXME: do everything on the rust side
332+
std::vector<uint32_t> path = get_subaccount_root_path(subaccount);
333+
path.push_back(is_internal ? 1 : 0);
334+
path.push_back(pointer);
335+
return path;
332336
}
333337

334338
nlohmann::json ga_rust::get_available_currencies() const

src/ga_rust.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace sdk {
4444
void rename_subaccount(uint32_t subaccount, const std::string& new_name);
4545
void set_subaccount_hidden(uint32_t subaccount, bool is_hidden);
4646
std::vector<uint32_t> get_subaccount_root_path(uint32_t subaccount);
47-
std::vector<uint32_t> get_subaccount_full_path(uint32_t subaccount, uint32_t pointer);
47+
std::vector<uint32_t> get_subaccount_full_path(uint32_t subaccount, uint32_t pointer, bool is_internal);
4848

4949
nlohmann::json get_available_currencies() const;
5050

src/ga_session.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3137,7 +3137,8 @@ namespace sdk {
31373137
return ga_user_pubkeys::get_ga_subaccount_root_path(subaccount);
31383138
}
31393139

3140-
std::vector<uint32_t> ga_session::get_subaccount_full_path(uint32_t subaccount, uint32_t pointer)
3140+
std::vector<uint32_t> ga_session::get_subaccount_full_path(
3141+
uint32_t subaccount, uint32_t pointer, bool /*is_internal*/)
31413142
{
31423143
if (m_user_pubkeys) {
31433144
locker_t locker(m_mutex);

src/ga_session.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ namespace sdk {
155155
ga_user_pubkeys& get_recovery_pubkeys();
156156
bool has_recovery_pubkeys_subaccount(uint32_t subaccount);
157157
std::vector<uint32_t> get_subaccount_root_path(uint32_t subaccount);
158-
std::vector<uint32_t> get_subaccount_full_path(uint32_t subaccount, uint32_t pointer);
158+
std::vector<uint32_t> get_subaccount_full_path(uint32_t subaccount, uint32_t pointer, bool is_internal);
159159
std::string get_service_xpub(uint32_t subaccount);
160160
std::string get_recovery_xpub(uint32_t subaccount);
161161

src/ga_tx.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ namespace sdk {
4343
{
4444
const uint32_t subaccount = json_get_value(utxo, "subaccount", 0u);
4545
const uint32_t pointer = utxo.at("pointer");
46+
const bool is_internal = utxo.value("is_internal", false);
4647

4748
if (utxo.find("user_path") == utxo.end()) {
4849
// Populate the full user path for h/w signing
49-
utxo["user_path"] = session.get_subaccount_full_path(subaccount, pointer);
50+
utxo["user_path"] = session.get_subaccount_full_path(subaccount, pointer, is_internal);
5051
}
5152

5253
if (utxo.find("service_xpub") == utxo.end()) {
@@ -887,6 +888,7 @@ namespace sdk {
887888
const uint32_t subaccount = json_get_value(u, "subaccount", 0u);
888889
const uint32_t pointer = json_get_value(u, "pointer", 0u);
889890
const auto type = script_type(u.at("script_type"));
891+
const bool is_internal = json_get_value(u, "is_internal", false);
890892
const auto script = h2b(u.at("prevout_script"));
891893
const std::string private_key = json_get_value(u, "private_key");
892894
auto signer = session.get_nonnull_signer();
@@ -903,7 +905,7 @@ namespace sdk {
903905
tx_set_input_script(tx, index, scriptsig_p2pkh_from_der(h2b(u.at("public_key")), der));
904906
return b2h(der);
905907
} else {
906-
const auto path = session.get_subaccount_full_path(subaccount, pointer);
908+
const auto path = session.get_subaccount_full_path(subaccount, pointer, is_internal);
907909
const auto user_sig = signer->sign_hash(path, tx_hash);
908910
const auto der = ec_sig_to_der(user_sig, true);
909911

src/session_impl.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ namespace sdk {
110110
virtual void rename_subaccount(uint32_t subaccount, const std::string& new_name) = 0;
111111
virtual void set_subaccount_hidden(uint32_t subaccount, bool is_hidden) = 0;
112112
virtual std::vector<uint32_t> get_subaccount_root_path(uint32_t subaccount) = 0;
113-
virtual std::vector<uint32_t> get_subaccount_full_path(uint32_t subaccount, uint32_t pointer) = 0;
113+
virtual std::vector<uint32_t> get_subaccount_full_path(uint32_t subaccount, uint32_t pointer, bool is_internal)
114+
= 0;
114115

115116
virtual nlohmann::json get_available_currencies() const = 0;
116117

0 commit comments

Comments
 (0)