From f5ab4835db20b375490a768f2b410ea4e42d35d1 Mon Sep 17 00:00:00 2001 From: ghost Date: Sat, 17 Feb 2024 22:12:20 +0200 Subject: [PATCH] implement sendToAddress method --- src/Client.php | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/src/Client.php b/src/Client.php index acf7eb6..c4dbcfa 100644 --- a/src/Client.php +++ b/src/Client.php @@ -497,7 +497,7 @@ class Client return null; } - public function getReceivedByAddress(string $address, int $minconf = 0): ?float + public function getReceivedByAddress(string $address, ?int $minconf = 0): ?float { $this->_id++; @@ -524,4 +524,47 @@ class Client return null; } + + public function sendToAddress( + string $address, + float $amount = 0, + ?string $comment = null, + ?string $comment_to = null, + ?bool $subtractfeefromamount = false, + $replaceable = null, + $conf_target = null, + $estimate_mode = null + ): ?string + { + $this->_id++; + + $this->_prepare( + '', + 'POST', + [ + 'method' => 'sendtoaddress', + 'params' => + [ + $address, + $amount, + $comment, + $comment_to, + $subtractfeefromamount, + $replaceable, + $conf_target, + $estimate_mode + ], + 'id' => $this->_id + ] + ); + + $response = $this->_execute(); + + if (!empty($response['result']) && !empty($response['result']['txid']) && is_string($response['result']['txid'])) + { + return $response['result']['txid']; + } + + return null; + } }