2021-07-16 02:35:54 -04:00
< ? php
namespace App\Rules ;
use Illuminate\Contracts\Validation\Rule ;
use MoneroIntegrations\MoneroPhp\walletRPC ;
class ValidateAddress implements Rule
{
/**
* Create a new rule instance .
*
* @ return void
*/
public function __construct ()
{
//
}
/**
* Determine if the validation rule passes .
*
* @ param string $attribute
* @ param mixed $value
* @ return bool
*/
public function passes ( $attribute , $value )
{
2021-08-06 16:06:07 -04:00
$walletRPC = new walletRPC ( config ( 'app.xmr_daemon_ip' ), config ( 'app.xmr_network_port' )); // Change to match your wallet (monero-wallet-rpc) IP address and port; 18083 is the customary port for mainnet, 28083 for testnet, 38083 for stagenet
2021-07-16 02:35:54 -04:00
$open_wallet = $walletRPC -> open_wallet ( config ( 'app.xmr_wallet_name' ), '' );
$validate_address = $walletRPC -> validate_address ( $value );
return $validate_address [ 'valid' ];
}
/**
* Get the validation error message .
*
* @ return string
*/
public function message ()
{
return 'The Monero address is not valid.' ;
}
}