Skip to content

doc: How to Denominate #41

@coolaj86

Description

@coolaj86

Turns out, this is a really hard problem (the "subset sum problem"). But I think we can really simplify it to the point that, well, it isn't that hard of a problem.

1. Denominate on Sync

All coins should always be denominated by default. Mixing denom and non-denom is really difficult - as in approaching O(2^n) difficult.

2. Calc by mdash value, not sat value

{
  "satoshis": 837422585,
  "value": 837400000,
  "stamps": 112,
  "dust": 185
}

A payment request for 8.37422585 is instead calculated (and sent) as a request for 8.375, using Math.ceil().

3. XPub / Multi-Address Send

Sent to multiple addresses by default. Error if not enough addresses can be generated.

8.375 becomes

5.000
2.000
1.000
0.200
0.100
0.050
0.020
0.005

where each coin also has many unseen transaction "stamps".

(tending towards just 1.7 coins per digit with a mostly even distribution, but less with the natural distribution - 10.99+tax, or 15 for a sale)

digit coins #
9 5, 2, 2 3
8 5, 2, 1 3
7 5, 2 2
6 5, 1 2
5 5 1
4 2, 2 2
3 2, 1 2
2 2 1
1 1 1
0 - 0

17 coins / 10 digits = 1.7 coins per digit

It's okay if change comes back by these means. It will be difficult to tell which is the change.

4. Single Address Send

We can send multiple coins to a single address if absolutely necessary.

5. Exact Send to a single address

This is tricky because we may want to include the stamp values as part of the calculation rather than rolling over (since they all get donated to the network anyway).

A request for 8.37422585 should be calculated as 8.374:

5.000, s*13
2.000, s*13
1.000, s*12
0.200, s*13
0.100, s*12
0.050, s*12
0.020, s*13
0.002, s*12
0.002, s*12

But if the stamp values fail to meet the target + fees, then it should be calculated as 8.375:

5.000, s*14
2.000, s*14
1.000, s*14
0.200, s*14
0.100, s*14
0.050, s*14
0.020, s*14
0.005, s*14

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions