Пример #1
0
        public static object depositNEO(byte[] walletId)
        {
            BasicMethods.assert(BasicMethods._isByte32(walletId), "walletId is not byte32");
            PbEntity.TokenType token = PbEntity.getStandardTokenType();
            BigInteger         value = LedgerStruct.getTransactionValue(token.NEO, ExecutionEngine.ExecutingScriptHash);

            BasicMethods.assert(value >= 0, "amount is less than zero");
            _whenNotPaused();
            BasicMethods.assert(_updateBalance(walletId, LedgerStruct.NeoAddress, value, getStandardMathOperation().add), "updateBalance failed");

            DepositToWallet(walletId, LedgerStruct.NeoAddress, value);
            return(true);
        }
        public static bool deposit(byte[] _channelId, byte[] _receiver, BigInteger _transferFromAmount)
        {
            BasicMethods.assert(BasicMethods._isByte32(_channelId), "_channelId illegal");
            BasicMethods.assert(BasicMethods._isLegalAddress(_receiver), "_receiver illegal");
            BasicMethods.assert(_transferFromAmount >= 0, "_transferFromAmount illegal");

            LedgerStruct.Channel c = LedgerStruct.getChannelMap(_channelId);
            byte rid = LedgerChannel._getPeerId(c, _receiver);

            BasicMethods.assert(rid == 0 || rid == 1, "rid illegal");
            PbEntity.TokenInfo token  = c.token;
            BigInteger         value  = LedgerStruct.getTransactionValue(token.tokenType, getCelerWallet());
            BigInteger         amount = _transferFromAmount + value;

            LedgerStruct.PeerProfile[] peerProfiles = c.peerProfiles;
            LedgerStruct.PeerProfile   peerProfile  = peerProfiles[rid];
            peerProfile.deposit = peerProfile.deposit + amount;
            peerProfiles[rid]   = peerProfile;
            c.peerProfiles      = peerProfiles;
            LedgerStruct.BalanceMap balanceMap = LedgerChannel.getBalanceMapInner(c);
            LedgerStruct.setChannelMap(_channelId, c);
            DepositEvent(_channelId, balanceMap.peerAddrs, balanceMap.deposits, balanceMap.withdrawals);
            return(true);
        }