Skip to content

Commit

Permalink
feat: implement CoinJoin in JavaScript
Browse files Browse the repository at this point in the history
- use rpc to select from MNs
- getverack response
- parse p2p message header
- parse p2p version response
- send verack
- read full messages
- get wallet + address info
- fill and denominate wallet
- create collateral tx
- ping/pong + unit test
- compose DSA and get responses
- test DSA packing
- senddsq
- add fixtures from observed-working regtest traffic
- pack DSI message
- split denominations
- create and test DSSU parser
- create and test DSQ parser
- add salt to wallets to create different 'users'
- sort evonodes so all 'users' join the same evonode
- add string time output for easy comparison / debugging
- create and test packDsi
- allow arbitrary whitespace in hex of test fixtures
- get and parse DSF, add test fixtures
- add known-working transaction to test fixtures
- add Packer.packDss()
- add test fixtures for known-good dsa, dsf, and dss messages
- add first-ever ALL|ANYONECANPAY test fixtures
  • Loading branch information
Your Name authored and coolaj86 committed May 15, 2024
1 parent 58cd291 commit bb3b102
Show file tree
Hide file tree
Showing 47 changed files with 3,604 additions and 423 deletions.
53 changes: 53 additions & 0 deletions coinjoin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
'use strict';

let CoinJoin = module.exports;

CoinJoin.STANDARD_DENOMINATIONS = [
// 0.00100001
100001,
// 0.01000010
1000010,
// 0.10000100
10000100,
// 1.00001000
100001000,
// 10.0000100
1000010000,
];

// TODO the spec seems to be more of an ID, though
// the implementation makes it look more like a mask...
CoinJoin.STANDARD_DENOMINATION_MASKS = {
// 0.00100001
100001: 0b00010000,
// 0.01000010
1000010: 0b00001000,
// 0.10000100
10000100: 0b00000100,
// 1.00001000
100001000: 0b00000010,
// 10.00010000
1000010000: 0b00000001,
};

CoinJoin.STANDARD_DENOMINATIONS_MAP = {
// 0.00100001
0b00010000: 100001,
// 0.01000010
0b00001000: 1000010,
// 0.10000100
0b00000100: 10000100,
// 1.00001000
0b00000010: 100001000,
// 10.00010000
0b00000001: 1000010000,
};

// (STANDARD_DENOMINATIONS[0] / 10).floor();
CoinJoin.COLLATERAL = 10000;
// COLLATERAL * 4
CoinJoin.MAX_COLLATERAL = 40000;

CoinJoin.isDenominated = function (sats) {
return CoinJoin.STANDARD_DENOMINATIONS.includes(sats);
};
Loading

0 comments on commit bb3b102

Please sign in to comment.