コード例 #1
0
        private string FormatPermissionsString(BlockChainPermission permissions, string entity)
        {
            var builder = new StringBuilder();

            AppendPermission(BlockChainPermission.Connect, "connect");
            AppendPermission(BlockChainPermission.Send, "send");
            AppendPermission(BlockChainPermission.Receive, "receive");
            AppendPermission(BlockChainPermission.Issue, "issue");
            AppendPermission(BlockChainPermission.Mine, "mine");
            AppendPermission(BlockChainPermission.Admin, "admin");
            AppendPermission(BlockChainPermission.Activate, "activate");
            AppendPermission(BlockChainPermission.Write, "write");

            if (entity != null)
            {
                builder.Insert(0, $"{entity}.");
            }

            return(builder.ToString());

            void AppendPermission(Enums.BlockChainPermission permissionToChek, string permissionToChekStr)
            {
                if ((permissions & permissionToChek) != 0)
                {
                    if (builder.Length > 0)
                    {
                        builder.Append(',');
                    }

                    builder.Append(permissionToChekStr);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Revokes permissions from addresses, a comma-separated list of addresses. The permissions parameter works the same as for grant. This is equivalent to calling grant with start-block=0 and end-block=0. Returns the txid of transaction revoking the permissions. For more information, see permissions management.
        /// </summary>
        /// <param name="addresses"></param>
        /// <param name="permissions"></param>
        /// <param name="entity"></param>
        /// <param name="nativeAmount"></param>
        /// <param name="comment"></param>
        /// <param name="commentTo"></param>
        /// <param name="startBlock"></param>
        /// <param name="endBlock"></param>
        /// <returns></returns>
        public JsonRpcResponse <string> Revoke(IEnumerable <string> addresses, BlockChainPermission permissions, string entity = null, decimal nativeAmount = 0M, string comment = null, string commentTo = null, int startBlock = 0, int endBlock = 0)
        {
            var stringifiedAddresses = Util.Utility.StringifyValues(addresses);
            var permissionsAsString  = this.FormatPermissionsString(permissions, entity);

            return(_Client.Execute <string>("revoke", 0, stringifiedAddresses, permissionsAsString));
        }
コード例 #3
0
        /// <summary>
        /// Grants permissions to addresses, a comma-separated list of addresses. For global permissions, set permissions to one of connect, send, receive, create, issue, mine, activate, admin, or a comma-separated list thereof. For per-asset or per-stream permissions, use the form entity.issue or entity.write,admin where entity is an asset or stream name, ref or creation txid. If the chain uses a native currency, you can send some to each recipient using the native-amount parameter. Returns the txid of the transaction granting the permissions. For more information, see permissions management.
        /// </summary>
        /// <param name="addresses"></param>
        /// <param name="permissions"></param>
        /// <param name="entity"></param>
        /// <param name="nativeAmount"></param>
        /// <param name="comment"></param>
        /// <param name="commentTo"></param>
        /// <param name="startBlock"></param>
        /// <param name="endBlock"></param>
        /// <returns></returns>
        public Task <JsonRpcResponse <string> > GrantAsync(IEnumerable <string> addresses, BlockChainPermission permissions, string entity = null, decimal nativeAmount = 0M, string comment = null, string commentTo = null, int startBlock = 0, int endBlock = 0)
        {
            var permissionsAsString = this.FormatPermissionsString(permissions, entity);

            return(GrantAsync(addresses, permissionsAsString, nativeAmount, comment, commentTo, startBlock, endBlock));
        }
コード例 #4
0
        /// <summary>
        /// Returns a list of all permissions which have been explicitly granted to addresses. To list information about specific global permissions, set permissions to one of connect, send, receive, issue, mine, activate, admin, or a comma-separated list thereof. Omit or pass * or all to list all global permissions. For per-asset or per-stream permissions, use the form entity.issue, entity.write,admin or entity.* where entity is an asset or stream name, ref or creation txid. Provide a comma-delimited list in addresses to list the permissions for particular addresses or * for all addresses. If verbose is true, the admins output field lists the administrator/s who assigned the corresponding permission, and the pending field lists permission changes which are waiting to reach consensus.
        /// </summary>
        /// <param name="permissions"></param>
        /// <param name="entity"></param>
        /// <param name="address"></param>
        /// <returns></returns>
        public Task <JsonRpcResponse <List <ListPermissionsResponse> > > ListPermissionsAsync(BlockChainPermission permissions, string entity = null, string address = "*")
        {
            var permissionsAsString = this.FormatPermissionsString(permissions, entity);

            return(_Client.ExecuteAsync <List <ListPermissionsResponse> >("listpermissions", 0, permissionsAsString, address));
        }
コード例 #5
0
        /// <summary>
        /// This works like grantwithdata, but with control over the from-address used to grant the permissions.
        /// </summary>
        /// <param name="fromAddress"></param>
        /// <param name="toAddresses"></param>
        /// <param name="permissions"></param>
        /// <param name="metaData"></param>
        /// <param name="entity"></param>
        /// <param name="nativeAmount"></param>
        /// <param name="startBlock"></param>
        /// <param name="endBlock"></param>
        /// <returns></returns>
        public JsonRpcResponse <string> GrantWithDataFrom(string fromAddress, IEnumerable <string> toAddresses, BlockChainPermission permissions, [Optional] object metaData, string entity = null, decimal nativeAmount = 0M, int startBlock = 0, int endBlock = 0)
        {
            var stringifiedAddresses = Util.Utility.StringifyValues(toAddresses);
            var permissionsAsString  = this.FormatPermissionsString(permissions, entity);

            return(_Client.Execute <string>("grantwithdatafrom", 0, fromAddress, toAddresses, stringifiedAddresses, permissionsAsString));
        }