From 77cf47f9610b758fa38421b2ebf750f77a8cab9c Mon Sep 17 00:00:00 2001 From: edtubbs Date: Mon, 4 Nov 2024 13:58:32 -0600 Subject: [PATCH 1/2] ci: updated runner to macos-13 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c0fd0e444..f39380e22 100755 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,7 +81,7 @@ jobs: goal: install - name: x86_64-macos host: x86_64-apple-darwin15 - os: macos-12 + os: macos-13 run-tests: true dep-opts: "SPEED=slow V=1" config-opts: "--enable-static --disable-shared --enable-test-passwd" From 4bd9c87604a2d34fe61b14d35c33c304afc9bb08 Mon Sep 17 00:00:00 2001 From: edtubbs Date: Mon, 16 Dec 2024 16:32:01 -0600 Subject: [PATCH 2/2] rest: added utxo confirmations chainparams: added recent checkpoint wallet: added utxo confirmations, moved utxos init to scrape --- include/dogecoin/chainparams.h | 2 +- include/dogecoin/wallet.h | 2 ++ src/chainparams.c | 3 ++- src/rest.c | 1 + src/wallet.c | 15 +++++++++++++-- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/include/dogecoin/chainparams.h b/include/dogecoin/chainparams.h index 5830149eb..6f548ef96 100644 --- a/include/dogecoin/chainparams.h +++ b/include/dogecoin/chainparams.h @@ -68,7 +68,7 @@ extern const dogecoin_chainparams dogecoin_chainparams_test; extern const dogecoin_chainparams dogecoin_chainparams_regtest; // the mainnet checkpoints, needs a fix size -extern const dogecoin_checkpoint dogecoin_mainnet_checkpoint_array[23]; +extern const dogecoin_checkpoint dogecoin_mainnet_checkpoint_array[24]; extern const dogecoin_checkpoint dogecoin_testnet_checkpoint_array[19]; LIBDOGECOIN_API const dogecoin_chainparams* chain_from_b58_prefix(const char* address); diff --git a/include/dogecoin/wallet.h b/include/dogecoin/wallet.h index 38ffb4a98..c3eabfce2 100644 --- a/include/dogecoin/wallet.h +++ b/include/dogecoin/wallet.h @@ -59,6 +59,7 @@ typedef struct dogecoin_utxo_ { char script_pubkey[SCRIPT_PUBKEY_STRINGLEN]; char amount[KOINU_STRINGLEN]; int confirmations; + int height; dogecoin_bool spendable; dogecoin_bool solvable; UT_hash_handle hh; @@ -125,6 +126,7 @@ LIBDOGECOIN_API void remove_dogecoin_utxo(dogecoin_utxo* utxo); LIBDOGECOIN_API void remove_all_utxos(); LIBDOGECOIN_API void dogecoin_wallet_utxo_free(dogecoin_utxo* utxo); LIBDOGECOIN_API void dogecoin_wallet_scrape_utxos(dogecoin_wallet* wallet, dogecoin_wtx* wtx); +LIBDOGECOIN_API void dogecoin_wallet_utxos_update_confirmations(int height); /** ------------------------------------ */ /** wallet addr functions */ diff --git a/src/chainparams.c b/src/chainparams.c index 8eaa73dd1..ca6cce570 100644 --- a/src/chainparams.c +++ b/src/chainparams.c @@ -109,7 +109,8 @@ const dogecoin_checkpoint dogecoin_mainnet_checkpoint_array[] = { {3854173, "e4b4ecda4c022406c502a247c0525480268ce7abbbef632796e8ca1646425e75", 1628934997, 0x1a03ca36}, {3963597, "2b6927cfaa5e82353d45f02be8aadd3bfd165ece5ce24b9bfa4db20432befb5d", 1635884460, 0x1a037bc9}, {4303965, "ed7d266dcbd8bb8af80f9ccb8deb3e18f9cc3f6972912680feeb37b090f8cee0", 1657646310, 0x1a0344f5}, - {5050000, "e7d4577405223918491477db725a393bcfc349d8ee63b0a4fde23cbfbfd81dea", 1705383360, 0x1a019541}}; + {5050000, "e7d4577405223918491477db725a393bcfc349d8ee63b0a4fde23cbfbfd81dea", 1705383360, 0x1a019541}, + {5400000, "cbb1f4ae807da83e13bdf9c28188982938c9ee6bf560c1023f51adac229eef87", 1727704957, 0x0106DAC9}}; const dogecoin_checkpoint dogecoin_testnet_checkpoint_array[] = { {0, "bb0a78264637406b6360aad926284d544d7049f45189db5664f3c4d07350559e", 1391503289, 0x1e0ffff0}, diff --git a/src/rest.c b/src/rest.c index 75cc7ae91..bb6773fe0 100644 --- a/src/rest.c +++ b/src/rest.c @@ -120,6 +120,7 @@ void dogecoin_http_request_cb(struct evhttp_request *req, void *arg) { evbuffer_add_printf(evb, "address: %s\n", utxo->address); evbuffer_add_printf(evb, "script_pubkey: %s\n", utxo->script_pubkey); evbuffer_add_printf(evb, "amount: %s\n", utxo->amount); + evbuffer_add_printf(evb, "confirmations: %d\n", utxo->confirmations); evbuffer_add_printf(evb, "spendable: %d\n", utxo->spendable); evbuffer_add_printf(evb, "solvable: %d\n", utxo->solvable); wallet_total_u64_unspent += coins_to_koinu_str(utxo->amount); diff --git a/src/wallet.c b/src/wallet.c index 98b3128d7..6a46380d6 100644 --- a/src/wallet.c +++ b/src/wallet.c @@ -740,6 +740,8 @@ void dogecoin_wallet_scrape_utxos(dogecoin_wallet* wallet, dogecoin_wtx* wtx) { memcpy_safe(utxo->address, p2pkh_from_script_pubkey, P2PKHLEN); // set amount of utxo: koinu_to_coins_str(tx_out->value, utxo->amount); + // set the height of the utxo: + utxo->height = wtx->height; // finally add utxo to rbtree: dogecoin_btree_tfind(utxo, &wallet->unspent_rbtree, dogecoin_utxo_compare); add_dogecoin_utxo(utxo); @@ -749,8 +751,18 @@ void dogecoin_wallet_scrape_utxos(dogecoin_wallet* wallet, dogecoin_wtx* wtx) { vector_free(addrs, true); } } + + // update the wallet with the new utxos: + wallet->utxos = utxos; } +void dogecoin_wallet_utxos_update_confirmations(int height) { + dogecoin_utxo* utxo; + dogecoin_utxo* tmp; + HASH_ITER(hh, utxos, utxo, tmp) { + utxo->confirmations = height - utxo->height + 1; + } +} void dogecoin_wallet_add_wtx_intern_move(dogecoin_wallet *wallet, const dogecoin_wtx *wtx) { // check if wtx already exists dogecoin_wtx* checkwtx = dogecoin_btree_tfind(wtx, &wallet->wtxes_rbtree, dogecoin_wtx_compare); @@ -992,8 +1004,6 @@ dogecoin_bool dogecoin_wallet_load(dogecoin_wallet* wallet, const char* file_pat } } - wallet->utxos = utxos; - return true; } @@ -1519,6 +1529,7 @@ void dogecoin_wallet_check_transaction(void *ctx, dogecoin_tx *tx, unsigned int dogecoin_wallet_scrape_utxos(wallet, wtx); dogecoin_wallet_add_wtx_move(wallet, wtx); } + dogecoin_wallet_utxos_update_confirmations(pindex->height); } dogecoin_wallet* dogecoin_wallet_read(char* address) {