Resolve "WIP: UTXO Selection and Storage"
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import { BlockchainElectrum, StorageMemory, WalletHD } from '@xo/wallet';
|
||||
|
||||
const ELECTRUM_SERVERS = [
|
||||
'bch.imaginary.cash',
|
||||
'cashnode.bch.ninja',
|
||||
'electrum.imaginary.cash',
|
||||
];
|
||||
|
||||
const blockchainElectrum = new BlockchainElectrum(ELECTRUM_SERVERS);
|
||||
await blockchainElectrum.start();
|
||||
|
||||
const storage = new StorageMemory();
|
||||
|
||||
const walletStore = await storage.getChild('wallets');
|
||||
const walletOneStore = await walletStore.getChild('1');
|
||||
console.log(walletOneStore);
|
||||
|
||||
const cache = new StorageMemory();
|
||||
|
||||
const services = {
|
||||
blockchain: blockchainElectrum,
|
||||
storage: walletOneStore,
|
||||
cache: cache,
|
||||
};
|
||||
|
||||
const wallet = await WalletHD.from(
|
||||
{
|
||||
mnemonic:
|
||||
'grape amazing region hand script truck veteran tilt gaze rough despair guard',
|
||||
},
|
||||
blockchain,
|
||||
walletOneStore,
|
||||
cache,
|
||||
);
|
||||
|
||||
await wallet.start();
|
||||
|
||||
console.log(await storage.export());
|
||||
|
||||
const txs = await wallet.fetchTransactions();
|
||||
|
||||
console.log(txs);
|
||||
|
||||
const wallet2 = await WalletHD.fromStorage(services);
|
||||
|
||||
await wallet2.start();
|
||||
|
||||
console.log(await wallet2.fetchTransactions());
|
||||
Reference in New Issue
Block a user