Skip to content

Commit

Permalink
Subaddresses
Browse files Browse the repository at this point in the history
Generate subaddress instead of payment id and don't bother creating an integrated address if we're using the rpc.
itssteven authored and serhack committed Jan 12, 2019
1 parent 5064b95 commit 8009819
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions include/class-monero-gateway.php
Original file line number Diff line number Diff line change
@@ -209,12 +209,24 @@ public function process_payment($order_id)

$order = wc_get_order($order_id);

// 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);
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 @@ protected static function get_payment_details($order_id)
$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);

0 comments on commit 8009819

Please sign in to comment.