From 6abcb181457d1b52da8374ca714ff8ff0ba354c7 Mon Sep 17 00:00:00 2001 From: elsirion Date: Fri, 13 May 2022 22:23:34 +0000 Subject: [PATCH] Add basic arithmetic to `Amount` type --- cln-rpc/src/primitives.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/cln-rpc/src/primitives.rs b/cln-rpc/src/primitives.rs index 0987fafde..ea6a03433 100644 --- a/cln-rpc/src/primitives.rs +++ b/cln-rpc/src/primitives.rs @@ -78,6 +78,26 @@ impl Amount { } } +impl std::ops::Add for Amount { + type Output = Amount; + + fn add(self, rhs: Self) -> Self::Output { + Amount { + msat: self.msat + rhs.msat + } + } +} + +impl std::ops::Sub for Amount { + type Output = Amount; + + fn sub(self, rhs: Self) -> Self::Output { + Amount { + msat: self.msat - rhs.msat + } + } +} + #[derive(Clone, Copy, Debug)] pub struct ShortChannelId(u64);