コード例 #1
0
    def get(
            channel_identifier,
            participant,
            transferred_amount=0,
            locked_amount=0,
            nonce=0,
            locksroot=None,
            additional_hash=None,
            v=27,
            signer=None,
            other_token_network=None,
    ):
        _token_network = other_token_network or token_network
        private_key = get_private_key(signer or participant)
        locksroot = locksroot or b'\x00' * 32
        additional_hash = additional_hash or b'\x00' * 32

        balance_hash = hash_balance_data(transferred_amount, locked_amount, locksroot)

        signature = sign_balance_proof(
            private_key,
            _token_network.address,
            int(_token_network.functions.chain_id().call()),
            channel_identifier,
            balance_hash,
            nonce,
            additional_hash,
            v,
        )
        return (
            balance_hash,
            nonce,
            additional_hash,
            signature,
        )
コード例 #2
0
ファイル: channel.py プロジェクト: lemengbin/raiden-contracts
    def get(
        channel_identifier: int,
        participant: HexAddress,
        transferred_amount: int = 0,
        locked_amount: int = 0,
        nonce: int = 0,
        locksroot: Optional[bytes] = None,
        additional_hash: Optional[bytes] = None,
        v: int = 27,
        signer: Optional[HexAddress] = None,
        other_token_network: Optional[Contract] = None,
    ) -> Tuple:
        _token_network = other_token_network or token_network
        private_key = get_private_key(signer or participant)
        locksroot = locksroot or LOCKSROOT_OF_NO_LOCKS
        additional_hash = additional_hash or b"\x00" * 32

        balance_hash = hash_balance_data(transferred_amount, locked_amount,
                                         locksroot)

        signature = sign_balance_proof(
            private_key,
            _token_network.address,
            int(_token_network.functions.chain_id().call()),
            channel_identifier,
            balance_hash,
            nonce,
            additional_hash,
            v,
        )
        return (balance_hash, nonce, additional_hash, signature)
コード例 #3
0
ファイル: channel.py プロジェクト: r1oga/raiden-contracts
    def get(
        channel_identifier: ChannelID,
        participant: HexAddress,
        transferred_amount: TokenAmount = TokenAmount(0),  # noqa
        locked_amount: TokenAmount = TokenAmount(0),  # noqa
        nonce: Nonce = Nonce(0),  # noqa
        locksroot: Optional[Locksroot] = None,
        additional_hash: Optional[AdditionalHash] = None,
        v: int = 27,
        signer: Optional[HexAddress] = None,
        other_token_network: Optional[Contract] = None,
    ) -> OnchainBalanceProof:
        _token_network = other_token_network or token_network
        private_key = get_private_key(signer or participant)
        locksroot = locksroot or LOCKSROOT_OF_NO_LOCKS
        additional_hash = additional_hash or AdditionalHash(b"\x00" * 32)

        balance_hash = hash_balance_data(transferred_amount, locked_amount,
                                         locksroot)

        signature = sign_balance_proof(
            private_key,
            _token_network.address,
            _token_network.functions.chain_id().call(),
            channel_identifier,
            MessageTypeId.BALANCE_PROOF,
            balance_hash,
            nonce,
            additional_hash,
            v,
        )
        # The keys of the dictionary correspond to the parameters of
        # create_balance_proof_countersignature.
        return OnchainBalanceProof(
            balance_hash=balance_hash,
            nonce=nonce,
            additional_hash=additional_hash,
            original_signature=signature,
        )