mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-03-30 15:08:28 +00:00

Golang uses: - Camel Case for variable names, e.g. `firstName` - Camel Case for private function names, e.g. `getFirstName` - Pascal Case for public function names, e.g. `GetFirstName` Signed-off-by: Julian Strobl <jmastr@mailbox.org>
44 lines
937 B
Go
44 lines
937 B
Go
package util
|
|
|
|
import (
|
|
"bytes"
|
|
"encoding/json"
|
|
"errors"
|
|
"os/exec"
|
|
"strconv"
|
|
"strings"
|
|
|
|
"github.com/planetmint/planetmint-go/config"
|
|
)
|
|
|
|
type ReissueResult struct {
|
|
Txid string `json:"txid"`
|
|
Vin int `json:"vin"`
|
|
}
|
|
|
|
func ReissueAsset(reissueTx string) (txid string, err error) {
|
|
conf := config.GetConfig()
|
|
cmdArgs := strings.Split(reissueTx, " ")
|
|
cmd := exec.Command("/usr/local/bin/elements-cli", "-rpcpassword="+conf.RPCPassword,
|
|
"-rpcuser="+conf.RPCUser, "-rpcport="+strconv.Itoa(conf.RPCPort), "-rpcconnect="+conf.RPCHost,
|
|
cmdArgs[0], cmdArgs[1], cmdArgs[2])
|
|
|
|
var stdout, stderr bytes.Buffer
|
|
cmd.Stdout = &stdout
|
|
cmd.Stderr = &stderr
|
|
|
|
err = cmd.Run()
|
|
errstr := stderr.String()
|
|
|
|
if err != nil || len(errstr) > 0 {
|
|
err = errors.New("reissuance of RDDL failed")
|
|
} else {
|
|
var txobj ReissueResult
|
|
err = json.Unmarshal(stdout.Bytes(), &txobj)
|
|
if err == nil {
|
|
txid = txobj.Txid
|
|
}
|
|
}
|
|
return txid, err
|
|
}
|