Fix for mutiny_wallet, handle new storage

This commit is contained in:
benthecarman
2023-05-06 14:15:01 -05:00
parent 1b3c73a40c
commit dfe87ce8a3
16 changed files with 105 additions and 106 deletions

View File

@@ -141,19 +141,19 @@ export function Activity() {
const getTransactions = async () => {
console.log("Getting onchain txs");
const txs = await state.mutiny_manager?.list_onchain() as OnChainTx[];
const txs = await state.mutiny_wallet?.list_onchain() as OnChainTx[];
return txs.reverse();
}
const getInvoices = async () => {
console.log("Getting invoices");
const invoices = await state.mutiny_manager?.list_invoices() as MutinyInvoice[];
const invoices = await state.mutiny_wallet?.list_invoices() as MutinyInvoice[];
return invoices.filter((inv) => inv.paid).reverse();
}
const getUtXos = async () => {
console.log("Getting utxos");
const utxos = await state.mutiny_manager?.list_utxos() as UtxoItem[];
const utxos = await state.mutiny_wallet?.list_utxos() as UtxoItem[];
return utxos;
}

View File

@@ -1,5 +1,5 @@
import logo from '~/assets/icons/mutiny-logo.svg';
import { DefaultMain, MutinyManagerGuard, SafeArea } from "~/components/layout";
import { DefaultMain, MutinyWalletGuard, SafeArea } from "~/components/layout";
import BalanceBox from "~/components/BalanceBox";
import NavBar from "~/components/NavBar";
import ReloadPrompt from "~/components/Reload";
@@ -9,7 +9,7 @@ import settings from '~/assets/icons/settings.svg';
export default function App() {
return (
<MutinyManagerGuard>
<MutinyWalletGuard>
<SafeArea>
<DefaultMain>
<header class="w-full flex justify-between items-center mt-4 mb-2">
@@ -22,6 +22,6 @@ export default function App() {
</DefaultMain>
<NavBar activeTab="home" />
</SafeArea>
</MutinyManagerGuard>
</MutinyWalletGuard>
);
}

View File

@@ -21,15 +21,15 @@ export default function BalanceBox() {
const fetchOnchainBalance = async () => {
console.log("Refetching onchain balance");
await state.mutiny_manager?.sync();
const balance = await state.mutiny_manager?.get_balance();
await state.mutiny_wallet?.sync();
const balance = await state.mutiny_wallet?.get_balance();
return balance
};
// TODO: it's hacky to do these separately, but ln doesn't need the sync so I don't want to wait
const fetchLnBalance = async () => {
console.log("Refetching ln balance");
const balance = await state.mutiny_manager?.get_balance();
const balance = await state.mutiny_wallet?.get_balance();
return balance
};

View File

@@ -16,13 +16,13 @@ function PeerItem(props: { peer: MutinyPeer }) {
const [state, _] = useMegaStore()
const handleDisconnectPeer = async () => {
const nodes = await state.mutiny_manager?.list_nodes();
const nodes = await state.mutiny_wallet?.list_nodes();
const firstNode = nodes[0] as string || ""
if (props.peer.is_connected) {
await state.mutiny_manager?.disconnect_peer(firstNode, props.peer.pubkey);
await state.mutiny_wallet?.disconnect_peer(firstNode, props.peer.pubkey);
} else {
await state.mutiny_manager?.delete_peer(firstNode, props.peer.pubkey);
await state.mutiny_wallet?.delete_peer(firstNode, props.peer.pubkey);
}
};
@@ -49,7 +49,7 @@ function PeersList() {
const [state, _] = useMegaStore()
const getPeers = async () => {
return await state.mutiny_manager?.list_peers() as Promise<MutinyPeer[]>
return await state.mutiny_wallet?.list_peers() as Promise<MutinyPeer[]>
};
const [peers, { refetch }] = createResource(getPeers);
@@ -94,10 +94,10 @@ function ConnectPeer(props: { refetchPeers: RefetchPeersType }) {
e.preventDefault();
const peerConnectString = value().trim();
const nodes = await state.mutiny_manager?.list_nodes();
const nodes = await state.mutiny_wallet?.list_nodes();
const firstNode = nodes[0] as string || ""
await state.mutiny_manager?.connect_to_peer(firstNode, peerConnectString)
await state.mutiny_wallet?.connect_to_peer(firstNode, peerConnectString)
await props.refetchPeers()
@@ -139,7 +139,7 @@ function ChannelItem(props: { channel: MutinyChannel, network?: string }) {
async function confirmCloseChannel() {
setConfirmLoading(true);
try {
await state.mutiny_manager?.close_channel(props.channel.outpoint as string)
await state.mutiny_wallet?.close_channel(props.channel.outpoint as string)
} catch (e) {
console.error(e);
showToast(eify(e));
@@ -178,7 +178,7 @@ function ChannelsList() {
const [state, _] = useMegaStore()
const getChannels = async () => {
return await state.mutiny_manager?.list_channels() as Promise<MutinyChannel[]>
return await state.mutiny_wallet?.list_channels() as Promise<MutinyChannel[]>
};
const [channels, { refetch }] = createResource(getChannels);
@@ -193,7 +193,7 @@ function ChannelsList() {
});
})
const network = state.mutiny_manager?.get_network();
const network = state.mutiny_wallet?.get_network();
return (
<>
@@ -235,10 +235,10 @@ function OpenChannel(props: { refetchChannels: RefetchChannelsListType }) {
const pubkey = peerPubkey().trim();
const bigAmount = BigInt(amount());
const nodes = await state.mutiny_manager?.list_nodes();
const nodes = await state.mutiny_wallet?.list_nodes();
const firstNode = nodes[0] as string || ""
const new_channel = await state.mutiny_manager?.open_channel(firstNode, pubkey, bigAmount)
const new_channel = await state.mutiny_wallet?.open_channel(firstNode, pubkey, bigAmount)
setNewChannel(new_channel)

View File

@@ -3,7 +3,7 @@ import { As, Dialog } from "@kobalte/core";
import { Button, Card } from "~/components/layout";
import { useMegaStore } from "~/state/megaStore";
import { Show, createResource } from "solid-js";
import { getExistingSettings } from "~/logic/mutinyManagerSetup";
import { getExistingSettings } from "~/logic/mutinyWalletSetup";
import getHostname from "~/utils/getHostname";
const OVERLAY = "fixed inset-0 z-50 bg-black/50 backdrop-blur-sm"
@@ -15,9 +15,9 @@ export default function PeerConnectModal() {
const [state, _] = useMegaStore()
const getPeerConnectString = async () => {
if (state.mutiny_manager) {
if (state.mutiny_wallet) {
const { proxy } = getExistingSettings();
const nodes = await state.mutiny_manager.list_nodes();
const nodes = await state.mutiny_wallet.list_nodes();
const firstNode = nodes[0] as string || ""
const hostName = getHostname(proxy || "")
const connectString = `mutiny:${firstNode}@${hostName}`

View File

@@ -1,6 +1,6 @@
import { createForm, url } from '@modular-forms/solid';
import { TextField } from '~/components/layout/TextField';
import { MutinyManagerSettingStrings, getExistingSettings } from '~/logic/mutinyManagerSetup';
import { MutinyWalletSettingStrings, getExistingSettings } from '~/logic/mutinyWalletSetup';
import { Button } from '~/components/layout';
import { createSignal } from 'solid-js';
import { deleteDb } from '~/components/DeleteEverything';
@@ -11,14 +11,14 @@ import { useMegaStore } from '~/state/megaStore';
export function SettingsStringsEditor() {
const existingSettings = getExistingSettings();
const [_settingsForm, { Form, Field }] = createForm<MutinyManagerSettingStrings>({ initialValues: existingSettings });
const [_settingsForm, { Form, Field }] = createForm<MutinyWalletSettingStrings>({ initialValues: existingSettings });
const [confirmOpen, setConfirmOpen] = createSignal(false);
const [settingsTemp, setSettingsTemp] = createSignal<MutinyManagerSettingStrings>();
const [settingsTemp, setSettingsTemp] = createSignal<MutinyWalletSettingStrings>();
const [_store, actions] = useMegaStore();
async function handleSubmit(values: MutinyManagerSettingStrings) {
async function handleSubmit(values: MutinyWalletSettingStrings) {
try {
const existing = getExistingSettings();
const newSettings = { ...existing, ...values }
@@ -28,7 +28,7 @@ export function SettingsStringsEditor() {
setSettingsTemp(newSettings);
setConfirmOpen(true);
} else {
await actions.setupMutinyManager(newSettings);
await actions.setupMutinyWallet(newSettings);
window.location.reload();
}
} catch (e) {
@@ -45,7 +45,7 @@ export function SettingsStringsEditor() {
showToast({ title: "Deleted", description: `Deleted all data` })
const loadedValues = settingsTemp();
await actions.setupMutinyManager(loadedValues);
await actions.setupMutinyWallet(loadedValues);
window.location.reload();
} catch (e) {
console.error(e)

View File

@@ -71,11 +71,11 @@ export const FullscreenLoader = () => {
);
}
export const MutinyManagerGuard: ParentComponent = (props) => {
export const MutinyWalletGuard: ParentComponent = (props) => {
const [state, _] = useMegaStore();
return (
<Suspense fallback={<FullscreenLoader />}>
<Show when={state.mutiny_manager}>
<Show when={state.mutiny_wallet}>
{props.children}
</Show>
</Suspense>

View File

@@ -1,17 +1,17 @@
import initMutinyManager, { MutinyManager } from '@mutinywallet/mutiny-wasm';
import initMutinyWallet, { MutinyWallet } from '@mutinywallet/mutiny-wasm';
import initWaila from '@mutinywallet/waila-wasm'
// export type MutinyManagerSettingStrings = {
// export type MutinyWalletSettingStrings = {
// network?: string, proxy?: string, esplora?: string, rgs?: string, lsp?: string,
// }
type Network = "bitcoin" | "testnet" | "regtest" | "signet";
export type MutinyManagerSettingStrings = {
export type MutinyWalletSettingStrings = {
network?: Network, proxy?: string, esplora?: string, rgs?: string, lsp?: string,
}
export function getExistingSettings(): MutinyManagerSettingStrings {
export function getExistingSettings(): MutinyWalletSettingStrings {
const network = localStorage.getItem('MUTINY_SETTINGS_network') || import.meta.env.VITE_NETWORK;
const proxy = localStorage.getItem('MUTINY_SETTINGS_proxy') || import.meta.env.VITE_PROXY;
const esplora = localStorage.getItem('MUTINY_SETTINGS_esplora') || import.meta.env.VITE_ESPLORA;
@@ -21,7 +21,7 @@ export function getExistingSettings(): MutinyManagerSettingStrings {
return { network, proxy, esplora, rgs, lsp }
}
export async function setAndGetMutinySettings(settings?: MutinyManagerSettingStrings): Promise<MutinyManagerSettingStrings> {
export async function setAndGetMutinySettings(settings?: MutinyWalletSettingStrings): Promise<MutinyWalletSettingStrings> {
let { network, proxy, esplora, rgs, lsp } = settings || {};
const existingSettings = getExistingSettings();
@@ -70,8 +70,8 @@ export async function checkForWasm() {
}
}
export async function setupMutinyManager(settings?: MutinyManagerSettingStrings): Promise<MutinyManager> {
await initMutinyManager();
export async function setupMutinyWallet(settings?: MutinyWalletSettingStrings): Promise<MutinyWallet> {
await initMutinyWallet();
// Might as well init waila while we're at it
await initWaila();
@@ -85,14 +85,14 @@ export async function setupMutinyManager(settings?: MutinyManagerSettingStrings)
console.log("Using rgs address", rgs);
console.log("Using lsp address", lsp);
const mutinyManager = await new MutinyManager("", undefined, proxy, network, esplora, rgs, lsp)
const mutinyWallet = await new MutinyWallet("", undefined, proxy, network, esplora, rgs, lsp)
const nodes = await mutinyManager.list_nodes();
const nodes = await mutinyWallet.list_nodes();
// If we don't have any nodes yet, create one
if (!nodes.length) {
await mutinyManager?.new_node()
await mutinyWallet?.new_node()
}
return mutinyManager
return mutinyWallet
}

View File

@@ -1,12 +1,12 @@
import { DeleteEverything } from "~/components/DeleteEverything";
import KitchenSink from "~/components/KitchenSink";
import NavBar from "~/components/NavBar";
import { Card, DefaultMain, LargeHeader, MutinyManagerGuard, SafeArea, SmallHeader, VStack } from "~/components/layout";
import { Card, DefaultMain, LargeHeader, MutinyWalletGuard, SafeArea, SmallHeader, VStack } from "~/components/layout";
import { BackLink } from "~/components/layout/BackLink";
export default function Admin() {
return (
<MutinyManagerGuard>
<MutinyWalletGuard>
<SafeArea>
<DefaultMain>
<BackLink href="/settings" title="Settings" />
@@ -22,6 +22,6 @@ export default function Admin() {
</DefaultMain>
<NavBar activeTab="none" />
</SafeArea>
</MutinyManagerGuard>
</MutinyWalletGuard>
)
}

View File

@@ -2,7 +2,7 @@ import { MutinyBip21RawMaterials, MutinyInvoice } from "@mutinywallet/mutiny-was
import { createEffect, createResource, createSignal, For, Match, onCleanup, Switch } from "solid-js";
import { QRCodeSVG } from "solid-qr-code";
import { AmountEditable } from "~/components/AmountEditable";
import { Button, Card, LargeHeader, MutinyManagerGuard, SafeArea, SmallHeader } from "~/components/layout";
import { Button, Card, LargeHeader, MutinyWalletGuard, SafeArea, SmallHeader } from "~/components/layout";
import NavBar from "~/components/NavBar";
import { useMegaStore } from "~/state/megaStore";
import { objectToSearchParams } from "~/utils/objectToSearchParams";
@@ -138,7 +138,7 @@ export default function Receive() {
async function getUnifiedQr(amount: string) {
const bigAmount = BigInt(amount);
try {
const raw = await state.mutiny_manager?.create_bip21(bigAmount);
const raw = await state.mutiny_wallet?.create_bip21(bigAmount);
// Save the raw info so we can watch the address and invoice
setBip21Raw(raw);
@@ -171,7 +171,7 @@ export default function Receive() {
const lightning = bip21.invoice
const address = bip21.address
const invoice = await state.mutiny_manager?.get_invoice(lightning)
const invoice = await state.mutiny_wallet?.get_invoice(lightning)
if (invoice && invoice.paid) {
setReceiveState("paid")
@@ -179,7 +179,7 @@ export default function Receive() {
return "lightning_paid"
}
const tx = await state.mutiny_manager?.check_address(address) as OnChainTx | undefined;
const tx = await state.mutiny_wallet?.check_address(address) as OnChainTx | undefined;
if (tx) {
setReceiveState("paid")
@@ -201,7 +201,7 @@ export default function Receive() {
});
return (
<MutinyManagerGuard>
<MutinyWalletGuard>
<SafeArea>
<main class="max-w-[600px] flex flex-col gap-4 mx-auto p-4">
<BackLink />
@@ -285,6 +285,6 @@ export default function Receive() {
</main>
<NavBar activeTab="receive" />
</SafeArea >
</MutinyManagerGuard>
</MutinyWalletGuard>
)
}

View File

@@ -1,6 +1,6 @@
import { Component, createEffect, createMemo, createResource, createSignal, For, Match, onCleanup, onMount, ParentComponent, Show, Suspense, Switch } from "solid-js";
import { CENTER_COLUMN, MISSING_LABEL, REDSHIFT_LABEL, RIGHT_COLUMN, THREE_COLUMNS, UtxoItem } from "~/components/Activity";
import { Card, DefaultMain, LargeHeader, LoadingSpinner, NiceP, MutinyManagerGuard, SafeArea, SmallAmount, SmallHeader, VStack } from "~/components/layout";
import { Card, DefaultMain, LargeHeader, LoadingSpinner, NiceP, MutinyWalletGuard, SafeArea, SmallAmount, SmallHeader, VStack } from "~/components/layout";
import { BackLink } from "~/components/layout/BackLink";
import { StyledRadioGroup } from "~/components/layout/Radio";
import NavBar from "~/components/NavBar";
@@ -19,12 +19,12 @@ type ShiftOption = "utxo" | "lightning"
type ShiftStage = "choose" | "observe" | "success" | "failure"
type OutPoint = string; // Replace with the actual TypeScript type for OutPoint
type RedshiftStatus = any; // Replace with the actual TypeScript type for RedshiftStatus
type RedshiftStatus = string; // Replace with the actual TypeScript type for RedshiftStatus
type RedshiftRecipient = any; // Replace with the actual TypeScript type for RedshiftRecipient
type PublicKey = any; // Replace with the actual TypeScript type for PublicKey
interface RedshiftResult {
id: bigint;
id: string;
input_utxo: OutPoint;
status: RedshiftStatus;
recipient: RedshiftRecipient;
@@ -38,9 +38,9 @@ interface RedshiftResult {
}
const dummyRedshift: RedshiftResult = {
id: BigInt(1),
id: "44036599c37d590899e8d5d920860286",
input_utxo: "44036599c37d590899e8d5d92086028695d2c2966fdc354ce1da9a9eac610a53:1",
status: {}, // Replace with a dummy value for RedshiftStatus
status: "Completed", // Replace with a dummy value for RedshiftStatus
recipient: {}, // Replace with a dummy value for RedshiftRecipient
output_utxo: "44036599c37d590899e8d5d92086028695d2c2966fdc354ce1da9a9eac610a53:1",
introduction_channel: "a7773e57f8595848a635e9af105927cac9ecaf292d71a76456ae0455bd3c9c64:0",
@@ -56,7 +56,7 @@ function RedshiftReport(props: { redshift: RedshiftResult, utxo: UtxoItem }) {
const getUtXos = async () => {
console.log("Getting utxos");
return await state.mutiny_manager?.list_utxos() as UtxoItem[];
return await state.mutiny_wallet?.list_utxos() as UtxoItem[];
}
function findUtxoByOutpoint(outpoint?: string, utxos: UtxoItem[] = []): UtxoItem | undefined {
@@ -75,15 +75,15 @@ function RedshiftReport(props: { redshift: RedshiftResult, utxo: UtxoItem }) {
})
async function checkRedshift(outpoint: string) {
async function checkRedshift(id: string) {
// const rs = redshiftItems[0] as RedshiftResult;
console.log("Checking redshift", outpoint)
const redshift = await state.mutiny_manager?.get_redshift(outpoint);
console.log("Checking redshift", id)
const redshift = await state.mutiny_wallet?.get_redshift(id);
console.log(redshift)
return redshift[0]
return redshift;
}
const [redshiftResource, { refetch }] = createResource(props.utxo.outpoint, checkRedshift);
const [redshiftResource, { refetch }] = createResource(props.redshift.id, checkRedshift);
onMount(() => {
const interval = setInterval(() => {
if (redshiftResource()) refetch();
@@ -196,7 +196,7 @@ export function Utxo(props: { item: UtxoItem, onClick?: () => void }) {
const FAKE_STATES = ["Creating a new node", "Opening a channel", "Sending funds through", "Closing the channel", "Redshift complete"]
function ShiftObserver(props: { setShiftStage: (stage: ShiftStage) => void, utxo: UtxoItem }) {
function ShiftObserver(props: { setShiftStage: (stage: ShiftStage) => void, redshiftId: String }) {
const [state, _actions] = useMegaStore();
const [fakeStage, setFakeStage] = createSignal(2);
@@ -216,15 +216,14 @@ function ShiftObserver(props: { setShiftStage: (stage: ShiftStage) => void, utxo
}, 1000)
})
async function checkRedshift(outpoint: string) {
// const rs = redshiftItems[0] as RedshiftResult;
console.log("Checking redshift", outpoint)
const redshift = await state.mutiny_manager?.get_redshift(outpoint);
async function checkRedshift(id: string) {
console.log("Checking redshift", id)
const redshift = await state.mutiny_wallet?.get_redshift(id);
console.log(redshift)
return redshift
}
const [redshiftResource, { refetch }] = createResource(props.utxo.outpoint, checkRedshift);
const [redshiftResource, { refetch }] = createResource(props.redshiftId, checkRedshift);
// onMount(() => {
// const interval = setInterval(() => {
@@ -282,13 +281,13 @@ export default function Redshift() {
const getUtXos = async () => {
console.log("Getting utxos");
return await state.mutiny_manager?.list_utxos() as UtxoItem[];
return await state.mutiny_wallet?.list_utxos() as UtxoItem[];
}
const getChannels = async () => {
console.log("Getting channels");
await state.mutiny_manager?.sync()
const channels = await state.mutiny_manager?.list_channels() as Promise<MutinyChannel[]>;
await state.mutiny_wallet?.sync()
const channels = await state.mutiny_wallet?.list_channels() as Promise<MutinyChannel[]>;
console.log(channels)
return channels
@@ -315,7 +314,7 @@ export default function Redshift() {
async function redshiftUtxo(utxo: UtxoItem) {
console.log("Redshifting utxo", utxo.outpoint)
const redshift = await state.mutiny_manager?.init_redshift(utxo.outpoint);
const redshift = await state.mutiny_wallet?.init_redshift(utxo.outpoint);
console.log("Redshift initialized:")
console.log(redshift)
return redshift
@@ -331,7 +330,7 @@ export default function Redshift() {
})
return (
<MutinyManagerGuard>
<MutinyWalletGuard>
<SafeArea>
<DefaultMain>
<BackLink />
@@ -405,6 +404,6 @@ export default function Redshift() {
</DefaultMain>
<NavBar activeTab="redshift" />
</SafeArea>
</MutinyManagerGuard>
</MutinyWalletGuard>
)
}

View File

@@ -87,7 +87,7 @@ export default function Scanner() {
// When we have a nice result we can head over to the send screen
createEffect(() => {
if (scanResult()) {
const network = state.mutiny_manager?.get_network() || "signet";
const network = state.mutiny_wallet?.get_network() || "signet";
const result = toParsedParams(scanResult() || "", network);
if (!result.ok) {
showToast(result.error);

View File

@@ -1,7 +1,7 @@
import { Match, Show, Switch, createEffect, createMemo, createResource, createSignal, onCleanup, onMount } from "solid-js";
import { Amount } from "~/components/Amount";
import NavBar from "~/components/NavBar";
import { Button, ButtonLink, DefaultMain, HStack, LargeHeader, MutinyManagerGuard, SafeArea, SmallHeader, VStack } from "~/components/layout";
import { Button, ButtonLink, DefaultMain, HStack, LargeHeader, MutinyWalletGuard, SafeArea, SmallHeader, VStack } from "~/components/layout";
import { Paste } from "~/assets/svg/Paste";
import { Scan } from "~/assets/svg/Scan";
import { useMegaStore } from "~/state/megaStore";
@@ -84,7 +84,7 @@ export default function Send() {
if (source.memo) setDescription(source.memo);
if (source.invoice) {
state.mutiny_manager?.decode_invoice(source.invoice).then(invoice => {
state.mutiny_wallet?.decode_invoice(source.invoice).then(invoice => {
if (invoice?.amount_sats) setAmountSats(invoice.amount_sats);
setInvoice(invoice)
setSource("lightning")
@@ -107,7 +107,7 @@ export default function Send() {
function parsePaste(text: string) {
if (text) {
const network = state.mutiny_manager?.get_network() || "signet";
const network = state.mutiny_wallet?.get_network() || "signet";
const result = toParsedParams(text || "", network);
if (!result.ok) {
showToast(result.error);
@@ -144,21 +144,21 @@ export default function Send() {
const bolt11 = invoice()?.bolt11;
let sentDetails: Partial<SentDetails> = {};
if (source() === "lightning" && invoice() && bolt11) {
const nodes = await state.mutiny_manager?.list_nodes();
const nodes = await state.mutiny_wallet?.list_nodes();
const firstNode = nodes[0] as string || ""
sentDetails.destination = bolt11;
// If the invoice has sats use that, otherwise we pass the user-defined amount
if (invoice()?.amount_sats) {
await state.mutiny_manager?.pay_invoice(firstNode, bolt11);
await state.mutiny_wallet?.pay_invoice(firstNode, bolt11);
sentDetails.amount = invoice()?.amount_sats;
} else {
await state.mutiny_manager?.pay_invoice(firstNode, bolt11, amountSats());
await state.mutiny_wallet?.pay_invoice(firstNode, bolt11, amountSats());
sentDetails.amount = amountSats();
}
} else if (source() === "lightning" && nodePubkey()) {
const nodes = await state.mutiny_manager?.list_nodes();
const nodes = await state.mutiny_wallet?.list_nodes();
const firstNode = nodes[0] as string || ""
const payment = await state.mutiny_manager?.keysend(firstNode, nodePubkey()!, amountSats());
const payment = await state.mutiny_wallet?.keysend(firstNode, nodePubkey()!, amountSats());
console.log(payment?.value)
// TODO: handle timeouts
@@ -169,7 +169,7 @@ export default function Send() {
}
} else if (source() === "onchain" && address()) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const txid = await state.mutiny_manager?.send_to_address(address()!, amountSats());
const txid = await state.mutiny_wallet?.send_to_address(address()!, amountSats());
sentDetails.amount = amountSats();
sentDetails.destination = address();
// TODO: figure out if this is necessary, it takes forever
@@ -194,7 +194,7 @@ export default function Send() {
})
return (
<MutinyManagerGuard>
<MutinyWalletGuard>
<SafeArea>
<DefaultMain>
<BackLink />
@@ -216,7 +216,7 @@ export default function Send() {
<img src={handshake} alt="handshake" class="w-1/2 mx-auto max-w-[50vh]" />
<Amount amountSats={sentDetails()?.amount} showFiat />
<Show when={sentDetails()?.txid}>
<a href={mempoolTxUrl(sentDetails()?.txid, state.mutiny_manager?.get_network())} target="_blank" rel="noreferrer">
<a href={mempoolTxUrl(sentDetails()?.txid, state.mutiny_wallet?.get_network())} target="_blank" rel="noreferrer">
Mempool Link
</a>
</Show>
@@ -315,6 +315,6 @@ export default function Send() {
</DefaultMain>
<NavBar activeTab="send" />
</SafeArea >
</MutinyManagerGuard >
</MutinyWalletGuard >
)
}

View File

@@ -1,4 +1,4 @@
import { ButtonLink, DefaultMain, LargeHeader, MutinyManagerGuard, SafeArea, VStack } from "~/components/layout";
import { ButtonLink, DefaultMain, LargeHeader, MutinyWalletGuard, SafeArea, VStack } from "~/components/layout";
import { BackLink } from "~/components/layout/BackLink";
import NavBar from "~/components/NavBar";
import { SeedWords } from "~/components/SeedWords";
@@ -9,7 +9,7 @@ export default function Settings() {
const [store, _actions] = useMegaStore();
return (
<MutinyManagerGuard>
<MutinyWalletGuard>
<SafeArea>
<DefaultMain>
<BackLink />
@@ -17,7 +17,7 @@ export default function Settings() {
<VStack biggap>
<VStack>
<p class="text-2xl font-light">Write down these words or you'll die!</p>
<SeedWords words={store.mutiny_manager?.show_seed() || ""} />
<SeedWords words={store.mutiny_wallet?.show_seed() || ""} />
</VStack>
<SettingsStringsEditor />
<ButtonLink href="/admin">"I know what I'm doing"</ButtonLink>
@@ -25,6 +25,6 @@ export default function Settings() {
</DefaultMain>
<NavBar activeTab="settings" />
</SafeArea>
</MutinyManagerGuard>
</MutinyWalletGuard>
)
}

View File

@@ -2,8 +2,8 @@
import { ParentComponent, createContext, createEffect, onCleanup, onMount, useContext } from "solid-js";
import { createStore } from "solid-js/store";
import { MutinyManagerSettingStrings, setupMutinyManager } from "~/logic/mutinyManagerSetup";
import { MutinyBalance, MutinyManager } from "@mutinywallet/mutiny-wasm";
import { MutinyWalletSettingStrings, setupMutinyWallet } from "~/logic/mutinyWalletSetup";
import { MutinyBalance, MutinyWallet } from "@mutinywallet/mutiny-wasm";
import { ParsedParams } from "~/routes/Scanner";
const MegaStoreContext = createContext<MegaStore>();
@@ -12,7 +12,7 @@ type UserStatus = undefined | "new_here" | "waitlisted" | "approved" | "paid"
export type MegaStore = [{
waitlist_id?: string;
mutiny_manager?: MutinyManager;
mutiny_wallet?: MutinyWallet;
user_status: UserStatus;
scan_result?: ParsedParams;
balance?: MutinyBalance;
@@ -20,7 +20,7 @@ export type MegaStore = [{
price: number
}, {
fetchUserStatus(): Promise<UserStatus>;
setupMutinyManager(settings?: MutinyManagerSettingStrings): Promise<void>;
setupMutinyWallet(settings?: MutinyWalletSettingStrings): Promise<void>;
setWaitlistId(waitlist_id: string): void;
setScanResult(scan_result: ParsedParams | undefined): void;
sync(): Promise<void>;
@@ -29,7 +29,7 @@ export type MegaStore = [{
export const Provider: ParentComponent = (props) => {
const [state, setState] = createStore({
waitlist_id: localStorage.getItem("waitlist_id"),
mutiny_manager: undefined as MutinyManager | undefined,
mutiny_wallet: undefined as MutinyWallet | undefined,
user_status: undefined as UserStatus,
scan_result: undefined as ParsedParams | undefined,
// TODO: wire this up to real price once we have caching
@@ -55,10 +55,10 @@ export const Provider: ParentComponent = (props) => {
return "new_here"
}
},
async setupMutinyManager(settings?: MutinyManagerSettingStrings): Promise<void> {
async setupMutinyWallet(settings?: MutinyWalletSettingStrings): Promise<void> {
try {
const mutinyManager = await setupMutinyManager(settings)
setState({ mutiny_manager: mutinyManager })
const mutinyWallet = await setupMutinyWallet(settings)
setState({ mutiny_wallet: mutinyWallet })
} catch (e) {
console.error(e)
}
@@ -69,7 +69,7 @@ export const Provider: ParentComponent = (props) => {
async sync(): Promise<void> {
console.time("BDK Sync Time")
try {
await state.mutiny_manager?.sync()
await state.mutiny_wallet?.sync()
} catch (e) {
console.error(e);
}
@@ -89,9 +89,9 @@ export const Provider: ParentComponent = (props) => {
// Only load node manager when status is approved
createEffect(() => {
if (state.user_status === "approved" && !state.mutiny_manager) {
if (state.user_status === "approved" && !state.mutiny_wallet) {
console.log("running setup node manager...")
actions.setupMutinyManager().then(() => console.log("node manager setup done"))
actions.setupMutinyWallet().then(() => console.log("node manager setup done"))
}
})
@@ -102,7 +102,7 @@ export const Provider: ParentComponent = (props) => {
createEffect(() => {
const interval = setInterval(() => {
if (state.mutiny_manager) actions.sync();
if (state.mutiny_wallet) actions.sync();
}, 60 * 1000); // Poll every minute
onCleanup(() => {

View File

@@ -1,11 +1,11 @@
import { MutinyManager } from "@mutinywallet/mutiny-wasm";
import { MutinyWallet } from "@mutinywallet/mutiny-wasm";
export function satsToUsd(amount: number | undefined, price: number, formatted: boolean): string {
if (typeof amount !== "number" || isNaN(amount)) {
return ""
}
try {
const btc = MutinyManager.convert_sats_to_btc(BigInt(Math.floor(amount)));
const btc = MutinyWallet.convert_sats_to_btc(BigInt(Math.floor(amount)));
const usd = btc * price;
if (formatted) {
@@ -26,7 +26,7 @@ export function usdToSats(amount: number | undefined, price: number, formatted:
}
try {
const btc = price / amount;
const sats = MutinyManager.convert_btc_to_sats(btc);
const sats = MutinyWallet.convert_btc_to_sats(btc);
if (formatted) {
return parseInt(sats.toString()).toLocaleString();
} else {