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

Closes #4410.
This commit is contained in:
d11n 2022-12-14 04:06:54 +01:00 committed by GitHub
parent cdac238f6d
commit e9deb13ce4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 23 deletions

View File

@ -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>
@ -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>

View File

@ -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;
};
/**
@ -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")
}
});
});
};