@@ -8,7 +8,7 @@ const { Layout } = DefaultTheme
|
|||||||
<template>
|
<template>
|
||||||
<Layout>
|
<Layout>
|
||||||
<template #aside-outline-before>
|
<template #aside-outline-before>
|
||||||
My custom sidebar top content
|
<!-- My custom sidebar top content -->
|
||||||
</template>
|
</template>
|
||||||
</Layout>
|
</Layout>
|
||||||
</template>
|
</template>
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
* in custom container, badges, etc.
|
* in custom container, badges, etc.
|
||||||
* -------------------------------------------------------------------------- */
|
* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
:root {
|
:root {
|
||||||
--vp-c-default-1: var(--vp-c-gray-1);
|
--vp-c-default-1: var(--vp-c-gray-1);
|
||||||
--vp-c-default-2: var(--vp-c-gray-2);
|
--vp-c-default-2: var(--vp-c-gray-2);
|
||||||
--vp-c-default-3: var(--vp-c-gray-3);
|
--vp-c-default-3: var(--vp-c-gray-3);
|
||||||
@@ -70,22 +70,6 @@
|
|||||||
--vp-c-danger-soft: var(--vp-c-red-soft);
|
--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
|
* Component: Button
|
||||||
* -------------------------------------------------------------------------- */
|
* -------------------------------------------------------------------------- */
|
||||||
@@ -153,3 +137,77 @@
|
|||||||
--docsearch-primary-color: var(--vp-c-brand-1) !important;
|
--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,4 +1,4 @@
|
|||||||
import { Transaction } from '@xo/primitives';
|
import { Transaction } from './transaction.js';
|
||||||
|
|
||||||
import { binToHex, Output } from '@bitauth/libauth';
|
import { binToHex, Output } from '@bitauth/libauth';
|
||||||
|
|
||||||
|
|||||||
@@ -59,6 +59,14 @@ export class Transaction {
|
|||||||
return Transaction.fromBytes(bytes);
|
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 {
|
public toBytes(): Uint8Array {
|
||||||
const bytes = encodeTransaction(this.transaction);
|
const bytes = encodeTransaction(this.transaction);
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Transaction } from '@xo/primitives';
|
import { Transaction, TransactionGraph } from '@xo/primitives';
|
||||||
import { AddressNotification, ElectrumRequest } from './blockchain-types.js';
|
import { AddressNotification, ElectrumRequest } from './blockchain-types.js';
|
||||||
|
|
||||||
import { ElectrumClient } from '@electrum-cash/network';
|
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.
|
// 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?).
|
// Might be able to copy whatever structure a proper node uses (DAG?).
|
||||||
export class Blockchain {
|
export class Blockchain {
|
||||||
|
pendingTransactions: TransactionGraph = new TransactionGraph();
|
||||||
|
|
||||||
electrumClient!: ElectrumClient;
|
electrumClient!: ElectrumClient;
|
||||||
|
|
||||||
// Address subscriptions.
|
// Address subscriptions.
|
||||||
@@ -76,21 +78,49 @@ export class Blockchain {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: async commit() method
|
/**
|
||||||
// This won't actually broadcast, this will just commit the transaction to our graph.
|
* 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.
|
* 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).
|
* And we just want to be able to monitor whether service did the needful (broadcasted it).
|
||||||
// This should accept options: { waitForSeen: boolean }
|
* This should accept options: { waitForSeen: boolean }
|
||||||
|
*/
|
||||||
async commitTransaction(
|
async commitTransaction(
|
||||||
transaction: Transaction,
|
transaction: Uint8Array | Transaction | string,
|
||||||
opts: { waitUntilSeen: boolean } = { waitUntilSeen: true }
|
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);
|
console.log(opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: async broadcast() method
|
// TODO: async broadcast() method
|
||||||
// This should accept options: { waitForSeen: boolean }
|
// 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) {
|
async subscribeAddress(address: string, callback: AddressCallback) {
|
||||||
await this.electrumClient.subscribe(
|
await this.electrumClient.subscribe(
|
||||||
|
|||||||
Reference in New Issue
Block a user