我正在尝试编写一个代码,可以通过POST请求将所有资金从priv_key
键发送到目标地址。因此,当我尝试使用importprivkey
RPC命令时,我被卡在了下一个命令getaccountaddress
上。我需要知道私钥的地址是什么,但是每次我用importprivkey
命令导入私钥时,我得到的地址(通过getaccountaddress
)与真实地址不同。
我使用的是PHP 7.2,在VPS中创建并安装了EasyCoin-PHP库。
所以,我的问题是如何仅通过私钥/ WIF获得硬币地址? 在PHP或JS中。
这是我到目前为止所做的:
$Coin = new Coin('USERNAME', 'PASSWORD', 'URL', 'PORT');
$Coin->importprivkey($priv, $priv); // importprivkey(privateKey, accountName)
$dr = $Coin->getaccountaddress($priv); // Return string of the address. Here is the problem
$Coin->settxfee(0.0001); // For transaction
$tx = $Coin->sendfrom($priv, $dest, getbalance($dr)); // getbalance is a function that i made to retrieve address balance
// $dr is containing the address strings but the result is not like what i expected
对不起,这是我的第一个问题。而英语不是我的主要语言