require('common.php');
require('html.php');
//print_r($_POST);
$question_marks = implode(', ', array_map(function () { return '?'; }, $_POST['sids']));
$query_string = implode('&', array_map(function ($a) { return 'sids[]='.$a; }, $_POST['sids']));
//$scriptpubkey_info = db_single_row('SELECT * FROM scriptpubkeys WHERE scriptpubkey_id = ?', $_POST['scriptpubkey_id']);
//print_r($scriptpubkey_info);
// we do not update the walletpath of HD addresses, this should be done at another level
db_exec('UPDATE scriptpubkeys SET walletpath_id = ? WHERE scriptpubkey_id IN ( '.$question_marks.') AND idx IS NULL', $_POST['walletpath_id'], $_POST['sids']);
header('Location: address.php?'.$query_string.'&format='.$_POST['format']);
?>