Skip to content

Commit 3d80e6d

Browse files
committed
init
0 parents  commit 3d80e6d

File tree

12 files changed

+2210
-0
lines changed

12 files changed

+2210
-0
lines changed

.gitignore

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
.pnpm-debug.log*
9+
10+
# Diagnostic reports (https://nodejs.org/api/report.html)
11+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
12+
13+
# Runtime data
14+
pids
15+
*.pid
16+
*.seed
17+
*.pid.lock
18+
19+
# Directory for instrumented libs generated by jscoverage/JSCover
20+
lib-cov
21+
22+
# Coverage directory used by tools like istanbul
23+
coverage
24+
*.lcov
25+
26+
# nyc test coverage
27+
.nyc_output
28+
29+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
30+
.grunt
31+
32+
# Bower dependency directory (https://bower.io/)
33+
bower_components
34+
35+
# node-waf configuration
36+
.lock-wscript
37+
38+
# Compiled binary addons (https://nodejs.org/api/addons.html)
39+
build/Release
40+
41+
# Dependency directories
42+
node_modules/
43+
jspm_packages/
44+
45+
# Snowpack dependency directory (https://snowpack.dev/)
46+
web_modules/
47+
48+
# TypeScript cache
49+
*.tsbuildinfo
50+
51+
# Optional npm cache directory
52+
.npm
53+
54+
# Optional eslint cache
55+
.eslintcache
56+
57+
# Optional stylelint cache
58+
.stylelintcache
59+
60+
# Microbundle cache
61+
.rpt2_cache/
62+
.rts2_cache_cjs/
63+
.rts2_cache_es/
64+
.rts2_cache_umd/
65+
66+
# Optional REPL history
67+
.node_repl_history
68+
69+
# Output of 'npm pack'
70+
*.tgz
71+
72+
# Yarn Integrity file
73+
.yarn-integrity
74+
75+
# dotenv environment variable files
76+
.env
77+
.env.development.local
78+
.env.test.local
79+
.env.production.local
80+
.env.local
81+
82+
# parcel-bundler cache (https://parceljs.org/)
83+
.cache
84+
.parcel-cache
85+
86+
# Next.js build output
87+
.next
88+
out
89+
90+
# Nuxt.js build / generate output
91+
.nuxt
92+
dist
93+
94+
# Gatsby files
95+
.cache/
96+
# Comment in the public line in if your project uses Gatsby and not Next.js
97+
# https://nextjs.org/blog/next-9-1#public-directory-support
98+
# public
99+
100+
# vuepress build output
101+
.vuepress/dist
102+
103+
# vuepress v2.x temp and cache directory
104+
.temp
105+
.cache
106+
107+
# Docusaurus cache and generated files
108+
.docusaurus
109+
110+
# Serverless directories
111+
.serverless/
112+
113+
# FuseBox cache
114+
.fusebox/
115+
116+
# DynamoDB Local files
117+
.dynamodb/
118+
119+
# TernJS port file
120+
.tern-port
121+
122+
# Stores VSCode versions used for testing VSCode extensions
123+
.vscode-test
124+
125+
# yarn v2
126+
.yarn/cache
127+
.yarn/unplugged
128+
.yarn/build-state.yml
129+
.yarn/install-state.gz
130+
.pnp.*
131+

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Wallet Lib
2+
3+
Modular multi asset non-custodial wallet library
4+
5+
6+
7+
## How to use
8+
9+
```
10+
const wallet = new Wallet({})
11+
```

api-notes.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
### Wallet API
2+
3+
### Classes
4+
5+
WalletStore: Generic storage class. can be extended for various db/platforms. Inspired by hypercore's RAM.
6+
7+
PaymentProcessor: Generic payment processor. Developers can extend this class for adding new payment processor. Payment processors have uniform apis that are called from Wallet. Inspired by BFX's btc.coin.js lib.
8+
9+
AssetKey: Generic asset key manager. Developer extend/implement methods of this class for building their own key manager for assets.
10+
11+
Wallet: Main Interface for developers to interact with the wallet. Global level apis for :
12+
- import/export wallet
13+
- sync wallet
14+
- wallet events
15+
- access to low level asset api.
16+
17+
Currency: Encapsulation of currency logic. units, contract addr, conversion, symbols. To allow to
18+
19+
Provider: Generic class that can optionally be used for assets that can have multiple remote nodes. Example: Bitcoin Core/Electrum
20+
21+
22+
Example Wallet API calls:
23+
24+
Wallet Creation:
25+
26+
const wallet = new Wallet([
27+
28+
new BitcoinPayment({ //
29+
30+
// unique name for accessing this asset. There could be multiple Bitcoin assets, example for bitcoin core .
31+
asset_name: "btc_electrum",
32+
provider: new Electrum({ url : "blockstream.com"}), // can be BitcoinCore
33+
34+
// Modular Key manager.
35+
// Developers can create their own key manager by extending AssetKey class
36+
37+
keyManager: new BitcoinKeys()
38+
}),
39+
40+
new USDTPayments({
41+
asset_name: 'usdt_eth'
42+
provider: "infura.com",
43+
keyManager: new EthKeys(),
44+
}),
45+
...etc
46+
], {
47+
48+
// Storage class. Wallet's ledger.
49+
store: WalletStore,
50+
seed: WalletSeed, // seed for wallet
51+
52+
// any other future settings
53+
})
54+
55+
56+
Restore Wallet:
57+
58+
//restore wallet, keys, missed tx.
59+
const wallet = await Wallet.import(snapshot)
60+
await wallet.sync()
61+
62+
63+
### Example of high level wallet api:
64+
wallet.export(asset_name): Creates a dump of everything or just an asset needed to backup and restore wallet
65+
wallet.add(PaymentProcessor): add a new payment processor to the wallet
66+
wallet.remove(PaymentProcessor): add a new asset to the wallet
67+
wallet.sync(options): catch up on all or some missed transactions
68+
wallet.on('wallet-events'): global wallet events
69+
//etc
70+
71+
72+
### Example of low level Asset api
73+
For accessing per asset events
74+
wallet low level asset api:
75+
wallet.assetName.method()
76+
wallet.btc.updateProvider()
77+
wallet.btc.getBalance()
78+
wallet.btc.getNewAddress()
79+
wallet.btc.on('eventname'): asset level events
80+
wallet.btc.exportSeed()
81+
82+
### Tx syncing
83+
84+
85+
- Manual syncing by calling low level api refresh.
86+
- used when in the asset view of a wallet
87+
- refreshing per asset
88+
- compare remote head with local head.
89+
- Global asset refresh:
90+
- track refreshes per asset
91+
- throttle syncing
92+
- rate limites
93+
- state managment of syncing
94+
- next asset, current asset, previous asset

config/eth.usdt.json

Whitespace-only changes.

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const Currency = require('./src/lib/currency.js')
2+
3+
module.exports = {
4+
Currency
5+
}

0 commit comments

Comments
 (0)