-
Notifications
You must be signed in to change notification settings - Fork 150
Description
As far as i do understand the new groups are pretty cool. More than one account can share the same address, and XAS (or assets) from that address can only be transferred if the group members confirm the transaction by voting.
The first question what is the meaning of m of a group, see also:https://stackoverflow.com/questions/52295820/what-is-the-meaning-of-the-input-variables-when-registering-a-new-group
And than, how to add a new member to the group? According the tests at asch/test/integration/contract/group.test.js i should create a MultiSigTransaction and let i sign by the other group members:
trs = lib.AschJS.transaction.createMultiSigTransaction({
type: 502,
fee: 100000000,
senderId: groupAddress,
args: [group.newMembers[0].address, 1, 4],
})
trs.signatures = []
for (let i = 0; i < 3; i++) {
trs.signatures.push(lib.AschJS.transaction
.signMultiSigTransaction(trs, group.members[i].secret))
}
await lib.submitTransactionAsync(trs)
Well okay, but howto sign a MultiSigTransaction in a production environment? See also: https://stackoverflow.com/questions/52367434/how-can-users-sign-a-multi-signed-transaction.
Where are the signatures checked? And when and should the transaction be executed if the required signatures are set?
In the current situation i found that signatures are not required to add a new member to the group.
When a create group with address GQ73kHXgCW72L91QCA4rCnW82E6gKCeDaw, and send some XAS to it, by running:
../asch-cli/bin/asch-cli sendmoney --secret "stone elephant caught wrong spend traffic success fetch inside blush virtual element" --amount 20000000000 --to "GQ73kHXgCW72L91QCA4rCnW82E6gKCeDaw"
, i can add a new group member with any signature by running the following code:
const groupAddress = 'GQ73kHXgCW72L91QCA4rCnW82E6gKCeDaw';
const address = 'AAsAqFppypTjY5cBSkWQMbMbr25iAnn17X';
const weight = 1;
const m = 3;
let trs = aschJS.group.addMember(groupAddress, address, weight, m);
trs.signatures = [];
console.log(JSON.stringify(trs, null, 2));
let data = {
transaction: trs
}
let headers = {
headers: {
magic: "594fe0f3",
version: ''
}
}
axios.post(url, data, headers)
.then((response) => {
console.log(`${JSON.stringify(response.data, null, 2)}`)
})
.catch(error => {
console.log(JSON.stringify(error.message))
})
Where aschJS.group.addMember looks like that shown below:
function addMember(groupAddress, address, weight, m){
return transaction.createMultiSigTransaction({
type: 502,
fee: 1 * 1e8,
senderId: groupAddress,
args: [address, weight, m]
})
}