# Litecoin

Source: https://developers.bitgo.com/docs/litecoin

## Litecoin

Litecoin can be accessed with the following coin types:

| Environment         | Coin Type | Faucet                                                                                                             |
| :------------------ | :-------- | :----------------------------------------------------------------------------------------------------------------- |
| Litecoin Production | ltc       |                                                                                                                    |
| Litecoin Testnet    | tltc      | <a href="https://tltc.bitaps.com/" target="_blank" rel="noreferrer">https://tltc.bitaps.com/</a> |

### Explorer
<a href="https://mempool.space/ltc" target="_blank" rel="noreferrer">https://mempool.space/ltc</a>

### Dust Threshold

A dust threshold is the minimum amount of Litecoin that you can create in a single output. Litecoin has a dust threshold of 5460 microlitecoins.

### Generating wallets

```javascript
bitgo
  .coin('tltc')
  .wallets()
  .generateWallet({
    label: 'My Test Wallet',
    passphrase: 'secretpassphrase1a5df8380e0e30',
  })
  .then(function (wallet) {
    // print the new wallet
    console.dir(wallet);
  });
```
```shell
LABEL="My Test Wallet"
PASSPHRASE="secretpassphrase1a5df8380e0e30"

curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-d "{ \"label\": \"$LABEL\", \"passphrase\": \"$PASSPHRASE\" }" \
http://$BITGO_EXPRESS_HOST/api/v2/tltc/wallet/generate
```

For Litecoin, BitGo uses the same 2-of-3 multisig P2SH scheme as for Bitcoin, with the keys in the order of User, Backup,
and BitGo respectively.

### Creating addresses

```javascript
bitgo
  .coin('tltc')
  .wallets()
  .getWallet({ id: '585c51a5df8380e0e3082e46' })
  .then(function (wallet) {
    return wallet.createAddress();
  })
  .then(function (newAddress) {
    // print new address details
    console.dir(newAddress);
  });
```
```shell
WALLET=585c51a5df8380e0e3082e46

curl -X POST \
-H "Authorization: Bearer $ACCESS_TOKEN" \
https://app.bitgo-test.com/api/v2/tltc/wallet/$WALLET/address
```

> 📘 **Note:** To view all supported address types and chain codes, see [UTXO Address Types](/docs/utxo-address-types). Litecoin defaults to chain code 0.

### Converting addresses

```javascript
bitgo.coin('ltc').canonicalAddress('3GBygsGPvTdfKMbq4AKZZRu1sPMWPEsBfd', 2);
// MNQ7zkgMsaV67rsjA3JuP59RC5wxRXpwgE

bitgo.coin('ltc').canonicalAddress('3GBygsGPvTdfKMbq4AKZZRu1sPMWPEsBfd', 1);
bitgo.coin('ltc').canonicalAddress('MNQ7zkgMsaV67rsjA3JuP59RC5wxRXpwgE', 1);
// 3GBygsGPvTdfKMbq4AKZZRu1sPMWPEsBfd
```
```shell
curl -X POST \
-H "Content-Type: application/json" \
-d "{ \"address\": \"3GBygsGPvTdfKMbq4AKZZRu1sPMWPEsBfd\", \"scriptHashVersion\": 2 }" \
http://$BITGO_EXPRESS_HOST/api/v2/ltc/canonicaladdress
# MNQ7zkgMsaV67rsjA3JuP59RC5wxRXpwgE
```

Litecoin used to support the same P2SH address format as Bitcoin, but switched to other version identifiers. This is why
some Litecoin addresses start with `3` and some with `M`. Both addresses are the same.

For incoming transactions, BitGo converts each address that start with `3` to one that starts with `M`. For outgoing
transactions, BitGo only accepts the new address format.

> 📘 **Note:** In testnet, the new P2SH addresses start with `Q`, so the corresponding conversion could be between
> `2MsFGJvxH1kCoRp3XEYvKduAjY6eYz9PJHz` and `QLc2RwpX2rFtZzoZrexLibcAgV6Nsg74Jn`.

#### Method

`bitgo.coin('ltc').canonicalAddress(address, scriptHashVersion)`

`bitgo.coin('tltc').canonicalAddress(address, scriptHashVersion)`

#### HTTP Request

`POST /api/v2/:coin/canonicaladdress`

#### Function Arguments

| Parameter         | Type    | Required | Description                                               |
| :---------------- | :------ | :------- | :-------------------------------------------------------- |
| address           | String  | Yes      | The address string to convert                             |
| scriptHashVersion | Integer | No       | `1` for old address format, `2` for new. Defaults to `2`. |

### Balances

Litecoin (LTC) is the native asset of the Litecoin blockchain. The base unit of Litecoin is microlitecoin:

- 1 microlitecoin is (<code>10<sup>-8</sup></code>) or 0.00000001 Litecoin.
- 1 Litecoin is (<code>10<sup>8</sup></code>) or 100000000 microlitecoins (100 million).

BitGo supports balances in string and number format but recommends string to ensure values do not exceed the
programmable number limit: `balanceString`, `confirmedBalanceString`, and `spendableBalanceString`.
