Skip to content

Commit

Permalink
Merge pull request #389 from perun-network/get-signed-state
Browse files Browse the repository at this point in the history
Grant access to SignedState
  • Loading branch information
RmbRT authored Mar 16, 2023
2 parents 5e5bcbc + 74c31cc commit 6163e20
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ linters-settings:
goheader:
values:
regexp:
ANY_YEAR: "20(19|20|21|22)" # 2019-2022
ANY_YEAR: "20(19|2\\d)" # 2019-2029
template-path: ".scripts/copyright-notice"
forbidigo:
forbid:
Expand Down
38 changes: 38 additions & 0 deletions client/transparentchannel.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2023 - See NOTICE file for copyright holders.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package client

import "perun.network/go-perun/channel"

// TransparentChannel grants access to the `SignedState` of the underlying
// channel, which is otherwise hidden by `Channel`. Behaves like a normal channel in
// all other cases.
type TransparentChannel struct {
*Channel
}

// NewTransparentChannel returns a new `TransparentChannel` from a `Channel`.
func NewTransparentChannel(c *Channel) *TransparentChannel {
return &TransparentChannel{c}
}

// SignedState returns the current signed state of the channel.
func (c *TransparentChannel) SignedState() channel.SignedState {
return channel.SignedState{
Params: c.Params(),
State: c.machine.CurrentTX().State,
Sigs: c.machine.CurrentTX().Sigs,
}
}

0 comments on commit 6163e20

Please sign in to comment.