예제 #1
0
파일: cli.go 프로젝트: alist/mint-client
func genDocAddAccountAndValidator(genDoc *stypes.GenesisDoc, pubKey account.PubKeyEd25519, amt int64, name string, perm, setbit ptypes.PermFlag, index int) {
	addr := pubKey.Address()
	genDoc.Accounts[index] = stypes.GenesisAccount{
		Address: addr,
		Amount:  amt,
		Name:    name,
		Permissions: &ptypes.AccountPermissions{
			Base: ptypes.BasePermissions{
				Perms:  perm,
				SetBit: setbit,
			},
		},
	}
	genDoc.Validators[index] = stypes.GenesisValidator{
		PubKey: pubKey,
		Amount: amt,
		Name:   name,
		UnbondTo: []stypes.BasicAccount{
			stypes.BasicAccount{
				Address: addr,
				Amount:  amt,
			},
		},
	}
}
예제 #2
0
파일: core.go 프로젝트: alist/mint-client
func Bond(nodeAddr, pubkey, unbondAddr, amtS, nonceS string) (*types.BondTx, error) {
	pub, addrBytes, amt, nonce, err := checkCommon(nodeAddr, pubkey, "", amtS, nonceS)
	if err != nil {
		return nil, err
	}
	var pubKey account.PubKeyEd25519
	var unbondAddrBytes []byte

	if unbondAddr == "" {
		pkb, _ := hex.DecodeString(pubkey)
		copy(pubKey[:], pkb)
		unbondAddrBytes = pubKey.Address()
	} else {
		unbondAddrBytes, err = hex.DecodeString(unbondAddr)
		if err != nil {
			return nil, fmt.Errorf("unbondAddr is bad hex: %v", err)
		}

	}

	tx, err := types.NewBondTx(pub)
	if err != nil {
		return nil, err
	}
	_ = addrBytes
	tx.AddInputWithNonce(pub, amt, int(nonce))
	tx.AddOutput(unbondAddrBytes, amt)

	return tx, nil
}
예제 #3
0
파일: cli.go 프로젝트: dbabits/mint-client
func genDocAddValidator(genDoc *stypes.GenesisDoc, pubKey account.PubKeyEd25519, amt int64, name string, perm, setbit ptypes.PermFlag, index int) {
	addr := pubKey.Address()
	genDoc.Validators[index] = stypes.GenesisValidator{
		PubKey: pubKey,
		Amount: amt,
		Name:   name,
		UnbondTo: []stypes.BasicAccount{
			stypes.BasicAccount{
				Address: addr,
				Amount:  amt,
			},
		},
	}
}
예제 #4
0
파일: cli.go 프로젝트: dbabits/mint-client
func genDocAddAccount(genDoc *stypes.GenesisDoc, pubKey account.PubKeyEd25519, amt int64, name string, perm, setbit ptypes.PermFlag, index int) {
	addr := pubKey.Address()
	acc := stypes.GenesisAccount{
		Address: addr,
		Amount:  amt,
		Name:    name,
		Permissions: &ptypes.AccountPermissions{
			Base: ptypes.BasePermissions{
				Perms:  perm,
				SetBit: setbit,
			},
		},
	}
	if index < 0 {
		genDoc.Accounts = append(genDoc.Accounts, acc)
	} else {
		genDoc.Accounts[index] = acc
	}
}