Skip to content

Commit bb3b102

Browse files
Your Namecoolaj86
authored andcommitted
feat: implement CoinJoin in JavaScript
- 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
1 parent 58cd291 commit bb3b102

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+3604
-423
lines changed

coinjoin.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
'use strict';
2+
3+
let CoinJoin = module.exports;
4+
5+
CoinJoin.STANDARD_DENOMINATIONS = [
6+
// 0.00100001
7+
100001,
8+
// 0.01000010
9+
1000010,
10+
// 0.10000100
11+
10000100,
12+
// 1.00001000
13+
100001000,
14+
// 10.0000100
15+
1000010000,
16+
];
17+
18+
// TODO the spec seems to be more of an ID, though
19+
// the implementation makes it look more like a mask...
20+
CoinJoin.STANDARD_DENOMINATION_MASKS = {
21+
// 0.00100001
22+
100001: 0b00010000,
23+
// 0.01000010
24+
1000010: 0b00001000,
25+
// 0.10000100
26+
10000100: 0b00000100,
27+
// 1.00001000
28+
100001000: 0b00000010,
29+
// 10.00010000
30+
1000010000: 0b00000001,
31+
};
32+
33+
CoinJoin.STANDARD_DENOMINATIONS_MAP = {
34+
// 0.00100001
35+
0b00010000: 100001,
36+
// 0.01000010
37+
0b00001000: 1000010,
38+
// 0.10000100
39+
0b00000100: 10000100,
40+
// 1.00001000
41+
0b00000010: 100001000,
42+
// 10.00010000
43+
0b00000001: 1000010000,
44+
};
45+
46+
// (STANDARD_DENOMINATIONS[0] / 10).floor();
47+
CoinJoin.COLLATERAL = 10000;
48+
// COLLATERAL * 4
49+
CoinJoin.MAX_COLLATERAL = 40000;
50+
51+
CoinJoin.isDenominated = function (sats) {
52+
return CoinJoin.STANDARD_DENOMINATIONS.includes(sats);
53+
};

0 commit comments

Comments
 (0)