Skip to content

Commit

Permalink
Add node wallet utxo consolidation guide
Browse files Browse the repository at this point in the history
  • Loading branch information
h0ngcha0 committed Feb 18, 2024
1 parent 3557359 commit 1888987
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions docs/integration/mining.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,50 @@ In alephium, the size of the `nonce` is 24 bytes, and the hash of the block is:
### Checking the ChainIndex

In addition to checking the target, the miner also needs to check the chain index of the block as alephium encodes the chain index into the block hash. You can refer to the code provided [here](https://github.com/alephium/gpu-miner/blob/master/src/blake3/original-blake.hpp#LL303C2-L303C2) to check whether the chain index of the block hash is correct.

## UTXO Management

Due to the limited number of inputs that can be included in each transaction, withdrawals may fail if miner's wallet is filled with small UTXOs. In practice, some miners tend to send mining rewards directly to exchange addresses. If that is the case please follow the guide [here](/integration/exchange#utxo-management).

If node wallet is used for mining, here are the simpler and more efficient ways to consolidate the UTXOs.

### Consolidate UTXOs for the active address

```shell
# Consolidate UTXOs for the active address
curl -X 'POST' \
'http://127.0.0.1:22973/wallets/my-wallet/sweep-active-address' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"toAddress": "1C2RAVWSuaXw8xtUxqVERR7ChKBE1XgscNFw73NSHE1v3"
}'
```

Note that this will only consolidate the UTXOs for the active address. To consolidate UTXOs for other addresses, we need to update each of them as active address and run the same command above.

```shell
# Change active address
curl -X 'POST' \
'http://127.0.0.1:22973/wallets/my-wallet/change-active-address' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"address": "1AujpupFP4KWeZvqA7itsHY9cLJmx4qTzojVZrg8W9y"
}'
```

### Consolidate UTXOs for the all addresses

The simplest way to consolidate UTXOs for all the addresses in the node wallet is to use the `sweep-all-addresses` endpoint:

```shell
# Consolidate UTXOs for all addresses
curl -X 'POST' \
'http://127.0.0.1:22973/wallets/my-wallet/sweep-all-addresses \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"toAddress": "1C2RAVWSuaXw8xtUxqVERR7ChKBE1XgscNFw73NSHE1v3"
}'
```

0 comments on commit 1888987

Please sign in to comment.