global: private xpub support part 1

This commit is contained in:
nym21
2026-06-16 23:37:03 +02:00
parent 6f430bdb8c
commit 0c7861071d
70 changed files with 5874 additions and 12510 deletions
+23
View File
@@ -0,0 +1,23 @@
import { isOutputDescriptor } from "./xpub/index.js";
const EXTENDED_PUBLIC_KEY_PATTERN =
/\b(?:xpub|ypub|zpub|tpub|upub|vpub)[1-9A-HJ-NP-Za-km-z]{20,}\b/;
/**
* @param {string} text
*/
export function readWalletSourceText(text) {
const value = text.trim();
if (isOutputDescriptor(value)) {
return value;
}
const match = value.match(EXTENDED_PUBLIC_KEY_PATTERN);
if (match) {
return match[0];
}
throw new Error("Expected an xpub or descriptor");
}