This commit is contained in:
callebtc
2022-09-28 17:42:48 +02:00
parent a723417eef
commit 001b5e24a0
31 changed files with 2535 additions and 0 deletions

8
cashu/core/split.py Normal file
View File

@@ -0,0 +1,8 @@
def amount_split(amount):
"""Given an amount returns a list of amounts returned e.g. 13 is [1, 4, 8]."""
bits_amt = bin(amount)[::-1][:-2]
rv = []
for (pos, bit) in enumerate(bits_amt):
if bit == "1":
rv.append(2**pos)
return rv