使用Electrum JSON-RPC发送比特币

时间:2019-10-02 12:29:31

标签: php bitcoin json-rpc

我正在尝试使用电子jsonrpc发送比特币,但是​​它一直显示“无效参数”错误。

这就是我所谓的payto方法。

public function payTo($dest, $amount, $source, $fee)
 {
      return $this->sendRequest('payto', ['destination' => $dest, 'amount' => $amount, 'fee' => $fee, 'from_addr' => $source]);
 }
public function sendRequest($method, $params = [])
 {
      $request = $this->client->request('POST', '/', [
           'json' => [
                'jsonrpc' => '2.0',
                'method' => $method,
                'params' => $params,
                'id' => 'curltext'
           ],
           'auth' => ['user', ''],
      ]);

      $response = json_decode($request->getBody()->getContents());
      if (isset($response->error)) {
         throw new Exception($response->error->message);
     } else {
         return $response->result;
     }
 }

1 个答案:

答案 0 :(得分:0)

jsonrpc要求const props = ['name', 'description', 'startDate']; for(let i = 0; i < props.length; i++) { const prop = props[i]; getScheduleInfo.inputData.newSchedules[0][prop] = propValues[i]; } 是一个递增数字,而不是id