Give the transfer pair a price from the lots it moved
This commit is contained in:
1 parent
456a66151b
commit
32d4cb0641
1 file changed
+14
-1
@@ -55,9 +55,22 @@ def btc_price_ore(tx):
|
|||||||
"""The bitcoin price of docs/spec.md section 7.3, in ore per whole BTC.
|
"""The bitcoin price of docs/spec.md section 7.3, in ore per whole BTC.
|
||||||
|
|
||||||
The kroner amount is the leg that carries it, or `value_ore` where no leg
|
The kroner amount is the leg that carries it, or `value_ore` where no leg
|
||||||
does; the fee is left out. Returns None when the type has no price.
|
does; the fee is left out. A transfer has no kroner leg to read, so it uses
|
||||||
|
the lots it moved: the consumed lots for the outgoing side, the mirrored
|
||||||
|
lots for the incoming side, which gives both sides the same price. Returns
|
||||||
|
None when the type has no price.
|
||||||
"""
|
"""
|
||||||
tx_type = tx["type"]
|
tx_type = tx["type"]
|
||||||
|
if tx_type in ("transfer_out", "transfer_in"):
|
||||||
|
if tx_type == "transfer_out":
|
||||||
|
nok_ore = tx["cost_ore"]
|
||||||
|
sats = tx["consumed_sats"]
|
||||||
|
else:
|
||||||
|
nok_ore = tx["lot_cost_ore"]
|
||||||
|
sats = tx["lot_sats"]
|
||||||
|
if not nok_ore or not sats:
|
||||||
|
return None
|
||||||
|
return _round_div(nok_ore * SATS_PER_BTC, sats)
|
||||||
if tx_type not in PRICE_TYPES:
|
if tx_type not in PRICE_TYPES:
|
||||||
return None
|
return None
|
||||||
if tx_type in ("income", "gift_received"):
|
if tx_type in ("income", "gift_received"):
|
||||||
|
|||||||
Reference in new issue
Block a user