Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow more then 20 accounts when using BTCPayServer.Vault #4430

Merged
merged 1 commit into from Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 3 additions & 8 deletions BTCPayServer/Views/UIStores/ImportWallet/Hardware.cshtml
Expand Up @@ -25,7 +25,7 @@
<div id="vault-status" class="mb-4"></div>
<div id="vault-xpub" class="mt-4" style="display:none;">
<div class="form-group">
<label for="addressType">Address type</label>
<label for="addressType" class="form-label">Address type</label>
<select id="addressType" name="addressType" class="form-select w-auto">
<option value="segwit">Segwit (Recommended, cheapest fee)</option>
<option value="segwitWrapped">Segwit wrapped (Compatible with old wallets)</option>
Expand All @@ -37,13 +37,8 @@
</select>
</div>
<div class="form-group">
<label for="accountNumber">Account</label>
<select id="accountNumber" name="accountNumber" class="form-select w-auto">
@for (int i = 0; i < 20; i++)
{
<option value="@i">@i</option>
}
</select>
<label for="accountNumber" class="form-label">Account</label>
<input id="accountNumber" class="form-control" name="accountNumber" type="number" value="0" min="0" step="1" style="max-width:10ch;" />
</div>
</div>
<div>
Expand Down
37 changes: 22 additions & 15 deletions BTCPayServer/wwwroot/js/vaultbridge.ui.js
Expand Up @@ -245,18 +245,22 @@ var vaultui = (function () {
return await self.askForXPubs();
return false;
}
var selectedXPubs = await self.getXpubSettings();
self.bridge.socket.send(JSON.stringify(selectedXPubs));
show(VaultFeedbacks.fetchingXpubs);
json = await self.bridge.waitBackendMessage();
if (json.hasOwnProperty("error")) {
if (await needRetry(json))
return await self.askForXPubs();
return false;
try {
var selectedXPubs = await self.getXpubSettings();
self.bridge.socket.send(JSON.stringify(selectedXPubs));
show(VaultFeedbacks.fetchingXpubs);
json = await self.bridge.waitBackendMessage();
if (json.hasOwnProperty("error")) {
if (await needRetry(json))
return await self.askForXPubs();
return false;
}
show(VaultFeedbacks.fetchedXpubs);
self.xpub = json;
return true;
} catch (err) {
showError({ error: true, message: err });
}
show(VaultFeedbacks.fetchedXpubs);
self.xpub = json;
return true;
};

/**
Expand All @@ -273,10 +277,13 @@ var vaultui = (function () {
$("#vault-xpub").css("display", "none");
$("#vault-confirm").css("display", "none");
$(this).unbind();
resolve({
addressType: $("select[name=\"addressType\"]").val(),
accountNumber: parseInt($("select[name=\"accountNumber\"]").val())
});
const addressType = $("select[name=\"addressType\"]").val();
const accountNumber = parseInt($("input[name=\"accountNumber\"]").val());
if (addressType && !isNaN(accountNumber)) {
resolve({ addressType, accountNumber });
} else {
reject("Provide an address type and account number")
}
});
});
};
Expand Down