Skip to content

Commit

Permalink
wallet: add flush wallet to end of unregister node
Browse files Browse the repository at this point in the history
  • Loading branch information
xanimo committed Jul 8, 2023
1 parent 6820464 commit b632371
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
6 changes: 0 additions & 6 deletions src/cli/spvnode.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,6 @@ int main(int argc, char* argv[]) {
char *ptr = strtok(address_copy, delim);
while(ptr != NULL)
{
dogecoin_wallet* wallet = dogecoin_wallet_read(ptr);
waddr = dogecoin_wallet_addr_new();

if (!dogecoin_p2pkh_address_to_wallet_pubkeyhash(ptr, waddr, wallet)) {
exit(EXIT_FAILURE);
}
int res = dogecoin_register_watch_address_with_node(ptr);
printf("registered: %d %s\n", res, ptr);
uint64_t amount = dogecoin_get_balance(ptr);
Expand Down
3 changes: 2 additions & 1 deletion src/wallet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,6 @@ int dogecoin_unregister_watch_address_with_node(char* address) {
dogecoin_mem_zero(addresses, strlen(address));
for (; i < wallet->waddr_vector->len; i++) {
char* address_inner = vector_idx(wallet->waddr_vector, i);
size_t address_length = strlen(address_inner);
char p2pkh_tmp[35];
dogecoin_p2pkh_addr_from_hash160((const uint8_t*)address_inner, wallet->chain, p2pkh_tmp, 35);
if (strcmp(ptr, p2pkh_tmp)==0) {
Expand Down Expand Up @@ -1431,7 +1430,9 @@ int dogecoin_unregister_watch_address_with_node(char* address) {
if (found) {
rename("temp.bin", wallet->filename);
} else remove("temp.bin");
dogecoin_wallet_flush(wallet);
dogecoin_wallet_free(wallet);
dogecoin_wallet_free(wallet_new);
ptr = strtok(NULL, delim);
}
} else return false;
Expand Down

0 comments on commit b632371

Please sign in to comment.