mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-15 11:59:16 +01:00
Add type sat
.
We actually use this in multiple places for requests. The key difference between this and msat is what we do when presented with a raw number! I prefer insisting on explicit suffixes, for this reason, but at least this will document the field correctly! Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
ee00f84fed
commit
f100b1cdf1
1 changed files with 11 additions and 0 deletions
|
@ -348,6 +348,16 @@ def _extra_validator(is_request: bool):
|
|||
except TypeError:
|
||||
return False
|
||||
|
||||
def is_sat(checker, instance):
|
||||
"""sat fields can be raw integers, sats, btc."""
|
||||
try:
|
||||
# For plain integers, this gives the wrong value by 1000,
|
||||
# but all we care about is the type here.
|
||||
Millisatoshi(instance)
|
||||
return True
|
||||
except TypeError:
|
||||
return False
|
||||
|
||||
def is_msat_response(checker, instance):
|
||||
"""A positive integer"""
|
||||
return type(instance) is int and instance >= 0
|
||||
|
@ -396,6 +406,7 @@ def _extra_validator(is_request: bool):
|
|||
"u16": is_u16,
|
||||
"u8": is_u8,
|
||||
"pubkey": is_pubkey,
|
||||
"sat": is_sat,
|
||||
"msat": is_msat,
|
||||
"msat_or_all": is_msat_or_all,
|
||||
"msat_or_any": is_msat_or_any,
|
||||
|
|
Loading…
Add table
Reference in a new issue