Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please, help to understand the groups #267

Open
bassjobsen opened this issue Sep 18, 2018 · 1 comment
Open

Please, help to understand the groups #267

bassjobsen opened this issue Sep 18, 2018 · 1 comment

Comments

@bassjobsen
Copy link
Contributor

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]
  })  
}
@chengenguan
Copy link
Member

Hi Jobsen,
You are right, it is a bug and has been fixed in v1.4.5. Really appreciate your observation and contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants