global: private xpub support part 2

This commit is contained in:
nym21
2026-06-17 11:25:42 +02:00
parent 0c7861071d
commit 43df9e098c
68 changed files with 1836 additions and 1653 deletions
+23
View File
@@ -0,0 +1,23 @@
import { isOutputDescriptor } from "../derive/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");
}