mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-01 22:39:03 -07:00
website: redesign part 31
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { createElement } from "../dom.js";
|
||||
import { createField } from "../form/index.js";
|
||||
import { redaction } from "../redaction/index.js";
|
||||
|
||||
@@ -35,14 +34,14 @@ function createSourceInput() {
|
||||
* @param {AddWalletFormOptions} options
|
||||
*/
|
||||
export function createAddForm(options) {
|
||||
const form = createElement("form", "wallets__dialog-form");
|
||||
const form = document.createElement("form");
|
||||
const title = document.createElement("h2");
|
||||
const name = document.createElement("input");
|
||||
const source = createSourceInput();
|
||||
const actions = createElement("div", "wallets__dialog-actions");
|
||||
const actions = document.createElement("div");
|
||||
const cancel = document.createElement("button");
|
||||
const submit = document.createElement("button");
|
||||
const status = createElement("p", "wallets__status");
|
||||
const status = document.createElement("p");
|
||||
const fields = [
|
||||
createField("name", name),
|
||||
createField("xpub or descriptor", source),
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
import { fetchWalletAddresses } from "../lookup/index.js";
|
||||
import {
|
||||
generateAddressesFromKey,
|
||||
isOutputDescriptor,
|
||||
} from "../derive/index.js";
|
||||
import { parseOutputDescriptor } from "../derive/descriptor.js";
|
||||
import { addressScripts } from "../derive/script.js";
|
||||
|
||||
const RECEIVE_PATH = /** @type {const} */ ([0]);
|
||||
|
||||
/**
|
||||
* @typedef {import("../derive/address.js").AddressScript} AddressScript
|
||||
* @typedef {import("../scan/branch.js").AddressClient} AddressClient
|
||||
* @typedef {import("../lookup/index.js").WalletAddress} WalletAddress
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {WalletAddress} address
|
||||
*/
|
||||
function hasHistory(address) {
|
||||
return address.received > 0 || address.sent > 0 || address.txCount > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {AddressClient} client
|
||||
* @param {string} source
|
||||
* @returns {Promise<AddressScript>}
|
||||
*/
|
||||
export async function inferAddressScript(client, source) {
|
||||
if (isOutputDescriptor(source)) {
|
||||
return parseOutputDescriptor(source).script;
|
||||
}
|
||||
|
||||
for (const { id } of addressScripts) {
|
||||
const generated = await generateAddressesFromKey(source, {
|
||||
start: 0,
|
||||
count: 1,
|
||||
script: id,
|
||||
path: RECEIVE_PATH,
|
||||
});
|
||||
const [address] = await fetchWalletAddresses(client, generated);
|
||||
|
||||
if (address && hasHistory(address)) {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
return addressScripts[0].id;
|
||||
}
|
||||
@@ -1,12 +1,20 @@
|
||||
main.wallets {
|
||||
.wallets__dialog-form {
|
||||
display: grid;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
.wallets__dialog {
|
||||
> form {
|
||||
display: grid;
|
||||
gap: 0.75rem;
|
||||
|
||||
.wallets__dialog-actions {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
justify-content: end;
|
||||
> div {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
justify-content: end;
|
||||
}
|
||||
|
||||
button[type="submit"] {
|
||||
border-color: var(--orange);
|
||||
color: var(--black);
|
||||
background: var(--orange);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user