OSDN Git Service

add listUnspentOutputsPayload
authorChengcheng Zhang <943420582@qq.com>
Tue, 3 Sep 2019 02:53:06 +0000 (10:53 +0800)
committerChengcheng Zhang <943420582@qq.com>
Tue, 3 Sep 2019 02:53:06 +0000 (10:53 +0800)
swap/contract.go

index 7a0e16e..6c9fc27 100644 (file)
@@ -278,12 +278,17 @@ type listUnspentOutputsResponse struct {
        Program     string `json:"program"`
 }
 
+var listUnspentOutputsPayload = `{
+       "id": "%s",
+       "unconfirmed": true,
+       "smart_contract": true
+}`
+
 func ListUnspentOutputs(contractUTXOID string) (string, *AssetAmount, error) {
-       payload := []byte(`{
-               "id": "` + contractUTXOID + `",
-               "unconfirmed": true,
-               "smart_contract": true
-       }`)
+       payload := []byte(fmt.Sprintf(
+               listUnspentOutputsPayload,
+               contractUTXOID,
+       ))
        var res []listUnspentOutputsResponse
        if err := request(listUnspentOutputsURL, payload, &res); err != nil {
                return "", nil, err