Signed-off-by: James Zuccon <zuccon@gmail.com>
This commit is contained in:
James Zuccon
2024-09-06 12:10:09 +10:00
parent f189c4643b
commit ce688ce0a4
5 changed files with 124 additions and 28 deletions
+2 -2
View File
@@ -8,7 +8,7 @@ const { Layout } = DefaultTheme
<template>
<Layout>
<template #aside-outline-before>
My custom sidebar top content
<!-- My custom sidebar top content -->
</template>
</Layout>
</template>
</template>
+75 -17
View File
@@ -43,7 +43,7 @@
* in custom container, badges, etc.
* -------------------------------------------------------------------------- */
:root {
:root {
--vp-c-default-1: var(--vp-c-gray-1);
--vp-c-default-2: var(--vp-c-gray-2);
--vp-c-default-3: var(--vp-c-gray-3);
@@ -70,22 +70,6 @@
--vp-c-danger-soft: var(--vp-c-red-soft);
}
.VPSidebarItem.level-2.is-active > .item > .indicator,
.VPSidebarItem.level-3.is-active > .item > .indicator,
.VPSidebarItem.level-4.is-active > .item > .indicator,
.VPSidebarItem.level-5.is-active > .item > .indicator {
background-color: #b2fb54 !important;
}
.VPSidebarItem.level-0.is-active > .item .link > .text,
.VPSidebarItem.level-1.is-active > .item .link > .text,
.VPSidebarItem.level-2.is-active > .item .link > .text,
.VPSidebarItem.level-3.is-active > .item .link > .text,
.VPSidebarItem.level-4.is-active > .item .link > .text,
.VPSidebarItem.level-5.is-active > .item .link > .text {
color: #b2fb54 !important;
}
/**
* Component: Button
* -------------------------------------------------------------------------- */
@@ -153,3 +137,77 @@
--docsearch-primary-color: var(--vp-c-brand-1) !important;
}
/**
* Overrides
*/
:root {
--primary: #2c7d00;
--vp-nav-logo-height: 48px;
}
html.dark {
--primary: #b2fb54;
}
body {
font-size: 14px;
}
.vp-nav .title {
font-size: 24px !important;
}
.vp-doc h1 {
font-size: 24px;
}
.vp-doc h2 {
font-size: 20px;
}
.vp-doc h3 {
font-size: 16px;
}
.vp-doc h4 {
font-size: 14px;
opacity: 0.75;
}
.VPSidebarItem .text {
font-size: 12px;
}
.VPSidebarItem.level-2.is-active > .item > .indicator,
.VPSidebarItem.level-3.is-active > .item > .indicator,
.VPSidebarItem.level-4.is-active > .item > .indicator,
.VPSidebarItem.level-5.is-active > .item > .indicator {
background-color: var(--primary) !important;
}
.VPSidebarItem.level-0.is-active > .item .link > .text,
.VPSidebarItem.level-1.is-active > .item .link > .text,
.VPSidebarItem.level-2.is-active > .item .link > .text,
.VPSidebarItem.level-3.is-active > .item .link > .text,
.VPSidebarItem.level-4.is-active > .item .link > .text,
.VPSidebarItem.level-5.is-active > .item .link > .text {
color: var(--primary) !important;
}
.VPSidebarItem.level-0.is-link > .item > .link:hover .text,
.VPSidebarItem.level-1.is-link > .item > .link:hover .text,
.VPSidebarItem.level-2.is-link > .item > .link:hover .text,
.VPSidebarItem.level-3.is-link > .item > .link:hover .text,
.VPSidebarItem.level-4.is-link > .item > .link:hover .text,
.VPSidebarItem.level-5.is-link > .item > .link:hover .text {
color: var(--primary) !important;
}
.outline-title {
font-size: 12px !important;
}
.outline-link {
font-size: 12px !important;
}
+1 -1
View File
@@ -1,4 +1,4 @@
import { Transaction } from '@xo/primitives';
import { Transaction } from './transaction.js';
import { binToHex, Output } from '@bitauth/libauth';
+8
View File
@@ -59,6 +59,14 @@ export class Transaction {
return Transaction.fromBytes(bytes);
}
public static fromAny(bytesOrHex: Uint8Array | string) {
if (typeof bytesOrHex === 'string') {
return Transaction.fromHex(bytesOrHex);
}
return Transaction.fromBytes(bytesOrHex);
}
public toBytes(): Uint8Array {
const bytes = encodeTransaction(this.transaction);
+38 -8
View File
@@ -1,4 +1,4 @@
import { Transaction } from '@xo/primitives';
import { Transaction, TransactionGraph } from '@xo/primitives';
import { AddressNotification, ElectrumRequest } from './blockchain-types.js';
import { ElectrumClient } from '@electrum-cash/network';
@@ -9,6 +9,8 @@ export type AddressCallback = (status: string | null) => void;
// For local state, we'll want to track a tree of dependencies locally.
// Might be able to copy whatever structure a proper node uses (DAG?).
export class Blockchain {
pendingTransactions: TransactionGraph = new TransactionGraph();
electrumClient!: ElectrumClient;
// Address subscriptions.
@@ -76,21 +78,49 @@ export class Blockchain {
return response;
}
// TODO: async commit() method
// This won't actually broadcast, this will just commit the transaction to our graph.
// The reason we want this is because, for protos like BIP70, we want service to verify the tx and broadcast it.
// And we just want to be able to monitor whether service did the needful (broadcasted it).
// This should accept options: { waitForSeen: boolean }
/**
* This won't actually broadcast, this will just commit the transaction to our graph.
* The reason we want this is because, for protos like BIP70, we want service to verify the tx and broadcast it.
* And we just want to be able to monitor whether service did the needful (broadcasted it).
* This should accept options: { waitForSeen: boolean }
*/
async commitTransaction(
transaction: Transaction,
transaction: Uint8Array | Transaction | string,
opts: { waitUntilSeen: boolean } = { waitUntilSeen: true }
) {
console.log(transaction);
if (typeof transaction === 'string') {
transaction = Transaction.fromHex(transaction);
}
if (transaction instanceof Uint8Array) {
transaction = Transaction.fromBytes(transaction);
}
this.pendingTransactions.addTransaction(transaction);
// TODO: Wait for transaction to be seen on network.
console.log(opts);
}
// TODO: async broadcast() method
// This should accept options: { waitForSeen: boolean }
async broadcastTransaction(
transaction: Uint8Array | Transaction | string,
opts: { waitUntilSeen: boolean } = { waitUntilSeen: true }
) {
if (typeof transaction === 'string') {
transaction = Transaction.fromHex(transaction);
}
if (transaction instanceof Uint8Array) {
transaction = Transaction.fromBytes(transaction);
}
this.pendingTransactions.addTransaction(transaction);
// TODO: Broadcast the transaction.
// TODO: Wait for transaction to be seen on network.
console.log(opts);
}
async subscribeAddress(address: string, callback: AddressCallback) {
await this.electrumClient.subscribe(