Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/pktd/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Installation will depend on your system, for debian/ubuntu like systems you will

#### Install the components
Once you have golang and git fully installed and set up, you can use the following commands to
install pktd, pktwallet and pktctl.
install pktd, pktwallet and pldctl.

git clone https://github.com/pkt-cash/pktd
cd pktd
Expand Down
12 changes: 6 additions & 6 deletions docs/pktd/migrating_from_electrum.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ Follow the instructions in [pktwallet](./pktwallet) to get your wallet up and ru
* The key will look sometihng like this: `ci2TBp2HTWtyMQtizWMuugHxG6lNpInA1bSpLIWzjJS2AI8ObwV5`

## Step 3: Import key to pktwallet
* In a terminal window, run `pktctl --wallet getbalance` to verify that your wallet is working
* Unlock your wallet using `pktctl --wallet walletpassphrase <the password you used when setting it up> 1000000`
* Type `pktctl --wallet importprivkey <the key you just copied>`
* Unlock your wallet using `pldctl wallet/unlock --wallet_passphrase=<the password you used when setting it up>`
* In a terminal window, run `pldctl wallet/balance` to verify that your wallet is working
* Type `pldctl wallet/address/import --private_key=<the key you just copied>`
* You should see the address printed on the screen

## Importing more keys
* When you import a key, it starts a rescan of the chain automatically, in order to import more you need to stop
* `pktctl --wallet stopresync` to stop
* `pldctl wallet/address/stopresync` to stop

## Speed things up
If you know exactly when an address was paid, you can speed up the import by only rescanning blocks where it
might have been paid. For example if you are sure that the address was not paid earlier than block number 600000
you can do the following:

* `pktctl --wallet stopresync`
* `pktctl --wallet resync 600000 100000000`
* `pldctl wallet/address/stopresync`
* `pldctl wallet/address/resync --from_height=600000 --to_height=100000000`

## Check that it's working
It's recommended that you run pktwallet with `-d debug` flag in order to be able to see the debug logs.
Expand Down
165 changes: 93 additions & 72 deletions docs/pktd/pktwallet.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,46 +14,46 @@ The command line PKT wallet
- Download the most recent zip archive suffixed with `-windows.zip` available from
[pktd releases page](https://github.com/pkt-cash/pktd/releases)

For example: `pktd-v1.4.0-windows.zip`
For example: `pktd-v1.6.1-windows.zip`

- Unarchive the content of the zip file
- Open the command prompt and navigate to the bin directory in the extracted archive
- For Example: `cd Downloads\pktd*\bin`
- Follow the instructions below but
- In place of `./bin/pktwallet`, use `pktwallet.exe`
- In place of `./bin/pktctl`, use `pktctl.exe`
- In place of `./bin/pld`, use `pld.exe`
- In place of `./bin/pldctl`, use `pldctl.exe`

### MacOS and Linux

- Download one of the most recent packages available for Linux or MacOS from
[pktd releases page](https://github.com/pkt-cash/pktd/releases)

For example, for `pktd-v1.4.0` release:
For example, for `pktd-v1.6.1` release:

- For **MacOS**, after having downloaded `pktd-v1.4.0-macos.pkg`,
- For **MacOS**, after having downloaded `pktd-v1.6.1-macos.pkg`,
install `pktwallet` and other utilities by clicking on the package icon in the Finder.

- For **Linux**, after having downloaded one of the following packages:
- `pktd-v1.4.0-linux.deb` (Debian or Ubuntu)
- `pktd-v1.4.0-linux.rpm` (Fedora or RedHat)
- `pktd-v1.6.1-linux.deb` (Debian or Ubuntu)
- `pktd-v1.6.1-linux.rpm` (Fedora or RedHat)
- [pktd AUR package](https://aur.archlinux.org/packages/pktd) (Arch linux or Manjaro),
install `pktwallet` and other utilities by clicking
on the appropriate package icon or running an installation command

## Creating a New Wallet

To create a new PKT wallet, use the pktwallet --create command:
To create a new PKT wallet, use the pld --create command:

./bin/pktwallet --create
./bin/pld --create

You will be prompted to follow a few steps. Make sure you write your seed words on paper so that you can
recover your funds even if your computer is damaged. Do not skip this step. You will thank yourself later. Keep it secret. Keep it safe.

## Launching pktwallet
## Launching pld

After creating your wallet, you can launch pktwallet with:
After creating your wallet, you can launch pld with:

./bin/pktwallet
./bin/pld

Watch the output from the logs and when you see a log line like this:

Expand All @@ -64,13 +64,36 @@ Compare the height number in the log line (e.g. 702781) to the number in

## Creating a New PKT Address

While pktwallet is running in the background (or in another terminal), use the following command:
While pld is running in the background (or in another terminal), use the following command:

```bash
curl -X POST "Content-Type: application/json" -d '{}' http://localhost:8080/api/v1/wallet/address/create
```
or

./pldclt wallet/address/create

./bin/pktctl --wallet getnewaddress

You should see a series of numbers and letters beginning with `pkt1`. This is your newly created PKT address which you can use for receiving coins. If you need to view it after creation, the address, along with the balance, can be seen in the output from running:
Note: setting *showzerobalance* to true will show all addresses, even those with a zero balance.

```bash
curl -X POST "Content-Type: application/json" -d '{ "showzerobalance": true }' http://localhost:8080/api/v1/wallet/address/balances
```
or

./pldctl wallet/address/balances --showzerobalance

do

./bin/pktctl --wallet getaddressbalances 1 1
./pldclt wallet/address/balances

in order to see only addresses with a non-zero balance.

In order to view the total balance of your wallet including all the addresses, you can use:
```bash
curl http://localhost:8080/api/v1/wallet/balance
```

**NOTE**: Every time you use `getnewaddress`, the address you receive must be remembered by pktwallet forever. So, only use it when you actually need an address.

Expand All @@ -90,11 +113,11 @@ You should see a series of numbers and letters beginning with `pkt1`. This is yo
## How to install a CLI Wallet
If you already have a wallet created on your computer called wallet.db you will need to create a new wallet by following these steps:

1. Download [pktd-v1.5.1-macos.pkg](https://github.com/pkt-cash/pktd/releases/download/pktd-v1.5.1/pktd-v1.5.1-macos.pkg){target=_blank}
1. Download [pktd-v1.6.1-macos.pkg](https://github.com/pkt-cash/pktd/releases/download/pktd-v1.6.1/pktd-v1.6.1-macos.pkg){target=_blank}
2. Run the installation
3. Open Terminal
4. Enter the command: ```$ cd pktd```
5. Enter the command: ```$ ~/pktd/bin/pktwallet --create --wallet xxxx```
5. Enter the command: ```$ ~/pktd/bin/pld --create --wallet xxxx```
*`xxxx` is the name of the wallet i.e. wallet personal*
*Make sure to write this down for your notes*
6. Enter passphrase or leave empty
Expand All @@ -108,23 +131,23 @@ If you already have a wallet created on your computer called wallet.db you will
1. Open terminal
2. Enter the command: ```$ cd pktd```
3. Enter the command:
```$ ~/pktd/bin/pktwallet --wallet```
```$ ~/pktd/bin/pld --wallet xxxx```
*(whatever you named your wallet) i.e* ```wallet personal```

### How to create new PKT wallet address

1. Make sure you have the CLI wallet running in a separate terminal window
2. Open Terminal
3. Enter command: ```$ cd pktd```
4. Enter command: ```$ ~/pktd/bin/pktctl --wallet getnewaddress```
4. Enter command: ```$ ~/pktd/bin/pldctl wallet/address/create```
*Save your address in a safe place that is easily accessible*

### How to send PKT from your CLI wallet

1. Make sure you have the CLI wallet running in a separate terminal window
2. Open terminal
3. Enter command: ```$ cd pktd```
4. Enter Command: ```$ ~/pktd/pktd/bin/pktctl --wallet sendfrom pkt1xxxxx $$$$ '["pkt1xxxxx"]' ```
4. Enter Command: ```$ ~/pktd/pktd/bin/pldctl wallet/transaction/sendfrom --to_address=pkt1xxxxx --amount=$$$$ '--from_address=["pkt1xxxxx"]' ```
*xxxxx = PKT address you want to send from and to*
*$$$$ = amount of pkt you want to send*

Expand All @@ -135,7 +158,7 @@ If you already have a wallet created on your computer called wallet.db you will
2. Run the installation
3. Open Terminal
4. Enter the command: ```$ cd pktd```
5. Enter the command: ```$ ~/pktd/bin/pktwallet --create --wallet xxxx```
5. Enter the command: ```$ ~/pktd/bin/pld --create --wallet xxxx```
*xxxx is the name of the wallet i.e. wallet personal*
*Make sure to write this down for your notes*
6. Enter passphrase or leave empty
Expand All @@ -145,96 +168,76 @@ If you already have a wallet created on your computer called wallet.db you will
9. Start up wallet (see instructions above)
10. Open new terminal window
11. Enter the command: ```$ cd pktd```
12. Enter the command: ```$ ~/pktd/bin/pktctl --wallet getnewaddress```
12. Enter the command: ```$ ~/pktd/bin/pldctl wallet/address/create```
*repeat until you find receive (each of) your recovered wallet address(es)*
13. Enter the command: ```$ ~/pktd/bin/pktctl --wallet resync```
13. Enter the command: ```$ ~/pktd/bin/pldctl wallet/address/resync```
*This will resync the wallet to the blockchain (takes at least 24 hours)*
14. Enter the command: ```$ ~/pktd/bin/pktctl --wallet getaddressbalances 1 1```
14. Enter the command: ```$ ~/pktd/bin/pldctl wallet/address/balances```
*this is how you view all your (sub)wallet balances*


# Using Your Wallet

pktctl is the program that interfaces with a running pktwallet instance. pktctl functions will not work if pktwallet is not running and accessible. Some functions will be limited until pktwallet is fully synchronized. Some functions require the wallet being unlocked before executing.

## Getting Your Balance

You can check your current PKT balance using pktctl or you can check the balances of each of your addresses if you have more than one.

./bin/pktctl --wallet getbalance
pldctl is the program that interfaces with a running pktwallet instance. pldctl functions will not work if pktwallet is not running and accessible. Some functions will be limited until pktwallet is fully synchronized. Some functions require the wallet being unlocked before executing.

or:
## Unlocking Wallet

./bin/pktctl --wallet getaddressbalances
While many functions can be performed while the wallet is locked, other functions first require the wallet to be unlocked, including sending PKT and folding. The passphrase used to unlock the wallet was set when creating the wallet.

`getaddressbalances` by itself will not show 0 balance addresses you may have created. To show these addresses, use:
To keep your wallet unlocked, use:

./bin/pktctl --wallet getaddressbalances 1 1
./pldctl wallet/unlock --wallet_passphrase="pktdi3zkgr" --wallet_name="wallet_xxxxx.db"

For more explanation of the meaning of the output of `getaddressbalances`, use:
*xxxx refers to the wallet name you might have defined upon creation, otherwise the default wallet name is wallet.db and to unlock this --wallet_name is not needed*

./bin/pktctl --wallet help getaddressbalances
## Getting Your Balance

## Unlocking Wallet
You can check your current PKT balance using pldctl or you can check the balances of each of your addresses if you have more than one.

While many functions can be performed while the wallet is locked, other functions first require the wallet to be unlocked, including sending PKT and folding. The passphrase used to unlock the wallet was set when creating the wallet.
./bin/pldctl wallet/balance

To unlock your wallet for 120 seconds (this can be changed to your liking), use:
or:

./bin/pktctl --wallet walletpassphrase <passphrase you used when creating wallet> 120
To keep your wallet unlocked, use:
./bin/pldctl wallet/address/balances

./bin/pktctl --wallet walletpassphrase <passphrase you used when creating wallet> 0
If using `0` as in the previous example to keep your wallet indefinitely unlocked, it will stay unlocked until you either restart pktwallet or run:
`wallet/address/balances` by itself will not show 0 balance addresses you may have created. To show these addresses, use:

./bin/pktctl --wallet walletlock
./bin/pldctl wallet/address/balances --showzerobalance

**NOTE:** Special characters (e.g., !, #, & *) in your passphrase may be incorrectly interpreted by your shell. You may need to wrap your passphrase in quotes.
For more explanation of the meaning of the output of `getaddressbalances`, use:

./bin/pktctl --wallet walletpassphrase 'suP3r_S3cReT^P@s5W0Rd!' 120
./bin/pldctl help wallet/address/balances

## Sending PKT

You can send PKT using the `sendtoaddress` command, but first you must unlock your wallet for sending, as shown in the previous step.

To send cjd a 10 PKT tip:

./bin/pktctl --wallet sendtoaddress pkt1qt8xe7dwpelngtcpsgn5nkj3pwwdm7gf3l4auax 10

### Sending PKT from Specific Address

pktwallet gives you control over which addresses are used for making a payment. This means you can
keep different PKT in your wallet separate, for example separating business transactions from personal
transactions.
./bin/pldctl wallet/transaction/sendfrom --to_address=pkt1qt8xe7dwpelngtcpsgn5nkj3pwwdm7gf3l4auax --amount=10 '--from_address=["pkt1xxxxx"]

**NOTE**: PKT is _not_ a "privacy coin", so transactions are still shown in the blockchain
like with Bitcoin.

Unlock wallet:

./bin/pktctl --wallet walletpassphrase <passphrase you used when creating wallet> 60

Send 10 PKT to "their address" from "your address":

./bin/pktctl --wallet sendfrom <their address> 10 '["<your address>"]'
*pkt1xxxxx = PKT address you want to send from*

Notice the `'["`. This is because the last argument is actually a quoted
[JSON array](https://www.w3schools.com/js/js_json_arrays.asp). This means you can use multiple
addresses as the source of a payment. For example:

./bin/pktctl --wallet sendfrom <their address> 10 '["<your address>", "<your other address>"]'
./bin/pldctl wallet/transaction/sendfrom --to_address=pkt1xxxxx --amount=10 '--from_address=["pkt1yyyy1","pkt1yyyy2"]

*pkt1xxxx is their address, pkt1yyyy1 and pktyyyy2 is your PKT addresses to send from*

**Windows users require unique formatting for command prompt:**
>`pktctl.exe --wallet sendfrom <their address> 10 [\"<your address>\"]`
>`pldctl.exe wallet/transaction/sendfrom --to_address=<their address> --amount=10 --from_address=[\"<your address>\"]`

### Sweeping an Address

With pktwallet, sending 0 PKT has special significance in that it will send "as much PKT as possible".
To sweep `<old address>` address into `<new address>`, you can use the following command:

./bin/pktctl --wallet sendfrom <new address> 0 '["<old address>"]'
./bin/pldctl wallet/transaction/sendfrom --to_address=<new address> --amount=0 --from_address='["<old address>"]'

**Windows:**
>`pktctl.exe --wallet sendfrom <new address> 0 [\"<old address>\"]`
>`pldctl.exe wallet/transaction/sendfrom --to_address=<new address> --amount=0 --from_address=[\"<old address>\"]`

**NOTE**: Sweeping an address will send _as much PKT as possible_, which is not necessarily all PKT
in that address. You may need to sweep multiple times before the address is empty.
Expand All @@ -248,11 +251,29 @@ Folding is sweeping an address _to itself_. Just like in sweeping, you may need

For example:

./bin/pktctl --wallet sendfrom <address> 0 '["<address>"]'
./bin/pldctl wallet/transaction/sendfrom --to_address=<address> --amount=0 --from_address='["<address>"]'

## Opening a lightning channel

First you need to find your node publick key. Do this after unlocking your wallet by running:

./bin/pldctl meta/getinfo

get the **identityPubkey** from lightning section. Then you need to convert it by running:

>`echo -n '<identity_pub_key>' | base64 -d | xxd -ps`

You can use the output from this as the node pubkey when opening a channel. To do this, run the command:

./bin/pldctl lightning/channel/open --node_pubkey=<node_pubkey> --local_funding_amount=<amount> --private=true

*set private to true if you want your channel to be private*
*amount should be in satoshis*

**Note**: In case your pld instance runs behind NAT make sure you have port-forwarding enable for port 9735, which is the default port for connecting peers.

**Windows:**
>`pktctl.exe --wallet sendfrom <address> 0 [\"<address>\"]`
>`pldctl.exe wallet/transaction/sendfrom --to_address=<address> --amount=0 --from_address=[\"<address>\"]`

# Alternative GUI Wallets

Expand All @@ -272,8 +293,8 @@ For example:

## Should I leave pktwallet running?

>It is not a requirement to have pktwallet running to mine. However, if you leave it running, it will stay synced. This will save time when performing pktctl functions, such as folding and sending coins. If pktwallet has not been running for some time, it will need time to sync up to the current block from the time it last ran. As a safety precaution, don't forget to lock your wallet if you do keep it running.
>It is not a requirement to have pktwallet running to mine. However, if you leave it running, it will stay synced. This will save time when performing pldctl functions, such as folding and sending coins. If pktwallet has not been running for some time, it will need time to sync up to the current block from the time it last ran. As a safety precaution, don't forget to lock your wallet if you do keep it running.

## How often should I fold and why?

>The purpose of folding is to turn all your small payments (such as from mining) into quickly and easily spendable coins. If you are multi-pool mining and have rewards in every block, you will have roughly 1440 unconsolidated transactions per day - one for each block at a rate of ~ 1 block/min. If you do not fold these transactions, after awhile you'll have a huge amount of transactions to process if you wish to send the sum or portion thereof of these smaller transactions. So, while folding isn't required and will have no impact on mining if you do or do not, you're doing yourself a favor later by keeping the transactions as consolidated as possible. It is typical to fold as much as possible every day or every few days when you think about it, depending on your use case. It can also be scripted. Note that folding is a transaction itself. Depending on how much you have to fold, you may need to run the command many times. You also may need to wait for coins to confirm before folding more. Once the folding command fails or you see a very low number in the outputcount field from running `./bin/pktctl --wallet getaddressbalances 1 1` or on [PKT block explorer](https://explorer.pkt.cash/) under Unconsolidated Txns, you have successfully folded the best you can for that point in time.
>The purpose of folding is to turn all your small payments (such as from mining) into quickly and easily spendable coins. If you are multi-pool mining and have rewards in every block, you will have roughly 1440 unconsolidated transactions per day - one for each block at a rate of ~ 1 block/min. If you do not fold these transactions, after awhile you'll have a huge amount of transactions to process if you wish to send the sum or portion thereof of these smaller transactions. So, while folding isn't required and will have no impact on mining if you do or do not, you're doing yourself a favor later by keeping the transactions as consolidated as possible. It is typical to fold as much as possible every day or every few days when you think about it, depending on your use case. It can also be scripted. Note that folding is a transaction itself. Depending on how much you have to fold, you may need to run the command many times. You also may need to wait for coins to confirm before folding more. Once the folding command fails or you see a very low number in the outputcount field from running `./bin/pldctl wallet/address/balances` or on [PKT block explorer](https://explorer.pkt.cash/) under Unconsolidated Txns, you have successfully folded the best you can for that point in time.