100 lines
3.4 KiB
Markdown
100 lines
3.4 KiB
Markdown
# kisstron (Go)
|
|
|
|
A KISS-oriented TRON CLI wallet, ported from Python to Go with **zero third-party
|
|
dependencies** (Go standard library only). It doubles as an importable library.
|
|
|
|
## Install
|
|
|
|
```sh
|
|
go install code.luxferre.top/luxferre/kisstron@latest
|
|
```
|
|
|
|
This builds the `kisstron` CLI into `$(go env GOPATH)/bin`.
|
|
|
|
## CLI usage
|
|
|
|
The command-line interface is identical to the original Python `kisstron.py`:
|
|
|
|
```sh
|
|
kisstron new trx
|
|
kisstron import trx
|
|
kisstron info trx -addr <tron-address>
|
|
kisstron info trx -pk <hex-private-key> -net nile
|
|
kisstron send trx -addr <dest> -amt 10 -pk <hex-key>
|
|
kisstron send usdt -addr <dest> -amt 5 -pk <hex-key> -nc
|
|
kisstron fre trx -amt 100 -pk <hex-key>
|
|
kisstron unf trx -amt 100 -pk <hex-key>
|
|
kisstron send trx -addr <dest> -amt 10 -pk <hex-key> -o # offline: emit signed JSON
|
|
kisstron bro trx # broadcast JSON from stdin
|
|
```
|
|
|
|
Options: `-net/--network`, `-node/--tron-node`, `-tgkey/--trongrid-api-key`,
|
|
`-fee/--fee-limit`, `-addr/--address`, `-amt/--amount`, `-pk/--private-key`,
|
|
`-o/--offline`, `-pp/--passphrase`, `-wc/--words-count`, `-dp/--derivation-path`,
|
|
`-nc/--no-confirm`. See `kisstron -h` for details.
|
|
|
|
## Library usage
|
|
|
|
All packages live at the module root and can be imported directly:
|
|
|
|
| Package | Purpose |
|
|
| --- | --- |
|
|
| `code.luxferre.top/luxferre/kisstron/tron` | Keys, addresses, TRON client, transactions, TRC20, wallet helpers |
|
|
| `code.luxferre.top/luxferre/kisstron/keccak` | Legacy Keccak-256 |
|
|
| `code.luxferre.top/luxferre/kisstron/base58` | Base58 / base58check |
|
|
| `code.luxferre.top/luxferre/kisstron/secp256k1` | secp256k1 curve + recoverable ECDSA |
|
|
| `code.luxferre.top/luxferre/kisstron/bip39` | BIP-39 mnemonics and seed derivation |
|
|
| `code.luxferre.top/luxferre/kisstron/bip32` | BIP-32 CKDpriv derivation |
|
|
| `code.luxferre.top/luxferre/kisstron/ops` | High-level wallet operations |
|
|
| `code.luxferre.top/luxferre/kisstron/cli` | Result formatting and confirmation |
|
|
|
|
Example: restore a wallet and convert an address.
|
|
|
|
```go
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"code.luxferre.top/luxferre/kisstron/tron"
|
|
)
|
|
|
|
func main() {
|
|
key, err := tron.DeriveFromMnemonic("cloth print knife public box ... rose lounge", "", "")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
fmt.Println(key.Pub.ToBase58CheckAddress())
|
|
|
|
addr, _ := tron.ToHexAddress(key.Pub.ToBase58CheckAddress())
|
|
fmt.Println(addr)
|
|
}
|
|
```
|
|
|
|
Example: query the chain and send TRX.
|
|
|
|
```go
|
|
client := tron.NewClient("nile", tron.DefaultEndpoint("nile"), tron.FeeLimitTestnet, "")
|
|
info, err := client.GetAccount("TTynhnM88m4C9Wohm2zT6oiYbV7hC8qUJm")
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
fmt.Println(info["balance"])
|
|
|
|
key, _ := tron.PrivateKeyFromHex("<hex>")
|
|
builder, _ := client.Transfer(key.Pub.ToBase58CheckAddress(), "<dest>", 1_000_000)
|
|
tx, _ := builder.Build()
|
|
_ = tx.Sign(key)
|
|
receipt, _ := tx.Broadcast()
|
|
fmt.Println(receipt["txid"])
|
|
```
|
|
|
|
## Notes
|
|
|
|
- **Zero dependencies**: `go.mod` has no `require` block and there is no `go.sum`.
|
|
Every cryptographic primitive is implemented on the Go standard library.
|
|
- Source uses 2-space indentation (do not run `gofmt`, which would convert it to tabs).
|
|
- The original Python implementation is retained as `kisstron.py` for reference.
|
|
- The Go port reproduces the original output byte-for-byte, including a latent
|
|
bandwidth calculation quirk in the Python original (documented in `ops/ops.go`).
|
|
- Created by Luxferre, released into the public domain with no warranties. |