github.com/mysteriumnetwork/node@v0.0.0-20240516044423-365054f76801/tequilapi/contract/channel.go (about) 1 /* 2 * Copyright (C) 2020 The "MysteriumNetwork/node" Authors. 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 3 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 package contract 19 20 import ( 21 "math/big" 22 23 "github.com/mysteriumnetwork/node/session/pingpong" 24 ) 25 26 // NewPaymentChannelDTO maps to API payment channel. 27 func NewPaymentChannelDTO(channel pingpong.HermesChannel) PaymentChannelDTO { 28 return PaymentChannelDTO{ 29 ID: channel.ChannelID, 30 OwnerID: channel.Identity.Address, 31 HermesID: channel.HermesID.Hex(), 32 Earnings: channel.UnsettledBalance(), 33 EarningsTotal: channel.LifetimeBalance(), 34 Beneficiary: channel.Beneficiary.Hex(), 35 } 36 } 37 38 // PaymentChannelDTO represents represents opened payment channel between identity and hermes. 39 // swagger:model PaymentChannelDTO 40 type PaymentChannelDTO struct { 41 // Unique identifier of payment channel 42 // example: 0x8fc5f7a1794dc39c6837df10613bddf1ec9810503a50306a8667f702457a739a 43 ID string `json:"id"` 44 45 // example: 0x0000000000000000000000000000000000000001 46 OwnerID string `json:"owner_id"` 47 48 // example: 0x42a537D649d6853C0a866470f2d084DA0f73b5E4 49 HermesID string `json:"hermes_id"` 50 51 // Current unsettled earnings 52 // example: 19449034049997187 53 Earnings *big.Int `json:"earnings"` 54 55 // Earnings of all history 56 // example: 19449034049997187 57 EarningsTotal *big.Int `json:"earnings_total"` 58 59 // Beneficiary - eth wallet address 60 Beneficiary string `json:"beneficiary"` 61 }