]> git.bitcoin.ninja Git - rust-lightning/commit
Drop `claimable` from `Balance::claimable_amount_satoshis` fields 2023-07-claimable-clarify
authorMatt Corallo <git@bluematt.me>
Fri, 28 Jul 2023 06:20:43 +0000 (06:20 +0000)
committerMatt Corallo <git@bluematt.me>
Sun, 30 Jul 2023 02:24:16 +0000 (02:24 +0000)
commit830220393f04a7be0418ef0d390fb51ab0215ad0
treec20b14e4b10f1a12f26db2530c271206ce775fd6
parent685f26665594e9b941ae94b00600f2b4a4a533fa
Drop `claimable` from `Balance::claimable_amount_satoshis` fields

In Java/TypeScript, we map enums as a base class and each variant
as a class which extends the base. In Java/TypeScript, functions
and fields share the same namespace, which means we cannot have
functions on an enum which have the same name as any fields in any
enum variants.

`Balance`'s `claimable_amount_satoshis` method aliases with fields
in each variant, and thus ultimately doesn't compile in TypeScript.

Because `Balance::claimable_amount_satoshis` has the same name as
the fields, it's also a bit confusing, as it doesn't return the
field for each variant, but sometimes returns zero if we're not
sure we can claim the balance.

Instead, we rename the fields in each enum variant to simply
`amount_satoshis`, to avoid implying that we can definitely claim
the balance.
lightning/src/chain/channelmonitor.rs
lightning/src/ln/monitor_tests.rs