Skip to content

Commit

Permalink
add instruction for updateAccountPermission
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-liu55 committed Mar 1, 2019
1 parent e461147 commit a6254bd
Showing 1 changed file with 59 additions and 37 deletions.
96 changes: 59 additions & 37 deletions 中文文档/波场协议/多重签名.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
[3.API](#3) \
[3.1 修改权限](#3.1)\
[3.2 执行合约](#3.2)\
[4.其他问题](#4)
[4.其他](#4)

## <h2 id="1">1.背景</h2>

Expand Down Expand Up @@ -65,11 +65,11 @@
`AccountPermissionUpdateContract`\
`owner_address`:待修改权限的账户的地址\
`owner`:修改后的 owner 权限,覆盖\
`witness`:修改后的 witness 权限(如果是 witness ),覆盖\
`actives`:修改后的 actives 权限,覆盖
`owner`:修改后的 owner 权限\
`witness`:修改后的 witness 权限(如果是 witness )\
`actives`:修改后的 actives 权限

该接口是覆盖原账户权限,因此,如果只想修改owner权限,witness(如果是witnss)及actives的也需要设置。
该接口是覆盖原账户权限,因此,如果只想修改owner权限,witness(如果是witnss账户)及actives的也需要设置。


**4. Permission**
Expand All @@ -93,11 +93,11 @@
`id`: 值由系统自动设置,Owner id=0, Witness id=1, Active id 从2开始递增分配。在执行合约时,
通过该id来指定使用哪个权限,如使用owner权限,即将id设置为0。\
`permission_name`: 权限名称,由用户设定\
`threshold`: 阈值,只有当参与签名的权重之和超过域值才允许做相应的操作。\
`threshold`: 阈值,只有当参与签名的权重之和超过域值才允许做相应的操作。要求小于Long类型的最大值\
`parent_id`:目前只能为0 \
`operations`:共32字节(256位),每位代表一个合约的权限,为1时表示拥有该合约的权限。
`operations=0x0100...00(十六进制),即100...0(二进制)`时,查看Transaction.ContractType,合约AccountCreateContract的值为0
即表示该permission只拥有执行AccountCreateContract的权限\
`operations=0x0100...00(十六进制),即100...0(二进制)`时,查看proto中Transaction.ContractType定义,合约AccountCreateContract的id为0
即表示该permission只拥有执行AccountCreateContract的权限,可以使用"active权限中operations的计算示例"计算获得。\
`keys`:共同拥有该权限的地址及权重,最多允许5个key。

**5. Key**
Expand Down Expand Up @@ -166,14 +166,14 @@ Active权限,用于提供一个权限的组合,比如提供一个只能执
Active权限有以下特性:\
1、拥有OwnerPermission的地址可以修改Active权限\
2、拥有执行AccountPermissionUpdateContract权限的地址也能够修改Active权限\
1、最多支持8个组合。\
1、permission的id从2开始自动递增。
3、最多支持8个组合。\
4、permission的id从2开始自动递增。\
5、账户新建时,自动创建一个Active权限,并将该账户的地址填充到其中,默认域值为1,keys中仅包含该账户地址且权重为1。


### <h2 id="2.5">2.5 费用</h2>


1、使用更新账户权限时,即AccountPermissionUpdate 合约,收取100TRX。\
1、使用更新账户权限时,即 AccountPermissionUpdate 合约,收取100TRX。\
2、使用多重签名的交易时,即交易中包括两个及两个以上签名的交易,除交易费用外,另收取1TRX。\
3、可通过提议,修改以上费用。

Expand All @@ -188,7 +188,7 @@ Active权限有以下特性:\
4、发送交易


http-demo
**http-demo**
```
http://{{host}}:{{port}}/wallet/accountpermissionupdate
Expand All @@ -198,7 +198,7 @@ http://{{host}}:{{port}}/wallet/accountpermissionupdate
"owner": {
"type": 0,
"permission_name": "owner",
"threshold": 5,
"threshold": 2,
"keys": [{
"address": "41F08012B4881C320EB40B80F1228731898824E09D",
"weight": 1
Expand All @@ -210,21 +210,13 @@ http://{{host}}:{{port}}/wallet/accountpermissionupdate
{
"address": "41BB7322198D273E39B940A5A4C955CB7199A0CDEE",
"weight": 1
},
{
"address": "412080D8A0364E82150DD5235CE7A61A7B40F3F9EF",
"weight": 1
},
{
"address": "4173FC381D3E2AFEFCCED94A57D49520291C38AFBB",
"weight": 1
}
]
},
"actives": {
"actives": [{
"type": 2,
"permission_name": "active0",
"threshold": 5,
"threshold": 3,
"operations": "7fff1fc0037e0000000000000000000000000000000000000000000000000000",
"keys": [{
"address": "41F08012B4881C320EB40B80F1228731898824E09D",
Expand All @@ -237,20 +229,35 @@ http://{{host}}:{{port}}/wallet/accountpermissionupdate
{
"address": "41BB7322198D273E39B940A5A4C955CB7199A0CDEE",
"weight": 1
},
{
"address": "412080D8A0364E82150DD5235CE7A61A7B40F3F9EF",
"weight": 1
},
{
"address": "4173FC381D3E2AFEFCCED94A57D49520291C38AFBB",
"weight": 1
}
]
}
}]
}
参数字段的定义及限制,请查看"2.1 结构说明"。
```

**active权限中operations的计算示例**

``` java
public static void main(String[] args) {

//指定需要支持的合约id(查看proto中Transaction.ContractType定义),这里包含除AccountPermissionUpdateContract(id=46)以外的所有合约
Integer[] contractId = {0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 30, 31,
32, 33, 41, 42, 43, 44, 45};
List<Integer> list = new ArrayList<>(Arrays.asList(contractId));
byte[] operations = new byte[32];
list.forEach(e -> {
operations[e / 8] |= (1 << e % 8);
});

//7fff1fc0037e0000000000000000000000000000000000000000000000000000
System.out.println(ByteArray.toHexString(operations));
}
```


### <h2 id="3.2">3.2 执行合约</h2>

1、创建交易\
Expand All @@ -263,8 +270,23 @@ n+1、验证多重签名的权重之和大于域值则接受交易,否则拒
代码示例:

https://github.com/tronprotocol/wallet-cli/blob/multi_sign_V2/src/main/java/org/tron/demo/MultiSignDemo.java

## <h2 id="4">4.其他问题</h2>
1、兼容性说明



## <h2 id="4">4.其他</h2>

1、支持多重签名后,创建账户时有什么变化?\
在升级到V3.5版本后,并且多重签名提议生效后,创建账户时将自动生成owner-permission以及一个active-permission,
其中owner-permission中仅包含一个key,权限及阈值都为1。active-permission中也包含一个key,权限及阈值都为1,并且
operations为"7fff1fc0037e0000000000000000000000000000000000000000000000000000",表示支持除
AccountPermissionUpdateContract以外的所有操作。\











0 comments on commit a6254bd

Please sign in to comment.