mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-31 19:26:42 +00:00

* [NOD-205] Reimplement txgen * [NOD-205] remove prev outpoints of all initial transactions * [NOD-205] break txloop to smaller functions * [NOD-205] Limit collectTransactions iterations * [NOD-205] Use requiredConfirmations constant instead of inline number * [NOD-205] Rename wTx -> walletTx * [NOD-205] Remove handleNewBlock * [NOD-205] Fix search and replace error
41 lines
775 B
Go
41 lines
775 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/daglabs/btcd/rpcclient"
|
|
"io/ioutil"
|
|
)
|
|
|
|
func connectToServer(cfg *config) (*txgenClient, error) {
|
|
|
|
var cert []byte
|
|
if !cfg.DisableTLS {
|
|
var err error
|
|
cert, err = ioutil.ReadFile(cfg.CertificatePath)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("Error reading certificates file: %s", err)
|
|
}
|
|
}
|
|
|
|
connCfg := &rpcclient.ConnConfig{
|
|
Host: cfg.Address,
|
|
Endpoint: "ws",
|
|
User: "user",
|
|
Pass: "pass",
|
|
DisableTLS: cfg.DisableTLS,
|
|
}
|
|
|
|
if !cfg.DisableTLS {
|
|
connCfg.Certificates = cert
|
|
}
|
|
|
|
client, err := newTxgenClient(connCfg)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("Error connecting to address %s: %s", cfg.Address, err)
|
|
}
|
|
|
|
log.Infof("Connected to server %s", cfg.Address)
|
|
|
|
return client, nil
|
|
}
|