Subaddresses
Generate subaddress instead of payment id and don't bother creating an integrated address if we're using the rpc.
This commit is contained in:
parent
5064b95040
commit
8009819592
@ -209,12 +209,24 @@ class Monero_Gateway extends WC_Payment_Gateway
|
||||
|
||||
$order = wc_get_order($order_id);
|
||||
|
||||
if(self::$confirm_type != 'wownero-wallet-rpc') {
|
||||
// Generate a unique payment id
|
||||
do {
|
||||
$payment_id = bin2hex(openssl_random_pseudo_bytes(8));
|
||||
$query = $wpdb->prepare("SELECT COUNT(*) FROM $table_name WHERE payment_id=%s", array($payment_id));
|
||||
$payment_id_used = $wpdb->get_var($query);
|
||||
} while ($payment_id_used);
|
||||
}
|
||||
else {
|
||||
// Generate subaddress
|
||||
$payment_id = self::$wownero_wallet_rpc->create_address(0, 'Order: ' . $order_id);
|
||||
if(isset($payment_id['address'])) {
|
||||
$payment_id = $payment_id['address'];
|
||||
}
|
||||
else {
|
||||
$this->log->add('Wownero_Gateway', 'Couldn\'t create subaddress for order ' . $order_id);
|
||||
}
|
||||
}
|
||||
|
||||
$currency = $order->get_currency();
|
||||
$rate = self::get_live_rate($currency);
|
||||
@ -477,13 +489,7 @@ class Monero_Gateway extends WC_Payment_Gateway
|
||||
$payment_id = self::sanatize_id($details[0]->payment_id);
|
||||
|
||||
if(self::$confirm_type == 'monero-wallet-rpc') {
|
||||
$array_integrated_address = self::$monero_wallet_rpc->make_integrated_address($payment_id);
|
||||
if (isset($array_integrated_address['integrated_address'])) {
|
||||
$integrated_addr = $array_integrated_address['integrated_address'];
|
||||
} else {
|
||||
self::$log->add('Monero_Gateway', '[ERROR] Unable get integrated address');
|
||||
return '[ERROR] Unable get integrated address';
|
||||
}
|
||||
$integrated_addr = $payment_id;
|
||||
} else {
|
||||
if ($address) {
|
||||
$decoded_address = self::$cryptonote->decode_address($address);
|
||||
|
Loading…
Reference in New Issue
Block a user