Skip to content

Commit

Permalink
Make getDerivedHDAddress return address, not key
Browse files Browse the repository at this point in the history
  • Loading branch information
chromatic committed Jun 11, 2024
1 parent dc499c5 commit bdffe31
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
3 changes: 1 addition & 2 deletions src/address.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,8 +486,7 @@ int getDerivedHDAddress(const char* masterkey, uint32_t account, bool ischange,
return false;
}

int ret = getDerivedHDKeyByPath(masterkey, derived_path, outaddress, outprivkey);
return ret;
return getDerivedHDAddressByPath(masterkey, derived_path, outaddress);
}

/**
Expand Down
16 changes: 8 additions & 8 deletions test/address_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,28 +111,28 @@ void test_address()
char* masterkey_main_ext = "dgpv51eADS3spNJh8h13wso3DdDAw3EJRqWvftZyjTNCFEG7gqV6zsZmucmJR6xZfvgfmzUthVC6LNicBeNNDQdLiqjQJjPeZnxG8uW3Q3gCA3e";
int res = getDerivedHDAddress(masterkey_main_ext, 0, false, 0, extout, true);
u_assert_int_eq(res, true);
u_assert_str_eq(extout, "dgpv5BeiZXttUioRMzXUhD3s2uE9F23EhAwFu9meZeY9G99YS6hJCsQ9u6PRsAG3qfVwB1T7aQTVGLsmpxMiczV1dRDgzpbUxR7utpTRmN41iV7");
u_assert_str_eq(extout, "DCm7oSg95sxwn3sWxYUDHgKKbB2mDmuR3B");
res = getDerivedHDAddress(masterkey_main_ext, 0, true, 0, extout, true);
u_assert_int_eq(res, true);
u_assert_str_eq(extout, "dgpv5B5FdsPKQH8hK3vUo5ZR9ZXktfUxv1PStiM2TfnwH9oct5nJwAUx28356eNXoUwcNwzvfVRSDVh85aV3CQdKpQo2Vm8MKyz7KsNAXTEMbeS");
u_assert_str_eq(extout, "D91jVi3CVGhRmyt83fhMdL4UJWtDuiTZET");
res = getDerivedHDAddress(masterkey_main_ext, 0, false, 0, extout, false);
u_assert_int_eq(res, true);
u_assert_str_eq(extout, "dgub8vXjuDpn2sTkerBdjSfq9kmjhaQsXHxyBkYrikw84GCYz9ozcdwvYPo5SSDWqZUVT5d4jrG8CHiGsC1M7pdETPhoKiQa92znT2vG9YaytBH");
u_assert_str_eq(extout, "DCm7oSg95sxwn3sWxYUDHgKKbB2mDmuR3B");
res = getDerivedHDAddress(masterkey_main_ext, 0, true, 0, extout, false);
u_assert_int_eq(res, true);
u_assert_str_eq(extout, "dgub8uxGyZKCxRo2buadqKBPGR5MMDrbk8RABK8EcnBv5GrdS8u1Lw2ifRSifsT3wuVRsK45b9kugWkd2cREzkJLiGvwbY5txG2dKfsY3bndC93");
u_assert_str_eq(extout, "D91jVi3CVGhRmyt83fhMdL4UJWtDuiTZET");
res = getDerivedHDAddress(masterkey_main_ext, 1, false, 1, extout, true);
u_assert_int_eq(res, true);
u_assert_str_eq(extout, "dgpv5Ckgu5gakCr2g8NwFsi9aXXgBTXvzoFxwi8ybQHRmutQzYDoa8y4QD6w94EEYFtinVGD3ZzZG89t8pedriw9L8VgPYKeQsUHoZQaKcSEqwr");
u_assert_str_eq(extout, "D5Se361tds246n9Bm6diMQwkg7PfQrME65");
res = getDerivedHDAddress(masterkey_main_ext, 1, true, 1, extout, true);
u_assert_int_eq(res, true);
u_assert_str_eq(extout, "dgpv5CnqDfc6af4vKYLZQfyGgYYVQcgkiGwqAm1qEirxruSwXwSQJoTLjSckPkbZDXRQs7X83esTtoBEmy4zr4UgJBHb8T1EMc6HYCsWgKk4JRh");
u_assert_str_eq(extout, "DD5ztaSL3pscXYL6XXcRFTvbdghKppsKDn");
res = getDerivedHDAddress(masterkey_main_ext, 1, false, 1, extout, false);
u_assert_int_eq(res, true);
u_assert_str_eq(extout, "dgub8wdiEmcUJMWMxz36J7L7hP5Ge1uZpvHgEJvBkWgQa2wRYbLVyuWq3WWaiK3ZgYs893RqrgZN3QgRghPXkpRr7kdT44XVSaJuwMF1PTHi2mQ");
u_assert_str_eq(extout, "D5Se361tds246n9Bm6diMQwkg7PfQrME65");
res = getDerivedHDAddress(masterkey_main_ext, 1, true, 1, extout, false);
u_assert_int_eq(res, true);
u_assert_str_eq(extout, "dgub8wfrZMXz8ojFcPziSubEoQ65sB4PYPyYTMo3PqFwf2Vx5zZ6ia17Nk2Py25c3dvq1e7ZnfBrurCS5wuagzRoBCXhJ2NeGU54NBytvuUuRyA");
u_assert_str_eq(extout, "DD5ztaSL3pscXYL6XXcRFTvbdghKppsKDn");

// hardened paths (unabstracted as this is called by getDerivedHDAddress)
res = getDerivedHDKeyByPath(masterkey_main_ext, "m/44'/3'/0'/0/0", extout, true);
Expand Down

0 comments on commit bdffe31

Please sign in to comment.