1
0

CoinJoin.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <template>
  2. <main>
  3. <!-- Page Section -->
  4. <section class="content">
  5. <div class="container-fluid">
  6. <div class="row">
  7. <div class="col-md-6">
  8. <!-- <Navbar /> -->
  9. <div class="card">
  10. <div class="card-body">
  11. <dl class="row" v-if="stats">
  12. <dt class="col-sm-4 text-right">Server</dt>
  13. <dd class="col-sm-8 mb-0">
  14. <a :href="serverUri" target="_blank">
  15. <strong class="text-info">{{serverUri}}</strong>
  16. </a>
  17. </dd>
  18. <dd class="col-sm-8 offset-sm-4 mt-0">
  19. <small class="text-danger">
  20. <strong>
  21. This is a public server operated by ...
  22. </strong>
  23. </small>
  24. </dd>
  25. <dt class="col-sm-4 text-right">Shuffle Port</dt>
  26. <dd class="col-sm-8">
  27. <strong class="text-info">{{stats.shufflePort}}</strong>
  28. </dd>
  29. <dt class="col-sm-4 text-right">Websocket Port</dt>
  30. <dd class="col-sm-8">
  31. <strong class="text-info">{{stats.shuffleWebSocketPort}}</strong>
  32. </dd>
  33. <dt class="col-sm-4 text-right">Ban Score</dt>
  34. <dd class="col-sm-8">
  35. <strong class="text-info">{{stats.banScore}}</strong>
  36. </dd>
  37. <dt class="col-sm-4 text-right">Banned</dt>
  38. <dd class="col-sm-8">
  39. <strong class="text-info">{{stats.banned}}</strong>
  40. </dd>
  41. <dt class="col-sm-4 text-right">Connections</dt>
  42. <dd class="col-sm-8">
  43. <strong class="text-info">{{stats.connections}}</strong>
  44. </dd>
  45. <dt class="col-sm-4 text-right">Pool Size</dt>
  46. <dd class="col-sm-8">
  47. <strong class="text-info">{{stats.poolSize}}</strong>
  48. </dd>
  49. </dl>
  50. <hr />
  51. <dl class="row" v-for="pool of pools(network)" :key="pool.version + '.' + pool.amount">
  52. <dt class="col-sm-4 text-right">Members</dt>
  53. <dd class="col-sm-8">
  54. <strong class="text-info">{{pool.members}}</strong>
  55. </dd>
  56. <dt class="col-sm-4 text-right">Amount</dt>
  57. <dd class="col-sm-8 mb-0">
  58. <strong class="text-info">{{satoshis(pool.amount)}}</strong> satoshis
  59. </dd>
  60. <dd class="col-sm-8 offset-sm-4 mt-0">
  61. <small><strong class="text-danger">{{bch(pool.amount)}}</strong> BCH</small> |
  62. <small><strong class="text-danger">{{fiat(pool.amount)}}</strong> USD</small>
  63. </dd>
  64. <dt class="col-sm-4 text-right">Type</dt>
  65. <dd class="col-sm-8">
  66. <strong class="text-info">{{pool.type}}</strong>
  67. </dd>
  68. <dt class="col-sm-4 text-right">Full</dt>
  69. <dd class="col-sm-8">
  70. <strong class="text-info">{{pool.full}}</strong>
  71. </dd>
  72. <dt class="col-sm-4 text-right">Version</dt>
  73. <dd class="col-sm-8">
  74. <strong class="text-info">{{pool.version}}</strong>
  75. </dd>
  76. </dl>
  77. <!-- <pre v-if="stats">
  78. <code>
  79. {{stats}}
  80. </code>
  81. </pre> -->
  82. </div>
  83. </div>
  84. </div>
  85. <div class="col-md-6">
  86. <div class="card">
  87. <div class="card-header">
  88. <h3 class="card-title">
  89. <i class="fas fa-info-circle mr-1"></i>
  90. CashShuffle Guide
  91. </h3>
  92. </div>
  93. <div class="card-body">
  94. <div class="mb-0">
  95. CashShuffle is an anonymity protocol designed to shuffle <em>(using the CoinJoin spec)</em> a coin input with 4 other random participants, each with an equal output.
  96. </div>
  97. <div class="mt-0 mb-3">
  98. <small class="text-danger"><strong>NOTE:</strong> Shuffled outputs <strong>MUST</strong> be handled with care to prevent privacy leaks.</small>
  99. </div>
  100. <dl class="row">
  101. <dt class="col-sm-4"># of Participants</dt>
  102. <dd class="col-sm-8">
  103. <strong class="text-info">5</strong> per pool
  104. </dd>
  105. <dt class="col-sm-4"># of Shuffle Pools</dt>
  106. <dd class="col-sm-8">
  107. Up to <strong class="text-info">8</strong> per server
  108. <br />Lowest: <strong class="text-info">100 bits</strong> <small><strong class="text-danger">{{fiat(10000)}}</strong> USD</small>
  109. <br />Highest: <strong class="text-info">1,000 BCH</strong> <small><strong class="text-danger">{{fiat(100000000000)}}</strong> USD</small>
  110. </dd>
  111. <!-- <dd class="col-sm-8 offset-sm-4">Donec id elit non mi porta gravida at eget metus.</dd> -->
  112. <dt class="col-sm-4">Avg Completion</dt>
  113. <dd class="col-sm-8">
  114. Minimum: <strong class="text-info">less than 1min</strong>
  115. <br />Maximum: <strong class="text-info">n/a</strong>
  116. </dd>
  117. <dt class="col-sm-4">Felis euismod semper eget lacinia</dt>
  118. <dd class="col-sm-8">Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo
  119. sit amet risus.
  120. </dd>
  121. </dl>
  122. </div>
  123. </div>
  124. </div>
  125. </div>
  126. </div>
  127. </section>
  128. </main>
  129. </template>
  130. <script>
  131. /* Import modules. */
  132. import numeral from 'numeral'
  133. export default {
  134. data: () => {
  135. return {
  136. network: 'mainnet',
  137. usd: 0,
  138. serverUri: null,
  139. stats: null,
  140. }
  141. },
  142. computed: {
  143. //
  144. },
  145. methods: {
  146. /**
  147. * Update Price
  148. */
  149. async updatePrice() {
  150. try {
  151. // const current = await this.bitbox.Price.current('usd')
  152. // console.log('CURRENT PRICE', current)
  153. // this.usd = current
  154. } catch (err) {
  155. console.error(err)
  156. }
  157. },
  158. /**
  159. * Pools
  160. *
  161. * Filters the available pools (based on network type).
  162. */
  163. pools(_network) {
  164. if (!this.stats || !this.stats.pools) {
  165. return []
  166. }
  167. if (_network === 'mainnet') {
  168. /* Filter pools. */
  169. const filtered = this.stats.pools.filter(pool => pool.version === 300)
  170. /* Sort pools. */
  171. const sorted = filtered.sort((a, b) => {
  172. return a.amount - b.amount
  173. })
  174. /* Return pools. */
  175. return sorted
  176. } else {
  177. /* Filter pools. */
  178. const filtered = this.stats.pools.filter(pool => pool.version === 301)
  179. /* Sort pools. */
  180. const sorted = filtered.sort((a, b) => {
  181. return a.amount - b.amount
  182. })
  183. /* Return pools. */
  184. return sorted
  185. }
  186. },
  187. /**
  188. * Satoshis
  189. *
  190. * Formated with commas.
  191. */
  192. satoshis(_satoshis) {
  193. return numeral(_satoshis).format('0,0')
  194. },
  195. /**
  196. * Bitcoin Cash (BCH)
  197. *
  198. * Calculated from satoshis to BCH value.
  199. */
  200. bch(_satoshis) {
  201. /* Calculate BCH value. */
  202. const bchVal = parseFloat(_satoshis / 100000000.0)
  203. return numeral(bchVal).format('0,0.[0000]')
  204. },
  205. /**
  206. * Fiat
  207. *
  208. * Calculated from satoshis to fiat (USD) value.
  209. */
  210. fiat(_satoshis) {
  211. /* Validate USD price. */
  212. if (!this.usd) {
  213. return 0.00
  214. }
  215. /* Calculate BCH value. */
  216. const bchVal = parseFloat(_satoshis / 100000000.0)
  217. /* Calculate fiat value. */
  218. const fiat = bchVal * parseFloat(this.usd / 100.0)
  219. /* Return value. */
  220. return numeral(fiat).format('$0,0.00[00]')
  221. },
  222. },
  223. created: async function () {
  224. /* Update USD. */
  225. this.updatePrice()
  226. /* Set server URI. */
  227. this.serverUri = 'https://shuffle.servo.cash:8080/stats'
  228. // fetch(this.serverUri)
  229. // .set('accept', 'json')
  230. // .end((err, res) => {
  231. // if (err) {
  232. // return console.error('API ERROR:', err)
  233. // }
  234. // console.log('API RESPONSE', res)
  235. // /* Set statistics. */
  236. // const stats = res.body
  237. // console.log('STATISTICS', stats)
  238. // /* Set statistics. */
  239. // this.stats = stats
  240. // })
  241. },
  242. mounted: function () {
  243. //
  244. },
  245. beforeDestroy: function () {
  246. //
  247. },
  248. }
  249. </script>